void test5() { TFile file("test.root"); TTree* tree = (TTree *)file.Get("tree;1"); TList* list = tree->GetUserInfo() ; list->Print(); TObjString* objstr = (TObjString*)list->At(0); objstr->Print(); TString xmlstring = objstr->GetString(); cout << xmlstring << endl; }
void analyzePFvsCaloJetsppData(std::vector<std::string> urls, const char *outname = "eventObjects.root", Long64_t nentries = 20, Int_t firstF = -1, Int_t lastF = -1) { // std::vector<std::string> urls = CollectFiles(list); // Printf("anaFile: %d",anaFile); std::cout << "nfiles: " << urls.size() << std::endl; for (auto i = urls.begin(); i != urls.end(); ++i) std::cout << *i << std::endl; size_t firstFile = 0; size_t lastFile = urls.size(); if(firstF>-1) { firstFile = (size_t)firstF; lastFile = (size_t)lastF; } std::cout << "firstFile: " << firstFile << " lastFile: " << lastFile << std::endl; //add files to chain TChain *chain = NULL; chain = new TChain("hiEvtAnalyzer/HiTree"); for(size_t i=firstFile; i<lastFile; i++) chain->Add(urls[i].c_str()); Printf("hiTree done"); TChain *hltTree = new TChain("hltanalysis/HltTree"); for(size_t i=firstFile; i<lastFile; i++) hltTree->Add(urls[i].c_str()); chain->AddFriend(hltTree); Printf("hltTree done"); TChain *skimTree = new TChain("skimanalysis/HltTree"); for(size_t i=firstFile; i<lastFile; i++) skimTree->Add(urls[i].c_str()); chain->AddFriend(skimTree); Printf("skimTree done"); //TChain *pileupTree = new TChain("pileup/tree"); // for(size_t i=firstFile; i<lastFile; i++) pileupTree->Add(urls[i].c_str()); //chain->AddFriend(pileupTree); TChain *pfTree = new TChain("pfcandAnalyzer/pfTree"); for(size_t i=firstFile; i<lastFile; i++) pfTree->Add(urls[i].c_str()); chain->AddFriend(pfTree); Printf("pfTree done"); // TChain *muTree = new TChain("hltMuTree/HLTMuTree"); // for(size_t i=firstFile; i<lastFile; i++) muTree->Add(urls[i].c_str()); // chain->AddFriend(muTree); // Printf("muTree done"); TChain *pfJetTree = new TChain("ak4PFJetAnalyzer/t"); for(size_t i=firstFile; i<lastFile; i++) pfJetTree->Add(urls[i].c_str()); chain->AddFriend(pfJetTree); Printf("pfJetTree done"); TChain *caloJetTree = new TChain("ak4CaloJetAnalyzer/t"); for(size_t i=firstFile; i<lastFile; i++) caloJetTree->Add(urls[i].c_str()); //chain->AddFriend(caloJetTree); Printf("caloJetTree done"); // TChain *genTree = new TChain("HiGenParticleAna/hi"); // for(size_t i=firstFile; i<lastFile; i++) genTree->Add(urls[i].c_str()); // chain->AddFriend(genTree); // Printf("genTree done"); TList *fEventObjects = new TList(); //--------------------------------------------------------------- // producers // hiEventProducer *p_evt = new hiEventProducer("hiEvtProd"); p_evt->SetInput(chain); p_evt->SetHIEventContName("hiEventContainer"); p_evt->SetEventObjects(fEventObjects); pfParticleProducer *p_pf = new pfParticleProducer("pfPartProd"); p_pf->SetInput(chain); p_pf->SetpfParticlesName("pfParticles"); p_pf->SetEventObjects(fEventObjects); lwJetFromForestProducer *p_pfJet = new lwJetFromForestProducer("lwJetForestProd"); p_pfJet->SetInput(pfJetTree);//chain); p_pfJet->SetJetContName("akt4PF"); p_pfJet->SetGenJetContName("");//akt4Gen"); p_pfJet->SetEventObjects(fEventObjects); p_pfJet->SetRadius(0.4); lwJetFromForestProducer *p_caloJet = new lwJetFromForestProducer("lwJetForestProd"); p_caloJet->SetInput(caloJetTree); p_caloJet->SetJetContName("akt4Calo"); p_caloJet->SetGenJetContName(""); p_caloJet->SetEventObjects(fEventObjects); p_caloJet->SetRadius(0.4); //--------------------------------------------------------------- //analysis modules // //handler to which all modules will be added anaBaseTask *handler = new anaBaseTask("handler","handler"); anaJetMatching *matchingPFCaloJet = new anaJetMatching("matchingPFCaloJet","matchingPFCaloJet"); matchingPFCaloJet->ConnectEventObject(fEventObjects); matchingPFCaloJet->SetHiEvtName("hiEventContainer"); matchingPFCaloJet->DoPFJet80(true); matchingPFCaloJet->DoExcludePhoton30(true); matchingPFCaloJet->SetJetsNameBase("akt4PF"); matchingPFCaloJet->SetJetsNameTag("akt4Calo"); matchingPFCaloJet->SetNCentBins(1); handler->Add(matchingPFCaloJet); anaPFvsCaloJet *anaPFCaloJet = new anaPFvsCaloJet("anaPFvsCaloJet","anaPFvsCaloJet"); anaPFCaloJet->ConnectEventObject(fEventObjects); anaPFCaloJet->SetHiEvtName("hiEventContainer"); anaPFCaloJet->DoPFJet80(true); anaPFCaloJet->DoExcludePhoton30(true); anaPFCaloJet->SetPFJetsName("akt4PF"); anaPFCaloJet->SetCaloJetsName("akt4Calo"); handler->Add(anaPFCaloJet); anaPFvsCaloJet *anaCaloPFJet = new anaPFvsCaloJet("anaCalovsPFJet","anaCalovsPFJet"); anaCaloPFJet->ConnectEventObject(fEventObjects); anaCaloPFJet->SetHiEvtName("hiEventContainer"); anaCaloPFJet->DoPFJet80(true); anaCaloPFJet->DoExcludePhoton30(true); anaCaloPFJet->SetPFJetsName("akt4Calo"); anaCaloPFJet->SetCaloJetsName("akt4PF"); handler->Add(anaCaloPFJet); /* //PF-GEN matching anaJetMatching *matchingGenPFJet = new anaJetMatching("matchingGenPFJet","matchingGenPFJet"); matchingGenPFJet->ConnectEventObject(fEventObjects); matchingGenPFJet->SetHiEvtName(""); matchingGenPFJet->SetJetsNameBase("akt4Gen"); matchingGenPFJet->SetJetsNameTag("akt4PF"); matchingGenPFJet->SetNCentBins(1); handler->Add(matchingGenPFJet); anaPFvsCaloJet *anaGenPFJet = new anaPFvsCaloJet("anaGenVsPFJet","anaGenVsPFJet"); anaGenPFJet->ConnectEventObject(fEventObjects); anaGenPFJet->SetHiEvtName(""); anaGenPFJet->SetPFJetsName("akt4Gen"); anaGenPFJet->SetCaloJetsName("akt4PF"); handler->Add(anaGenPFJet); */ //--------------------------------------------------------------- //Event loop //--------------------------------------------------------------- Long64_t entries_tot = chain->GetEntriesFast(); //93064 if(nentries<0) nentries = chain->GetEntries(); // Long64_t nentries = 20;//chain->GetEntriesFast(); Printf("nentries: %lld tot: %lld",nentries,entries_tot); for (Long64_t jentry=0; jentry<nentries;jentry++) { if (jentry%10000==0) Printf("Processing event %d %d",(int)(jentry), (int)(nentries)); //Run producers // Printf("produce hiEvent"); p_evt->Run(jentry); //hi event properties //Printf("produce pf particles"); // p_pf->Run(jentry); //pf particles p_pfJet->Run(jentry); //jets p_caloJet->Run(jentry); //jets //Execute all analysis tasks handler->ExecuteTask(); } fEventObjects->Print(); TFile *out = new TFile(outname,"RECREATE"); TList *tasks = handler->GetListOfTasks(); TIter next(tasks); anaBaseTask *obj; while ((obj = dynamic_cast<anaBaseTask*>(next()) )) if(obj->GetOutput()) obj->GetOutput()->Write(obj->GetName(),TObject::kSingleKey); out->Write(); out->Close(); }
void analyzeGenChJetMass(std::vector<std::string> urls, const char *outname = "eventObjects.root", Long64_t nentries = 20, Int_t firstF = -1, Int_t lastF = -1, Int_t firstEvent = 0) { std::cout << "nfiles: " << urls.size() << std::endl; for (auto i = urls.begin(); i != urls.end(); ++i) std::cout << *i << std::endl; size_t firstFile = 0; size_t lastFile = urls.size(); if(firstF>-1) { firstFile = (size_t)firstF; lastFile = std::min((size_t)lastF,lastFile); } std::cout << "firstFile: " << firstFile << " lastFile: " << lastFile << std::endl; Int_t lastEvent = nentries; if(firstEvent>0) { lastEvent = firstEvent + nentries; } std::cout << "firstEvent: " << firstEvent << std::endl; //add files to chain TChain *chain = NULL; //chain = new TChain("hiEvtAnalyzer/HiTree"); //for(size_t i=firstFile; i<lastFile; i++) chain->Add(urls[i].c_str()); //Printf("hiTree done"); TChain *genTree = new TChain("HiGenParticleAna/hi"); for(size_t i=firstFile; i<lastFile; i++) genTree->Add(urls[i].c_str()); chain = genTree; //chain->AddFriend(genTree); Printf("genTree done"); TList *fEventObjects = new TList(); //--------------------------------------------------------------- // producers // hiEventProducer *p_evt = new hiEventProducer("hiEvtProd"); p_evt->SetInput(chain); p_evt->SetHIEventContName("hiEventContainer"); p_evt->SetEventObjects(fEventObjects); genParticleProducer *p_gen = new genParticleProducer("genParticleProd"); p_gen->SetInput(chain); p_gen->SetGenParticlesName("genParticles"); p_gen->SetEventObjects(fEventObjects); //--------------------------------------------------------------- //analysis modules // //handler to which all modules will be added anaBaseTask *handler = new anaBaseTask("handler","handler"); //anti-kt jet finder on gen particles charged LWJetProducer *lwjaktGen = new LWJetProducer("LWGenJetProducerAKTR030Ch","LWGenJetProducerAKTR030Ch"); //lwjaktGen->SetInput(chain); lwjaktGen->ConnectEventObject(fEventObjects); lwjaktGen->SetJetType(LWJetProducer::kAKT); lwjaktGen->SetRadius(0.4); lwjaktGen->SetGhostArea(0.005); lwjaktGen->SetPtMinConst(0.); lwjaktGen->SetChargedOnly(true); lwjaktGen->SetParticlesName("genParticles"); lwjaktGen->SetJetContName("GenJetsAKTR040"); lwjaktGen->SetDoConstituentSubtraction(kFALSE); handler->Add(lwjaktGen); anaJetMass *anaJetMassCh = new anaJetMass("anaJetMassChR040","anaJetMassChR040"); anaJetMassCh->ConnectEventObject(fEventObjects); anaJetMassCh->SetHiEvtName("");//hiEventContainer"); anaJetMassCh->SetJetsName("GenJetsAKTR040"); handler->Add(anaJetMassCh); //anti-kt jet finder on gen particles all -> FULL jets LWJetProducer *lwjaktGenFull = new LWJetProducer("LWGenJetProducerAKTR030Full","LWGenJetProducerAKTR030Full"); //lwjaktGen->SetInput(chain); lwjaktGenFull->ConnectEventObject(fEventObjects); lwjaktGenFull->SetJetType(LWJetProducer::kAKT); lwjaktGenFull->SetRadius(0.4); lwjaktGenFull->SetGhostArea(0.005); lwjaktGenFull->SetPtMinConst(0.); lwjaktGenFull->SetChargedOnly(false); lwjaktGenFull->SetParticlesName("genParticles"); lwjaktGenFull->SetJetContName("GenJetsAKTR040Full"); lwjaktGenFull->SetDoConstituentSubtraction(kFALSE); handler->Add(lwjaktGenFull); anaJetMass *anaJetMassFull = new anaJetMass("anaJetMassFullR040","anaJetMassFullR040"); anaJetMassFull->ConnectEventObject(fEventObjects); anaJetMassFull->SetHiEvtName("");//hiEventContainer"); anaJetMassFull->SetJetsName("GenJetsAKTR040Full"); handler->Add(anaJetMassFull); //--------------------------------------------------------------- //Event loop //--------------------------------------------------------------- Long64_t entries_tot = chain->GetEntries(); //93064 if(nentries<0) lastEvent = chain->GetEntries(); Printf("nentries: %lld tot: %lld",nentries,entries_tot); lastEvent = std::min((int)entries_tot,lastEvent); Printf("firstEvent: %d lastEvent: %d",firstEvent,lastEvent); for (Long64_t jentry=firstEvent; jentry<lastEvent; ++jentry) { if(jentry%10000==0) cout << "entry: "<< jentry << endl; //Run producers //Printf("produce hiEvent"); //p_evt->Run(jentry); //hi event properties p_gen->Run(jentry); //generated particles //Execute all analysis tasks handler->ExecuteTask(); } fEventObjects->Print(); TFile *out = new TFile(outname,"RECREATE"); TList *tasks = handler->GetListOfTasks(); TIter next(tasks); anaBaseTask *obj; while ((obj = dynamic_cast<anaBaseTask*>(next()) )) if(obj->GetOutput()) obj->GetOutput()->Write(obj->GetName(),TObject::kSingleKey); out->Write(); out->Close(); }
void analyzeJES(std::vector<std::string> urls, const char *outname = "eventObjects.root", Long64_t nentries = 20, Int_t firstF = -1, Int_t lastF = -1, Int_t firstEvent = 0) { /* ptminType: minimum raw pt for particles used by puppi 0 : 0 GeV 1 : 1 GeV 2 : 2 GeV jetSignalType: jets used to select jetty region in events 0 : detector-level jets (akPu4PF) 1 : particle-level jets (gen jets) */ TString jetName = "aktPuppiR040"; TString jetTreeName = "akPuppi4PFJetAnalyzer"; jetName = "aktCsR040"; jetTreeName = "akCs4PFJetAnalyzer"; //jetName = "aktVsR040"; //jetTreeName = "akVs4PFJetAnalyzer"; std::cout << "analyzing JES for: " << jetName << " tree: " << jetTreeName << std::endl; std::cout << "nfiles: " << urls.size() << std::endl; for (auto i = urls.begin(); i != urls.end(); ++i) std::cout << *i << std::endl; size_t firstFile = 0; size_t lastFile = urls.size(); if(firstF>-1) { firstFile = (size_t)firstF; lastFile = std::min((size_t)lastF,lastFile); } std::cout << "firstFile: " << firstFile << " lastFile: " << lastFile << std::endl; Int_t lastEvent = nentries; if(firstEvent>0) { lastEvent = firstEvent + nentries; } std::cout << "firstEvent: " << firstEvent << std::endl; //add files to chain TChain *chain = NULL; chain = new TChain("hiEvtAnalyzer/HiTree"); for(size_t i=firstFile; i<lastFile; i++) chain->Add(urls[i].c_str()); Printf("hiTree done"); TChain *jetTree = new TChain(Form("%s/t",jetTreeName.Data())); for(size_t i=firstFile; i<lastFile; i++) jetTree->Add(urls[i].c_str()); chain->AddFriend(jetTree); Printf("jetTree done"); TList *fEventObjects = new TList(); //--------------------------------------------------------------- // producers // hiEventProducer *p_evt = new hiEventProducer("hiEvtProd"); p_evt->SetInput(chain); p_evt->SetHIEventContName("hiEventContainer"); p_evt->SetEventObjects(fEventObjects); lwJetFromForestProducer *p_PUJet = new lwJetFromForestProducer("lwJetForestProd"); p_PUJet->SetInput(chain); p_PUJet->SetJetContName(jetName); p_PUJet->SetGenJetContName("akt4Gen"); p_PUJet->SetEventObjects(fEventObjects); p_PUJet->SetRadius(0.4); //--------------------------------------------------------------- //analysis modules // //handler to which all modules will be added anaBaseTask *handler = new anaBaseTask("handler","handler"); anaJetEnergyScale *anajesForest = new anaJetEnergyScale("anaJESForest","anaJESForest"); anajesForest->ConnectEventObject(fEventObjects); anajesForest->SetHiEvtName("hiEventContainer"); anajesForest->SetGenJetsName("akt4Gen"); anajesForest->SetRecJetsName(jetName); anajesForest->SetNCentBins(4); anajesForest->SetUseForestMatching(true); //anajesForest->SetMaxDistance(0.2); handler->Add(anajesForest); anaJetEnergyScale *anajesForestQuarks = new anaJetEnergyScale("anaJESForestQuarks","anaJESForestQuarks"); anajesForestQuarks->ConnectEventObject(fEventObjects); anajesForestQuarks->SetHiEvtName("hiEventContainer"); anajesForestQuarks->SetGenJetsName("akt4Gen"); anajesForestQuarks->SetRecJetsName(jetName); anajesForestQuarks->SetNCentBins(4); anajesForestQuarks->SetUseForestMatching(true); //anajesForestQuarks->SetMaxDistance(0.2); anajesForestQuarks->SetRefPartonFlavor(0,2); handler->Add(anajesForestQuarks); anaJetEnergyScale *anajesForestGluons = new anaJetEnergyScale("anaJESForestGluons","anaJESForestGluons"); anajesForestGluons->ConnectEventObject(fEventObjects); anajesForestGluons->SetHiEvtName("hiEventContainer"); anajesForestGluons->SetGenJetsName("akt4Gen"); anajesForestGluons->SetRecJetsName(jetName); anajesForestGluons->SetNCentBins(4); anajesForestGluons->SetUseForestMatching(true); //anajesForestGluons->SetMaxDistance(0.2); anajesForestGluons->SetRefPartonFlavor(21,21); handler->Add(anajesForestGluons); anaJetEnergyScale *anajesForestRaw = new anaJetEnergyScale("anaJESForestRaw","anaJESForestRaw"); anajesForestRaw->ConnectEventObject(fEventObjects); anajesForestRaw->SetHiEvtName("hiEventContainer"); anajesForestRaw->SetGenJetsName(""); anajesForestRaw->SetRecJetsName(jetName); anajesForestRaw->SetNCentBins(4); anajesForestRaw->SetUseForestMatching(true); anajesForestRaw->SetUseRawPt(true); //handler->Add(anajesForestRaw); //particle-detector-level jet matching anaJetMatching *match = new anaJetMatching("jetMatching","jetMatching"); match->ConnectEventObject(fEventObjects); match->SetHiEvtName("hiEventContainer"); //match->SetJetsNameBase(jetName); //match->SetJetsNameTag("akt4Gen"); match->SetJetsNameTag(jetName); match->SetJetsNameBase("akt4Gen"); match->SetMatchingType(0); //handler->Add(match); anaJetEnergyScale *anajes = new anaJetEnergyScale("anaJES","anaJES"); anajes->ConnectEventObject(fEventObjects); anajes->SetHiEvtName("hiEventContainer"); anajes->SetGenJetsName("akt4Gen"); anajes->SetRecJetsName(jetName); anajes->SetNCentBins(4); //handler->Add(anajes); anaJetEnergyScale *anajesRaw = new anaJetEnergyScale("anaJESRaw","anaJESRaw"); anajesRaw->ConnectEventObject(fEventObjects); anajesRaw->SetHiEvtName("hiEventContainer"); anajesRaw->SetGenJetsName("akt4Gen"); anajesRaw->SetRecJetsName(jetName); anajesRaw->SetNCentBins(4); anajesRaw->SetUseForestMatching(false); anajesRaw->SetUseRawPt(true); //handler->Add(anajesRaw); //--------------------------------------------------------------- //Event loop //--------------------------------------------------------------- Long64_t entries_tot = chain->GetEntries(); //93064 if(nentries<0) lastEvent = chain->GetEntries(); Printf("nentries: %lld tot: %lld",nentries,entries_tot); for (Long64_t jentry=firstEvent; jentry<lastEvent; ++jentry) { if(jentry%10000==0) cout << "entry: "<< jentry << endl; //Run producers //Printf("produce hiEvent"); p_evt->Run(jentry); //hi event properties //Printf("produce PU jets"); p_PUJet->Run(jentry); //forest jets //Execute all analysis tasks handler->ExecuteTask(); } fEventObjects->Print(); TFile *out = new TFile(outname,"RECREATE"); TList *tasks = handler->GetListOfTasks(); TIter next(tasks); anaBaseTask *obj; while ((obj = dynamic_cast<anaBaseTask*>(next()) )) if(obj->GetOutput()) obj->GetOutput()->Write(obj->GetName(),TObject::kSingleKey); out->Write(); out->Close(); }
void analyzePuppi(std::vector<std::string> urls, const char *outname = "eventObjects.root", Long64_t nentries = 20, Int_t firstF = -1, Int_t lastF = -1) { // std::vector<std::string> urls = CollectFiles(list); // Printf("anaFile: %d",anaFile); std::cout << "nfiles: " << urls.size() << std::endl; for (auto i = urls.begin(); i != urls.end(); ++i) std::cout << *i << std::endl; size_t firstFile = 0; size_t lastFile = urls.size(); if(firstF>-1) { firstFile = (size_t)firstF; lastFile = (size_t)lastF; } std::cout << "firstFile: " << firstFile << " lastFile: " << lastFile << std::endl; //add files to chain TChain *chain = NULL; chain = new TChain("hiEvtAnalyzer/HiTree"); for(size_t i=firstFile; i<lastFile; i++) chain->Add(urls[i].c_str()); Printf("hiTree done"); TChain *pfTree = new TChain("pfcandAnalyzer/pfTree"); for(size_t i=firstFile; i<lastFile; i++) pfTree->Add(urls[i].c_str()); chain->AddFriend(pfTree); Printf("pfTree done"); // TChain *muTree = new TChain("hltMuTree/HLTMuTree"); // for(size_t i=firstFile; i<lastFile; i++) muTree->Add(urls[i].c_str()); // chain->AddFriend(muTree); // Printf("muTree done"); //TChain *jetTree = new TChain("akPu3PFJetAnalyzer/t"); TChain *jetTree = new TChain("akPu2PFJetAnalyzer10/t"); for(size_t i=firstFile; i<lastFile; i++) jetTree->Add(urls[i].c_str()); chain->AddFriend(jetTree); Printf("jetTree done"); TChain *genTree = new TChain("HiGenParticleAna/hi"); for(size_t i=firstFile; i<lastFile; i++) genTree->Add(urls[i].c_str()); chain->AddFriend(genTree); Printf("genTree done"); TList *fEventObjects = new TList(); //--------------------------------------------------------------- // producers // hiEventProducer *p_evt = new hiEventProducer("hiEvtProd"); p_evt->SetInput(chain); p_evt->SetHIEventContName("hiEventContainer"); p_evt->SetEventObjects(fEventObjects); pfParticleProducer *p_pf = new pfParticleProducer("pfPartProd"); p_pf->SetInput(chain); p_pf->SetpfParticlesName("pfParticles"); p_pf->SetEventObjects(fEventObjects); genParticleProducer *p_gen = new genParticleProducer("genParticleProd"); p_gen->SetInput(chain); p_gen->SetGenParticlesName("genParticles"); p_gen->SetEventObjects(fEventObjects); lwJetFromForestProducer *p_PUJet = new lwJetFromForestProducer("lwJetForestProd"); p_PUJet->SetInput(chain); p_PUJet->SetJetContName("aktPUR030"); p_PUJet->SetEventObjects(fEventObjects); p_PUJet->SetRadius(0.3); //--------------------------------------------------------------- //analysis modules // //handler to which all modules will be added anaBaseTask *handler = new anaBaseTask("handler","handler"); //analysis modules which also produce anaPuppiProducer *pupProd = new anaPuppiProducer("pupProd","pupProd"); pupProd->ConnectEventObject(fEventObjects); pupProd->SetHiEvtName("hiEventContainer"); pupProd->SetPFPartName("pfParticles"); pupProd->SetPuppiPartName("puppiParticles"); pupProd->SetJetsName("aktPUR030"); pupProd->SetAddMetricType(anaPuppiProducer::kMass); if(doPuppi) handler->Add(pupProd); //anti-kt jet finder on reconstructed PUPPI particles ptmin=0 LWJetProducer *lwjakt = new LWJetProducer("LWJetProducerAKTR030Puppi","LWJetProducerAKTR030Puppi"); lwjakt->ConnectEventObject(fEventObjects); lwjakt->SetJetType(LWJetProducer::kAKT); lwjakt->SetRadius(0.3); lwjakt->SetGhostArea(0.005); lwjakt->SetPtMinConst(0.); lwjakt->SetParticlesName("puppiParticles"); lwjakt->SetJetContName("JetsAKTR030Puppi"); if(doPuppi) handler->Add(lwjakt); //anti-kt jet finder on reconstructed PUPPI particles ptmin=1 LWJetProducer *lwjaktpt100 = new LWJetProducer("LWJetProducerAKTR030PuppiPtMin100","LWJetProducerAKTR030PuppiPtMin100"); lwjaktpt100->ConnectEventObject(fEventObjects); lwjaktpt100->SetJetType(LWJetProducer::kAKT); lwjaktpt100->SetRadius(0.3); lwjaktpt100->SetGhostArea(0.005); lwjaktpt100->SetPtMinConst(1.); lwjaktpt100->SetParticlesName("puppiParticles"); lwjaktpt100->SetJetContName("JetsAKTR030PuppiPtMin100"); if(doPuppi) handler->Add(lwjaktpt100); //anti-kt jet finder on reconstructed PUPPI particles ptmin=2 LWJetProducer *lwjaktpt200 = new LWJetProducer("LWJetProducerAKTR030PuppiPtMin200","LWJetProducerAKTR030PuppiPtMin200"); lwjaktpt200->ConnectEventObject(fEventObjects); lwjaktpt200->SetJetType(LWJetProducer::kAKT); lwjaktpt200->SetRadius(0.3); lwjaktpt200->SetGhostArea(0.005); lwjaktpt200->SetPtMinConst(2.); lwjaktpt200->SetParticlesName("puppiParticles"); lwjaktpt200->SetJetContName("JetsAKTR030PuppiPtMin200"); if(doPuppi) handler->Add(lwjaktpt200); //anti-kt jet finder on generated particles LWJetProducer *lwjaktGen = new LWJetProducer("LWGenJetProducerAKTR030","LWGenJetProducerAKTR030"); lwjaktGen->ConnectEventObject(fEventObjects); lwjaktGen->SetJetType(LWJetProducer::kAKT); lwjaktGen->SetRadius(0.3); lwjaktGen->SetGhostArea(0.005); lwjaktGen->SetPtMinConst(0.); lwjaktGen->SetParticlesName("genParticles"); lwjaktGen->SetJetContName("GenJetsAKTR030"); handler->Add(lwjaktGen); //Initialization of all analysis modules anaPuppiParticles *pupAna = new anaPuppiParticles("pupAna","pupAna"); pupAna->ConnectEventObject(fEventObjects); pupAna->SetHiEvtName("hiEventContainer"); pupAna->SetParticlesName("pfParticles"); pupAna->SetJetsName("aktPUR030"); if(doPuppi) handler->Add(pupAna); //particle-detector-level jet matching anaJetMatching *match = new anaJetMatching("jetMatching","jetMatching"); match->ConnectEventObject(fEventObjects); match->SetHiEvtName("hiEventContainer"); match->SetJetsNameBase("JetsAKTR030Puppi"); match->SetJetsNameTag("GenJetsAKTR030"); if(doPuppi) handler->Add(match); anaJetMatching *matchPt100 = new anaJetMatching("jetMatchingPtMin100","jetMatchingPtMin100"); matchPt100->ConnectEventObject(fEventObjects); matchPt100->SetHiEvtName("hiEventContainer"); matchPt100->SetJetsNameBase("JetsAKTR030PuppiPtMin100"); matchPt100->SetJetsNameTag("GenJetsAKTR030"); if(doPuppi) handler->Add(matchPt100); anaJetMatching *matchPt200 = new anaJetMatching("jetMatchingPtMin200","jetMatchingPtMin200"); matchPt200->ConnectEventObject(fEventObjects); matchPt200->SetHiEvtName("hiEventContainer"); matchPt200->SetJetsNameBase("JetsAKTR030PuppiPtMin200"); matchPt200->SetJetsNameTag("GenJetsAKTR030"); if(doPuppi) handler->Add(matchPt200); //--------------------------------------------------------------- //Event loop //--------------------------------------------------------------- Long64_t entries_tot = chain->GetEntriesFast(); //93064 if(nentries<0) nentries = chain->GetEntries(); // Long64_t nentries = 20;//chain->GetEntriesFast(); Printf("nentries: %lld tot: %lld",nentries,entries_tot); for (Long64_t jentry=0; jentry<nentries;jentry++) { //Run producers Printf("produce hiEvent"); p_evt->Run(jentry); //hi event properties Printf("produce pf particles"); p_pf->Run(jentry); //pf particles Printf("produce gen particles"); p_gen->Run(jentry); //generated particles Printf("produce PU jets"); p_PUJet->Run(jentry); //forest jets //Execute all analysis tasks // handler->ExecuteTask(); } fEventObjects->Print(); TFile *out = new TFile(outname,"RECREATE"); TList *tasks = handler->GetListOfTasks(); TIter next(tasks); anaBaseTask *obj; while ((obj = dynamic_cast<anaBaseTask*>(next()) )) if(obj->GetOutput()) obj->GetOutput()->Write(obj->GetName(),TObject::kSingleKey); out->Write(); out->Close(); }
void qaitsAddMetadata(TTree*tree, Int_t verbose){ // // Set metadata infomation // if (tree==NULL) { ::Error("qaitsAddMetadata","Start processing. Emtpy tree"); return; } ::Info("qaitsAddMetadata","Start processing Tree %s",tree->GetName()); TObjArray * branches=tree->GetListOfBranches(); // Clasigication of variables // regular expression to defined automaticaly some variables following naming conventions - used to define classes/Axis/legends // default description // regular expression used can be tested on site https://regex101.com/ // hovewer root (perl) regular expression looks to be in some cases different - in some case double escape had to be used // e.g to math c. expression c\\. has to be used // variables const TString kineVariableClass[11]={"X", "Y","Z", "Phi", "Theta", "Pt", "QOverPt"}; const TString kineVariableAxisTitle[11]={"x(cm)", "y(cm)","z(cm)", "#phi", "#Theta", "p_{T}", "q/p_{T}(c/GeV)"}; const TString kineVariableLegend[11]={"x", "y","z", "#phi", "#Theta", "p_{T}", "q/p_{T}"}; const TString kineVariableTitle[11]={"x", "y","z", "#phi", "#Theta", "p_{T}", "q/p_{T}"}; TPRegexp regKineVariables[11]; regKineVariables[0]=TPRegexp("^x|x$"); // X - varaible begining on X regKineVariables[1]=TPRegexp("(^y|^infoy|y$)"); // Y - regKineVariables[2]=TPRegexp("(^z|^infoz|z$)"); // Z regKineVariables[3]=TPRegexp("(phi|infophi)"); // phi regKineVariables[4]=TPRegexp("(theta|lambda|infolambda)"); // theta regKineVariables[5]=TPRegexp("(^pt)"); // pt regKineVariables[6]=TPRegexp("qoverpt"); // qoverPt // // QA variables const TString qaVariableClass[11]={"Frac", "$","dEdx","ChargeRatio"}; const TString qaVariableAxisTitle[11]={"Frac","$","dEdx","ChargeRatio"}; const TString qaVariableLegend[11]={"Frac","$","dEdx","ChargeRatio"}; const TString qaVariableTitle[11]={"Frac","$","dEdx","ChargeRatio"}; TPRegexp regQAVariable[11]; regQAVariable[0]=TPRegexp("frac"); // Frac regQAVariable[1]=TPRegexp("(eff[0-9]|effone|^eff)"); // eff layer? regQAVariable[2]=TPRegexp("(mpv|dedx)"); // dEdx regQAVariable[3]=TPRegexp("chargeratio"); // ChargeRatio // // statistic // const TString statClass[10]={"Constrain", "Mean","Delta","Median", "RMS","Pull", "Err","Chi2", "StatInfo[]","FitInfo[]"}; const TString statAxisTitle[10]={"Constrain", "mean","#Delta","med.", "rms","pull", "#sigma"," #chi2","stat[]","fit[]"}; const TString statTitle[10]={"Constrain", "mean","#Delta","med.", "rms","pull", "#sigma"," #chi2","stat[]","fit[]" }; TPRegexp regStat[10]; regStat[0]=TPRegexp("constrain"); // constrain regStat[1]=TPRegexp("^mean"); // mean regStat[2]=TPRegexp("^delta"); // delta regStat[3]=TPRegexp("^median"); // median variable regStat[4]=TPRegexp("(^rms|resolution|sigma)");// rms resolution regStat[5]=TPRegexp("pull"); // pull regStat[6]=TPRegexp("err"); // error regStat[7]=TPRegexp("chi2"); // chi2 regStat[8]=TPRegexp("^info"); // stat info array regStat[9]=TPRegexp("^fit"); // fit info array // // const TString categoryClass[10]={"Vertex","$1","$1"}; const TString categoryLegend[10]={"Vertex","$1","$1"}; const TString categoryTitle[10]={"Vertex","$1","$1"}; TPRegexp regCategory[10]; // proper parsing of layer numbers to be added regCategory[0]=TPRegexp("(vertex|vtx)"); // regCategory[1]=TPRegexp("s(p|d|d)d[0-2]?"); // reg.exp match silical layers+number regCategory[2]=TPRegexp("pt[0-9]+"); // pt bin for (Int_t ibr=0; ibr<branches->GetEntriesFast(); ibr++){ TBranch * branch = (TBranch*)branches->At(ibr); TString matchClass=""; // class match TString brClass=""; TString brAxisTitle=""; TString brTitle=""; TString brLegend=""; // TString brNameCase(branches->At(ibr)->GetName()); brNameCase.ToLower(); // // define met brClass="ITS"; brAxisTitle=""; // stat for (Int_t ivar=0; ivar<11; ivar++) if (brNameCase.Contains( regStat[ivar])) { brClass+=" "+statClass[ivar]; brTitle+=statTitle[ivar]; } // kine variables for (Int_t ivar=0; ivar<7; ivar++) if (brNameCase.Contains( regKineVariables[ivar])) { brClass+=" "+kineVariableClass[ivar]; brAxisTitle+=" "+kineVariableAxisTitle[ivar]; brTitle+=" "+kineVariableTitle[ivar]; brLegend+=" "+kineVariableLegend[ivar]; } // QA variables for (Int_t ivar=0; ivar<5; ivar++) if (brNameCase.Contains( regQAVariable[ivar])) { if ( qaVariableClass[ivar].Contains("$")==kFALSE){ brClass+=" "+ qaVariableClass[ivar]; brLegend+=" "+ qaVariableLegend[ivar]; brTitle+=" "+ qaVariableTitle[ivar]; }else{ TObjArray *amatch=regQAVariable[ivar].MatchS(brNameCase); if (amatch){ TString match=amatch->At(0)->GetName(); brClass+=" "+match; brLegend+=" "+match; brTitle+=" "+match; } } } // category for (Int_t ivar=0; ivar<3; ivar++) if (brNameCase.Contains(regCategory[ivar])) { if (categoryClass[ivar].Contains("$")==kFALSE){ brClass+=" "+categoryClass[ivar]; brLegend+=" "+categoryLegend[ivar]; brTitle+=" "+categoryTitle[ivar]; }else{ TObjArray *amatch=regCategory[ivar].MatchS(brNameCase); if (amatch){ TString match=amatch->At(0)->GetName(); brClass+=" "+match; brLegend+=" "+match; brTitle+=" "+match; } } } if (branch!=NULL && branch->GetClassName()!=NULL && strlen(branch->GetClassName())>0){ brClass+=" Class:"; brClass+=branch->GetClassName(); } // TStatToolkit::AddMetadata(tree,TString::Format("%s.Description",branches->At(ibr)->GetName()).Data(), TString::Format("ITS standard QA variables. Class %s", brClass.Data()).Data()); TStatToolkit::AddMetadata(tree,TString::Format("%s.class",branches->At(ibr)->GetName()).Data(),brClass.Data()); TStatToolkit::AddMetadata(tree,TString::Format("%s.AxisTitle",branches->At(ibr)->GetName()).Data(),brAxisTitle.Data()); TStatToolkit::AddMetadata(tree,TString::Format("%s.Title",branches->At(ibr)->GetName()).Data(),brTitle.Data()); TStatToolkit::AddMetadata(tree,TString::Format("%s.Legend",branches->At(ibr)->GetName()).Data(),brLegend.Data()); if (verbose&4) printf("Class %s: \t%s\n", branches->At(ibr)->GetName(),brClass.Data()); if (verbose&8) printf("Axis title %s: \t%s\n", branches->At(ibr)->GetName(),brAxisTitle.Data()); if (verbose&16) printf("Title %s: \t%s\n", branches->At(ibr)->GetName(),brTitle.Data()); if (verbose&32) printf("Legend %s: \t%s\n", branches->At(ibr)->GetName(),brLegend.Data()); } // Fill Based and custom metadata // // Index TStatToolkit::AddMetadata(tree,"run.class","Base Index"); TStatToolkit::AddMetadata(tree,"run.Title","run"); TStatToolkit::AddMetadata(tree,"run.AxisTitle","run"); // TList * mlist = (TList*)(tree->GetUserInfo()->FindObject("metaTable")); mlist->Sort(); if ((verbose&1)>0){ mlist->Print(); } if ((verbose&2)>0){ AliTreePlayer::selectMetadata(tree, "[class==\"\"]",0)->Print(); } ::Info("qaitsAddMetadata","End"); }
void analyzeZgHistos(std::vector<std::string> urls, const char *outname = "eventObjects.root", Long64_t nentries = 20, Int_t firstF = -1, Int_t lastF = -1, Int_t firstEvent = 0, int activateJetShift = 0) { /* ptminType: minimum raw pt for particles used by puppi 0 : 0 GeV 1 : 1 GeV 2 : 2 GeV jetSignalType: jets used to select jetty region in events 0 : detector-level jets (akPu4PF) 1 : particle-level jets (gen jets) */ TString jetSDName = "aktCs4PFSoftDrop"; TString jetTreeSDName = "akCsSoftDrop4PFJetAnalyzer";//"akCs4PFSoftDropJetAnalyzer";// TString jetName = "aktPu4Calo"; TString jetTreeName = "akPu4CaloJetAnalyzer"; bool doDRVar = false; bool doJetShift = false; if(activateJetShift>0) doJetShift = true; float jetShift = 0.04; if(activateJetShift==1) jetShift = 0.04; if(activateJetShift==2) jetShift = -0.04; double minptjet = 30.; //bool doDijet = false; //if(!doDijet) minptjet = 80.; std::cout << "analyzing subjets for: " << jetName << " tree: " << jetTreeName << std::endl; std::cout << "analyzing subjets for: " << jetSDName << " tree: " << jetTreeSDName << std::endl; std::cout << "nfiles: " << urls.size() << std::endl; for (auto i = urls.begin(); i != urls.end(); ++i) std::cout << *i << std::endl; size_t firstFile = 0; size_t lastFile = urls.size(); if(firstF>-1) { firstFile = (size_t)firstF; lastFile = std::min((size_t)lastF,lastFile); } std::cout << "firstFile: " << firstFile << " lastFile: " << lastFile << std::endl; Int_t lastEvent = nentries; if(firstEvent>0) { lastEvent = firstEvent + nentries; } std::cout << "firstEvent: " << firstEvent << std::endl; //add files to chain TChain *chain = NULL; chain = new TChain("hiEvtAnalyzer/HiTree"); for(size_t i=firstFile; i<lastFile; i++) chain->Add(urls[i].c_str()); Printf("hiTree done"); TChain *skimTree = new TChain("skimanalysis/HltTree"); for(size_t i=firstFile; i<lastFile; i++) skimTree->Add(urls[i].c_str()); chain->AddFriend(skimTree); Printf("skimTree done"); TChain *hltTree = new TChain("hltanalysis/HltTree"); for(size_t i=firstFile; i<lastFile; i++) hltTree->Add(urls[i].c_str()); chain->AddFriend(hltTree); Printf("hltTree done"); TChain *jetTreeSD = new TChain(Form("%s/t",jetTreeSDName.Data())); for(size_t i=firstFile; i<lastFile; i++) jetTreeSD->Add(urls[i].c_str()); chain->AddFriend(jetTreeSD); Printf("jetTreeSD done"); TChain *jetTree = new TChain(Form("%s/t",jetTreeName.Data())); for(size_t i=firstFile; i<lastFile; i++) jetTree->Add(urls[i].c_str()); Printf("jetTree done"); TChain *rhoTree = new TChain("hiFJRhoAnalyzer/t"); for(size_t i=firstFile; i<lastFile; i++) rhoTree->Add(urls[i].c_str()); chain->AddFriend(rhoTree); TList *fEventObjects = new TList(); //--------------------------------------------------------------- // producers // hiEventProducer *p_evt = new hiEventProducer("hiEvtProd"); p_evt->SetInput(chain); p_evt->SetHIEventContName("hiEventContainer"); p_evt->SetEventObjects(fEventObjects); triggerProducer *p_trg = new triggerProducer("trigProd"); p_trg->SetInput(chain); p_trg->SetTriggerMapName("triggerMap"); p_trg->AddTrigger("HLT_HIPuAK4CaloJet100_Eta5p1_v1"); p_trg->AddTrigger("HLT_HIPuAK4CaloJet100_Eta5p1_Cent30_100_v1"); p_trg->SetEventObjects(fEventObjects); lwJetFromForestProducer *p_SDJet = new lwJetFromForestProducer("lwJetForestProdSD"); p_SDJet->SetInput(chain); p_SDJet->SetJetContName(jetSDName); p_SDJet->SetGenJetContName(""); p_SDJet->SetEventObjects(fEventObjects); p_SDJet->SetMinJetPt(minptjet); p_SDJet->SetRadius(0.4); lwJetFromForestProducer *p_Jet = new lwJetFromForestProducer("lwJetForestProd"); p_Jet->SetInput(jetTree); p_Jet->SetJetContName(jetName); p_Jet->SetGenJetContName("akt4Gen"); p_Jet->SetEventObjects(fEventObjects); p_Jet->SetMinJetPt(minptjet); p_Jet->SetRadius(0.4); //--------------------------------------------------------------- //analysis modules // //handler to which all modules will be added anaBaseTask *handler = new anaBaseTask("handler","handler"); anaJetQA *jetQA = new anaJetQA("anaJetQA","anaJetQA"); jetQA->ConnectEventObject(fEventObjects); jetQA->SetJetsName(jetName); jetQA->SetTriggerMapName("triggerMap"); jetQA->AddTriggerSel("HLT_HIPuAK4CaloJet100_Eta5p1_v1"); jetQA->AddTriggerSel("HLT_HIPuAK4CaloJet100_Eta5p1_Cent30_100_v1"); handler->Add(jetQA); anaJetMatching *match = new anaJetMatching("jetMatching","jetMatching"); match->ConnectEventObject(fEventObjects); match->SetHiEvtName("hiEventContainer"); match->SetTriggerMapName("triggerMap"); match->AddTriggerSel("HLT_HIPuAK4CaloJet100_Eta5p1_v1"); match->AddTriggerSel("HLT_HIPuAK4CaloJet100_Eta5p1_Cent30_100_v1"); match->SetJetsNameBase(jetName); match->SetJetsNameTag(jetSDName); match->SetMatchingType(0); handler->Add(match); anaZgHistos *anazghistos = new anaZgHistos("anaZgHistos","anaZgHistos"); anazghistos->ConnectEventObject(fEventObjects); anazghistos->SetHiEvtName("hiEventContainer"); anazghistos->DoCollisionEventSel(true); anazghistos->DoHBHENoiseFilter(true); anazghistos->DoHBHENoiseFilterLoose(true); anazghistos->DoPrimaryVertexFilter(true); anazghistos->DoClusterCompatibilityFilter(true); anazghistos->DoHFCoincFilter(true); anazghistos->SetTriggerMapName("triggerMap"); anazghistos->AddTriggerSel("HLT_HIPuAK4CaloJet100_Eta5p1_v1"); anazghistos->AddTriggerSel("HLT_HIPuAK4CaloJet100_Eta5p1_Cent30_100_v1"); anazghistos->SetRhoMax(330.); anazghistos->SetJetsName(jetSDName); anazghistos->SetJetsRefName(jetName); anazghistos->SetNCentBins(4); anazghistos->SetJetEtaRange(-1.3,1.3); anazghistos->SetDeltaRRange(0.1,999.); anazghistos->DoJetShift(doJetShift,jetShift); handler->Add(anazghistos); anaZgHistos *anazghistosdrSmall = new anaZgHistos("anaZgHistosDrSmall","anaZgHistosDrSmall"); anazghistosdrSmall->ConnectEventObject(fEventObjects); anazghistosdrSmall->SetHiEvtName("hiEventContainer"); anazghistosdrSmall->DoCollisionEventSel(true); anazghistosdrSmall->DoHBHENoiseFilter(true); anazghistosdrSmall->DoHBHENoiseFilterLoose(true); anazghistosdrSmall->DoPrimaryVertexFilter(true); anazghistosdrSmall->DoClusterCompatibilityFilter(true); anazghistosdrSmall->DoHFCoincFilter(true); anazghistosdrSmall->SetTriggerMapName("triggerMap"); anazghistosdrSmall->AddTriggerSel("HLT_HIPuAK4CaloJet100_Eta5p1_v1"); anazghistosdrSmall->AddTriggerSel("HLT_HIPuAK4CaloJet100_Eta5p1_Cent30_100_v1"); anazghistosdrSmall->SetRhoMax(330.); anazghistosdrSmall->SetJetsName(jetSDName); anazghistosdrSmall->SetJetsRefName(jetName); anazghistosdrSmall->SetNCentBins(4); anazghistosdrSmall->SetJetEtaRange(-1.3,1.3); anazghistosdrSmall->SetDeltaRRange(0.1,0.2); anazghistosdrSmall->DoJetShift(doJetShift,jetShift); handler->Add(anazghistosdrSmall); anaZgHistos *anazghistosdrLarge = new anaZgHistos("anaZgHistosDrLarge","anaZgHistosDrLarge"); anazghistosdrLarge->ConnectEventObject(fEventObjects); anazghistosdrLarge->SetHiEvtName("hiEventContainer"); anazghistosdrLarge->DoCollisionEventSel(true); anazghistosdrLarge->DoHBHENoiseFilter(true); anazghistosdrLarge->DoHBHENoiseFilterLoose(true); anazghistosdrLarge->DoPrimaryVertexFilter(true); anazghistosdrLarge->DoClusterCompatibilityFilter(true); anazghistosdrLarge->DoHFCoincFilter(true); anazghistosdrLarge->SetTriggerMapName("triggerMap"); anazghistosdrLarge->AddTriggerSel("HLT_HIPuAK4CaloJet100_Eta5p1_v1"); anazghistosdrLarge->AddTriggerSel("HLT_HIPuAK4CaloJet100_Eta5p1_Cent30_100_v1"); anazghistosdrLarge->SetRhoMax(330.); anazghistosdrLarge->SetJetsName(jetSDName); anazghistosdrLarge->SetJetsRefName(jetName); anazghistosdrLarge->SetNCentBins(4); anazghistosdrLarge->SetJetEtaRange(-1.3,1.3); anazghistosdrLarge->SetDeltaRRange(0.2,999.); anazghistosdrLarge->DoJetShift(doJetShift,jetShift); handler->Add(anazghistosdrLarge); if(doDRVar) { anaZgHistos *anazghistosDRVarDown = new anaZgHistos("anaZgHistosDrVarDown","anaZgHistosDrVarDown"); anazghistosDRVarDown->ConnectEventObject(fEventObjects); anazghistosDRVarDown->SetHiEvtName("hiEventContainer"); anazghistosDRVarDown->DoCollisionEventSel(true); anazghistosDRVarDown->DoHBHENoiseFilter(true); anazghistosDRVarDown->DoHBHENoiseFilterLoose(true); anazghistosDRVarDown->DoPrimaryVertexFilter(true); anazghistosDRVarDown->DoClusterCompatibilityFilter(true); anazghistosDRVarDown->DoHFCoincFilter(true); anazghistosDRVarDown->SetTriggerMapName("triggerMap"); anazghistosDRVarDown->AddTriggerSel("HLT_HIPuAK4CaloJet100_Eta5p1_v1"); anazghistosDRVarDown->AddTriggerSel("HLT_HIPuAK4CaloJet100_Eta5p1_Cent30_100_v1"); anazghistosDRVarDown->SetRhoMax(330.); anazghistosDRVarDown->SetJetsName(jetSDName); anazghistosDRVarDown->SetJetsRefName(jetName); anazghistosDRVarDown->SetNCentBins(4); anazghistosDRVarDown->SetJetEtaRange(-1.3,1.3); anazghistosDRVarDown->SetDeltaRRange(0.1*0.85,999.); anazghistosDRVarDown->DoJetShift(doJetShift,jetShift); handler->Add(anazghistosDRVarDown); anaZgHistos *anazghistosDRVarUp = new anaZgHistos("anaZgHistosDrVarUp","anaZgHistosDrVarUp"); anazghistosDRVarUp->ConnectEventObject(fEventObjects); anazghistosDRVarUp->SetHiEvtName("hiEventContainer"); anazghistosDRVarUp->DoCollisionEventSel(true); anazghistosDRVarUp->DoHBHENoiseFilter(true); anazghistosDRVarUp->DoHBHENoiseFilterLoose(true); anazghistosDRVarUp->DoPrimaryVertexFilter(true); anazghistosDRVarUp->DoClusterCompatibilityFilter(true); anazghistosDRVarUp->DoHFCoincFilter(true); anazghistosDRVarUp->SetTriggerMapName("triggerMap"); anazghistosDRVarUp->AddTriggerSel("HLT_HIPuAK4CaloJet100_Eta5p1_v1"); anazghistosDRVarUp->AddTriggerSel("HLT_HIPuAK4CaloJet100_Eta5p1_Cent30_100_v1"); anazghistosDRVarUp->SetRhoMax(330.); anazghistosDRVarUp->SetJetsName(jetSDName); anazghistosDRVarUp->SetJetsRefName(jetName); anazghistosDRVarUp->SetNCentBins(4); anazghistosDRVarUp->SetJetEtaRange(-1.3,1.3); anazghistosDRVarUp->SetDeltaRRange(0.1*1.15,999.); anazghistosDRVarUp->DoJetShift(doJetShift,jetShift); handler->Add(anazghistosDRVarUp); } //--------------------------------------------------------------- //Event loop //--------------------------------------------------------------- Long64_t entries_tot = chain->GetEntries(); //93064 if(nentries<0) lastEvent = chain->GetEntries(); Printf("nentries: %lld tot: %lld",nentries,entries_tot); for (Long64_t jentry=firstEvent; jentry<lastEvent; ++jentry) { if(jentry%10000==0) cout << "entry: "<< jentry << endl; //Run producers //Printf("produce hiEvent"); p_evt->Run(jentry); //hi event properties p_trg->Run(jentry); //Printf("produce jets"); p_SDJet->Run(jentry); //forest SoftDrop jets p_Jet->Run(jentry); //forest jets //Execute all analysis tasks handler->ExecuteTask(); } fEventObjects->Print(); TFile *out = new TFile(outname,"RECREATE"); TList *tasks = handler->GetListOfTasks(); TIter next(tasks); anaBaseTask *obj; while ((obj = dynamic_cast<anaBaseTask*>(next()) )) if(obj->GetOutput()) obj->GetOutput()->Write(obj->GetName(),TObject::kSingleKey); out->Write(); out->Close(); }
void analyzeSubJets(std::vector<std::string> urls, const char *outname = "eventObjects.root", Long64_t nentries = 20, Int_t firstF = -1, Int_t lastF = -1, Int_t firstEvent = 0) { /* ptminType: minimum raw pt for particles used by puppi 0 : 0 GeV 1 : 1 GeV 2 : 2 GeV jetSignalType: jets used to select jetty region in events 0 : detector-level jets (akPu4PF) 1 : particle-level jets (gen jets) */ TString jetSDName = "akt4PFSD"; TString jetTreeSDName = "akSoftDrop4PFJetAnalyzer"; TString jetSDChName = "akt4PFSDCh"; TString jetTreeSDChName = "akSoftDropCh4PFJetAnalyzer"; TString jetSD000Name = "akt4PFSDZCut000"; TString jetTreeSD000Name = "akSoftDropZCut0004PFJetAnalyzer"; TString jetName = "akt4PF"; TString jetTreeName = "ak4PFJetAnalyzer"; //jetName = "akCs4PFFilter"; //jetTreeName = "akCs4PFFilterJetAnalyzer"; double minptjet = 30.; bool doDijet = false; if(!doDijet) minptjet = 40.; std::cout << "analyzing subjets for: " << jetName << " tree: " << jetTreeName << std::endl; std::cout << "analyzing subjets for: " << jetSDName << " tree: " << jetTreeSDName << std::endl; std::cout << "nfiles: " << urls.size() << std::endl; for (auto i = urls.begin(); i != urls.end(); ++i) std::cout << *i << std::endl; size_t firstFile = 0; size_t lastFile = urls.size(); if(firstF>-1) { firstFile = (size_t)firstF; lastFile = std::min((size_t)lastF,lastFile); } std::cout << "firstFile: " << firstFile << " lastFile: " << lastFile << std::endl; Int_t lastEvent = nentries; if(firstEvent>0) { lastEvent = firstEvent + nentries; } std::cout << "firstEvent: " << firstEvent << std::endl; //add files to chain TChain *chain = NULL; chain = new TChain("hiEvtAnalyzer/HiTree"); for(size_t i=firstFile; i<lastFile; i++) chain->Add(urls[i].c_str()); Printf("hiTree done"); TChain *jetTreeSD = new TChain(Form("%s/t",jetTreeSDName.Data())); for(size_t i=firstFile; i<lastFile; i++) jetTreeSD->Add(urls[i].c_str()); chain->AddFriend(jetTreeSD); Printf("jetTreeSD done"); TChain *jetTreeSD000 = new TChain(Form("%s/t",jetTreeSD000Name.Data())); for(size_t i=firstFile; i<lastFile; i++) jetTreeSD000->Add(urls[i].c_str()); Printf("jetTreeSD000 done"); // TChain *jetTreeSDCh = new TChain(Form("%s/t",jetTreeSDChName.Data())); // for(size_t i=firstFile; i<lastFile; i++) jetTreeSDCh->Add(urls[i].c_str()); // Printf("jetTreeSDCh done"); TChain *jetTree = new TChain(Form("%s/t",jetTreeName.Data())); for(size_t i=firstFile; i<lastFile; i++) jetTree->Add(urls[i].c_str()); Printf("jetTree done"); TList *fEventObjects = new TList(); //--------------------------------------------------------------- // producers // hiEventProducer *p_evt = new hiEventProducer("hiEvtProd"); p_evt->SetInput(chain); p_evt->SetHIEventContName("hiEventContainer"); p_evt->SetEventObjects(fEventObjects); lwJetFromForestProducer *p_SDJet = new lwJetFromForestProducer("lwJetForestProdSD"); p_SDJet->SetInput(chain); p_SDJet->SetJetContName(jetSDName); p_SDJet->SetGenJetContName("akt4Gen"); p_SDJet->SetEventObjects(fEventObjects); p_SDJet->SetMinJetPt(minptjet); p_SDJet->SetRadius(0.4); lwJetFromForestProducer *p_SD000Jet = new lwJetFromForestProducer("lwJetForestProdSD000"); p_SD000Jet->SetInput(jetTreeSD000); p_SD000Jet->SetJetContName(jetSD000Name); p_SD000Jet->SetGenJetContName("akt4Gen000"); p_SD000Jet->SetEventObjects(fEventObjects); p_SD000Jet->SetMinJetPt(minptjet); p_SD000Jet->SetRadius(0.4); /* lwJetFromForestProducer *p_SDChJet = new lwJetFromForestProducer("lwJetForestProdSDCh"); p_SDChJet->SetInput(jetTreeSDCh); p_SDChJet->SetJetContName(jetSDChName); p_SDChJet->SetGenJetContName("akt4GenCh"); p_SDChJet->SetEventObjects(fEventObjects); p_SDChJet->SetMinJetPt(minptjet); p_SDChJet->SetRadius(0.4); */ lwJetFromForestProducer *p_Jet = new lwJetFromForestProducer("lwJetForestProd"); p_Jet->SetInput(jetTree); p_Jet->SetJetContName(jetName); p_Jet->SetGenJetContName("");//akt4Gen"); p_Jet->SetEventObjects(fEventObjects); p_Jet->SetMinJetPt(minptjet); p_Jet->SetRadius(0.4); //--------------------------------------------------------------- //analysis modules // //handler to which all modules will be added anaBaseTask *handler = new anaBaseTask("handler","handler"); anaJetQA *jetQA = new anaJetQA("anaJetQA","anaJetQA"); jetQA->ConnectEventObject(fEventObjects); jetQA->SetJetsName(jetName); handler->Add(jetQA); anaJetMatching *match = new anaJetMatching("jetMatching","jetMatching"); match->ConnectEventObject(fEventObjects); match->SetHiEvtName("hiEventContainer"); match->SetNCentBins(1); match->SetJetsNameBase(jetName); match->SetJetsNameTag(jetSDName); match->SetMatchingType(0); handler->Add(match); anaJetMatching *match000 = new anaJetMatching("jetMatching000","jetMatching000"); match000->ConnectEventObject(fEventObjects); match000->SetHiEvtName("hiEventContainer"); match000->SetNCentBins(1); match000->SetJetsNameBase(jetName); match000->SetJetsNameTag(jetSD000Name); match000->SetMatchingType(0); match000->SetMatchId(2); handler->Add(match000); anaSubJet *anasubjets = new anaSubJet("anaSubJets","anaSubJets"); anasubjets->ConnectEventObject(fEventObjects); anasubjets->SetHiEvtName("hiEventContainer"); anasubjets->SetJetsName(jetSDName); anasubjets->SetJetsRefName(jetName); anasubjets->SetJets000Name(jetSD000Name); anasubjets->SetNCentBins(1); //anasubjets->SetJetEtaRange(-2.,2.); anasubjets->SetJetEtaRange(-1.3,1.3); anasubjets->SetDoDijets(doDijet); anasubjets->AddLeadingJetPtBin(120.,150.); anasubjets->AddLeadingJetPtBin(150.,180.); anasubjets->AddLeadingJetPtBin(180.,220.); anasubjets->AddLeadingJetPtBin(220.,260.); anasubjets->AddLeadingJetPtBin(260.,300.); anasubjets->AddLeadingJetPtBin(300.,500.); anasubjets->SetPtMinSubleading(30.); anasubjets->SetStoreTree(true); anasubjets->SetStoreTreeRef(true);//false); anasubjets->SetMinPtJetTree(80.); handler->Add(anasubjets); anaJetMatching *matchRev = new anaJetMatching("jetMatchingReversed","jetMatchingReversed"); matchRev->ConnectEventObject(fEventObjects); matchRev->SetHiEvtName("hiEventContainer"); matchRev->SetNCentBins(1); matchRev->SetJetsNameBase(jetName); matchRev->SetJetsNameTag(jetSD000Name); matchRev->SetMatchingType(0); handler->Add(matchRev); anaJetMatching *match000Rev = new anaJetMatching("jetMatching000Reversed","jetMatching000Reversed"); match000Rev->ConnectEventObject(fEventObjects); match000Rev->SetHiEvtName("hiEventContainer"); match000Rev->SetNCentBins(1); match000Rev->SetJetsNameBase(jetName); match000Rev->SetJetsNameTag(jetSDName); match000Rev->SetMatchingType(0); match000Rev->SetMatchId(2); handler->Add(match000Rev); anaSubJet *anasubjetsRev = new anaSubJet("anaSubJetsReversed","anaSubJetsReversed"); anasubjetsRev->ConnectEventObject(fEventObjects); anasubjetsRev->SetHiEvtName("hiEventContainer"); anasubjetsRev->SetJetsName(jetSD000Name); anasubjetsRev->SetJetsRefName(jetName); anasubjetsRev->SetJets000Name(jetSDName); anasubjetsRev->SetNCentBins(1); //anasubjetsRev->SetJetEtaRange(-2.,2.); anasubjetsRev->SetJetEtaRange(-1.3,1.3); anasubjetsRev->SetDoDijets(doDijet); anasubjetsRev->AddLeadingJetPtBin(120.,150.); anasubjetsRev->AddLeadingJetPtBin(150.,180.); anasubjetsRev->AddLeadingJetPtBin(180.,220.); anasubjetsRev->AddLeadingJetPtBin(220.,260.); anasubjetsRev->AddLeadingJetPtBin(260.,300.); anasubjetsRev->AddLeadingJetPtBin(300.,500.); anasubjetsRev->SetPtMinSubleading(30.); anasubjetsRev->SetStoreTree(true); anasubjetsRev->SetStoreTreeRef(true);//false); anasubjetsRev->SetMinPtJetTree(80.); handler->Add(anasubjetsRev); anaSubJet *anasubjetsGen = new anaSubJet("anasubjetsGen","anasubjetsGen"); anasubjetsGen->ConnectEventObject(fEventObjects); anasubjetsGen->SetHiEvtName("hiEventContainer"); anasubjetsGen->SetJetsName("akt4Gen"); //ungroomed jets with groomed subjet variables at gen level anasubjetsGen->SetJetsRefName(""); // anasubjetsGen->SetNCentBins(1); anasubjetsGen->SetJetEtaRange(-1.3,1.3); //anasubjetsGen->SetJetEtaRange(-2.,2.); anasubjetsGen->SetDoDijets(doDijet); anasubjetsGen->AddLeadingJetPtBin(120.,150.); anasubjetsGen->AddLeadingJetPtBin(150.,180.); anasubjetsGen->AddLeadingJetPtBin(180.,220.); anasubjetsGen->AddLeadingJetPtBin(220.,260.); anasubjetsGen->AddLeadingJetPtBin(260.,300.); anasubjetsGen->AddLeadingJetPtBin(300.,500.); anasubjetsGen->SetPtMinSubleading(30.); anasubjetsGen->SetStoreTree(true); anasubjetsGen->SetStoreTreeRef(false); anasubjetsGen->SetMinPtJetTree(80.); handler->Add(anasubjetsGen); anaSubJet *anasubjetsGen000 = new anaSubJet("anasubjetsGen000","anasubjetsGen000"); anasubjetsGen000->ConnectEventObject(fEventObjects); anasubjetsGen000->SetHiEvtName("hiEventContainer"); anasubjetsGen000->SetJetsName("akt4Gen000"); //ungroomed jets with groomed subjet variables at gen level anasubjetsGen000->SetJetsRefName(""); // anasubjetsGen000->SetNCentBins(1); anasubjetsGen000->SetJetEtaRange(-1.3,1.3); //anasubjetsGen000->SetJetEtaRange(-2.,2.); anasubjetsGen000->SetDoDijets(doDijet); anasubjetsGen000->AddLeadingJetPtBin(120.,150.); anasubjetsGen000->AddLeadingJetPtBin(150.,180.); anasubjetsGen000->AddLeadingJetPtBin(180.,220.); anasubjetsGen000->AddLeadingJetPtBin(220.,260.); anasubjetsGen000->AddLeadingJetPtBin(260.,300.); anasubjetsGen000->AddLeadingJetPtBin(300.,500.); anasubjetsGen000->SetPtMinSubleading(30.); anasubjetsGen000->SetStoreTree(true); anasubjetsGen000->SetStoreTreeRef(false); anasubjetsGen000->SetMinPtJetTree(80.); handler->Add(anasubjetsGen000); anaSubJet *anasubjetsNoFakes = new anaSubJet("anaSubJetsNoFakes","anaSubJetsNoFakes"); anasubjetsNoFakes->ConnectEventObject(fEventObjects); anasubjetsNoFakes->SetHiEvtName("hiEventContainer"); anasubjetsNoFakes->SetJetsName(jetSDName); anasubjetsNoFakes->SetJetsRefName(jetName); anasubjetsNoFakes->SetNCentBins(4); anasubjetsNoFakes->SetJetEtaRange(-2.,2.); anasubjetsNoFakes->SetMinRefPt(10.); //handler->Add(anasubjetsNoFakes); //SD with charged hadrons anaJetMatching *matchCh = new anaJetMatching("jetMatchingCh","jetMatchingCh"); matchCh->ConnectEventObject(fEventObjects); matchCh->SetHiEvtName("hiEventContainer"); matchCh->SetNCentBins(1); matchCh->SetJetsNameBase(jetName); matchCh->SetJetsNameTag(jetSDChName); matchCh->SetMatchingType(0); // handler->Add(matchCh); anaSubJet *anasubjetsCh = new anaSubJet("anaSubJetsCh","anaSubJetsCh"); anasubjetsCh->ConnectEventObject(fEventObjects); anasubjetsCh->SetHiEvtName("hiEventContainer"); anasubjetsCh->SetJetsName(jetSDChName); anasubjetsCh->SetJetsRefName(jetName); anasubjetsCh->SetNCentBins(1); //anasubjetsCh->SetJetEtaRange(-2.,2.); anasubjetsCh->SetJetEtaRange(-1.3,1.3); anasubjetsCh->SetDoDijets(doDijet); anasubjetsCh->AddLeadingJetPtBin(120.,150.); anasubjetsCh->AddLeadingJetPtBin(150.,180.); anasubjetsCh->AddLeadingJetPtBin(180.,220.); anasubjetsCh->AddLeadingJetPtBin(220.,260.); anasubjetsCh->AddLeadingJetPtBin(260.,300.); anasubjetsCh->AddLeadingJetPtBin(300.,500.); anasubjetsCh->SetPtMinSubleading(30.); anasubjetsCh->SetStoreTree(true); anasubjetsCh->SetStoreTreeRef(true);//false); anasubjetsCh->SetMinPtJetTree(80.); // handler->Add(anasubjetsCh); anaSubJet *anasubjetsGenCh = new anaSubJet("anasubjetsGenCh","anasubjetsGenCh"); anasubjetsGenCh->ConnectEventObject(fEventObjects); anasubjetsGenCh->SetHiEvtName("hiEventContainer"); anasubjetsGenCh->SetJetsName("akt4GenCh"); //ungroomed jets with groomed subjet variables at gen level anasubjetsGenCh->SetJetsRefName(""); // anasubjetsGenCh->SetNCentBins(1); anasubjetsGenCh->SetJetEtaRange(-1.3,1.3); //anasubjetsGenCh->SetJetEtaRange(-2.,2.); anasubjetsGenCh->SetDoDijets(doDijet); anasubjetsGenCh->AddLeadingJetPtBin(120.,150.); anasubjetsGenCh->AddLeadingJetPtBin(150.,180.); anasubjetsGenCh->AddLeadingJetPtBin(180.,220.); anasubjetsGenCh->AddLeadingJetPtBin(220.,260.); anasubjetsGenCh->AddLeadingJetPtBin(260.,300.); anasubjetsGenCh->AddLeadingJetPtBin(300.,500.); anasubjetsGenCh->SetPtMinSubleading(30.); anasubjetsGenCh->SetStoreTree(true); anasubjetsGenCh->SetStoreTreeRef(false); anasubjetsGenCh->SetMinPtJetTree(80.); // handler->Add(anasubjetsGenCh); //--------------------------------------------------------------- //Event loop //--------------------------------------------------------------- Long64_t entries_tot = chain->GetEntries(); //93064 if(nentries<0) lastEvent = chain->GetEntries(); Printf("nentries: %lld tot: %lld",nentries,entries_tot); for (Long64_t jentry=firstEvent; jentry<lastEvent; ++jentry) { if(jentry%10000==0) cout << "entry: "<< jentry << endl; //Run producers //Printf("produce hiEvent"); p_evt->Run(jentry); //hi event properties //Printf("produce jets"); p_SDJet->Run(jentry); //forest SoftDrop jets p_SD000Jet->Run(jentry); //forest SoftDrop jets with zcut=0 // p_SDChJet->Run(jentry); //forest SoftDrop jets with charged hadrons p_Jet->Run(jentry); //forest jets //Execute all analysis tasks handler->ExecuteTask(); } fEventObjects->Print(); TFile *out = new TFile(outname,"RECREATE","",8); TList *tasks = handler->GetListOfTasks(); TIter next(tasks); anaBaseTask *obj; while ((obj = dynamic_cast<anaBaseTask*>(next()) )) if(obj->GetOutput()) obj->GetOutput()->Write(obj->GetName(),TObject::kSingleKey); out->Write(); out->Close(); }
void analyzeDijetAj(std::vector<std::string> urls, const char *outname = "eventObjects.root", Long64_t nentries = 20, Int_t firstF = -1, Int_t lastF = -1, Int_t firstEvent = 0) { /* ptminType: minimum raw pt for particles used by puppi 0 : 0 GeV 1 : 1 GeV 2 : 2 GeV jetSignalType: jets used to select jetty region in events 0 : detector-level jets (akPu4PF) 1 : particle-level jets (gen jets) */ double ptminjet = 30.; TString jetName = "aktCs4PF"; TString jetTreeName = "akCs4PFJetAnalyzer"; //jetName = "akCs4PFFilter"; //jetTreeName = "akCs4PFFilterJetAnalyzer"; std::cout << "analyzing subjets for: " << jetName << " tree: " << jetTreeName << std::endl; std::cout << "nfiles: " << urls.size() << std::endl; for (auto i = urls.begin(); i != urls.end(); ++i) std::cout << *i << std::endl; size_t firstFile = 0; size_t lastFile = urls.size(); if(firstF>-1) { firstFile = (size_t)firstF; lastFile = std::min((size_t)lastF,lastFile); } std::cout << "firstFile: " << firstFile << " lastFile: " << lastFile << std::endl; Int_t lastEvent = nentries; if(firstEvent>0) { lastEvent = firstEvent + nentries; } std::cout << "firstEvent: " << firstEvent << std::endl; //add files to chain TChain *chain = NULL; chain = new TChain("hiEvtAnalyzer/HiTree"); for(size_t i=firstFile; i<lastFile; i++) chain->Add(urls[i].c_str()); Printf("hiTree done"); TChain *skimTree = new TChain("skimanalysis/HltTree"); for(size_t i=firstFile; i<lastFile; i++) skimTree->Add(urls[i].c_str()); chain->AddFriend(skimTree); Printf("skimTree done"); TChain *hltTree = new TChain("hltanalysis/HltTree"); for(size_t i=firstFile; i<lastFile; i++) hltTree->Add(urls[i].c_str()); chain->AddFriend(hltTree); Printf("hltTree done"); TChain *jetTree = new TChain(Form("%s/t",jetTreeName.Data())); for(size_t i=firstFile; i<lastFile; i++) jetTree->Add(urls[i].c_str()); chain->AddFriend(jetTree); Printf("jetTree done"); // TChain *csJetTree = new TChain(Form("%s/t","akCs4PFJetAnalyzer")); // for(size_t i=firstFile; i<lastFile; i++) csJetTree->Add(urls[i].c_str()); // chain->AddFriend(csJetTree); // Printf("csJetTree done"); TList *fEventObjects = new TList(); //--------------------------------------------------------------- // producers // hiEventProducer *p_evt = new hiEventProducer("hiEvtProd"); p_evt->SetInput(chain); p_evt->SetHIEventContName("hiEventContainer"); p_evt->SetEventObjects(fEventObjects); triggerProducer *p_trg = new triggerProducer("trigProd"); p_trg->SetInput(chain);//hltTree); p_trg->SetTriggerMapName("triggerMap"); p_trg->AddTrigger("HLT_HIPuAK4CaloJet100_Eta5p1_v1"); p_trg->SetEventObjects(fEventObjects); lwJetFromForestProducer *p_PUJet = new lwJetFromForestProducer("lwJetForestProd"); p_PUJet->SetInput(chain); p_PUJet->SetJetContName(jetName); p_PUJet->SetGenJetContName(""); p_PUJet->SetEventObjects(fEventObjects); p_PUJet->SetRadius(0.4); p_PUJet->SetMinJetPt(ptminjet); // lwJetFromForestProducer *p_CSJet = new lwJetFromForestProducer("lwJetForestProd"); // p_CSJet->SetInput(csJetTree); // p_CSJet->SetJetContName("aktCs4PF"); // p_CSJet->SetGenJetContName(""); // p_CSJet->SetEventObjects(fEventObjects); // p_CSJet->SetRadius(0.4); //--------------------------------------------------------------- //analysis modules // //handler to which all modules will be added anaBaseTask *handler = new anaBaseTask("handler","handler"); anaDijetAj *anadijetAj = new anaDijetAj("anaDijetAj","anaDijetAj"); anadijetAj->ConnectEventObject(fEventObjects); anadijetAj->SetHiEvtName("hiEventContainer"); anadijetAj->DoCollisionEventSel(true); anadijetAj->DoHBHENoiseFilter(true); anadijetAj->DoHBHENoiseFilterLoose(true); anadijetAj->DoPrimaryVertexFilter(true); anadijetAj->DoClusterCompatibilityFilter(true); anadijetAj->DoHFCoincFilter(true); anadijetAj->SetTriggerMapName("triggerMap"); anadijetAj->AddTriggerSel("HLT_HIPuAK4CaloJet100_Eta5p1_v1"); anadijetAj->SetJetsName(jetName); anadijetAj->SetNCentBins(5); anadijetAj->SetJetEtaRange(-1.3,1.3); anadijetAj->SetDoDijets(true); anadijetAj->AddLeadingJetPtBin(120.,150.); anadijetAj->AddLeadingJetPtBin(150.,180.); anadijetAj->AddLeadingJetPtBin(180.,220.); anadijetAj->AddLeadingJetPtBin(220.,260.); anadijetAj->AddLeadingJetPtBin(260.,300.); anadijetAj->AddLeadingJetPtBin(300.,500.); anadijetAj->SetPtMinSubleading(40.); handler->Add(anadijetAj); anaDijetAj *anadijetAjMassCut = new anaDijetAj("anaDijetAjMassCut","anaDijetAjMassCut"); anadijetAjMassCut->ConnectEventObject(fEventObjects); anadijetAjMassCut->SetHiEvtName("hiEventContainer"); anadijetAjMassCut->DoCollisionEventSel(true); anadijetAjMassCut->DoHBHENoiseFilter(true); anadijetAjMassCut->DoHBHENoiseFilterLoose(true); anadijetAjMassCut->DoPrimaryVertexFilter(true); anadijetAjMassCut->DoClusterCompatibilityFilter(true); anadijetAjMassCut->DoHFCoincFilter(true); anadijetAjMassCut->SetTriggerMapName("triggerMap"); anadijetAjMassCut->AddTriggerSel("HLT_HIPuAK4CaloJet100_Eta5p1_v1"); anadijetAjMassCut->SetJetsName(jetName); anadijetAjMassCut->SetNCentBins(5); anadijetAjMassCut->SetJetEtaRange(-1.,3.); anadijetAjMassCut->SetDoDijets(true); anadijetAjMassCut->AddLeadingJetPtBin(120.,150.); anadijetAjMassCut->AddLeadingJetPtBin(150.,180.); anadijetAjMassCut->AddLeadingJetPtBin(180.,220.); anadijetAjMassCut->AddLeadingJetPtBin(220.,260.); anadijetAjMassCut->AddLeadingJetPtBin(260.,300.); anadijetAjMassCut->AddLeadingJetPtBin(300.,500.); anadijetAjMassCut->SetPtMinSubleading(40.); anadijetAjMassCut->SetMinMassLeading(10.); handler->Add(anadijetAjMassCut); //--------------------------------------------------------------- //Event loop //--------------------------------------------------------------- Long64_t entries_tot = chain->GetEntries(); //93064 if(nentries<0) lastEvent = chain->GetEntries(); Printf("nentries: %lld tot: %lld",nentries,entries_tot); for (Long64_t jentry=firstEvent; jentry<lastEvent; ++jentry) { if(jentry%10000==0) cout << "entry: "<< jentry << endl; //Run producers //Printf("produce hiEvent"); p_evt->Run(jentry); //hi event properties //Printf("produce PU jets"); p_PUJet->Run(jentry); //forest jets p_trg->Run(jentry); //Execute all analysis tasks handler->ExecuteTask(); } fEventObjects->Print(); TFile *out = new TFile(outname,"RECREATE"); TList *tasks = handler->GetListOfTasks(); TIter next(tasks); anaBaseTask *obj; while ((obj = dynamic_cast<anaBaseTask*>(next()) )) if(obj->GetOutput()) obj->GetOutput()->Write(obj->GetName(),TObject::kSingleKey); out->Write(); out->Close(); }
void analyzePFCandidates(std::vector<std::string> urls, const char *outname = "eventObjects.root", Long64_t nentries = 20, Int_t firstF = -1, Int_t lastF = -1) { // std::vector<std::string> urls = CollectFiles(list); // Printf("anaFile: %d",anaFile); std::cout << "nfiles: " << urls.size() << std::endl; for (auto i = urls.begin(); i != urls.end(); ++i) std::cout << *i << std::endl; size_t firstFile = 0; size_t lastFile = urls.size(); if(firstF>-1) { firstFile = (size_t)firstF; lastFile = (size_t)lastF; } std::cout << "firstFile: " << firstFile << " lastFile: " << lastFile << std::endl; //add files to chain TChain *chain = NULL; // chain = new TChain("hiEvtAnalyzer/HiTree"); //for(size_t i=firstFile; i<lastFile; i++) chain->Add(urls[i].c_str()); //Printf("hiTree done"); //TChain *pfTree = new TChain("pfcandAnalyzer/pfTree"); chain = new TChain("pfcandAnalyzer/pfTree"); //for(size_t i=firstFile; i<lastFile; i++) pfTree->Add(urls[i].c_str()); for(size_t i=firstFile; i<lastFile; i++) chain->Add(urls[i].c_str()); //chain->AddFriend(pfTree); Printf("pfTree done"); // TChain *muTree = new TChain("hltMuTree/HLTMuTree"); // for(size_t i=firstFile; i<lastFile; i++) muTree->Add(urls[i].c_str()); // chain->AddFriend(muTree); // Printf("muTree done"); TChain *jetTree = new TChain("ak4PFJetAnalyzer/t");//akPu4CaloJetAnalyzer/t"); for(size_t i=firstFile; i<lastFile; i++) jetTree->Add(urls[i].c_str()); chain->AddFriend(jetTree); Printf("jetTree done"); TChain *hltTree = new TChain("hltanalysis/HltTree"); for(size_t i=firstFile; i<lastFile; i++) hltTree->Add(urls[i].c_str()); chain->AddFriend(hltTree); Printf("hltTree done"); TChain *skimTree = new TChain("skimanalysis/HltTree"); for(size_t i=firstFile; i<lastFile; i++) skimTree->Add(urls[i].c_str()); chain->AddFriend(skimTree); Printf("skimTree done"); if(doTracks) { // TChain *trackTree = new TChain("anaTrack/trackTree"); TChain *trackTree = new TChain("ppTrack/trackTree"); for(size_t i=firstFile; i<lastFile; i++) trackTree->Add(urls[i].c_str()); chain->AddFriend(trackTree); Printf("trackTree done"); } // TChain *genTree = new TChain("HiGenParticleAna/hi"); // for(size_t i=firstFile; i<lastFile; i++) genTree->Add(urls[i].c_str()); // chain->AddFriend(genTree); // Printf("genTree done"); TList *fEventObjects = new TList(); //--------------------------------------------------------------- // producers // hiEventProducer *p_evt = new hiEventProducer("hiEvtProd"); p_evt->SetInput(chain); p_evt->SetHIEventContName("hiEventContainer"); p_evt->SetEventObjects(fEventObjects); pfParticleProducer *p_pf = new pfParticleProducer("pfPartProd"); p_pf->SetInput(chain); p_pf->SetpfParticlesName("pfParticles"); p_pf->SetEventObjects(fEventObjects); lwJetFromForestProducer *p_PUJet = new lwJetFromForestProducer("lwJetForestProd"); p_PUJet->SetInput(chain); p_PUJet->SetJetContName("akt4PF"); p_PUJet->SetGenJetContName("akt4Gen"); p_PUJet->SetEventObjects(fEventObjects); p_PUJet->SetRadius(0.4); trackProducer *p_trk = new trackProducer("trackProd"); if(doTracks) { p_trk->SetInput(chain); p_trk->SetTracksName("tracks"); p_trk->SetEventObjects(fEventObjects); } //--------------------------------------------------------------- //analysis modules // //handler to which all modules will be added anaBaseTask *handler = new anaBaseTask("handler","handler"); anaPFCandidates *anaPFCandJet = new anaPFCandidates("pfCandWithPFJets","pfCandWithPFJets"); anaPFCandJet->ConnectEventObject(fEventObjects); // anaPFCandJet->SetHiEvtName("hiEventContainer"); anaPFCandJet->SetParticlesName("pfParticles"); anaPFCandJet->SetJetsName("akt4PF"); handler->Add(anaPFCandJet); anaPFCandidates *anaPF = new anaPFCandidates("pfCand","pfCand"); anaPF->ConnectEventObject(fEventObjects); //anaPF->SetHiEvtName("hiEventContainer"); anaPF->SetParticlesName("pfParticles"); anaPF->SetJetsName("akt4Gen"); handler->Add(anaPF); anaPFCandidates *anaTrkCaloJet = new anaPFCandidates("tracksWithCaloJets","tracksWithCaloJets"); anaTrkCaloJet->ConnectEventObject(fEventObjects); //anaTrkCaloJet->SetHiEvtName("hiEventContainer"); anaTrkCaloJet->SetParticlesName("tracks"); anaTrkCaloJet->SetJetsName("aktPu4Calo"); if(doTracks) handler->Add(anaTrkCaloJet); anaPFCandidates *anaTrk = new anaPFCandidates("tracksWithGenJet","tracksWithGenJet"); anaTrk->ConnectEventObject(fEventObjects); //anaTrk->SetHiEvtName("hiEventContainer"); anaTrk->SetParticlesName("tracks"); anaTrk->SetJetsName("akt4Gen"); if(doTracks) handler->Add(anaTrk); //--------------------------------------------------------------- //Event loop //--------------------------------------------------------------- Long64_t entries_tot = chain->GetEntriesFast(); //93064 if(nentries<0) nentries = chain->GetEntries(); // Long64_t nentries = 20;//chain->GetEntriesFast(); Printf("nentries: %lld tot: %lld",nentries,entries_tot); for (Long64_t jentry=0; jentry<nentries;jentry++) { //Run producers // Printf("produce hiEvent"); // p_evt->Run(jentry); //hi event properties //Printf("produce pf particles"); p_pf->Run(jentry); //pf particles if(doTracks) p_trk->Run(jentry); //tracks p_PUJet->Run(jentry); //jets //Execute all analysis tasks handler->ExecuteTask(); } fEventObjects->Print(); TFile *out = new TFile(outname,"RECREATE"); TList *tasks = handler->GetListOfTasks(); TIter next(tasks); anaBaseTask *obj; while ((obj = dynamic_cast<anaBaseTask*>(next()) )) if(obj->GetOutput()) obj->GetOutput()->Write(obj->GetName(),TObject::kSingleKey); out->Write(); out->Close(); }
void analyzeZJetMCResponse(std::vector<std::string> urls, const char *outname = "eventObjects.root", Long64_t nentries = 20, Int_t firstF = -1, Int_t lastF = -1, Int_t firstEvent = 0) { TString jetName = "aktPuppiR040"; TString jetTreeName = "akPuppi4PFJetAnalyzer"; jetName = "aktPuR030"; //"aktCsR040"; jetTreeName = "akPu3PFJetAnalyzer"; //"akCs4PFJetAnalyzer"; //akCs4PFJetAnalyzer std::cout << "analyzing Z-jet response for: " << jetName << " tree: " << jetTreeName << std::endl; std::cout << "nfiles: " << urls.size() << std::endl; for (auto i = urls.begin(); i != urls.end(); ++i) std::cout << *i << std::endl; size_t firstFile = 0; size_t lastFile = urls.size(); if(firstF>-1) { firstFile = (size_t)firstF; lastFile = (size_t)lastF; } std::cout << "firstFile: " << firstFile << " lastFile: " << lastFile << std::endl; Int_t lastEvent = nentries; if(firstEvent>0) { lastEvent = firstEvent + nentries; } //add files to chain TChain *chain = NULL; chain = new TChain("hiEvtAnalyzer/HiTree"); for(size_t i=firstFile; i<lastFile; i++) chain->Add(urls[i].c_str()); Printf("hiTree done"); // TChain *hltTree = new TChain("hltanalysis/HltTree"); // for(size_t i=firstFile; i<lastFile; i++) hltTree->Add(urls[i].c_str()); // chain->AddFriend(hltTree); // Printf("hltTree done"); // TChain *skimTree = new TChain("skimanalysis/HltTree"); // for(size_t i=firstFile; i<lastFile; i++) skimTree->Add(urls[i].c_str()); // chain->AddFriend(skimTree); // Printf("skimTree done"); // TChain *muTree = new TChain("ggHiNtuplizer/EventTree"); // for(size_t i=firstFile; i<lastFile; i++) muTree->Add(urls[i].c_str()); // chain->AddFriend(muTree); // Printf("muTree done"); TChain *genTree = new TChain("HiGenParticleAna/hi"); for(size_t i=firstFile; i<lastFile; i++) genTree->Add(urls[i].c_str()); //chain->AddFriend(genTree); Printf("genTree done: %d",(int)genTree->GetEntries()); TChain *jetTree = new TChain(Form("%s/t",jetTreeName.Data())); for(size_t i=firstFile; i<lastFile; i++) jetTree->Add(urls[i].c_str()); chain->AddFriend(jetTree); Printf("jetTree done"); TList *fEventObjects = new TList(); //--------------------------------------------------------------- // producers // hiEventProducer *p_evt = new hiEventProducer("hiEvtProd"); p_evt->SetInput(chain); p_evt->SetHIEventContName("hiEventContainer"); p_evt->SetEventObjects(fEventObjects); lwMuonProducer *p_mu = new lwMuonProducer("lwMuonProd"); p_mu->SetInput(chain); p_mu->SetlwMuonsRecoName("lwMuonsReco"); p_mu->SetlwMuonsGeneName(""); p_mu->SetEventObjects(fEventObjects); genParticleProducer *p_gen = new genParticleProducer("genParticleProd"); p_gen->SetInput(genTree); p_gen->SetGenParticlesName("genParticles"); p_gen->SetEventObjects(fEventObjects); lwJetFromForestProducer *p_PUJet = new lwJetFromForestProducer("lwJetForestProd"); p_PUJet->SetInput(chain); p_PUJet->SetJetContName(jetName); p_PUJet->SetGenJetContName("");//akt4Gen"); p_PUJet->SetEventObjects(fEventObjects); p_PUJet->SetRadius(0.4); //--------------------------------------------------------------- //analysis modules // //handler to which all modules will be added anaBaseTask *handler = new anaBaseTask("handler","handler"); //Z to mumu anaZToMuMu *ZToMuMu = new anaZToMuMu("ZToMuMu","ZToMuMu"); ZToMuMu->ConnectEventObject(fEventObjects); ZToMuMu->SetHiEvtName("hiEventContainer"); ZToMuMu->SetMuonsName("genParticles"); ZToMuMu->SetCheckPid(true); ZToMuMu->SetZsName("zMuMuBosons"); handler->Add(ZToMuMu); anaZJetMCResponse *ZResp = new anaZJetMCResponse("ZJetMCResponse","ZJetMCResponse"); ZResp->ConnectEventObject(fEventObjects); ZResp->SetHiEvtName("hiEventContainer"); ZResp->SetZsName("zMuMuBosons"); ZResp->SetJetsName(jetName); ZResp->SetNCentBins(3); handler->Add(ZResp); //--------------------------------------------------------------- //Event loop //--------------------------------------------------------------- Long64_t entries_tot = chain->GetEntriesFast(); //93064 if(nentries<0) lastEvent = chain->GetEntries(); // Long64_t nentries = 20;//chain->GetEntriesFast(); Printf("nentries: %lld tot: %lld",nentries,entries_tot); for (Long64_t jentry=firstEvent; jentry<lastEvent; ++jentry) { if (jentry%10000==0) Printf("Processing event %d %d",(int)(jentry), (int)(lastEvent)); //Run producers // Printf("produce hiEvent"); p_evt->Run(jentry); //hi event properties //Printf("produce pf particles"); p_gen->Run(jentry); //gen particles p_PUJet->Run(jentry); //jets //Execute all analysis tasks handler->ExecuteTask(); } fEventObjects->Print(); TFile *out = new TFile(outname,"RECREATE"); TList *tasks = handler->GetListOfTasks(); TIter next(tasks); anaBaseTask *obj; while ((obj = dynamic_cast<anaBaseTask*>(next()) )) if(obj->GetOutput()) obj->GetOutput()->Write(obj->GetName(),TObject::kSingleKey); out->Write(); out->Close(); }
//____________________________________________________________________________ void get_mass(Double_t length_unit, Double_t density_unit) { //tables of Z and A const Int_t lcin_Z = 150; const Int_t lcin_A = 300; // calc unit conversion factors Double_t density_unit_to_SI = density_unit / units::kg_m3; Double_t length_unit_to_SI = length_unit / units::m; Double_t volume_unit_to_SI = TMath::Power(length_unit_to_SI, 3.); #ifdef _debug_ cout << "Input density unit --> kg/m^3 : x" << density_unit_to_SI << endl; cout << "Input length unit --> m : x" << length_unit_to_SI << endl; #endif // get materials in geometry TList *matlist = gGeoManager->GetListOfMaterials(); if (!matlist ) { cout << "Null list of materials!" << endl; return; } else { #ifdef _debug_ matlist->Print(); #endif } int max_idx = 0; // number of mixtures in geometry Int_t nmat = matlist->GetEntries(); for( Int_t imat = 0; imat < nmat; imat++ ) { Int_t idx = gGeoManager->GetMaterial(imat)->GetIndex(); max_idx = TMath::Max(max_idx, idx); } //check if material index is unique Int_t * checkindex = new Int_t[max_idx+1]; for( Int_t i = 0; i<max_idx+1; i++ ) checkindex[i] = 0; for( Int_t imat = 0; imat < nmat; imat++ ) { if( !checkindex[imat] ) checkindex[imat] = 1; else { cout << "material index is not unique" << endl; return; } } #ifdef _debug_ cout << "max_idx = " << max_idx << endl; cout << "nmat = " << nmat << endl; #endif TGeoVolume * topvol = gGeoManager->GetTopVolume(); //get top volume if (!topvol) { cout << "volume does not exist" << endl; return; } TGeoIterator NodeIter(topvol); TGeoNode *node; NodeIter.SetType(0); // include all daughters Double_t * volume = new Double_t[max_idx+1]; Double_t * mass = new Double_t[max_idx+1]; for( Int_t i = 0; i<max_idx+1; i++ ){ volume[i]=0.; mass[i]=0.; } // IMPORTANT! force empty arrays, allows repated calls without ending ROOT session volume[ topvol->GetMaterial()->GetIndex() ] = topvol->Capacity() * volume_unit_to_SI; //iterator does not include topvolume while ( (node=NodeIter()) ) { Int_t momidx = node->GetMotherVolume()->GetMaterial()->GetIndex() ; Int_t idx = node->GetVolume() ->GetMaterial()->GetIndex() ; Double_t node_vol = node->GetVolume()->Capacity() * volume_unit_to_SI; volume[ momidx ] -= node_vol; //substract subvolume from mother volume[ idx ] += node_vol; } Double_t larr_MassIsotopes[lcin_Z][lcin_A] = {0.}; //[Z][A], no map in pure ROOT Double_t larr_VolumeIsotopes[lcin_Z][lcin_A] = {0.}; //[Z][A], no map in pure ROOT for( Int_t i=0; i<gGeoManager->GetListOfMaterials()->GetEntries(); i++ ) { TGeoMaterial *lgeo_Mat = gGeoManager->GetMaterial(i); Int_t idx = gGeoManager->GetMaterial(i)->GetIndex(); if( lgeo_Mat->IsMixture() ) { TGeoMixture * lgeo_Mix = dynamic_cast <TGeoMixture*> ( lgeo_Mat ); Int_t lint_Nelements = lgeo_Mix->GetNelements(); for ( Int_t j=0; j<lint_Nelements; j++) { Int_t lint_Z = TMath::Nint( (Double_t) lgeo_Mix->GetZmixt()[j] ); Int_t lint_A = TMath::Nint( (Double_t) lgeo_Mix->GetAmixt()[j] ); Double_t ldou_Fraction = lgeo_Mix->GetWmixt()[j]; Double_t ldou_Density = lgeo_Mix->GetDensity() * density_unit_to_SI; larr_MassIsotopes[ lint_Z ][ lint_A ] += volume[idx] * ldou_Fraction * ldou_Density; larr_VolumeIsotopes[ lint_Z ][ lint_A ] += volume[idx] * ldou_Fraction; } } } // // print out volume/mass for each `material' // Double_t ldou_MinimumVolume = 1e-20; cout << endl << " Geometry: \"" << gFileName << "\"" << endl << " TopVolume: \"" << topvol->GetName() << "\"" << endl; cout <<endl << "materials:" << endl; cout << setw(5) << "index" << setw(15) << "name" << setprecision(6) << setw(14) << "volume (m^3)" << setw(14) << "mass (kg)" << setw(14) << "mass (%)" << endl; double total_mass_materials = 0; for( Int_t i=0; i<gGeoManager->GetListOfMaterials()->GetEntries(); i++ ) { Int_t idx = gGeoManager->GetMaterial(i)->GetIndex(); Double_t density = gGeoManager->GetMaterial(i)->GetDensity() * density_unit_to_SI; Double_t mass_material = density * volume[idx]; if ( volume[idx] > ldou_MinimumVolume ) { total_mass_materials += mass_material; } } for( Int_t i=0; i<gGeoManager->GetListOfMaterials()->GetEntries(); i++ ) { Int_t idx = gGeoManager->GetMaterial(i)->GetIndex(); Double_t density = gGeoManager->GetMaterial(i)->GetDensity() * density_unit_to_SI; mass[idx] = density * volume[idx]; if( volume[idx] > ldou_MinimumVolume ) { cout << setw(5) << i << setw(15) << gGeoManager->GetMaterial(i)->GetName() << setprecision(6) << setw(14) << volume[idx] << setw(14) << mass[idx] << setw(14) << mass[idx]*100./total_mass_materials << endl; } } // // print out mass contribution for each nuclear target // PDGLibrary* pdglib = PDGLibrary::Instance(); cout <<endl << "isotopes:" << endl; cout << setw(4) << "Z" << setw(4) << "A" << setw(14) << "PDG isotope" << setw(5) << " " << setprecision(6) << setw(14) << "volume (m^3)" << setw(14) << "mass (kg)" << setw(10) << "mass (%)" << endl; double total_mass_isotopes = 0; for( Int_t i=0; i<lcin_Z; i++ ) { for( Int_t j=0; j<lcin_A; j++ ) { if( larr_VolumeIsotopes[ i ][ j ] > ldou_MinimumVolume ) { total_mass_isotopes += larr_MassIsotopes[ i ][ j ]; } } } for( Int_t i=0; i<lcin_Z; i++ ) { for( Int_t j=0; j<lcin_A; j++ ) { if( larr_VolumeIsotopes[ i ][ j ] > ldou_MinimumVolume ) { int pdgcode = 1000000000 + i*10000 + j*10; cout << setw(4) << i << setw(4)<< j << setw(14) << pdgcode << setw(5) << pdglib->Find(pdgcode)->GetName() << setprecision(6) << setw(14) << larr_VolumeIsotopes[ i ][ j ] << setw(14) << larr_MassIsotopes[ i ][ j ] << setw(10) << larr_MassIsotopes[ i ][ j ]*100.0/total_mass_isotopes << endl; } else if ( larr_VolumeIsotopes[ i ][ j ] < -ldou_MinimumVolume ) { cout << "negative volume, check geometry " << larr_VolumeIsotopes[ i ][ j ] << endl; } } } cout << endl << " mass totals: " << total_mass_materials << " " << total_mass_isotopes << endl << endl; delete [] volume; delete [] mass; }