void WriteXsection() { TPythia6 *pythia = TPythia6::Instance(); pythia->Pystat(1); Int_t ntrials = pythia->GetMSTI(5); Double_t xsection = pythia->GetPARI(1); cout << "Pythia cross section: " << xsection << ", number of trials: " << ntrials << endl; TFile *file = TFile::Open("pyxsec_hists.root", "NEW"); TList *list = new TList(); TProfile *h1Xsec = new TProfile("h1Xsec", "", 1, 0., 1.); list->Add(h1Xsec); TH1F *h1Trials = new TH1F("h1Trials", "", 1, 0., 1.); h1Trials->Sumw2(); list->Add(h1Trials); h1Xsec->Fill(0.5, xsection); h1Trials->Fill(0.5, ntrials); file->cd(); list->Write("cFilterList", TObject::kSingleKey); file->Close(); return; }
void analysis_t_test1::Terminate() { // The Terminate() function is the last function to be called during // a query. It always runs on the client, it can be used to present // the results graphically or save the results to file. TFile file_out("analysis_t_test1_output.root","recreate"); TList *outlist = GetOutputList(); outlist->Write(); file_out.Write(); file_out.Close(); }
void neutrootracker::DoAnalysis(const TString filelist, const Int_t ntarget, const TString tag) { gRooTrackerUtils::Ini(); Init(gRooTrackerUtils::IniIO(filelist,"nRooTracker")); printf("NeutTrackerAnalysis ntarget = %d\n", ntarget); TList *lout = gRooTrackerUtils::GetHistList(); TTree *tout = gRooTrackerUtils::GetTree(); const Int_t nentries = fChain->GetEntries(); Int_t nsel = 0; Int_t nfail = 0; for (Int_t jentry = 0; jentry<nentries; jentry++) { if(jentry%10000==0) printf("%d/%d nsel %d nfail %d\n", jentry, nentries, nsel, nfail); if(!fChain->GetEntry(jentry)){ printf("DoAnalysis GetEntry ends at jentry %d\n", jentry); break; } gRooTrackerUtils::FillCount(lout,0); const Int_t nfound = gRooTrackerUtils::FindParticles(StdHepN, StdHepPdg, StdHepStatus, StdHepP4, StdHepP4, "NEUT"); gRooTrackerUtils::SetCount(nfound); gRooTrackerUtils::SetpTT(); gRooTrackerUtils::SetDeltapTT(); gRooTrackerUtils::SetConsSum(); gRooTrackerUtils::SetAltdpTT(); gRooTrackerUtils::FillCount(lout,11); tout->Fill(); nsel++; if(ntarget>=0 && nsel>=ntarget) break; } printf("nentries %d nsel %d nfail %d delta %d\n", nentries, nsel, nfail, nentries-nsel-nfail); if( (nentries-nsel-nfail)!=0 ){ printf("NeutRooTracker: nsel nfail bad nsel %d nfail %d nentries %d\n", nsel, nfail, nentries); //exit(1); } TFile *fout= new TFile(Form("%s_DeltapTT.root",tag.Data()),"recreate"); tout->Write(); //for further handling in plot lout->Write("lout",TObject::kSingleKey); fout->Save(); fout->Close(); delete fout; }
void tables_write() { // first connect to data base // "recreate" option delete all your tables !!!! TSQLFile* f = new TSQLFile(dbname, "recreate", username, userpass); if (f->IsZombie()) { delete f; return; } // you can change configuration only until first object // is written to TSQLFile f->SetUseSuffixes(kFALSE); f->SetArrayLimit(1000); f->SetUseIndexes(1); // f->SetTablesType("ISAM"); // f->SetUseTransactions(kFALSE); // lets first write histogram TH1I* h1 = new TH1I("histo1","histo title", 1000, -4., 4.); h1->FillRandom("gaus",10000); h1->Write("histo"); h1->SetDirectory(0); // here we create list of objects and store them as single key // without kSingleKey all TBox objects will appear as separate keys TList* arr = new TList; for(Int_t n=0;n<10;n++) { TBox* b = new TBox(n*10,n*100,n*20,n*200); arr->Add(b, Form("option_%d_option",n)); } arr->Write("list",TObject::kSingleKey); // clones array is also stored as single key TClonesArray clones("TBox",10); for(int n=0;n<10;n++) new (clones[n]) TBox(n*10,n*100,n*20,n*200); clones.Write("clones",TObject::kSingleKey); // close connection to database delete f; }
void AdaptFileStructure(TString fileName) { TFile* f = TFile::Open(fileName.Data(), "READ"); TList* cList = new TList(); cList->SetName("cList"); cList->SetOwner(kTRUE); for (Int_t i = 0; i < gFile->GetNkeys(); i++) { TObject* obj = f->GetListOfKeys()->At(i); TString name = obj->GetName(); TObject* obj2 = f->Get(name.Data()); cList->Add(obj2); } TString fileNameOutput = fileName; fileNameOutput.ReplaceAll(".root", "_commonStructure.root"); TFile* fOut = TFile::Open(fileNameOutput.Data(), "RECREATE"); fOut->mkdir("PWGLF_PPVsMultXCheck_MC"); fOut->cd("PWGLF_PPVsMultXCheck_MC"); cList->Write("cList", TObject::kSingleKey); fOut->Close(); f->Close(); }
/** * Steering * * @param input Input file */ void ExtractGSE(const char* input) { if (!gROOT->GetClass("GraphSysErr")) gROOT->LoadMacro("$HOME/GraphSysErr/GraphSysErr.C+g"); TString base = gSystem->BaseName(input); base.ReplaceAll(".root",""); TFile* file = TFile::Open(input, "READ"); if (!file) return; TH1* cent = GetH1(file, "realCent"); Bool_t first = true; TList* stack = new TList; for (Int_t i = 1; i <= cent->GetNbinsX(); i++) { Double_t c1 = cent->GetXaxis()->GetBinLowEdge(i); Double_t c2 = cent->GetXaxis()->GetBinUpEdge(i); TObject* g = MakeGSE(file, c1, c2); if (!g) continue; stack->Add(g); if (first) g->Draw("quad stat combine axis"); else g->Draw("quad stat combine"); first = false; } TString obase(base); obase.Prepend("GSE_"); std::ofstream out(Form("%s.input", obase.Data())); GraphSysErr::Export(stack, out, "HFC", 2); out << "*E" << std::endl; out.close(); TFile* rout = TFile::Open(Form("%s.root", obase.Data()), "RECREATE"); stack->Write("container", TObject::kSingleKey); rout->Write(); }
void deltarPHJET1( TString myMethodList = "" ) { // Book output histograms UInt_t nbin = 14; double min=0; double max=6; TFile *input(0); std::vector<string> samples_; std::vector<string> datasamples_; std::vector<TH1F*> datahists; std::vector<TH1F*> revDATAhists; std::vector<TH1F*> ihists; std::vector<TH1F*> iSBhists; float scales[] = {0.0978,1.491,0.0961,0.0253,0.0224,0.0145,0.0125,0.0160,0.0158,0.0341,0.0341,0.0341,0.020,0.0017,0.0055,0.0032,0.00084,0.02,0.01139,0.01139,0.049094905,0.049094905,0.049094905,0.049094905,0.049094905/19.145}; //samples_.push_back("WJET.root"); samples_.push_back("ZJET.root"); samples_.push_back("PHJET200400.root"); samples_.push_back("WPHJET.root"); samples_.push_back("T-W-CH.root"); samples_.push_back("TBAR-W-CH.root"); samples_.push_back("T-S-CH.root"); samples_.push_back("TBAR-S-CH.root"); samples_.push_back("T-T-CH.root"); samples_.push_back("TBAR-T-CH.root"); samples_.push_back("TTBAR1.root"); samples_.push_back("TTBAR2.root"); samples_.push_back("TTBAR3.root"); samples_.push_back("TTG.root"); samples_.push_back("WWG.root"); samples_.push_back("WW.root"); samples_.push_back("WZ.root"); samples_.push_back("ZZ.root"); samples_.push_back("ZGAMMA.root"); samples_.push_back("SINGLE-TOP-PH.root"); samples_.push_back("SINGLE-ANTITOP-PH.root"); samples_.push_back("SIGNALtGu.root"); samples_.push_back("SIGNALtGu.root"); samples_.push_back("SIGNALtGu.root"); samples_.push_back("SIGNALtGu.root"); samples_.push_back("SIGNALtGu.root"); datasamples_.push_back("REALDATA1.root"); datasamples_.push_back("REALDATA2.root"); datasamples_.push_back("REALDATA3.root"); std::vector<string> datasamplesreverse_; datasamplesreverse_.push_back("etarev/REALDATA1.root"); datasamplesreverse_.push_back("etarev/REALDATA2.root"); datasamplesreverse_.push_back("etarev/REALDATA3.root"); std::vector<string> systematics; systematics.push_back("__JES__plus"); systematics.push_back("__JES__minus"); systematics.push_back("__JER__plus"); systematics.push_back("__JER__minus"); systematics.push_back("__PhES__plus"); systematics.push_back("__PhES__minus"); systematics.push_back("__btagSF__plus"); systematics.push_back("__btagSF__minus"); systematics.push_back("__PU__plus"); systematics.push_back("__PU__minus"); systematics.push_back("__TRIG__plus"); systematics.push_back("__TRIG__minus"); //systematics.push_back("__MISSTAG__plus"); //systematics.push_back("__MISSTAG__minus"); systematics.push_back("__MUON__plus"); systematics.push_back("__MUON__minus"); systematics.push_back("__PHOTON__plus"); systematics.push_back("__PHOTON__minus"); systematics.push_back(""); map<string, double> eventwight; TList* hList = new TList(); // list of histograms to store double insidewphjet; double outsidewphjet; double insidewjet; double outsidewjet; double mtopup=220; double mtopdown=130; for(unsigned int phi=0; phi<systematics.size(); ++phi){ insidewphjet=0; outsidewphjet=0; insidewjet=0; outsidewjet=0; std::vector<TH1F*> hists; std::vector<TH1F*> SBhists; TH1F *wphjethist(0), *zjethist(0) , *phjethist(0), *wjethist(0), *twchhist(0), *tbarwhist(0), *tschhist(0), *tbarschhist(0), *ttchhist(0), *tbartchhist(0), *tt1hist(0) ,*tt2hist(0), *tt3hist(0), *ttphhist(0), *wwphhist(0), *wwhist(0), *wzhist(0), *zzhist(0), *zgammahist(0),*singletopphotonhist(0), *singleantitopphotonhist(0), *signalhist5(0) , *signalhist10(0), *signalhist20(0), *signalhist30(0), *signalhist40(0); TH1F *wphjethistSB(0), *zjethistSB(0) , *phjethistSB(0), *wjethistSB(0), *twchhistSB(0), *tbarwhistSB(0), *tschhistSB(0), *tbarschhistSB(0), *ttchhistSB(0), *tbartchhistSB(0), *tt1histSB(0) ,*tt2histSB(0), *tt3histSB(0), *ttphhistSB(0), *wwphhistSB(0), *wwhistSB(0), *wzhistSB(0), *zzhistSB(0), *zgammahistSB(0),*singletopphotonhistSB(0), *singleantitopphotonhistSB(0), *signalhistSB5(0) , *signalhistSB10(0), *signalhistSB20(0), *signalhistSB30(0), *signalhistSB40(0); TH1F *data1histrev(0), *data2histrev(0) ,*data3histrev(0),*datahistsideband(0); wphjethist = new TH1F( std::string("BDT__wphjethists").append(systematics[phi]).c_str(), std::string("BDT__wphjethists").append(systematics[phi]).c_str() , nbin, min, max ); zjethist = new TH1F( std::string("BDT__zjethist").append(systematics[phi]).c_str(), std::string("BDT__zjethist").append(systematics[phi]).c_str(), nbin, min, max ); phjethist = new TH1F( std::string("BDT__phjethist").append(systematics[phi]).c_str(),std::string("BDT__phjethist").append(systematics[phi]).c_str() , nbin, min, max ); //wjethist = new TH1F( std::string("BDT__wjethist").append(systematics[phi]).c_str(),std::string("BDT__wjethist").append(systematics[phi]).c_str() , nbin, -0.8, 0.8 ); twchhist = new TH1F( std::string("BDT__twchhist").append(systematics[phi]).c_str(),std::string("BDT__twchhist").append(systematics[phi]).c_str() ,nbin, min, max ); tbarwhist = new TH1F( std::string("BDT__tbarwhist").append(systematics[phi]).c_str(),std::string("BDT__tbarwhist").append(systematics[phi]).c_str() ,nbin, min, max ); tschhist = new TH1F( std::string("BDT__tschhist").append(systematics[phi]).c_str(), std::string("BDT__tschhist").append(systematics[phi]).c_str(), nbin, min, max ); tbarschhist = new TH1F( std::string("BDT__tbarschhist").append(systematics[phi]).c_str(),std::string("BDT__tbarschhist").append(systematics[phi]).c_str(), nbin, min, max ); ttchhist = new TH1F( std::string("BDT__ttchhist").append(systematics[phi]).c_str(),std::string("BDT__ttchhist").append(systematics[phi]).c_str(), nbin, min, max ); tbartchhist = new TH1F( std::string("BDT__tbartchhist").append(systematics[phi]).c_str(), std::string("BDT__tbartchhist").append(systematics[phi]).c_str(), nbin, min, max ); tt1hist = new TH1F( std::string("BDT__tt1hist").append(systematics[phi]).c_str(), std::string("BDT__tt1hist").append(systematics[phi]).c_str(), nbin, min, max ); tt2hist = new TH1F( std::string("BDT__tt2hist").append(systematics[phi]).c_str(), std::string("BDT__tt2hist").append(systematics[phi]).c_str(), nbin, min, max ); tt3hist = new TH1F( std::string("BDT__tt3hist").append(systematics[phi]).c_str(),std::string("BDT__tt3hist").append(systematics[phi]).c_str() , nbin, min, max ); ttphhist = new TH1F( std::string("BDT__ttphhist").append(systematics[phi]).c_str(),std::string("BDT__ttphhist").append(systematics[phi]).c_str() ,nbin, min, max ); wwphhist = new TH1F( std::string("BDT__wwphhist").append(systematics[phi]).c_str(),std::string("BDT__wwphhist").append(systematics[phi]).c_str(), nbin,min, max ); wwhist = new TH1F( std::string("BDT__wwhist").append(systematics[phi]).c_str(),std::string("BDT__wwhist").append(systematics[phi]).c_str() ,nbin, min, max ); wzhist = new TH1F( std::string("BDT__wzhist").append(systematics[phi]).c_str(),std::string("BDT__wzhist").append(systematics[phi]).c_str(), nbin, min, max ); zzhist = new TH1F( std::string("BDT__zzhist").append(systematics[phi]).c_str(),std::string("BDT__zzhist").append(systematics[phi]).c_str() ,nbin, min, max ); zgammahist = new TH1F( std::string("BDT__zgammahist").append(systematics[phi]).c_str(),std::string("BDT__zgammahist").append(systematics[phi]).c_str() ,nbin, min, max ); singletopphotonhist = new TH1F( std::string("BDT__singletopphotonhist").append(systematics[phi]).c_str(), std::string("BDT__singletopphotonhist").append(systematics[phi]).c_str(),nbin, min, max ); singleantitopphotonhist = new TH1F( std::string("BDT__singleantitopphotonhist").append(systematics[phi]).c_str(), std::string("BDT__singleantitopphotonhist").append(systematics[phi]).c_str(),nbin, min, max ); signalhist5 = new TH1F( std::string("BDT__signal5").append(systematics[phi]).c_str(),std::string("BDT__signal5").append(systematics[phi]).c_str() ,nbin, min, max ); signalhist10 = new TH1F( std::string("BDT__signal10").append(systematics[phi]).c_str(),std::string("BDT__signal10").append(systematics[phi]).c_str() ,nbin, min, max ); signalhist20 = new TH1F( std::string("BDT__signal20").append(systematics[phi]).c_str(),std::string("BDT__signal20").append(systematics[phi]).c_str() ,nbin, min, max ); signalhist30 = new TH1F( std::string("BDT__signal30").append(systematics[phi]).c_str(),std::string("BDT__signal30").append(systematics[phi]).c_str() ,nbin, min, max ); signalhist40 = new TH1F( std::string("BDT__signal40").append(systematics[phi]).c_str(),std::string("BDT__signal40").append(systematics[phi]).c_str() ,nbin,min, max ); //side band region histograms out of top mass wphjethistSB = new TH1F( std::string("BDT__wphjethistSB").append(systematics[phi]).c_str(), std::string("BDT__wphjethistSB").append(systematics[phi]).c_str() , nbin, min, max ); zjethistSB = new TH1F( std::string("BDT__zjethistSB").append(systematics[phi]).c_str(), std::string("BDT__zjethistSB").append(systematics[phi]).c_str(), nbin, min, max ); phjethistSB = new TH1F( std::string("BDT__phjethistSB").append(systematics[phi]).c_str(),std::string("BDT__phjethistSB").append(systematics[phi]).c_str() , nbin, min, max ); //wjethist = new TH1F( std::string("BDT__wjethist").append(systematics[phi]).c_str(),std::string("BDT__wjethist").append(systematics[phi]).c_str() , nbin, -0.8, 0.8 ); twchhistSB = new TH1F( std::string("BDT__twchhistSB").append(systematics[phi]).c_str(),std::string("BDT__twchhistSB").append(systematics[phi]).c_str() ,nbin, min, max ); tbarwhistSB = new TH1F( std::string("BDT__tbarwhistSB").append(systematics[phi]).c_str(),std::string("BDT__tbarwhistSB").append(systematics[phi]).c_str() ,nbin, min, max ); tschhistSB = new TH1F( std::string("BDT__tschhistSB").append(systematics[phi]).c_str(), std::string("BDT__tschhistSB").append(systematics[phi]).c_str(), nbin, min, max ); tbarschhistSB = new TH1F( std::string("BDT__tbarschhistSB").append(systematics[phi]).c_str(),std::string("BDT__tbarschhistSB").append(systematics[phi]).c_str(), nbin, min, max ); ttchhistSB = new TH1F( std::string("BDT__ttchhistSB").append(systematics[phi]).c_str(),std::string("BDT__ttchhistSB").append(systematics[phi]).c_str(), nbin, min, max ); tbartchhistSB = new TH1F( std::string("BDT__tbartchhistSB").append(systematics[phi]).c_str(), std::string("BDT__tbartchhistSB").append(systematics[phi]).c_str(), nbin, min, max ); tt1histSB = new TH1F( std::string("BDT__tt1histSB").append(systematics[phi]).c_str(), std::string("BDT__tt1histSB").append(systematics[phi]).c_str(), nbin, min, max ); tt2histSB = new TH1F( std::string("BDT__tt2histSB").append(systematics[phi]).c_str(), std::string("BDT__tt2histSB").append(systematics[phi]).c_str(), nbin, min, max ); tt3histSB = new TH1F( std::string("BDT__tt3histSB").append(systematics[phi]).c_str(),std::string("BDT__tt3histSB").append(systematics[phi]).c_str() , nbin, min, max ); ttphhistSB = new TH1F( std::string("BDT__ttphhistSB").append(systematics[phi]).c_str(),std::string("BDT__ttphhistSB").append(systematics[phi]).c_str() ,nbin, min, max ); wwphhistSB = new TH1F( std::string("BDT__wwphhistSB").append(systematics[phi]).c_str(),std::string("BDT__wwphhistSB").append(systematics[phi]).c_str(), nbin, min, max ); wwhistSB = new TH1F( std::string("BDT__wwhistSB").append(systematics[phi]).c_str(),std::string("BDT__wwhistSB").append(systematics[phi]).c_str() ,nbin, min, max ); wzhistSB = new TH1F( std::string("BDT__wzhistSB").append(systematics[phi]).c_str(),std::string("BDT__wzhistSB").append(systematics[phi]).c_str(), nbin, min, max ); zzhistSB = new TH1F( std::string("BDT__zzhistSB").append(systematics[phi]).c_str(),std::string("BDT__zzhistSB").append(systematics[phi]).c_str() ,nbin, min, max ); zgammahistSB = new TH1F( std::string("BDT__zgammahistSB").append(systematics[phi]).c_str(),std::string("BDT__zgammahistSB").append(systematics[phi]).c_str() ,nbin, min, max ); singletopphotonhistSB = new TH1F( std::string("BDT__singletopphotonhistSB").append(systematics[phi]).c_str(), std::string("BDT__singletopphotonhistSB").append(systematics[phi]).c_str(),nbin, min, max); singleantitopphotonhistSB = new TH1F( std::string("BDT__singleantitopphotonhistSB").append(systematics[phi]).c_str(), std::string("BDT__singleantitopphotonhistSB").append(systematics[phi]).c_str(),nbin, min, max ); signalhistSB5= new TH1F( std::string("BDT__signal5SB").append(systematics[phi]).c_str(),std::string("BDT__signal5SB").append(systematics[phi]).c_str() ,nbin, min, max ); signalhistSB10 = new TH1F( std::string("BDT__signalSB10").append(systematics[phi]).c_str(),std::string("BDT__signalSB10").append(systematics[phi]).c_str() ,nbin, min, max ); signalhistSB20 = new TH1F( std::string("BDT__signalSB20").append(systematics[phi]).c_str(),std::string("BDT__signalSB20").append(systematics[phi]).c_str() ,nbin, min, max ); signalhistSB30 = new TH1F( std::string("BDT__signalSB30").append(systematics[phi]).c_str(),std::string("BDT__signalSB30").append(systematics[phi]).c_str() ,nbin,min, max ); signalhistSB40 = new TH1F( std::string("BDT__signalSB40").append(systematics[phi]).c_str(),std::string("BDT__signalSB40").append(systematics[phi]).c_str() ,nbin,min, max ); hists.push_back(zjethist); hists.push_back(phjethist); hists.push_back(wphjethist); //hists.push_back(wjethist); hists.push_back(twchhist); hists.push_back(tbarwhist); hists.push_back(tschhist); hists.push_back(tbarschhist); hists.push_back(ttchhist); hists.push_back(tbartchhist); hists.push_back(tt1hist); hists.push_back(tt2hist); hists.push_back(tt3hist); hists.push_back(ttphhist); hists.push_back(wwphhist); hists.push_back(wwhist); hists.push_back(wzhist); hists.push_back(zzhist); hists.push_back(zgammahist); hists.push_back(singletopphotonhist); hists.push_back(singleantitopphotonhist); hists.push_back(signalhist5); hists.push_back(signalhist10); hists.push_back(signalhist20); hists.push_back(signalhist30); hists.push_back(signalhist40); SBhists.push_back(zjethistSB); SBhists.push_back(phjethistSB); SBhists.push_back(wphjethistSB); SBhists.push_back(twchhistSB); SBhists.push_back(tbarwhistSB); SBhists.push_back(tschhistSB); SBhists.push_back(tbarschhistSB); SBhists.push_back(ttchhistSB); SBhists.push_back(tbartchhistSB); SBhists.push_back(tt1histSB); SBhists.push_back(tt2histSB); SBhists.push_back(tt3histSB); SBhists.push_back(ttphhistSB); SBhists.push_back(wwphhistSB); SBhists.push_back(wwhistSB); SBhists.push_back(wzhistSB); SBhists.push_back(zzhistSB); SBhists.push_back(zgammahistSB); SBhists.push_back(singletopphotonhistSB); SBhists.push_back(singleantitopphotonhistSB); SBhists.push_back(signalhistSB5); SBhists.push_back(signalhistSB10); SBhists.push_back(signalhistSB20); SBhists.push_back(signalhistSB30); SBhists.push_back(signalhistSB40); for(unsigned int idx=0; idx<samples_.size(); ++idx){ hists[idx]->Sumw2();} for(unsigned int idx=0; idx<samples_.size(); ++idx){ TFile *input(0); TString fname; if (phi<6) fname =systematics[phi]+"/"+samples_[idx]; else fname =samples_[idx]; if (!gSystem->AccessPathName( fname )) input = TFile::Open( fname ); // check if file in local directory exists else input = TFile::Open( "http://root.cern.ch/files/tmva_class_example.root" ); // if not: download from ROOT server if (!input) { std::cout << "ERROR: could not open data file" << std::endl; exit(1); } std::cout << "--- TMVAClassificationApp : Using input file: " << input->GetName() << std::endl; // --- Event loop std::vector<double> *myptphoton=0; std::vector<double> *myetaphoton=0; std::vector<double> *myptmuon=0; std::vector<double> *myetamuon=0; std::vector<double> *myptjet=0; std::vector<double> *myetajet=0; std::vector<double> *mymasstop=0; //std::vector<double> *mymtw=0; std::vector<double> *mydeltaRphotonjet=0; std::vector<double> *mydeltaRphotonmuon=0; //std::vector<double> *myht=0; std::vector<double> *mycostopphoton=0; std::vector<double> *mydeltaphiphotonmet=0; std::vector<double> *mycvsdiscriminant=0; std::vector<double> *myjetmultiplicity=0; //std::vector<double> *mybjetmultiplicity=0; //std::vector<double> *myleptoncharge=0; std::vector<double> *myweight=0; std::vector<double> *mybtagSF=0; std::vector<double> *mybtagSFup=0; std::vector<double> *mybtagSFdown=0; std::vector<double> *mymistagSFup=0; std::vector<double> *mymistagSFdown=0; std::vector<double> *mytriggerSF=0; std::vector<double> *mytriggerSFup=0; std::vector<double> *mytriggerSFdown=0; std::vector<double> *myphotonSF=0; std::vector<double> *myphotonSFup=0; std::vector<double> *myphotonSFdown=0; std::vector<double> *mypileupSF=0; std::vector<double> *mypileupSFup=0; std::vector<double> *mypileupSFdown=0; std::vector<double> *mymuonSFup=0; std::vector<double> *mymuonSFdown=0; std::vector<double> *mymuonSF=0; std::vector<double> *myjetmatchinginfo=0; std::vector<double> *mycoswphoton=0; std::vector<double> *myphiphoton=0; std::vector<double> *mysigmaietaieta=0; std::cout << "--- Select signal sample" << std::endl; TTree* theTree = (TTree*)input->Get("analyzestep2/atq"); // Int_t myjetmultiplicity, mybjetmultiplicity , myleptoncharge; // Float_t userVar1, userVar2; theTree->SetBranchAddress("ptphoton", &myptphoton ); theTree->SetBranchAddress( "etaphoton", &myetaphoton ); theTree->SetBranchAddress( "ptmuon", &myptmuon ); theTree->SetBranchAddress( "etamuon", &myetamuon ); theTree->SetBranchAddress( "ptjet", &myptjet ); theTree->SetBranchAddress( "etajet", &myetajet ); theTree->SetBranchAddress( "masstop", &mymasstop ); // theTree->SetBranchAddress( "mtw", &mymtw ); theTree->SetBranchAddress( "deltaRphotonjet", &mydeltaRphotonjet ); theTree->SetBranchAddress( "deltaRphotonmuon", &mydeltaRphotonmuon ); // theTree->SetBranchAddress( "ht", &myht ); theTree->SetBranchAddress( "costopphoton", &mycostopphoton ); theTree->SetBranchAddress( "jetmultiplicity", &myjetmultiplicity ); // theTree->SetBranchAddress( "bjetmultiplicity", &mybjetmultiplicity ); theTree->SetBranchAddress( "deltaphiphotonmet", &mydeltaphiphotonmet ); theTree->SetBranchAddress( "cvsdiscriminant", &mycvsdiscriminant ); theTree->SetBranchAddress( "coswphoton", &mycoswphoton ); // theTree->SetBranchAddress( "leptoncharge", &myleptoncharge ); theTree->SetBranchAddress( "weight", &myweight); theTree->SetBranchAddress( "btagSF", &mybtagSF); theTree->SetBranchAddress( "btagSFup", &mybtagSFup); theTree->SetBranchAddress( "btagSFdown", &mybtagSFdown); theTree->SetBranchAddress( "mistagSFup", &mymistagSFup); theTree->SetBranchAddress( "mistagSFdown", &mymistagSFdown); theTree->SetBranchAddress( "triggerSF", &mytriggerSF); theTree->SetBranchAddress( "triggerSFup", &mytriggerSFup); theTree->SetBranchAddress( "triggerSFdown", &mytriggerSFdown); theTree->SetBranchAddress( "photonSF", &myphotonSF); theTree->SetBranchAddress( "photonSFup", &myphotonSFup); theTree->SetBranchAddress( "photonSFdown", &myphotonSFdown); theTree->SetBranchAddress( "muonSF", &mymuonSF); theTree->SetBranchAddress( "muonSFup", &mymuonSFup); theTree->SetBranchAddress( "muonSFdown", &mymuonSFdown); theTree->SetBranchAddress( "pileupSF", &mypileupSF); theTree->SetBranchAddress( "pileupSFup", &mypileupSFup); theTree->SetBranchAddress( "pileupSFdown", &mypileupSFdown); theTree->SetBranchAddress( "jetmatchinginfo", &myjetmatchinginfo ); theTree->SetBranchAddress( "phiphoton", &myphiphoton ); theTree->SetBranchAddress( "sigmaieta", &mysigmaietaieta ); // std::cout << "--- Processing: " << theTree->GetEntries() << " events" << std::endl; TStopwatch sw; sw.Start(); for (Long64_t ievt=0; ievt<theTree->GetEntries();ievt++) { // std::cout << "--- ... Processing event: " << ievt << std::endl; double finalweight; if (ievt%5000 == 0) std::cout << "--- ... Processing event: " << ievt << std::endl; theTree->GetEntry(ievt); //for (int l=0;l<sizeof(myptphoton);l++){ //std::cout << "--- ... reza: " << myptphoton[l] <<std::endl; //} //std::cout << "--- ......................."<< (*mycvsdiscriminant)[0]<<std::endl; // --- Return the MVA outputs and fill into histograms finalweight=(*myweight)[0]; //cout<<(*myweight)[0]<<endl; eventwight["__PU__plus"]=((*myweight)[0]*(*mypileupSFup)[0])/(*mypileupSF)[0]; eventwight["__PU__minus"]=((*myweight)[0]*(*mypileupSFdown)[0])/(*mypileupSF)[0]; eventwight["__TRIG__plus"]=((*myweight)[0]*(*mytriggerSFup)[0])/(*mytriggerSF)[0]; eventwight["__TRIG__minus"]=((*myweight)[0]*(*mytriggerSFdown)[0])/(*mytriggerSF)[0]; eventwight["__BTAG__plus"]=((*myweight)[0]*(*mybtagSFup)[0])/(*mybtagSF)[0]; eventwight["__BTAG__minus"]=((*myweight)[0]*(*mybtagSFdown)[0])/(*mybtagSF)[0]; eventwight["__MISSTAG__plus"]=((*myweight)[0]*(*mymistagSFup)[0])/(*mybtagSF)[0]; eventwight["__MISSTAG__minus"]=((*myweight)[0]*(*mymistagSFdown)[0])/(*mybtagSF)[0]; eventwight["__MUON__plus"]=((*myweight)[0]*(*mymuonSFup)[0])/(*mymuonSF)[0]; eventwight["__MUON__minus"]=((*myweight)[0]*(*mymuonSFdown)[0])/(*mymuonSF)[0]; eventwight["__PHOTON__plus"]=((*myweight)[0]*(*myphotonSFup)[0])/(*myphotonSF)[0]; eventwight["__PHOTON__minus"]=((*myweight)[0]*(*myphotonSFdown)[0])/(*myphotonSF)[0]; eventwight[""]=(*myweight)[0]; //if (phi<4) finalweight=(*myweight)[0]; if (phi>7) finalweight=eventwight[systematics[phi].c_str()]; //if (samples_[idx]=="SIGNALtGu.root") cout<<"negative event weight"<<finalweight<<" "<<endl; //if (samples_[idx]=="WPHJET") finalweight=(*mypileupSF)[0]*(*mytriggerSF)[0]*(*mybtagSF)[0]*(*mymuonSF)[0]*(*myphotonSF)[0]; //if (finalweight<0) finalweight=30; //cout<<"negative event weight"<<finalweight<<" "<<ptphoton<<endl; if(sqrt(pow((*myetaphoton )[0]+1.76,2)+pow((*myphiphoton )[0]-1.37,2))>0.05 && sqrt(pow((*myetaphoton )[0]-2.37,2)+pow((*myphiphoton )[0]-2.69,2))>0.05){ if(sqrt(pow((*myetaphoton )[0]- 1.61,2)+pow((*myphiphoton )[0]+2.05,2))>0.05 && sqrt(pow((*myetaphoton )[0]-1.75,2)+pow((*myphiphoton )[0]-2.12,2))>0.05){ if((*mymasstop )[0]>mtopdown && (*mymasstop )[0]<mtopup){ hists[idx] ->Fill( (*mydeltaRphotonjet)[0] ,finalweight*scales[idx] ); if (samples_[idx]=="WPHJET.root") insidewphjet=insidewphjet+finalweight; } else { SBhists[idx] ->Fill( (*mydeltaRphotonjet)[0] ,finalweight*scales[idx] ); if (samples_[idx]=="WPHJET.root") outsidewphjet=outsidewphjet+finalweight;} }} } // Get elapsed time sw.Stop(); std::cout << "--- End of event loop: "; sw.Print(); delete myptphoton; delete myetaphoton; delete myptmuon; delete myetamuon; delete myptjet; delete myetajet; delete mymasstop; //delete mymtw; delete mydeltaRphotonjet; delete mydeltaRphotonmuon; //delete myht; delete mycostopphoton; delete mydeltaphiphotonmet; delete mycvsdiscriminant; delete myjetmultiplicity; //delete mybjetmultiplicity; //delete myleptoncharge; //delete myplot; delete mybtagSF; delete mybtagSFup; delete mybtagSFdown; delete mymistagSFup; delete mytriggerSF; delete mytriggerSFup; delete mytriggerSFdown; delete myphotonSF; delete myphotonSFup; delete myphotonSFdown; delete mypileupSF; delete mypileupSFup; delete mypileupSFdown; delete input; delete myjetmatchinginfo; //if (idx==samples_.size()-5) hists[idx]->Scale(5/hists[idx]->Integral()); //if (idx==samples_.size()-4) hists[idx]->Scale(10/hists[idx]->Integral()); //if (idx==samples_.size()-3) hists[idx]->Scale(20/hists[idx]->Integral()); //if (idx==samples_.size()-2) hists[idx]->Scale(30/hists[idx]->Integral()); //if (idx==samples_.size()-1) hists[idx]->Scale(40/hists[idx]->Integral()); if (samples_[idx]=="WPHJET.root") hists[idx]->Scale(3173/hists[idx]->Integral()); if (samples_[idx]=="TTBAR2.root") hists[idx]->Add(hists[idx-1]); if (samples_[idx]=="TTBAR3.root") hists[idx]->Add(hists[idx-1]); if (samples_[idx]=="SINGLE-ANTITOP-PH.root") hists[idx]->Add(hists[idx-1]); if (samples_[idx]=="TBAR-W-CH.root") hists[idx]->Add(hists[idx-1]); if (samples_[idx]=="T-S-CH.root") hists[idx]->Add(hists[idx-1]); if (samples_[idx]=="TBAR-S-CH.root") hists[idx]->Add(hists[idx-1]); if (samples_[idx]=="T-T-CH.root") hists[idx]->Add(hists[idx-1]); if (samples_[idx]=="TBAR-T-CH.root") hists[idx]->Add(hists[idx-1]); if (samples_[idx]=="WZ.root") hists[idx]->Add(hists[idx-1]); if (samples_[idx]=="ZZ.root") hists[idx]->Add(hists[idx-1]); if (!(samples_[idx]=="TTBAR1.root" || samples_[idx]=="TTBAR2.root"|| samples_[idx]=="SINGLE-TOP-PH.root"||samples_[idx]=="SIGNALtGu.root" || samples_[idx]=="WPHJET.root"||samples_[idx]=="T-W-CH.root" ||samples_[idx]=="TBAR-W-CH.root" ||samples_[idx]=="T-S-CH.root" ||samples_[idx]=="TBAR-S-CH.root" ||samples_[idx]=="T-T-CH.root" ||samples_[idx]=="WW.root" ||samples_[idx]=="WZ.root") ) hList->Add(hists[idx]); if (idx==samples_.size()-1)hList->Add(hists[idx]); if (systematics[phi]==""){ ihists.push_back(hists[idx]); iSBhists.push_back(SBhists[idx]);} } } TH1F *data1hist(0), *data2hist(0) ,*data3hist(0),*datahistsideband(0); data1hist = new TH1F( "mu_BDT__data1hist", "mu_BDT__data1hist", nbin, min, max ); data1hist->Sumw2(); data2hist = new TH1F( "mu_BDT__data2hist", "mu_BDT__data2hist", nbin, min, max ); data2hist->Sumw2(); data3hist = new TH1F( "BDT__DATA", "BDT__DATA", nbin, min, max ); data3hist->Sumw2(); datahistsideband = new TH1F( "BDT__wphjethist", "BDT__wphjethist", nbin,min, max ); datahistsideband->Sumw2(); datahists.push_back(data1hist); datahists.push_back(data2hist); datahists.push_back(data3hist); datahists.push_back(datahistsideband); for(unsigned int idx=0; idx<datasamples_.size(); ++idx){ TFile *input(0); TString fname =datasamples_[idx]; if (!gSystem->AccessPathName( fname )) input = TFile::Open( fname ); // check if file in local directory exists else input = TFile::Open( "http://root.cern.ch/files/tmva_class_example.root" ); // if not: download from ROOT server if (!input) { std::cout << "ERROR: could not open data file" << std::endl; exit(1); } std::cout << "--- TMVAClassificationApp : Using input file: " << input->GetName() << std::endl; // --- Event loop // Prepare the event tree // - here the variable names have to corres[1]ponds to your tree // - you can use the same variables as above which is slightly faster, // but of course you can use different ones and copy the values inside the event loop // std::vector<double> *myptphoton=0; std::vector<double> *myetaphoton=0; std::vector<double> *myptmuon=0; std::vector<double> *myetamuon=0; std::vector<double> *myptjet=0; std::vector<double> *myetajet=0; std::vector<double> *mymasstop=0; //std::vector<double> *mymtw=0; std::vector<double> *mydeltaRphotonjet=0; std::vector<double> *mydeltaRphotonmuon=0; //std::vector<double> *myht=0; std::vector<double> *mycostopphoton=0; std::vector<double> *mydeltaphiphotonmet=0; std::vector<double> *mycvsdiscriminant=0; std::vector<double> *myjetmultiplicity=0; //std::vector<double> *mybjetmultiplicity=0; //std::vector<double> *myleptoncharge=0; std::vector<double> *mycoswphoton=0; std::vector<double> *myphiphoton=0; std::vector<double> *mysigmaietaieta=0; std::cout << "--- Select signal sample" << std::endl; TTree* theTree = (TTree*)input->Get("analyzestep2/atq"); // Int_t myjetmultiplicity, mybjetmultiplicity , myleptoncharge; // Float_t userVar1, userVar2; theTree->SetBranchAddress("ptphoton", &myptphoton ); theTree->SetBranchAddress( "etaphoton", &myetaphoton ); theTree->SetBranchAddress( "ptmuon", &myptmuon ); theTree->SetBranchAddress( "etamuon", &myetamuon ); theTree->SetBranchAddress( "ptjet", &myptjet ); theTree->SetBranchAddress( "etajet", &myetajet ); theTree->SetBranchAddress( "masstop", &mymasstop ); // theTree->SetBranchAddress( "mtw", &mymtw ); theTree->SetBranchAddress( "deltaRphotonjet", &mydeltaRphotonjet ); theTree->SetBranchAddress( "deltaRphotonmuon", &mydeltaRphotonmuon ); // theTree->SetBranchAddress( "ht", &myht ); theTree->SetBranchAddress( "costopphoton", &mycostopphoton ); theTree->SetBranchAddress( "jetmultiplicity", &myjetmultiplicity ); // theTree->SetBranchAddress( "bjetmultiplicity", &mybjetmultiplicity ); theTree->SetBranchAddress( "deltaphiphotonmet", &mydeltaphiphotonmet ); theTree->SetBranchAddress( "cvsdiscriminant", &mycvsdiscriminant ); theTree->SetBranchAddress( "coswphoton", &mycoswphoton ); // theTree->SetBranchAddress( "leptoncharge", &myleptoncharge ); theTree->SetBranchAddress( "phiphoton", &myphiphoton ); theTree->SetBranchAddress( "sigmaieta", &mysigmaietaieta ); std::cout << "--- Processing: " << theTree->GetEntries() << " events" << std::endl; TStopwatch sw; sw.Start(); for (Long64_t ievt=0; ievt<theTree->GetEntries();ievt++) { // std::cout << "--- ... Processing event: " << ievt << std::endl; if (ievt%5000 == 0) std::cout << "--- ... Processing event: " << ievt << std::endl; theTree->GetEntry(ievt); if(sqrt(pow((*myetaphoton )[0]+1.76,2)+pow((*myphiphoton )[0]-1.37,2))>0.05 && sqrt(pow((*myetaphoton )[0]-2.37,2)+pow((*myphiphoton )[0]-2.69,2))>0.05){ if(sqrt(pow((*myetaphoton )[0]- 1.61,2)+pow((*myphiphoton )[0]+2.05,2))>0.05 && sqrt(pow((*myetaphoton )[0]-1.75,2)+pow((*myphiphoton )[0]-2.12,2))>0.05){ if((*mymasstop )[0]>mtopdown && (*mymasstop )[0]<mtopup) datahists[idx] ->Fill( (*mydeltaRphotonjet)[0]); else datahists[3]->Fill( (*mydeltaRphotonjet)[0] ); }}} // Get elapsed time sw.Stop(); std::cout << "--- End of event loop: "; sw.Print(); delete myptphoton; delete myetaphoton; delete myptmuon; delete myetamuon; delete myptjet; delete myetajet; delete mymasstop; //delete mymtw; delete mydeltaRphotonjet; delete mydeltaRphotonmuon; //delete myht; delete mycostopphoton; delete mydeltaphiphotonmet; delete mycvsdiscriminant; delete myjetmultiplicity; //delete mybjetmultiplicity; //delete myleptoncharge; //delete myplot; delete input; } for(unsigned int idx=1; idx<datasamples_.size(); ++idx){ datahists[idx]->Add(datahists[idx-1]); } hList->Add(datahists[2]); TH1F *data1histrev(0), *data2histrev(0) ,*data3histrev(0), *datahistrevsideband(0); data1histrev = new TH1F( "BDT__data1histrev", "BDT__data1histrev", nbin,min, max ); data2histrev = new TH1F( "BDT__data2histrev", "BDT__data2histrev", nbin,min, max ); data3histrev = new TH1F( "BDT__wjet", "BDT__wjet", nbin, min, max ); datahistrevsideband = new TH1F( "mu_BDT__DATArevsideband", "mu_BDT__DATArevsideband", nbin, min, max ); revDATAhists.push_back(data1histrev); revDATAhists.push_back(data2histrev); revDATAhists.push_back(data3histrev); revDATAhists.push_back(datahistrevsideband); for(unsigned int idx=0; idx<datasamplesreverse_.size(); ++idx){ TFile *input(0); TString fname =datasamplesreverse_[idx]; if (!gSystem->AccessPathName( fname )) input = TFile::Open( fname ); // check if file in local directory exists else input = TFile::Open( "http://root.cern.ch/files/tmva_class_example.root" ); // if not: download from ROOT server if (!input) { std::cout << "ERROR: could not open data file" << std::endl; exit(1); } std::cout << "--- TMVAClassificationApp : Using input file: " << input->GetName() << std::endl; std::vector<double> *myptphoton=0; std::vector<double> *myetaphoton=0; std::vector<double> *myptmuon=0; std::vector<double> *myetamuon=0; std::vector<double> *myptjet=0; std::vector<double> *myetajet=0; std::vector<double> *mymasstop=0; //std::vector<double> *mymtw=0; std::vector<double> *mydeltaRphotonjet=0; std::vector<double> *mydeltaRphotonmuon=0; //std::vector<double> *myht=0; std::vector<double> *mycostopphoton=0; std::vector<double> *mydeltaphiphotonmet=0; std::vector<double> *mycvsdiscriminant=0; std::vector<double> *myjetmultiplicity=0; std::vector<double> *mycoswphoton=0; //std::vector<double> *mybjetmultiplicity=0; //std::vector<double> *myleptoncharge=0; std::vector<double> *myphiphoton=0; std::vector<double> *mysigmaietaieta=0; TTree* theTree = (TTree*)input->Get("analyzestep2/atq"); theTree->SetBranchAddress("ptphoton", &myptphoton ); theTree->SetBranchAddress( "etaphoton", &myetaphoton ); theTree->SetBranchAddress( "ptmuon", &myptmuon ); theTree->SetBranchAddress( "etamuon", &myetamuon ); theTree->SetBranchAddress( "ptjet", &myptjet ); theTree->SetBranchAddress( "etajet", &myetajet ); theTree->SetBranchAddress( "masstop", &mymasstop ); // theTree->SetBranchAddress( "mtw", &mymtw ); theTree->SetBranchAddress( "deltaRphotonjet", &mydeltaRphotonjet ); theTree->SetBranchAddress( "deltaRphotonmuon", &mydeltaRphotonmuon ); // theTree->SetBranchAddress( "ht", &myht ); theTree->SetBranchAddress( "costopphoton", &mycostopphoton ); theTree->SetBranchAddress( "jetmultiplicity", &myjetmultiplicity ); // theTree->SetBranchAddress( "bjetmultiplicity", &mybjetmultiplicity ); theTree->SetBranchAddress( "deltaphiphotonmet", &mydeltaphiphotonmet ); theTree->SetBranchAddress( "cvsdiscriminant", &mycvsdiscriminant ); theTree->SetBranchAddress( "coswphoton", &mycoswphoton ); // theTree->SetBranchAddress( "leptoncharge", &myleptoncharge ); theTree->SetBranchAddress( "phiphoton", &myphiphoton ); theTree->SetBranchAddress( "sigmaieta", &mysigmaietaieta ); // Efficiency calculator for cut method std::cout << "--- Processing: " << theTree->GetEntries() << " events" << std::endl; TStopwatch sw; sw.Start(); for (Long64_t ievt=0; ievt<theTree->GetEntries();ievt++) { // std::cout << "--- ... Processing event: " << ievt << std::endl; if (ievt%5000 == 0) std::cout << "--- ... Processing event: " << ievt << std::endl; theTree->GetEntry(ievt); //for (int l=0;l<sizeof(myptphoton);l++){ if(sqrt(pow((*myetaphoton )[0]+1.76,2)+pow((*myphiphoton )[0]-1.37,2))>0.05 && sqrt(pow((*myetaphoton )[0]-2.37,2)+pow((*myphiphoton )[0]-2.69,2))>0.05){ if(sqrt(pow((*myetaphoton )[0]- 1.61,2)+pow((*myphiphoton )[0]+2.05,2))>0.05 && sqrt(pow((*myetaphoton )[0]-1.75,2)+pow((*myphiphoton )[0]-2.12,2))>0.05){ if ((abs((*myetaphoton )[0]) >1.444 && (*mysigmaietaieta)[0] >0.031)||(abs((*myetaphoton )[0]) <1.444 && (*mysigmaietaieta)[0] >0.011)) { if((*mymasstop )[0]>mtopdown && (*mymasstop )[0]<mtopup) { revDATAhists[idx]->Fill( (*mydeltaRphotonjet)[0]); insidewjet=insidewjet+1;} else {revDATAhists[3]->Fill( (*mydeltaRphotonjet)[0] ); outsidewjet=outsidewjet+1;} }}} } sw.Stop(); std::cout << "--- End of event loop: "; sw.Print(); delete myptphoton; delete myetaphoton; delete myptmuon; delete myetamuon; delete myptjet; delete myetajet; delete mymasstop; //delete mymtw; delete mydeltaRphotonjet; delete mydeltaRphotonmuon; //delete myht; delete mycostopphoton; delete mydeltaphiphotonmet; delete mycvsdiscriminant; delete myjetmultiplicity; ////delete mybjetmultiplicity; ////delete myleptoncharge; ////delete myplot; // delete input; } double wphjetscale; wphjetscale=insidewphjet/(insidewphjet+outsidewphjet); double wjetscale; wjetscale=insidewjet/(insidewjet+outsidewjet); //cout<<insidewphjet<<"insidewphjet"<<" "<<wphjetscale<<" "<<insidewjet/(insidewjet+outsidewjet)<<endl; float lumi = 1; for(unsigned int idx=1; idx<datasamplesreverse_.size(); ++idx){ revDATAhists[idx]->Add(revDATAhists[idx-1]); } revDATAhists[2]->Scale(302.91/revDATAhists[2]->Integral()); for(unsigned int idx=1; idx<revDATAhists[2]->GetNbinsX()+1; ++idx){ revDATAhists[2]->SetBinError(idx,(revDATAhists[2]->GetBinContent(idx)/revDATAhists[2]->Integral())*74.84); //if (revDATAhists[2]->GetBinError(idx)>revDATAhists[2]->GetBinContent(idx)) revDATAhists[2]->SetBinError(idx, revDATAhists[2]->GetBinContent(idx)/2); } hList->Add(revDATAhists[2]); revDATAhists[3]->Scale(302.91/revDATAhists[3]->Integral()); revDATAhists[3]->Scale((1-wjetscale)/wjetscale); //cout<<revDATAhists[2]->Integral()<<endl; datahists[3]->Add(revDATAhists[3],-1); datahists[3]->Add(iSBhists[0],-1); datahists[3]->Add(iSBhists[1],-1); for(unsigned int idx=3; idx<samples_.size()-5; ++idx){ datahists[3]->Add(iSBhists[idx],-1);} for(unsigned int idx=1; idx<nbin; ++idx){ if (datahists[3]->GetBinContent(idx)<0)datahists[3]->SetBinContent(idx,0); } datahists[3]->Scale(985.18/datahists[3]->Integral()); for(unsigned int idx=1; idx<datahists[3]->GetNbinsX()+1; ++idx){ datahists[3]->SetBinError(idx,(datahists[3]->GetBinContent(idx)/datahists[3]->Integral())*139.11);} hList->Add(datahists[3]); cout<<datahists[3]->Integral()<<endl; ///////////////////////////////////////////////////////////////////////// std::vector<string> signalsystematics; std::vector<string> signalsamples_; signalsystematics.push_back("__Qscale__plus"); signalsystematics.push_back("__Qscale__minus"); signalsystematics.push_back("__Topmass__plus"); signalsystematics.push_back("__Topmass__minus"); signalsamples_.push_back("SIGNALtGu_scaleup.root"); signalsamples_.push_back("SIGNALtGu_scaledown.root"); signalsamples_.push_back("SIGNALtGu_massup.root"); signalsamples_.push_back("SIGNALtGu_massdown.root"); float signalscales[] ={0.1084/19.145,0.0933/19.145,0.0838/19.145,0.0892/19.145}; for(unsigned int phi=0; phi<signalsystematics.size(); ++phi){ TH1F *shist5(0) , *shist10(0), *shist20(0), *shist30(0), *shist40(0); std::vector<TH1F*> Shists; shist5 = new TH1F( std::string("BDT__signal5").append(signalsystematics[phi]).c_str(),std::string("BDT__signal5").append(signalsystematics[phi]).c_str() ,nbin, min, max ); shist10 = new TH1F( std::string("BDT__signal10").append(signalsystematics[phi]).c_str(),std::string("BDT__signal10").append(signalsystematics[phi]).c_str() ,nbin, min, max ); shist20 = new TH1F( std::string("BDT__signal20").append(signalsystematics[phi]).c_str(),std::string("BDT__signal20").append(signalsystematics[phi]).c_str() ,nbin, min, max ); shist30 = new TH1F( std::string("BDT__signal30").append(signalsystematics[phi]).c_str(),std::string("BDT__signal30").append(signalsystematics[phi]).c_str() ,nbin, min, max ); shist40 = new TH1F( std::string("BDT__signal40").append(signalsystematics[phi]).c_str(),std::string("BDT__signal40").append(signalsystematics[phi]).c_str() ,nbin,min, max ); Shists.push_back(shist5); Shists.push_back(shist10); Shists.push_back(shist20); Shists.push_back(shist30); Shists.push_back(shist40); for(unsigned int idx=0; idx<Shists.size(); ++idx){ Shists[idx]->Sumw2();} TFile *input(0); TString fname; fname =signalsamples_[phi]; input = TFile::Open( fname ); std::vector<double> *myptphoton=0; std::vector<double> *myetaphoton=0; std::vector<double> *myptmuon=0; std::vector<double> *myetamuon=0; std::vector<double> *myptjet=0; std::vector<double> *myetajet=0; std::vector<double> *mymasstop=0; //std::vector<double> *mymtw=0; std::vector<double> *mydeltaRphotonjet=0; std::vector<double> *mydeltaRphotonmuon=0; //std::vector<double> *myht=0; std::vector<double> *mycostopphoton=0; std::vector<double> *mydeltaphiphotonmet=0; std::vector<double> *mycvsdiscriminant=0; std::vector<double> *myjetmultiplicity=0; //std::vector<double> *mybjetmultiplicity=0; //std::vector<double> *myleptoncharge=0; std::vector<double> *myweight=0; std::vector<double> *mybtagSF=0; std::vector<double> *mybtagSFup=0; std::vector<double> *mybtagSFdown=0; std::vector<double> *mymistagSFup=0; std::vector<double> *mymistagSFdown=0; std::vector<double> *mytriggerSF=0; std::vector<double> *mytriggerSFup=0; std::vector<double> *mytriggerSFdown=0; std::vector<double> *myphotonSF=0; std::vector<double> *myphotonSFup=0; std::vector<double> *myphotonSFdown=0; std::vector<double> *mypileupSF=0; std::vector<double> *mypileupSFup=0; std::vector<double> *mypileupSFdown=0; std::vector<double> *mymuonSFup=0; std::vector<double> *mymuonSFdown=0; std::vector<double> *mymuonSF=0; std::vector<double> *myjetmatchinginfo=0; std::vector<double> *mycoswphoton=0; std::cout << "--- Select signal sample" << std::endl; TTree* theTree = (TTree*)input->Get("analyzestep2/atq"); theTree->SetBranchAddress("ptphoton", &myptphoton ); theTree->SetBranchAddress( "etaphoton", &myetaphoton ); theTree->SetBranchAddress( "ptmuon", &myptmuon ); theTree->SetBranchAddress( "etamuon", &myetamuon ); theTree->SetBranchAddress( "ptjet", &myptjet ); theTree->SetBranchAddress( "etajet", &myetajet ); theTree->SetBranchAddress( "masstop", &mymasstop ); // theTree->SetBranchAddress( "mtw", &mymtw ); theTree->SetBranchAddress( "deltaRphotonjet", &mydeltaRphotonjet ); theTree->SetBranchAddress( "deltaRphotonmuon", &mydeltaRphotonmuon ); // theTree->SetBranchAddress( "ht", &myht ); theTree->SetBranchAddress( "costopphoton", &mycostopphoton ); theTree->SetBranchAddress( "jetmultiplicity", &myjetmultiplicity ); // theTree->SetBranchAddress( "bjetmultiplicity", &mybjetmultiplicity ); theTree->SetBranchAddress( "deltaphiphotonmet", &mydeltaphiphotonmet ); theTree->SetBranchAddress( "cvsdiscriminant", &mycvsdiscriminant ); theTree->SetBranchAddress( "coswphoton", &mycoswphoton ); // theTree->SetBranchAddress( "leptoncharge", &myleptoncharge ); theTree->SetBranchAddress( "weight", &myweight); theTree->SetBranchAddress( "btagSF", &mybtagSF); theTree->SetBranchAddress( "btagSFup", &mybtagSFup); theTree->SetBranchAddress( "btagSFdown", &mybtagSFdown); theTree->SetBranchAddress( "mistagSFup", &mymistagSFup); theTree->SetBranchAddress( "mistagSFdown", &mymistagSFdown); theTree->SetBranchAddress( "triggerSF", &mytriggerSF); theTree->SetBranchAddress( "triggerSFup", &mytriggerSFup); theTree->SetBranchAddress( "triggerSFdown", &mytriggerSFdown); theTree->SetBranchAddress( "photonSF", &myphotonSF); theTree->SetBranchAddress( "photonSFup", &myphotonSFup); theTree->SetBranchAddress( "photonSFdown", &myphotonSFdown); theTree->SetBranchAddress( "muonSF", &mymuonSF); theTree->SetBranchAddress( "muonSFup", &mymuonSFup); theTree->SetBranchAddress( "muonSFdown", &mymuonSFdown); theTree->SetBranchAddress( "pileupSF", &mypileupSF); theTree->SetBranchAddress( "pileupSFup", &mypileupSFup); theTree->SetBranchAddress( "pileupSFdown", &mypileupSFdown); theTree->SetBranchAddress( "jetmatchinginfo", &myjetmatchinginfo ); for (Long64_t ievt=0; ievt<theTree->GetEntries();ievt++) { double finalweight; theTree->GetEntry(ievt); finalweight=(*myweight)[0]; //cout<<(*myweight)[0]<<endl; if((*mymasstop )[0]>mtopdown && (*mymasstop )[0]<mtopup){ Shists[0] ->Fill( (*mydeltaRphotonjet)[0],finalweight*signalscales[phi]); Shists[1] ->Fill((*mydeltaRphotonjet)[0],finalweight*signalscales[phi]); Shists[2] ->Fill( (*mydeltaRphotonjet)[0],finalweight*signalscales[phi]); Shists[3] ->Fill( (*mydeltaRphotonjet)[0],finalweight*signalscales[phi]); Shists[4] ->Fill( (*mydeltaRphotonjet)[0],finalweight*signalscales[phi]); } } delete myptphoton; delete myetaphoton; delete myptmuon; delete myetamuon; delete myptjet; delete myetajet; delete mymasstop; //delete mymtw; delete mydeltaRphotonjet; delete mydeltaRphotonmuon; //delete myht; delete mycostopphoton; delete mydeltaphiphotonmet; delete mycvsdiscriminant; delete myjetmultiplicity; //delete mybjetmultiplicity; //delete myleptoncharge; //delete myplot; delete mybtagSF; delete mybtagSFup; delete mybtagSFdown; delete mymistagSFup; delete mytriggerSF; delete mytriggerSFup; delete mytriggerSFdown; delete myphotonSF; delete myphotonSFup; delete myphotonSFdown; delete mypileupSF; delete mypileupSFup; delete mypileupSFdown; delete input; delete myjetmatchinginfo; /*Shists[0]->Scale(5/Shists[0]->Integral()); Shists[1]->Scale(10/Shists[1]->Integral()); Shists[2]->Scale(20/Shists[2]->Integral()); Shists[3]->Scale(30/Shists[3]->Integral()); */ //Shists[4]->Scale(40/Shists[4]->Integral()); //hList->Add(Shists[0]); //hList->Add(Shists[1]); //hList->Add(Shists[2]); //hList->Add(Shists[3]); hList->Add(Shists[4]); } ///////////////////////////////////////////////////////////////////////// TFile *target = new TFile( "DELTARIPHJET.root","RECREATE" ); hList->Write(); target->Close(); }
void RunEbyEFlowAnalysisFWLite( int ffrom, int fto, double zvtxmin, double zvtxmax, int nmin, int nmax, int centmin, int centmax) { setup(ffrom, fto, zvtxmin, zvtxmax, nmin, nmax, centmin, centmax); TStopwatch *watch = new TStopwatch(); // Run the analysis TList* files = GetFileList(gFilesetname.Data()); if(!files) { cerr << "Could not retrieve fileset: " << gFilesetname << endl; return; } vector<string> fileNames = GetDataVector(files,gFfrom,gFto); fwlite::ChainEvent event(fileNames); //Initialize the analyzer EbyEFlowAnalyzerFWLite* corr = new EbyEFlowAnalyzerFWLite(event); corr->SetCutParameters(gCut); TString strtrgid = "Track"; if(gSystem->Getenv("TRGID")) strtrgid = gSystem->Getenv("TRGID"); DiHadronCorrelationMultiBaseFWLite::ParticleType gTrgID = corr->GetParticleID(strtrgid); TString strassid = "Track"; if(gSystem->Getenv("ASSID")) strassid = gSystem->Getenv("ASSID"); DiHadronCorrelationMultiBaseFWLite::ParticleType gAssID = corr->GetParticleID(strassid); corr->SetTrgID(gTrgID); corr->SetAssID(gAssID); if(gCentfilename.Contains("root")) { cout<<"Running correlation analysis in Heavy Ion!"<<endl; TFile* fcentfile = new TFile(gCentfilename.Data()); if(fcentfile->IsOpen()) corr->SetCentrality(fcentfile,gCenttablename,gNCentBins,gCentRunnum); else cout<<"Centrality table cannot be opened!"<<endl; } else cout<<"Running correlation analysis in pp!"<<endl; if(gEffhistname.Contains("root")) { TFile* feffhist = new TFile(gEffhistname.Data()); if(feffhist->IsOpen()) { TH3D* htotaleff = 0; if(!gCut.IsHI) htotaleff = (TH3D*)feffhist->Get("rTotalEff3D"); else { int histcentbin = -1; if((gCut.centmin>=0 && gCut.centmax<=2) || gCut.centmin>=50) histcentbin = 0; if(gCut.centmin>=2 && gCut.centmax<=4) histcentbin = 1; if(gCut.centmin>=4 && gCut.centmax<=12) histcentbin = 2; if(gCut.centmin>=12 && gCut.centmax<=20) histcentbin = 3; if(gCut.centmin>=20 && gCut.centmax<=40) histcentbin = 4; if(gCut.centmin==-1 && gCut.centmax==-1) histcentbin = 4; htotaleff = (TH3D*)feffhist->Get(Form("Tot_%d",histcentbin)); } corr->LoadEffWeight(htotaleff); cout<<"Tracking efficiency weighting histogram is loaded!"<<endl; } else cout<<"Tracking efficiency weighting file cannot be opened!"<<endl; } else cout<<"No Tracking efficiency weighting histogram is found, or it's running MC!"<<endl; if(gTrghistname.Contains("root")) { TFile* ftrghist = new TFile(gTrghistname.Data()); if(ftrghist->IsOpen()) { corr->LoadTrgWeight((TH1D*)ftrghist->Get("trgEff")); cout<<"Triggering efficiency weighting histogram is loaded!"<<endl; } else cout<<"Triggering efficiency weighting file cannot be opened!"<<endl; } else cout<<"No Triggering efficiency weighting histogram is found, or it's running MC!"<<endl; if(gPileupdistfunchistname.Contains("root")) { TFile* fpileupdistfunchist = new TFile(gPileupdistfunchistname.Data()); if(fpileupdistfunchist->IsOpen()) { corr->LoadPileUpDistFunc((TH1D*)fpileupdistfunchist->Get("distfunc")); cout<<"Pileup distfunc histogram is loaded!"<<endl; } else cout<<"Pileup distfunc file cannot be opened!"<<endl; } corr->Process(); // open output file TString outputfilename = Form("%s/%s/unmerged/%s_%s_ffrom%d_fto%d_vtxmin%.1f_vtxmax%.1f_nmin%d_nmax%d_etatrg%.1f-%.1f_etaass%.1f-%.1f_centmin%d_centmax%d.root",gOutputDir.Data(),gEventtype.Data(),gEventtype.Data(),gTag.Data(),gFfrom,gFto,gCut.zvtxmin,gCut.zvtxmax,gCut.nmin,gCut.nmax,gCut.etatrgmin,gCut.etatrgmax,gCut.etaassmin,gCut.etaassmax,gCut.centmin,gCut.centmax); TFile* outf = new TFile(outputfilename.Data(),"recreate"); // Save the outputs TList* output = corr->GetOutputs(); if(outf && output) { outf->cd(); output->Write(); cout << "Output file " << outf->GetName() << " written: " << endl; outf->ls(); outf->Close(); if(outf) delete outf; } delete output; watch->Stop(); watch->Print(); }
int main(int argc, char* argv[]) { TApplication theApp(srcName.Data(), &argc, argv); //============================================================================= if (argc<5) return -1; TString sPath = argv[1]; if (sPath.IsNull()) return -1; TString sFile = argv[2]; if (sFile.IsNull()) return -1; TString sJetR = argv[3]; if (sJetR.IsNull()) return -1; TString sSjeR = argv[4]; if (sSjeR.IsNull()) return -1; //============================================================================= sPath.ReplaceAll("#", "/"); //============================================================================= double dJetR = -1.; if (sJetR=="JetR02") dJetR = 0.2; if (sJetR=="JetR03") dJetR = 0.3; if (sJetR=="JetR04") dJetR = 0.4; if (sJetR=="JetR05") dJetR = 0.5; if (dJetR<0.) return -1; cout << "Jet R = " << dJetR << endl; //============================================================================= double dSjeR = -1.; if (sSjeR=="SjeR01") dSjeR = 0.1; if (sSjeR=="SjeR02") dSjeR = 0.2; if (sSjeR=="SjeR03") dSjeR = 0.3; if (sSjeR=="SjeR04") dSjeR = 0.4; if (dSjeR<0.) return -1; cout << "Sub-jet R = " << dSjeR << endl; //============================================================================= const int multiLHC = 3000; const double dJetsPtMin = 0.001; const double dCutEtaMax = 1.6; const double dJetEtaMax = 1.; const double dJetAreaRef = TMath::Pi() * dJetR * dJetR; fastjet::GhostedAreaSpec areaSpc(dCutEtaMax); fastjet::JetDefinition jetsDef(fastjet::antikt_algorithm, dJetR, fastjet::BIpt_scheme, fastjet::Best); //fastjet::AreaDefinition areaDef(fastjet::active_area,areaSpc); fastjet::AreaDefinition areaDef(fastjet::active_area_explicit_ghosts,areaSpc); fastjet::JetDefinition bkgsDef(fastjet::kt_algorithm, 0.2, fastjet::BIpt_scheme, fastjet::Best); fastjet::AreaDefinition aBkgDef(fastjet::active_area_explicit_ghosts, areaSpc); fastjet::Selector selectJet = fastjet::SelectorAbsEtaMax(dJetEtaMax); fastjet::Selector selectRho = fastjet::SelectorAbsEtaMax(dCutEtaMax-0.2); fastjet::Selector selecHard = fastjet::SelectorNHardest(2); fastjet::Selector selectBkg = selectRho * (!(selecHard)); fastjet::JetMedianBackgroundEstimator bkgsEstimator(selectBkg, bkgsDef, aBkgDef); //fastjet::Subtractor bkgSubtractor(&bkgsEstimator); fastjet::JetDefinition subjDef(fastjet::kt_algorithm, dSjeR, fastjet::BIpt_scheme, fastjet::Best); //============================================================================= TRandom3 *r3 = new TRandom3(0); TF1 *fBkg = BackgroundSpec(); //============================================================================= std::vector<fastjet::PseudoJet> fjInputVac; std::vector<fastjet::PseudoJet> fjInputHyd; //============================================================================= TList *list = new TList(); TH1D *hWeightSum = new TH1D("hWeightSum", "", 1, 0., 1.); list->Add(hWeightSum); //============================================================================= HepMC::IO_GenEvent ascii_in(Form("%s/%s.hepmc",sPath.Data(),sFile.Data()), std::ios::in); HepMC::GenEvent *evt = ascii_in.read_next_event(); while (evt) { fjInputVac.resize(0); fjInputHyd.resize(0); double dXsect = evt->cross_section()->cross_section() / 1e9; double dWeight = evt->weights().back(); double dNorm = dWeight * dXsect; hWeightSum->Fill(0.5, dWeight); int iCount = 0; TLorentzVector vPseudo; for (HepMC::GenEvent::particle_const_iterator p=evt->particles_begin(); p!=evt->particles_end(); ++p) if ((*p)->status()==1) { vPseudo.SetPtEtaPhiM((*p)->momentum().perp(), (*p)->momentum().eta(), (*p)->momentum().phi(), 0.); if ((TMath::Abs(vPar.Eta())<dCutEtaMax)) { fjInputVac.push_back(fastjet::PseudoJet(vPseudo.Px(), vPseudo.Py(), vPseudo.Pz(), vPseudo.E())); fjInputVac.back().set_user_info(new UserInfoTrk(false)); fjInputVac.back().set_user_index(iCount); iCount+=1; } } //============================================================================= for (int i=0; i<=multiLHC; i++) { double dPt = fBkg->GetRandom(fgkPtBkgMin, fgkPtBkgMax); if (dPt<0.001) continue; vPseudo.SetPtEtaPhiM(dPt, r3->Uniform(-1.*dCutEtaMax,dCutEtaMax), r3->Uniform(0.,TMath::TwoPi()), 0.); fjInputHyd.push_back(fastjet::PseudoJet(vPseudo.Px(), vPseudo.Py(), vPseudo.Pz(), vPseudo.E())); fjInputHyd.back().set_user_info(new UserInfoTrk(true)); fjInputHyd.back().set_user_index(-10); } fjInputHyd.insert(fjInputHyd.end(), fjInputVac.begin(),fjInputVac.end()); //============================================================================= fastjet::ClusterSequenceArea clustSeq(fjInputVac, jetsDef, areaDef); std::vector<fastjet::PseudoJet> includJetsPy = clustSeq.inclusive_jets(dJetsPtMin); // std::vector<fastjet::PseudoJet> subtedJetsPy = bkgSubtractor(includJetsPy); std::vector<fastjet::PseudoJet> selectJetsPy = selectJet(includJetsPy); // std::vector<fastjet::PseudoJet> sortedJetsPy = fastjet::sorted_by_pt(selectJetsPy); for (int j=0; j<selectJetsPy.size(); j++) { SetJetUserInfo(selectJetsPy[j]); selectJetsPy[j].set_user_index(j); } //============================================================================= bkgsEstimator.set_particles(fjInputHyd); double dBkgRhoHd = bkgsEstimator.rho(); double dBkgRmsHd = bkgsEstimator.sigma(); fastjet::ClusterSequenceArea clustSeqHd(fjInputHyd, jetsDef, areaDef); std::vector<fastjet::PseudoJet> includJetsHd = clustSeqHd.inclusive_jets(dJetsPtMin); std::vector<fastjet::PseudoJet> selectJetsHd = selectJet(includJetsHd); for (int j=0; j<selectJetsHd.size(); j++) { SetJetUserInfo(selectJetsHd[j]); selectJetsHd[j].set_user_index(j); if (selectJetsHd[j].user_info<UserInfoJet>().IsBkg()) continue; for (int i=0; i<selectJetsPy.size(); i++) { if (CalcDeltaR(selectJetsHd[j],selectJetsPy[i])>0.8) continue; DoTrkMatch(selectJetsHd[j], selectJetsPy[i]); } } //============================================================================= for (int j=0; j<sortedJets.size(); j++) { double dJet = sortedJets[j].pt(); hJet->Fill(dJet, dNorm); //============================================================================= fastjet::Filter trimmer(subjDef, fastjet::SelectorPtFractionMin(0.)); fastjet::PseudoJet trimmdJet = trimmer(sortedJets[j]); std::vector<fastjet::PseudoJet> trimmdSj = trimmdJet.pieces(); double nIsj = 0.; double d1sj = -1.; int k1sj = -1; double d2sj = -1.; int k2sj = -1; for (int i=0; i<trimmdSj.size(); i++) { double dIsj = trimmdSj[i].pt(); if (dIsj<0.001) continue; hJetIsj->Fill(dJet, dIsj, dNorm); hJetIsz->Fill(dJet, dIsj/dJet, dNorm); if (dIsj>d1sj) { d2sj = d1sj; k2sj = k1sj; d1sj = dIsj; k1sj = i; } else if (dIsj>d2sj) { d2sj = dIsj; k2sj = i; } nIsj += 1.; } hJetNsj->Fill(dJet, nIsj, dNorm); if (d1sj>0.) { hJet1sj->Fill(dJet, d1sj, dNorm); hJet1sz->Fill(dJet, d1sj/dJet, dNorm); } if (d2sj>0.) { hJet2sj->Fill(dJet, d2sj, dNorm); hJet2sz->Fill(dJet, d2sj/dJet, dNorm); } if ((d1sj>0.) && (d2sj>0.)) { TVector3 v1sj; v1sj.SetPtEtaPhi(d1sj, trimmdSj[k1sj].eta(), trimmdSj[k1sj].phi()); TVector3 v2sj; v2sj.SetPtEtaPhi(d2sj, trimmdSj[k2sj].eta(), trimmdSj[k2sj].phi()); double dsj = d1sj - d2sj; double dsz = dsj / dJet; double dsr = v1sj.DeltaR(v2sj) / 2. / dJetR; hJetDsj->Fill(dJet, dsj, dNorm); hJetDsz->Fill(dJet, dsz, dNorm); hJetDsr->Fill(dJet, dsz, dsr, dNorm); } } //============================================================================= delete evt; ascii_in >> evt; } //============================================================================= TFile *file = TFile::Open(Form("%s.root",sFile.Data()), "NEW"); list->Write(); file->Close(); //============================================================================= cout << "DONE" << endl; return 0; }
// ______________________________________________________________________________________ void plotVsDeltaEta_nice(const Char_t* name = "ratioVsDeltaEta") { gROOT->LoadMacro("include/toolsEtaNice.C++"); SetupStyle(); SetGlobals(); // ----------------------------------------------------- TFile *inFiles[nEtaSets][nDataSets][nMoments]; TGraphErrors *graphs[nEtaSets][nDataSets][nMoments]; for (int idxEta = 0 ; idxEta < nEtaSets; ++idxEta) for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) for (int idxMoment = 0 ; idxMoment < nMoments; ++idxMoment) { inFiles[idxEta][idxDataSet][idxMoment] = TFile::Open(Form("output/%s/%s/Moments_%s.root", aEtaSets[idxEta], aDataSets[idxDataSet], aMoments[idxMoment])); graphs[idxEta][idxDataSet][idxMoment] = static_cast<TGraphErrors*>((inFiles[idxEta][idxDataSet][idxMoment]->Get(aMoments[idxMoment]))->Clone()); if (inFiles[idxEta][idxDataSet][idxMoment]) (inFiles[idxEta][idxDataSet][idxMoment])->Close(); } // ----------------------------------------------------- TLegend *legRat[nDataSets]; for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) { legRat[idxDataSet] = new TLegend(0.12, 0.12, 0.70, 0.495); legRat[idxDataSet]->SetTextAlign(12); legRat[idxDataSet]->SetTextSize(0.06); legRat[idxDataSet]->SetFillColor(1182); legRat[idxDataSet]->SetLineColor(0); legRat[idxDataSet]->SetBorderSize(0); } // ----------------------------------------------------- TGraphErrors *etaGraphs[9][nDataSets][nMoments]; for (int idxCent = 0; idxCent < nCent; idxCent++) { for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) { for (int idxMoment = 4 ; idxMoment < nMoments; ++idxMoment) { float y[nEtaSets]; float ey[nEtaSets]; for (int idxEta = 0 ; idxEta < nEtaSets; ++idxEta) { y[idxEta] = graphs[idxEta][idxDataSet][idxMoment]->GetY()[idxCent]; ey[idxEta] = graphs[idxEta][idxDataSet][idxMoment]->GetEY()[idxCent]; } etaGraphs[idxCent][idxDataSet][idxMoment] = new TGraphErrors(nEtaSets, aEtaSetBinWidth, y, 0, ey); PrepareGraph(etaGraphs[idxCent][idxDataSet][idxMoment]); } // for (int idxMoment = 0 ; idxMoment < nMoments; ++idxMoment) { } // for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) { } // for (int idxCent = 0; idxCent < 9; idxCent++) { // ----------------------------------------------------- for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) { TPad *pad = SetupCanvas(Form("canDeltaEta_Ratio_%s", aDataSets[idxDataSet]), aDataSetsTitle[idxDataSet], "#Delta#eta", 0.48); for (int idxMoment = 4 ; idxMoment < nMoments; ++idxMoment) { pad->cd(idxMoment-3); for (int idxCent = 0; idxCent < 9; idxCent++) { if (idxCent != 0 && idxCent != 1 && idxCent != 8 && idxCent != 4 ) continue; TGraphErrors *g = etaGraphs[idxCent][idxDataSet][idxMoment]; if (idxCent == 0) ShiftGraphX(g, -0.015); else if (idxCent == 1) ShiftGraphX(g, -0.005); else if (idxCent == 4) ShiftGraphX(g, 0.005); else if (idxCent == 8) ShiftGraphX(g, 0.015); ConfigGraph(g, idxMoment, idxCent); if (idxCent == 0) { g->Draw("AP"); if (idxMoment == 5) { // TLine *line0 = new TLine(aMinX, 0, aMaxX, 0); // line0->SetLineColor(kGray+1); // line0->SetLineStyle(2); // line0->SetLineWidth(2); // line0->Draw(); } else if (idxMoment == 6) { TLine *line1 = new TLine(aMinX, 1, aMaxX, 1); line1->SetLineColor(kGray+1); line1->SetLineStyle(2); line1->SetLineWidth(2); line1->Draw(); legRat[idxDataSet]->AddEntry(line1, "Poisson", "l"); } } g->Draw("PSAME"); if (idxMoment == 4) legRat[idxDataSet]->AddEntry(etaGraphs[idxCent][idxDataSet][4], Form("%s", cent1[idxCent]), "pl"); } // for (int idxCent = 0; idxCent < 9; idxCent++) { } // for (int idxMoment = 0 ; idxMoment < nMoments; ++idxMoment) { pad->cd(2); TLatex *texb_3 = new TLatex(0.05, 0.55, "Au+Au collisions #sqrt{#it{s}_{NN}} = 14.5 GeV"); texb_3->SetTextSize(0.07); texb_3->Draw("same"); TLatex *texb_3a = new TLatex(0.05, 0.49, "Net-Charge, 0.2 < #it{p}_{T} (GeV/#it{c}) < 2.0, 0-5%"); texb_3a->SetTextSize(0.07); texb_3a->Draw("same"); TLatex *texb_3b = new TLatex(0.05,0.44, "statistical errors only"); texb_3b->SetTextSize(0.06); texb_3b->Draw("same"); pad->cd(1); TLatex *texb_4 = new TLatex(0.7, 19, "STAR Preliminary"); texb_4->SetTextSize(0.07); texb_4->Draw("same"); pad->cd(3); legRat[idxDataSet]->Draw(); pad->Modified(); } // for (int idxDataSet = 0 ; idxDataSet < nDataSets; ++idxDataSet) { // ----------------------------------------------------- SaveCanvas(name); // ----------------------------------------------------- TFile *fOut = TFile::Open("STAR_QM2015_Preliminary.root", "UPDATE"); fOut->cd(); TList* list = new TList; for (int idxMoment = 4; idxMoment < nMoments; ++idxMoment) { for (int idxCent = 0; idxCent < nCent; ++idxCent) { if (idxCent > 1) continue; if (idxCent == 0) ShiftGraphX(etaGraphs[idxCent][0][idxMoment], 0.015); else if (idxCent == 1) ShiftGraphX(etaGraphs[idxCent][0][idxMoment], 0.005); else if (idxCent == 4) ShiftGraphX(etaGraphs[idxCent][0][idxMoment], -0.005); else if (idxCent == 8) ShiftGraphX(etaGraphs[idxCent][0][idxMoment], -0.015); etaGraphs[idxCent][0][idxMoment]->SetName(Form("Net-Charge_%s_DeltaEta_14.5GeV_%s_stat", aMoments[idxMoment], cent[idxCent])); list->Add(etaGraphs[idxCent][0][idxMoment]); } } list->Write("Net-Charge_VsDeltaEta", TObject::kSingleKey); fOut->Close(); }
int main(int argc, char* argv[]) { TApplication theApp(srcName.Data(), &argc, argv); //============================================================================= if (argc<5) return -1; TString sPath = argv[1]; if (sPath.IsNull()) return -1; TString sFile = argv[2]; if (sFile.IsNull()) return -1; TString sJetR = argv[3]; if (sJetR.IsNull()) return -1; TString sSjeR = argv[4]; if (sSjeR.IsNull()) return -1; //============================================================================= sPath.ReplaceAll("#", "/"); //============================================================================= double dJetR = -1.; if (sJetR=="JetR02") dJetR = 0.2; if (sJetR=="JetR03") dJetR = 0.3; if (sJetR=="JetR04") dJetR = 0.4; if (sJetR=="JetR05") dJetR = 0.5; if (dJetR<0.) return -1; cout << "Jet R = " << dJetR << endl; //============================================================================= double dSjeR = -1.; if (sSjeR=="SjeR01") dSjeR = 0.1; if (sSjeR=="SjeR02") dSjeR = 0.2; if (sSjeR=="SjeR03") dSjeR = 0.3; if (sSjeR=="SjeR04") dSjeR = 0.4; if (dSjeR<0.) return -1; cout << "Sub-jet R = " << dSjeR << endl; //============================================================================= const double dJetsPtMin = 0.001; const double dCutEtaMax = 1.6; const double dJetEtaMax = 1.; const double dJetAreaRef = TMath::Pi() * dJetR * dJetR; fastjet::GhostedAreaSpec areaSpc(dCutEtaMax); fastjet::JetDefinition jetsDef(fastjet::antikt_algorithm, dJetR, fastjet::E_scheme, fastjet::Best); //fastjet::AreaDefinition areaDef(fastjet::active_area,areaSpc); fastjet::AreaDefinition areaDef(fastjet::active_area_explicit_ghosts,areaSpc); //fastjet::JetDefinition bkgsDef(fastjet::kt_algorithm, 0.2, fastjet::BIpt_scheme, fastjet::Best); //fastjet::AreaDefinition aBkgDef(fastjet::active_area_explicit_ghosts, areaSpc); fastjet::Selector selectJet = fastjet::SelectorAbsEtaMax(dJetEtaMax); //fastjet::Selector selectRho = fastjet::SelectorAbsEtaMax(dCutEtaMax-0.2); //fastjet::Selector selecHard = fastjet::SelectorNHardest(2); //fastjet::Selector selectBkg = selectRho * (!(selecHard)); //fastjet::JetMedianBackgroundEstimator bkgsEstimator(selectBkg, bkgsDef, aBkgDef); //fastjet::Subtractor bkgSubtractor(&bkgsEstimator); fastjet::JetDefinition subjDef(fastjet::kt_algorithm, dSjeR, fastjet::E_scheme, fastjet::Best); //============================================================================= std::vector<fastjet::PseudoJet> fjInput; const double dMass = TDatabasePDG::Instance()->GetParticle(211)->Mass(); //============================================================================= TList *list = new TList(); TH1D *hJet = new TH1D("hJet", "", 1000, 0., 1000.); hJet->Sumw2(); list->Add(hJet); enum { kJet, kMje, kDsz, kIsm, kZsm, kDsr, kVar }; const TString sHist[] = { "aJet", "aMje", "aDsz", "aIsm", "aZsm", "aDsr" }; const Int_t nv[] = { 1000, 150, 120, 150, 150, 500 }; const Double_t dMin[] = { 0., 0., 0., 0., 0., 0. }; const Double_t dMax[] = { 1000., 150., 1.2, 150., 1.5, 5. }; THnSparseD *hs = new THnSparseD("hs", "", kVar, nv, dMin, dMax); hs->Sumw2(); for (Int_t i=0; i<kVar; i++) hs->GetAxis(i)->SetName(sHist[i].Data()); list->Add(hs); //============================================================================= HepMC::IO_GenEvent ascii_in(Form("%s/%s.hepmc",sPath.Data(),sFile.Data()), std::ios::in); HepMC::GenEvent *evt = ascii_in.read_next_event(); while (evt) { fjInput.resize(0); TLorentzVector vPar; for (HepMC::GenEvent::particle_const_iterator p=evt->particles_begin(); p!=evt->particles_end(); ++p) if ((*p)->status()==1) { vPar.SetPtEtaPhiM((*p)->momentum().perp(), (*p)->momentum().eta(), (*p)->momentum().phi(), dMass); if ((TMath::Abs(vPar.Eta())<dCutEtaMax)) { fjInput.push_back(fastjet::PseudoJet(vPar.Px(), vPar.Py(), vPar.Pz(), vPar.E())); } } //============================================================================= fastjet::ClusterSequenceArea clustSeq(fjInput, jetsDef, areaDef); std::vector<fastjet::PseudoJet> includJets = clustSeq.inclusive_jets(dJetsPtMin); // std::vector<fastjet::PseudoJet> subtedJets = bkgSubtractor(includJets); std::vector<fastjet::PseudoJet> selectJets = selectJet(includJets); // std::vector<fastjet::PseudoJet> sortedJets = fastjet::sorted_by_pt(selectJets); for (int j=0; j<selectJets.size(); j++) { double dJet = selectJets[j].pt(); hJet->Fill(dJet); //============================================================================= fastjet::Filter trimmer(subjDef, fastjet::SelectorPtFractionMin(0.)); fastjet::PseudoJet trimmdJet = trimmer(selectJets[j]); std::vector<fastjet::PseudoJet> trimmdSj = trimmdJet.pieces(); double d1sj = -1.; int k1sj = -1; double d2sj = -1.; int k2sj = -1; for (int i=0; i<trimmdSj.size(); i++) { double dIsj = trimmdSj[i].pt(); if (dIsj<0.001) continue; if (dIsj>d1sj) { d2sj = d1sj; k2sj = k1sj; d1sj = dIsj; k1sj = i; } else if (dIsj>d2sj) { d2sj = dIsj; k2sj = i; } } if ((d1sj>0.) && (d2sj>0.)) { TLorentzVector v1sj; v1sj.SetPtEtaPhiM(d1sj, trimmdSj[k1sj].eta(), trimmdSj[k1sj].phi(), trimmdSj[k1sj].m()); TLorentzVector v2sj; v2sj.SetPtEtaPhiM(d2sj, trimmdSj[k2sj].eta(), trimmdSj[k2sj].phi(), trimmdSj[k2sj].m()); TLorentzVector vIsj = v1sj + v2sj; Double_t dIsm = vIsj.M(); Double_t dMje = selectJets[j].m(); Double_t dVar[] = { dJet, dMje, (d1sj-d2sj)/dJet, dIsm, dIsm/dMje, v1sj.DeltaR(v2sj)/2./dJetR }; hs->Fill(dVar); } } //============================================================================= delete evt; ascii_in >> evt; } //============================================================================= TString sXsec = sFile; sXsec.ReplaceAll("out", "xsecs"); TFile *file = TFile::Open(Form("%s/xsecs/%s.root",sPath.Data(),sXsec.Data()), "READ"); TH1D *hPtHat = (TH1D*)file->Get("hPtHat"); hPtHat->SetDirectory(0); TH1D *hWeightSum = (TH1D*)file->Get("hWeightSum"); hWeightSum->SetDirectory(0); TProfile *hSigmaGen = (TProfile*)file->Get("hSigmaGen"); hSigmaGen->SetDirectory(0); file->Close(); //============================================================================= file = TFile::Open(Form("%s.root",sFile.Data()), "NEW"); hPtHat->Write(); hWeightSum->Write(); hSigmaGen->Write(); list->Write(); file->Close(); //============================================================================= cout << "DONE" << endl; return 0; }
Int_t DrawPerformanceZDCQAMatch(TString inFile="trending.root"){ // Draw control histograms and generate output pictures gSystem->Load("libSTAT"); gSystem->Load("libANALYSIS"); gSystem->Load("libANALYSISalice"); gSystem->Load("libANALYSIScalib"); gSystem->Load("libCORRFW"); gSystem->Load("libANALYSISalice"); gSystem->Load("libANALYSIScalib"); gSystem->Load("libTender"); gSystem->Load("libPWGPP"); gROOT->Reset(); gROOT->SetStyle("Plain"); gStyle->SetPalette(1); gStyle->SetOptStat(0); gStyle->SetTitleSize(0.025); TH1::AddDirectory(kFALSE); TFile * fin = TFile::Open(inFile.Data()); if (!fin){ Printf("File not found !!!"); return -1; } TTree * ttree = (TTree*) fin->Get("trending"); //in TTree * tree = new TTree("tree","tree"); //out (to be summed) if (!ttree){ Printf("Invalid trending tree!!!!!!!!!!!!!!"); return -2; } Int_t nRuns = ttree->GetEntries(); TList list; printf(" nRuns %d\n", nRuns); /*set graphic style*/ gStyle->SetCanvasColor(kWhite); gStyle->SetFrameFillColor(kWhite); gStyle->SetFrameBorderMode(0); gStyle->SetCanvasBorderMode(0); gStyle->SetTitleFillColor(kWhite); gStyle->SetTitleBorderSize(0); gStyle->SetTitleFont(42); gStyle->SetTitleX(0.5); gStyle->SetTitleAlign(23); gStyle->SetTextFont(42); gStyle->SetStatColor(kWhite); gStyle->SetStatBorderSize(1); gStyle->SetOptStat(0); gStyle->SetTickLength(0.02,"y"); gStyle->SetLabelSize(0.02,"xyz"); gStyle->SetLabelOffset(0.03,"xyz"); TString plotDir("."); TLegend *legend = new TLegend(0.9,0.1,1.0,0.9); legend->SetFillColor(kWhite); Int_t runNumber=0; Double_t ZNC_mean=0; Double_t ZNA_mean=0; Double_t ZPA_mean=0; Double_t ZPC_mean=0; Double_t ZNCuncalib_mean=0; Double_t ZNAuncalib_mean=0; Double_t ZPAuncalib_mean=0; Double_t ZPCuncalib_mean=0; Double_t ZEM1_mean=0; Double_t ZEM2_mean=0; Double_t ZNC_XCent=0; Double_t ZNC_YCent=0; Double_t ZNA_XCent=0; Double_t ZNA_YCent=0; Double_t ZNC_XCent_err=0; Double_t ZNC_YCent_err=0; Double_t ZNA_XCent_err=0; Double_t ZNA_YCent_err=0; Double_t ZN_TDC_Sum=0; Double_t ZN_TDC_Diff=0; Double_t ZN_TDC_Sum_err=0; Double_t ZN_TDC_Diff_err=0; Double_t ZNC_TDC=0; Double_t ZNA_TDC=0; TH1F *hZNCpmcUncalib = new TH1F("hZNCpmcUncalib","hZNCpmcUncalib",200.,0.,2000.); TH1F *hZNApmcUncalib = new TH1F("hZNApmcUncalib","hZNApmcUncalib",200.,0.,2000.); TH1F *hZPCpmcUncalib = new TH1F("hZPCpmcUncalib","hZPCpmcUncalib",200.,0.,2000.); TH1F *hZPApmcUncalib = new TH1F("hZPApmcUncalib","hZPApmcUncalib",200.,0.,2000.); TH1F *hZEM1 = new TH1F("hZEM1","hZEM1",200.,0.,2000.); TH1F *hZEM2 = new TH1F("hZEM2","hZEM2",200.,0.,2000.); ttree->SetBranchAddress("run",&runNumber); ttree->SetBranchAddress("ZNC_mean_value",&ZNC_mean); ttree->SetBranchAddress("ZNA_mean_value",&ZNA_mean); ttree->SetBranchAddress("ZPC_mean_value",&ZPC_mean); ttree->SetBranchAddress("ZPA_mean_value",&ZPA_mean); ttree->SetBranchAddress("ZNCuncalib_mean",&ZNCuncalib_mean); ttree->SetBranchAddress("ZNAuncalib_mean",&ZNAuncalib_mean); ttree->SetBranchAddress("ZPCuncalib_mean",&ZPCuncalib_mean); ttree->SetBranchAddress("ZPAuncalib_mean",&ZPAuncalib_mean); ttree->SetBranchAddress("ZEM1_mean_value",&ZEM1_mean); ttree->SetBranchAddress("ZEM2_mean_value",&ZEM2_mean); ttree->SetBranchAddress("ZNC_X_Centroid",&ZNC_XCent); ttree->SetBranchAddress("ZNC_Y_Centroid",&ZNC_YCent); ttree->SetBranchAddress("ZNA_X_Centroid",&ZNA_XCent); ttree->SetBranchAddress("ZNA_Y_Centroid",&ZNA_YCent); ttree->SetBranchAddress("ZNC_X_Centroid_Err",&ZNC_XCent_err); ttree->SetBranchAddress("ZNC_Y_Centroid_Err",&ZNC_YCent_err); ttree->SetBranchAddress("ZNA_X_Centroid_Err",&ZNA_XCent_err); ttree->SetBranchAddress("ZNA_Y_Centroid_Err",&ZNA_YCent_err); ttree->SetBranchAddress("ZN_TDC_Sum",&ZN_TDC_Sum); ttree->SetBranchAddress("ZN_TDC_Diff",&ZN_TDC_Diff); ttree->SetBranchAddress("ZN_TDC_Sum_Err",&ZN_TDC_Sum_err); ttree->SetBranchAddress("ZN_TDC_Diff_Err",&ZN_TDC_Diff_err); //ttree->SetBranchAddress("ZNC_TDC",&ZNC_TDC); //ttree->SetBranchAddress("ZNA_TDC",&ZNA_TDC); printf(" branch addresses set\n"); TH1F *hznc = new TH1F("hznc","ZNC average signal",3,-1,1); hznc->GetXaxis()->SetRangeUser(-1.,1.); hznc->SetDrawOption("EP"); hznc->SetMarkerStyle(20); hznc->SetMarkerColor(kRed); hznc->SetLineColor(kRed); TH1F *hzna = new TH1F("hzna","ZNA average signal",3,-1,1); hzna->GetXaxis()->SetRangeUser(-1.,1.); hzna->SetDrawOption("EP"); hzna->SetMarkerStyle(20); hzna->SetMarkerColor(kRed); hzna->SetLineColor(kRed); TH1F *hzpc = new TH1F("hzpc","ZPC average signal",3,-1,1); hzpc->GetXaxis()->SetRangeUser(-1.,1.); hzpc->SetDrawOption("EP"); hzpc->SetMarkerStyle(20); hzpc->SetMarkerColor(kRed); hzpc->SetLineColor(kRed); TH1F *hzpa = new TH1F("hzpa","ZPA average signal",3,-1,1); hzpa->GetXaxis()->SetRangeUser(-1.,1.); hzpa->SetDrawOption("EP"); hzpa->SetMarkerStyle(20); hzpa->SetMarkerColor(kRed); hzpa->SetLineColor(kRed); TH1F *hzncUncalib = new TH1F("hzncUncalib","ZNC uncalibrated average signal",3,-1,1); hzncUncalib->GetXaxis()->SetRangeUser(-1.,1.); hzncUncalib->SetDrawOption("EP"); hzncUncalib->SetMarkerStyle(20); hzncUncalib->SetMarkerColor(kAzure+10); hzncUncalib->SetLineColor(kAzure+10); TH1F *hznaUncalib = new TH1F("hznaUncalib","ZNA uncalibrated average signal",3,-1,1); hznaUncalib->GetXaxis()->SetRangeUser(-1.,1.); hznaUncalib->SetDrawOption("EP"); hznaUncalib->SetMarkerStyle(20); hznaUncalib->SetMarkerColor(kAzure+10); hznaUncalib->SetLineColor(kAzure+10); TH1F *hzpcUncalib = new TH1F("hzpcUncalib","ZPC uncalibrated average signal",3,-1,1); hzpcUncalib->GetXaxis()->SetRangeUser(-1.,1.); hzpcUncalib->SetDrawOption("EP"); hzpcUncalib->SetMarkerStyle(20); hzpcUncalib->SetMarkerColor(kAzure+10); hzpcUncalib->SetLineColor(kAzure+10); TH1F *hzpaUncalib = new TH1F("hzpaUncalib","ZPA uncalibrated average signal",3,-1,1); hzpaUncalib->GetXaxis()->SetRangeUser(-1.,1.); hzpaUncalib->SetDrawOption("EP"); hzpaUncalib->SetMarkerStyle(20); hzpaUncalib->SetMarkerColor(kAzure+10); hzpaUncalib->SetLineColor(kAzure+10); TH1F *hzem1 = new TH1F("hzem1","ZEM1 average signal",3,-1,1); hzem1->GetXaxis()->SetRangeUser(-1.,1.); hzem1->SetDrawOption("EP"); hzem1->SetMarkerStyle(20); hzem1->SetMarkerColor(kRed); hzem1->SetLineColor(kRed); TH1F *hzem2 = new TH1F("hzem2","ZEM2 average signal",3,-1,1); hzem2->GetXaxis()->SetRangeUser(-1.,1.); hzem2->SetDrawOption("EP"); hzem2->SetMarkerStyle(20); hzem2->SetMarkerColor(kRed); hzem2->SetLineColor(kRed); TH1F *hzna_Xcentroid = new TH1F("hzna_Xcentroid","ZNA X centroid",3,-1,1); hzna_Xcentroid->GetXaxis()->SetRangeUser(-1.,1.); hzna_Xcentroid->SetDrawOption("EP"); hzna_Xcentroid->SetMarkerStyle(20); hzna_Xcentroid->SetMarkerColor(kRed); hzna_Xcentroid->SetLineColor(kRed); TH1F *hzna_Ycentroid = new TH1F("hzna_Ycentroid","ZNA Y centroid",3,-1,1); hzna_Ycentroid->GetXaxis()->SetRangeUser(-1.,1.); hzna_Ycentroid->SetDrawOption("EP"); hzna_Ycentroid->SetMarkerStyle(20); hzna_Ycentroid->SetMarkerColor(kRed); hzna_Ycentroid->SetLineColor(kRed); TH1F *hznc_Xcentroid = new TH1F("hznc_Xcentroid","ZNC X centroid",3,-1,1); hznc_Xcentroid->GetXaxis()->SetRangeUser(-1.,1.); hznc_Xcentroid->SetDrawOption("EP"); hznc_Xcentroid->SetMarkerStyle(20); hznc_Xcentroid->SetMarkerColor(kRed); hznc_Xcentroid->SetLineColor(kRed); TH1F *hznc_Ycentroid = new TH1F("hznc_Ycentroid","ZNC Y centroid",3,-1,1); hznc_Ycentroid->GetXaxis()->SetRangeUser(-1.,1.); hznc_Ycentroid->SetDrawOption("EP"); hznc_Ycentroid->SetMarkerStyle(20); hznc_Ycentroid->SetMarkerColor(kRed); hznc_Ycentroid->SetLineColor(kRed); TH1F *hzn_TDC_Sum = new TH1F("hzn_TDC_Sum","ZNC TDC + ZNA TDC",3,-1,1); hzn_TDC_Sum->GetXaxis()->SetRangeUser(-1.,1.); hzn_TDC_Sum->SetDrawOption("EP"); hzn_TDC_Sum->SetMarkerStyle(20); hzn_TDC_Sum->SetMarkerColor(kRed); hzn_TDC_Sum->SetLineColor(kRed); TH1F *hzn_TDC_Diff = new TH1F("hzn_TDC_Diff","ZNC TDC - ZNA TDC",3,-1,1); hzn_TDC_Diff->GetXaxis()->SetRangeUser(-1.,1.); hzn_TDC_Diff->SetDrawOption("EP"); hzn_TDC_Diff->SetMarkerStyle(20); hzn_TDC_Diff->SetMarkerColor(kRed); hzn_TDC_Diff->SetLineColor(kRed); TH1F *hznc_TDC = new TH1F("hznc_TDC","ZNC TDC",3,-1,1); hznc_TDC->GetXaxis()->SetRangeUser(-1.,1.); hznc_TDC->SetDrawOption("EP"); hznc_TDC->SetMarkerStyle(20); hznc_TDC->SetMarkerColor(kRed); hznc_TDC->SetLineColor(kRed); TH1F *hzna_TDC = new TH1F("hzna_TDC","ZNA TDC",3,-1,1); hzna_TDC->GetXaxis()->SetRangeUser(-1.,1.); hzna_TDC->SetDrawOption("EP"); hzna_TDC->SetMarkerStyle(20); hzna_TDC->SetMarkerColor(kRed); hzna_TDC->SetLineColor(kRed); char runlabel[40]; for (Int_t irun=0;irun<nRuns;irun++){ ttree->GetEntry(irun); } sprintf(runlabel,"%i",runNumber); //---------------------------------------------------------------------- //spectrum vs run //---------------------------------------------------------------------- hZNCpmcUncalib = dynamic_cast<TH1F*> (fin->Get("fhZNCpmcUncalib")); if(hZNCpmcUncalib){ if(hZNCpmcUncalib->GetEntries()>0. ) hZNCpmcUncalib->Scale(1./hZNCpmcUncalib->GetEntries()); hZNCpmcUncalib->SetLineColor(kRed); hZNCpmcUncalib->SetLineWidth(2); hZNCpmcUncalib->SetTitle("ZNC spectrum"); hZNCpmcUncalib->SetXTitle("ZNC signal "); } hZNApmcUncalib = dynamic_cast<TH1F*> (fin->Get("fhZNApmcUncalib")); if(hZNApmcUncalib){ if(hZNApmcUncalib->GetEntries()>0. ) hZNApmcUncalib->Scale(1./hZNApmcUncalib->GetEntries()); hZNApmcUncalib->SetLineColor(kRed); hZNApmcUncalib->SetLineWidth(2); hZNApmcUncalib->SetTitle("ZNA spectrum"); hZNApmcUncalib->SetXTitle("ZNA signal "); } hZPCpmcUncalib = dynamic_cast<TH1F*> (fin->Get("fhZPCpmcUncalib")); if(hZPCpmcUncalib){ if(hZPCpmcUncalib->GetEntries()>0. ) hZPCpmcUncalib->Scale(1./hZPCpmcUncalib->GetEntries()); hZPCpmcUncalib->SetLineColor(kRed); hZPCpmcUncalib->SetLineWidth(2); hZPCpmcUncalib->SetTitle("ZPC spectrum"); hZPCpmcUncalib->SetXTitle("ZPC signal "); } hZPApmcUncalib = dynamic_cast<TH1F*> (fin->Get("fhZPApmcUncalib")); if(hZPApmcUncalib){ if(hZPApmcUncalib->GetEntries()>0. ) hZPApmcUncalib->Scale(1./hZPApmcUncalib->GetEntries()); hZPApmcUncalib->SetLineColor(kRed); hZPApmcUncalib->SetLineWidth(2); hZPApmcUncalib->SetTitle("ZPA spectrum"); hZPApmcUncalib->SetXTitle("ZPA signal "); } hZEM1 = dynamic_cast<TH1F*> (fin->Get("fhZEM1Spectrum")); if(hZEM1){ if(hZEM1->GetEntries()>0.) hZEM1->Scale(1./hZEM1->GetEntries()); hZEM1->SetLineColor(kRed); hZEM1->SetLineWidth(2); hZEM1->SetTitle("ZEM1 spectrum"); hZEM1->SetXTitle("ZEM1 signal (ADC ch.)"); } hZEM2 = dynamic_cast<TH1F*> (fin->Get("fhZEM2Spectrum")); if(hZEM2){ if(hZEM2->GetEntries()>0.) hZEM2->Scale(1./hZEM2->GetEntries()); hZEM2->SetLineColor(kRed); hZEM2->SetLineWidth(2); hZEM2->SetTitle("ZEM2 spectrum"); hZEM2->SetXTitle("ZEM2 signal (ADC ch.)"); } //---------------------------------------------------------------------- //variables vs run //---------------------------------------------------------------------- hzna->SetBinContent(2,ZNA_mean); hzna->GetXaxis()->SetBinLabel(2,runlabel); hzna->GetXaxis()->SetLabelSize(0.05); hzpc->SetBinContent(2,ZPC_mean); hzpc->GetXaxis()->SetBinLabel(2,runlabel); hzpc->GetXaxis()->SetLabelSize(0.05); hznc->SetBinContent(2,ZNC_mean); hznc->GetXaxis()->SetBinLabel(2,runlabel); hznc->GetXaxis()->SetLabelSize(0.05); hzpa->SetBinContent(2,ZPA_mean); hzpa->GetXaxis()->SetBinLabel(2,runlabel); hzpa->GetXaxis()->SetLabelSize(0.05); hznaUncalib->SetBinContent(2,ZNAuncalib_mean); hznaUncalib->GetXaxis()->SetBinLabel(2,runlabel); hznaUncalib->GetXaxis()->SetLabelSize(0.05); hzpcUncalib->SetBinContent(2,ZPCuncalib_mean); hzpcUncalib->GetXaxis()->SetBinLabel(2,runlabel); hzpcUncalib->GetXaxis()->SetLabelSize(0.05); hzncUncalib->SetBinContent(2,ZNCuncalib_mean); hzncUncalib->GetXaxis()->SetBinLabel(2,runlabel); hzncUncalib->GetXaxis()->SetLabelSize(0.05); hzpaUncalib->SetBinContent(2,ZPAuncalib_mean); hzpaUncalib->GetXaxis()->SetBinLabel(2,runlabel); hzpaUncalib->GetXaxis()->SetLabelSize(0.05); hzem1->SetBinContent(2,ZEM1_mean); hzem1->GetXaxis()->SetBinLabel(2,runlabel); hzem1->GetXaxis()->SetLabelSize(0.05); hzem2->SetBinContent(2,ZEM2_mean); hzem2->GetXaxis()->SetBinLabel(2,runlabel); hzem2->GetXaxis()->SetLabelSize(0.05); hzna_Xcentroid->SetBinContent(2,ZNA_XCent); hzna_Xcentroid->SetBinError(2,ZNA_XCent_err); hzna_Xcentroid->GetXaxis()->SetBinLabel(2,runlabel); hzna_Xcentroid->GetXaxis()->SetLabelSize(0.05); hzna_Xcentroid->GetYaxis()->SetTitle("(cm)"); hzna_Ycentroid->SetBinContent(2,ZNA_YCent); hzna_Ycentroid->SetBinError(2,ZNA_YCent_err); hzna_Ycentroid->GetXaxis()->SetBinLabel(2,runlabel); hzna_Ycentroid->GetXaxis()->SetLabelSize(0.05); hzna_Ycentroid->GetYaxis()->SetTitle("(cm)"); hznc_Xcentroid->SetBinContent(2,ZNC_XCent); hznc_Xcentroid->SetBinError(2,ZNC_XCent_err); hznc_Xcentroid->GetXaxis()->SetBinLabel(2,runlabel); hznc_Xcentroid->GetXaxis()->SetLabelSize(0.05); hznc_Xcentroid->GetYaxis()->SetTitle("(cm)"); hznc_Ycentroid->SetBinContent(2,ZNC_YCent); hznc_Ycentroid->SetBinError(2,ZNC_YCent_err); hznc_Ycentroid->GetXaxis()->SetBinLabel(2,runlabel); hznc_Ycentroid->GetXaxis()->SetLabelSize(0.05); hznc_Ycentroid->GetYaxis()->SetTitle("(cm)"); hzn_TDC_Sum->SetBinContent(2,ZN_TDC_Sum); hzn_TDC_Sum->SetBinError(2,ZN_TDC_Sum_err); hzn_TDC_Sum->GetXaxis()->SetBinLabel(2,runlabel); hzn_TDC_Sum->GetXaxis()->SetLabelSize(0.05); hzn_TDC_Sum->GetYaxis()->SetTitle("(ns)"); hzn_TDC_Diff->SetBinContent(2,ZN_TDC_Diff); hzn_TDC_Diff->SetBinError(2,ZN_TDC_Diff_err); hzn_TDC_Diff->GetXaxis()->SetBinLabel(2,runlabel); hzn_TDC_Diff->GetXaxis()->SetLabelSize(0.05); hzn_TDC_Diff->GetYaxis()->SetTitle("(ns)"); hznc_TDC->SetBinContent(2,ZNC_TDC); //hznc_TDC->SetBinError(2,ZNC_TDC_err); hznc_TDC->GetXaxis()->SetBinLabel(2,runlabel); hznc_TDC->GetXaxis()->SetLabelSize(0.05); hznc_TDC->GetYaxis()->SetTitle("(ns)"); hzna_TDC->SetBinContent(2,ZNA_TDC); //hzna_TDC->SetBinError(2,ZNA_TDC_err); hzna_TDC->GetXaxis()->SetBinLabel(2,runlabel); hzna_TDC->GetXaxis()->SetLabelSize(0.05); hzna_TDC->GetYaxis()->SetTitle("(ns)"); //---------------------------------------------------------------------- //spectra //---------------------------------------------------------------------- TCanvas* cZNC_Spectra_Uncal = new TCanvas("cZNC_Spectra_Uncal","cZNC_Spectra_Uncal",0,0,1200,900); if(hZNCpmcUncalib){ gPad->SetLogy(); hZNCpmcUncalib->Draw(); cZNC_Spectra_Uncal->Print(Form("%s/cZNC_Spectra_Uncal.png",plotDir.Data())); } TCanvas* cZNA_Spectra_Uncal = new TCanvas("cZNA_Spectra_Uncal","cZNA_Spectra_Uncal",0,0,1200,900); if(hZNApmcUncalib){ gPad->SetLogy(); hZNApmcUncalib->Draw(); cZNA_Spectra_Uncal->Print(Form("%s/cZNA_Spectra_Uncal.png",plotDir.Data())); } TCanvas* cZPC_Spectra_Uncal = new TCanvas("cZPC_Spectra_Uncal","cZPC_Spectra_Uncal",0,0,1200,900); if(hZPCpmcUncalib){ gPad->SetLogy(); hZPCpmcUncalib->Draw(); cZPC_Spectra_Uncal->Print(Form("%s/cZPC_Spectra_Uncal.png",plotDir.Data())); } TCanvas* cZPA_Spectra_Uncal = new TCanvas("cZPA_Spectra_Uncal","cZPA_Spectra_Uncal",0,0,1200,900); if(hZPApmcUncalib){ gPad->SetLogy(); hZPApmcUncalib->Draw(); cZPA_Spectra_Uncal->Print(Form("%s/cZPA_Spectra_Uncal.png",plotDir.Data())); } TCanvas* cZEM1_Spectra = new TCanvas("cZEM1_Spectra","cZEM1_Spectra",0,0,1200,900); if(hZEM1){ gPad->SetLogy(); hZEM1->Draw(); cZEM1_Spectra->Print(Form("%s/cZEM1_Spectra.png",plotDir.Data())); } TCanvas* cZEM2_Spectra = new TCanvas("cZEM2_Spectra","cZEM2_Spectra",0,0,1200,900); if(hZEM2){ gPad->SetLogy(); hZEM2->Draw(); cZEM2_Spectra->Print(Form("%s/cZEM2_Spectra.png",plotDir.Data())); } //--------------------------------------------------------------------------------------------------- //means //--------------------------------------------------------------------------------------------------- TCanvas* cZNC_Mean_Values = new TCanvas("cZNC_Mean_Values","cZNC_Mean_Values", 0,0,750,900); hznc->Draw("ep"); cZNC_Mean_Values->Print(Form("%s/cZNC_Mean_Values.png",plotDir.Data())); TCanvas* cZNA_Mean_Values = new TCanvas("cZNA_Mean_Values","cZNA_Mean_Values", 0,0,750,900); hzna->Draw("ep"); cZNA_Mean_Values->Print(Form("%s/cZNA_Mean_Values.png",plotDir.Data())); TCanvas* cZPC_Mean_Values = new TCanvas("cZPC_Mean_Values","cZPC_Mean_Values", 0,0,750,900); hzpc->Draw("ep"); cZPC_Mean_Values->Print(Form("%s/cZPC_Mean_Values.png",plotDir.Data())); TCanvas* cZPA_Mean_Values = new TCanvas("cZPA_Mean_Values","cZPA_Mean_Values", 0,0,750,900); hzpa->Draw("ep"); cZPA_Mean_Values->Print(Form("%s/cZPA_Mean_Values.png",plotDir.Data())); TCanvas* cZNC_Mean_Uncalib = new TCanvas("cZNC_Mean_Uncalib","cZNC_Mean_Uncalib", 0,0,750,900); hzncUncalib->Draw("ep"); cZNC_Mean_Uncalib->Print(Form("%s/cZNC_Mean_Uncalib.png",plotDir.Data())); TCanvas* cZNA_Mean_Uncalib = new TCanvas("cZNA_Mean_Uncalib","cZNA_Mean_Uncalib", 0,0,750,900); hznaUncalib->Draw("ep"); cZNA_Mean_Uncalib->Print(Form("%s/cZNA_Mean_Uncalib.png",plotDir.Data())); TCanvas* cZPC_Mean_Uncalib = new TCanvas("cZPC_Mean_Uncalib","cZPC_Mean_Uncalib", 0,0,750,900); hzpcUncalib->Draw("ep"); cZPC_Mean_Uncalib->Print(Form("%s/cZPC_Mean_Uncalib.png",plotDir.Data())); TCanvas* cZPA_Mean_Uncalib = new TCanvas("cZPA_Mean_Uncalib","cZPA_Mean_Uncalib", 0,0,750,900); hzpaUncalib->Draw("ep"); cZPA_Mean_Uncalib->Print(Form("%s/cZPA_Mean_Uncalib.png",plotDir.Data())); TCanvas* cZEM1_Mean_Values = new TCanvas("cZEM1_Mean_Values","cZEM1_Mean_Values", 0,0,750,900); hzem1->Draw("ep"); cZEM1_Mean_Values->Print(Form("%s/cZEM1_Mean_Values.png",plotDir.Data())); TCanvas* cZEM2_Mean_Values = new TCanvas("cZEM2_Mean_Values","cZEM2_Mean_Values", 0,0,750,900); hzem2->Draw("ep"); cZEM2_Mean_Values->Print(Form("%s/cZEM2_Mean_Values.png",plotDir.Data())); //--------------------------------------------------------------------------------------------------- //centroids //--------------------------------------------------------------------------------------------------- TCanvas* cZNA_X_centroid = new TCanvas("cZNA_X_centroid","cZNA_X_centroid", 0,0,750,900); hzna_Xcentroid->Draw(); cZNA_X_centroid->Print(Form("%s/cZNA_X_centroid.png",plotDir.Data())); TCanvas* cZNA_Y_centroid = new TCanvas("cZNA_Y_centroid","cZNA_Y_centroid", 0,0,750,900); hzna_Ycentroid->Draw(); cZNA_Y_centroid->Print(Form("%s/cZNA_Y_centroid.png",plotDir.Data())); TCanvas* cZNC_X_centroid = new TCanvas("cZNC_X_centroid","cZNC_X_centroid", 0,0,750,900); hznc_Xcentroid->Draw(); cZNC_X_centroid->Print(Form("%s/cZNC_X_centroid.png",plotDir.Data())); TCanvas* cZNC_Y_centroid = new TCanvas("cZNC_Y_centroid","cZNC_Y_centroid", 0,0,750,900); hznc_Ycentroid->Draw(); cZNC_Y_centroid->Print(Form("%s/cZNC_Y_centroid.png",plotDir.Data())); //--------------------------------------------------------------------------------- //timing //--------------------------------------------------------------------------------- TCanvas* cTimingSum = new TCanvas("cTimingSum","cTimingSum",0,0,750,900); hzn_TDC_Sum->Draw(); cTimingSum->Print(Form("%s/cTimingSum.png",plotDir.Data())); TCanvas* cTimingDiff = new TCanvas("cTimingDiff","cTimingDiff",0,0,750,900); hzn_TDC_Diff->Draw(); cTimingDiff->Print(Form("%s/cTimingDiff.png",plotDir.Data())); //---------------------------------------------------------------------- //out //---------------------------------------------------------------------- printf(" preparing output tree\n"); tree->Branch("run",&runNumber,"runNumber/I"); tree->Branch("ZNC_mean_value",&ZNC_mean,"ZNC_mean/D"); tree->Branch("ZNA_mean_value",&ZNA_mean,"ZNA_mean/D"); tree->Branch("ZPC_mean_value",&ZPC_mean,"ZPC_mean/D"); tree->Branch("ZPA_mean_value",&ZPA_mean,"ZPA_mean/D"); tree->Branch("ZNC_mean_uncalib",&ZNCuncalib_mean,"ZNCuncalib_mean/D"); tree->Branch("ZNA_mean_uncalib",&ZNAuncalib_mean,"ZNAuncalib_mean/D"); tree->Branch("ZPC_mean_uncalib",&ZPCuncalib_mean,"ZPCuncalib_mean/D"); tree->Branch("ZPA_mean_uncalib",&ZPAuncalib_mean,"ZPAuncalib_mean/D"); tree->Branch("ZEM1_mean_value",&ZEM1_mean,"ZEM1_mean/D"); tree->Branch("ZEM2_mean_value",&ZEM2_mean,"ZEM2_mean/D"); tree->Branch("ZNC_X_Centroid",&ZNC_XCent,"ZNC_XCent/D"); tree->Branch("ZNC_Y_Centroid",&ZNC_YCent,"ZNC_YCent/D"); tree->Branch("ZNA_X_Centroid",&ZNA_XCent,"ZNA_XCent/D"); tree->Branch("ZNA_Y_Centroid",&ZNA_YCent,"ZNA_YCent/D"); tree->Branch("ZNC_X_Centroid_Err",&ZNC_XCent_err,"ZNC_XCent_err/D"); tree->Branch("ZNC_Y_Centroid_Err",&ZNC_YCent_err,"ZNC_YCent_err/D"); tree->Branch("ZNA_X_Centroid_Err",&ZNA_XCent_err,"ZNA_XCent_err/D"); tree->Branch("ZNA_Y_Centroid_Err",&ZNA_YCent_err,"ZNA_YCent_err/D"); tree->Branch("ZN_TDC_Sum",&ZN_TDC_Sum,"ZN_TDC_Sum/D"); tree->Branch("ZN_TDC_Diff",&ZN_TDC_Diff,"ZN_TDC_Diff/D"); tree->Branch("ZN_TDC_Sum_Err",&ZN_TDC_Sum_err,"ZN_TDC_Sum_err/D"); tree->Branch("ZN_TDC_Diff_Err",&ZN_TDC_Diff_err,"ZN_TDC_Diff_err/D"); tree->Fill(); if(hZNCpmcUncalib) list.Add(cZNC_Spectra_Uncal); if(hZNApmcUncalib) list.Add(cZNA_Spectra_Uncal); if(hZPCpmcUncalib) list.Add(cZPC_Spectra_Uncal); if(hZPApmcUncalib) list.Add(cZPA_Spectra_Uncal); list.Add(cZEM1_Spectra); list.Add(cZEM2_Spectra); list.Add(cTimingSum); list.Add(cTimingDiff); list.Add(cZNA_X_centroid); list.Add(cZNA_Y_centroid); list.Add(cZNC_X_centroid); list.Add(cZNC_Y_centroid); TFile *fout; fout = TFile::Open("prodQAhistos.root", "update"); if(!fout) fout = new TFile("prodQAhistos.root"); fout->cd(); list.Write(); tree->Write(); fout->Close(); return 0; }
Int_t DrawTrendingTOFQA(TString mergedTrendFile = "trending.root", // trending tree file Bool_t displayAll = kFALSE) //set to kTRUE to display trending for expert plots { // //reads merged trending.root file and draws trending plots from tree // if (!mergedTrendFile) { Printf("Cannot open merged trend file with TOF QA"); return 1; } char outfilename[200]= "ProductionQA.hist.root"; TString plotDir("."); // TString plotDir(Form("PlotsTrending")); // gSystem->Exec(Form("mkdir %s",plotDir.Data())); Int_t runNumber=0; Double_t avTime=0., peakTime=0., spreadTime=0., peakTimeErr=0., spreadTimeErr=0.,negTimeRatio=0., avRawTime=0., peakRawTime=0., spreadRawTime=0., peakRawTimeErr=0., spreadRawTimeErr=0., avTot=0., peakTot=0.,spreadTot=0., peakTotErr=0.,spreadTotErr=0., meanResTOF=0., spreadResTOF=0., meanResTOFerr=0., spreadResTOFerr=0., orphansRatio=0., avL=0., negLratio=0., matchEffIntegratedErr=-9999., matchEffIntegrated=-9999., matchEffLinFit1Gev=0.,matchEffLinFit1GevErr=0.; Double_t avDiffTime=0.,peakDiffTime=0., spreadDiffTime=0.,peakDiffTimeErr=0., spreadDiffTimeErr=0.,avT0fillRes=0.; Double_t avT0A=0.,peakT0A=0., spreadT0A=0.,peakT0AErr=0., spreadT0AErr=0.; Double_t avT0C=0.,peakT0C=0., spreadT0C=0.,peakT0CErr=0., spreadT0CErr=0.; Double_t avT0AC=0.,peakT0AC=0., spreadT0AC=0.,peakT0ACErr=0., spreadT0ACErr=0.; Double_t avT0res=0.,peakT0res=0., spreadT0res=0.,peakT0resErr=0., spreadT0resErr=0.; Double_t StartTime_pBestT0 = 0.0, StartTime_pBestT0Err = 0.0, StartTime_pFillT0 = 0.0, StartTime_pFillT0Err = 0.0, StartTime_pTOFT0 = 0.0, StartTime_pTOFT0Err = 0.0, StartTime_pT0ACT0 = 0.0, StartTime_pT0ACT0Err = 0.0, StartTime_pT0AT0 = 0.0, StartTime_pT0AT0Err = 0.0, StartTime_pT0CT0 = 0.0, StartTime_pT0CT0Err = 0.0; Double_t StartTime_pBestT0_Res = 0.0, StartTime_pFillT0_Res = 0.0, StartTime_pTOFT0_Res = 0.0, StartTime_pT0ACT0_Res = 0.0, StartTime_pT0AT0_Res = 0.0, StartTime_pT0CT0_Res = 0.0; Float_t avMulti=0; Float_t fractionEventsWHits=0.0; Double_t goodChannelRatio=0.0; Double_t goodChannelRatioInAcc=0.0; TFile * fin = TFile::Open(mergedTrendFile.Data()); TTree * ttree = (TTree*) fin->Get("trending"); if (!ttree){ fin->ls(); Printf("Invalid trending tree."); return 2; } ttree->SetBranchAddress("run",&runNumber); ttree->SetBranchAddress("avMulti",&avMulti); ttree->SetBranchAddress("goodChannelsRatio",&goodChannelRatio); ttree->SetBranchAddress("goodChannelsRatioInAcc",&goodChannelRatioInAcc); ttree->SetBranchAddress("avTime",&avTime); //mean time ttree->SetBranchAddress("peakTime",&peakTime); //main peak time after fit ttree->SetBranchAddress("spreadTime",&spreadTime); //spread of main peak of time after fit ttree->SetBranchAddress("peakTimeErr",&peakTimeErr); //main peak time after fit error ttree->SetBranchAddress("spreadTimeErr",&spreadTimeErr); //spread of main peak of time after fit error ttree->SetBranchAddress("negTimeRatio",&negTimeRatio); //negative time ratio ttree->SetBranchAddress("avRawTime",&avRawTime); //mean raw time ttree->SetBranchAddress("peakRawTime",&peakRawTime); //mean peak of raw time after fit ttree->SetBranchAddress("spreadRawTime",&spreadRawTime); //spread of main peak of raw time after fit ttree->SetBranchAddress("peakRawTimeErr",&peakRawTimeErr); //main peak raw time after fit error ttree->SetBranchAddress("spreadRawTimeErr",&spreadRawTimeErr); //spread of raw main peak of time after fit error ttree->SetBranchAddress("avTot",&avTot); //main peak tot ttree->SetBranchAddress("peakTot",&peakTot); // main peak of tot after fit ttree->SetBranchAddress("spreadTot",&spreadTot); //spread of main peak of tot after fit ttree->SetBranchAddress("peakTotErr",&peakTotErr); // main peak of tot after fit ttree->SetBranchAddress("spreadTotErr",&spreadTotErr); //spread of main peak of tot after fit ttree->SetBranchAddress("orphansRatio",&orphansRatio); //orphans ratio ttree->SetBranchAddress("avL",&avL); //mean track length ttree->SetBranchAddress("negLratio",&negLratio);//ratio of tracks with track length <350 cm if(0 != ttree->SetBranchAddress("matchEffIntegrated",&matchEffIntegrated)) //matching eff integrated in pt (1-10GeV/c) matchEffIntegrated = 0; if(0 != ttree->SetBranchAddress("matchEffIntegratedErr",&matchEffIntegratedErr)) //matching eff integrated in pt (1-10GeV/c) matchEffIntegratedErr = 0; ttree->SetBranchAddress("matchEffLinFit1Gev",&matchEffLinFit1Gev);//matching eff fit param ttree->SetBranchAddress("matchEffLinFit1GevErr",&matchEffLinFit1GevErr);////matching eff fit param error ttree->SetBranchAddress("avPiDiffTime",&avDiffTime); //mean t-texp ttree->SetBranchAddress("peakPiDiffTime",&peakDiffTime); //main peak t-texp after fit ttree->SetBranchAddress("spreadPiDiffTime",&spreadDiffTime); //spread of main peak t-texp after fit ttree->SetBranchAddress("peakPiDiffTimeErr",&peakDiffTimeErr); //main peak t-texp after fit error ttree->SetBranchAddress("spreadPiDiffTimeErr",&spreadDiffTimeErr); //spread of main peak of t-texp after fit error ttree->SetBranchAddress("meanResTOF",&meanResTOF); //mean of t-texp_pi-t0_TOF ttree->SetBranchAddress("spreadResTOF",&spreadResTOF); //spread of t-texp_pi-t0_TOF, ie. resolution ttree->SetBranchAddress("meanResTOFerr",&meanResTOFerr); //error on mean of t-texp_pi-t0_TOF ttree->SetBranchAddress("spreadResTOFerr",&spreadResTOFerr); //error on the spread of t-texp_pi-t0_TOF ttree->SetBranchAddress("avT0A",&avT0A); //main peak t0A ttree->SetBranchAddress("peakT0A",&peakT0A); // main peak of t0A after fit ttree->SetBranchAddress("spreadT0A",&spreadT0A); //spread of main peak of t0A after fit ttree->SetBranchAddress("peakT0AErr",&peakT0AErr); // main peak of t0A after fit ttree->SetBranchAddress("spreadT0AErr",&spreadT0AErr); //spread of main peak of t0A after fit ttree->SetBranchAddress("avT0C",&avT0C); //main peak t0C ttree->SetBranchAddress("peakT0C",&peakT0C); // main peak of t0C after fit ttree->SetBranchAddress("spreadT0C",&spreadT0C); //spread of main peak of t0C after fit ttree->SetBranchAddress("peakT0CErr",&peakT0CErr); // main peak of t0C after fit ttree->SetBranchAddress("spreadT0CErr",&spreadT0CErr); //spread of main peak of t0C after fit ttree->SetBranchAddress("avT0AC",&avT0AC); //main peak t0AC ttree->SetBranchAddress("peakT0AC",&peakT0AC); // main peak of t0AC after fit ttree->SetBranchAddress("spreadT0AC",&spreadT0AC); //spread of main peak of t0AC after fit ttree->SetBranchAddress("peakT0ACErr",&peakT0ACErr); // main peak of t0AC after fit ttree->SetBranchAddress("spreadT0ACErr",&spreadT0ACErr); //spread of main peak of t0AC after fit ttree->SetBranchAddress("avT0res",&avT0res); //main peak t0AC ttree->SetBranchAddress("peakT0res",&peakT0res); // main peak of t0AC after fit ttree->SetBranchAddress("spreadT0res",&spreadT0res); //spread of main peak of t0AC after fit ttree->SetBranchAddress("peakT0resErr",&peakT0resErr); // main peak of t0AC after fit ttree->SetBranchAddress("spreadT0resErr",&spreadT0resErr); //spread of main peak of t0AC after fit ttree->SetBranchAddress("avT0fillRes",&avT0fillRes); //t0 fill res ttree->SetBranchAddress("StartTime_pBestT0",&StartTime_pBestT0); //T0Best ttree->SetBranchAddress("StartTime_pFillT0",&StartTime_pFillT0); //T0Fill ttree->SetBranchAddress("StartTime_pTOFT0",&StartTime_pTOFT0); //T0TOF ttree->SetBranchAddress("StartTime_pT0ACT0",&StartTime_pT0ACT0); //T0AC ttree->SetBranchAddress("StartTime_pT0AT0",&StartTime_pT0AT0); //T0A ttree->SetBranchAddress("StartTime_pT0CT0",&StartTime_pT0CT0); //T0C ttree->SetBranchAddress("StartTime_pBestT0_Res",&StartTime_pBestT0_Res); //T0Best ttree->SetBranchAddress("StartTime_pFillT0_Res",&StartTime_pFillT0_Res); //T0Fill res ttree->SetBranchAddress("StartTime_pTOFT0_Res",&StartTime_pTOFT0_Res); //T0TOF res ttree->SetBranchAddress("StartTime_pT0ACT0_Res",&StartTime_pT0ACT0_Res); //T0AC res ttree->SetBranchAddress("StartTime_pT0AT0_Res",&StartTime_pT0AT0_Res); //T0A res ttree->SetBranchAddress("StartTime_pT0CT0_Res",&StartTime_pT0CT0_Res); //T0C res ttree->SetBranchAddress("StartTime_pBestT0Err",&StartTime_pBestT0Err); //T0Best ttree->SetBranchAddress("StartTime_pFillT0Err",&StartTime_pFillT0Err); //T0Fill ttree->SetBranchAddress("StartTime_pTOFT0Err",&StartTime_pTOFT0Err); //T0TOF ttree->SetBranchAddress("StartTime_pT0ACT0Err",&StartTime_pT0ACT0Err); //T0AC ttree->SetBranchAddress("StartTime_pT0AT0Err",&StartTime_pT0AT0Err); //T0A ttree->SetBranchAddress("StartTime_pT0CT0Err",&StartTime_pT0CT0Err); //T0C //Fetch period-integrated PID plots //Pions TH2F * hDiffTimePi=(TH2F*)fin->Get("hExpTimePiVsP_all"); hDiffTimePi->SetTitle("PIONS t-t_{exp,#pi} (from tracking) vs. P"); //Kaon TH2F * hDiffTimeKa=(TH2F*)fin->Get("hExpTimeKaVsP_all"); hDiffTimeKa->SetTitle("KAONS t-t_{exp,K} (from tracking) vs. P"); //Protons TH2F * hDiffTimePro=(TH2F*)fin->Get("hExpTimeProVsP_all"); hDiffTimePro->SetTitle("PROTONS t-t_{exp,p} (from tracking) vs. P"); //Create trending plots Int_t nRuns=ttree->GetEntries(); TList lista; TH1F * hAvMulti=new TH1F("hAvMulti","Average multiplicity of matched tracks <N_{TOF}>;; <N_{TOF}>", nRuns,0., nRuns);//, 600, 0. , 600.); hAvMulti->SetDrawOption("E1"); hAvMulti->SetMarkerStyle(20); hAvMulti->SetMarkerColor(kBlue); TH1F * hAvDiffTimeVsRun=new TH1F("hAvDiffTimeVsRun","Mean t-t_{exp} (no fit);run;<t^{TOF}-t_{exp,#pi}> (ps)",nRuns,0., nRuns);//, 600, 0. , 600.); hAvDiffTimeVsRun->SetDrawOption("E1"); hAvDiffTimeVsRun->SetMarkerStyle(20); hAvDiffTimeVsRun->SetMarkerColor(kBlue); // hAvTimeVsRun->GetYaxis()->SetRangeUser(0.0, 50.0); TH1F * hPeakDiffTimeVsRun=new TH1F("hPeakDiffTimeVsRun","t-t_{exp} (gaussian fit) ;; <t^{TOF}-t_{exp,#pi}> (ps)",nRuns,0., nRuns);//,600, 0. , 600. ); hPeakDiffTimeVsRun->SetDrawOption("E1"); hPeakDiffTimeVsRun->SetMarkerStyle(20); hPeakDiffTimeVsRun->SetMarkerColor(kBlue); TH1F * hSpreadDiffTimeVsRun=new TH1F("hSpreadDiffTimeVsRun","#sigma(t-t_{exp}) (gaussian fit);; #sigma(t^{TOF}-t_{exp,#pi}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.); hSpreadDiffTimeVsRun->SetDrawOption("E1"); hSpreadDiffTimeVsRun->SetMarkerStyle(20); hSpreadDiffTimeVsRun->SetMarkerColor(kBlue); TH1F * hMeanTOFResVsRun=new TH1F("hMeanTOFResVsRun","Mean value of t-t_{exp,#pi}-t0_{TOF} (ps);;<t^{TOF}-t_{exp,#pi}-t_{0,TOF}> (ps)",nRuns,0., nRuns); hMeanTOFResVsRun->SetDrawOption("E1"); hMeanTOFResVsRun->SetMarkerStyle(20); hMeanTOFResVsRun->SetMarkerColor(kBlue); TH1F * hSigmaTOFResVsRun=new TH1F("hSigmaTOFResVsRun","Spread of t-t_{exp,#pi}-t0_{TOF} (ps);;#sigma(t^{TOF}-t_{exp,#pi}-t_{0,TOF}) (ps)",nRuns,0., nRuns); hSigmaTOFResVsRun->SetDrawOption("E1"); hSigmaTOFResVsRun->SetMarkerStyle(20); hSigmaTOFResVsRun->SetMarkerColor(kBlue); TH1F * hAvTimeVsRun=new TH1F("hAvTimeVsRun","<t^{TOF}>;;<t^{TOF}> (ns)",nRuns,0., nRuns);//, 600, 0. , 600.); hAvTimeVsRun->SetDrawOption("E1"); hAvTimeVsRun->SetMarkerStyle(20); hAvTimeVsRun->SetMarkerColor(kBlue); // hAvTimeVsRun->GetYaxis()->SetRangeUser(0.0, 50.0); TH1F * hPeakTimeVsRun=new TH1F("hPeakTimeVsRun","Peak value of t^{TOF} (landau fit);;t_{peak}^{TOF} (ns)",nRuns,0., nRuns);//,600, 0. , 600. ); hPeakTimeVsRun->SetDrawOption("E1"); hPeakTimeVsRun->SetMarkerStyle(20); hPeakTimeVsRun->SetMarkerColor(kBlue); TH1F * hSpreadTimeVsRun=new TH1F("hSpreadTimeVsRun","Spread of t^{TOF} (landau fit);; #sigma(t^{TOF}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.); hSpreadTimeVsRun->SetDrawOption("E1"); hSpreadTimeVsRun->SetMarkerStyle(20); hSpreadTimeVsRun->SetMarkerColor(kBlue); TH1F * hAvRawTimeVsRun=new TH1F("hAvRawTimeVsRun","Peak value of raw t^{TOF};;<t_{raw}^{TOF}> (ns)",nRuns,0., nRuns);//, 600, 0. , 600.); hAvRawTimeVsRun->SetDrawOption("E1"); hAvRawTimeVsRun->SetMarkerStyle(21); hAvRawTimeVsRun->SetMarkerColor(kGreen); TH1F * hPeakRawTimeVsRun=new TH1F("hPeakRawTimeVsRun","Peak value of raw t^{TOF} (landau fit);;t_{peak,raw}^{TOF} (ns)",nRuns,0., nRuns);//, 600, 0. , 600.); hPeakRawTimeVsRun->SetDrawOption("E1"); hPeakRawTimeVsRun->SetMarkerStyle(21); hPeakRawTimeVsRun->SetMarkerColor(kGreen); TH1F * hSpreadRawTimeVsRun=new TH1F("hSpreadRawTimeVsRun","Spread of raw t^{TOF} (landau fit);;#sigma(t_{raw}^{TOF}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.); hSpreadRawTimeVsRun->SetDrawOption("E1"); hSpreadRawTimeVsRun->SetMarkerStyle(21); hSpreadRawTimeVsRun->SetMarkerColor(kGreen); TH1F * hAvTotVsRun=new TH1F("hAvTotVsRun","<ToT> (no fit);run;<ToT> (ns)",nRuns,0., nRuns);//, 50, 0. , 50.); hAvTotVsRun->SetDrawOption("E1"); hAvTotVsRun->SetMarkerStyle(22); TH1F * hPeakTotVsRun=new TH1F("hPeakTotVsRun","<ToT> (gaussian fit);;ToT_{peak} (ns)",nRuns,0., nRuns);//, 50, 0. , 50.); hPeakTotVsRun->SetDrawOption("E1"); hPeakTotVsRun->SetMarkerStyle(22); TH1F * hSpreadTotVsRun=new TH1F("hSpreadTotVsRun","#sigma(ToT) (gaussian fit);#sigma(ToT) (ns)",nRuns,0., nRuns);//, 50, 0. , 50.); hSpreadTotVsRun->SetDrawOption("E1"); hSpreadTotVsRun->SetMarkerStyle(22); TH1F * hNegTimeRatioVsRun=new TH1F("hNegTimeRatioVsRun","Ratio of tracks with t^{TOF}<12.5 ns; ; ratio of tracks with t^{TOF}<12.5 ns (%)",nRuns, 0., nRuns);//, 100, 0. , 100.); hNegTimeRatioVsRun->SetDrawOption("E"); TH1F * hOrphansRatioVsRun=new TH1F("hOrphansRatioVsRun","Ratio of orphans (hits with ToT=0); ; ratio of orphans (%)",nRuns, 0., nRuns);//, 1000, 0. , 100.); hOrphansRatioVsRun->SetDrawOption("E"); TH1F * hMeanLVsRun=new TH1F("hMeanLVsRun","Average track length;; <L> (cm)",nRuns, 0., nRuns);//, 350, 350. , 700.); hMeanLVsRun->SetDrawOption("E"); TH1F * hNegLRatioVsRun=new TH1F("hNegLRatioVsRun","Ratio of tracks with L<350 cm;; ratio of tracks with L<350 cm (%)",nRuns, 0., nRuns);//, 1000, 0. , 100.); hNegLRatioVsRun->SetDrawOption("E"); TH1F * hMatchEffVsRun=new TH1F("hMatchEffVsRun","#epsilon_{match} (linear fit for p_{T}>1.0 GeV/c);;#epsilon_{match} (p_{T}>1.0 GeV/c)",nRuns, 0., nRuns);//, 100, 0. , 1.); hMatchEffVsRun->SetDrawOption("E"); TH1F * hMatchEffVsRunNormToGoodCh=new TH1F("hMatchEffVsRunNormToGoodCh","#epsilon_{match} normalized to percentage of TOF good channels;;#epsilon_{match}(p_{T}>1.0 GeV/c,|#eta|<0.8)/f_{all good}",nRuns, 0., nRuns);//, 100, 0. , 1.); hMatchEffVsRunNormToGoodCh->SetDrawOption("E"); TH1F * hMatchEffVsRunNormToGoodChInAcc=new TH1F("hMatchEffVsRunNormToGoodChInAcc","#epsilon_{match} normalized to TOF good channels in |#eta|<0.8;;#epsilon_{match}(p_{T}>1.0 GeV/c,|#eta|<0.8/f_{good}(|#eta|<0.8)",nRuns, 0., nRuns);//, 100, 0. , 1.); hMatchEffVsRunNormToGoodChInAcc->SetDrawOption("E"); TH1F * hMatchEffIntegratedVsRun=new TH1F("hMatchEffVsRun1hMatchEffIntegratedVsRun","#it{p}_{T} integrated #epsilon_{match}; ; #epsilon_{match} (1 < p_{T} < 10 GeV/c)",nRuns, 0., nRuns); hMatchEffIntegratedVsRun->SetDrawOption("E"); TH1F * hPeakT0AVsRun=new TH1F("hPeakT0AVsRun","Peak value of T0A (gaussian fit);;t0A (ps)",nRuns,0., nRuns); TH1F * hPeakT0CVsRun=new TH1F("hPeakT0CVsRun","Peak value of T0C (gaussian fit);;t0AC (ps)",nRuns,0., nRuns); TH1F * hPeakT0ACVsRun=new TH1F("hPeakT0ACVsRun","Peak value of T0AC (gaussian fit);;t0AC (ps)",nRuns,0., nRuns); TH1F * hT0fillResVsRun=new TH1F("hT0fillResVsRun","t0_fill spread;;t0_spread (ps)",nRuns,0., nRuns); TH1F * hT0BestVsRun=new TH1F("hT0BestVsRun","start time by best_t0;;t0 Best (ps)",nRuns,0., nRuns); hT0BestVsRun->SetDrawOption("E1"); hT0BestVsRun->SetLineColor(kOrange); hT0BestVsRun->SetLineWidth(2); hT0BestVsRun->SetMarkerStyle(20); hT0BestVsRun->SetMarkerColor(kOrange); TH1F * hT0FillVsRun=new TH1F("hT0FillVsRun","start time by fill_t0;;t0 Fill (ps)",nRuns,0., nRuns); hT0FillVsRun->SetDrawOption("E1"); hT0FillVsRun->SetLineColor(kBlue); hT0FillVsRun->SetLineWidth(2); hT0FillVsRun->SetMarkerStyle(20); hT0FillVsRun->SetMarkerColor(kBlue); TH1F * hT0TOFVsRun=new TH1F("hT0TOFVsRun","start time by TOF_t0;;t0 TOF (ps)",nRuns,0., nRuns); hT0TOFVsRun->SetDrawOption("E1"); hT0TOFVsRun->SetLineColor(kBlue); hT0TOFVsRun->SetLineWidth(2); hT0TOFVsRun->SetMarkerStyle(20); hT0TOFVsRun->SetMarkerColor(kBlue); TH1F * hT0T0ACVsRun=new TH1F("hT0T0ACVsRun","start time by T0AC;;t0 T0AC (ps)",nRuns,0., nRuns); hT0T0ACVsRun->SetDrawOption("E1"); hT0T0ACVsRun->SetLineColor(kRed); hT0T0ACVsRun->SetLineWidth(2); hT0T0ACVsRun->SetMarkerStyle(20); hT0T0ACVsRun->SetMarkerColor(kRed); TH1F * hT0T0AVsRun=new TH1F("hT0T0AtVsRun","start time by T0A;;t0 T0A (ps)",nRuns,0., nRuns); hT0T0AVsRun->SetDrawOption("E1"); hT0T0AVsRun->SetLineColor(kGreen+2); hT0T0AVsRun->SetLineWidth(2); hT0T0AVsRun->SetMarkerStyle(20); hT0T0AVsRun->SetMarkerColor(kGreen+2); TH1F * hT0T0CVsRun=new TH1F("hT0T0CVsRun","start time by T0C;;t0 T0C (ps)",nRuns,0., nRuns); hT0T0CVsRun->SetDrawOption("E1"); hT0T0CVsRun->SetLineColor(kMagenta); hT0T0CVsRun->SetLineWidth(2); hT0T0CVsRun->SetMarkerStyle(20); hT0T0CVsRun->SetMarkerColor(kMagenta); TH1F * hT0BestVsRunRes=new TH1F("hT0BestVsRunRes","#sigma of best_t0;; #sigma t0 Best (ps)",nRuns,0., nRuns); hT0BestVsRunRes->SetDrawOption("E1"); hT0BestVsRunRes->SetLineColor(kOrange); hT0BestVsRunRes->SetLineWidth(2); hT0BestVsRunRes->SetMarkerStyle(20); hT0BestVsRunRes->SetMarkerColor(kOrange); TH1F * hT0FillVsRunRes=new TH1F("hT0FillVsRunRes","fill_t0;; #sigmat0 Fill (ps)",nRuns,0., nRuns); hT0FillVsRunRes->SetDrawOption("E1"); hT0FillVsRunRes->SetLineColor(kBlue); hT0FillVsRunRes->SetLineWidth(2); hT0FillVsRunRes->SetMarkerStyle(20); hT0FillVsRunRes->SetMarkerColor(kBlue); TH1F * hT0TOFVsRunRes=new TH1F("hT0T0FVsRunRes","TOF_t0;; #sigma t0 TOF (ps)",nRuns,0., nRuns); hT0TOFVsRunRes->SetDrawOption("E1"); hT0TOFVsRunRes->SetLineColor(kBlue); hT0TOFVsRunRes->SetLineWidth(2); hT0TOFVsRunRes->SetMarkerStyle(20); hT0TOFVsRunRes->SetMarkerColor(kBlue); TH1F * hT0T0ACVsRunRes=new TH1F("hT0T0ACVsRunRes","T0AC_t0;; #sigma t0 T0AC (ps)",nRuns,0., nRuns); hT0T0ACVsRunRes->SetDrawOption("E1"); hT0T0ACVsRunRes->SetLineColor(kRed); hT0T0ACVsRunRes->SetLineWidth(2); hT0T0ACVsRunRes->SetMarkerStyle(20); hT0T0ACVsRunRes->SetMarkerColor(kRed); TH1F * hT0T0AVsRunRes=new TH1F("hT0T0AVsRunRes","T0A_t0;; #sigma t0 T0A (ps)",nRuns,0., nRuns); hT0T0AVsRunRes->SetDrawOption("E1"); hT0T0AVsRunRes->SetLineColor(kGreen+2); hT0T0AVsRunRes->SetLineWidth(2); hT0T0AVsRunRes->SetMarkerStyle(20); hT0T0AVsRunRes->SetMarkerColor(kGreen+2); TH1F * hT0T0CVsRunRes=new TH1F("hT0T0CVsRunRes","T0C_t0;; #sigma t0 T0C (ps)",nRuns,0., nRuns); hT0T0CVsRunRes->SetDrawOption("E1"); hT0T0CVsRunRes->SetLineColor(kMagenta); hT0T0CVsRunRes->SetLineWidth(2); hT0T0CVsRunRes->SetMarkerStyle(20); hT0T0CVsRunRes->SetMarkerColor(kMagenta); TH1F * hGoodChannelsRatio=new TH1F("hGoodChannelsRatio","Fraction of TOF good channels;;fraction of good channels",nRuns, 0., nRuns);//, 100, 0. , 1.); hGoodChannelsRatio->SetDrawOption("E"); TH1F * hGoodChannelsRatioInAcc=new TH1F("hGoodChannelsRatioInAcc","Fraction of TOF good channels in |#eta|<0.8;;fraction of good channels in |#eta|<0.8",nRuns, 0., nRuns);//, 100, 0. , 1.); hGoodChannelsRatioInAcc->SetDrawOption("E"); lista.Add(hAvMulti); lista.Add(hAvDiffTimeVsRun); lista.Add(hPeakDiffTimeVsRun); lista.Add(hSpreadDiffTimeVsRun); lista.Add(hAvTimeVsRun); lista.Add(hPeakTimeVsRun); lista.Add(hMeanTOFResVsRun); lista.Add(hSigmaTOFResVsRun); lista.Add(hSpreadTimeVsRun); lista.Add(hAvRawTimeVsRun); lista.Add(hPeakRawTimeVsRun); lista.Add(hSpreadRawTimeVsRun); lista.Add(hAvTotVsRun); lista.Add(hPeakTotVsRun); lista.Add(hSpreadTotVsRun); lista.Add(hNegTimeRatioVsRun); lista.Add(hOrphansRatioVsRun); lista.Add(hMeanLVsRun); lista.Add(hNegLRatioVsRun); lista.Add(hMatchEffVsRun); lista.Add(hMatchEffVsRunNormToGoodCh); lista.Add(hMatchEffVsRunNormToGoodChInAcc); lista.Add(hPeakT0AVsRun); lista.Add(hPeakT0CVsRun); lista.Add(hPeakT0ACVsRun); lista.Add(hT0fillResVsRun); lista.Add(hGoodChannelsRatio); lista.Add(hGoodChannelsRatioInAcc); lista.Add(hT0BestVsRun); lista.Add(hT0FillVsRun); lista.Add(hT0TOFVsRun); lista.Add(hT0T0ACVsRun); lista.Add(hT0T0AVsRun); lista.Add(hT0T0CVsRun); lista.Add(hT0BestVsRunRes); lista.Add(hT0FillVsRunRes); lista.Add(hT0TOFVsRunRes); lista.Add(hT0T0ACVsRunRes); lista.Add(hT0T0AVsRunRes); lista.Add(hT0T0CVsRunRes); char runlabel[6]; for (Int_t irun=0;irun<nRuns;irun++){ ttree->GetEntry(irun); sprintf(runlabel,"%i",runNumber); hAvMulti->SetBinContent(irun+1, avMulti); hAvMulti->GetXaxis()->SetBinLabel(irun+1,runlabel); hAvDiffTimeVsRun->SetBinContent(irun+1, avDiffTime); hAvDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hPeakDiffTimeVsRun->SetBinContent(irun+1,peakDiffTime); hPeakDiffTimeVsRun->SetBinError(irun+1,peakDiffTimeErr); hPeakDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hSpreadDiffTimeVsRun->SetBinContent(irun+1,spreadDiffTime); hSpreadDiffTimeVsRun->SetBinError(irun+1,spreadDiffTimeErr); hSpreadDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hMeanTOFResVsRun->SetBinContent(irun+1,meanResTOF); hMeanTOFResVsRun->SetBinError(irun+1,meanResTOFerr); hMeanTOFResVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hSigmaTOFResVsRun->SetBinContent(irun+1,spreadResTOF); hSigmaTOFResVsRun->SetBinError(irun+1,spreadResTOFerr); hSigmaTOFResVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hAvTimeVsRun->SetBinContent(irun+1, avTime); hAvTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hPeakTimeVsRun->SetBinContent(irun+1,peakTime); hPeakTimeVsRun->SetBinError(irun+1,peakTimeErr); hPeakTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hSpreadTimeVsRun->SetBinContent(irun+1,spreadTime); hSpreadTimeVsRun->SetBinError(irun+1,spreadTimeErr); hSpreadTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hAvRawTimeVsRun->SetBinContent(irun+1, avRawTime); hAvRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hPeakRawTimeVsRun->SetBinContent(irun+1,peakRawTime); hPeakRawTimeVsRun->SetBinError(irun+1,peakRawTimeErr); hPeakRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hSpreadRawTimeVsRun->SetBinContent(irun+1,spreadRawTime); hSpreadRawTimeVsRun->SetBinError(irun+1,spreadRawTimeErr); hSpreadRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hAvTotVsRun->SetBinContent(irun+1,avTot); hAvTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hPeakTotVsRun->SetBinContent(irun+1,peakTot); hPeakTotVsRun->SetBinError(irun+1,peakTotErr); hPeakTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hSpreadTotVsRun->SetBinContent(irun+1,spreadTot); hSpreadTotVsRun->SetBinError(irun+1,spreadTotErr); hSpreadTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hNegTimeRatioVsRun->SetBinContent(irun+1,negTimeRatio); hNegTimeRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hOrphansRatioVsRun->SetBinContent(irun+1,orphansRatio); hOrphansRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hMeanLVsRun->SetBinContent(irun+1,avL); hMeanLVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hNegLRatioVsRun->SetBinContent(irun+1,negLratio); hNegLRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hMatchEffVsRun->SetBinContent(irun+1,matchEffLinFit1Gev); hMatchEffVsRun->SetBinError(irun+1,matchEffLinFit1GevErr); hMatchEffVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hMatchEffVsRun->SetLineColor(kRed); hMatchEffVsRun->SetLineWidth(2); hMatchEffIntegratedVsRun->SetBinContent(irun+1, matchEffIntegrated); hMatchEffIntegratedVsRun->SetBinError(irun+1, matchEffIntegratedErr); hMatchEffIntegratedVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hMatchEffIntegratedVsRun->SetLineColor(kOrange); hMatchEffIntegratedVsRun->SetLineStyle(7); hMatchEffIntegratedVsRun->SetLineWidth(2); if (goodChannelRatio>0) hMatchEffVsRunNormToGoodCh->SetBinContent(irun+1,matchEffLinFit1Gev/goodChannelRatio); else hMatchEffVsRunNormToGoodCh->SetBinContent(irun+1, 0.0); hMatchEffVsRunNormToGoodCh->SetBinError(irun+1,matchEffLinFit1GevErr); hMatchEffVsRunNormToGoodCh->GetXaxis()->SetBinLabel(irun+1,runlabel); hMatchEffVsRunNormToGoodCh->SetLineColor(kCyan+2); hMatchEffVsRunNormToGoodCh->SetLineWidth(2); hGoodChannelsRatio->SetBinContent(irun+1, goodChannelRatio); hGoodChannelsRatio->SetLineColor(kCyan-1); hGoodChannelsRatio->SetLineWidth(2); hGoodChannelsRatio->GetXaxis()->SetBinLabel(irun+1,runlabel); if (goodChannelRatioInAcc>0) hMatchEffVsRunNormToGoodChInAcc->SetBinContent(irun+1,matchEffLinFit1Gev/goodChannelRatioInAcc); else hMatchEffVsRunNormToGoodChInAcc->SetBinContent(irun+1, 0.0); hMatchEffVsRunNormToGoodChInAcc->SetBinError(irun+1,matchEffLinFit1GevErr); hMatchEffVsRunNormToGoodChInAcc->GetXaxis()->SetBinLabel(irun+1,runlabel); hMatchEffVsRunNormToGoodChInAcc->SetLineColor(kBlue); hMatchEffVsRunNormToGoodChInAcc->SetLineWidth(2); hGoodChannelsRatioInAcc->SetBinContent(irun+1, goodChannelRatioInAcc); hGoodChannelsRatioInAcc->SetLineColor(kBlue+2); hGoodChannelsRatioInAcc->SetLineWidth(2); hGoodChannelsRatioInAcc->GetXaxis()->SetBinLabel(irun+1,runlabel); hPeakT0AVsRun->SetBinContent(irun+1,peakT0A); hPeakT0AVsRun->SetBinError(irun+1,spreadT0A); hPeakT0AVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hPeakT0CVsRun->SetBinContent(irun+1,peakT0C); hPeakT0CVsRun->SetBinError(irun+1,spreadT0C); hPeakT0CVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hPeakT0ACVsRun->SetBinContent(irun+1,peakT0AC); hPeakT0ACVsRun->SetBinError(irun+1,spreadT0AC); hPeakT0ACVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0fillResVsRun->SetBinContent(irun+1,avT0fillRes); hT0fillResVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0BestVsRun->SetBinContent(irun+1,StartTime_pBestT0); hT0BestVsRun->SetBinError(irun+1,StartTime_pBestT0Err); hT0BestVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0FillVsRun->SetBinContent(irun+1,StartTime_pFillT0); hT0FillVsRun->SetBinError(irun+1,StartTime_pFillT0Err); hT0FillVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0TOFVsRun->SetBinContent(irun+1,StartTime_pTOFT0); hT0TOFVsRun->SetBinError(irun+1,StartTime_pTOFT0Err); hT0TOFVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0T0ACVsRun->SetBinContent(irun+1,StartTime_pT0ACT0); hT0T0ACVsRun->SetBinError(irun+1,StartTime_pT0ACT0Err); hT0T0ACVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0T0AVsRun->SetBinContent(irun+1,StartTime_pT0AT0); hT0T0AVsRun->SetBinError(irun+1,StartTime_pT0AT0Err); hT0T0AVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0T0CVsRun->SetBinContent(irun+1,StartTime_pT0CT0); hT0T0CVsRun->SetBinError(irun+1,StartTime_pT0CT0Err); hT0T0CVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0BestVsRunRes->SetBinContent(irun+1,StartTime_pBestT0_Res); hT0BestVsRunRes->SetBinError(irun+1, 1.e-5); hT0BestVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0FillVsRunRes->SetBinContent(irun+1,StartTime_pFillT0_Res); hT0FillVsRunRes->SetBinError(irun+1, 1.e-5); hT0FillVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0TOFVsRunRes->SetBinContent(irun+1,StartTime_pTOFT0_Res); hT0TOFVsRunRes->SetBinError(irun+1, 1.e-5); hT0TOFVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0T0ACVsRunRes->SetBinContent(irun+1,StartTime_pT0ACT0_Res); hT0T0ACVsRunRes->SetBinError(irun+1, 1.e-5); hT0T0ACVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0T0AVsRunRes->SetBinContent(irun+1,StartTime_pT0AT0_Res); hT0T0AVsRunRes->SetBinError(irun+1, 1.e-5); hT0T0AVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel); hT0T0CVsRunRes->SetBinContent(irun+1,StartTime_pT0CT0_Res); hT0T0CVsRunRes->SetBinError(irun+1, 1.e-5); hT0T0CVsRunRes->GetXaxis()->SetBinLabel(irun+1,runlabel); } TFile * fout=new TFile(outfilename,"recreate"); fout->cd(); lista.Write(); fout->Close(); gStyle->SetOptStat(10); TString plotext = "png"; const TString desiredext = gSystem->Getenv("TOFQAPLOTEXTENSION"); if(desiredext.EqualTo("pdf") || desiredext.EqualTo("root")) plotext = desiredext; else if(!desiredext.IsNull()) cout<<"Unrecognized extension: '"<<desiredext<<"'"<<endl; //Plot t-texp trend TCanvas* cPeakDiffTimeVsRun = new TCanvas("cPeakDiffTimeVsRun","cPeakDiffTimeVsRun", 50,50,1050, 550); hPeakDiffTimeVsRun->GetYaxis()->SetRangeUser(-50.,50.); hPeakDiffTimeVsRun->Draw(); cPeakDiffTimeVsRun->Print(Form("%s/cPeakDiffTimeVsRun.%s", plotDir.Data(), plotext.Data())); TCanvas* cSpreadDiffTimeVsRun = new TCanvas("cSpreadDiffTimeVsRun","cSpreadDiffTimeVsRun", 50,50,1050, 550); hSpreadDiffTimeVsRun->GetYaxis()->SetRangeUser(0.,400.); hSpreadDiffTimeVsRun->Draw(); cSpreadDiffTimeVsRun->Print(Form("%s/cSpreadDiffTimeVsRun.%s", plotDir.Data(), plotext.Data())); //Plot average of t-texp-t0tof and resolution trend TCanvas* cMeanTOFResVsRun = new TCanvas("cMeanTOFResVsRun","cMeanTOFResVsRun", 50,50,1050, 550); hMeanTOFResVsRun->GetYaxis()->SetRangeUser(-50.,50.); hMeanTOFResVsRun->Draw(); cMeanTOFResVsRun->Print(Form("%s/cMeanTOFResVsRun.%s", plotDir.Data(), plotext.Data())); TCanvas* cSigmaTOFResVsRun = new TCanvas("cSigmaTOFResVsRun","cSigmaTOFResVsRun", 50,50,1050, 550); hSigmaTOFResVsRun->GetYaxis()->SetRangeUser(0.,200.); hSigmaTOFResVsRun->Draw(); cSigmaTOFResVsRun->Print(Form("%s/cSigmaTOFResVsRun.%s", plotDir.Data(), plotext.Data())); //Plot matching efficiency trend TCanvas* cMatchEffVsRun = new TCanvas("cMatchEffVsRun","cMatchEffVsRun",50, 50, 1050, 550); hMatchEffVsRun->GetYaxis()->SetRangeUser(0.,1.); hMatchEffVsRun->Draw(); hMatchEffIntegratedVsRun->Draw("same"); cMatchEffVsRun->Print(Form("%s/cMatchEffVsRun.%s", plotDir.Data(), plotext.Data())); TCanvas* cMatchEffNormToGoodChInAcc = new TCanvas("cMatchEffNormToGoodChInAcc","cMatchEffNormToGoodChInAcc",50, 50,1050, 550); hMatchEffVsRunNormToGoodChInAcc->GetYaxis()->SetRangeUser(0.,1.); hMatchEffVsRunNormToGoodChInAcc->Draw(); cMatchEffNormToGoodChInAcc->Print(Form("%s/cMatchEffNormToGoodChInAcc.%s", plotDir.Data(), plotext.Data())); TCanvas* cMatchEffNormToGoodCh = new TCanvas("cMatchEffNormToGoodCh","cMatchEffNormToGoodCh",50, 50,1050, 550); hMatchEffVsRunNormToGoodCh->GetYaxis()->SetRangeUser(0.,1.); hMatchEffVsRunNormToGoodCh->Draw(); cMatchEffNormToGoodCh->Print(Form("%s/cMatchEffNormToGoodCh.%s", plotDir.Data(), plotext.Data())); TLegend *leg = new TLegend(0.5095602,0.1206897,0.8891013,0.3314176,NULL,"brNDC"); leg->SetBorderSize(1); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(1001); TLegendEntry *entry=leg->AddEntry("hMatchEffVsRun","#epsilon_{match} (linear fit for p_{T}>1.0 GeV/c)","lpf"); entry->SetFillStyle(1001); Int_t ci = TColor::GetColor("#ff0000"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(2); entry->SetMarkerColor(1); entry->SetMarkerStyle(1); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("hMatchEffVsRunNormToGoodCh","#epsilon_{match} norm. to fraction of TOF good channels","lpf"); entry->SetFillStyle(1001); ci = TColor::GetColor("#009999"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(2); entry->SetMarkerColor(1); entry->SetMarkerStyle(1); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("hMatchEffVsRunNormToGoodChInAcc","#epsilon_{match} norm. to fraction of TOF good channels in |#eta|<0.8","lpf"); entry->SetFillStyle(1001); ci = TColor::GetColor("#0000ff"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(2); entry->SetMarkerColor(1); entry->SetMarkerStyle(1); entry->SetMarkerSize(1); entry->SetTextFont(42); TCanvas* cMatchEffSummary = new TCanvas("cMatchEffSummary","cMatchEffSummary",50, 50,1050, 550); hMatchEffVsRun->GetYaxis()->SetRangeUser(0.4,0.8); hMatchEffVsRun->Draw(); hMatchEffVsRunNormToGoodCh->Draw("same"); hMatchEffVsRunNormToGoodChInAcc->Draw("same"); leg->Draw("same"); cMatchEffSummary->Print(Form("%s/cMatchEffSummary.%s", plotDir.Data(), plotext.Data())); //Plot start time trend TCanvas* cStartTimeSummary = new TCanvas("cStartTimeSummary","cStartTimeSummary",50, 50,1050, 550); hT0TOFVsRun->GetYaxis()->SetRangeUser(-100.,100.); hT0TOFVsRun->GetYaxis()->SetTitle("Start Time (ps)"); hT0TOFVsRun->Draw(); hT0T0ACVsRun->Draw("same"); hT0T0AVsRun->Draw("same"); hT0T0CVsRun->Draw("same"); hT0BestVsRun->Draw("same"); gPad->SetGridy(); gPad->SetTitle("Start Time by different methods"); TLegend * cLegSTS = new TLegend(0.6,0.7,0.9,0.9); cLegSTS->SetFillStyle(1001); cLegSTS->SetFillColor(kWhite); cLegSTS->SetNColumns(2); cLegSTS->SetBorderSize(1); cLegSTS->AddEntry(hT0TOFVsRun,"TOF_T0","lp"); cLegSTS->AddEntry(hT0T0ACVsRun,"T0AC_T0","lp"); cLegSTS->AddEntry(hT0T0AVsRun,"T0A_T0","lp"); cLegSTS->AddEntry(hT0T0CVsRun,"T0C_T0","lp"); cLegSTS->AddEntry(hT0BestVsRun, "Best_T0","lp"); cLegSTS->Draw(); cStartTimeSummary->Print(Form("%s/cStartTimeSummary.%s", plotDir.Data(), plotext.Data())); TCanvas* cStartTimeResolutionSummary = new TCanvas("cStartTimeResolutionSummary","cStartTimeResolutionSummary",50, 50,1050, 550); hT0TOFVsRunRes->GetYaxis()->SetRangeUser(0.,200.); hT0TOFVsRunRes->GetYaxis()->SetTitle("#sigma Start Time (ps)"); hT0TOFVsRunRes->Draw(); hT0T0ACVsRunRes->Draw("same"); hT0T0AVsRunRes->Draw("same"); hT0T0CVsRunRes->Draw("same"); hT0BestVsRunRes->Draw("same"); TLegend * cLegSTRS = new TLegend(0.6,0.7,0.9,0.9); cLegSTRS->SetFillStyle(1001); cLegSTRS->SetFillColor(kWhite); cLegSTRS->SetNColumns(2); cLegSTRS->SetBorderSize(1); cLegSTRS->AddEntry(hT0TOFVsRunRes,"TOF_T0 res.","lp"); cLegSTRS->AddEntry(hT0T0ACVsRunRes,"T0AC_T0 res.","lp"); cLegSTRS->AddEntry(hT0T0AVsRunRes,"T0A_T0 res.","lp"); cLegSTRS->AddEntry(hT0T0CVsRunRes,"T0C_T0 res.","lp"); cLegSTRS->AddEntry(hT0BestVsRunRes, "Best_T0 res.","lp"); cLegSTRS->Draw(); cStartTimeResolutionSummary->Print(Form("%s/cStartTimeResolutionSummary.%s", plotDir.Data(), plotext.Data())); TCanvas* cGoodCh = new TCanvas("cGoodCh","cGoodCh",50, 50,1050, 550); hGoodChannelsRatio->GetYaxis()->SetRangeUser(0.75,1.); hGoodChannelsRatio->Draw(); cGoodCh->Print(Form("%s/cGoodCh.%s", plotDir.Data(), plotext.Data())); TCanvas* cGoodChInAcc = new TCanvas("cGoodChInAcc","cGoodChInAcc",50, 50,1050, 550); hGoodChannelsRatioInAcc->GetYaxis()->SetRangeUser(0.75,1.); hGoodChannelsRatioInAcc->Draw(); cGoodChInAcc->Print(Form("%s/cGoodChInAcc.%s", plotDir.Data(), plotext.Data())); TCanvas* cPidPerformance= new TCanvas("cPidPerformance","summary of PID performance", 1200, 500); cPidPerformance->Divide(3,1); cPidPerformance->cd(1); gPad->SetLogz(); hDiffTimePi->Draw("colz"); cPidPerformance->cd(2); gPad->SetLogz(); hDiffTimeKa->Draw("colz"); cPidPerformance->cd(3); gPad->SetLogz(); hDiffTimePro->Draw("colz"); cPidPerformance->Print(Form("%s/cPIDExpTimes.%s", plotDir.Data(), plotext.Data())); if (displayAll) { TCanvas* cPeakT0AVsRun = new TCanvas("cPeakT0AVsRun","cPeakT0AVsRun", 50,50,1050, 550); hPeakT0AVsRun->Draw(); cPeakT0AVsRun->Print(Form("%s/cPeakT0AVsRun.png",plotDir.Data())); TCanvas* cPeakT0CVsRun = new TCanvas("cPeakT0CVsRun","cPeakT0CVsRun", 50,50,1050, 550); hPeakT0CVsRun->Draw(); cPeakT0CVsRun->Print(Form("%s/cPeakT0CVsRun.png",plotDir.Data())); TCanvas* cPeakT0ACVsRun = new TCanvas("cPeakT0ACVsRun","cPeakT0ACVsRun", 50,50,1050, 550); hPeakT0ACVsRun->Draw(); cPeakT0ACVsRun->Print(Form("%s/cPeakT0ACVsRun.png",plotDir.Data())); TCanvas* cT0fillResVsRun = new TCanvas("cT0fillResVsRun","cT0fillResVsRun", 50,50,1050, 550); hT0fillResVsRun->Draw(); cT0fillResVsRun->Print(Form("%s/cT0fillResVsRun.png",plotDir.Data())); //Plot TOF signal trend TCanvas* cAvDiffTimeVsRun = new TCanvas("cAvDiffTimeVsRun","cAvDiffTimeVsRun",50,50,1050, 550); gPad->SetGridx(); gPad->SetGridy(); hAvDiffTimeVsRun->Draw(); cAvDiffTimeVsRun->Print(Form("%s/cAvDiffTimeVsRun.png",plotDir.Data())); TCanvas* cAvTimeVsRun = new TCanvas("cAvTimeVsRun","cAvTimeVsRun", 50,50,1050, 550); hAvTimeVsRun->Draw(); cAvTimeVsRun->Print(Form("%s/cAvTimeVsRun.png",plotDir.Data())); TCanvas* cPeakTimeVsRun = new TCanvas("cPeakTimeVsRun","cPeakTimeVsRun", 50,50,1050, 550); hPeakTimeVsRun->Draw(); cPeakTimeVsRun->Print(Form("%s/cPeakTimeVsRun.png",plotDir.Data())); TCanvas* cSpreadTimeVsRun = new TCanvas("cSpreadTimeVsRun","cSpreadTimeVsRun", 50,50,1050, 550); hSpreadTimeVsRun->Draw(); cSpreadTimeVsRun->Print(Form("%s/cSpreadTimeVsRun.png",plotDir.Data())); TCanvas* cAvRawTimeVsRun = new TCanvas("cAvRawTimeVsRun","cAvRawTimeVsRun", 50,50,1050, 550); hAvRawTimeVsRun->Draw(); cAvRawTimeVsRun->Print(Form("%s/cAvRawTimeVsRun.png",plotDir.Data())); TCanvas* cPeakRawTimeVsRun = new TCanvas("cPeakRawTimeVsRun","cPeakRawTimeVsRun", 50,50,1050, 550); hPeakRawTimeVsRun->Draw(); cPeakRawTimeVsRun->Print(Form("%s/cPeakRawTimeVsRun.png",plotDir.Data())); TCanvas* cSpreadRawTimeVsRun = new TCanvas("cSpreadRawTimeVsRun","cSpreadRawTimeVsRun", 50,50,1050, 550); hSpreadRawTimeVsRun->Draw(); cSpreadRawTimeVsRun->Print(Form("%s/cSpreadRawTimeVsRun.png",plotDir.Data())); TCanvas* cAvTotVsRun = new TCanvas("cAvTotVsRun","cAvTotVsRun", 50,50,1050, 550); hAvTotVsRun->Draw(); cAvTotVsRun->Print(Form("%s/cAvTotVsRun.png",plotDir.Data())); TCanvas* cPeakTotVsRun = new TCanvas("cPeakTotVsRun","cPeakTotVsRun", 50,50,1050, 550); hPeakTotVsRun->Draw(); cPeakTotVsRun->Print(Form("%s/cPeakTotVsRun.png",plotDir.Data())); TCanvas* cSpreadTotVsRun = new TCanvas("cSpreadTotVsRun","cSpreadTotVsRun", 50,50,1050, 550); hSpreadTotVsRun->Draw(); cSpreadTotVsRun->Print(Form("%s/cSpreadTotVsRun.png",plotDir.Data())); TCanvas* cNegTimeRatioVsRun = new TCanvas("cNegTimeRatioVsRun","cNegTimeRatioVsRun", 50,50,1050, 550); hNegTimeRatioVsRun->Draw(); cNegTimeRatioVsRun->Print(Form("%s/cNegTimeRatioVsRun.png",plotDir.Data())); TCanvas* cOrphansRatioVsRun = new TCanvas("cOrphansRatioVsRun","cOrphansRatioVsRun", 50,50,1050, 550); hOrphansRatioVsRun->Draw(); cOrphansRatioVsRun->Print(Form("%s/cOrphansRatioVsRun.png",plotDir.Data())); TCanvas* cMeanLVsRun = new TCanvas("cMeanLVsRun","cMeanLVsRun", 50,50,1050, 550); hMeanLVsRun->Draw(); cMeanLVsRun->Print(Form("%s/cMeanLVsRun.png",plotDir.Data())); TCanvas* cNegLRatioVsRun = new TCanvas("cNegLRatioVsRun","cNegLRatioVsRun", 50,50,1050, 550); hNegLRatioVsRun->Draw(); cNegLRatioVsRun->Print(Form("%s/cNegLRatioVsRun.png",plotDir.Data())); } return 0; }
int main(int argc, char* argv[]) { TApplication theApp(srcName.Data(), &argc, argv); //============================================================================= for (int i=0; i<argc; i++) cout << i << ", " << argv[i] << endl; //============================================================================= if (argc<5) return -1; TString sPath = argv[1]; if (sPath.IsNull()) return -1; TString sFile = argv[2]; if (sFile.IsNull()) return -1; TString sJetR = argv[3]; if (sJetR.IsNull()) return -1; TString sSjeR = argv[4]; if (sSjeR.IsNull()) return -1; //============================================================================= sPath.ReplaceAll("#", "/"); //============================================================================= double dJetR = -1.; if (sJetR=="JetR02") dJetR = 0.2; if (sJetR=="JetR03") dJetR = 0.3; if (sJetR=="JetR04") dJetR = 0.4; if (sJetR=="JetR05") dJetR = 0.5; if (dJetR<0.) return -1; cout << "Jet R = " << dJetR << endl; //============================================================================= double dSjeR = -1.; if (sSjeR=="SjeR01") dSjeR = 0.1; if (sSjeR=="SjeR02") dSjeR = 0.2; if (sSjeR=="SjeR03") dSjeR = 0.3; if (sSjeR=="SjeR04") dSjeR = 0.4; if (dSjeR<0.) return -1; cout << "Sub-jet R = " << dSjeR << endl; //============================================================================= const double dJetsPtMin = 0.001; const double dCutEtaMax = 1.6; const double dJetEtaMax = 1.; const double dJetAreaRef = TMath::Pi() * dJetR * dJetR; fastjet::GhostedAreaSpec areaSpc(dCutEtaMax); fastjet::JetDefinition jetsDef(fastjet::antikt_algorithm, dJetR, fastjet::BIpt_scheme, fastjet::Best); //fastjet::AreaDefinition areaDef(fastjet::active_area,areaSpc); fastjet::AreaDefinition areaDef(fastjet::active_area_explicit_ghosts,areaSpc); //fastjet::JetDefinition bkgsDef(fastjet::kt_algorithm, 0.2, fastjet::BIpt_scheme, fastjet::Best); //fastjet::AreaDefinition aBkgDef(fastjet::active_area_explicit_ghosts, areaSpc); fastjet::Selector selectJet = fastjet::SelectorAbsEtaMax(dJetEtaMax); //fastjet::Selector selectRho = fastjet::SelectorAbsEtaMax(dCutEtaMax-0.2); //fastjet::Selector selecHard = fastjet::SelectorNHardest(2); //fastjet::Selector selectBkg = selectRho * (!(selecHard)); //fastjet::JetMedianBackgroundEstimator bkgsEstimator(selectBkg, bkgsDef, aBkgDef); //fastjet::Subtractor bkgSubtractor(&bkgsEstimator); fastjet::JetDefinition subjDef(fastjet::antikt_algorithm, dSjeR, fastjet::BIpt_scheme, fastjet::Best); //============================================================================= std::vector<fastjet::PseudoJet> fjInput; //============================================================================= TList *list = new TList(); TH1D *hPtHat = new TH1D("hPtHat", "", 1000, 0., 1000.); TH1D *hJet = new TH1D("hJet", "", 1000, 0., 1000.); hJet->Sumw2(); list->Add(hJet); TH2D *hJetNsj = new TH2D("hJetNsj", "", 1000, 0., 1000., 101, -0.5, 100.5); hJetNsj->Sumw2(); list->Add(hJetNsj); TH2D *hJetIsj = new TH2D("hJetIsj", "", 1000, 0., 1000., 1000, 0., 1000.); hJetIsj->Sumw2(); list->Add(hJetIsj); TH2D *hJet1sj = new TH2D("hJet1sj", "", 1000, 0., 1000., 1000, 0., 1000.); hJet1sj->Sumw2(); list->Add(hJet1sj); TH2D *hJet2sj = new TH2D("hJet2sj", "", 1000, 0., 1000., 1000, 0., 1000.); hJet2sj->Sumw2(); list->Add(hJet2sj); TH2D *hJetDsj = new TH2D("hJetDsj", "", 1000, 0., 1000., 1000, 0., 1000.); hJetDsj->Sumw2(); list->Add(hJetDsj); TH2D *hJetIsz = new TH2D("hJetIsz", "", 1000, 0., 1000., 120, 0., 1.2); hJetIsz->Sumw2(); list->Add(hJetIsz); TH2D *hJet1sz = new TH2D("hJet1sz", "", 1000, 0., 1000., 120, 0., 1.2); hJet1sz->Sumw2(); list->Add(hJet1sz); TH2D *hJet2sz = new TH2D("hJet2sz", "", 1000, 0., 1000., 120, 0., 1.2); hJet2sz->Sumw2(); list->Add(hJet2sz); TH2D *hJetDsz = new TH2D("hJetDsz", "", 1000, 0., 1000., 120, 0., 1.2); hJetDsz->Sumw2(); list->Add(hJetDsz); //============================================================================= AliRunLoader *rl = AliRunLoader::Open(Form("%s/galice.root",sPath.Data())); if (!rl) return -1; if (rl->LoadHeader()) return -1; if (rl->LoadKinematics("READ")) return -1; //============================================================================= for (Int_t iEvent=0; iEvent<rl->GetNumberOfEvents(); iEvent++) { fjInput.resize(0); if (rl->GetEvent(iEvent)) continue; //============================================================================= AliStack *pStack = rl->Stack(); if (!pStack) continue; AliHeader *pHeader = rl->GetHeader(); if (!pHeader) continue; //============================================================================= AliGenPythiaEventHeader *pHeadPy = (AliGenPythiaEventHeader*)pHeader->GenEventHeader(); if (!pHeadPy) continue; hPtHat->Fill(pHeadPy->GetPtHard()); //============================================================================= for (Int_t i=0; i<pStack->GetNtrack(); i++) if (pStack->IsPhysicalPrimary(i)) { TParticle *pTrk = pStack->Particle(i); if (!pTrk) continue; if (TMath::Abs(pTrk->Eta())>dCutEtaMax) { pTrk = 0; continue; } // TParticlePDG *pPDG = pTrk->GetPDG(); if (!pPDG) { pTrk = 0; continue; } fjInput.push_back(fastjet::PseudoJet(pTrk->Px(), pTrk->Py(), pTrk->Pz(), pTrk->P())); // pPDG = 0; pTrk = 0; } //============================================================================= fastjet::ClusterSequenceArea clustSeq(fjInput, jetsDef, areaDef); std::vector<fastjet::PseudoJet> includJets = clustSeq.inclusive_jets(dJetsPtMin); // std::vector<fastjet::PseudoJet> subtedJets = bkgSubtractor(includJets); std::vector<fastjet::PseudoJet> selectJets = selectJet(includJets); // std::vector<fastjet::PseudoJet> sortedJets = fastjet::sorted_by_pt(selectJets); for (int j=0; j<selectJets.size(); j++) { double dJet = selectJets[j].pt(); hJet->Fill(dJet); //============================================================================= fastjet::Filter trimmer(subjDef, fastjet::SelectorPtFractionMin(0.)); fastjet::PseudoJet trimmdJet = trimmer(selectJets[j]); std::vector<fastjet::PseudoJet> trimmdSj = trimmdJet.pieces(); double nIsj = 0.; double d1sj = -1.; int k1sj = -1; double d2sj = -1.; int k2sj = -1; for (int i=0; i<trimmdSj.size(); i++) { double dIsj = trimmdSj[i].pt(); if (dIsj<0.001) continue; hJetIsj->Fill(dJet, dIsj); hJetIsz->Fill(dJet, dIsj/dJet); if (dIsj>d1sj) { d2sj = d1sj; k2sj = k1sj; d1sj = dIsj; k1sj = i; } else if (dIsj>d2sj) { d2sj = dIsj; k2sj = i; } nIsj += 1.; } hJetNsj->Fill(dJet, nIsj); if (d1sj>0.) { hJet1sj->Fill(dJet, d1sj); hJet1sz->Fill(dJet, d1sj/dJet); } if (d2sj>0.) { hJet2sj->Fill(dJet, d2sj); hJet2sz->Fill(dJet, d2sj/dJet); } if ((d1sj>0.) && (d2sj>0.)) { double dsj = d1sj - d2sj; double dsz = dsj / dJet; hJetDsj->Fill(dJet, dsj); hJetDsz->Fill(dJet, dsz); } } //============================================================================= pStack = 0; pHeadPy = 0; pHeader = 0; } //============================================================================= rl->UnloadgAlice(); rl->UnloadHeader(); rl->UnloadKinematics(); rl->RemoveEventFolder(); //============================================================================= TFile *file = TFile::Open(Form("%s/pyxsec_hists.root",sPath.Data()), "READ"); TList *lXsc = (TList*)file->Get("cFilterList"); file->Close(); TH1D *hWeightSum = (TH1D*)lXsc->FindObject("h1Trials"); hWeightSum->SetName("hWeightSum"); TProfile *hSigmaGen = (TProfile*)lXsc->FindObject("h1Xsec"); hSigmaGen->SetName("hSigmaGen"); //============================================================================= file = TFile::Open(Form("%s.root",sFile.Data()), "NEW"); hPtHat->Write(); hWeightSum->Write(); hSigmaGen->Write(); list->Write(); file->Close(); //============================================================================= cout << "DONE" << endl; //============================================================================= return 0; }
void readMCPerform(TString filename="QAresults_AOD.root", Int_t drawOnlyDzerDplus = 1, Int_t runNumber=-1) { const Int_t totTrending=5; Float_t vecForTrend[totTrending]; TString varForTrending[totTrending]={"nDzeroCandperEv","nDplusCandperEv","nDsCandperEv","nLcCandperEv","nDstarCandperEv"}; TTree* trtree=new TTree("trendingHF","tree of trending variables"); trtree->Branch("nrun",&runNumber,"nrun/I"); for(Int_t j=0; j<totTrending; j++){ trtree->Branch(varForTrending[j].Data(),&vecForTrend[j],Form("%s/F",varForTrending[j].Data())); vecForTrend[j]=-99.; } TFile *ff = new TFile(filename.Data()); Int_t color[5] = {kBlack, kRed, kGreen, kBlue, kOrange}; TDirectoryFile *dirD2H = (TDirectoryFile *)ff->Get("PWG3_D2H_QA"); if(!dirD2H){ printf("Directory PWG3_D2H_QA not found in file %s\n",filename.Data()); return; } TList *listD2H = (TList *)dirD2H->Get("nEntriesQA"); if(!listD2H){ printf("TList nEntriesQA not found in file %s\n",filename.Data()); return; } TH1F *hNentries = (TH1F *)listD2H->FindObject("hNentries"); TH2F *hHasSelBit = (TH2F *)listD2H->FindObject("HasSelBit"); TCanvas *cqa = new TCanvas("cqa", "cqa", 800, 500); cqa->Divide(2, 1); cqa->cd(1); hNentries->Draw(); cqa->cd(2); hHasSelBit->Draw("colz"); cqa->SaveAs("plot_D2HQA.png"); Double_t nEv=hNentries->GetBinContent(10); vecForTrend[0]=hHasSelBit->GetBinContent(1)/nEv; vecForTrend[1]=hHasSelBit->GetBinContent(2)/nEv; vecForTrend[2]=hHasSelBit->GetBinContent(3)/nEv; vecForTrend[3]=hHasSelBit->GetBinContent(4)/nEv; vecForTrend[4]=hHasSelBit->GetBinContent(5)/nEv; TDirectoryFile *dir = (TDirectoryFile *)ff->Get("PWGHF_D2H_MCPerform"); TList* list = 0x0; if (dir) { list = (TList *)dir->Get("coutputDperfQA"); if(list){ TH1F *hn = (TH1F *)list->FindObject("fHistNEvents"); TH1F *hnGenD = (TH1F *)list->FindObject("fHistNGenD"); Int_t entries = hn->GetBinContent(3); TH2F *fHistNCand = (TH2F *)list->FindObject("fHistNCand"); TH1F *fHistNCandDzero = (TH1F *)fHistNCand->ProjectionY("fHistNCandDzero", 1, 1); TH1F *fHistNCandDplus = (TH1F *)fHistNCand->ProjectionY("fHistNCandDplus", 2, 2); TH1F *fHistNCandDstar = (TH1F *)fHistNCand->ProjectionY("fHistNCandDstar", 3, 3); TH1F *fHistNCandDs = (TH1F *)fHistNCand->ProjectionY("fHistNCandDs", 4, 4); TH1F *fHistNCandLc = (TH1F *)fHistNCand->ProjectionY("fHistNCandLc", 5, 5); TString names[5] = {"Dzero", "Dplus", "Dstar", "Ds", "Lc2pkpi"}; TString type[2] = {"Prompt", "Feeddown"}; const Int_t nDecays = 5; TH2F *fHistXvtxResVsPt[2 * nDecays]; TH2F *fHistYvtxResVsPt[2 * nDecays]; TH2F *fHistZvtxResVsPt[2 * nDecays]; TH2F *fHistInvMassVsPt[2 * nDecays]; TH2F *fHistDecLenVsPt[2 * nDecays]; TH2F *fHistNormDLxyVsPt[2 * nDecays]; TH2F *fHistCosPointVsPt[2 * nDecays]; TH3F *fHistPtYMultGenDauInAcc[2 * nDecays]; TH3F *fHistPtYMultRecoFilt[2 * nDecays]; TProfile *fHistXvtxRes[2 * nDecays]; TProfile *fHistYvtxRes[2 * nDecays]; TProfile *fHistZvtxRes[2 * nDecays]; TProfile *fHistXvtxMean[2 * nDecays]; TProfile *fHistYvtxMean[2 * nDecays]; TProfile *fHistZvtxMean[2 * nDecays]; TH1F *fHistXvtxRes2[2 * nDecays]; TH1F *fHistYvtxRes2[2 * nDecays]; TH1F *fHistZvtxRes2[2 * nDecays]; TProfile *fHistInvMass[2 * nDecays]; TProfile *fHistDecLen[2 * nDecays]; TProfile *fHistCosp[2 * nDecays]; TH1F *fHistInvMassRes[2 * nDecays]; TH1F *hEffPt[2 * nDecays]; TH1F *htemp; for (Int_t j = 0; j < 5; j++) { //decays for (Int_t i = 0; i < 2; i++) { //prompt and fd Int_t index = j * 2 + i; fHistXvtxResVsPt[index] = (TH2F *)list->FindObject(Form("hXvtxResVsPt%s%s", type[i].Data(), names[j].Data())); fHistYvtxResVsPt[index] = (TH2F *)list->FindObject(Form("hYvtxResVsPt%s%s", type[i].Data(), names[j].Data())); fHistZvtxResVsPt[index] = (TH2F *)list->FindObject(Form("hZvtxResVsPt%s%s", type[i].Data(), names[j].Data())); fHistInvMassVsPt[index] = (TH2F *)list->FindObject(Form("hInvMassVsPt%s%s", type[i].Data(), names[j].Data())); fHistDecLenVsPt[index] = (TH2F *)list->FindObject(Form("hDecLenVsPt%s%s", type[i].Data(), names[j].Data())); fHistCosPointVsPt[index] = (TH2F *)list->FindObject(Form("hCosPointVsPt%s%s", type[i].Data(), names[j].Data())); fHistPtYMultGenDauInAcc[index] = (TH3F *)list->FindObject(Form("hPtYMult%sGenDauInAcc%s", type[i].Data(), names[j].Data())); fHistPtYMultRecoFilt[index] = (TH3F *)list->FindObject(Form("hPtYMult%sRecoFilt%s", type[i].Data(), names[j].Data())); fHistXvtxMean[index] = (TProfile *)fHistXvtxResVsPt[index]->ProfileX(Form("hXvtxMean%s%s", type[i].Data(), names[j].Data())); fHistXvtxMean[index]->SetLineColor(color[j]); fHistXvtxMean[index]->SetLineWidth(2); fHistXvtxMean[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistXvtxMean[index]->GetYaxis()->SetTitle("Xvtx (reco-true) mean (#mum)"); fHistXvtxMean[index]->SetTitle("Xvtx residual vs pT"); fHistYvtxMean[index] = (TProfile *)fHistYvtxResVsPt[index]->ProfileX(Form("hYvtxMean%s%s", type[i].Data(), names[j].Data())); fHistYvtxMean[index]->SetLineColor(color[j]); fHistYvtxMean[index]->SetLineWidth(2); fHistYvtxMean[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistYvtxMean[index]->GetYaxis()->SetTitle("Yvtx (reco-true) mean (#mum)"); fHistYvtxMean[index]->SetTitle("Yvtx residual vs pT"); fHistZvtxMean[index] = (TProfile *)fHistZvtxResVsPt[index]->ProfileX(Form("hZvtxMean%s%s", type[i].Data(), names[j].Data())); fHistZvtxMean[index]->SetLineColor(color[j]); fHistZvtxMean[index]->SetLineWidth(2); fHistZvtxMean[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistZvtxMean[index]->GetYaxis()->SetTitle("Zvtx (reco-true) mean (#mum)"); fHistZvtxMean[index]->SetTitle("Zvtx residual vs pT"); fHistXvtxRes[index] = (TProfile *)fHistXvtxResVsPt[index]->ProfileX(Form("hXvtxRes%s%s", type[i].Data(), names[j].Data()), 1, -1, "s"); fHistYvtxRes[index] = (TProfile *)fHistYvtxResVsPt[index]->ProfileX(Form("hYvtxRes%s%s", type[i].Data(), names[j].Data()), 1, -1, "s"); fHistZvtxRes[index] = (TProfile *)fHistZvtxResVsPt[index]->ProfileX(Form("hZvtxRes%s%s", type[i].Data(), names[j].Data()), 1, -1, "s"); fHistXvtxRes2[index] = (TH1F *)fHistXvtxResVsPt[index]->ProjectionX(Form("hXvtxRes2%s%s", type[i].Data(), names[j].Data())); fHistYvtxRes2[index] = (TH1F *)fHistYvtxResVsPt[index]->ProjectionX(Form("hYvtxRes2%s%s", type[i].Data(), names[j].Data())); fHistZvtxRes2[index] = (TH1F *)fHistZvtxResVsPt[index]->ProjectionX(Form("hZvtxRes2%s%s", type[i].Data(), names[j].Data())); fHistXvtxRes[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistXvtxRes[index]->GetYaxis()->SetTitle("Xvtx (reco-true) RMS (#mum)"); fHistXvtxRes[index]->SetTitle("Xvtx resolution vs pT"); fHistYvtxRes[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistYvtxRes[index]->GetYaxis()->SetTitle("Yvtx (reco-true) RMS (#mum)"); fHistYvtxRes[index]->SetTitle("Yvtx resolution vs pT"); fHistZvtxRes[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistZvtxRes[index]->GetYaxis()->SetTitle("Zvtx (reco-true) RMS (#mum)"); fHistZvtxRes[index]->SetTitle("Zvtx resolution vs pT"); fHistXvtxRes2[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistXvtxRes2[index]->GetYaxis()->SetTitle("Xvtx (reco-true) RMS (#mum)"); fHistXvtxRes2[index]->SetTitle("Xvtx resolution vs pT"); fHistYvtxRes2[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistYvtxRes2[index]->GetYaxis()->SetTitle("Yvtx (reco-true) RMS (#mum)"); fHistYvtxRes2[index]->SetTitle("Yvtx resolution vs pT"); fHistZvtxRes2[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistZvtxRes2[index]->GetYaxis()->SetTitle("Zvtx (reco-true) RMS (#mum)"); fHistZvtxRes2[index]->SetTitle("Zvtx resolution vs pT"); fHistXvtxRes2[index]->SetLineColor(color[j]); fHistYvtxRes2[index]->SetLineColor(color[j]); fHistZvtxRes2[index]->SetLineColor(color[j]); fHistXvtxRes2[index]->SetMarkerColor(color[j]); fHistXvtxRes2[index]->SetMarkerStyle(20); fHistYvtxRes2[index]->SetMarkerColor(color[j]); fHistYvtxRes2[index]->SetMarkerStyle(20); fHistZvtxRes2[index]->SetMarkerColor(color[j]); fHistZvtxRes2[index]->SetMarkerStyle(20); fHistXvtxRes2[index]->SetLineWidth(2); fHistYvtxRes2[index]->SetLineWidth(2); fHistZvtxRes2[index]->SetLineWidth(2); fHistXvtxRes2[index]->Sumw2(); fHistYvtxRes2[index]->Sumw2(); fHistZvtxRes2[index]->Sumw2(); fHistInvMass[index] = (TProfile *)fHistInvMassVsPt[index]->ProfileX(Form("hInvMassVsPt%s%s", type[i].Data(), names[j].Data())); fHistInvMass[index]->SetLineColor(color[j]); fHistInvMass[index]->SetLineWidth(2); fHistInvMass[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistInvMass[index]->GetYaxis()->SetTitle("Inv Mass (GeV/c2)"); fHistInvMass[index]->SetTitle("Inv Mass vs pT"); fHistDecLen[index] = (TProfile *)fHistDecLenVsPt[index]->ProfileX(Form("hDecLenVsPt%s%s", type[i].Data(), names[j].Data())); fHistDecLen[index]->SetLineColor(color[j]); fHistDecLen[index]->SetLineWidth(2); fHistDecLen[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistDecLen[index]->GetYaxis()->SetTitle("Dec Len (#mum)"); fHistDecLen[index]->SetTitle("Prompt Dec Len vs pT"); fHistCosp[index] = (TProfile *)fHistCosPointVsPt[index]->ProfileX(Form("hCosPVsPt%s%s", type[i].Data(), names[j].Data())); fHistCosp[index]->SetLineColor(color[j]); fHistCosp[index]->SetLineWidth(2); fHistCosp[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistCosp[index]->GetYaxis()->SetTitle("Cos Point"); fHistCosp[index]->SetTitle("Prompt CosPoint vs pT"); if (index % 2 == 1) fHistDecLen[index]->SetTitle("FeedDown Dec Len vs pT"); htemp = (TH1F *)fHistPtYMultGenDauInAcc[index]->ProjectionX(Form("hPtDen%s%s", type[i].Data(), names[j].Data())); hEffPt[index] = (TH1F *)fHistPtYMultRecoFilt[index]->ProjectionX(Form("hPtNum%s%s", type[i].Data(), names[j].Data())); fHistPtYMultGenDauInAcc[index]->Sumw2(); fHistPtYMultRecoFilt[index]->Sumw2(); hEffPt[index]->Sumw2(); hEffPt[index]->Divide(htemp); hEffPt[index]->SetLineColor(color[j]); hEffPt[index]->SetLineWidth(2); hEffPt[index]->GetXaxis()->SetTitle("pT (GeV/c)"); hEffPt[index]->GetYaxis()->SetTitle("Prompt Efficiency"); hEffPt[index]->SetTitle("Prompt Efficiency"); hEffPt[index]->SetStats(0); fHistCosp[index]->SetStats(0); fHistDecLen[index]->SetStats(0); if (index % 2 == 1) { hEffPt[index]->GetYaxis()->SetTitle("Feeddown Efficiency"); hEffPt[index]->SetTitle("Feeddown Efficiency"); } fHistInvMassRes[index] = new TH1F(*hEffPt[index]); for (Int_t jj = 1; jj < hEffPt[index]->GetNbinsX() + 1; jj++) { TH1F *hTemp = (TH1F *)fHistInvMassVsPt[index]->ProjectionY("htemp", jj, jj); fHistInvMassRes[index]->SetBinContent(jj, hTemp->GetRMS()); fHistInvMassRes[index]->SetBinError(jj, hTemp->GetRMSError()); fHistInvMassRes[index]->SetLineColor(color[j]); fHistInvMassRes[index]->SetLineWidth(2); fHistInvMassRes[index]->GetXaxis()->SetTitle("pT (GeV/c)"); fHistInvMassRes[index]->GetYaxis()->SetTitle("Inv Mass RMS (GeV/c2)"); fHistInvMassRes[index]->SetTitle("Inv Mass RMS vs pT"); if (index == 0) printf("D0: pt=%f, res=%f \n", fHistInvMassRes[index]->GetBinCenter(jj), fHistInvMassRes[index]->GetBinContent(jj)); TH1F *hTempX = (TH1F *)fHistXvtxResVsPt[index]->ProjectionY("htempX", jj, jj); TH1F *hTempY = (TH1F *)fHistYvtxResVsPt[index]->ProjectionY("htempY", jj, jj); TH1F *hTempZ = (TH1F *)fHistZvtxResVsPt[index]->ProjectionY("htempZ", jj, jj); fHistXvtxRes2[index]->SetBinContent(jj, hTempX->GetRMS()); fHistXvtxRes2[index]->SetBinError(jj, hTempX->GetRMSError()); fHistYvtxRes2[index]->SetBinContent(jj, hTempY->GetRMS()); fHistYvtxRes2[index]->SetBinError(jj, hTempY->GetRMSError()); fHistZvtxRes2[index]->SetBinContent(jj, hTempZ->GetRMS()); fHistZvtxRes2[index]->SetBinError(jj, hTempZ->GetRMSError()); } } } fHistNCandDplus->SetLineColor(2); fHistNCandDstar->SetLineColor(3); fHistNCandDs->SetLineColor(4); fHistNCandLc->SetLineColor(kOrange); fHistNCandDplus->SetLineWidth(2); fHistNCandDstar->SetLineWidth(2); fHistNCandDs->SetLineWidth(2); fHistNCandLc->SetLineWidth(2); fHistNCandDzero->GetXaxis()->SetTitle("pT (GeV/c)"); fHistNCandDzero->GetYaxis()->SetTitle("counts"); TLegend *leg = new TLegend(0.6, 0.7, 0.8, 0.9); leg->AddEntry(fHistNCandDzero, "Dzero", "l"); leg->AddEntry(fHistNCandDplus, "Dplus", "l"); leg->AddEntry(fHistNCandDstar, "Dstar", "l"); leg->AddEntry(fHistNCandDs, "Ds", "l"); leg->AddEntry(fHistNCandLc, "Lc", "l"); TLegend *leg1 = new TLegend(0.5, 0.7, 0.7, 0.9); leg1->AddEntry(fHistYvtxRes2[0], "Dzero", "pl"); leg1->AddEntry(fHistYvtxRes2[2], "Dplus", "pl"); if (drawOnlyDzerDplus == 0) leg1->AddEntry(fHistYvtxRes2[6], "Ds", "pl"); if (drawOnlyDzerDplus == 0) leg1->AddEntry(fHistYvtxRes2[8], "Lc", "pl"); TLegend *leg2 = new TLegend(0.5, 0.7, 0.7, 0.9); leg2->AddEntry(fHistYvtxMean[0], "Dzero", "l"); leg2->AddEntry(fHistYvtxMean[2], "Dplus", "l"); if (drawOnlyDzerDplus == 0) leg2->AddEntry(fHistYvtxMean[6], "Ds", "l"); if (drawOnlyDzerDplus == 0) leg2->AddEntry(fHistYvtxMean[8], "Lc", "l"); TLegend *leg3 = new TLegend(0.2, 0.7, 0.4, 0.9); leg3->AddEntry(fHistNCandDzero, "Dzero", "l"); leg3->AddEntry(fHistNCandDplus, "Dplus", "l"); if (drawOnlyDzerDplus == 0) leg3->AddEntry(fHistNCandDstar, "Dstar", "l"); if (drawOnlyDzerDplus == 0) leg3->AddEntry(fHistNCandDs, "Ds", "l"); if (drawOnlyDzerDplus == 0) leg3->AddEntry(fHistNCandLc, "Lc", "l"); TLegend *leg4 = new TLegend(0.7, 0.7, 0.9, 0.9); leg4->AddEntry(fHistNCandDzero, "Dzero", "l"); leg4->AddEntry(fHistNCandDplus, "Dplus", "l"); if (drawOnlyDzerDplus == 0) leg4->AddEntry(fHistNCandDstar, "Dstar", "l"); if (drawOnlyDzerDplus == 0) leg4->AddEntry(fHistNCandDs, "Ds", "l"); if (drawOnlyDzerDplus == 0) leg4->AddEntry(fHistNCandLc, "Lc", "l"); TCanvas *c0_1 = new TCanvas("c0_1", "c0_1", 500, 500); hnGenD->SetTitle("number of generated D mesons"); hnGenD->Draw(); c0_1->SaveAs("plotDgen.png"); TCanvas *c0_2 = new TCanvas("c0_2", "c0_2", 500, 500); c0_2->SetLogy(); fHistNCandDs->SetTitle("Candidates passing filtering cuts"); fHistNCandDs->Draw(""); c0_2->Update(); TPaveStats *stats = (TPaveStats *)c0_2->GetPrimitive("stats"); stats->SetName("h1stats"); stats->SetY1NDC(0.5); stats->SetY2NDC(0.35); c0_2->Update(); fHistNCandDplus->Draw("sames"); c0_2->Update(); TPaveStats *stats2 = (TPaveStats *)c0_2->GetPrimitive("stats"); stats2->SetName("h2stats"); stats2->SetY1NDC(0.8); stats2->SetY2NDC(.65); c0_2->Update(); fHistNCandDstar->Draw("sames"); c0_2->Update(); TPaveStats *stats3 = (TPaveStats *)c0_2->GetPrimitive("stats"); stats3->SetName("h3stats"); stats3->SetY1NDC(0.65); stats3->SetY2NDC(.5); c0_2->Update(); fHistNCandDzero->Draw("sames"); c0_2->Update(); TPaveStats *stats4 = (TPaveStats *)c0_2->GetPrimitive("stats"); stats4->SetName("h4stats"); stats4->SetY1NDC(0.95); stats4->SetY2NDC(.8); c0_2->Update(); fHistNCandLc->Draw("sames"); c0_2->Update(); TPaveStats *stats5 = (TPaveStats *)c0_2->GetPrimitive("stats"); stats5->SetName("h1stats"); stats5->SetY1NDC(0.35); stats5->SetY2NDC(.2); c0_2->Update(); leg->Draw(); c0_2->SaveAs("plotDcandpt.png"); TCanvas *c0_3 = new TCanvas("c0_3", "c0_3", 500, 500); fHistInvMass[0]->SetMinimum(1.6); fHistInvMass[0]->SetMaximum(2.4); fHistInvMass[0]->Draw(); fHistInvMass[2]->Draw("sames"); fHistInvMass[4]->Draw("sames"); fHistInvMass[6]->Draw("sames"); fHistInvMass[8]->Draw("sames"); leg->Draw(); c0_3->SaveAs("plotDcandInvMass.png"); TCanvas *c0_4 = new TCanvas("c0_4", "c0_4", 500, 500); //fHistInvMassRes[0]->SetMinimum(1.6); //fHistInvMassRes[0]->SetMaximum(2.4); fHistInvMassRes[0]->GetYaxis()->SetTitleOffset(1.4); fHistInvMassRes[0]->SetTitle("D0 Inv Mass RMS vs pT"); fHistInvMassRes[0]->Draw(""); // fHistInvMassRes[2]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistInvMassRes[4]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistInvMassRes[6]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistInvMassRes[8]->Draw("sames"); //leg->Draw(); c0_4->SaveAs("plotD0candInvMassWidth.png"); fHistXvtxMean[0]->SetStats(0); fHistYvtxMean[0]->SetStats(0); fHistZvtxMean[0]->SetStats(0); fHistXvtxMean[2]->SetStats(0); fHistYvtxMean[2]->SetStats(0); fHistZvtxMean[2]->SetStats(0); fHistXvtxRes2[0]->SetStats(0); fHistYvtxRes2[0]->SetStats(0); fHistZvtxRes2[0]->SetStats(0); fHistXvtxRes2[2]->SetStats(0); fHistYvtxRes2[2]->SetStats(0); fHistZvtxRes2[2]->SetStats(0); TCanvas *cc = new TCanvas("cc", "cc", 1200, 500); cc->Divide(3, 1); cc->cd(1); fHistXvtxMean[0]->GetYaxis()->SetTitleOffset(1.4); fHistXvtxMean[0]->SetMinimum(-300.); fHistXvtxMean[0]->SetMaximum(300.); fHistXvtxMean[0]->Draw(); fHistXvtxMean[2]->Draw("sames"); leg2->Draw(); cc->cd(2); fHistYvtxMean[0]->GetYaxis()->SetTitleOffset(1.4); fHistYvtxMean[0]->SetMinimum(-300.); fHistYvtxMean[0]->SetMaximum(300.); fHistYvtxMean[0]->Draw(); fHistYvtxMean[2]->Draw("sames"); leg2->Draw(); cc->cd(3); fHistZvtxMean[0]->GetYaxis()->SetTitleOffset(1.4); fHistZvtxMean[0]->SetMinimum(-300.); fHistZvtxMean[0]->SetMaximum(300.); fHistZvtxMean[0]->Draw(); fHistZvtxMean[2]->Draw("sames"); leg2->Draw(); cc->SaveAs("plotXYZVtxMean.png"); ///////// TCanvas *ccr = new TCanvas("ccr", "ccr", 1200, 500); ccr->Divide(3, 1); ccr->cd(1); fHistXvtxRes2[0]->GetYaxis()->SetTitleOffset(1.4); fHistXvtxRes2[0]->SetMinimum(0.); fHistXvtxRes2[0]->SetMaximum(500.); fHistXvtxRes2[0]->Draw(); fHistXvtxRes2[2]->Draw("sames"); leg2->Draw(); ccr->cd(2); fHistYvtxRes2[0]->GetYaxis()->SetTitleOffset(1.4); fHistYvtxRes2[0]->SetMinimum(0.); fHistYvtxRes2[0]->SetMaximum(500.); fHistYvtxRes2[0]->Draw(); fHistYvtxRes2[2]->Draw("sames"); leg2->Draw(); ccr->cd(3); fHistZvtxRes2[0]->GetYaxis()->SetTitleOffset(1.4); fHistZvtxRes2[0]->SetMinimum(0.); fHistZvtxRes2[0]->SetMaximum(500.); fHistZvtxRes2[0]->Draw(); fHistZvtxRes2[2]->Draw("sames"); leg2->Draw(); ccr->SaveAs("plotXYZVtxRMS.png"); TCanvas *ccc = new TCanvas("ccc", "ccc", 1200, 800); ccc->Divide(3, 2); ccc->cd(1); fHistDecLen[0]->GetYaxis()->SetTitleOffset(1.45); fHistDecLen[0]->Draw(); fHistDecLen[2]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistDecLen[4]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistDecLen[6]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistDecLen[8]->Draw("sames"); leg3->Draw(); ccc->cd(2); fHistCosp[0]->GetYaxis()->SetTitleOffset(1.45); fHistCosp[0]->Draw(); fHistCosp[2]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistCosp[4]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistCosp[6]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistCosp[8]->Draw("sames"); leg4->Draw(); ccc->cd(3); hEffPt[0]->GetYaxis()->SetTitleOffset(1.45); hEffPt[0]->Draw(); hEffPt[2]->Draw("sames"); if (drawOnlyDzerDplus == 0) hEffPt[4]->Draw("sames"); if (drawOnlyDzerDplus == 0) hEffPt[6]->Draw("sames"); if (drawOnlyDzerDplus == 0) hEffPt[8]->Draw("sames"); leg3->Draw(); ccc->cd(4); fHistDecLen[1]->GetYaxis()->SetTitleOffset(1.45); fHistDecLen[1]->Draw(); fHistDecLen[3]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistDecLen[5]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistDecLen[7]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistDecLen[9]->Draw("sames"); leg3->Draw(); ccc->cd(5); fHistCosp[1]->GetYaxis()->SetTitleOffset(1.45); fHistCosp[1]->Draw(); fHistCosp[3]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistCosp[5]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistCosp[7]->Draw("sames"); if (drawOnlyDzerDplus == 0) fHistCosp[9]->Draw("sames"); leg4->Draw(); ccc->cd(6); hEffPt[1]->GetYaxis()->SetTitleOffset(1.45); hEffPt[1]->Draw(); hEffPt[3]->Draw("sames"); if (drawOnlyDzerDplus == 0) hEffPt[5]->Draw("sames"); if (drawOnlyDzerDplus == 0) hEffPt[7]->Draw("sames"); if (drawOnlyDzerDplus == 0) hEffPt[9]->Draw("sames"); leg3->Draw(); ccc->SaveAs("plot_DL_cosp_Eff_prompt_fd.png"); } } trtree->Fill(); if(runNumber>0){ TFile* foutfile=new TFile("trendingHF.root","recreate"); trtree->Write(); TDirectory* outdir=foutfile->mkdir(dirD2H->GetName()); outdir->cd(); listD2H->Write(listD2H->GetName(),1); foutfile->cd(); if(dir && list){ TDirectory* outdir2=foutfile->mkdir(dir->GetName()); outdir2->cd(); list->Write(list->GetName(),1); } foutfile->Close(); delete foutfile; } }
Int_t IlcTARGETGeoPlot (Int_t evesel=0, char *opt="All+ClustersV2", char *filename="gilc.root", Int_t isfastpoints = 0) { /******************************************************************* * This macro displays geometrical information related to the * hits, digits and rec points (or V2 clusters) in TARGET. * There are histograms that are not displayed (i.e. energy * deposition) but that are saved onto a file (see below) * * INPUT arguments: * * Int_t evesel: the selected event number. It's =0 by default * * Options: Any combination of: * 1) subdetector name: "SPD", "SDD", "SSD", "All" (default) * 2) Printouts: "Verbose" Almost everything is printed out: * it is wise to redirect the output onto a file * e.g.: .x IlcTARGETGeoPlot.C("All+Verbose") > out.log * 3) Rec Points option: "Rec" ---> Uses Rec. Points (default) * * 4) ClustersV2 option: "ClustersV2" ---->Uses ClustersV2 * otherwise ---->uses hits and digits only * Examples: * .x IlcTARGETGeoPlot(); (All subdetectors; no-verbose; no-recpoints) * .x IlcTARGETGeoPlot("SPD+SSD+Verbose+Rec"); * * filename: It's "gilc.root" by default. * isfastpoints: integer. It is set to 0 by defaults. This means that * slow reconstruction is assumed. If fast recpoint are in * in use, isfastpoints must be set =1. * * OUTPUT: It produces a root file with a list of histograms * * WARNING: spatial information for SSD/DIGTARGET is obtained by pairing * digits on p and n side originating from the same track, when * possible. This (mis)use of DIGTARGET is tolerated for debugging * purposes only !!!! The pairing in real life should be done * starting from info really available... * * COMPILATION: this macro can be compiled. * 1) You need to set your include path with * gSystem->SetIncludePath("-I- -I$ILC_ROOT/include -I$ILC_ROOT/TARGET -g"); * 3) If you are using root instead of ilcroot you need to * execute the macro loadlibs.C in advance * 4) To compile this macro from root (or ilcroot): * --- .L IlcTARGETGeoPlot.C++ * --- IlcTARGETGeoPlot(); * * M.Masera 14/05/2001 18:30 * Last rev. 31/05/2004 14:00 (Clusters V2 added) E.C. ********************************************************************/ //Options TString choice(opt); Bool_t All = choice.Contains("All"); Bool_t verbose=choice.Contains("Verbose"); Bool_t userec=choice.Contains("Rec"); Bool_t useclustersv2=choice.Contains("ClustersV2"); Int_t retcode=1; //return code if (gClassTable->GetID("IlcRun") < 0) { gInterpreter->ExecuteMacro("loadlibs.C"); } else { if(gIlc){ delete gIlc->GetRunLoader(); delete gIlc; gIlc=0; } } IlcRunLoader* rl = IlcRunLoader::Open(filename); if (rl == 0x0){ cerr<<"IlcTARGETGeoPlot.C : Can not open session RL=NULL"<< endl; return -1; } Int_t retval = rl->LoadgIlc(); if (retval){ cerr<<"IlcTARGETGeoPlot.C : LoadgIlc returned error"<<endl; return -1; } gIlc=rl->GetIlcRun(); retval = rl->LoadHeader(); if (retval){ cerr<<"IlcTARGETGeoPlot.C : LoadHeader returned error"<<endl; return -1; } IlcTARGETLoader* TARGETloader = (IlcTARGETLoader*) rl->GetLoader("TARGETLoader"); if(!TARGETloader){ cerr<<"IlcTARGETGeoPlot.C : TARGET loader not found"<<endl; return -1; } TARGETloader->LoadHits("read"); TARGETloader->LoadDigits("read"); if(isfastpoints==1)TARGETloader->SetRecPointsFileName("TARGET.FastRecPoints.root"); TARGETloader->LoadRecPoints("read"); rl->GetEvent(evesel); Int_t nparticles = rl->GetHeader()->GetNtrack(); IlcTARGET *TARGET = (IlcTARGET*)gIlc->GetModule("TARGET"); TARGET->SetTreeAddress(); if(verbose) { cout<<" "<<endl<<" "<<endl; cout<<"******* Event processing started *******"<<endl; cout<<"In the following, hits with 'StatusEntering' flag active"<<endl; cout<<"will not be processed"<<endl; cout << "Number of particles= " << nparticles <<endl; } // HTARGET TTree *TH = TARGETloader->TreeH(); Stat_t ntracks = TH->GetEntries(); if(verbose)cout<<"Number of primary tracks= "<<ntracks<<endl; // TARGET Int_t nmodules; TARGET->InitModules(-1,nmodules); cout<<"Number of TARGET modules= "<<nmodules<<endl; cout<<"Filling modules... It takes a while, now. Please be patient"<<endl; TARGET->FillModules(0,0,nmodules," "," "); cout<<"TARGET modules .... DONE!"<<endl; IlcTARGETDetTypeRec* detTypeRec = new IlcTARGETDetTypeRec(TARGETloader); detTypeRec->SetDefaults(); // DIGTARGET TTree *TD = TARGETloader->TreeD(); //RECPOINTS (V2 clusters) TTree *TR = TARGETloader->TreeR(); TClonesArray *TARGETrec = detTypeRec->RecPoints(); TBranch *branch = 0; if(userec && TR && TARGETrec){ if(isfastpoints==1){ branch = TARGETloader->TreeR()->GetBranch("TARGETRecPointsF"); cout<<"using fast points\n"; } else { branch = TARGETloader->TreeR()->GetBranch("TARGETRecPoints"); } if(branch)branch->SetAddress(&TARGETrec); } if(userec && (!TR || !TARGETrec || !branch)){ userec = kFALSE; cout<<"\n ======================================================= \n"; cout<<"WARNING: there are no RECPOINTS on this file ! \n"; cout<<"======================================================= \n \n"; } if(useclustersv2 && TR && TARGETrec){ branch = TARGETloader->TreeR()->GetBranch("TARGETRecPoints"); if(branch)branch->SetAddress(&TARGETrec); } if(useclustersv2 && (!TR || !TARGETrec || !branch)){ useclustersv2 = kFALSE; cout<<"\n ======================================================= \n"; cout<<"WARNING: there are no CLUSTERSV2 on this file ! \n"; cout<<"======================================================= \n \n"; } //local variables Int_t mod; //module number Int_t nbytes = 0; Double_t pos[3]; // Global position of the current module Float_t ragdet; // Radius of detector (x y plane) Int_t first; // first module Int_t last; // last module Int_t nrecp; //number of RecPoints for a given module //List of histograms TObjArray histos(26,0); // contains the pointers to the histograms // Book histograms SPD TH2F *rspd = new TH2F("rspd","Radii of digits - SPD",50,-10.,10.,50,-10.,10.); TH2F *rhspd = new TH2F("rhspd","Radii of hits - SPD",50,-10.,10.,50,-10.,10.); TH2F *rmspd = new TH2F("rmspd","Radii of SPD modules",50,-10.,10.,50,-10.,10.); TH1F *zspd = new TH1F("zspd","Z of digits - SPD",100,-30.,30.); TH1F *zhspd = new TH1F("zhspd","Z of hits - SPD",100,-30.,30.); TH1F *zmspd = new TH1F("zmspd","Z of SPD modules",100,-30,30.); Char_t title1[50]=""; Char_t title2[50]=""; if(userec){ sprintf(title1,"Radii of recpoints - %s","SPD"); sprintf(title2,"Z of recpoints - %s","SPD"); } if(useclustersv2){ sprintf(title1,"Radii of clustersV2 - %s","SPD"); sprintf(title2,"Z of clustersV2 - %s","SPD"); } TH2F *rrspd = new TH2F("rrspd",title1,50,-10.,10.,50,-10.,10.); TH1F *zrspd = new TH1F("zrspd",title2,100,-30.,30.); TH1F *enespd = new TH1F("enespd","Energy deposition SPD (KeV)",100,0.,1000.); histos.AddLast(rspd); // 0 histos.AddLast(rhspd); // 1 histos.AddLast(rmspd); // 2 histos.AddLast(zspd); // 3 histos.AddLast(zhspd); // 4 histos.AddLast(zmspd); // 5 histos.AddLast(rrspd); // 6 histos.AddLast(zrspd); // 7 histos.AddLast(enespd); // 8 // Book histograms SDD TH2F *rsdd = new TH2F("rsdd","Radii of digits - SDD",50,-40.,40.,50,-40.,40.); TH2F *rhsdd = new TH2F("rhsdd","Radii of hits - SDD",50,-40.,40.,50,-40.,40.); TH2F *rmsdd = new TH2F("rmsdd","Radii of SDD modules",50,-40.,40.,50,-40.,40.); TH1F *zsdd = new TH1F("zsdd","Z of digits - SDD",100,-40.,40.); TH1F *zhsdd = new TH1F("zhsdd","Z of hits - SDD",100,-40.,40.); TH1F *zmsdd = new TH1F("zmsdd","Z of SDD modules",100,-40,40.); Char_t title3[50]; Char_t title4[50]; if(userec){ sprintf(title3,"Radii of recpoints - %s","SDD"); sprintf(title4,"Z of recpoints - %s","SDD"); } if(useclustersv2){ sprintf(title3,"Radii of clustersV2 - %s","SDD"); sprintf(title4,"Z of clustersV2 - %s","SDD"); } TH2F *rrsdd = new TH2F("rrsdd",title3,50,-40.,40.,50,-40.,40.); TH1F *zrsdd = new TH1F("zrsdd",title4,100,-40.,40.); TH1F *enesdd = new TH1F("enesdd","Energy deposition SDD (KeV)",100,0.,1000.); histos.AddLast(rsdd); // 9 histos.AddLast(rhsdd); // 10 histos.AddLast(rmsdd); // 11 histos.AddLast(zsdd); // 12 histos.AddLast(zhsdd); // 13 histos.AddLast(zmsdd); // 14 histos.AddLast(rrsdd); // 15 histos.AddLast(zrsdd); // 16 histos.AddLast(enesdd); // 17 // Book histogram SSD TH2F *rssd = new TH2F("rssd","Radii of digits - SSD",50,-50.,50.,50,-50.,50.); TH2F *rhssd = new TH2F("rhssd","Radii of hits - SSD",50,-50.,50.,50,-50.,50.); TH2F *rmssd = new TH2F("rmssd","Radii of SSD modules",50,-50.,50.,50,-50.,50.); TH1F *zssd = new TH1F("zssd","Z of digits - SSD",100,-70.,70.); TH1F *zhssd = new TH1F("zhssd","Z of hits - SSD",100,-70.,70.); TH1F *zmssd = new TH1F("zmssd","Z of SSD modules",100,-70,70.); Char_t title5[50]; Char_t title6[50]; if(userec){ sprintf(title5,"Radii of recpoints - %s","SSD"); sprintf(title6,"Z of recpoints - %s","SSD"); } if(useclustersv2){ sprintf(title5,"Radii of clustersV2 - %s","SSD"); sprintf(title6,"Z of clustersV2 - %s","SSD"); } TH2F *rrssd = new TH2F("rrssd",title5,50,-50.,50.,50,-50.,50.); TH1F *zrssd = new TH1F("zrssd",title6,100,-70.,70.); TH1F *enessd = new TH1F("enessd","Energy deposition SSD (KeV)",100,0.,1000.); histos.AddLast(rssd); // 18 histos.AddLast(rhssd); // 19 histos.AddLast(rmssd); // 20 histos.AddLast(zssd); // 21 histos.AddLast(zhssd); // 22 histos.AddLast(zmssd); // 23 histos.AddLast(rrssd); // 24 histos.AddLast(zrssd); // 25 histos.AddLast(enessd); // 26 // // Loop on subdetectors // IlcTARGETgeom *geom = TARGET->GetTARGETgeom(); TString detna; // subdetector name for(Int_t subd=0;subd<3;subd++){ if(All || (choice.Contains("SPD") && subd==0) || (choice.Contains("SDD") && subd==1) || (choice.Contains("SSD") && subd==2)){ // Prepare array for the digits TClonesArray *TARGETdigits = TARGET->DigitsAddress(subd); Bool_t usedigits = kTRUE; if(!TARGETdigits){ usedigits = kFALSE; cout<<"\n ======================================================= \n"; cout<<"WARNING: there are no DIGTARGET on this file ! \n"; cout<<"======================================================= \n \n"; } // Get segmentation model if(subd==0)detna="SPD"; if(subd==1)detna="SDD"; if(subd==2)detna="SSD"; IlcTARGETsegmentation *seg=(IlcTARGETsegmentation*)detTypeRec->GetSegmentationModel(subd); // Loop on modules first = geom->GetStartDet(subd); last = geom->GetLastDet(subd); if(verbose){ cout<<" "<<endl<<"-------------------------------------"<<endl; cout<<"Start processing subdetector "<<detna<<endl; cout<<detna<<" first module "<<first<<endl; cout<<detna<<" last module "<<last<<endl; cout<<" "<<endl<<" "<<endl; } for (mod=first; mod<=last; mod++){ geom->GetTrans(mod,pos); // position of the module in the MRS ragdet=sqrt(pos[0]*pos[0]+pos[1]*pos[1]); // The following 2 histos are a check of the geometry TH2F *bidi = (TH2F*)histos.At(2+subd*9); TH1F *uni = (TH1F*)histos.At(5+subd*9); bidi->Fill(pos[0],pos[1]); uni->Fill(pos[2]); if(verbose){ cout<<"=========================================================\n"; cout<<detna<<" module="<<mod<<endl; cout<<"Mod. coordinates: "<<pos[0]<<", "<<pos[1]<<", "; cout<<pos[2]<<" Radius "<<ragdet<<endl; } // Hits GetHitsCoor(TARGET,mod,histos,subd,verbose); //RecPoints if(userec){ detTypeRec->ResetRecPoints(); branch->GetEvent(mod); TH2F *bidi=(TH2F*)histos.At(6+subd*9); TH1F *uni=(TH1F*)histos.At(7+subd*9); nrecp=GetRecCoor(geom,TARGETrec,mod,bidi,uni,verbose); } if(useclustersv2){ detTypeRec->ResetRecPoints(); branch->GetEvent(mod); TH2F *bidi=(TH2F*)histos.At(6+subd*9); TH1F *uni=(TH1F*)histos.At(7+subd*9); nrecp=GetClusCoor(geom,TARGETrec,mod,bidi,uni,verbose); } // Digits if(usedigits){ detTypeRec->ResetDigits(); nbytes += TD->GetEvent(mod); GetDigits(seg,geom,TARGETdigits,subd,mod,verbose,histos); } } // End of loop on the modules TH1F *h1tmp; TH2F *h2tmp; // Plot the histograms TCanvas *current=0; // current Canvas (1--> SPD, 2---> SDD, 3---> SSD) if(subd==0){ // Prepare canvas 1 TCanvas *c1 = new TCanvas("c1","SPD",10,10,600,900); c1->Divide(2,3); current=c1; } if(subd==1){ // Prepare canvas 2 TCanvas *c2 = new TCanvas("c2","SDD",40,40,600,900); c2->Divide(2,3); current=c2; } if(subd==2){ // Prepare canvas 3 TCanvas *c3 = new TCanvas("c3","SSD",70,70,600,900); c3->Divide(2,3); current=c3; } current->cd(1); h2tmp = (TH2F*)histos.At(9*subd); h2tmp->Draw(); current->cd(2); h1tmp=(TH1F*)histos.At(3+subd*9); h1tmp->Draw(); current->cd(3); h2tmp=(TH2F*)histos.At(1+9*subd); h2tmp->Draw(); current->cd(4); h1tmp=(TH1F*)histos.At(4+subd*9); h1tmp->Draw(); if(userec || useclustersv2){ current->cd(5); h2tmp=(TH2F*)histos.At(6+9*subd); h2tmp->Draw(); current->cd(6); h1tmp=(TH1F*)histos.At(7+subd*9); h1tmp->Draw(); } else { current->cd(5); h2tmp=(TH2F*)histos.At(2+9*subd); h2tmp->Draw(); current->cd(6); h2tmp=(TH2F*)histos.At(5+9*subd); h2tmp->Draw(); } } // if(All..... } // end of loop on subdetectors // Save the histograms TFile *fh = new TFile("IlcTARGETGeoPlot.root","recreate"); // The list is written to file as a single entry TList *lihi = new TList(); // copy the pointers to the histograms to a TList object. // The histograms concerning recpoints are not copied if // 'userec' is false. for(Int_t i=0;i<histos.GetEntriesFast();i++){ if(choice.Contains("All") || (choice.Contains("SPD") && i<8) || (choice.Contains("SDD") && i>7 && i<16) || (choice.Contains("SSD") && i>15)){ if(!(!userec && ((i+2)%9==0 || (i+1)%9==0)))lihi->Add(histos.At(i)); } } lihi->Write("Histograms TARGET hits+digits+recpoints",TObject::kSingleKey); fh->Close(); return retcode; }
int main(int argc, char* argv[]) { TApplication theApp(srcName.Data(), &argc, argv); //============================================================================= if (argc<5) return -1; TString sPath = argv[1]; if (sPath.IsNull()) return -1; TString sFile = argv[2]; if (sFile.IsNull()) return -1; TString sJetR = argv[3]; if (sJetR.IsNull()) return -1; TString sSjeR = argv[4]; if (sSjeR.IsNull()) return -1; //============================================================================= sPath.ReplaceAll("#", "/"); //============================================================================= double dJetR = -1.; if (sJetR=="JetR02") dJetR = 0.2; if (sJetR=="JetR03") dJetR = 0.3; if (sJetR=="JetR04") dJetR = 0.4; if (sJetR=="JetR05") dJetR = 0.5; if (dJetR<0.) return -1; cout << "Jet R = " << dJetR << endl; //============================================================================= double dSjeR = -1.; if (sSjeR=="SjeR01") dSjeR = 0.1; if (sSjeR=="SjeR02") dSjeR = 0.2; if (sSjeR=="SjeR03") dSjeR = 0.3; if (sSjeR=="SjeR04") dSjeR = 0.4; if (dSjeR<0.) return -1; cout << "Sub-jet R = " << dSjeR << endl; //============================================================================= const double dJetsPtMin = 0.1; const double dJetEtaMax = 2.; const double dCutEtaMax = 2.6; fastjet::GhostedAreaSpec areaSpc(dCutEtaMax); fastjet::JetDefinition jetsDef(fastjet::antikt_algorithm, dJetR, fastjet::BIpt_scheme, fastjet::Best); fastjet::AreaDefinition areaDef(fastjet::active_area_explicit_ghosts,areaSpc); fastjet::Selector selectJet = fastjet::SelectorAbsEtaMax(dJetEtaMax); fastjet::JetDefinition subjDef(fastjet::kt_algorithm, dSjeR, fastjet::BIpt_scheme, fastjet::Best); //============================================================================= std::vector<fastjet::PseudoJet> fjInput; //============================================================================= TFile *file = TFile::Open(Form("%s.root",sFile.Data()), "NEW"); TList *list = new TList(); TH1D *hWeightSum = new TH1D("hWeightSum", "", 1, 0., 1.); list->Add(hWeightSum); TH2D *hTrkPtEta = new TH2D("hTrkPtEta", "", 1000, 0., 500., 60, -3., 3.); hTrkPtEta->Sumw2(); list->Add(hTrkPtEta); TH2D *hTrkPtPhi = new TH2D("hTrkPtPhi", "", 1000, 0., 500., 20, -1., 1.); hTrkPtPhi->Sumw2(); list->Add(hTrkPtPhi); TH2D *hJetPtNsj = new TH2D("hJetPtNsj", "", 1000, 0., 1000., 100, -0.5, 99.5); hJetPtNsj->Sumw2(); list->Add(hJetPtNsj); TH2D *hJetPtEta = new TH2D("hJetPtEta", "", 1000, 0., 1000., 60, -3., 3.); hJetPtEta->Sumw2(); list->Add(hJetPtEta); TH2D *hJetPtPhi = new TH2D("hJetPtPhi", "", 1000, 0., 1000., 20, -1., 1.); hJetPtPhi->Sumw2(); list->Add(hJetPtPhi); TH2D *hLjePtEta = new TH2D("hLjePtEta", "", 1000, 0., 1000., 60, -3., 3.); hLjePtEta->Sumw2(); list->Add(hLjePtEta); TH2D *hLjePtPhi = new TH2D("hLjePtPhi", "", 1000, 0., 1000., 20, -1., 1.); hLjePtPhi->Sumw2(); list->Add(hLjePtPhi); TH2D *hNjePtEta = new TH2D("hNjePtEta", "", 1000, 0., 1000., 60, -3., 3.); hNjePtEta->Sumw2(); list->Add(hNjePtEta); TH2D *hNjePtPhi = new TH2D("hNjePtPhi", "", 1000, 0., 1000., 20, -1., 1.); hNjePtPhi->Sumw2(); list->Add(hNjePtPhi); TH2D *hJe2PtEta = new TH2D("hJe2PtEta", "", 1000, 0., 1000., 60, -3., 3.); hJe2PtEta->Sumw2(); list->Add(hJe2PtEta); TH2D *hJe2PtPhi = new TH2D("hJe2PtPhi", "", 1000, 0., 1000., 20, -1., 1.); hJe2PtPhi->Sumw2(); list->Add(hJe2PtPhi); TH2D *hLj2PtEta = new TH2D("hLj2PtEta", "", 1000, 0., 1000., 60, -3., 3.); hLj2PtEta->Sumw2(); list->Add(hLj2PtEta); TH2D *hLj2PtPhi = new TH2D("hLj2PtPhi", "", 1000, 0., 1000., 20, -1., 1.); hLj2PtPhi->Sumw2(); list->Add(hLj2PtPhi); TH2D *hNj2PtEta = new TH2D("hNj2PtEta", "", 1000, 0., 1000., 60, -3., 3.); hNj2PtEta->Sumw2(); list->Add(hNj2PtEta); TH2D *hNj2PtPhi = new TH2D("hNj2PtPhi", "", 1000, 0., 1000., 20, -1., 1.); hNj2PtPhi->Sumw2(); list->Add(hNj2PtPhi); //============================================================================= HepMC::IO_GenEvent ascii_in(Form("%s/%s.hepmc",sPath.Data(),sFile.Data()), std::ios::in); HepMC::GenEvent *evt = ascii_in.read_next_event(); while (evt) { fjInput.resize(0); double dWeight = evt->weights().back(); double dXsect = evt->cross_section()->cross_section() / 1e9; double dNorm = dWeight * dXsect; hWeightSum->Fill(0.5, dWeight); TVector3 vTrk; for (HepMC::GenEvent::particle_const_iterator p=evt->particles_begin(); p!=evt->particles_end(); ++p) if ((*p)->status()==1) { double dTrkPt = (*p)->momentum().perp(); if (dTrkPt<0.5) continue; double dTrkEta = (*p)->momentum().eta(); if (TMath::Abs(dTrkEta)>dCutEtaMax) continue; double dTrkPhi = (*p)->momentum().phi(); vTrk.SetPtEtaPhi(dTrkPt, dTrkEta, dTrkPhi); double dTrkCos = TMath::Cos(dTrkPhi); if (dTrkCos==1.) dTrkCos = 1. - 1e-6; fjInput.push_back(fastjet::PseudoJet(vTrk.Px(), vTrk.Py(), vTrk.Pz(), vTrk.Mag())); hTrkPtEta->Fill(dTrkPt, dTrkEta, dNorm); hTrkPtPhi->Fill(dTrkPt, dTrkCos, dNorm); } //============================================================================= fastjet::ClusterSequenceArea clustSeq(fjInput, jetsDef, areaDef); std::vector<fastjet::PseudoJet> includJets = clustSeq.inclusive_jets(dJetsPtMin); std::vector<fastjet::PseudoJet> selectJets = selectJet(includJets); std::vector<fastjet::PseudoJet> sortedJets = fastjet::sorted_by_pt(selectJets); //============================================================================= for (int j=0; j<sortedJets.size(); j++) { double dJetPt = sortedJets[j].pt(); double dJetEta = sortedJets[j].eta(); double dJetPhi = sortedJets[j].phi(); double dJetCos = TMath::Cos(dJetPhi); if (dJetCos==1.) dJetCos = 1. - 1e-6; fastjet::Filter trimmer(subjDef, fastjet::SelectorPtFractionMin(0.)); fastjet::PseudoJet trimmdJet = trimmer(sortedJets[j]); std::vector<fastjet::PseudoJet> trimmdSj = trimmdJet.pieces(); int nSje = 0; for (int i=0; i<trimmdSj.size(); i++) if (trimmdSj[i].pt()>0.1) { nSje += 1; } hJetPtNsj->Fill(dJetPt, nSje, dNorm); hJetPtEta->Fill(dJetPt, dJetEta, dNorm); hJetPtPhi->Fill(dJetPt, dJetCos, dNorm); if (j==0) { hLjePtEta->Fill(dJetPt, dJetEta, dNorm); hLjePtPhi->Fill(dJetPt, dJetCos, dNorm); } if (j==1) { hNjePtEta->Fill(dJetPt, dJetEta, dNorm); hNjePtPhi->Fill(dJetPt, dJetCos, dNorm); } if (nSje>=2) { hJe2PtEta->Fill(dJetPt, dJetEta, dNorm); hJe2PtPhi->Fill(dJetPt, dJetCos, dNorm); if (j==0) { hLj2PtEta->Fill(dJetPt, dJetEta, dNorm); hLj2PtPhi->Fill(dJetPt, dJetCos, dNorm); } if (j==1) { hNj2PtEta->Fill(dJetPt, dJetEta, dNorm); hNj2PtPhi->Fill(dJetPt, dJetCos, dNorm); } } } //============================================================================= delete evt; ascii_in >> evt; } //============================================================================= file->cd(); list->Write(); file->Close(); //============================================================================= cout << "DONE" << endl; //============================================================================= return 0; }
// ______________________________________________________________________________________ void plotEnergyKaon(const Char_t* name = "ratioNetKaonVsEnergy") { Int_t idxNames = kNetK; gROOT->LoadMacro("include/toolsEnergyNice.C++"); gROOT->LoadMacro("include/getPublished.C++"); SetupStyle(); SetGlobals(); getPublished(); // ----------------------------------------------------- TFile *inFiles[nEnergies][nMoments]; TFile *inFilesUrqmd[nEnergies]; TGraphErrors *inGraphsStat[nEnergies][nMoments+1]; TGraphErrors *inGraphsPoisson[nEnergies][nMoments]; TGraphErrors *inGraphsUrqmd[nEnergies][nMoments]; for (int idxEnergy = 0; idxEnergy < nEnergies; ++idxEnergy) { if (idxEnergy != 2) inFilesUrqmd[idxEnergy]= TFile::Open(Form("URQMD/urqmd_kaon/AuAu%sGeV_Vz30_kpi1.root", exactEnergies[idxEnergy])); for (int idxMoment = 0; idxMoment < nMoments; ++idxMoment) { // -- value and stat errors inFiles[idxEnergy][idxMoment] = TFile::Open(Form("%s/%sGeV/moments_ana/Moments_%s.root", aNames[idxNames], exactEnergies[idxEnergy], aMoments[idxMoment])); inGraphsStat[idxEnergy][idxMoment] = (idxMoment != 5) ? static_cast<TGraphErrors*>((inFiles[idxEnergy][idxMoment]->Get(aMoments[idxMoment]))->Clone()) : static_cast<TGraphErrors*>((inFiles[idxEnergy][idxMoment]->Get(Form("%s_Poisson_ratio", aMoments[idxMoment])))->Clone()); if (idxMoment == 5) // get SK also inGraphsStat[idxEnergy][nMoments] = static_cast<TGraphErrors*>((inFiles[idxEnergy][idxMoment]->Get(aMoments[idxMoment]))->Clone()); // -- poisson inGraphsPoisson[idxEnergy][idxMoment] = static_cast<TGraphErrors*>((inFiles[idxEnergy][idxMoment]->Get(Form("%s_Poisson_base", aMoments[idxMoment])))->Clone()); if (inFiles[idxEnergy][idxMoment]) inFiles[idxEnergy][idxMoment]->Close(); // -- urqmd if (idxEnergy != 2) { if (idxMoment == 4) inGraphsUrqmd[idxEnergy][idxMoment] = static_cast<TGraphErrors*>((inFilesUrqmd[idxEnergy]->Get(Form("R21")))->Clone()); else if (idxMoment == 5) inGraphsUrqmd[idxEnergy][idxMoment] = static_cast<TGraphErrors*>((inFilesUrqmd[idxEnergy]->Get(Form("%s_Pos_ratio", aMoments[idxMoment])))->Clone()); else if (idxMoment == 6) inGraphsUrqmd[idxEnergy][idxMoment] = static_cast<TGraphErrors*>((inFilesUrqmd[idxEnergy]->Get(aMoments[idxMoment]))->Clone()); } } } // ----------------------------------------------------- // -- Make graphs for (int idxEnergy = 0; idxEnergy < nEnergies; ++idxEnergy) { for (int idxMoment = 4; idxMoment < nMoments+1; ++idxMoment) { for (int idxCent = 0; idxCent < nCent; ++idxCent) { if (idxCent != 0 && idxCent != 8) continue; Double_t xIn, yIn; inGraphsStat[idxEnergy][idxMoment]->GetPoint(idxCent, xIn, yIn); Double_t yErrorStatIn = inGraphsStat[idxEnergy][idxMoment]->GetErrorY(idxCent); Int_t accessCent = (idxCent == 0) ? 0 : 1; Int_t accessMoment = idxMoment - 4; Double_t yErrorSysIn = sysErrors[accessMoment][accessCent][idxEnergy]; for (Int_t idx = 0; idx < 2; ++idx) { Double_t xBin = (idx == 0) ? snn[idxEnergy] : mub[idxEnergy]; graphStat[idx][idxMoment][idxCent]->SetPoint(idxEnergy, xBin, yIn); graphStat[idx][idxMoment][idxCent]->SetPointError(idxEnergy, 0, yErrorStatIn); graphSys[idx][idxMoment][idxCent]->SetPoint(idxEnergy, xBin, yIn); graphSys[idx][idxMoment][idxCent]->SetPointError(idxEnergy, 0, yErrorSysIn); } if (idxMoment == nMoments) continue; inGraphsPoisson[idxEnergy][idxMoment]->GetPoint(idxCent, xIn, yIn); for (Int_t idx = 0; idx < 2; ++idx) { Double_t xBin = (idx == 0) ? snn[idxEnergy] : mub[idxEnergy]; graphPoisson[idx][idxMoment][idxCent]->SetPoint(idxEnergy, xBin, yIn); } if (idxCent == 0 && idxEnergy != 2) { Double_t yErrorUrqmdIn = inGraphsUrqmd[idxEnergy][idxMoment]->GetErrorY(idxCent); inGraphsUrqmd[idxEnergy][idxMoment]->GetPoint(idxCent, xIn, yIn); for (Int_t idx = 0; idx < 2; ++idx) { Double_t xBin = (idx == 0) ? snn[idxEnergy] : mub[idxEnergy]; Int_t energyArrayAccess = (idxEnergy >= 2) ? idxEnergy-1 : idxEnergy; graphUrqmd[idx][idxMoment][idxCent]->SetPoint(energyArrayAccess, xBin, yIn); graphUrqmd[idx][idxMoment][idxCent]->SetPointError(energyArrayAccess, 0, yErrorUrqmdIn); } } } // for (int idxCent = 0; idxCent < nCent; ++idxCent) { } // for (int idxMoment = 0 ; idxMoment < nMoments; ++idxMoment) { } // for (int idxEnergy = 0 ; idxEnergy < nEnergies; ++idxEnergy) { // ----------------------------------------------------- SetupCanvas(name, Form("%s Ratio energy dependence", aNames[idxNames])); CreateLegends(2, 3, 0.4, 0.09); // ----------------------------------------------------- for (int idxMoment = 4; idxMoment < nMoments; ++idxMoment) { pad->cd(idxMoment-3); gPad->SetLogx(); for (int idxCent = 0; idxCent < nCent; ++idxCent) { if (idxCent != 0 && idxCent != 8) continue; DrawSet(graphStat[0][idxMoment][idxCent], graphSys[0][idxMoment][idxCent], graphUrqmd[0][idxMoment][idxCent], graphPoisson[0][idxMoment][idxCent], idxMoment, idxCent); } // for (int idxCent = 0; idxCent < nCent; ++idxCent) { graphStat[0][idxMoment][0]->Draw("ZP,SAME"); graphSys[0][idxMoment][0]->Draw("[],SAME"); } // for (int idxMoment = 4; idxMoment < nMoments; ++idxMoment) { legTheo->AddEntry(graphUrqmd[0][4][0], Form("%s UrQMD", cent1[0]), "f"); // ----------------------------------------------------- LabelCanvas(aNames[idxNames], aNamesPt[idxNames]); SaveCanvas(name); // ----------------------------------------------------- TFile *fOut = TFile::Open("STAR_QM2015_Preliminary.root", "UPDATE"); fOut->cd(); TList* list = new TList; for (int idxMoment = 4; idxMoment < nMoments+1; ++idxMoment) { for (int idxCent = 0; idxCent < nCent; ++idxCent) { if (idxCent != 0) continue; graphStat[0][idxMoment][idxCent]->SetName(Form("%s_%s_sNN_%s_stat", aNames[idxNames], aMoments2[idxMoment], cent[idxCent])); graphSys[0][idxMoment][idxCent]->SetName(Form("%s_%s_sNN_%s_sys", aNames[idxNames], aMoments2[idxMoment], cent[idxCent])); list->Add(graphStat[0][idxMoment][idxCent]); list->Add(graphSys[0][idxMoment][idxCent]); } } list->Write(aNames[idxNames], TObject::kSingleKey); fOut->Close(); // ----------------------------------------------------- TFile *fOutAll = TFile::Open("STAR_Preliminary.root", "UPDATE"); fOutAll->cd(); TList* listAll = new TList; for (int idxMoment = 4; idxMoment < nMoments+1; ++idxMoment) { for (int idxCent = 0; idxCent < nCent; ++idxCent) { if (graphStat[0][idxMoment][idxCent] && graphStat[0][idxMoment][idxCent]->GetN() > 0) { graphStat[0][idxMoment][idxCent]->SetName(Form("%s_%s_sNN_%s_stat", aNames[idxNames], aMoments2[idxMoment], cent[idxCent])); listAll->Add(graphStat[0][idxMoment][idxCent]); } if (graphSys[0][idxMoment][idxCent] && graphSys[0][idxMoment][idxCent]->GetN() > 0) { graphSys[0][idxMoment][idxCent]->SetName(Form("%s_%s_sNN_%s_sys", aNames[idxNames], aMoments2[idxMoment], cent[idxCent])); listAll->Add(graphSys[0][idxMoment][idxCent]); } if (idxMoment == nMoments) continue; if (graphUrqmd[0][idxMoment][idxCent] && graphUrqmd[0][idxMoment][idxCent]->GetN() > 0) { graphUrqmd[0][idxMoment][idxCent]->SetName(Form("%s_%s_sNN_%s_urqmd", aNames[idxNames], aMoments2[idxMoment], cent[idxCent])); listAll->Add(graphUrqmd[0][idxMoment][idxCent]); } if (graphPoisson[0][idxMoment][idxCent] && graphPoisson[0][idxMoment][idxCent]->GetN() > 0) { graphPoisson[0][idxMoment][idxCent]->SetName(Form("%s_%s_sNN_%s_poisson", aNames[idxNames], aMoments2[idxMoment], cent[idxCent])); listAll->Add(graphPoisson[0][idxMoment][idxCent]); } } } listAll->Write(aNames[idxNames], TObject::kSingleKey); fOutAll->Close(); }
void generalpTT::DoAnalysis(const TString filelist, const Int_t ntarget, const TString tag) { TString GEN = TString(""); TString gTrack = TString(""); if(filelist.Contains("neut",TString::kIgnoreCase)){ GEN.Append("NEUT"); gTrack.Append("nRooTracker"); } else if(filelist.Contains("genie",TString::kIgnoreCase)){ GEN.Append("GENIE"); gTrack.Append("gRooTracker"); } else if(filelist.Contains("nuwro",TString::kIgnoreCase)){ GEN.Append("NUWRO"); gTrack.Append("nRooTracker"); } else if(filelist.Contains("gibuu",TString::kIgnoreCase)){ GEN.Append("GIBUU"); gTrack.Append("giRooTracker"); } else{ printf("generalpTT::ERROR : Cannot determine generator, please check.\n"); exit(1); } if(filelist.Contains("ccqe", TString::kIgnoreCase)){ GEN.Append("CCQE"); printf("NOTE: File is determined to contain CCQE interactions only.\n"); } const TString gen = (const TString)GEN; gRooTrackerUtils::Ini(); Init(gRooTrackerUtils::IniIO(filelist,gTrack)); TList *lout = gRooTrackerUtils::GetHistList(); TTree *tout = gRooTrackerUtils::GetTree(); const Int_t nentries = fChain->GetEntries(); Int_t nsel = 0; printf("********************************\n"); printf("Analysing in %s mode\n", gen.Data()); printf("********************************\n"); #ifdef Verbosity std::cout << "WARNING RUNNING IN VERBOSE MODE" << std::endl; #endif Int_t ndpp = 0; double pmomcons = 0.; Int_t ncons = 0; for (Int_t jentry = 0; jentry<nentries; jentry++) { if(jentry%10000==0) printf("%d/%d nsel %d\n", jentry, nentries, nsel); if(!fChain->GetEntry(jentry)){ printf("DoAnalysis GetEntry ends at jentry %d\n", jentry); break; } #ifdef Verbosity std:cout<<"Event "<<jentry+1; #endif /* if(fString){ if(fString.Atoi() == 11){ #ifdef Verbosity std::cout<<" Delta++"; #endif ndpp++; //continue; } }*/ #ifdef Verbosity std::cout<<" "<<std::endl; #endif gRooTrackerUtils::FillCount(lout,0); const Int_t nfound = gRooTrackerUtils::FindParticles(StdHepN, StdHepPdg, StdHepStatus, StdHepP4, StdHepP4, gen); gRooTrackerUtils::SetCount(nfound); gRooTrackerUtils::SetpTT(); gRooTrackerUtils::SetDeltapTT(); gRooTrackerUtils::SetSigneddpTT(); gRooTrackerUtils::SetdpT(); //gRooTrackerUtils::SetConsSum(); gRooTrackerUtils::SetAltdpTT(); gRooTrackerUtils::SetAbsdpTT(); if(gen.EqualTo("NEUT",TString::kIgnoreCase)){ gRooTrackerUtils::GetMomCons(); #ifdef Verbosity std::cout << "dp = "<< (*gRooTrackerUtils::fMomCons) << std::endl; #endif if((*gRooTrackerUtils::fMomCons) > 0.01){ #ifdef Verbosity std::cout<<"*** Mom. not conserved ***"<<std::endl; #endif ncons++; } pmomcons = ncons*100/ndpp; } gRooTrackerUtils::FillCount(lout,11); tout->Fill(); nsel++; if(ntarget>=0 && nsel>=ntarget) break; } std::cout<<std::endl; std::cout<<"SELECTION SUMMARY"<<std::endl; std::cout<<"No. Delta++ Events (NeutMode==11): "<<ndpp<<std::endl; std::cout<<"Percentage of events where momentum is not conserved: "<< pmomcons << "%" <<std::endl; printf("generalpTT: nsel %d of ntarget %d for %d nentries\n", nsel, ntarget, nentries); Int_t nevents; if(nsel < ntarget){ nevents = nsel; } else{ nevents = ntarget; } TFile *fout= new TFile(Form("%s_%d_DeltapTT.root",tag.Data(), nevents),"recreate"); tout->Write(); //for further handling in plot lout->Write("lout",TObject::kSingleKey); fout->Save(); fout->Close(); printf("FILE SAVED AS %s_%d_DeltapTT.root\n", tag.Data(), nevents); delete fout; delete lout; delete tout; }
int main(int argc, char* argv[]) { TApplication theApp(srcName.Data(), &argc, argv); //============================================================================= //TODO set paramters from arguments const Int_t nEvents = 1000; // # of events const Int_t dCentMin = 10.; // centrality min const Int_t dCentMax = 20.; // centrality max const Bool_t bUseBoltzmann = kTRUE; // sample track/cluster pT from Boltzmann const Double_t dTrkMeanPt = 0.7; // GeV/c, mean pT of tracks const Double_t dCluMeanPt = 0.7; // GeV/c, mean pT of clusters const TString sPath = "inputs"; // input data path //============================================================================= // jet finder, fastjet const double dJetsRange = 0.4; const double dJetsPtMin = 0.10; const double dPseuPtMin = 0.15; const double dCutEtaMax = 0.9; const double dJetEtaMax = 0.5; const double dJetAreaRef = TMath::Pi() * dJetsRange * dJetsRange; fastjet::GhostedAreaSpec areaSpc(dCutEtaMax); fastjet::JetDefinition jetsDef(fastjet::antikt_algorithm, dJetsRange, fastjet::BIpt_scheme, fastjet::Best); //fastjet::AreaDefinition areaDef(fastjet::active_area,areaSpc); fastjet::AreaDefinition areaDef(fastjet::active_area_explicit_ghosts,areaSpc); fastjet::JetDefinition bkgsDef(fastjet::kt_algorithm, 0.2, fastjet::BIpt_scheme, fastjet::Best); fastjet::AreaDefinition aBkgDef(fastjet::active_area_explicit_ghosts, areaSpc); fastjet::Selector selectJet = fastjet::SelectorAbsEtaMax(dJetEtaMax); fastjet::Selector selectRho = fastjet::SelectorAbsEtaMax(dCutEtaMax-0.2); fastjet::Selector selecHard = fastjet::SelectorNHardest(2); fastjet::Selector selectBkg = selectRho * (!(selecHard)); fastjet::JetMedianBackgroundEstimator bkgsEstimator(selectBkg, bkgsDef, aBkgDef); //============================================================================= // user defined outputs: histograms, THnSparse, ntuples... TFile *file = TFile::Open("AnalysisResults.root", "NEW"); TList *list = new TList(); TH1D *hCentrality = new TH1D("hCentrality", "", 100., 0., 100.); list->Add(hCentrality); TH1D *hTrkPt = new TH1D("hTrkPt", "", 200, 0., 100.); list->Add(hTrkPt); TH2D *hTrkEtaPhi = new TH2D("hTrkEtaPhi", "", 20, -1., 1., 100, 0., TMath::TwoPi()); list->Add(hTrkEtaPhi); TH1D *hCluPt = new TH1D("hCluPt", "", 200, 0., 100.); list->Add(hCluPt); TH2D *hCluEtaPhi = new TH2D("hCluEtaPhi", "", 20, -1., 1., 100, 0., TMath::TwoPi()); list->Add(hCluEtaPhi); //============================================================================= AliGenFastModelingEvent *gen = new AliGenFastModelingEvent("AliGenFastModelingEvents"); gen->SetCentralityRange(dCentMin, dCentMax); // set centrality range // get track/cluster multiplicity + the fluctuations from the given cent range in LHC11h data // get track/cluster pT, eta, phi distribution from the given cent range in LHC11h data /* optional: user defined track/cluster multiplicity ranges gen->SetMultiplicityUser(kTRUE); gen->SetTrackMultiplicityRangeUser(dUserTrkMultMin, dUserTrkMultMax); gen->SetClusterMultiplicityRangeUser(dUserCluMultMin, dUserCluMultMax); */ gen->SetUseBoltzmann(bUseBoltzmann); // sample track/cluster pT from bUseBoltzmann, otherwise it will be sampled from data gen->SetTrackMeanPt(dTrkMeanPt); // mean pT of tracks gen->SetClusterMeanPt(dCluMeanPt); // mean pT of clusters //============================================================================= if (gen->Init(sPath)) { cout << "Init failed!!!" << endl; return -1; } //============================================================================= for (Int_t iEvent=0; iEvent<nEvents; iEvent++) if (gen->InitEvent()) { hCentrality->Fill(gen->GetCentrality()); for (Int_t it=0; it<gen->GetTrackMultiplicity(); it++) { Double_t dPt=0., dEta=0., dPhi=0.; if (gen->GetTrackPtEtaPhi(dPt,dEta,dPhi)) continue; hTrkPt->Fill(dPt); hTrkEtaPhi->Fill(dEta, dPhi); } for (Int_t ic=0; ic<gen->GetClusterMultiplicity(); ic++) { Double_t dPt=0., dEta=0., dPhi=0.; if (gen->GetClusterPtEtaPhi(dPt,dEta,dPhi)) continue; hCluPt->Fill(dPt); hCluEtaPhi->Fill(dEta, dPhi); } } //============================================================================= file->cd(); list->Write(); file->Close(); //============================================================================= cout << "DONE" << endl; //============================================================================= return 0; }
void rezamyTMVAClassificationApplication1systematic( TString myMethodList = "" ) { #ifdef __CINT__ gROOT->ProcessLine( ".O0" ); // turn off optimization in CINT #endif //--------------------------------------------------------------- // This loads the library TMVA::Tools::Instance(); // Default MVA methods to be trained + tested std::map<std::string,int> Use; // --- Cut optimisation Use["Cuts"] = 0; Use["CutsD"] = 0; Use["CutsPCA"] = 0; Use["CutsGA"] = 0; Use["CutsSA"] = 0; // // --- 1-dimensional likelihood ("naive Bayes estimator") Use["Likelihood"] = 0; Use["LikelihoodD"] = 0; // the "D" extension indicates decorrelated input variables (see option strings) Use["LikelihoodPCA"] = 0; // the "PCA" extension indicates PCA-transformed input variables (see option strings) Use["LikelihoodKDE"] = 0; Use["LikelihoodMIX"] = 0; // // --- Mutidimensional likelihood and Nearest-Neighbour methods Use["PDERS"] = 0; Use["PDERSD"] = 0; Use["PDERSPCA"] = 0; Use["PDEFoam"] = 0; Use["PDEFoamBoost"] = 0; // uses generalised MVA method boosting Use["KNN"] = 0; // k-nearest neighbour method // // --- Linear Discriminant Analysis Use["LD"] = 0; // Linear Discriminant identical to Fisher Use["Fisher"] = 0; Use["FisherG"] = 0; Use["BoostedFisher"] = 0; // uses generalised MVA method boosting Use["HMatrix"] = 0; // // --- Function Discriminant analysis Use["FDA_GA"] = 0; // minimisation of user-defined function using Genetics Algorithm Use["FDA_SA"] = 0; Use["FDA_MC"] = 0; Use["FDA_MT"] = 0; Use["FDA_GAMT"] = 0; Use["FDA_MCMT"] = 0; // // --- Neural Networks (all are feed-forward Multilayer Perceptrons) Use["MLP"] = 0; // Recommended ANN Use["MLPBFGS"] = 0; // Recommended ANN with optional training method Use["MLPBNN"] = 0; // Recommended ANN with BFGS training method and bayesian regulator Use["CFMlpANN"] = 0; // Depreciated ANN from ALEPH Use["TMlpANN"] = 0; // ROOT's own ANN // // --- Support Vector Machine Use["SVM"] = 0; // // --- Boosted Decision Trees Use["BDT"] = 1; // uses Adaptive Boost Use["BDTG"] = 0; // uses Gradient Boost Use["BDTB"] = 0; // uses Bagging Use["BDTD"] = 0; // decorrelation + Adaptive Boost // // --- Friedman's RuleFit method, ie, an optimised series of cuts ("rules") Use["RuleFit"] = 0; // --------------------------------------------------------------- Use["Plugin"] = 0; Use["Category"] = 0; Use["SVM_Gauss"] = 0; Use["SVM_Poly"] = 0; Use["SVM_Lin"] = 0; std::cout << std::endl; std::cout << "==> Start TMVAClassificationApplication" << std::endl; // Select methods (don't look at this code - not of interest) if (myMethodList != "") { for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0; std::vector<TString> mlist = gTools().SplitString( myMethodList, ',' ); for (UInt_t i=0; i<mlist.size(); i++) { std::string regMethod(mlist[i]); if (Use.find(regMethod) == Use.end()) { std::cout << "Method \"" << regMethod << "\" not known in TMVA under this name. Choose among the following:" << std::endl; for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) { std::cout << it->first << " "; } std::cout << std::endl; return; } Use[regMethod] = 1; } } // -------------------------------------------------------------------------------------------------- // --- Create the Reader object TMVA::Reader *reader = new TMVA::Reader( "!Color:!Silent" ); Float_t ptphoton,etaphoton,ptmuon,etamuon,ptjet,etajet,masstop,mtw,deltaRphotonjet,deltaRphotonmuon,ht,costopphoton,deltaphiphotonmet,cvsdiscriminant; Float_t jetmultiplicity,bjetmultiplicity,leptoncharge; // Create a set of variables and declare them to the reader // - the variable names MUST corresponds in name and type to those given in the weight file(s) used reader->AddVariable ("ptphoton", &ptphoton); // reader->AddVariable ("etaphoton", &etaphoton); reader->AddVariable ("ptmuon", &ptmuon); // reader->AddVariable ("etamuon", &etamuon); reader->AddVariable ("ptjet", &ptjet); // reader->AddVariable ("etajet", &etajet); // reader->AddVariable ("masstop", &masstop); // reader->AddVariable ("mtw", &mtw); reader->AddVariable ("deltaRphotonjet", &deltaRphotonjet); reader->AddVariable ("deltaRphotonmuon", &deltaRphotonmuon); // reader->AddVariable ("ht", &ht); // reader->AddVariable ("photonmuonmass", &photonmuonmass); reader->AddVariable ("costopphoton", &costopphoton); // reader->AddVariable ("topphotonmass", &topphotonmass); //reader->AddVariable ("pttop", &pttop); //reader->AddVariable ("etatop", &etatop); reader->AddVariable ("jetmultiplicity", &jetmultiplicity); // reader->AddVariable ("bjetmultiplicity", &bjetmultiplicity); reader->AddVariable ("deltaphiphotonmet", &deltaphiphotonmet); reader->AddVariable ("cvsdiscriminant", &cvsdiscriminant); // reader->AddVariable ("leptoncharge", &leptoncharge); /* // Spectator variables declared in the training have to be added to the reader, too reader->AddSpectator( "spec1 := var1*2", &spec1 ); reader->AddSpectator( "spec2 := var1*3", &spec2 ); Float_t Category_cat1, Category_cat2, Category_cat3; if (Use["Category"]){ // Add artificial spectators for distinguishing categories reader->AddSpectator( "Category_cat1 := var3<=0", &Category_cat1 ); reader->AddSpectator( "Category_cat2 := (var3>0)&&(var4<0)", &Category_cat2 ); reader->AddSpectator( "Category_cat3 := (var3>0)&&(var4>=0)", &Category_cat3 ); } */ // --- Book the MVA methods TString dir = "weights/"; TString prefix = "TMVA"; // Book method(s) for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) { if (it->second) { TString methodName = TString(it->first) + TString(" method"); TString weightfile = dir + prefix + TString("_") + TString(it->first) + TString(".weights.xml"); reader->BookMVA( methodName, weightfile ); } } // Book output histograms UInt_t nbin = 40; TH1F *histLk(0), *histLkD(0), *histLkPCA(0), *histLkKDE(0), *histLkMIX(0), *histPD(0), *histPDD(0); TH1F *histPDPCA(0), *histPDEFoam(0), *histPDEFoamErr(0), *histPDEFoamSig(0), *histKNN(0), *histHm(0); TH1F *histFi(0), *histFiG(0), *histFiB(0), *histLD(0), *histNn(0),*histNnbfgs(0),*histNnbnn(0); TH1F *histNnC(0), *histNnT(0), *histBdt(0), *histBdtG(0), *histBdtD(0), *histRf(0), *histSVMG(0); TH1F *histSVMP(0), *histSVML(0), *histFDAMT(0), *histFDAGA(0), *histCat(0), *histPBdt(0); if (Use["Likelihood"]) histLk = new TH1F( "MVA_Likelihood", "MVA_Likelihood", nbin, -1, 1 ); if (Use["LikelihoodD"]) histLkD = new TH1F( "MVA_LikelihoodD", "MVA_LikelihoodD", nbin, -1, 0.9999 ); if (Use["LikelihoodPCA"]) histLkPCA = new TH1F( "MVA_LikelihoodPCA", "MVA_LikelihoodPCA", nbin, -1, 1 ); if (Use["LikelihoodKDE"]) histLkKDE = new TH1F( "MVA_LikelihoodKDE", "MVA_LikelihoodKDE", nbin, -0.00001, 0.99999 ); if (Use["LikelihoodMIX"]) histLkMIX = new TH1F( "MVA_LikelihoodMIX", "MVA_LikelihoodMIX", nbin, 0, 1 ); if (Use["PDERS"]) histPD = new TH1F( "MVA_PDERS", "MVA_PDERS", nbin, 0, 1 ); if (Use["PDERSD"]) histPDD = new TH1F( "MVA_PDERSD", "MVA_PDERSD", nbin, 0, 1 ); if (Use["PDERSPCA"]) histPDPCA = new TH1F( "MVA_PDERSPCA", "MVA_PDERSPCA", nbin, 0, 1 ); if (Use["KNN"]) histKNN = new TH1F( "MVA_KNN", "MVA_KNN", nbin, 0, 1 ); if (Use["HMatrix"]) histHm = new TH1F( "MVA_HMatrix", "MVA_HMatrix", nbin, -0.95, 1.55 ); if (Use["Fisher"]) histFi = new TH1F( "MVA_Fisher", "MVA_Fisher", nbin, -4, 4 ); if (Use["FisherG"]) histFiG = new TH1F( "MVA_FisherG", "MVA_FisherG", nbin, -1, 1 ); if (Use["BoostedFisher"]) histFiB = new TH1F( "MVA_BoostedFisher", "MVA_BoostedFisher", nbin, -2, 2 ); if (Use["LD"]) histLD = new TH1F( "MVA_LD", "MVA_LD", nbin, -2, 2 ); if (Use["MLP"]) histNn = new TH1F( "MVA_MLP", "MVA_MLP", nbin, -1.25, 1.5 ); if (Use["MLPBFGS"]) histNnbfgs = new TH1F( "MVA_MLPBFGS", "MVA_MLPBFGS", nbin, -1.25, 1.5 ); if (Use["MLPBNN"]) histNnbnn = new TH1F( "MVA_MLPBNN", "MVA_MLPBNN", nbin, -1.25, 1.5 ); if (Use["CFMlpANN"]) histNnC = new TH1F( "MVA_CFMlpANN", "MVA_CFMlpANN", nbin, 0, 1 ); if (Use["TMlpANN"]) histNnT = new TH1F( "MVA_TMlpANN", "MVA_TMlpANN", nbin, -1.3, 1.3 ); if (Use["BDT"]) histBdt = new TH1F( "MVA_BDT", "MVA_BDT", nbin, -0.8, 0.8 ); if (Use["BDTD"]) histBdtD = new TH1F( "MVA_BDTD", "MVA_BDTD", nbin, -0.8, 0.8 ); if (Use["BDTG"]) histBdtG = new TH1F( "MVA_BDTG", "MVA_BDTG", nbin, -1.0, 1.0 ); if (Use["RuleFit"]) histRf = new TH1F( "MVA_RuleFit", "MVA_RuleFit", nbin, -2.0, 2.0 ); if (Use["SVM_Gauss"]) histSVMG = new TH1F( "MVA_SVM_Gauss", "MVA_SVM_Gauss", nbin, 0.0, 1.0 ); if (Use["SVM_Poly"]) histSVMP = new TH1F( "MVA_SVM_Poly", "MVA_SVM_Poly", nbin, 0.0, 1.0 ); if (Use["SVM_Lin"]) histSVML = new TH1F( "MVA_SVM_Lin", "MVA_SVM_Lin", nbin, 0.0, 1.0 ); if (Use["FDA_MT"]) histFDAMT = new TH1F( "MVA_FDA_MT", "MVA_FDA_MT", nbin, -2.0, 3.0 ); if (Use["FDA_GA"]) histFDAGA = new TH1F( "MVA_FDA_GA", "MVA_FDA_GA", nbin, -2.0, 3.0 ); if (Use["Category"]) histCat = new TH1F( "MVA_Category", "MVA_Category", nbin, -2., 2. ); if (Use["Plugin"]) histPBdt = new TH1F( "MVA_PBDT", "MVA_BDT", nbin, -0.8, 0.8 ); // PDEFoam also returns per-event error, fill in histogram, and also fill significance if (Use["PDEFoam"]) { histPDEFoam = new TH1F( "MVA_PDEFoam", "MVA_PDEFoam", nbin, 0, 1 ); histPDEFoamErr = new TH1F( "MVA_PDEFoamErr", "MVA_PDEFoam error", nbin, 0, 1 ); histPDEFoamSig = new TH1F( "MVA_PDEFoamSig", "MVA_PDEFoam significance", nbin, 0, 10 ); } // Book example histogram for probability (the other methods are done similarly) TH1F *probHistFi(0), *rarityHistFi(0); if (Use["Fisher"]) { probHistFi = new TH1F( "MVA_Fisher_Proba", "MVA_Fisher_Proba", nbin, 0, 1 ); rarityHistFi = new TH1F( "MVA_Fisher_Rarity", "MVA_Fisher_Rarity", nbin, 0, 1 ); } // Prepare input tree (this must be replaced by your data source) // in this example, there is a toy tree with signal and one with background events // we'll later on use only the "signal" events for the test in this example. // TFile *input(0); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// std::vector<string> samples_; std::vector<string> datasamples_; std::vector<TH1F*> datahists; std::vector<TH1F*> revDATAhists; float scales[] = {0.0978,1.491,0.0961,0.0253,0.0224,0.0145,0.0125,0.0160,0.0158,0.0341,0.0341,0.0341,0.020,0.0017,0.0055,0.0032,0.00084,0.02,19.145*0.0169,19.145*0.0169,19.145*0.0169,19.145*0.0169,19.145*0.0169}; //samples_.push_back("WJET.root"); samples_.push_back("ZJET.root"); samples_.push_back("PHJET200400.root"); samples_.push_back("WPHJET.root"); samples_.push_back("T-W-CH.root"); samples_.push_back("TBAR-W-CH.root"); samples_.push_back("T-S-CH.root"); samples_.push_back("TBAR-S-CH.root"); samples_.push_back("T-T-CH.root"); samples_.push_back("TBAR-T-CH.root"); samples_.push_back("TTBAR1.root"); samples_.push_back("TTBAR2.root"); samples_.push_back("TTBAR3.root"); samples_.push_back("TTG.root"); samples_.push_back("WWG.root"); samples_.push_back("WW.root"); samples_.push_back("WZ.root"); samples_.push_back("ZZ.root"); samples_.push_back("ZGAMMA.root"); samples_.push_back("SIGNAL.root"); samples_.push_back("SIGNAL.root"); samples_.push_back("SIGNAL.root"); samples_.push_back("SIGNAL.root"); samples_.push_back("SIGNAL.root"); datasamples_.push_back("REALDATA1.root"); datasamples_.push_back("REALDATA2.root"); datasamples_.push_back("REALDATA3.root"); std::vector<string> datasamplesreverse_; datasamplesreverse_.push_back("etarev/REALDATA1.root"); datasamplesreverse_.push_back("etarev/REALDATA2.root"); datasamplesreverse_.push_back("etarev/REALDATA3.root"); std::vector<string> systematics; //systematics.push_back("__JES__plus"); //systematics.push_back("__JES__minus"); //systematics.push_back("__JER__plus"); //systematics.push_back("__JER__minus"); systematics.push_back("__PU__plus"); systematics.push_back("__PU__minus"); systematics.push_back("__TRIG__plus"); systematics.push_back("__TRIG__minus"); systematics.push_back("__BTAG__plus"); systematics.push_back("__BTAG__minus"); systematics.push_back("__MISSTAG__plus"); systematics.push_back("__MISSTAG__minus"); systematics.push_back("__MUON__plus"); systematics.push_back("__MUON__minus"); systematics.push_back("__PHOTON__plus"); systematics.push_back("__PHOTON__minus"); systematics.push_back(""); map<string, double> eventwight; TList* hList = new TList(); // list of histograms to store std::vector<TFile*> files; for(unsigned int idx=0; idx<samples_.size(); ++idx){ files.push_back(new TFile(samples_[idx].c_str())); } std::vector<TFile*> datafiles; for(unsigned int idx=0; idx<datasamples_.size(); ++idx){ datafiles.push_back(new TFile(datasamples_[idx].c_str())); } for(unsigned int phi=0; phi<systematics.size(); ++phi){ std::vector<TH1F*> hists; TH1F *wphjethist(0), *zjethist(0) , *phjethist(0), *wjethist(0), *twchhist(0), *tbarwhist(0), *tschhist(0), *tbarschhist(0), *ttchhist(0), *tbartchhist(0), *tt1hist(0) ,*tt2hist(0), *tt3hist(0), *ttphhist(0), *wwphhist(0), *wwhist(0), *wzhist(0), *zzhist(0), *zgammahist(0), *signalhist5(0) , *signalhist10(0), *signalhist20(0), *signalhist30(0), *signalhist40(0); TH1F *data1histrev(0), *data2histrev(0) ,*data3histrev(0); wphjethist = new TH1F( std::string("BDT__wphjethist").append(systematics[phi]).c_str(), std::string("BDT__wphjethist").append(systematics[phi]).c_str() , nbin, -1, 1 ); zjethist = new TH1F( std::string("BDT__zjethist").append(systematics[phi]).c_str(), std::string("BDT__zjethist").append(systematics[phi]).c_str(), nbin, -1, 1 ); phjethist = new TH1F( std::string("BDT__phjethist").append(systematics[phi]).c_str(),std::string("BDT__phjethist").append(systematics[phi]).c_str() , nbin, -1, 1 ); //wjethist = new TH1F( std::string("BDT__wjethist").append(systematics[phi]).c_str(),std::string("BDT__wjethist").append(systematics[phi]).c_str() , nbin, -0.8, 0.8 ); twchhist = new TH1F( std::string("BDT__twchhist").append(systematics[phi]).c_str(),std::string("BDT__twchhist").append(systematics[phi]).c_str() ,nbin, -1, 1 ); tbarwhist = new TH1F( std::string("BDT__tbarwhist").append(systematics[phi]).c_str(),std::string("BDT__tbarwhist").append(systematics[phi]).c_str() ,nbin, -1, 1 ); tschhist = new TH1F( std::string("BDT__tschhist").append(systematics[phi]).c_str(), std::string("BDT__tschhist").append(systematics[phi]).c_str(), nbin, -1, 1 ); tbarschhist = new TH1F( std::string("BDT__tbarschhist").append(systematics[phi]).c_str(),std::string("BDT__tbarschhist").append(systematics[phi]).c_str(), nbin, -1, 1 ); ttchhist = new TH1F( std::string("BDT__ttchhist").append(systematics[phi]).c_str(),std::string("BDT__ttchhist").append(systematics[phi]).c_str(), nbin, -1, 1 ); tbartchhist = new TH1F( std::string("BDT__tbartchhist").append(systematics[phi]).c_str(), std::string("BDT__tbartchhist").append(systematics[phi]).c_str(), nbin, -1, 1 ); tt1hist = new TH1F( std::string("BDT__tt1hist").append(systematics[phi]).c_str(), std::string("BDT__tt1hist").append(systematics[phi]).c_str(), nbin, -1, 1 ); tt2hist = new TH1F( std::string("BDT__tt2hist").append(systematics[phi]).c_str(), std::string("BDT__tt2hist").append(systematics[phi]).c_str(), nbin, -1, 1 ); tt3hist = new TH1F( std::string("BDT__tt3hist").append(systematics[phi]).c_str(),std::string("BDT__tt3hist").append(systematics[phi]).c_str() , nbin, -1, 1 ); ttphhist = new TH1F( std::string("BDT__ttphhist").append(systematics[phi]).c_str(),std::string("BDT__ttphhist").append(systematics[phi]).c_str() ,nbin, -1, 1 ); wwphhist = new TH1F( std::string("BDT__wwphhist").append(systematics[phi]).c_str(),std::string("BDT__wwphhist").append(systematics[phi]).c_str(), nbin, -1, 1 ); wwhist = new TH1F( std::string("BDT__wwhist").append(systematics[phi]).c_str(),std::string("BDT__wwhist").append(systematics[phi]).c_str() ,nbin, -1, 1 ); wzhist = new TH1F( std::string("BDT__wzhist").append(systematics[phi]).c_str(),std::string("BDT__wzhist").append(systematics[phi]).c_str(), nbin, -1, 1 ); zzhist = new TH1F( std::string("BDT__zzhist").append(systematics[phi]).c_str(),std::string("BDT__zzhist").append(systematics[phi]).c_str() ,nbin, -1, 1 ); zgammahist = new TH1F( std::string("BDT__zgammahist").append(systematics[phi]).c_str(),std::string("BDT__zgammahist").append(systematics[phi]).c_str() ,nbin, -1, 1 ); signalhist5 = new TH1F( std::string("BDT__signal5").append(systematics[phi]).c_str(),std::string("BDT__signal5").append(systematics[phi]).c_str() ,nbin, -1, 1 ); signalhist10 = new TH1F( std::string("BDT__signal10").append(systematics[phi]).c_str(),std::string("BDT__signal10").append(systematics[phi]).c_str() ,nbin, -1, 1 ); signalhist20 = new TH1F( std::string("BDT__signal20").append(systematics[phi]).c_str(),std::string("BDT__signal20").append(systematics[phi]).c_str() ,nbin, -1, 1 ); signalhist30 = new TH1F( std::string("BDT__signal30").append(systematics[phi]).c_str(),std::string("BDT__signal30").append(systematics[phi]).c_str() ,nbin, -1, 1 ); signalhist40 = new TH1F( std::string("BDT__signal40").append(systematics[phi]).c_str(),std::string("BDT__signal40").append(systematics[phi]).c_str() ,nbin, -1, 1 ); hists.push_back(zjethist); hists.push_back(phjethist); hists.push_back(wphjethist); //hists.push_back(wjethist); hists.push_back(twchhist); hists.push_back(tbarwhist); hists.push_back(tschhist); hists.push_back(tbarschhist); hists.push_back(ttchhist); hists.push_back(tbartchhist); hists.push_back(tt1hist); hists.push_back(tt2hist); hists.push_back(tt3hist); hists.push_back(ttphhist); hists.push_back(wwphhist); hists.push_back(wwhist); hists.push_back(wzhist); hists.push_back(zzhist); hists.push_back(zgammahist); hists.push_back(signalhist5); hists.push_back(signalhist10); hists.push_back(signalhist20); hists.push_back(signalhist30); hists.push_back(signalhist40); for(unsigned int idx=0; idx<samples_.size(); ++idx){ TFile *input(0); TString fname =samples_[idx]; if (!gSystem->AccessPathName( fname )) input = TFile::Open( fname ); // check if file in local directory exists else input = TFile::Open( "http://root.cern.ch/files/tmva_class_example.root" ); // if not: download from ROOT server if (!input) { std::cout << "ERROR: could not open data file" << std::endl; exit(1); } std::cout << "--- TMVAClassificationApp : Using input file: " << input->GetName() << std::endl; // --- Event loop // Prepare the event tree // - here the variable names have to corres[1]ponds to your tree // - you can use the same variables as above which is slightly faster, // but of course you can use different ones and copy the values inside the event loop // //Double_t myptphoton,myetaphoton,myptmuon,myetamuon,myptjet,myetajet,mymasstop,mymtw,mydeltaRphotonjet,mydeltaRphotonmuon,myht,mycostopphoton,mydeltaphiphotonmet,mycvsdiscriminant,myjetmultiplicity,mybjetmultiplicity,myleptoncharge; std::vector<double> *myptphoton=0; std::vector<double> *myetaphoton=0; std::vector<double> *myptmuon=0; std::vector<double> *myetamuon=0; std::vector<double> *myptjet=0; std::vector<double> *myetajet=0; std::vector<double> *mymasstop=0; //std::vector<double> *mymtw=0; std::vector<double> *mydeltaRphotonjet=0; std::vector<double> *mydeltaRphotonmuon=0; //std::vector<double> *myht=0; std::vector<double> *mycostopphoton=0; std::vector<double> *mydeltaphiphotonmet=0; std::vector<double> *mycvsdiscriminant=0; std::vector<double> *myjetmultiplicity=0; //std::vector<double> *mybjetmultiplicity=0; //std::vector<double> *myleptoncharge=0; std::vector<double> *myweight=0; std::vector<double> *mybtagSF=0; std::vector<double> *mybtagSFup=0; std::vector<double> *mybtagSFdown=0; std::vector<double> *mymistagSFup=0; std::vector<double> *mymistagSFdown=0; std::vector<double> *mytriggerSF=0; std::vector<double> *mytriggerSFup=0; std::vector<double> *mytriggerSFdown=0; std::vector<double> *myphotonSF=0; std::vector<double> *myphotonSFup=0; std::vector<double> *myphotonSFdown=0; std::vector<double> *mypileupSF=0; std::vector<double> *mypileupSFup=0; std::vector<double> *mypileupSFdown=0; std::vector<double> *mymuonSFup=0; std::vector<double> *mymuonSFdown=0; std::vector<double> *mymuonSF=0; std::cout << "--- Select signal sample" << std::endl; TTree* theTree = (TTree*)input->Get("analyzestep2/atq"); // Int_t myjetmultiplicity, mybjetmultiplicity , myleptoncharge; // Float_t userVar1, userVar2; theTree->SetBranchAddress("ptphoton", &myptphoton ); theTree->SetBranchAddress( "etaphoton", &myetaphoton ); theTree->SetBranchAddress( "ptmuon", &myptmuon ); theTree->SetBranchAddress( "etamuon", &myetamuon ); theTree->SetBranchAddress( "ptjet", &myptjet ); theTree->SetBranchAddress( "etajet", &myetajet ); theTree->SetBranchAddress( "masstop", &mymasstop ); // theTree->SetBranchAddress( "mtw", &mymtw ); theTree->SetBranchAddress( "deltaRphotonjet", &mydeltaRphotonjet ); theTree->SetBranchAddress( "deltaRphotonmuon", &mydeltaRphotonmuon ); // theTree->SetBranchAddress( "ht", &myht ); theTree->SetBranchAddress( "costopphoton", &mycostopphoton ); theTree->SetBranchAddress( "jetmultiplicity", &myjetmultiplicity ); // theTree->SetBranchAddress( "bjetmultiplicity", &mybjetmultiplicity ); theTree->SetBranchAddress( "deltaphiphotonmet", &mydeltaphiphotonmet ); theTree->SetBranchAddress( "cvsdiscriminant", &mycvsdiscriminant ); // theTree->SetBranchAddress( "leptoncharge", &myleptoncharge ); theTree->SetBranchAddress( "weight", &myweight); theTree->SetBranchAddress( "btagSF", &mybtagSF); theTree->SetBranchAddress( "btagSFup", &mybtagSFup); theTree->SetBranchAddress( "btagSFdown", &mybtagSFdown); theTree->SetBranchAddress( "mistagSFup", &mymistagSFup); theTree->SetBranchAddress( "mistagSFdown", &mymistagSFdown); theTree->SetBranchAddress( "triggerSF", &mytriggerSF); theTree->SetBranchAddress( "triggerSFup", &mytriggerSFup); theTree->SetBranchAddress( "triggerSFdown", &mytriggerSFdown); theTree->SetBranchAddress( "photonSF", &myphotonSF); theTree->SetBranchAddress( "photonSFup", &myphotonSFup); theTree->SetBranchAddress( "photonSFdown", &myphotonSFdown); theTree->SetBranchAddress( "muonSF", &mymuonSF); theTree->SetBranchAddress( "muonSFup", &mymuonSFup); theTree->SetBranchAddress( "muonSFdown", &mymuonSFdown); theTree->SetBranchAddress( "pileupSF", &mypileupSF); theTree->SetBranchAddress( "pileupSFup", &mypileupSFup); theTree->SetBranchAddress( "pileupSFdown", &mypileupSFdown); // Efficiency calculator for cut method Int_t nSelCutsGA = 0; Double_t effS = 0.7; std::vector<Float_t> vecVar(4); // vector for EvaluateMVA tests // std::cout << "--- Processing: " << theTree->GetEntries() << " events" << std::endl; TStopwatch sw; sw.Start(); for (Long64_t ievt=0; ievt<theTree->GetEntries();ievt++) { // std::cout << "--- ... Processing event: " << ievt << std::endl; double finalweight; if (ievt%1000 == 0) std::cout << "--- ... Processing event: " << ievt << std::endl; theTree->GetEntry(ievt); //for (int l=0;l<sizeof(myptphoton);l++){ //std::cout << "--- ... reza: " << myptphoton[l] <<std::endl; //} //std::cout << "--- ......................."<< (*mycvsdiscriminant)[0]<<std::endl; // --- Return the MVA outputs and fill into histograms ptphoton=(float)(*myptphoton)[0]; etaphoton=(float)(*myetaphoton )[0]; ptmuon=(float)(*myptmuon )[0]; etamuon=(float)(*myetamuon )[0]; ptjet=(float)(*myptjet )[0]; etajet=(float)(*myetajet )[0]; masstop=(float)(*mymasstop )[0]; //mtw=(float)(*mymtw )[0]; deltaRphotonjet=(float)(*mydeltaRphotonjet )[0]; deltaRphotonmuon=(float)(*mydeltaRphotonmuon )[0]; //ht=(float)(*myht )[0]; costopphoton=(float)(*mycostopphoton )[0]; jetmultiplicity=(float)(*myjetmultiplicity )[0]; //bjetmultiplicity=(float)(*mybjetmultiplicity )[0]; deltaphiphotonmet=(float)(*mydeltaphiphotonmet )[0]; cvsdiscriminant=(float)(*mycvsdiscriminant)[0]; //leptoncharge=(float)(*myleptoncharge )[0]; finalweight=(*myweight)[0]; //cout<<(*myweight)[0]<<endl; eventwight["__PU__plus"]=(*myweight)[0]*(*mypileupSFup)[0]/(*mypileupSF)[0]; eventwight["__PU__minus"]=(*myweight)[0]*(*mypileupSFdown)[0]/(*mypileupSF)[0]; eventwight["__TRIG__plus"]=(*myweight)[0]*(*mytriggerSFup)[0]/(*mytriggerSF)[0]; eventwight["__TRIG__minus"]=(*myweight)[0]*(*mytriggerSFdown)[0]/(*mytriggerSF)[0]; eventwight["__BTAG__plus"]=(*myweight)[0]*(*mybtagSFup)[0]/(*mybtagSF)[0]; eventwight["__BTAG__minus"]=(*myweight)[0]*(*mybtagSFdown)[0]/(*mybtagSF)[0]; eventwight["__MISSTAG__plus"]=(*myweight)[0]*(*mymistagSFup)[0]/(*mybtagSF)[0]; eventwight["__MISSTAG__minus"]=(*myweight)[0]*(*mymistagSFdown)[0]/(*mybtagSF)[0]; eventwight["__MUON__plus"]=(*myweight)[0]*(*mymuonSFup)[0]/(*mymuonSF)[0]; eventwight["__MUON__minus"]=(*myweight)[0]*(*mymuonSFdown)[0]/(*mymuonSF)[0]; eventwight["__PHOTON__plus"]=(*myweight)[0]*(*myphotonSFup)[0]/(*myphotonSF)[0]; eventwight["__PHOTON__minus"]=(*myweight)[0]*(*myphotonSFdown)[0]/(*myphotonSF)[0]; eventwight[""]=(*myweight)[0]; finalweight=eventwight[systematics[phi].c_str()]; if (samples_[idx]=="SIGNAL.root") finalweight=(*myweight)[0]; //if (samples_[idx]=="WPHJET") finalweight=(*mypileupSF)[0]*(*mytriggerSF)[0]*(*mybtagSF)[0]*(*mymuonSF)[0]*(*myphotonSF)[0]; //if (finalweight<0) finalweight=30; //cout<<"negative event weight"<<finalweight<<" "<<ptphoton<<endl; if (Use["CutsGA"]) { // Cuts is a special case: give the desired signal efficienciy Bool_t passed = reader->EvaluateMVA( "CutsGA method", effS ); if (passed) nSelCutsGA++; } hists[idx] ->Fill( reader->EvaluateMVA( "BDT method" ),finalweight* scales[idx] ); //cout<<reader->EvaluateMVA( "BDT method")<<" "<<finalweight<<endl; //cout<<(*myweight)[0]<<endl; // Retrieve also per-event error if (Use["PDEFoam"]) { Double_t val = reader->EvaluateMVA( "PDEFoam method" ); Double_t err = reader->GetMVAError(); histPDEFoam ->Fill( val ); histPDEFoamErr->Fill( err ); if (err>1.e-50) histPDEFoamSig->Fill( val/err ); } // Retrieve probability instead of MVA output if (Use["Fisher"]) { probHistFi ->Fill( reader->GetProba ( "Fisher method" ) ); rarityHistFi->Fill( reader->GetRarity( "Fisher method" ) ); } //delete finalweight; } // Get elapsed time sw.Stop(); std::cout << "--- End of event loop: "; sw.Print(); // Get efficiency for cuts classifier if (Use["CutsGA"]) std::cout << "--- Efficiency for CutsGA method: " << double(nSelCutsGA)/theTree->GetEntries() << " (for a required signal efficiency of " << effS << ")" << std::endl; if (Use["CutsGA"]) { // test: retrieve cuts for particular signal efficiency // CINT ignores dynamic_casts so we have to use a cuts-secific Reader function to acces the pointer TMVA::MethodCuts* mcuts = reader->FindCutsMVA( "CutsGA method" ) ; if (mcuts) { std::vector<Double_t> cutsMin; std::vector<Double_t> cutsMax; mcuts->GetCuts( 0.7, cutsMin, cutsMax ); std::cout << "--- -------------------------------------------------------------" << std::endl; std::cout << "--- Retrieve cut values for signal efficiency of 0.7 from Reader" << std::endl; for (UInt_t ivar=0; ivar<cutsMin.size(); ivar++) { std::cout << "... Cut: " << cutsMin[ivar] << " < \"" << mcuts->GetInputVar(ivar) << "\" <= " << cutsMax[ivar] << std::endl; } std::cout << "--- -------------------------------------------------------------" << std::endl; } } delete myptphoton; delete myetaphoton; delete myptmuon; delete myetamuon; delete myptjet; delete myetajet; delete mymasstop; //delete mymtw; delete mydeltaRphotonjet; delete mydeltaRphotonmuon; //delete myht; delete mycostopphoton; delete mydeltaphiphotonmet; delete mycvsdiscriminant; delete myjetmultiplicity; //delete mybjetmultiplicity; //delete myleptoncharge; //delete myplot; delete mybtagSF; delete mybtagSFup; delete mybtagSFdown; delete mymistagSFup; delete mytriggerSF; delete mytriggerSFup; delete mytriggerSFdown; delete myphotonSF; delete myphotonSFup; delete myphotonSFdown; delete mypileupSF; delete mypileupSFup; delete mypileupSFdown; delete input; if (idx==samples_.size()-5) hists[idx]->Scale(5/hists[idx]->Integral()); if (idx==samples_.size()-4) hists[idx]->Scale(10/hists[idx]->Integral()); if (idx==samples_.size()-3) hists[idx]->Scale(20/hists[idx]->Integral()); if (idx==samples_.size()-2) hists[idx]->Scale(30/hists[idx]->Integral()); if (idx==samples_.size()-1) hists[idx]->Scale(40/hists[idx]->Integral()); if (samples_[idx]=="WPHJET.root") hists[idx]->Scale(3173/hists[idx]->Integral()); if (samples_[idx]=="TTBAR2.root") hists[idx]->Add(hists[idx-1]); if (samples_[idx]=="TTBAR3.root") hists[idx]->Add(hists[idx-1]); if (!(samples_[idx]=="TTBAR1.root" || samples_[idx]=="TTBAR2.root")) hList->Add(hists[idx]); } } TH1F *data1hist(0), *data2hist(0) ,*data3hist(0); data1hist = new TH1F( "mu_BDT__data1hist", "mu_BDT__data1hist", nbin, -1, 1 ); data2hist = new TH1F( "mu_BDT__data2hist", "mu_BDT__data2hist", nbin, -1, 1 ); data3hist = new TH1F( "BDT__DATA", "BDT__DATA", nbin, -1, 1 ); datahists.push_back(data1hist); datahists.push_back(data2hist); datahists.push_back(data3hist); for(unsigned int idx=0; idx<datasamples_.size(); ++idx){ TFile *input(0); TString fname =datasamples_[idx]; if (!gSystem->AccessPathName( fname )) input = TFile::Open( fname ); // check if file in local directory exists else input = TFile::Open( "http://root.cern.ch/files/tmva_class_example.root" ); // if not: download from ROOT server if (!input) { std::cout << "ERROR: could not open data file" << std::endl; exit(1); } std::cout << "--- TMVAClassificationApp : Using input file: " << input->GetName() << std::endl; // --- Event loop // Prepare the event tree // - here the variable names have to corres[1]ponds to your tree // - you can use the same variables as above which is slightly faster, // but of course you can use different ones and copy the values inside the event loop // std::vector<double> *myptphoton=0; std::vector<double> *myetaphoton=0; std::vector<double> *myptmuon=0; std::vector<double> *myetamuon=0; std::vector<double> *myptjet=0; std::vector<double> *myetajet=0; std::vector<double> *mymasstop=0; //std::vector<double> *mymtw=0; std::vector<double> *mydeltaRphotonjet=0; std::vector<double> *mydeltaRphotonmuon=0; //std::vector<double> *myht=0; std::vector<double> *mycostopphoton=0; std::vector<double> *mydeltaphiphotonmet=0; std::vector<double> *mycvsdiscriminant=0; std::vector<double> *myjetmultiplicity=0; //std::vector<double> *mybjetmultiplicity=0; //std::vector<double> *myleptoncharge=0; std::cout << "--- Select signal sample" << std::endl; TTree* theTree = (TTree*)input->Get("analyzestep2/atq"); // Int_t myjetmultiplicity, mybjetmultiplicity , myleptoncharge; // Float_t userVar1, userVar2; theTree->SetBranchAddress("ptphoton", &myptphoton ); theTree->SetBranchAddress( "etaphoton", &myetaphoton ); theTree->SetBranchAddress( "ptmuon", &myptmuon ); theTree->SetBranchAddress( "etamuon", &myetamuon ); theTree->SetBranchAddress( "ptjet", &myptjet ); theTree->SetBranchAddress( "etajet", &myetajet ); theTree->SetBranchAddress( "masstop", &mymasstop ); // theTree->SetBranchAddress( "mtw", &mymtw ); theTree->SetBranchAddress( "deltaRphotonjet", &mydeltaRphotonjet ); theTree->SetBranchAddress( "deltaRphotonmuon", &mydeltaRphotonmuon ); // theTree->SetBranchAddress( "ht", &myht ); theTree->SetBranchAddress( "costopphoton", &mycostopphoton ); theTree->SetBranchAddress( "jetmultiplicity", &myjetmultiplicity ); // theTree->SetBranchAddress( "bjetmultiplicity", &mybjetmultiplicity ); theTree->SetBranchAddress( "deltaphiphotonmet", &mydeltaphiphotonmet ); theTree->SetBranchAddress( "cvsdiscriminant", &mycvsdiscriminant ); // theTree->SetBranchAddress( "leptoncharge", &myleptoncharge ); // Efficiency calculator for cut method Int_t nSelCutsGA = 0; Double_t effS = 0.7; std::vector<Float_t> vecVar(4); // vector for EvaluateMVA tests std::cout << "--- Processing: " << theTree->GetEntries() << " events" << std::endl; TStopwatch sw; sw.Start(); for (Long64_t ievt=0; ievt<theTree->GetEntries();ievt++) { // std::cout << "--- ... Processing event: " << ievt << std::endl; if (ievt%1000 == 0) std::cout << "--- ... Processing event: " << ievt << std::endl; theTree->GetEntry(ievt); //for (int l=0;l<sizeof(myptphoton);l++){ //std::cout << "--- ... reza: " << myptphoton[l] <<std::endl; //} //std::cout << "--- ......................."<< (*mycvsdiscriminant)[0]<<std::endl; // --- Return the MVA outputs and fill into histograms ptphoton=(float)(*myptphoton)[0]; etaphoton=(float)(*myetaphoton )[0]; ptmuon=(float)(*myptmuon )[0]; etamuon=(float)(*myetamuon )[0]; ptjet=(float)(*myptjet )[0]; etajet=(float)(*myetajet )[0]; masstop=(float)(*mymasstop )[0]; //mtw=(float)(*mymtw )[0]; deltaRphotonjet=(float)(*mydeltaRphotonjet )[0]; deltaRphotonmuon=(float)(*mydeltaRphotonmuon )[0]; //ht=(float)(*myht )[0]; costopphoton=(float)(*mycostopphoton )[0]; jetmultiplicity=(float)(*myjetmultiplicity )[0]; //bjetmultiplicity=(float)(*mybjetmultiplicity )[0]; deltaphiphotonmet=(float)(*mydeltaphiphotonmet )[0]; cvsdiscriminant=(float)(*mycvsdiscriminant)[0]; //leptoncharge=(float)(*myleptoncharge )[0]; if (Use["CutsGA"]) { // Cuts is a special case: give the desired signal efficienciy Bool_t passed = reader->EvaluateMVA( "CutsGA method", effS ); if (passed) nSelCutsGA++; } if (Use["Likelihood" ]) histLk ->Fill( reader->EvaluateMVA( "Likelihood method" ) ); if (Use["LikelihoodD" ]) histLkD ->Fill( reader->EvaluateMVA( "LikelihoodD method" ) ); if (Use["LikelihoodPCA"]) histLkPCA ->Fill( reader->EvaluateMVA( "LikelihoodPCA method" ) ); if (Use["LikelihoodKDE"]) histLkKDE ->Fill( reader->EvaluateMVA( "LikelihoodKDE method" ) ); if (Use["LikelihoodMIX"]) histLkMIX ->Fill( reader->EvaluateMVA( "LikelihoodMIX method" ) ); if (Use["PDERS" ]) histPD ->Fill( reader->EvaluateMVA( "PDERS method" ) ); if (Use["PDERSD" ]) histPDD ->Fill( reader->EvaluateMVA( "PDERSD method" ) ); if (Use["PDERSPCA" ]) histPDPCA ->Fill( reader->EvaluateMVA( "PDERSPCA method" ) ); if (Use["KNN" ]) histKNN ->Fill( reader->EvaluateMVA( "KNN method" ) ); if (Use["HMatrix" ]) histHm ->Fill( reader->EvaluateMVA( "HMatrix method" ) ); if (Use["Fisher" ]) histFi ->Fill( reader->EvaluateMVA( "Fisher method" ) ); if (Use["FisherG" ]) histFiG ->Fill( reader->EvaluateMVA( "FisherG method" ) ); if (Use["BoostedFisher"]) histFiB ->Fill( reader->EvaluateMVA( "BoostedFisher method" ) ); if (Use["LD" ]) histLD ->Fill( reader->EvaluateMVA( "LD method" ) ); if (Use["MLP" ]) histNn ->Fill( reader->EvaluateMVA( "MLP method" ) ); if (Use["MLPBFGS" ]) histNnbfgs ->Fill( reader->EvaluateMVA( "MLPBFGS method" ) ); if (Use["MLPBNN" ]) histNnbnn ->Fill( reader->EvaluateMVA( "MLPBNN method" ) ); if (Use["CFMlpANN" ]) histNnC ->Fill( reader->EvaluateMVA( "CFMlpANN method" ) ); if (Use["TMlpANN" ]) histNnT ->Fill( reader->EvaluateMVA( "TMlpANN method" ) ); if (Use["BDT" ]) histBdt ->Fill( reader->EvaluateMVA( "BDT method" ) ); if (Use["BDTD" ]) histBdtD ->Fill( reader->EvaluateMVA( "BDTD method" ) ); if (Use["BDTG" ]) histBdtG ->Fill( reader->EvaluateMVA( "BDTG method" ) ); if (Use["RuleFit" ]) histRf ->Fill( reader->EvaluateMVA( "RuleFit method" ) ); if (Use["SVM_Gauss" ]) histSVMG ->Fill( reader->EvaluateMVA( "SVM_Gauss method" ) ); if (Use["SVM_Poly" ]) histSVMP ->Fill( reader->EvaluateMVA( "SVM_Poly method" ) ); if (Use["SVM_Lin" ]) histSVML ->Fill( reader->EvaluateMVA( "SVM_Lin method" ) ); if (Use["FDA_MT" ]) histFDAMT ->Fill( reader->EvaluateMVA( "FDA_MT method" ) ); if (Use["FDA_GA" ]) histFDAGA ->Fill( reader->EvaluateMVA( "FDA_GA method" ) ); if (Use["Category" ]) histCat ->Fill( reader->EvaluateMVA( "Category method" ) ); if (Use["Plugin" ]) histPBdt ->Fill( reader->EvaluateMVA( "P_BDT method" ) ); datahists[idx] ->Fill( reader->EvaluateMVA( "BDT method" ) ); } // Get elapsed time sw.Stop(); std::cout << "--- End of event loop: "; sw.Print(); delete myptphoton; delete myetaphoton; delete myptmuon; delete myetamuon; delete myptjet; delete myetajet; delete mymasstop; //delete mymtw; delete mydeltaRphotonjet; delete mydeltaRphotonmuon; //delete myht; delete mycostopphoton; delete mydeltaphiphotonmet; delete mycvsdiscriminant; delete myjetmultiplicity; //delete mybjetmultiplicity; //delete myleptoncharge; //delete myplot; delete input; } for(unsigned int idx=1; idx<datasamples_.size(); ++idx){ datahists[idx]->Add(datahists[idx-1]); } hList->Add(datahists[2]); TH1F *data1histrev(0), *data2histrev(0) ,*data3histrev(0); data1histrev = new TH1F( "BDT__data1histrev", "BDT__data1histrev", nbin, -1, 1 ); data2histrev = new TH1F( "BDT__data2histrev", "BDT__data2histrev", nbin, -1, 1 ); data3histrev = new TH1F( "BDT__wjet", "BDT__wjet", nbin, -1, 1 ); revDATAhists.push_back(data1histrev); revDATAhists.push_back(data2histrev); revDATAhists.push_back(data3histrev); for(unsigned int idx=0; idx<datasamplesreverse_.size(); ++idx){ TFile *input(0); TString fname =datasamplesreverse_[idx]; if (!gSystem->AccessPathName( fname )) input = TFile::Open( fname ); // check if file in local directory exists else input = TFile::Open( "http://root.cern.ch/files/tmva_class_example.root" ); // if not: download from ROOT server if (!input) { std::cout << "ERROR: could not open data file" << std::endl; exit(1); } std::cout << "--- TMVAClassificationApp : Using input file: " << input->GetName() << std::endl; // --- Event loop // // // Prepare the event tree // // - here the variable names have to corres[1]ponds to your tree // // - you can use the same variables as above which is slightly faster, // // but of course you can use different ones and copy the values inside the event loop // // // Double_t myptphoton,myetaphoton,myptmuon,myetamuon,myptjet,myetajet,mymasstop,mymtw,mydeltaRphotonjet,mydeltaRphotonmuon,myht,mycostopphoton,mydeltaphiphotonmet,mycvsdiscriminant,myjetmultiplicity,mybjetmultiplicity,myleptoncharge; std::vector<double> *myptphoton=0; std::vector<double> *myetaphoton=0; std::vector<double> *myptmuon=0; std::vector<double> *myetamuon=0; std::vector<double> *myptjet=0; std::vector<double> *myetajet=0; std::vector<double> *mymasstop=0; //std::vector<double> *mymtw=0; std::vector<double> *mydeltaRphotonjet=0; std::vector<double> *mydeltaRphotonmuon=0; //std::vector<double> *myht=0; std::vector<double> *mycostopphoton=0; std::vector<double> *mydeltaphiphotonmet=0; std::vector<double> *mycvsdiscriminant=0; std::vector<double> *myjetmultiplicity=0; //std::vector<double> *mybjetmultiplicity=0; //std::vector<double> *myleptoncharge=0; TTree* theTree = (TTree*)input->Get("analyzestep2/atq"); theTree->SetBranchAddress("ptphoton", &myptphoton ); theTree->SetBranchAddress( "etaphoton", &myetaphoton ); theTree->SetBranchAddress( "ptmuon", &myptmuon ); theTree->SetBranchAddress( "etamuon", &myetamuon ); theTree->SetBranchAddress( "ptjet", &myptjet ); theTree->SetBranchAddress( "etajet", &myetajet ); theTree->SetBranchAddress( "masstop", &mymasstop ); // theTree->SetBranchAddress( "mtw", &mymtw ); theTree->SetBranchAddress( "deltaRphotonjet", &mydeltaRphotonjet ); theTree->SetBranchAddress( "deltaRphotonmuon", &mydeltaRphotonmuon ); // theTree->SetBranchAddress( "ht", &myht ); theTree->SetBranchAddress( "costopphoton", &mycostopphoton ); theTree->SetBranchAddress( "jetmultiplicity", &myjetmultiplicity ); // theTree->SetBranchAddress( "bjetmultiplicity", &mybjetmultiplicity ); theTree->SetBranchAddress( "deltaphiphotonmet", &mydeltaphiphotonmet ); theTree->SetBranchAddress( "cvsdiscriminant", &mycvsdiscriminant ); // theTree->SetBranchAddress( "leptoncharge", &myleptoncharge ); // Efficiency calculator for cut method Int_t nSelCutsGA = 0; Double_t effS = 0.7; std::vector<Float_t> vecVar(4); // vector for EvaluateMVA tests std::cout << "--- Processing: " << theTree->GetEntries() << " events" << std::endl; TStopwatch sw; sw.Start(); for (Long64_t ievt=0; ievt<theTree->GetEntries();ievt++) { // std::cout << "--- ... Processing event: " << ievt << std::endl; if (ievt%1000 == 0) std::cout << "--- ... Processing event: " << ievt << std::endl; theTree->GetEntry(ievt); //for (int l=0;l<sizeof(myptphoton);l++){ //std::cout << "--- ... reza: " << myptphoton[l] <<std::endl; //} // std::cout << "--- ......................."<< (*mycvsdiscriminant)[0]<<std::endl; // --- Return the MVA outputs and fill into histograms ptphoton=(float)(*myptphoton)[0]; etaphoton=(float)(*myetaphoton )[0]; ptmuon=(float)(*myptmuon )[0]; etamuon=(float)(*myetamuon )[0]; ptjet=(float)(*myptjet )[0]; etajet=(float)(*myetajet )[0]; masstop=(float)(*mymasstop )[0]; //mtw=(float)(*mymtw )[0]; deltaRphotonjet=(float)(*mydeltaRphotonjet )[0]; deltaRphotonmuon=(float)(*mydeltaRphotonmuon )[0]; //ht=(float)(*myht )[0]; costopphoton=(float)(*mycostopphoton )[0]; jetmultiplicity=(float)(*myjetmultiplicity )[0]; //bjetmultiplicity=(float)(*mybjetmultiplicity )[0]; deltaphiphotonmet=(float)(*mydeltaphiphotonmet )[0]; cvsdiscriminant=(float)(*mycvsdiscriminant)[0]; //leptoncharge=(float)(*myleptoncharge )[0]; if (Use["Likelihood" ]) histLk ->Fill( reader->EvaluateMVA( "Likelihood method" ) ); if (Use["LikelihoodD" ]) histLkD ->Fill( reader->EvaluateMVA( "LikelihoodD method" ) ); if (Use["LikelihoodPCA"]) histLkPCA ->Fill( reader->EvaluateMVA( "LikelihoodPCA method" ) ); if (Use["LikelihoodKDE"]) histLkKDE ->Fill( reader->EvaluateMVA( "LikelihoodKDE method" ) ); if (Use["LikelihoodMIX"]) histLkMIX ->Fill( reader->EvaluateMVA( "LikelihoodMIX method" ) ); if (Use["PDERS" ]) histPD ->Fill( reader->EvaluateMVA( "PDERS method" ) ); if (Use["PDERSD" ]) histPDD ->Fill( reader->EvaluateMVA( "PDERSD method" ) ); if (Use["PDERSPCA" ]) histPDPCA ->Fill( reader->EvaluateMVA( "PDERSPCA method" ) ); if (Use["KNN" ]) histKNN ->Fill( reader->EvaluateMVA( "KNN method" ) ); if (Use["HMatrix" ]) histHm ->Fill( reader->EvaluateMVA( "HMatrix method" ) ); if (Use["Fisher" ]) histFi ->Fill( reader->EvaluateMVA( "Fisher method" ) ); if (Use["FisherG" ]) histFiG ->Fill( reader->EvaluateMVA( "FisherG method" ) ); if (Use["BoostedFisher"]) histFiB ->Fill( reader->EvaluateMVA( "BoostedFisher method" ) ); if (Use["LD" ]) histLD ->Fill( reader->EvaluateMVA( "LD method" ) ); if (Use["MLP" ]) histNn ->Fill( reader->EvaluateMVA( "MLP method" ) ); if (Use["MLPBFGS" ]) histNnbfgs ->Fill( reader->EvaluateMVA( "MLPBFGS method" ) ); if (Use["MLPBNN" ]) histNnbnn ->Fill( reader->EvaluateMVA( "MLPBNN method" ) ); if (Use["CFMlpANN" ]) histNnC ->Fill( reader->EvaluateMVA( "CFMlpANN method" ) ); if (Use["TMlpANN" ]) histNnT ->Fill( reader->EvaluateMVA( "TMlpANN method" ) ); if (Use["BDT" ]) histBdt ->Fill( reader->EvaluateMVA( "BDT method" ) ); if (Use["BDTD" ]) histBdtD ->Fill( reader->EvaluateMVA( "BDTD method" ) ); if (Use["BDTG" ]) histBdtG ->Fill( reader->EvaluateMVA( "BDTG method" ) ); if (Use["RuleFit" ]) histRf ->Fill( reader->EvaluateMVA( "RuleFit method" ) ); if (Use["SVM_Gauss" ]) histSVMG ->Fill( reader->EvaluateMVA( "SVM_Gauss method" ) ); if (Use["SVM_Poly" ]) histSVMP ->Fill( reader->EvaluateMVA( "SVM_Poly method" ) ); if (Use["SVM_Lin" ]) histSVML ->Fill( reader->EvaluateMVA( "SVM_Lin method" ) ); if (Use["FDA_MT" ]) histFDAMT ->Fill( reader->EvaluateMVA( "FDA_MT method" ) ); if (Use["FDA_GA" ]) histFDAGA ->Fill( reader->EvaluateMVA( "FDA_GA method" ) ); if (Use["Category" ]) histCat ->Fill( reader->EvaluateMVA( "Category method" ) ); if (Use["Plugin" ]) histPBdt ->Fill( reader->EvaluateMVA( "P_BDT method" ) ); revDATAhists[idx]->Fill( reader->EvaluateMVA( "BDT method" ) );} sw.Stop(); std::cout << "--- End of event loop: "; sw.Print(); delete myptphoton; delete myetaphoton; delete myptmuon; delete myetamuon; delete myptjet; delete myetajet; delete mymasstop; //delete mymtw; delete mydeltaRphotonjet; delete mydeltaRphotonmuon; //delete myht; delete mycostopphoton; delete mydeltaphiphotonmet; delete mycvsdiscriminant; delete myjetmultiplicity; ////delete mybjetmultiplicity; ////delete myleptoncharge; ////delete myplot; // delete input; } for(unsigned int idx=1; idx<datasamplesreverse_.size(); ++idx){ revDATAhists[idx]->Add(revDATAhists[idx-1]); } revDATAhists[2]->Scale(620.32/revDATAhists[2]->Integral()); hList->Add(revDATAhists[2]); cout<<revDATAhists[2]->Integral()<<endl; TFile *target = new TFile( "MVApp.root","RECREATE" ); hList->Write(); target->Close(); }
void advancedNoiseAnalysis( unsigned int runNumber, unsigned int loop = 1) { string inputFileName = "./histo/run00" + toString( runNumber ) + "-ped-histo.root"; string outputFileName = "./histo/run00" + toString( runNumber ) + "-adv-noise.root"; // before opening the input and the output files, try to see if they // are not opened yet and in case close them before continue TList * listOfOpenedFile = (TList*) gROOT->GetListOfFiles(); for ( int i = 0; i < listOfOpenedFile->GetSize() ; ++i ) { TFile * file = (TFile*) listOfOpenedFile->At( i ) ; TString fileName(file->GetName()); TString inputFileName1( inputFileName.c_str() ); TString outputFileName1( outputFileName.c_str() ); if ( ( fileName.Contains( inputFileName1 ) ) || ( inputFileName1.Contains( fileName ) ) || ( fileName.Contains( outputFileName1 ) ) || ( outputFileName1.Contains( fileName ) ) ) { cout << "Closing " << fileName << " before reopen " << endl; file->Close(); } } // close also all the previously opened canvas TList * listOfOpenedCanvas = (TList*) gROOT->GetListOfCanvases(); for ( int i = 0 ; i < listOfOpenedCanvas->GetSize() ; ++i ) { TCanvas * canvas = (TCanvas*) listOfOpenedCanvas->At( i ); TString canvasName2 = canvas->GetName(); if ( canvasName2.Contains( "det" ) ) { canvas->Close(); } } // now safely open the file TFile * inputFile = TFile::Open( inputFileName.c_str() ) ; TFile * outputFile = TFile::Open( outputFileName.c_str(), "RECREATE") ; TList * outputHistoList = new TList; // look into the inputFile for a folder named string pedeProcessorFolderName = "PedestalAndNoiseCalculator"; TDirectoryFile * pedeProcessorFolder = (TDirectoryFile*) inputFile->Get( pedeProcessorFolderName.c_str() ); if ( pedeProcessorFolder == 0 ) { cerr << "No pedestal processor folder found in file " << inputFileName << endl; return ; } // this folder should contain one folder for each loop. string loopFolderName = "loop-" + toString( loop ); TDirectoryFile * loopFolder = (TDirectoryFile *) pedeProcessorFolder->Get( loopFolderName.c_str() ); if ( loopFolder == 0 ) { cerr << "No " << loopFolderName << " found in file " << inputFileName << endl; return ; } // guess the number of sensors from the number of subfolder in the loopfolder size_t nDetector = loopFolder->GetListOfKeys()->GetSize(); cout << "This file contains " << nDetector << " detectors" << endl; // prepare arrays to store the mean and the rms of the noise distribution if ( noiseMean == NULL ) { delete [] noiseMean; noiseMean = NULL; } if ( noiseRMS == NULL ) { delete [] noiseRMS; noiseRMS = NULL; } if ( channel == NULL ) { delete [] channel; channel = NULL; } noiseMean = new double[ nDetector * kNChan ]; noiseRMS = new double[ nDetector * kNChan ]; channel = new double[ kNChan ]; string canvasName = "comparison"; string canvasTitle = "Noise comparison"; TCanvas * comparisonCanvas = new TCanvas( canvasName.c_str(), canvasTitle.c_str(), 1000, 500 ); comparisonCanvas->Divide(1,2); TPad * topPad = (TPad*) comparisonCanvas->cd(1); topPad->Divide( nDetector ); TPad * middlePad = (TPad *) comparisonCanvas->cd(2); middlePad->Divide( kNChan ); // for each detector we have to get the noise map and to prepare 4 // separe histos and maps for ( unsigned int iDetector = 0; iDetector < nDetector; iDetector++ ) { // get the noise map. string noiseMapName = "detector-" + toString( iDetector ) ; noiseMapName += "/NoiseMap-d" + toString( iDetector ) ; noiseMapName += "-l" + toString( loop ) ; TH2D * noiseMap = ( TH2D* ) loopFolder->Get( noiseMapName.c_str() ); // create a folder in the output file TDirectory * subfolder = outputFile->mkdir( string( "detector_" + toString( iDetector ) ).c_str(), string( "detector_" + toString( iDetector ) ).c_str() ); subfolder->cd(); string canvasName = "det" + toString( iDetector ); string canvasTitle = "Detector " + toString( iDetector ); TCanvas * canvas = new TCanvas( canvasName.c_str(), canvasTitle.c_str(), 1000, 500 ); canvas->Divide( kNChan, 2 ); // ok now start the loop on channels for ( size_t iChan = 0 ; iChan < kNChan ; ++iChan ) { if ( iDetector == 0 ) channel[iChan] = iChan - 0.5; string tempName = "NoiseMap_d" + toString( iDetector ) + "_l" + toString( loop ) + "_ch" + toString( iChan ) ; string tempTitle = "NoiseMap Det. " + toString( iDetector ) + " - Ch. " + toString( iChan ) ; TH2D * noiseMapCh = new TH2D ( tempName.c_str() , tempTitle.c_str(), kXPixel / kNChan , -0.5 + xLimit[ iChan ] , -0.5 + xLimit[ iChan + 1 ], kYPixel, -0.5, -0.5 + kYPixel ); noiseMapCh->SetXTitle("X [pixel]"); noiseMapCh->SetYTitle("Y [pixel]"); noiseMapCh->SetZTitle("Noise [ADC]"); noiseMapCh->SetStats( false ); outputHistoList->Add( noiseMapCh ) ; tempName = "NoiseDist_d" + toString( iDetector ) + "_l" + toString( loop ) + "_ch" + toString( iChan ) ; tempTitle = "NoiseDist Det. " + toString( iDetector ) + " - Ch. " + toString( iChan ) ; TH1D * noiseDistCh = new TH1D( tempName.c_str(), tempTitle.c_str(), 50, 0., 10. ); noiseDistCh->SetXTitle("Noise [ADC]"); noiseDistCh->SetLineColor( kColor[iDetector] ); noiseDistCh->SetLineStyle( iChan + 2 ); noiseDistCh->SetLineWidth( 2 ); outputHistoList->Add( noiseDistCh ); // let's start looping on pixels now for ( size_t yPixel = 1 ; yPixel <= kYPixel ; ++yPixel ) { for ( size_t xPixel = xLimit[ iChan ] + 1; xPixel <= xLimit[ iChan +1 ] ; ++xPixel ) { double noise = noiseMap->GetBinContent( xPixel , yPixel ); noiseMapCh->Fill( xPixel - 1 , yPixel - 1, noise ); noiseDistCh->Fill( noise ); } } canvas->cd( iChan + 1 ) ; noiseMapCh->Draw("colz"); canvas->cd( iChan + kNChan + 1 ); noiseDistCh->Draw(); topPad->cd( iDetector + 1 ); if ( iChan == 0 ) { noiseDistCh->Draw(); } else { noiseDistCh->Draw("same"); } middlePad->cd( iChan + 1 ); if ( iDetector == 0 ) { noiseDistCh->Draw(); } else { noiseDistCh->Draw("same"); } noiseMean[ kNChan * iDetector + iChan ] = noiseDistCh->GetMean(); noiseRMS[ kNChan * iDetector + iChan ] = noiseDistCh->GetRMS(); } canvas->Write(); } canvasName = "summary"; canvasTitle = "Noise summary"; TCanvas * summaryCanvas = new TCanvas( canvasName.c_str(), canvasTitle.c_str(), 1000, 500 ); summaryCanvas->SetGridx(1); TLegend * legend = new TLegend(0.5, 4.8, 1.5, 4.3,"","br");; for ( size_t iDetector = 0 ; iDetector < nDetector ; ++iDetector ) { TGraphErrors * gr = new TGraphErrors( kNChan, channel, &noiseMean[ iDetector * kNChan ], NULL, &noiseRMS[ iDetector * kNChan ] ); gr->SetName( string( "NoisePerChannel_d" + toString( iDetector )).c_str()); gr->SetTitle(string("Detector " + toString( iDetector )).c_str()); gr->GetXaxis()->SetTitle("Channel #"); gr->GetYaxis()->SetTitle("Noise [ADC]"); gr->GetXaxis()->SetNdivisions( 5 ); gr->GetXaxis()->SetLabelSize( 0 ); gr->SetMarkerStyle( iDetector + 1 ); gr->SetMarkerColor( kColor[iDetector] ); gr->SetLineColor( kColor[iDetector] ); gr->SetLineWidth( 2 ); legend->AddEntry( gr, string("Detector " + toString( iDetector )).c_str(), "LP"); if ( iDetector == 0 ) { gr->Draw("ALP"); } else { gr->Draw("LP"); } } legend->Draw(); for ( size_t iChan = 0 ; iChan < kNChan ; ++iChan ) { TPaveLabel * label = new TPaveLabel( iChan - 0.75 , 3.2 , iChan -0.25 , 3, string("Ch " + toString( iChan ) ).c_str()); label->Draw(); } summaryCanvas->Write(); comparisonCanvas->Write(); outputHistoList->Write(); }
int main(int argc, char* argv[]) { TApplication theApp(srcName.Data(), &argc, argv); //============================================================================= if (argc<5) return -1; TString sPath = argv[1]; if (sPath.IsNull()) return -1; TString sFile = argv[2]; if (sFile.IsNull()) return -1; TString sJetR = argv[3]; if (sJetR.IsNull()) return -1; TString sSjeR = argv[4]; if (sSjeR.IsNull()) return -1; //============================================================================= sPath.ReplaceAll("#", "/"); //============================================================================= double dJetR = -1.; if (sJetR=="JetR02") dJetR = 0.2; if (sJetR=="JetR03") dJetR = 0.3; if (sJetR=="JetR04") dJetR = 0.4; if (sJetR=="JetR05") dJetR = 0.5; if (dJetR<0.) return -1; cout << "Jet R = " << dJetR << endl; //============================================================================= double dSjeR = -1.; if (sSjeR=="SjeR01") dSjeR = 0.1; if (sSjeR=="SjeR02") dSjeR = 0.2; if (sSjeR=="SjeR03") dSjeR = 0.3; if (sSjeR=="SjeR04") dSjeR = 0.4; if (dSjeR<0.) return -1; cout << "Sub-jet R = " << dSjeR << endl; //============================================================================= const double dJetsPtMin = 0.001; const double dCutEtaMax = 1.6; const double dJetEtaMax = 1.; const double dJetAreaRef = TMath::Pi() * dJetR * dJetR; fastjet::GhostedAreaSpec areaSpc(dCutEtaMax); fastjet::JetDefinition jetsDef(fastjet::antikt_algorithm, dJetR, fastjet::BIpt_scheme, fastjet::Best); //fastjet::AreaDefinition areaDef(fastjet::active_area,areaSpc); fastjet::AreaDefinition areaDef(fastjet::active_area_explicit_ghosts,areaSpc); //fastjet::JetDefinition bkgsDef(fastjet::kt_algorithm, 0.2, fastjet::BIpt_scheme, fastjet::Best); //fastjet::AreaDefinition aBkgDef(fastjet::active_area_explicit_ghosts, areaSpc); fastjet::Selector selectJet = fastjet::SelectorAbsEtaMax(dJetEtaMax); //fastjet::Selector selectRho = fastjet::SelectorAbsEtaMax(dCutEtaMax-0.2); //fastjet::Selector selecHard = fastjet::SelectorNHardest(2); //fastjet::Selector selectBkg = selectRho * (!(selecHard)); //fastjet::JetMedianBackgroundEstimator bkgsEstimator(selectBkg, bkgsDef, aBkgDef); //fastjet::Subtractor bkgSubtractor(&bkgsEstimator); fastjet::JetDefinition subjDef(fastjet::antikt_algorithm, dSjeR, fastjet::BIpt_scheme, fastjet::Best); //============================================================================= std::vector<fastjet::PseudoJet> fjInput; //============================================================================= TList *list = new TList(); TH1D *hWeightSum = new TH1D("hWeightSum", "", 1, 0., 1.); list->Add(hWeightSum); TH1D *hJet = new TH1D("hJet", "", 1000, 0., 1000.); hJet->Sumw2(); list->Add(hJet); TH2D *hJetNsj = new TH2D("hJetNsj", "", 1000, 0., 1000., 101, -0.5, 100.5); hJetNsj->Sumw2(); list->Add(hJetNsj); TH2D *hJetIsj = new TH2D("hJetIsj", "", 1000, 0., 1000., 1000, 0., 1000.); hJetIsj->Sumw2(); list->Add(hJetIsj); TH2D *hJet1sj = new TH2D("hJet1sj", "", 1000, 0., 1000., 1000, 0., 1000.); hJet1sj->Sumw2(); list->Add(hJet1sj); TH2D *hJet2sj = new TH2D("hJet2sj", "", 1000, 0., 1000., 1000, 0., 1000.); hJet2sj->Sumw2(); list->Add(hJet2sj); TH2D *hJetDsj = new TH2D("hJetDsj", "", 1000, 0., 1000., 1000, 0., 1000.); hJetDsj->Sumw2(); list->Add(hJetDsj); TH2D *hJetIsz = new TH2D("hJetIsz", "", 1000, 0., 1000., 120, 0., 1.2); hJetIsz->Sumw2(); list->Add(hJetIsz); TH2D *hJet1sz = new TH2D("hJet1sz", "", 1000, 0., 1000., 120, 0., 1.2); hJet1sz->Sumw2(); list->Add(hJet1sz); TH2D *hJet2sz = new TH2D("hJet2sz", "", 1000, 0., 1000., 120, 0., 1.2); hJet2sz->Sumw2(); list->Add(hJet2sz); TH2D *hJetDsz = new TH2D("hJetDsz", "", 1000, 0., 1000., 120, 0., 1.2); hJetDsz->Sumw2(); list->Add(hJetDsz); //============================================================================= HepMC::IO_GenEvent ascii_in(Form("%s/%s.hepmc",sPath.Data(),sFile.Data()), std::ios::in); HepMC::GenEvent *evt = ascii_in.read_next_event(); while (evt) { fjInput.resize(0); double dXsect = evt->cross_section()->cross_section() / 1e9; double dWeight = evt->weights().back(); double dNorm = dWeight * dXsect; hWeightSum->Fill(0.5, dWeight); TVector3 vPar; for (HepMC::GenEvent::particle_const_iterator p=evt->particles_begin(); p!=evt->particles_end(); ++p) if ((*p)->status()==1) { vPar.SetXYZ((*p)->momentum().px(), (*p)->momentum().py(), (*p)->momentum().pz()); if ((TMath::Abs(vPar.Eta())<dCutEtaMax)) { fjInput.push_back(fastjet::PseudoJet(vPar.Px(), vPar.Py(), vPar.Pz(), vPar.Mag())); } } //============================================================================= fastjet::ClusterSequenceArea clustSeq(fjInput, jetsDef, areaDef); std::vector<fastjet::PseudoJet> includJets = clustSeq.inclusive_jets(dJetsPtMin); // std::vector<fastjet::PseudoJet> subtedJets = bkgSubtractor(includJets); std::vector<fastjet::PseudoJet> selectJets = selectJet(includJets); // std::vector<fastjet::PseudoJet> sortedJets = fastjet::sorted_by_pt(selectJets); for (int j=0; j<selectJets.size(); j++) { double dJet = selectJets[j].pt(); hJet->Fill(dJet, dNorm); //============================================================================= fastjet::Filter trimmer(subjDef, fastjet::SelectorPtFractionMin(0.)); fastjet::PseudoJet trimmdJet = trimmer(selectJets[j]); std::vector<fastjet::PseudoJet> trimmdSj = trimmdJet.pieces(); double nIsj = 0.; double d1sj = -1.; int k1sj = -1; double d2sj = -1.; int k2sj = -1; for (int i=0; i<trimmdSj.size(); i++) { double dIsj = trimmdSj[i].pt(); if (dIsj<0.001) continue; hJetIsj->Fill(dJet, dIsj, dNorm); hJetIsz->Fill(dJet, dIsj/dJet, dNorm); if (dIsj>d1sj) { d2sj = d1sj; k2sj = k1sj; d1sj = dIsj; k1sj = i; } else if (dIsj>d2sj) { d2sj = dIsj; k2sj = i; } nIsj += 1.; } hJetNsj->Fill(dJet, nIsj, dNorm); if (d1sj>0.) { hJet1sj->Fill(dJet, d1sj, dNorm); hJet1sz->Fill(dJet, d1sj/dJet, dNorm); } if (d2sj>0.) { hJet2sj->Fill(dJet, d2sj, dNorm); hJet2sz->Fill(dJet, d2sj/dJet, dNorm); } if ((d1sj>0.) && (d2sj>0.)) { double dsj = d1sj - d2sj; double dsz = dsj / dJet; hJetDsj->Fill(dJet, dsj, dNorm); hJetDsz->Fill(dJet, dsz, dNorm); } } //============================================================================= delete evt; ascii_in >> evt; } //============================================================================= TFile *file = TFile::Open(Form("%s.root",sFile.Data()), "NEW"); list->Write(); file->Close(); //============================================================================= cout << "DONE" << endl; return 0; }
/** * Extract ALICE PbPb @ 5.02TeV over |eta|<2 * * @param filename Input file name * @param outname Output file name * @param reweigh Whether it is reweighed */ void Extract(const char* filename="dndneta.pbpb502.20151124.root", const char* outname="TRACKLETS_5023_PbPb.input", Bool_t reweigh=false) { if (filename == 0) return; TFile* file = TFile::Open(filename, "READ"); TObjArray* arr = static_cast<TObjArray*>(file->Get("TObjArray")); // Now count number of bins Int_t nBins = 0; TIter next(arr); TObject* obj = 0; while ((obj = next())) { if (TString(obj->GetName()).Contains("DataCorrSignal")) nBins++; } Info("ExtractdNdeta", "Defining %d centrality bins", nBins); TArrayD c(nBins+1); if (nBins == 5) { c[0] = 0; c[1] = 10; c[2] = 20; c[3] = 40; c[4] = 60; c[5] = 80; } else if (nBins >= 9) { c[0] = 0; c[1] = 5; c[2] = 10; c[3] = 20; c[4] = 30; c[5] = 40; c[6] = 50; c[7] = 60; c[8] = 70; c[9] = 80; if (nBins >= 10) c[10] = 90; if (nBins >= 11) c[11] = 100; } THStack* all = new THStack("all","all"); std::ofstream out(outname); std::ostream& o = out; // std::cout; // std::ostream& o = std::cout; o << "*author: SHAHOYAN : 2015\n" << "*title: Full centrality dependence of the charged " << "particle pseudo-rapidity density over the widest " << "possible pseudo-rapidity range in Pb-Pb collisions " << "at 5.02 TeV\n" << "*detector: TRACKLETS\n" << "*experiment: CERN-LHC-TRACKLETS\n" << "*comment: CERN-LHC: We present the charged particle pseudo-rapidity " << "density of charged particles in Pb-Pb collisions at sqrt(s)/nucleon " "= 5.02 over the widest possible pseudo-rapidity and centrality range " << "possible.\n" << std::endl; for (Int_t i = 0; i < nBins; i++) { TString hName = Form("bin%d_DataCorrSignal_PbPb",i); TH1* h = static_cast<TH1*>(arr->FindObject(hName)); if (!h) { hName.ReplaceAll("PbPb", "PBPB"); h = static_cast<TH1*>(arr->FindObject(hName)); if (!h) { Warning("", "Histogram (%s) missing for bin %d", hName.Data(), i); arr->Print(); continue; } } Color_t col = PbPbColor(c[i], c[i+1]); h->SetLineColor(col); h->SetMarkerColor(col); h->SetFillColor(col); all->Add(h); Info("","Making GSE for %0d%% to %3d%% (%d)", Int_t(c[i]), Int_t(c[i+1]), col); MakeGSE(o, h, c[i], c[i+1], reweigh); } // all->Draw("nostack"); o << "*E" << std::endl; out.close(); TCanvas* can = new TCanvas("c","C", 1600, 800); can->SetRightMargin(0.2); can->SetTopMargin(0.01); TLegend* cl = new TLegend(1-can->GetRightMargin(), can->GetBottomMargin(),.99, 1-can->GetTopMargin()); cl->SetFillStyle(0); cl->SetBorderSize(0); gROOT->LoadMacro("$HOME/GraphSysErr/GraphSysErr.C+"); TList* ll = GraphSysErr::Import(outname); // ll->ls(); TIter next(ll); TObject* obj = 0; Bool_t first = true; TH1* frame = 0; Double_t min=100000, max=0; Int_t i = 0; while ((obj = next())) { if (c[i+1] > 80) break; GraphSysErr* g = static_cast<GraphSysErr*>(obj); Color_t col = PbPbColor(c[i], c[i+1]); TLegendEntry* e = cl->AddEntry("", Form("%4.1f-%4.1f%%", c[i], c[i+1]), "F"); e->SetFillColor(col); e->SetFillStyle(1001); g->SetLineColor(col); g->SetMarkerColor(col); g->SetFillColor(col); // g->Print("qual"); g->SetDataOption(GraphSysErr::kNoTick); g->SetSumOption(GraphSysErr::kBox); g->SetSumLineColor(col); g->SetSumFillColor(col); g->SetCommonSumOption(GraphSysErr::kBox); g->SetCommonSumLineColor(col); g->SetCommonSumFillColor(col); g->SetName(Form("tracklets%03dd%02d_%03dd%02d", Int_t(c[i]), Int_t(c[i]*100) % 100, Int_t(c[i+1]), Int_t(c[i+1]*100) % 100)); g->SetTitle(Form("%4.1f - %4.1f%%", c[i], c[i+1])); if (first) g->Draw("combine stat quad axis xbase=2.5"); else g->Draw("combine stat quad xbase=2.5"); if (!frame) frame = g->GetMulti()->GetHistogram(); first = false; Double_t mn, mx; g->GetMinMax("combine stat quad", mn, mx); FindLeastLargest(g, c[i], c[i+1]); min = TMath::Min(min, mn); max = TMath::Max(max, mx); i++; } frame->SetMinimum(min*.9); frame->SetMaximum(max*1.1); cl->Draw(); TFile* outFile = TFile::Open(Form("PbPb5023midRapidity%s.root", reweigh ? "Reweighed" : "Normal"), "RECREATE"); ll->Write("container",TObject::kSingleKey); outFile->Write(); can->SaveAs(Form("PbPb5023midRapidity%s.png", reweigh ? "Reweighed" : "Normal")); }
void plotPFRandomCone(TString str = "forest.root", Int_t nRCPerEvent = 1, int maxEvents = -1) { // gStyle->SetOptStat(0000); // gStyle->SetOptTitle(0); double minEta = -1.5; double maxEta = 1.5; double minPhi = -TMath::Pi(); double maxPhi = TMath::Pi(); double radiusRC = 0.4; TChain *fChain = new TChain("hiEvtAnalyzer/HiTree"); TChain *pfTree = new TChain("pfcandAnalyzer/pfTree"); TChain *skimTree = new TChain("skimanalysis/HltTree"); TChain *hltTree = new TChain("hltanalysis/HltTree"); // TFile *f = TFile::Open(str.Data()); fChain->Add(str.Data()); pfTree->Add(str.Data()); skimTree->Add(str.Data()); hltTree->Add(str.Data()); fChain->AddFriend(pfTree); fChain->AddFriend(skimTree); fChain->AddFriend(hltTree); if(!fChain) { Printf("Couldn't find pfTree. Aborting!"); return; } Int_t MinBiasTriggerBit; Int_t phfCoincFilter; Int_t hiBin; TBranch *b_hiBin; //! fChain->SetBranchAddress("hiBin", &hiBin, &b_hiBin); fChain->SetBranchAddress("HLT_HIL1MinimumBiasHF1ANDExpress_v1",&MinBiasTriggerBit); fChain->SetBranchAddress("phfCoincFilter3",&phfCoincFilter); ForestPFs fPFs; //!PFs in tree if (fChain->GetBranch("nPFpart")) fChain->SetBranchAddress("nPFpart", &fPFs.nPFpart, &fPFs.b_nPFpart); if (fChain->GetBranch("pfId")) fChain->SetBranchAddress("pfId", fPFs.pfId, &fPFs.b_pfId); if (fChain->GetBranch("pfPt")) fChain->SetBranchAddress("pfPt", fPFs.pfPt, &fPFs.b_pfPt); if (fChain->GetBranch("pfVsPtInitial")) fChain->SetBranchAddress("pfVsPtInitial", fPFs.pfVsPt, &fPFs.b_pfVsPt); if (fChain->GetBranch("pfEta")) fChain->SetBranchAddress("pfEta", fPFs.pfEta, &fPFs.b_pfEta); if (fChain->GetBranch("pfPhi")) fChain->SetBranchAddress("pfPhi", fPFs.pfPhi, &fPFs.b_pfPhi); //Printf("nentries: %d",(Int_t)fChain->GetEntries()); TList *fOutput = new TList(); TH1::SetDefaultSumw2(); TH3D *h2CentPtRCEta = new TH3D("h2CentPtRCEta","h2CentPtRCEta;centrality;p_{T,RC};#eta",100,0,100,250,-50.,200.,60,-6,6); fOutput->Add(h2CentPtRCEta); TH3D *h2CentPtRCEtaVS = new TH3D("h2CentPtRCEtaVS","h2CentPtRCEtaVS;centrality;p_{T,RC}^{VS};#eta",100,0,100,250,-50.,200.,60,-6,6); fOutput->Add(h2CentPtRCEtaVS); TH3D *h2MultPtRCEta = new TH3D("h2MultPtRCEta","h2MultPtRCEta;centrality;p_{T,RC};#eta",3000,0,6000,150,-50.,100.,60,-6,6); fOutput->Add(h2MultPtRCEta); TH3D *h2MultPtRCEtaVS = new TH3D("h2MultPtRCEtaVS","h2MultPtRCEtaVS;centrality;p_{T,RC}^{VS};#eta",3000,0,6000,150,-50.,100.,60,-6,6); fOutput->Add(h2MultPtRCEtaVS); Printf("histos defined"); Int_t startEntry = 0; Int_t lastEntry = fChain->GetEntries();//100; Printf("events in chain: %d",lastEntry); if(maxEvents<lastEntry) lastEntry = maxEvents; Printf("lastEntry: %d",lastEntry); TRandom3 *rnd = new TRandom3(); for (int j=startEntry; j<lastEntry; j++) { fChain->GetEntry(j); if(j%100==0) std::cout << "entry: "<< j << std::endl; //if(!MinBiasTriggerBit) continue; if(!phfCoincFilter) continue; double etaRC = rnd->Rndm() * (maxEta - minEta) + minEta; double phiRC = rnd->Rndm() * (maxPhi - minPhi) + minPhi; double ptRC = 0.; double ptRCVS = 0.; Int_t pfCount = 0; for(Int_t i = 0; i<fPFs.nPFpart; i++) { double pt = fPFs.pfPt[i]; double ptVS = fPFs.pfVsPt[i]; double phi = fPFs.pfPhi[i]; double eta = fPFs.pfEta[i]; double dr = deltaR(phi,phiRC,eta,etaRC); if(dr<radiusRC) { ptRC+=pt; ptRCVS+=ptVS; } if(abs(eta)<2.) pfCount++; } Double_t cent = (Double_t)hiBin/2.; h2CentPtRCEta->Fill(cent,ptRC,etaRC); h2CentPtRCEtaVS->Fill(cent,ptRCVS,etaRC); h2MultPtRCEta->Fill(pfCount,ptRC,etaRC); h2MultPtRCEtaVS->Fill(pfCount,ptRCVS,etaRC); } TFile *fout = new TFile("RandomCones.root","RECREATE"); fOutput->Write(); fout->Write(); fout->Close(); }