void runProofFwdDetsQA(const char * dataset = "/COMMON/COMMON/LHC09a4_run8101X",Long64_t nentries=100000, Long64_t firstentry=0) { gSystem->Load("libANALYSIS"); gSystem->Load("libANALYSISalice"); gSystem->AddIncludePath("-I$ALICE_ROOT/include"); // Connect to Proof gEnv->SetValue("XSec.GSI.DelegProxy","2"); TProof::Open("cheshkov:PWG0@alicecaf"); // Upload and enable packages: please use the correct version! gProof->UploadPackage("/afs/cern.ch/alice/caf/sw/ALICE/PARs/v4-16-Release/AF-v4-16"); gProof->EnablePackage("/afs/cern.ch/alice/caf/sw/ALICE/PARs/v4-16-Release/AF-v4-16"); // Create the analysis manager AliAnalysisManager *mgr = new AliAnalysisManager("AliAnaFwdDetsQA"); AliVEventHandler* esdH = new AliESDInputHandler(); mgr->SetInputEventHandler(esdH); // Enable MC event handler AliVEventHandler* handler = new AliMCEventHandler; mgr->SetMCtruthEventHandler(handler); // Create task gProof->Load(Form("%s/PWGPP/AliAnaFwdDetsQA.cxx++g", gSystem->Getenv("ALICE_ROOT"))); AliAnalysisTask *task = new AliAnaFwdDetsQA("AliAnaFwdDetsQA"); // Add task mgr->AddTask(task); // Create containers for input/output AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer(); AliAnalysisDataContainer *coutput = mgr->CreateContainer("coutput", TList::Class(), AliAnalysisManager::kOutputContainer, "FwdDetsQA.root"); // Connect input/output mgr->ConnectInput(task, 0, cinput); mgr->ConnectOutput(task, 1, coutput); // Enable debug printouts mgr->SetDebugLevel(3); if (!mgr->InitAnalysis()) return; mgr->PrintStatus(); TFileCollection *proofColl = gProof->GetDataSet(dataset); TChain *chain = new TChain("esdTree"); chain->AddFileInfoList((TCollection*)(proofColl->GetList())); mgr->StartAnalysis("proof", chain, nentries, firstentry); // mgr->StartAnalysis("proof",dataset,nentries,firstentry); }
void trim(const char* treepath = "/media/Disk1/avartak/CMS/Data/Dileptons/DoubleMuon/tree*.root", const char* outfilename = "/media/Disk1/avartak/CMS/Data/Dileptons/DoubleMuon/trim.root", bool isMC = false) { TFile purwtfile("../data/purwt.root"); TFile muoidfile("../data/muonIDIsoSF.root"); TH1F* purwthist = (TH1F*)purwtfile.Get("puhist"); TH2F* muidlhist = (TH2F*)muoidfile.Get("scalefactors_MuonMediumId_Muon"); TH2F* muidmhist = (TH2F*)muoidfile.Get("scalefactors_MuonMediumId_Muon"); TH2F* muidthist = (TH2F*)muoidfile.Get("scalefactors_TightId_Muon" ); TH2F* muislhist = (TH2F*)muoidfile.Get("scalefactors_Iso_MuonMediumId" ); TH2F* muismhist = (TH2F*)muoidfile.Get("scalefactors_Iso_MuonMediumId" ); TH2F* muisthist = (TH2F*)muoidfile.Get("scalefactors_Iso_MuonTightId" ); TFileCollection fc("fc"); fc.Add(treepath); TChain* chain = new TChain("mmtree/tree"); chain->AddFileInfoList(fc.GetList()); TTreeReader reader(chain); TTreeReaderValue<double> xsec (reader, "xsec" ); TTreeReaderValue<double> wgt (reader, "wgt" ); TTreeReaderValue<unsigned> nvtx (reader, "nvtx" ); TTreeReaderValue<std::vector<TLorentzVector> > dimuons (reader, "dimuons" ); TTreeReaderValue<std::vector<unsigned> > m1idx (reader, "m1idx" ); TTreeReaderValue<std::vector<unsigned> > m2idx (reader, "m2idx" ); TTreeReaderValue<std::vector<double> > masserr (reader, "masserr" ); TTreeReaderValue<std::vector<TLorentzVector> > muons (reader, "muons" ); TTreeReaderValue<std::vector<double> > miso (reader, "miso" ); TTreeReaderValue<std::vector<char> > mid (reader, "mid" ); TTreeReaderValue<unsigned char> hlt2m (reader, "hltdoublemu"); TTreeReaderValue<unsigned char> hlt1m (reader, "hltsinglemu"); TFile* outfile = new TFile(outfilename, "RECREATE"); TTree* outtree = new TTree("tree", "tree"); double wgtsum = isMC ? sumwgt(treepath) : 1.0; double mcwgt = 1.0; double puwgt = 1.0; double lidw1 = 1.0; double lidw2 = 1.0; double midw1 = 1.0; double midw2 = 1.0; double tidw1 = 1.0; double tidw2 = 1.0; double m1pt = 0.0; double m1eta = 0.0; double m1phi = 0.0; double m1iso = 0.0; double m2pt = 0.0; double m2eta = 0.0; double m2phi = 0.0; double m2iso = 0.0; double mmpt = 0.0; double mmeta = 0.0; double mmphi = 0.0; double mass = 0.0; double merr = 0.0; char m1id = 0; char m2id = 0; char trig1m = 0; char trig2m = 0; outtree->Branch("mcwgt" , &mcwgt , "mcwgt/D" ); outtree->Branch("puwgt" , &puwgt , "puwgt/D" ); outtree->Branch("lidw1" , &lidw1 , "lidw1/D" ); outtree->Branch("lidw2" , &lidw2 , "lidw2/D" ); outtree->Branch("midw1" , &midw1 , "midw1/D" ); outtree->Branch("midw2" , &midw2 , "midw2/D" ); outtree->Branch("tidw1" , &tidw1 , "tidw1/D" ); outtree->Branch("tidw2" , &tidw2 , "tidw2/D" ); outtree->Branch("m1pt" , &m1pt , "m1pt/D" ); outtree->Branch("m1eta" , &m1eta , "m1eta/D" ); outtree->Branch("m1eta" , &m1phi , "m1phi/D" ); outtree->Branch("m1id" , &m1id , "m1id/B" ); outtree->Branch("m1iso" , &m1iso , "m1iso/D" ); outtree->Branch("m2pt" , &m2pt , "m2pt/D" ); outtree->Branch("m2eta" , &m2eta , "m2eta/D" ); outtree->Branch("m2eta" , &m2phi , "m2phi/D" ); outtree->Branch("m2id" , &m2id , "m2id/B" ); outtree->Branch("m2iso" , &m2iso , "m2iso/D" ); outtree->Branch("mmpt" , &mmpt , "mmpt/D" ); outtree->Branch("mmeta" , &mmeta , "mmeta/D" ); outtree->Branch("mmeta" , &mmphi , "mmphi/D" ); outtree->Branch("mass" , &mass , "mass/D" ); outtree->Branch("merr" , &merr , "merr/D" ); outtree->Branch("trig1m", &trig1m, "trig1m/b"); outtree->Branch("trig2m", &trig2m, "trig2m/b"); while(reader.Next()) { if (muons->size() != 2) continue; if (dimuons->size() != 1) continue; unsigned numvtx = *nvtx; if (numvtx > 40) numvtx = 40; double pt1 = muons->at((*m1idx)[0]).Pt(); double pt2 = muons->at((*m2idx)[0]).Pt(); double eta1 = fabs(muons->at((*m1idx)[0]).Eta()); double eta2 = fabs(muons->at((*m2idx)[0]).Eta()); if (pt1 >= 120.0) pt1 = 119.9; if (pt2 >= 120.0) pt2 = 119.9; if (pt1 <= 20.0) pt1 = 20.1; if (pt2 <= 20.0) pt2 = 20.1; if (isMC) { mcwgt = 35.9 * (*wgt) * (*xsec) / wgtsum; puwgt = purwthist->GetBinContent(purwthist->FindBin(numvtx)); lidw1 = muidlhist->GetBinContent(muidlhist->FindBin(eta1, pt1)); lidw1*= muislhist->GetBinContent(muislhist->FindBin(eta1, pt1)); lidw2 = muidlhist->GetBinContent(muidlhist->FindBin(eta2, pt2)); lidw2*= muislhist->GetBinContent(muislhist->FindBin(eta2, pt2)); midw1 = muidmhist->GetBinContent(muidmhist->FindBin(eta1, pt1)); midw1*= muismhist->GetBinContent(muismhist->FindBin(eta1, pt1)); midw2 = muidmhist->GetBinContent(muidmhist->FindBin(eta2, pt2)); midw2*= muismhist->GetBinContent(muismhist->FindBin(eta2, pt2)); tidw1 = muidthist->GetBinContent(muidthist->FindBin(eta1, pt1)); tidw1*= muisthist->GetBinContent(muisthist->FindBin(eta1, pt1)); tidw2 = muidthist->GetBinContent(muidthist->FindBin(eta2, pt2)); tidw2*= muisthist->GetBinContent(muisthist->FindBin(eta2, pt2)); } m1pt = muons->at((*m1idx)[0]).Pt(); m1eta = muons->at((*m1idx)[0]).Eta(); m1phi = muons->at((*m1idx)[0]).Phi(); m2pt = muons->at((*m2idx)[0]).Pt(); m2eta = muons->at((*m2idx)[0]).Eta(); m2phi = muons->at((*m2idx)[0]).Phi(); mmpt = (*dimuons)[0].Pt(); mmeta = (*dimuons)[0].Eta(); mmphi = (*dimuons)[0].Phi(); mass = (*dimuons)[0].M(); merr = (*masserr)[0]; m1id = mid->at((*m1idx)[0]); m2id = mid->at((*m2idx)[0]); m1iso = miso->at((*m1idx)[0]); m2iso = miso->at((*m2idx)[0]); trig1m = (*hlt1m); trig2m = (*hlt2m); outtree->Fill(); } outtree->Write(); outfile->Close(); }