vector <TString> OnlineConfig::SplitString(TString instring,TString delim) { // Utility to split up a string on the deliminator. // returns a vector of strings. vector <TString> v; TString remainingString = instring; TString tempstring = instring; int i; while (remainingString.Index(delim) != -1) { i = remainingString.Index(delim); tempstring.Remove(i); v.push_back(tempstring); remainingString.Remove(0,i+1); while(remainingString.Index(delim) == 0) { remainingString.Remove(0,1); } tempstring = remainingString; } while(tempstring.EndsWith(delim)) { tempstring.Chop(); } if(!tempstring.IsNull()) v.push_back(tempstring); return v; }
void FindAny(bool found, const TString& fsname, TClass* cl, TString baseexpected, const char* ext, const char* tag) { if (baseexpected == "") { baseexpected = cl->GetName(); Ssiz_t posCol = baseexpected.First('<'); if (posCol != -1) { baseexpected.Remove(posCol, baseexpected.Length()); } posCol = baseexpected.Last(':'); if (posCol != -1) { baseexpected.Remove(0, posCol + 1); } baseexpected += ext; } if (!found) { if (baseexpected != "FAIL") { printf("FAIL: %s file for class %s not found\n", tag, cl->GetName()); } return; } else { if (baseexpected == "FAIL") { printf("FAIL: expected to not find %s file for class %s but got %s\n", tag, cl->GetName(), fsname.Data()); return; } } if (!fsname.EndsWith(baseexpected)) { printf("FAIL: class %s expected %s file %s, got %s\n", cl->GetName(), tag, baseexpected.Data(), fsname.Data()); return; } }
void FinishBatch(TString sInput="", TString sOutput="ARHist"){ // Stuff to do at the end of an analysis run // Here all spectra are saved to disk printf("Events: %d Events Accepted: %d\n", gAN->GetNEvent(), gAN->GetNEvAnalysed() ); printf("End-of-Run macro executing\n"); TString sDir = gAR->GetTreeDir(); TString sFile; if (gAR->IsOnline()) sFile = gAR->GetFileName(); else sFile = gAR->GetTreeFile()->GetName(); while(sFile.Contains("/")) sFile.Remove(0,1+sFile.Index("/")); sFile.ReplaceAll(".dat",".root"); if(sInput.Length() && sFile.BeginsWith(sInput)) sFile.Remove(0,sInput.Length()); else sFile.Prepend("_"); sFile.Prepend(sOutput); sFile.Prepend(sDir); // Save histograms to file and close it TFile f(sFile, "recreate"); if( !f ){ printf("Open file %s for histogram save FAILED!!\n",sFile.Data()); return; } gROOT->GetList()->Write(); f.Close(); printf("All histograms saved to %s\n",sFile.Data()); if (!(gAR->IsOnline())) gSystem->Exit(0); }
void bcut::parseCuts(TString cuts){ vcuts_.clear(); // Starting the parsing every time cuts.ReplaceAll(" ", ""); TString cut; int pos; do{ pos = cuts.Index("&&"); cut = cuts; if(pos != -1) cut.Remove(pos, cut.Length()); vcuts_.push_back(onecut(cut)); cuts.Remove(0, pos+2); } while(pos != -1); }
//-------------------------------------------------------------------------------------------------- void catalogFile(const char *dir, const char *file) { TString fileName = TString(dir) + slash + + TString(file); //printf("Index: %d\n",fileName.Index("castor/cern.ch")); if (fileName.Index("castor/cern.ch") != -1) fileName = TString("castor:") + fileName; if (fileName.Index("pnfs/cmsaf.mit.edu") != -1) { fileName = dCacheDoor + fileName; } if (fileName.Index("mnt/hadoop/cms/store") != -1) { fileName.Remove(0,15); fileName = hadoopDoor + fileName; } printf("\n Opening: %s\n\n",fileName.Data()); TFile* f = TFile::Open(fileName.Data()); TTree* tree = (TTree*) f->FindObjectAny("Delphes"); if (tree) { printf("0000 %s %d %d\n",fileName.Data(),tree->GetEntries(),tree->GetEntries()); return; } TTree* tree = (TTree*) f->FindObjectAny("Events"); if (tree) printf("XX-CATALOG-XX %s %d\n",fileName.Data(),tree->GetEntries()); TTree* allTree = (TTree*) f->FindObjectAny("AllEvents"); if (tree && allTree) printf("XX-CATALOG-XX %s %d %d\n",fileName.Data(),tree->GetEntries(),allTree->GetEntries()); }
Bool_t SETUP_LoadLibraries(const TString &libs) { // Loads a list of colon-separated libraries. Returns kTRUE on success, kFALSE // if at least one library couldn't load properly. Does not check for double // loads (but ROOT does). TString l; Ssiz_t from; while ( libs.Tokenize(l, from, ":") ) { if (l.IsNull()) continue; if (!l.BeginsWith("lib")) l.Prepend("lib"); if (l.EndsWith(".so")) l.Remove(l.Length()-3, l.Length()); ::Info(gMessTag.Data(), ">> Loading library %s...", l.Data()); if (gSystem->Load(l.Data()) < 0) { ::Error(gMessTag.Data(), "Error loading %s, aborting", l.Data()); return kFALSE; // failure } } return kTRUE; // success return 0; }
void Finish(TString sDir = "") { // Finishing Macro for running with Worker printf("Events: %d Events Accepted: %d\n", gAN->GetNEvent(), gAN->GetNEvAnalysed() ); printf("\nEnd-of-Run macro executing\n"); // If user has not specified output directory, pull from AR if(sDir.Length() == 0) sDir = gAR->GetTreeDir(); if(sDir.Length() == 0) sDir = "~/"; // Append "/" to Directory if unspecified if(!(sDir.EndsWith("/"))) sDir.Append("/"); // Create output filename from input file name TString sFile; if (gAR->IsOnline()) sFile = gAR->GetFileName(); else sFile = gAR->GetTreeFile()->GetName(); while(sFile.Contains("/")) sFile.Remove(0,1+sFile.Index("/")); sFile.ReplaceAll(".dat",".root"); sFile.Prepend("Hist_"); sFile.Prepend(sDir); // Save histograms to file and close it TFile f(sFile, "recreate"); f.SetCompressionLevel(4); gROOT->GetList()->Write(); f.Close(); cout << "All histograms saved to " << sFile << endl; gSystem->Exit(0); }
//-------------------------------------------------------------------------------------------------- void catalogFile(const char *dir, const char *file) { // set up the modules gMod->SetMetaDataString((TString(dir)+slash+TString(file)).Data()); gMod->SetNFileSet(0); // set up analysis //hMod->Add(gMod); //gAna->SetSuperModule(hMod); gAna->SetSuperModule(gMod); TString fileName = TString(dir) + slash + + TString(file); //printf("Index: %d\n",fileName.Index("castor/cern.ch")); if (fileName.Index("castor/cern.ch") != -1) fileName = TString("castor:") + fileName; if (fileName.Index("mnt/hadoop/cms/store") != -1) { fileName.Remove(0,15); fileName = hadoopDoor + fileName; gMod->SetMetaDataString(fileName.Data()); } printf(" Adding: %s\n",fileName.Data()); gAna->AddFile(fileName); gAna->SetUseHLT(0); gAna->SetCacheSize(64*1024*1024); // run the analysis after successful initialisation gAna->Run(false); }
void bcut::parseWeights(TString weights){ weights.ReplaceAll(" ", ""); cutTypes_.clear(); fWeights_.clear(); fvWeights_.clear(); indWeights_.clear(); TString wgt; int pos; do{ pos = weights.Index("*"); wgt = weights; if(pos != -1) wgt.Remove(pos, wgt.Length()); parseWeight(wgt); weights.Remove(0, pos+1); } while(pos != -1); }
void RecoQA(const char* inFile) { gROOT->LoadMacro("bfcread_hist_prefixes_add_to_ps.C"); TString baseName = inFile; if (baseName.EndsWith(".daq")) baseName.ReplaceAll(".daq",".hist.root"); else if (baseName.EndsWith(".event.root")) baseName.ReplaceAll(".event.root",".hist.root"); else if (baseName.EndsWith(".MuDst.root")) baseName.ReplaceAll(".MuDst.root",".hist.root"); TString histFile = baseName; baseName.Remove(0,baseName.Last('/')+1); TString outputName = baseName; outputName.ReplaceAll(".root",".CC"); TString histList = "StRoot/St_QA_Maker/QAhlist_Reco.h"; if (! gSystem->Which(".",histList.Data())) histList.Prepend(gSystem->ExpandPathName("$STAR/")); bfcread_hist_prefixes_add_to_ps(histFile.Data(),"EventQA", "bfcTree",outputName.Data(),baseName.Data(),histList.Data()); }
TString RoundNumber(double num, int decimals, double denom) { if(denom==0 || !isfinite(num) || !isfinite(denom)) return " - "; double neg = 1; if(num*denom<0) neg = -1; num /= neg*denom; num += 0.5*pow(10.,-decimals); if(abs(num) > 1e16) return "-"; long num_int = static_cast<long>(num); long num_dec = static_cast<long>((1+num-num_int)*pow(10.,decimals)); TString s_dec = ""; s_dec += num_dec; s_dec.Remove(0,1); TString result=""; if(neg<0) result+="-"; result+= num_int; if(decimals>0) { result+="."; result+=s_dec; } TString afterdot = result; afterdot.Remove(0,afterdot.First(".")+1); for(int i=0; i<decimals-afterdot.Length(); i++) result += "0"; if(result.Length()>15) cout<<"num "<<num<<", denom "<<denom<<" ----> "<<result<<endl; return result; }
void ConnectFriends() { // Connect the friends tree as soon as available. // // Handle the friends first // if (!esdTree->FindBranch("ESDfriend.")) { // Try to add ESDfriend. branch as friend TString esdFriendTreeFName; esdFriendTreeFName = (esdTree->GetCurrentFile())->GetName(); TString basename = gSystem->BaseName(esdFriendTreeFName); Int_t index = basename.Index("#")+1; basename.Remove(index); basename += "AliESDfriends.root"; TString dirname = gSystem->DirName(esdFriendTreeFName); dirname += "/"; esdFriendTreeFName = dirname + basename; // TTree* cTree = esdTree->GetTree(); if (!cTree) cTree = esdTree; cTree->AddFriend("esdFriendTree", esdFriendTreeFName.Data()); cTree->SetBranchStatus("ESDfriend.", 1); esdFr = (AliESDfriend*)(esdEv->FindListObject("AliESDfriend")); if (esdFr) cTree->SetBranchAddress("ESDfriend.", &esdFr); } }
void KV_CCIN2P3_GE::GetBatchSystemParameterList(KVNameValueList& nl) { // Fill the list with all relevant parameters for batch system, // set to their default values. // // Parameters defined here are: // JobTime [string] // JobMemory [string] // JobDisk [string] // MultiJobsMode [bool] // RunsPerJob [int] // EMailOnStart [bool] // EMailOnEnd [bool] // EMailAddress [string] KVBatchSystem::GetBatchSystemParameterList(nl); nl.SetValue("JobTime", fDefJobTime); nl.SetValue("JobMemory", fDefJobMem); nl.SetValue("JobDisk", fDefJobDisk); nl.SetValue("MultiJobsMode", MultiJobsMode()); nl.SetValue("RunsPerJob", fRunsPerJob); nl.SetValue("EMailOnStart", kFALSE); nl.SetValue("EMailOnEnd", kFALSE); TString email = gSystem->GetFromPipe("email"); if (email.Index('=') > -1) { email.Remove(0, email.Index('=') + 2); nl.SetValue("EMailAddress", email); } else nl.SetValue("EMailAddress", ""); }
// used to create output file for canvas void imgconv( TCanvas* c, const TString & fname ) { // return; if (NULL == c) { cout << "*** Error in TMVAGlob::imgconv: canvas is NULL" << endl; } else { // create directory if not existing TString f = fname; TString dir = f.Remove( f.Last( '/' ), f.Length() - f.Last( '/' ) ); gSystem->mkdir( dir ); TString pngName = fname + ".png"; TString gifName = fname + ".gif"; TString epsName = fname + ".eps"; c->cd(); // create eps (other option: c->Print( epsName )) if (UsePaperStyle) { c->Print(epsName); } else { cout << "--- --------------------------------------------------------------------" << endl; cout << "--- If you want to save the image as eps, gif or png, please comment out " << endl; cout << "--- the corresponding lines (line no. 239-241) in tmvaglob.C" << endl; cout << "--- --------------------------------------------------------------------" << endl; c->Print(epsName); c->Print(pngName); // c->Print(gifName); } } }
void Setoutputfileprefix( TString const& filename ){ outputfileprefix = filename; Int_t pos(0); for(Int_t i(0);i<outputfileprefix.Sizeof();i++){ if(outputfileprefix[i] == '/') pos = i; } outputfileprefix.Remove(0,pos+1); outputfileprefix.ReplaceAll(".root",""); }
TString nPart(Int_t part,TString string) { if (part <= 0) return ""; for (int i = 1; i < part; i++) //part-1 times { if (string.Index(";") < 0) return ""; string.Replace(0,string.Index(";")+1,"",0); } if (string.Index(";") >= 0) string.Remove(string.Index(";")); return string; }
/** * Returns a suitable epsFilename build from a file or directory name and * histogram name. * * @param fileOrDirectoryName * name of the file or directory * @param histogramNamw * name of the histogram * @return * a suitable epsFilename */ TString epsFilename(const TString& fileOrDirectoryName, const TString& histogramName) { // {{{ TString s = fileOrDirectoryName; if (s.EndsWith("/")) s.Remove(s.Length()-1); s = gSystem->BaseName(s); s.ReplaceAll(".root", ""); s.Append(".").Append(histogramName); s.ReplaceAll(".", "_"); return s; // }}} };
void runLocal(TString dataset, TString treename = "", Long64_t nentries=TChain::kBigNumber, Long64_t firstentry = 0) { ProofAna* ana = new ProofAna(); //Need to provide a TList for local running TList* list = new TList(); ana->SetInputList(list); // Load dataset manager stuff, uses same local datasets as PROOF-Lite by design TString defaultdir(gSystem->HomeDirectory()); defaultdir.Append("/.proof"); TString dsetdir(gEnv->GetValue("ProofLite.Sandbox",defaultdir.Data())); dsetdir.Append("/datasets"); dsetdir.Prepend("dir:"); TDataSetManagerFile mgr(dsetdir); TString dsetfile(dataset); dsetfile.Append(".txt"); dsetfile.Prepend("../filelists/"); //Register dataset, if non-existent if(!mgr.ExistsDataSet(dataset)) { TFileCollection* dset = new TFileCollection(dataset,"",dsetfile); mgr.RegisterDataSet(dataset,dset,"V"); //This seems to return true regardless of success or failure at the moment if(treename.CompareTo("")!=0) { cout << "Setting default tree to " << treename << " (local and lite running)" << endl; TProof* lite = TProof::Open("lite://"); if(lite->SetDataSetTreeName(dataset,treename)) { cout << "Failure to set default tree to " << treename << endl; return; } delete lite; } } mgr.ShowDataSets(); // And yes, all this dataset garbage was to get the default tree name TFileCollection* dset = mgr.GetDataSet(dataset); TString defaultTree = dset->GetDefaultTreeName(); // Make TChain from TFileCollection...doesn't seem like there is a more direct way if(defaultTree.First("/")==0) defaultTree.Remove(0,1); TChain* T = new TChain(defaultTree); TList* filelist = (TList*)dset->GetList(); TIter next(filelist); TFileInfo* fileinfo = 0; while ((fileinfo = (TFileInfo*)next())) T->AddFile(fileinfo->GetCurrentUrl()->GetUrl()); // Process TChain T->Process(ana,"", nentries, firstentry); }
TString getSrcDir() { TString rootsys("$ROOTSYS"); gSystem->ExpandPathName(rootsys); TString cfgLoc(rootsys + "/config/Makefile.config"); ifstream cfgIn(cfgLoc); if (!cfgIn) { return rootsys; } TString line; while (line.ReadLine(cfgIn)) { if (line.BeginsWith("ROOT_SRCDIR")) { Ssiz_t posRP = line.Index("realpath, "); if (posRP != -1) { line.Remove(0, posRP + 10); line.Remove(line.Length() - 1); } else { line.Remove(0, 19); } return line; } } return rootsys; }
void dealWith_unEqualBinning_ZZ(TString file_name){ TFile * file_in=new TFile(file_name,"read"); // file_in->cd(); file_in->cd("ll"); // ll->cd(); file_in.ls(); cout << "listing dir.."<<endl; gDirectory->ls(); gDirectory->cd(); // TList * input_p=file_in->GetList(); // TList * list_histos=file_in->GetListOfKeys(); TList * list_histos=gDirectory->GetListOfKeys(); cout << "--------> histo name: "<< list_histos->At(0)->GetName()<< endl; TString file_out=file_name.Remove(file_name.Length() - 5, 5); file_out+="_uniformBins.root"; cout <<" ----> output: "<< file_out<<"\n" << endl; TFile *outFile=new TFile(file_out,"recreate"); outFile->cd(); for (int i=0;i<list_histos->GetEntries();i++){ file_in->cd("ll"); TString histo_name= list_histos->At(i)->GetName(); // TH1D * plot=file_in->Get(histo_name); TH1D * plot=gDirectory->Get(histo_name); //cout << " plot \""<<histo_name<<"\""<< endl; cout <<"\treading histo "<< histo_name<< " and rebinning.." << endl; cout <<"\t\t integral: "<<plot->Integral() << endl; int N_bins=plot->GetNbinsX(); TH1D * plot_rebin=new TH1D("plot_rebin","plot_rebin",N_bins-2,0,N_bins-2); for (int j=1;j<=N_bins;j++) plot_rebin->SetBinContent(j,plot->GetBinContent(j+2)); cout <<"\t\tbin yield starting: "<< plot->Integral()<<" after rebinning: "<<plot_rebin->Integral() << endl; outFile->cd(); plot_rebin->Write(histo_name); delete plot_rebin; } outFile->Close(); file_in->Close(); /* list_histos->GetEntries(); list_histos->At(4)->GetName(); TH1D * plot=file_in->Get("data_obs"); */ }
TString round(double n, int e, double d){ if(d==0) return " - "; double b = (int)(n/d*pow(10,e)+0.5); b /= pow(10,e); TString result; result+= b; result.ReplaceAll(" ",""); if(!result.Contains(".") && e != 0) result += "."; TString afterdot = result; afterdot.Remove(0,afterdot.First(".")+1); for(int i=0; i<e-afterdot.Length(); i++) result += "0"; return result; }
TString HiggsPlot::RoundNumber(double n, int e, double d){ if(d==0) return " - "; double neg = 1; if(n*d<0) neg = -1; double b = static_cast<int>(neg*n/d*pow(10.,static_cast<double>(e))+0.5); b /= pow(10.,static_cast<double>(e))*neg; TString result; result+= b; result.ReplaceAll(" ",""); if(!result.Contains(".") && e != 0) result += "."; TString afterdot = result; afterdot.Remove(0,afterdot.First(".")+1); for(int i=0; i<e-afterdot.Length(); i++) result += "0"; return result; }
//_____________________________________________________________________________ THaCut::EvalMode THaCut::ParsePrefix( TString& expr ) { // Parse the given expression for a mode prefix (e.g. "OR:") // and return its value. If the expression does not have a mode prefix, // return the default kAND (=0). // The expression is expected to have all whitespace removed. // If the prefix was found, it is stripped from the expression. // If a mode prefix seems to be present, but is not found in // the defined modes, return kModeErr. const EvalMode kDefaultMode = kOR; const char* const here = "THaCut"; struct ModeDef_t { const char* prefix; EvalMode mode; }; const ModeDef_t mode_defs[] = { { "OR", kOR }, { "ANY", kOR }, { "AND", kAND }, { "ALL", kAND }, { "XOR", kXOR }, { "ONE", kXOR }, { "ONEOF", kXOR }, { 0, kModeErr } }; Ssiz_t colon = expr.Index(":"); if( colon == kNPOS ) return kDefaultMode; const ModeDef_t* def = mode_defs; while( def->prefix ) { if( expr.BeginsWith(def->prefix) && static_cast<Ssiz_t>(strlen(def->prefix)) == colon ) { expr.Remove(0,colon+1); break; } ++def; } EvalMode mode = def->mode; if( mode == kModeErr ) { TString prefix = expr(0,colon); Error(here, "Unknown prefix %s", prefix.Data() ); } else if( expr.Length() == 0 ) { Error(here, "expression may not be empty"); mode = kModeErr; } if( mode == kModeErr ) SetBit(kError); return mode; }
void makehlt_tree(TString filename, TString outfolder="root/hlt/sep4/"){ TString cuts[] = {"onelpt>15", "onmupt>15"}; TString tags[] = {"el15", "mu15"}, folder, sCut; TChain tree("tree"); TChain treeglobal("treeglobal"); tree.Add(filename); treeglobal.Add(filename); vector<int> genlep_thresh, v_nori_genels, v_nori_genmus; vector<int> *nori_genels = &v_nori_genels, *nori_genmus = &v_nori_genmus; int noriginal, nori_genmu0, nori_genel0; treeglobal.SetBranchAddress("noriginal",&noriginal); treeglobal.GetEntry(0); genlep_thresh.push_back(0); genlep_thresh.push_back(10); genlep_thresh.push_back(15); genlep_thresh.push_back(17); genlep_thresh.push_back(20); genlep_thresh.push_back(25); for(unsigned ind(0); ind<genlep_thresh.size(); ind++){ sCut = "Max$(genels_pt)>"; sCut += genlep_thresh[ind]; v_nori_genels.push_back(tree.GetEntries(sCut)); sCut = "Max$(genmus_pt)>"; sCut += genlep_thresh[ind]; v_nori_genmus.push_back(tree.GetEntries(sCut)); } nori_genel0 = v_nori_genels[0]; nori_genmu0 = v_nori_genmus[0]; filename.Remove(0,filename.Last('/')+1); filename.ReplaceAll(".root",""); for(int cut(0); cut<2; cut++){ folder = outfolder+"/"+tags[cut]+"/"; gSystem->mkdir(folder, kTRUE); TTree *ctree = tree.CopyTree(cuts[cut]); folder += filename+"_"+tags[cut]+".root"; ctree->SaveAs(folder); TFile file(folder,"UPDATE"); file.cd(); TTree ctreeglobal("treeglobal", "treeglobal"); ctreeglobal.Branch("noriginal",&noriginal); ctreeglobal.Branch("nori_genels",&nori_genels); ctreeglobal.Branch("nori_genmus",&nori_genmus); ctreeglobal.Branch("nori_genel0",&nori_genel0); ctreeglobal.Branch("nori_genmu0",&nori_genmu0); ctreeglobal.Branch("genlep_thresh", &genlep_thresh); ctreeglobal.Fill(); ctreeglobal.Write(); file.Close(); } }
void bcut::parseWeight(TString wgt){ cutTypes_.push_back(kFloat); fWeights_.push_back(NULL); fvWeights_.push_back(NULL); indWeights_.push_back(-1); constWeights_.push_back(1.); if(wgt=="weight") fWeights_.back() = &baby_base::weight; else if(wgt=="w_lumi") fWeights_.back() = &baby_base::w_lumi; else if(wgt=="w_pu") fWeights_.back() = &baby_base::w_pu; else if(wgt=="w_lep") fWeights_.back() = &baby_base::w_lep; else if(wgt=="w_fs_lep") fWeights_.back() = &baby_base::w_fs_lep; else if(wgt=="w_toppt") fWeights_.back() = &baby_base::w_toppt; else if(wgt=="w_btag") fWeights_.back() = &baby_base::w_btag; else if(wgt=="eff_trig") fWeights_.back() = &baby_base::eff_trig; else if(wgt.Contains("[")){ // if weight is a vector element TString index_s(wgt); wgt.Remove(wgt.Index("["), wgt.Length()); index_s.Remove(0, index_s.Index("[")+1); index_s.Remove(index_s.Index("]"), index_s.Length()); indWeights_.back() = index_s.Atoi(); cutTypes_.back() = kvFloat; if(wgt=="w_pdf") fvWeights_.back() = &baby_base::w_pdf; else if(wgt=="sys_pdf") fvWeights_.back() = &baby_base::sys_pdf; else if(wgt=="sys_isr") fvWeights_.back() = &baby_base::sys_isr; else if(wgt=="sys_mur") fvWeights_.back() = &baby_base::sys_mur; else if(wgt=="sys_muf") fvWeights_.back() = &baby_base::sys_muf; else if(wgt=="sys_murf") fvWeights_.back() = &baby_base::sys_murf; else if(wgt=="sys_trig") fvWeights_.back() = &baby_base::sys_trig; else if(wgt=="sys_lep") fvWeights_.back() = &baby_base::sys_lep; else if(wgt=="sys_fs_lep") fvWeights_.back() = &baby_base::sys_fs_lep; else if(wgt=="sys_bctag") fvWeights_.back() = &baby_base::sys_bctag; else if(wgt=="sys_fs_bctag") fvWeights_.back() = &baby_base::sys_fs_bctag; else if(wgt=="sys_udsgtag") fvWeights_.back() = &baby_base::sys_udsgtag; else if(wgt=="sys_fs_udsgtag") fvWeights_.back() = &baby_base::sys_fs_udsgtag; else { cout<<"Weight \""<<wgt<<" not defined. Add it to bcut::parseWeight in bcut.cpp"<<endl; exit(0); } }else if(wgt.Atof()>0) { constWeights_.back() = wgt.Atof(); cutTypes_.back() = kConst; } else { cout<<"Weight \""<<wgt<<" not defined. Add it to bcut::parseWeight in bcut.cpp"<<endl; exit(0); } }
Int_t KVRTGIDManager::WriteAsciiFile ( const Char_t * filename, const TCollection *selection, Bool_t update ) { // Write identification functions in file 'filename'. // If selection=0 (default), write all grids. // If update=true, call UpdateListFromIDGridManager() before writing // If selection!=0, write only grids in list. // Returns number of functions written in file. if( update ) UpdateListFromIDGridManager(); if( !fIDGlobalList ){ Warning("KVRTGIDManager::WriteAsciiFile","No listed identification functions to write"); return 0; } ofstream tgidfile ( filename ); if( !tgidfile.is_open() ){ Error("KVRTGIDManager::WriteAsciiFile","No write permission for file %s", filename); return 0; } const TCollection *list_tgid = ( selection ? selection : fIDGlobalList ); TIter next ( list_tgid ); KVTGID *tgid = NULL; Int_t n_saved = 0; while ( ( tgid = (KVTGID *)next() ) ) { // Not write a KVTGID copy TString tmp = tgid->GetTitle(); if(tmp.Contains("COPY")){ tmp.Remove(0, tmp.Index("0x")); KVTGID *tmp_tgid = reinterpret_cast<KVTGID *>((Int_t)tmp.Atof()); Warning("KVRTGIDManager::WriteAsciiFile","The function %s (%s, %p) is not written because it is a copy of %s (%s, %p)" , tgid->GetName(), tgid->ClassName(), tgid , tmp_tgid->GetName(), tmp_tgid->ClassName(), tmp_tgid); continue; } tgid->WriteToAsciiFile ( tgidfile ); Info( "KVRTGIDManager::WriteAsciiFile", "%s (%s, %p) saved", tgid->GetName(), tgid->ClassName(), tgid ); n_saved++; } tgidfile.close(); return n_saved; }
void TDSPMultiEcho::Draw(Option_t *o, Double_t x0, Double_t x1, UInt_t num) { TString opt = o; opt.ToLower(); Ssiz_t pos; if ((pos = opt.Index("multi"))!= kNPOS) { opt.Remove(pos,5); TMultiGraph *m = MultiGraph(NULL,x0,x1,num); m->Draw(o); m->GetXaxis()->SetTitle("#tau / #mu s"); gPad->Update(); return; } TGraph *a = Graph(NULL,x0,x1,num); a->Draw(o); a->GetXaxis()->SetTitle("#tau / #mu s"); gPad->Update(); }
void KVINDRAUpDater::SetChVoltParameters(KVDBRun* kvrun) { KVRList* param_list = kvrun->GetLinks("Channel-Volt"); if (!param_list) return; if (!param_list->GetSize()) return; KVDetector* kvd; KVDBParameterSet* kvps; KVCalibrator* kvc; TIter next_ps(param_list); TString str; // Setting Channel-Volts calibration parameters while ((kvps = (KVDBParameterSet*) next_ps())) { // boucle sur les parametres str = kvps->GetName(); str.Remove(str.Sizeof() - 4, 3); //Removing 3 last letters (ex : "_PG") kvd = fArray->GetDetector(str.Data()); if (!kvd) Warning("SetChVoltParameters(UInt_t)", "Dectector %s not found !", str.Data()); else { // detector found kvc = kvd->GetCalibrator(kvps->GetName(), kvps->GetTitle()); if (!kvc) Warning("SetChVoltParameters(UInt_t)", "Calibrator %s %s not found !", kvps->GetName(), kvps->GetTitle()); else { //calibrator found for (Int_t i = 0; i < kvc->GetNumberParams(); i++) { kvc->SetParameter(i, kvps->GetParameter(i)); } kvc->SetStatus(kTRUE); // calibrator ready } //calibrator found } //detector found } //boucle sur les parameters }
Bool_t KVAvailableRunsFile::ExtractDateFromFileName(const Char_t* name, KVDatime& date) { // We assume that 'name' is the name of a run of the type of this available runs file. // We attempt several methods to try to extract a date from 'name'. // If successful, we return kTRUE and 'date' contains the result. //get format string for current dataset TString fmt = fDataSet-> GetDataSetEnv(Form("DataSet.RunFileName.%s", GetDataType())); Int_t rubbish = fmt.Index("%*"); if(rubbish>-1) fmt.Remove(rubbish,fmt.Length()); Int_t run = IsRunFileName(name); if(!run) return kFALSE; TString basename; basename.Form(fmt.Data(), run); TString fullname(name); if(!fullname.Contains(basename)) return kFALSE; if(fullname.Length()==basename.Length()) return kFALSE; fullname.Remove(0, basename.Length()+1); fullname.ReplaceAll("_"," "); fullname.ToUpper(); if(KVDatime::IsSQLFormat(fullname.Data())){ date.SetSQLDate(fullname.Data()); return kTRUE; } else { fullname.ReplaceAll("."," "); if(KVDatime::IsGANACQFormat(fullname.Data())){ date.SetGanacqDate(fullname.Data()); return kTRUE; } else if(KVDatime::IsGANACQ2010Format(fullname.Data())){ date.SetGanacq2010Date(fullname.Data()); return kTRUE; } } return kFALSE; }
void ProcYields::Proc_hYW(){ Info("Proc_hYW()", ""); TDirectory* dirhYW = _fout->mkdir("hYW"); TH1F* hYW[nVARSET]; TDirectory* dirVarset=NULL; for(Int_t iVarset=0;iVarset<nVARSET;iVarset++){ Info("Proc_hYW()","Varset = Varset%d", iVarset+1); dirVarset=dirhYW->mkdir(TString::Format("Varset%d",iVarset+1)); dirVarset->cd(); hYW[iVarset] = new TH1F("hYW","hYW", _user.nWbins, _user.Wmin, _user.Wmax); hYW[iVarset]->SetXTitle("W[GeV]"); //!Loop over Q2W dirs, get h5Ds and their yields TIter nextkey(_fout->GetListOfKeys()); TKey *key; while (key = (TKey*)nextkey()) { TString Q2Wdirname = key->GetName(); if(Q2Wdirname.EqualTo("hYW_Dir") || Q2Wdirname.EqualTo("hYW"))continue; Info("Proc_hYW()","Q2Wdir = %s", Q2Wdirname.Data()); TString wrange = Q2Wdirname.Tokenize("_")->At(1)->GetName(); TString wlow = wrange.Tokenize(",")->At(0)->GetName(); wlow.Remove(0,1); //remove "[" //Float_t w = wlow.Atof(); Double_t w = wlow.Atof(); sprintf(_hname, "%s/hY5D/Varset%d/hY5D_FULL", Q2Wdirname.Data(),iVarset+1); THnSparse* hY5D_FULL = (THnSparse*)_fout->Get(_hname); if (hY5D_FULL == NULL) cout <<"could not get h5D" << endl; //Float_t yield = getIntegral(hY5D_FULL); Double_t yield = getIntegral(hY5D_FULL); //hYW[iVarset]->Fill(w, yield); hYW[iVarset]->SetBinContent(hYW[iVarset]->FindBin(w+_intrinsic.Wbinw), yield); Info("Proc_hYW()","W = %f, bin# = %d, yield = %f\n", w, hYW[iVarset]->FindBin(w+_intrinsic.Wbinw), yield); } } Info("Proc_hYW()", "done\n"); }