bool Manager::delete_interface(const std::string& name, bool send_model_signal) { Prefixed_name split = split_name(name); if( split.second == "" ) { // if we're at the end of the path InterfaceMap::iterator it_row = interfaces_.find(split.first); if(it_row == interfaces_.end() ) { appli_warning( split.first << " does not exist" << std::endl ); return false; } if(send_model_signal && model_) { model_->begin_remove_item(this,std::distance(interfaces_.begin(), it_row)); } int n = interfaces_.erase(split.first); if(send_model_signal && model_) model_->end_remove_item(); return true; } else { // go down one level of the tree, if it exists SmartPtr<Directory> subdir = get_subdir( split.first ); if( subdir.raw_ptr() == 0 ) return false; else return subdir->delete_interface( split.second, send_model_signal ); } }
int find_num_ext(char *name, int mode) { char tmp_name[CCHMAXPATHCOMP]; char tmp_ext[CCHMAXPATHCOMP]; int name_offset; char *ext_offset; int ext_num; strcpy(tmp_name, name); name_offset=split_name(tmp_name, NULL, NULL); if((ext_offset=strchr(&tmp_name[name_offset], '.'))==NULL) strcat(tmp_name, ext_digits); else { strcpy(tmp_ext, ext_offset); /* Remember the original extension */ strcpy(ext_offset, ext_digits); /* Substitute extension */ if(mode==EXT_INSERT) strcat(tmp_name, tmp_ext); /* Complete with original extension */ } for(ext_num=0; ext_num<999; ext_num++) { sprintf(name, tmp_name, ext_num); if(!file_exists(name)) return(0); } msg_cprintf(0, M_EXISTS, name); return(-1); }
boolean cmp_wildcard(const char *fname, const char *wildcard) { #if _MINT_ /* HR 151102 */ return match_pattern(fname,wildcard); /* HR 051202: courtesy XaAES */ #else { char name[10], ext[4], wname[10], wext[4]; split_name(name, ext, fname); split_name(wname, wext, wildcard); if (cmp_part(name, wname) == FALSE) return FALSE; return cmp_part(ext, wext); } #endif }
Named_interface* Manager::new_interface_raw(const std::string& type_param, const std::string& name ) { // Look for the required manager and create the new interface without smart pointer. // The memory allocated is not managed, it is the user to delete it when not needed // If no factory method can be found to create the interface, look // for a plugin that would provide a factory method. Prefixed_name split = split_name(name); if( split.second == "" ) { // we're at the end of the path //---------- // Extract the type of the object to be created // and the parameters for the creation. These information are // contained in string "type_param" String_Op::string_pair split_params = String_Op::split_string( type_param, "://", true ); std::string type = split_params.first; std::string param = split_params.second; CallBackMap::iterator it = factory_.find(type); if( it == factory_.end() ) { // No factory method found => try loading a plugin bool loaded = load_library( type ); if( loaded ) it = factory_.find(type); } if( it == factory_.end() ) { // No factory method could be found, and no plugin provides a // suitable one appli_warning( "No factory method to create type " << type << std::endl << "Interface ..." << name << " could not be created" << std::endl ); return 0; } // If we've reached this point, it means we have a factory method // to create the requested interface. std::pair<InterfaceMap::iterator, bool> pos; return (it->second)( param ); } else { // we're not at the end of the path. // go down one level of the tree, if it exists, and try again SmartPtr<Directory> subdir = get_subdir( split.first ); if( subdir.raw_ptr() == 0 ) { appli_warning( "Could not descend into directory " << split.first << std::endl ); return 0; } else return subdir->new_interface_raw( type_param, split.second ); } }
int main() { std::string name; while( true ) { cin >> name; Prefixed_name s = split_name(name); std::cout << "'" << s.first << "' '" << s.second << "'" << std::endl; } }
void parse_reg_key() { char *nptr; char key_path[FILENAME_MAX]; char key[200]; FILE *stream; if(regdata[REG_NAME_SHIFT]=='\0') { #ifndef SKIP_GET_EXE_NAME nptr=exe_name; #if TARGET==DOS if(0) nptr=default_key_name; #endif split_name(nptr, key_path, NULL); strcat(key_path, key_name); #else split_name(exe_name, key_path, NULL); /* Hack for PACKAGER */ strcat(key_path, key_name); /* Hack for PACKAGER */ if(!file_exists(key_path)) sprintf(key_path, "%s/.%s", getenv("HOME"), key_name); if(!file_exists(key_path)) sprintf(key_path, "/etc/%s", key_name); #endif if(file_exists(key_path)) { if((stream=fopen(key_path, m_r))!=NULL) { if(fgets(key, sizeof(key), stream)==NULL) fclose(stream); else { fclose(stream); hot_reg(key); } } } } }
int main (int argc , char **argv) { { if (argc <= 2) { fprintf(stderr,"rms_extract.x filename tag1(=new_tag1) tag2 ... \n"); abort(); } } { const char * filename = argv[1]; int i; rms_tag_type * dim_tag; rms_file_type *file = rms_file_alloc(filename , false); printf("Skal laste inn file: %s \n",filename); rms_file_fread(file); dim_tag = rms_file_get_dim_tag_ref(file); for (i = 2; i < argc; i++) { char * new_name; char * old_name; char * new_file; split_name(argv[i] , &old_name , &new_name); printf("Exctracting %s -> %s \n" , old_name , new_name); fflush(stdout); new_file = util_alloc_filename(NULL , new_name , "ROFF"); { rms_tag_type * tag; rms_file_type * out_file = rms_file_alloc(new_file , false); FILE *stream = rms_file_fopen_w(out_file); rms_file_init_fwrite(out_file , "parameter"); rms_tag_fwrite(dim_tag , stream); tag = rms_file_get_tag_ref(file , "parameter" , "name" , old_name , true); rms_tag_fwrite_parameter(new_name, rms_tag_get_datakey(tag) , stream); rms_file_complete_fwrite(out_file); fclose(stream); } if (new_name == old_name) free(new_name); else { free(new_name); free(old_name); } } rms_file_free(file); return 0; } }
param_kind get_kind_in_module(symbol & name) const { param_kind k = get_kind(name); symbol prefix, suffix; if (k == CPK_INVALID && split_name(name, prefix, suffix)) { k = get_kind(suffix); if (k != CPK_INVALID) { if (symbol(get_module(suffix)) == prefix) { name = suffix; } else { k = CPK_INVALID; } } } return k; }
/* * Add a key and its data to the registry */ static void addkey(char *name, DWORD type, char *value, int datalen) { HKEY root; char *kname; /* Key name */ char *vname; /* Value name */ char rname[100]; HKEY key; LONG ret; char *s, *d; if (o_verify) return; kname = split_name(name, &root, rname); /* Locate last backslash, ignoring and fixing escaped ones */ vname = NULL; for (s = d = kname + strlen(kname) - 1; s >= kname; s--, d--) { *d = *s; if (*s == '\\') if (s != kname && s[-1] == '\\') s--; else { vname = d; *s = '\0'; break; } } if (vname) { *vname = '\0'; vname++; } if ((ret = RegCreateKeyEx(root, kname, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key, NULL)) != ERROR_SUCCESS) wperror("RegCreateKeyEx", ret); if (type != REG_NONE) if ((ret = RegSetValueEx(key, vname, 0, type, value, datalen)) != ERROR_SUCCESS) wperror("RegSetValueEx", ret); if ((ret = RegCloseKey(key)) != ERROR_SUCCESS) wperror("RegCloseKey", ret); if (remote && (ret = RegCloseKey(root)) != ERROR_SUCCESS) wperror("RegCloseKey", ret); }
main(int argc, char *argv[]) { int c; while ((c = getopt(argc, argv, "F:ntvcdr:i")) != EOF) switch (c) { case 'F': if (!optarg || optarg[1]) usage(argv[0]); field_sep = *optarg; break; case 'r': if (!optarg) usage(argv[0]); remote = strdup(optarg); break; case 'n': o_print_name = 0; break; case 't': o_print_type = 0; break; case 'v': o_print_value = 0; break; case 'c': o_verify = 1; break; case 'd': o_print_decimal = 1; break; case 'i': o_ignore_error = 1; break; case '?': usage(argv[0]); } if (argv[optind] != NULL) { LONG ret; if (argv[optind + 1] != NULL) usage(argv[0]); /* Dump a key */ print_registry(split_name(argv[optind], &rootkey, rootname)); if (remote && (ret = RegCloseKey(rootkey)) != ERROR_SUCCESS) wperror("RegCloseKey", ret); } else /* Read input and add keys */ input_process(); return (0); }
SmartPtr<Named_interface> Manager::interface(const std::string& name) { Prefixed_name split = split_name(name); if( split.second == "" ) { // if we're at the end of the path InterfaceMap::iterator it = interfaces_.find(split.first); if( it != interfaces_.end() ) { // if we found an object called "name" return it->second; } else return 0; } else { // go down one level of the tree, if it exists SmartPtr<Directory> subdir = get_subdir( split.first ); if( subdir.raw_ptr() == 0 ) return 0; else return subdir->interface( split.second ); } }
SmartPtr<Named_interface> Manager::new_interface(const std::string& type_param, const std::string& name, std::string* final_name ) { // Look for the required manager and create the new interface. // If no factory method can be found to create the interface, look // for a plugin that would provide a factory method. // It would be better to use the functionalities in namespace String_Op // rather than the split function defined above... I'll change that later Prefixed_name split = split_name(name); if( split.second == "" ) { // we're at the end of the path //---------- // Extract the type of the object to be created // and the parameters for the creation. These information are // contained in string "type_param" String_Op::string_pair split_params = String_Op::split_string( type_param, "://", true ); std::string type = split_params.first; std::string param = split_params.second; CallBackMap::iterator it = factory_.find(type); if( it == factory_.end() ) { // No factory method found => try loading a plugin bool loaded = load_library( type ); if( loaded ) it = factory_.find(type); } if( it == factory_.end() ) { // No factory method could be found, and no plugin provides a // suitable one appli_warning( "No factory method to create type " << type << std::endl << "Interface ..." << name << " could not be created" << std::endl ); return 0; } // If we've reached this point, it means we have a factory method // to create the requested interface. //First we need to find the name for the interface // if the interface has no name, don't manage it std::string interface_name = ""; if( !split.first.empty() ) { InterfaceMap::iterator it_interf = interfaces_.find(split.first); if(it_interf == interfaces_.end()) { // The interfaces does not already exist interface_name = split.first; } else { // If the name is already used, modify it if final_name is not null if( !final_name ) { appli_warning( "Interface " << split.first << " already exists" ); return 0; } else { int count = 1; std::string initial_name = split.first; do { final_name->erase(); std::ostringstream ostr; ostr << initial_name << "_" << count++; final_name->append( ostr.str() ); } while ( interfaces_.find(split.first) != interfaces_.end() ); interface_name = *final_name; } } if(model_) { InterfaceMap::iterator it_row = interfaces_.lower_bound(interface_name); model_->begin_insert_item(this,std::distance(interfaces_.begin(), it_row)); } //SmartPtr<Named_interface> interf = (it->second)( param ); SmartPtr<Named_interface> interf = (it->second)( param ); interf->name(interface_name); interf->parent_interface(this); interfaces_.insert( std::make_pair( interface_name, interf) ); if(model_) model_->end_insert_item(); return interf; } else { // No name hence will not be managed return (it->second)( param ); } } else { // we're not at the end of the path. // go down one level of the tree, if it exists, and try again SmartPtr<Directory> subdir = get_subdir( split.first ); if( subdir.raw_ptr() == 0 ) { appli_warning( "Could not descend into directory " << split.first << std::endl ); return 0; } else return subdir->new_interface( type_param, split.second, final_name ); } }
/* * Retrieve information by name. * Called indirectly through the directory_provider_static structure. */ static directory_error_t directory_provider_builtin_get( directory_entry_rpc *del, idmap_utf8str_list *ids, idmap_utf8str types, idmap_utf8str_list *attrs) { int i; for (i = 0; i < ids->idmap_utf8str_list_len; i++) { const wksids_table_t *wksid; directory_error_t de; int type; /* * Extract the type for this particular ID. * Advance to the next type, if it's there, else keep * using this type until we run out of IDs. */ type = *types; if (*(types+1) != '\0') types++; /* * If this entry has already been handled, one way or another, * skip it. */ if (del[i].status != DIRECTORY_NOT_FOUND) continue; char *id = ids->idmap_utf8str_list_val[i]; /* * End-to-end error injection point. * NEEDSWORK: should probably eliminate this for production */ if (uu_streq(id, " DEBUG BUILTIN ERROR ")) { directory_entry_set_error(&del[i], directory_error("Directory_provider_builtin.debug", "Directory_provider_builtin: artificial error", NULL)); continue; } if (type == DIRECTORY_ID_SID[0]) wksid = find_wk_by_sid(id); else { int idmap_id_type; if (type == DIRECTORY_ID_NAME[0]) idmap_id_type = IDMAP_POSIXID; else if (type == DIRECTORY_ID_USER[0]) idmap_id_type = IDMAP_UID; else if (type == DIRECTORY_ID_GROUP[0]) idmap_id_type = IDMAP_GID; else { directory_entry_set_error(&del[i], directory_error("invalid_arg.id_type", "Invalid ID type \"%1\"", types, NULL)); continue; } int id_len = strlen(id); char name[id_len + 1]; char domain[id_len + 1]; split_name(name, domain, id); wksid = find_wksid_by_name(name, domain, idmap_id_type); } if (wksid == NULL) continue; de = directory_provider_builtin_populate(&del[i], wksid, attrs); if (de != NULL) { directory_entry_set_error(&del[i], de); de = NULL; } } return (NULL); }
int main (int argc, char** argv) { // get run number std::string inputName = std::string(argv[1]); char split_char = '/'; std::vector<std::string> tokens; std::istringstream split(inputName); for(std::string each; getline(split, each, split_char); tokens.push_back(each)); split_char = '_'; std::vector<std::string> tokens_name; std::istringstream split_name(tokens.at(1)); for(std::string each; getline(split_name, each, split_char); tokens_name.push_back(each)); const int Ch_ref1 = atoi((tokens_name.at(1)).c_str()); const int Ch_ref2 = atoi((tokens_name.at(3)).c_str()); const int Ch_1 = atoi((tokens_name.at(5)).c_str()); const int Ch_2 = atoi((tokens_name.at(7)).c_str()); const int Ch_3 = atoi((tokens_name.at(9)).c_str()); std::vector<std::string> nameMCP; nameMCP.push_back("MiB1"); nameMCP.push_back("MiB2"); nameMCP.push_back("ScB"); nameMCP.push_back("Planacon"); nameMCP.push_back("MiB3"); nameMCP.push_back("Roma2"); if(tokens_name.at(0) == "Scan3") nameMCP.at(1) = "Roma1"; std::vector<std::string> pcMCP; for(unsigned int ii=0; ii<nameMCP.size(); ++ii) pcMCP.push_back(""); pcMCP.at(Ch_ref1) = tokens_name.at(2); pcMCP.at(Ch_ref2) = tokens_name.at(4); pcMCP.at(Ch_1) = tokens_name.at(6); pcMCP.at(Ch_2) = tokens_name.at(8); pcMCP.at(Ch_3) = tokens_name.at(10); //---treshold setup Scan-dependent init(); const int iScanTh = atoi(argv[2])-1; float Ch_th[6]={0,0,0,0,0,0}; Ch_th[Ch_ref1] = _th[iScanTh][Ch_ref1]; Ch_th[Ch_ref2] = _th[iScanTh][Ch_ref2]; Ch_th[Ch_1] = _th[iScanTh][Ch_1]; Ch_th[Ch_2] = _th[iScanTh][Ch_2]; Ch_th[Ch_3] = _th[iScanTh][Ch_3]; TFile* out = TFile::Open((tokens_name.at(0)+"_outHistos.root").c_str(),"recreate"); out->cd(); //Output dat std::ofstream data1(("analized_data/"+tokens_name.at(0)+"_"+nameMCP.at(Ch_1)+"_pc_"+pcMCP.at(Ch_1)+".dat").data()); std::ofstream data2(("analized_data/"+tokens_name.at(0)+"_"+nameMCP.at(Ch_2)+"_pc_"+pcMCP.at(Ch_2)+".dat").data()); std::ofstream data3(("analized_data/"+tokens_name.at(0)+"_"+nameMCP.at(Ch_3)+"_pc_"+pcMCP.at(Ch_3)+".dat").data()); int nFiles = 1, iRun = 0, goodEvt = 0; int iScan = 0; //---usefull histos TH1F* chHistoBase_All[9]; TH1F* chHistoSignal_All[9]; TH1F* timeDiffHisto[9]; TH1F* timeDiffHisto_Double = new TH1F("timeDiffHisto_Double", "timeDiffHisto_Double",5000,-10,10); //---histos initialization for(int iCh=0; iCh<6; ++iCh) { char h1[30], h2[30], h3[30]; sprintf(h1, "histoBase_All_Ch%d", iCh); sprintf(h2, "histoSignal_All_Ch%d", iCh); sprintf(h3, "histoTime_Ch%d", iCh); chHistoBase_All[iCh] = new TH1F(h1,h1,30000,-30000,1000); chHistoSignal_All[iCh] = new TH1F(h2, h2,30000,-30000,1000); timeDiffHisto[iCh] = new TH1F(h3, h3,1024,0,1024); } //---do runs loop ifstream log (argv[1], ios::in); while(log >> nFiles) { ++iScan; vector<float> digiCh[9]; float timeCF[9]; float baseline[9]; float intSignal[9], intBase[9]; int count[5]={0,0,0,0,0}, spare[5]={0,0,0,0,0}, spare2[5]={0,0,0,0,0}; int tot_tr1 = 0, tot_tr0 = 0, trig = 0; int HV1=0, HV2=0, HV3=0; TH1F* chHistoWF_Ch[9]; TH1F* chHistoBase_Ch[9]; TH1F* chHistoSignal_Ch[9]; TH1F* timeDiffHisto_Triple_Ch1 = new TH1F(Form("timeDiffHisto_Triple_Ch1_Scan%d",iScan), "", 5000,-100,100); TH1F* timeDiffHisto_Triple_Ch2 = new TH1F(Form("timeDiffHisto_Triple_Ch2_Scan%d",iScan), "", 5000,-100,100); TH1F* timeDiffHisto_Triple_Ch3 = new TH1F(Form("timeDiffHisto_Triple_Ch3_Scan%d",iScan), "", 5000,-100,100); char ha[10]; for (int iiw=0;iiw<9;++iiw){ sprintf (ha,"histoWF_Ch%d_Scan_%d",iiw, iScan); chHistoWF_Ch[iiw] = new TH1F( ha, "", 1024,0.,1024); chHistoWF_Ch[iiw]->SetXTitle("Waveform"); sprintf (ha,"histoBase_Ch%d_Scan_%d",iiw, iScan); chHistoBase_Ch[iiw] = new TH1F( ha, "", 30000,-30000,1000); chHistoBase_Ch[iiw] -> SetXTitle ("Integral BaseLine Ch(ADC)"); sprintf (ha,"histoSignal_Ch%d_Scan_%d",iiw, iScan); chHistoSignal_Ch[iiw] = new TH1F( ha, "", 30000,-30000,1000); chHistoSignal_Ch[iiw] -> SetXTitle ("Integral Signal Ch(ADC)"); } //---data chain TChain* chain = new TChain("eventRawData"); InitTree(chain); for(int iFiles=0; iFiles<nFiles; iFiles++){ log >> iRun; char iRun_str[30]; sprintf(iRun_str, "../Analysis_TB/DATA/run_IMCP_%d_*.root", iRun); chain->Add(iRun_str); cout << "Reading: ../Analysis_TB/DATA/run_IMCP_" << iRun << endl; } log >> HV1 >> HV2 >> HV3; for(int iEntry=0; iEntry<chain->GetEntries(); iEntry++) { //---always clear the std::vector !!! for(int iCh=0; iCh<9; iCh++) digiCh[iCh].clear(); //---Read the entry chain->GetEntry(iEntry); //---DAQ bug workaround if(iRun < 145) goodEvt = 10; else goodEvt = 1; if(evtNumber % goodEvt == 0){ //---Read SciFront ADC value and set the e- multiplicity //---(default = 1) trig = 1; for(int iCh=0; iCh<nAdcChannels; iCh++) { if(adcData[iCh] > 1500 && adcBoard[iCh] == 1 && adcChannel[iCh] == 0) trig=2; if(adcData[iCh] < 500 && adcBoard[iCh] == 1 && adcChannel[iCh] == 0) trig=0; } if(trig > 1) continue; //---Read digitizer samples for(int iSample=0; iSample<nDigiSamples; iSample++){ if(digiChannel[iSample] == 3){ digiCh[digiChannel[iSample]].push_back(-digiSampleValue[iSample]); chHistoWF_Ch[digiChannel[iSample]]->SetBinContent(digiSampleIndex[iSample]+1, -digiSampleValue[iSample]); } else{ digiCh[digiChannel[iSample]].push_back(digiSampleValue[iSample]); chHistoWF_Ch[digiChannel[iSample]]->SetBinContent(digiSampleIndex[iSample]+1, digiSampleValue[iSample]); } } for(int iCh=0; iCh<6; iCh++){ // baseline[iCh] = SubtractBaseline(5, 25, &digiCh[iCh]); baseline[iCh] = SubtractBaseline(26, 46, &digiCh[iCh]); intBase[iCh] = ComputeIntegral(26, 46, &digiCh[iCh]); if(trig == 0) { chHistoBase_All[iCh]->Fill(ComputeIntegral(26, 46, &digiCh[iCh])); chHistoBase_Ch[iCh]->Fill(ComputeIntegral(26, 46, &digiCh[iCh])); // chHistoBase_All[iCh]->Fill(ComputeIntegral(0, 150, &digiCh[iCh])); // chHistoBase_Ch[iCh]->Fill(ComputeIntegral(0, 150, &digiCh[iCh])); } timeCF[iCh]=TimeConstFrac(30, 500, &digiCh[iCh], 0.5); // timeDiffHisto[iCh]->Fill(timeCF[iCh]*0.2-timeCF[0]*0.2); timeDiffHisto[iCh]->Fill(timeCF[iCh]); int t1 = (int)(timeCF[iCh]/0.2) - 3; int t2 = (int)(timeCF[iCh]/0.2) + 17; //---Fill the signal integral histo only if the e- multiplicity is 1 if(t1 > 30 && t1 < 1024 && t2 > 30 && t2 < 1024 && trig == 1) { chHistoSignal_All[iCh]->Fill(ComputeIntegral(t1, t2, &digiCh[iCh])); chHistoSignal_Ch[iCh]->Fill(ComputeIntegral(t1, t2, &digiCh[iCh])); intSignal[iCh] = ComputeIntegral(t1, t2, &digiCh[iCh]); } else intSignal[iCh] = ComputeIntegral(50, 70, &digiCh[iCh]); }// loop over Ch //---Multiplicity == 1 --> compute efficency, fake rate and timing if(intSignal[Ch_ref1] < Ch_th[Ch_ref1] && intSignal[Ch_ref2] < Ch_th[Ch_ref2] && trig == 1){ ++tot_tr1; float tDiff = (timeCF[Ch_ref1] - timeCF[Ch_ref2]); float tMean = (timeCF[Ch_ref1] + timeCF[Ch_ref2])*0.5; timeDiffHisto_Double->Fill(tDiff); timeDiffHisto_Triple_Ch1->Fill(tMean - timeCF[Ch_1]); timeDiffHisto_Triple_Ch2->Fill(tMean - timeCF[Ch_2]); timeDiffHisto_Triple_Ch3->Fill(tMean - timeCF[Ch_3]); if(intSignal[Ch_1] < Ch_th[Ch_1]) ++count[1]; if(intSignal[Ch_2] < Ch_th[Ch_2]) ++count[2]; if(intSignal[Ch_3] < Ch_th[Ch_3]) ++count[3]; if(intBase[Ch_1] < Ch_th[Ch_1]) ++spare[1]; if(intBase[Ch_2] < Ch_th[Ch_2]) ++spare[2]; if(intBase[Ch_3] < Ch_th[Ch_3]) ++spare[3]; } }// good Event }// loop over entries std::cout << "HV1 = " << HV1 << " HV2 = " << HV2 << " HV3 = " << HV3 << std::endl; double eff1 = ((double)count[1]-(double)spare[1])/(double)tot_tr1; double eff2 = ((double)count[2]-(double)spare[2])/(double)tot_tr1; double eff3 = ((double)count[3]-(double)spare[3])/(double)tot_tr1; double eff1Err = TMath::Sqrt((eff1*(1-eff1))/tot_tr1); double eff2Err = TMath::Sqrt((eff2*(1-eff2))/tot_tr1); double eff3Err = TMath::Sqrt((eff3*(1-eff3))/tot_tr1); std::cout << "Ch_1 eff = " << eff1 << " +/- " << eff1Err << std::endl; std::cout << "Ch_2 eff = " << eff2 << " +/- " << eff2Err << std::endl; std::cout << "Ch_3 eff = " << eff3 << " +/- " << eff3Err << std::endl; /* data1 << HV1 << " " << eff1 << " " << 0 << " " << eff1Err << std::endl; data1 << HV2 << " " << eff2 << " " << 0 << " " << eff2Err << std::endl; data1 << HV3 << " " << eff3 << " " << 0 << " " << eff3Err << std::endl; */ for(int iw=0; iw<6; ++iw){ if(iw == 2) continue; chHistoBase_Ch[iw]->Write(); chHistoSignal_Ch[iw]->Write(); chHistoWF_Ch[iw]->Write(); } timeDiffHisto_Triple_Ch1->Write(); timeDiffHisto_Triple_Ch2->Write(); timeDiffHisto_Triple_Ch3->Write(); chain->Delete(); } for(int iw=0; iw<6; ++iw){ if(iw == 2) continue; chHistoBase_All[iw]->Write(); chHistoSignal_All[iw]->Write(); timeDiffHisto[iw]->Write(); } data1.close(); data2.close(); data3.close(); timeDiffHisto_Double->Write(); out->Close(); return 0; }
void scanAll(TString dataFolder, TString dataType) { // find input files of type pla or Cu // TString command = "ls " + dataFolder + "/" + dataType + "*.dat > tmp/input.tmp"; gSystem -> Exec(command); // loop over the file and read data std::ifstream scanDir("input.tmp"); string line; // plateaufile TString inFile; float hv,eff,shv,sff; int nFile=0; TGraphErrors *g[10]; TLegend* leg = new TLegend(0.7,0.6,0.99,0.95); leg->SetFillColor(kWhite); // read all the plateau files in the directory while( scanDir.good() ){ scanDir >> inFile; // = (TString)line; cout << inFile << endl; std::string inputName = std::string(std::string(inFile)); if(inputName.size() == 0) continue; char split_char = '/'; std::vector<std::string> tokens; std::istringstream split(inputName); for(std::string each; getline(split, each, split_char); tokens.push_back(each)); split_char = '_'; std::vector<std::string> tokens_name; std::istringstream split_name(tokens.at(1)); for(std::string each; getline(split_name, each, split_char); tokens_name.push_back(each)); tokens_name.at(tokens_name.size()-1).erase(tokens_name.at(tokens_name.size()-1).size()-4,tokens_name.at(tokens_name.size()-1).size()-1); std::string LegName = tokens_name.at(0)+"_"+tokens_name.at(1)+"_"+tokens_name.at(2)+"_"+tokens_name.at(3); g[nFile] = new TGraphErrors(); g[nFile] -> SetMarkerStyle(20 + (nFile%2)*4 ); g[nFile] -> SetMarkerColor(kRed+1); if (nFile/2==1) g[nFile] -> SetMarkerColor(kGreen+1 + (nFile%1)); if (nFile/2==2) g[nFile] -> SetMarkerColor(kAzure+1 + (nFile%1)); if (nFile/2==3) g[nFile] -> SetMarkerColor(kOrange+2+ (nFile%1)); std::ifstream infile (inFile.Data(), std::ios::in); int ipt=0; while ( infile.good() ) { infile >> hv >> eff >> shv >> sff; g[nFile]->SetPoint(ipt,hv,eff); g[nFile]->SetPointError(ipt,shv,sff); cout << nFile << " " << ipt << " " << hv << " " << eff << endl; ipt++; } leg->AddEntry(g[nFile],LegName.c_str(),"PL"); nFile++; } // do graph TCanvas *cc = new TCanvas("cc","cc",50.,50.,800.,500.); cc -> cd(); float xl=0.; float xh=15; TString xtit = "Absorber Thickness (X_{0})"; if (dataType=="Scan") { xl=1200; xh=3000.; xtit = "Bias voltage (V)"; } if (dataType=="Cu" || dataType == "Pb") { xl=-1.; xh=15; xtit = "Absorber Thickness (X_{0})"; } TH1F *hf = (TH1F*)gPad->DrawFrame(xl,0.,xh,1.2); hf->GetXaxis()->SetTitle(xtit); hf->GetYaxis()->SetTitle("Efficiency"); for (int i=0;i<nFile;i++){ g[i]->Draw("P"); leg->Draw("same"); } }
int resolve_longname(char *dest, char *name) { #ifdef HAVE_EAS unsigned char *tmp_name; int entry, l_sel, rc; #if TARGET==OS2 #ifdef __32BIT__ EAOP2 eaop; PGEA2LIST pgeal; PFEA2LIST pfeal; #else EAOP eaop; PGEALIST pgeal; PFEALIST pfeal; #endif #elif TARGET==WIN32 struct nt_sid *sid=NULL; unsigned char *streambuf=NULL; unsigned long stream_len, rem_len, fetch; FEALIST feal; PFEALIST pfeal; #endif char FAR *valptr; unsigned int st_len; if(name[0]=='\0'||name[0]==PATHSEP_DEFAULT&&name[1]=='\0'||name[1]==':'&&name[2]=='\0') { strcpy(dest, name); return(0); } tmp_name=(char *)malloc_msg(FILENAME_MAX); l_sel=entry=split_name(name, tmp_name, NULL); if(entry>0) { tmp_name[entry-1]='\0'; resolve_longname(dest, tmp_name); entry=strlen(dest); dest[entry]=PATHSEP_DEFAULT; dest[entry+1]='\0'; } else dest[0]='\0'; #if TARGET==OS2 #ifdef __32BIT__ pgeal=(PGEA2LIST)farmalloc_msg(sizeof(GEA2LIST)+sizeof(longname_ea)); pfeal=(PFEA2LIST)farmalloc_msg(sizeof(FEA2LIST)+sizeof(longname_ea)+FILENAME_MAX); #else pgeal=(PGEALIST)farmalloc_msg(sizeof(GEALIST)+sizeof(longname_ea)); pfeal=(PFEALIST)farmalloc_msg(sizeof(FEALIST)+sizeof(longname_ea)+FILENAME_MAX); #endif far_strcpy(pgeal->list[0].szName, (char FAR *)longname_ea); #elif TARGET==WIN32 pfeal=(PFEALIST)farmalloc_msg(sizeof(FEALIST)+sizeof(longname_ea)+FILENAME_MAX); #endif #if TARGET==OS2 #ifdef __32BIT__ pgeal->list[0].oNextEntryOffset=0; #endif pgeal->list[0].cbName=sizeof(longname_ea)-1; #ifdef __32BIT__ pgeal->cbList=sizeof(GEA2LIST)+sizeof(longname_ea)-1; pfeal->cbList=sizeof(FEA2LIST)+sizeof(longname_ea)+FILENAME_MAX-1-entry; eaop.fpGEA2List=pgeal; eaop.fpFEA2List=pfeal; #else pgeal->cbList=sizeof(GEALIST)+sizeof(longname_ea)-1; pfeal->cbList=sizeof(FEALIST)+sizeof(longname_ea)+FILENAME_MAX-1-entry; eaop.fpGEAList=pgeal; eaop.fpFEAList=pfeal; #endif #ifdef __32BIT__ if(DosQueryPathInfo(name, FIL_QUERYEASFROMLIST, (PBYTE)&eaop, sizeof(eaop))) #else if(DosQPathInfo(name, FIL_QUERYEASFROMLIST, (PBYTE)&eaop, sizeof(eaop), 0L)) #endif rc=0; else { rc=1; #ifdef __32BIT__ valptr=(char FAR *)pfeal+sizeof(FEA2LIST)+pfeal->list[0].cbName; #else valptr=(char FAR *)pfeal+sizeof(FEALIST)+pfeal->list[0].cbName+1; #endif } #elif TARGET==WIN32 rc=0; if((sid=open_streams(name, 0))!=NULL&& (stream_len=seek_stream_id(BACKUP_EA_DATA, sid))>0) { valptr=streambuf=(char *)farmalloc_msg(256); pfeal=(PFEALIST)&feal; while(read_stream((char *)pfeal, sizeof(FEALIST), sid)==sizeof(FEALIST)&& read_stream(streambuf, pfeal->list[0].cbName+1, sid)==pfeal->list[0].cbName+1) { rem_len=pfeal->cbList-sizeof(FEALIST)-pfeal->list[0].cbName-1; if(!stricmp(streambuf, longname_ea)) { if(pfeal->list[0].cbValue<256) { read_stream(streambuf, pfeal->list[0].cbValue, sid); rc=1; break; } } else { if(pfeal->cbList==0) break; /* Advance to the next EA entry */ while(rem_len>0) { fetch=min(256, rem_len); read_stream(streambuf, fetch, sid); rem_len-=fetch; } } } } #endif if(rc) { if((st_len=pfeal->list[0].cbValue)==0) rc=0; else { far_memmove((char FAR *)tmp_name, valptr, st_len); tmp_name[st_len]='\0'; if(tmp_name[0]==0xFD&&tmp_name[1]==0xFF) { strcpy(tmp_name, (char *)tmp_name+4); st_len-=4; } if(st_len==0||st_len+entry>=FILENAME_MAX) rc=0; else { while(st_len-->0) { if(tmp_name[st_len]<' '||strchr(forbidden_chars, tmp_name[st_len])!=NULL) { rc=0; break; } } } } } if(!rc) { if(strlen(name)+entry+l_sel>=FILENAME_MAX) error(M_MAXPATH_EXCEEDED, FILENAME_MAX, name); strcat(dest, name+l_sel); } else strcat(dest, (char *)tmp_name); #if TARGET==OS2 farfree(pgeal); farfree(pfeal); #elif TARGET==WIN32 if(streambuf!=NULL) farfree(streambuf); if(sid!=NULL) close_streams(sid); #endif free(tmp_name); return(rc); #else return(0); #endif }