/*************************************************************** * * setup: * This function calls the airDensity, volumeBalloon, and setBurstAlt * functions which initializes the class * ***************************************************************/ void Predictor::setup ( ) { _balloon->setLand(_balloon->getLatestPoint().getAlt()); list<double> air = airDensity(); volumeBalloon ( air ); setAscentRatePre( ); setBurstAlt ( ); setupFile ( ); }
bool OWavPlayer::setup( const QString &filename ) { m_filename = filename; if( setupFile() ) return setupSoundDevice( false ); // playback else return false; }
void Logger::file(char *message, ...) { if (!SysSettings.SDCardInserted) return; // not possible to log without card char buff[20]; va_list args; va_start(args, message); if (!setupFile()) return; for (; *message != 0; ++message) { if (*message == '%') { ++message; if (*message == '\0') { break; } if (*message == '%') { buffPutChar(*message); continue; } if (*message == 's') { register char *s = (char *)va_arg(args, int); buffPutString(s); continue; } if (*message == 'd' || *message == 'i') { sprintf(buff, "%i", va_arg(args, int)); buffPutString(buff); continue; } if (*message == 'f') { sprintf(buff, "%f0.2", va_arg(args, double)); buffPutString(buff); continue; }
void setupRuntime() { HiddenClass::getRoot(); object_cls = new BoxedClass(NULL, 0, sizeof(Box), false); type_cls = new BoxedClass(object_cls, offsetof(BoxedClass, attrs), sizeof(BoxedClass), false); type_cls->cls = type_cls; object_cls->cls = type_cls; none_cls = new BoxedClass(object_cls, 0, sizeof(Box), false); None = new Box(&none_flavor, none_cls); str_cls = new BoxedClass(object_cls, 0, sizeof(BoxedString), false); // It wasn't safe to add __base__ attributes until object+type+str are set up, so do that now: type_cls->giveAttr("__base__", object_cls); str_cls->giveAttr("__base__", object_cls); none_cls->giveAttr("__base__", object_cls); object_cls->giveAttr("__base__", None); tuple_cls = new BoxedClass(object_cls, 0, sizeof(BoxedTuple), false); EmptyTuple = new BoxedTuple({}); gc::registerStaticRootObj(EmptyTuple); module_cls = new BoxedClass(object_cls, offsetof(BoxedModule, attrs), sizeof(BoxedModule), false); // TODO it'd be nice to be able to do these in the respective setupType methods, // but those setup methods probably want access to these objects. // We could have a multi-stage setup process, but that seems overkill for now. bool_cls = new BoxedClass(object_cls, 0, sizeof(BoxedBool), false); int_cls = new BoxedClass(object_cls, 0, sizeof(BoxedInt), false); float_cls = new BoxedClass(object_cls, 0, sizeof(BoxedFloat), false); function_cls = new BoxedClass(object_cls, offsetof(BoxedFunction, attrs), sizeof(BoxedFunction), false); instancemethod_cls = new BoxedClass(object_cls, 0, sizeof(BoxedInstanceMethod), false); list_cls = new BoxedClass(object_cls, 0, sizeof(BoxedList), false); slice_cls = new BoxedClass(object_cls, 0, sizeof(BoxedSlice), false); dict_cls = new BoxedClass(object_cls, 0, sizeof(BoxedDict), false); file_cls = new BoxedClass(object_cls, 0, sizeof(BoxedFile), false); set_cls = new BoxedClass(object_cls, 0, sizeof(BoxedSet), false); member_cls = new BoxedClass(object_cls, 0, sizeof(BoxedMemberDescriptor), false); STR = typeFromClass(str_cls); BOXED_INT = typeFromClass(int_cls); BOXED_FLOAT = typeFromClass(float_cls); BOXED_BOOL = typeFromClass(bool_cls); NONE = typeFromClass(none_cls); LIST = typeFromClass(list_cls); SLICE = typeFromClass(slice_cls); MODULE = typeFromClass(module_cls); DICT = typeFromClass(dict_cls); SET = typeFromClass(set_cls); BOXED_TUPLE = typeFromClass(tuple_cls); object_cls->giveAttr("__name__", boxStrConstant("object")); object_cls->giveAttr("__new__", new BoxedFunction(boxRTFunction((void*)objectNew, UNKNOWN, 1, 0, true, false))); object_cls->freeze(); auto typeCallObj = boxRTFunction((void*)typeCall, UNKNOWN, 1, 0, true, false); typeCallObj->internal_callable = &typeCallInternal; type_cls->giveAttr("__call__", new BoxedFunction(typeCallObj)); type_cls->giveAttr("__name__", boxStrConstant("type")); type_cls->giveAttr("__new__", new BoxedFunction(boxRTFunction((void*)typeNew, UNKNOWN, 2))); type_cls->giveAttr("__repr__", new BoxedFunction(boxRTFunction((void*)typeRepr, STR, 1))); type_cls->giveAttr("__str__", type_cls->getattr("__repr__")); type_cls->freeze(); none_cls->giveAttr("__name__", boxStrConstant("NoneType")); none_cls->giveAttr("__repr__", new BoxedFunction(boxRTFunction((void*)noneRepr, STR, 1))); none_cls->giveAttr("__str__", none_cls->getattr("__repr__")); none_cls->giveAttr("__hash__", new BoxedFunction(boxRTFunction((void*)noneHash, UNKNOWN, 1))); none_cls->freeze(); module_cls->giveAttr("__name__", boxStrConstant("module")); module_cls->giveAttr("__repr__", new BoxedFunction(boxRTFunction((void*)moduleRepr, STR, 1))); module_cls->giveAttr("__str__", module_cls->getattr("__repr__")); module_cls->freeze(); member_cls->giveAttr("__name__", boxStrConstant("member")); member_cls->freeze(); setupBool(); setupInt(); setupFloat(); setupStr(); setupList(); setupDict(); setupSet(); setupTuple(); setupFile(); function_cls->giveAttr("__name__", boxStrConstant("function")); function_cls->giveAttr("__repr__", new BoxedFunction(boxRTFunction((void*)functionRepr, STR, 1))); function_cls->giveAttr("__str__", function_cls->getattr("__repr__")); function_cls->freeze(); instancemethod_cls->giveAttr("__name__", boxStrConstant("instancemethod")); instancemethod_cls->giveAttr("__repr__", new BoxedFunction(boxRTFunction((void*)instancemethodRepr, STR, 1))); instancemethod_cls->freeze(); slice_cls->giveAttr("__name__", boxStrConstant("slice")); slice_cls->giveAttr("__new__", new BoxedFunction(boxRTFunction((void*)sliceNew, UNKNOWN, 4, 2, false, false), { NULL, None })); slice_cls->giveAttr("__repr__", new BoxedFunction(boxRTFunction((void*)sliceRepr, STR, 1))); slice_cls->giveAttr("__str__", slice_cls->getattr("__repr__")); slice_cls->giveAttr("start", new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, SLICE_START_OFFSET)); slice_cls->giveAttr("stop", new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, SLICE_STOP_OFFSET)); slice_cls->giveAttr("step", new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, SLICE_STEP_OFFSET)); slice_cls->freeze(); // sys is the first module that needs to be set up, due to modules // being tracked in sys.modules: setupSys(); setupBuiltins(); setupMath(); setupTime(); setupThread(); setupCAPI(); TRACK_ALLOCATIONS = true; }
MfgThresholdFile * MfgThresholdMgr::getMfgThresholdFile() { setupFile(); return iv_file; }
void Downloader::start() { // Fetch HEAD to find out the size but also if it exists. reply = getHead(url); if (!reply) { QCoreApplication::exit(-1); return; } url = reply->url(); // Find "Content-Length". If not found then it keeps operating (with // a single connection) not knowing the total size but it will // eventually be known from the first chunk progress information. bool ok; if (reply->hasRawHeader("Content-Length")) { contentLen = QString::fromUtf8(reply->rawHeader("Content-Length")).toLongLong(&ok); if (!ok || contentLen == 0) { qCritical() << "ERROR Invalid content length:" << contentLen; contentLen = -1; } } // Check if the total is different than the Content-Length and, if // so, then change to that number. if (reply->hasRawHeader("Content-Range")) { single = false; QString range = QString::fromUtf8(reply->rawHeader("Content-Range")); QStringList elms = range.split("/", QString::SkipEmptyParts); if (elms.size() == 2) { qint64 tot = elms[1].toLongLong(&ok); if (ok && tot > 0 && tot != contentLen) { contentLen = tot; } } } QString type; if (reply->hasRawHeader("Content-Type")) { type = QString::fromUtf8(reply->rawHeader("Content-Type")); int pos; if ((pos = type.indexOf(";")) != -1) { type = type.mid(0, pos); } } // Check if filename is defined. if (reply->hasRawHeader("Content-Disposition")) { QString hdr = QString::fromUtf8(reply->rawHeader("Content-Disposition")); int pos = hdr.indexOf("; filename="); if (pos != -1) { hdr = hdr.mid(pos + 11).trimmed(); if (hdr.startsWith("\"")) { hdr = hdr.mid(1); } if (hdr.endsWith("\"")) { hdr.chop(1); } if (!hdr.isEmpty()) { fileOverride = hdr; } } } QString fsize; if (contentLen == -1) { fsize = "Unknown"; } else { fsize = Util::formatSize(contentLen, 1); } qDebug() << "File size" << qPrintable(fsize) << qPrintable(!type.isEmpty() ? "[" + type + "]" : ""); // Check for header "Accept-Ranges" and whether it has "bytes" // supported. resumable = false; if (reply->hasRawHeader("Accept-Ranges")) { const QString ranges = QString::fromUtf8(reply->rawHeader("Accept-Ranges")); resumable = ranges.toLower().contains("bytes"); } if (verbose) { qDebug() << qPrintable(QString("%1RESUMABLE"). arg(resumable ? "" : "NOT ")); } if (!resumable && resume) { qCritical() << "ERROR Cannot resume because server doesn't support it!"; QCoreApplication::exit(-1); return; } else if (resumable && resume && contentLen == -1) { qCritical() << "ERROR Cannot resume because the content length is unknown!"; QCoreApplication::exit(-1); return; } // Clean reply. reply->close(); reply = nullptr; // If performing a dry run then stop now. if (dryRun) { emit finished(); return; } if (!setupFile()) { QCoreApplication::exit(-1); return; } createRanges(); setupThreadPool(); emit information(outputPath, contentLen, rangeCount, conns, offset); // Start actual download. download(); }
int main(int argc, char* argv[]) { // initialize globalArgs globalArgs.data_folder = " "; globalArgs.arg_pathToSetupFile = " "; globalArgs.results_folder = " "; globalArgs.save_all = 0; // Get paremeter from the command int opt =0; opt = getopt(argc, argv, optString); if(opt == -1){ std::cerr << "There is no opption in the command! Type \"output -h\" for help." << std::endl; exit(EXIT_FAILURE); } while(opt != -1){ switch(opt){ case 'd': globalArgs.data_folder= optarg; //std::cout<<"-p option path= "<<globalArgs.arg_pathToData<<std::endl; break; case 'S': globalArgs.arg_pathToSetupFile = optarg; break; case 'o': globalArgs.results_folder = optarg; break; case 'a': globalArgs.save_all = 1; break; case 'h': case '?': std::cerr << "Usage: output -d pathToData -S pathToSetupFile -o pathToResultsFolder [-a]" << std::endl; std::cerr << "----------------------------------------------------------------------------------------------------"<<std::endl; std::cerr << " '-d'+'-S'+'-o' options are necessary!"<<std::endl; std::cerr << "-----------------------------------------------------------------------------------------------------"<<std::endl; std::cerr << " use '-a' option afterwards to save all the plots of the analysis to further check."<<std::endl; std::cerr << "-----------------------------------------------------------------------------------------------------"<<std::endl; std::cerr << "Example: ./output -d /Users/Analysis_waveforms/ov_scan_pde_H2014/ -S /Users/Analysis_waveforms/config_file.txt -o /Users/Analysis_waveforms/Plots/ [-a]"<<std::endl; exit(EXIT_FAILURE); break; default: break; } opt = getopt(argc, argv, optString); } if((strncmp(globalArgs.data_folder," ",1) == 0|| strncmp(globalArgs.arg_pathToSetupFile," ",1) == 0)){ std::cerr << "ERROR: -d or -S option is not set! Both of them has to be set correctly!"<<std::endl; exit(EXIT_FAILURE); } if(strncmp(globalArgs.results_folder," ",1) == 0){ std::cerr << "ERROR: -o option is not set! It has to be set up correctly!"<<std::endl; exit(EXIT_FAILURE); } ifstream setupFile(globalArgs.arg_pathToSetupFile); if(!setupFile){ std::cerr << "Failure: could not open file: \"" << globalArgs.arg_pathToSetupFile << "\"." << std::endl; std::cerr << "Please check if the path is correct or not!" << std::endl; exit(EXIT_FAILURE); } //////////////// //Define thresholds //////////////// //in nanoseconds const double reject_time = 4; vector <Double_t> reject_time_v; //used for AP, delayed x-talk and long tau fit //in percentage of pe const double after_pulse_th = 0.38; vector <Double_t> after_pulse_th_v; const double direct_xtalk_th = 1.17; vector <Double_t> direct_xtalk_th_v; const double xtalk_th = 0.85; vector <Double_t> xtalk_th_v; const double time_dist_th = 0.4; vector <Double_t> time_dist_th_v; //////////////// //////////////// //Read setup file: string s; vector <TString> vol_folders; Int_t data_size; while (true) { Double_t rt; Double_t ap; Double_t delay; Double_t imme; getline(setupFile, s); if (setupFile.eof()) break; const char* searchString = s.c_str(); char volt [20]; Int_t numfiles; if (s.find("#") == 0 || s=="") { continue; // Skip commented or empty lines } //Find the voltages if(sscanf(searchString, "V || %s ||", volt)==1){ vol_folders.push_back(volt); reject_time_v.push_back(reject_time); after_pulse_th_v.push_back(after_pulse_th); direct_xtalk_th_v.push_back(direct_xtalk_th); xtalk_th_v.push_back(xtalk_th); time_dist_th_v.push_back(time_dist_th); } if(sscanf(searchString, "V/th || %s ||", volt)==1){ vol_folders.push_back(volt); getline(setupFile, s); const char* thresholds_string = s.c_str(); sscanf(thresholds_string, "Rej_t: %lf, AP_th: %lf, Delay_th: %lf, Imm_th: %lf", &rt,&ap,&delay,&imme); reject_time_v.push_back(rt); after_pulse_th_v.push_back(ap); direct_xtalk_th_v.push_back(imme); xtalk_th_v.push_back(delay); time_dist_th_v.push_back(time_dist_th); } //Find data size if(sscanf(searchString, "Files at each voltage || %d ||", &numfiles)==1){ data_size = numfiles; } } //Initialize variables const Int_t vol_size = vol_folders.size(); int singleplot=0; Int_t Event=0; Char_t Category[15]; TGraph* waveform = 0; Double_t Amp; Double_t V_meas; double pe = 0.07; int row = 0; int full_n_file = 0; int ap_n_file = 0; int xtalk_n_file = 0; int dxtalk_n_file = 0; int time_dist_n_file = 0; int direct_xtalk_pulse; Double_t direct_xtalk_pulse_cnt=0; int xtalk_pulse; Double_t xtalk_pulse_cnt = 0; int after_pulse; Double_t after_pulse_cnt=0; Double_t event_cnt = 0; double sig_max = 0; double time_of_max = 0; double sig_max_first = 0; double time_of_max_first = 0; int max_cnt = 0; int max_noise_cnt = 0; int max_found = 0; /*const char * Voltage="56.5V"; int event=0; if (singleplot) { single_plot(Voltage,event); }*/ //Create a root tree with the graph of the waveform of each event and //classify them TString filename = globalArgs.results_folder; filename.Append("noiseanalysis.root"); TFile *hfile = 0; hfile = TFile::Open(filename,"RECREATE"); TTree *tree = new TTree("T","Noise Analysis"); tree->Branch("Event",&Event,"Event/I"); tree->Branch("Category",Category,"Category/C"); //Uncomment if every single waveform is desired to be saved by its own on the root file //tree->Branch("waveform","TGraph",&waveform); tree->Branch("V_meas",&V_meas,"V_meas/D"); //OV of the measurement TGraph* Correl_noise[4]; Correl_noise[0] = new TGraph(); Correl_noise[1] = new TGraph(); Correl_noise[2] = new TGraph(); Correl_noise[3] = new TGraph(); TGraph *Expfit_longtau[vol_size]; TGraph *Expfit_AP[vol_size]; //Fiting functions of long tau and AP recharge TF1 *exp_longtau= new TF1("exptau","[0]*exp(-x/[1])",0,180 * ns); TF1 *exp= new TF1("exp","[0]*(1-exp(-x/[1]))+[2]*exp(-x/[3])",0,180 * ns); TCanvas* c1[vol_size]; TCanvas* c2[vol_size]; TCanvas* c3[vol_size]; TCanvas* c4[vol_size]; TMultiGraph *Cleanwaves[vol_size]; TCanvas* expfit_longtau_c[vol_size]; TCanvas* expfit_AP_c[vol_size]; cout<<"////////////"<< endl; cout<<"****----->Voltage Breakdown calculation ***"<< endl; vector <Double_t> pe_volt; TGraph *Vbias_ver= new TGraph(); //Change to not recalculate the pe //pe_volt.push_back(6.87435e-02); /*pe_volt.push_back( 1.20426e-01); pe_volt.push_back(1.75262e-01); pe_volt.push_back(2.30936e-01); pe_volt.push_back(2.87958e-01);*/ //pe_volt.push_back( 3.44156e-01); //Double_t VBD=55.9006; //Calculate Voltage breakdown and value of pe for (int i=0; i<vol_size; i++) { pe_volt.push_back(Amplitude_calc(vol_folders.at(i).Data(), data_size)); V_meas = vol_folders.at(i).Atof(); Vbias_ver->SetPoint(i, pe_volt.at(i), V_meas); } TCanvas* ca= new TCanvas("Voltage Breakdown calculation","Voltage Breakdown calculation",100,100,900,700); Vbias_ver->SetTitle("Voltage Breakdown calculation"); Vbias_ver->GetYaxis()->SetTitle("Bias Volatge [V]"); Vbias_ver->GetYaxis()->SetTitleOffset(1.2); Vbias_ver->GetXaxis()->SetTitle("Mean peak amplitude [V]"); Vbias_ver->Draw("AP*"); ca->SetGrid(); TPaveText * pv = new TPaveText(0.2,0.65,0.35,0.74,"brNDC"); cout<<"////////////"<< endl; cout<<"****----->Voltage Breakdown fit ***"<< endl; TFitResultPtr fit = Vbias_ver->Fit("pol1","S"); Double_t VBD= fit->Value(0); Char_t VBD_text[20]; sprintf(VBD_text,"V_{BD} = %2.2f",VBD); pv->AddText(VBD_text); pv->Draw(); if (globalArgs.save_all==1) ca->Write(); cout<<"////////////"<< endl; cout<<"****----->Noise analysis ***"<< endl; cout<<"////////////"<< endl; ///////////////// // Loop over all Voltages measured ///////////////// for (int i=0; i<vol_size; i++) { //Important to reinitialize, the value color* = kOrange-11 is used to plot axis of TGraph() int color1 = kOrange-11; int color2 = kOrange-11; int color3 = kOrange-11; int color4 = kOrange-11; direct_xtalk_pulse_cnt = 0; xtalk_pulse_cnt = 0; after_pulse_cnt = 0; event_cnt = 0; //Events on the Voltage measured cout<<"****----->Voltage analyzed: "<< vol_folders.at(i) << endl; //Define amplitude measured at which OV Double_t pe = pe_volt.at(i); V_meas = vol_folders.at(i).Atof()-VBD; //Define canvases to save and check results Char_t canvas_title[40]; sprintf(canvas_title,"Direct CrossTalk OV = %2.2f V",V_meas); c1[i] = new TCanvas(canvas_title,canvas_title,100,100,900,700); sprintf(canvas_title,"Delayed CrossTalk OV = %2.2f V",V_meas); c2[i] = new TCanvas(canvas_title,canvas_title,100,100,900,700); sprintf(canvas_title,"After Pulse OV = %2.2f V",V_meas); c3[i] = new TCanvas(canvas_title,canvas_title,100,100,900,700); sprintf(canvas_title,"Clean OV = %2.2f V",V_meas); c4[i] = new TCanvas(canvas_title,canvas_title,100,100,900,700); Cleanwaves[i]=new TMultiGraph(); sprintf(canvas_title,"Exponential fit, #tau_l OV = %2.2f V",V_meas); expfit_longtau_c[i] = new TCanvas(canvas_title,canvas_title,300,100,900,500); sprintf(canvas_title,"Exponential fit OV = %2.2f V",V_meas); expfit_AP_c[i] = new TCanvas(canvas_title,canvas_title,300,100,900,500); Expfit_longtau[i]= new TGraph(); Expfit_AP[i]= new TGraph(); //loop over every measurement on a folder for (int j=0; j<data_size; j++) { Char_t datafilename[200]; Char_t datashortfilename[100]; sprintf(datafilename,"%s%s/C1H%05i.csv",globalArgs.data_folder,vol_folders.at(i).Data(),j); sprintf(datashortfilename,"%s_C1H%05i",vol_folders.at(i).Data(),j); //Get the data of a single file: waveform = new TGraph(datafilename,"%lg %lg","/t;,"); if (waveform->IsZombie()) continue; waveform->SetName(datashortfilename); waveform->SetTitle(""); Int_t ROWS_DATA = waveform->GetN(); Double_t *time = waveform->GetX(); Double_t *volts = waveform->GetY(); Amp = waveform->GetY()[0]; ///////////////////////////////////////////////////// // Data filtering into the different type of events // direct x-talk AP delayed x-talk ///////////////////////////////////////////////////// after_pulse = 0; xtalk_pulse = 0; direct_xtalk_pulse = 0; sig_max = 0; max_cnt = 0; max_found = 0; ///////////////////////////////////////////////////// // direct x-talk for (row = 0; row < ROWS_DATA; row++) { if ((time[row]>0 * ns)&(volts[row] > direct_xtalk_th_v.at(i) * pe)) {// time larger 0ns direct_xtalk_pulse++; } } ///////////////////////////////////////////////////// // after-pulse threshold for (row = 0; row < ROWS_DATA; row++) { if ((time[row]>reject_time_v.at(i)*ns)&(volts[row] > after_pulse_th_v.at(i) * pe)) {// time larger 4ns and ap_th after_pulse++; } } ///////////////////////////////////////////////////// // delayed x-talk for (row = 0; row < ROWS_DATA; row++) { if ((time[row]>reject_time_v.at(i)*ns)&(volts[row] > xtalk_th_v.at(i) * pe)) {// time larger 4ns and larger xtalk_th xtalk_pulse++; } } ///////////////////////////////////////////////////////////////////// // Detect peaks in data after 4ns, count the number of maxima and // measure the time of arrival of first maxima, used later for AP exp fit ///////////////////////////////////////////////////////////////////// max_noise_cnt = 0; for (row = 0; row < ROWS_DATA; row++) { if (time[row] > reject_time_v.at(i)*ns) {// time larger 4ns if (volts[row] > sig_max) { sig_max = volts[row]; // set the max time_of_max = time[row]; // time max max_noise_cnt++; // set the histeresis cnt }else if (max_noise_cnt > 0) max_noise_cnt--; // count down if no new max is reached // decide if real max or only noise, threshold has to be reached in case of a real max if (max_noise_cnt>2 && sig_max > time_dist_th_v.at(i) * pe) { max_cnt++; if (max_cnt == 1) { sig_max_first = sig_max; // sig max time_of_max_first = time_of_max; // time max max_found = 1; //printf("First max found: sig=%f time=%f ns max_noise_cnt=%d\n", sig_max, time_of_max / ns, max_noise_cnt); } //printf("Max number is: %d cnt=%d\n", max_cnt, max_noise_cnt); } } // 4ns } //loop over time bool clean = true; //The pulse is clean until the contrary can be demonstrated char graph_title[50]; //Check for imm x-talk and plot if (direct_xtalk_pulse > 0){ direct_xtalk_pulse_cnt++; sprintf(Category,"ImmCrosstalk"); c1[i]->cd(); //Set graph color, and counting to draw axis and title color1=color1+2; if (color1>kOrange+110) { color1=kOrange-8; }else if (color1>kOrange+109){ color1=kOrange-7; } waveform->SetLineColor(color1); waveform->SetMarkerColor(color1); //Format the graph sprintf(graph_title,"Direct CrossTalk OV = %2.2f V",V_meas); waveform = format_graph(waveform,graph_title,2.5*pe); if (color1>kOrange-8) { waveform->Draw("SAME"); }else{ waveform->Draw("AL"); c1[i]->SetGrid(); } clean = false; } // only delayed x-talk if (xtalk_pulse > 0 && direct_xtalk_pulse == 0){ xtalk_pulse_cnt++; sprintf(Category,"DelCrosstalk"); c2[i]->cd(); //Set graph color, and counting to draw axis and title color2=color2+2; if (color2>kOrange+110) { color2=kOrange-8; }else if (color2>kOrange+109){ color2=kOrange-7; } waveform->SetLineColor(color2); waveform->SetMarkerColor(color2); //Format the graph sprintf(graph_title,"Delayed cross-talk OV = %2.2f V",V_meas); waveform = format_graph(waveform,graph_title,1.2*pe); if (color2>kOrange-8) { waveform->Draw("SAME"); }else{ waveform->Draw("AL"); c2[i]->SetGrid(); } clean = false; } // Only after pulse if (after_pulse > 0 && xtalk_pulse == 0 && direct_xtalk_pulse == 0){ after_pulse_cnt++; sprintf(Category,"AfterPulse"); c3[i]->cd(); //Set graph color, and counting to draw axis and title color3=color3+2; if (color3>kOrange+110) { color3=kOrange-8; }else if (color3>kOrange+109){ color3=kOrange-7; } waveform->SetLineColor(color3); waveform->SetMarkerColor(color3); //Format the graph sprintf(graph_title,"After pulse OV = %2.2f V",V_meas); waveform = format_graph(waveform,graph_title,1.2*pe); if (color3>kOrange-8) { waveform->Draw("SAME"); }else{ waveform->Draw("AL"); c3[i]->SetGrid(); } clean = false; //Fill for the exponential fit Expfit_AP[i]->SetPoint(after_pulse_cnt-1,time_of_max,sig_max); } // Only clean graphs for the sample if (clean){ sprintf(Category,"Clean"); if (color4 < 860 && j <100) { //Max 100 clean graphs on the plot Cleanwaves[i]->Add(waveform); c4[i]->cd(); //Set graph color, and counting to draw axis and title color4=color4+2; if (color4>kOrange+110) { color4=kOrange-8; }else if (color4>kOrange+109){ color4=kOrange-7; } waveform->SetLineColor(color4); waveform->SetMarkerColor(color4); //Format the graph sprintf(graph_title,"Clean pulse OV = %2.2f V",V_meas); waveform = format_graph(waveform,graph_title,1.2*pe); if (color4>kOrange-8) { waveform->Draw("SAME"); }else{ waveform->Draw("AL"); c4[i]->SetGrid(); } } } tree->Fill(); Event ++;//Total number of events analyzed on the run if (Event%500==0) { cout<<"****----->Events analyzed:"<< Event << endl; } event_cnt++; } cout<<"////////////"<< endl; cout<<"****----->Long tau fit ***"<< endl; expfit_longtau_c[i]->cd(); Cleanwaves[i]->Draw("AP*"); // Fit parameters and limits to calculate slow component of the pulse exp_longtau->SetParameter(0,pe*0.2); exp_longtau->SetParLimits(0,0.05*pe,0.5*pe); exp_longtau->SetParameter(1,80*ns); exp_longtau->SetParLimits(1,4*ns,200*ns); Cleanwaves[i]->Fit("exptau","","",reject_time_v.at(i)*ns,60*ns); // Fit boundaries for the slow component of the pulse Double_t amp0 = exp_longtau->GetParameter(0); Double_t tau = exp_longtau->GetParameter(1); if (globalArgs.save_all==1) expfit_longtau_c[i]->Write(); c4[i]->cd(); TF1* exp_tau_plot =(TF1*) exp_longtau->Clone(); exp_tau_plot->Draw("SAME");//Draw fit-line over clean waveforms cout<<"////////////"<< endl; cout<<"****----->After pulse fit ***"<< endl; expfit_AP_c[i]->cd(); Expfit_AP[i]->Draw("AP*"); // Fit parameters and limits to calculate AP recharge exp->SetParameter(0,pe); exp->SetParLimits(0,0.5*pe,1.5*pe); exp->SetParameter(1,30*ns); exp->SetParLimits(1,4*ns,500*ns); exp->SetParameter(2,amp0); exp->FixParameter(2,amp0); exp->SetParameter(3,tau); exp->FixParameter(3,tau); Expfit_AP[i]->Fit("exp"); if (globalArgs.save_all==1) expfit_AP_c[i]->Write(); c3[i]->cd(); TF1* exp_plot =(TF1*) exp->Clone(); exp_plot->Draw("SAME"); //Draw fit-line over AP waveforms //Final result: Correlated noise Correl_noise[0]->SetPoint(i,V_meas,direct_xtalk_pulse_cnt/event_cnt*100); Correl_noise[1]->SetPoint(i,V_meas,after_pulse_cnt/event_cnt*100); Correl_noise[2]->SetPoint(i,V_meas,xtalk_pulse_cnt/event_cnt*100); Correl_noise[3]->SetPoint(i,V_meas, Correl_noise[0]->GetY()[i]+Correl_noise[1]->GetY()[i]+Correl_noise[2]->GetY()[i]); //Save/print reults: if (globalArgs.save_all==1){ c1[i]->Write(); c2[i]->Write(); c3[i]->Write(); c4[i]->Write(); } sprintf(canvas_title,"%sImmcrosstalk_%s.pdf",globalArgs.results_folder,vol_folders.at(i).Data()); c1[i]->Print(canvas_title,"pdf"); sprintf(canvas_title,"%sDelcrosstalk_%s.pdf",globalArgs.results_folder,vol_folders.at(i).Data()); c2[i]->Print(canvas_title,"pdf"); sprintf(canvas_title,"%sAfterpulse_%s.pdf",globalArgs.results_folder,vol_folders.at(i).Data()); c3[i]->Print(canvas_title,"pdf"); sprintf(canvas_title,"%sClean_%s.pdf",globalArgs.results_folder,vol_folders.at(i).Data()); c4[i]->Print(canvas_title,"pdf"); } //Save TTree with hist of noise //Save each event with its OV and the noise classification tree->Write(); //Create final plot of total correlated noise TCanvas* c5 = new TCanvas("Correlated Noise","Correlated Noise",100,100,900,700); Double_t tot_max_noise = TMath::MaxElement(Correl_noise[3]->GetN(),Correl_noise[3]->GetY()); Correl_noise[3]->SetTitle("Correlated Noise"); Correl_noise[3]->SetMarkerColor(kRed); Correl_noise[3]->SetLineColor(kRed); Correl_noise[3]->GetYaxis()->SetRangeUser(0,tot_max_noise+2); Correl_noise[3]->GetYaxis()->SetTitle("Noise [%]"); Correl_noise[3]->GetXaxis()->SetTitle("OverVoltage [V]"); Correl_noise[3]->Draw("ALP*"); Correl_noise[0]->SetTitle("Direct Cross-Talk"); Correl_noise[1]->SetTitle("After Pulse"); Correl_noise[2]->SetTitle("Delayed Cross-Talk"); Correl_noise[0]->SetLineColor(kBlue); Correl_noise[1]->SetLineColor(kOrange+7); Correl_noise[2]->SetLineColor(kGreen+2); Correl_noise[0]->SetMarkerColor(kBlue); Correl_noise[1]->SetMarkerColor(kOrange+7); Correl_noise[2]->SetMarkerColor(kGreen+2); Correl_noise[0]->Draw("LP*"); Correl_noise[1]->Draw("LP*"); Correl_noise[2]->Draw("LP*"); TLegend* leg = new TLegend(0.15,0.65,0.47,0.87); leg->AddEntry(Correl_noise[3],"Total","lp"); leg->AddEntry(Correl_noise[0],"Direct Cross-Talk","lp"); leg->AddEntry(Correl_noise[1],"After Pulse","lp"); leg->AddEntry(Correl_noise[2],"Delayed Cross-Talk","lp"); leg->Draw(); c5->SetGrid(); TString final_plot_name = globalArgs.results_folder; final_plot_name.Append("Correlated Noise.pdf"); c5->Print(final_plot_name,"pdf"); c5->Write(); delete hfile; return 0; }
void setupRuntime() { HiddenClass::getRoot(); type_cls = new BoxedClass(true, NULL); type_cls->cls = type_cls; none_cls = new BoxedClass(false, NULL); None = new Box(&none_flavor, none_cls); gc::registerStaticRootObj(None); module_cls = new BoxedClass(true, NULL); bool_cls = new BoxedClass(false, NULL); int_cls = new BoxedClass(false, NULL); float_cls = new BoxedClass(false, NULL); str_cls = new BoxedClass(false, (BoxedClass::Dtor)str_dtor); function_cls = new BoxedClass(true, NULL); instancemethod_cls = new BoxedClass(false, (BoxedClass::Dtor)instancemethod_dtor); list_cls = new BoxedClass(false, (BoxedClass::Dtor)list_dtor); slice_cls = new BoxedClass(true, NULL); dict_cls = new BoxedClass(false, (BoxedClass::Dtor)dict_dtor); tuple_cls = new BoxedClass(false, (BoxedClass::Dtor)tuple_dtor); file_cls = new BoxedClass(false, (BoxedClass::Dtor)file_dtor); STR = typeFromClass(str_cls); BOXED_INT = typeFromClass(int_cls); BOXED_FLOAT = typeFromClass(float_cls); BOXED_BOOL = typeFromClass(bool_cls); NONE = typeFromClass(none_cls); LIST = typeFromClass(list_cls); SLICE = typeFromClass(slice_cls); MODULE = typeFromClass(module_cls); DICT = typeFromClass(dict_cls); BOXED_TUPLE = typeFromClass(tuple_cls); type_cls->giveAttr("__name__", boxStrConstant("type")); type_cls->giveAttr("__call__", new BoxedFunction(boxRTFunction((void*)typeCall, NULL, 1, true))); type_cls->giveAttr("__new__", new BoxedFunction(boxRTFunction((void*)typeNew, NULL, 2, true))); type_cls->giveAttr("__repr__", new BoxedFunction(boxRTFunction((void*)typeRepr, NULL, 1, true))); type_cls->setattr("__str__", type_cls->peekattr("__repr__"), NULL, NULL); type_cls->freeze(); none_cls->giveAttr("__name__", boxStrConstant("NoneType")); none_cls->giveAttr("__repr__", new BoxedFunction(boxRTFunction((void*)noneRepr, NULL, 1, false))); none_cls->setattr("__str__", none_cls->peekattr("__repr__"), NULL, NULL); none_cls->freeze(); module_cls->giveAttr("__name__", boxStrConstant("module")); module_cls->giveAttr("__repr__", new BoxedFunction(boxRTFunction((void*)moduleRepr, NULL, 1, false))); module_cls->setattr("__str__", module_cls->peekattr("__repr__"), NULL, NULL); module_cls->freeze(); setupBool(); setupInt(); setupFloat(); setupStr(); setupList(); setupDict(); setupTuple(); setupFile(); function_cls->giveAttr("__name__", boxStrConstant("function")); function_cls->giveAttr("__repr__", new BoxedFunction(boxRTFunction((void*)functionRepr, NULL, 1, false))); function_cls->setattr("__str__", function_cls->peekattr("__repr__"), NULL, NULL); function_cls->freeze(); instancemethod_cls->giveAttr("__name__", boxStrConstant("instancemethod")); instancemethod_cls->giveAttr("__repr__", new BoxedFunction(boxRTFunction((void*)instancemethodRepr, NULL, 1, true))); instancemethod_cls->freeze(); slice_cls->giveAttr("__name__", boxStrConstant("slice")); slice_cls->giveAttr("__repr__", new BoxedFunction(boxRTFunction((void*)sliceRepr, NULL, 1, true))); slice_cls->setattr("__str__", slice_cls->peekattr("__repr__"), NULL, NULL); slice_cls->freeze(); setupMath(); gc::registerStaticRootObj(math_module); setupTime(); gc::registerStaticRootObj(time_module); setupBuiltins(); gc::registerStaticRootObj(builtins_module); setupCAPI(); TRACK_ALLOCATIONS = true; }
// ###################################################################### // Parse the scene setup file found in the given path SceneSetup loadSceneSetup(const int id) { SceneSetup setup; setup.setupPath = sceneDir; std::string setupFileName = setup.setupPath + "/" + sformat("%04d.txt", id); std::ifstream setupFile(setupFileName.c_str()); if (!setupFile.is_open()) LFATAL("Could not open setup file: %s", setupFileName.c_str()); std::string line; try { //SetupNumber getline(setupFile, line); setup.setupNum = boost::lexical_cast<int>(line.substr(line.find("=")+1)); //BackgroundIndex getline(setupFile, line); setup.backgroundIdx = boost::lexical_cast<int>(line.substr(line.find("=")+1)); //BackgroundFileName getline(setupFile, line); setup.backgroundFileName = line.substr(line.find("=")+1); //PathIndex getline(setupFile, line); std::vector<std::string> tok; split(line.substr(line.find("=")+1), ",", std::back_inserter(tok)); for (size_t ii = 0; ii < tok.size(); ++ii) setup.pathIndex.push_back(boost::lexical_cast<int>(tok[ii])); //NumberOfObjects getline(setupFile, line); int numObjects = boost::lexical_cast<int>(line.substr(line.find("=")+1)); for(int i=0; i<numObjects; ++i) { SceneSetup::Object obj; //TrayFileName getline(setupFile, line); obj.trayFileName = line.substr(line.find("=")+1); //TrayName size_t s = obj.trayFileName.find_last_of('/'); size_t e = obj.trayFileName.find_last_of('.'); obj.trayName = obj.trayFileName.substr(s+1, e-s-1); //TrayColumn getline(setupFile, line); obj.trayColumn = boost::lexical_cast<int>(line.substr(line.find("=")+1)); //TrayRow getline(setupFile, line); obj.trayRow = boost::lexical_cast<int>(line.substr(line.find("=")+1)); //XOnTray getline(setupFile, line); obj.trayX = boost::lexical_cast<float>(line.substr(line.find("=")+1)); //YOnTray getline(setupFile, line); obj.trayY = boost::lexical_cast<float>(line.substr(line.find("=")+1)); setup.objects.push_back(obj); } } catch(boost::bad_lexical_cast& e) { LFATAL("Error Parsing Setup File (%s) [%s] -- Offending Line: %s", setupFileName.c_str(), e.what(), line.c_str()); } return setup; }