void analyzer() { TString processName = "ZJets"; TFile* f = TFile::Open(Form("hist_%s.root", processName.Data()), "recreate"); // Create chain of root trees TChain chain("DelphesMA5tune"); //kisti //chain.Add("/cms/home/tjkim/fcnc/sample/ZToLL50-0Jet_sm-no_masses/events_*.root"); //hep chain.Add("/Users/tjkim/Work/fcnc/samples/ZToLL50-0Jet_sm-no_masses/events_*.root"); // Create object of class ExRootTreeReader ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t numberOfEntries = treeReader->GetEntries(); // Get pointers to branches used in this analysis TClonesArray *branchMuon = treeReader->UseBranch("DelphesMA5tuneMuon"); // Book histograms TH1 *histDiMuonMass = new TH1F("dimuon_mass","Di-Muon Invariant Mass (GeV)",100, 50, 150); // Loop over all events for(Int_t entry = 0; entry < numberOfEntries; ++entry) { // Load selected branches with data from specified event treeReader->ReadEntry(entry); int nmuon = 0; for( int i = 0; i < branchMuon->GetEntries(); i++) { Muon *muon = (Muon*) branchMuon->At(i); if( muon->PT <= 20 || abs(muon->Eta) >= 2.4 ) continue; nmuon = nmuon + 1 ; } if( nmuon >= 2){ Muon *mu1 = (Muon*) branchMuon->At(0); Muon *mu2 = (Muon*) branchMuon->At(1); // Plot di-muon invariant mass histDiMuonMass->Fill(((mu1->P4()) + (mu2->P4())).M()); } } // Show resulting histograms histDiMuonMass->Write(); f->Close(); }
plotDelphes3(TString inputName){ gSystem->Load("libDelphes"); // Create chain of root trees TChain chain("Delphes"); chain.Add(inputName.Data()); // Create object of class ExRootTreeReader ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t numberOfEntries = treeReader->GetEntries(); // Get pointers to branches used in this analysis TClonesArray *b_Jet = treeReader->UseBranch("Jet"); TClonesArray *b_Electron = treeReader->UseBranch("Electron"); TClonesArray *b_Muon = treeReader->UseBranch("Muon"); TClonesArray *b_MET = treeReader->UseBranch("MissingET"); TClonesArray *b_Truth = treeReader->UseBranch("Particle"); TString outputName(inputName); outputName="test.root"; TFile* output=new TFile(outputName,"RECREATE"); // Loop over all events for(Int_t entry = 0; entry < numberOfEntries; ++entry) { if(entry==maxEvents) break; if(entry%10000==0)cout<<entry<<endl; // Load selected branches with data from specified event treeReader->ReadEntry(entry); if(b_MET->GetEntries() > 0){ MissingET* met = (MissingET*) b_MET->At(0); h_MET->Fill(met->MET); } int nJets=0, nBJets=0; for(int jetNo=0; jetNo<b_Jet->GetEntries(); jetNo++){ Jet *jet=(Jet*) b_Jet->At(jetNo); if(jet->PT>jet_pT_min && fabs(jet->Eta)<jet_eta_max){ nJets++; h_jet_pT->Fill(jet->PT); h_jet_eta->Fill(jet->Eta); if(jet->BTag){ nBJets++; h_bJet_pT->Fill(jet->PT); h_bJet_eta->Fill(jet->Eta); } } } h_jet_mult->Fill(nJets); h_bJet_mult->Fill(nBJets); int nElectrons=0; for(int electronNo=0; electronNo<b_Electron->GetEntries(); electronNo++){ Electron *electron=(Electron*) b_Electron->At(electronNo); if(electron->PT>electron_pT_min && fabs(electron->Eta)<electron_eta_max){ nElectrons++; h_electron_pT->Fill(electron->PT); h_electron_eta->Fill(electron->Eta); } } h_electron_mult->Fill(nElectrons); int nMuons=0; for(int muonNo=0; muonNo<b_Muon->GetEntries(); muonNo++){ Muon *muon=(Muon*) b_Muon->At(muonNo); if(muon->PT>muon_pT_min && fabs(muon->Eta)<muon_eta_max){ nMuons++; h_muon_pT->Fill(muon->PT); h_muon_eta->Fill(muon->Eta); } } h_muon_mult->Fill(nMuons); int nGenMuons=0, nTMRMuonsIDIso=0; for(int genParticleNo=0; genParticleNo<b_Truth->GetEntries(); genParticleNo++){ GenParticle *particle=(GenParticle*) b_Truth->At(genParticleNo); if (particle->Status==3){ if (abs(particle->PID)==13){ nGenMuons++; h_genMuon_pT->Fill(particle->PT); h_genMuon_eta->Fill(fabs(particle->Eta)); h_genMuon_eta_pT->Fill(fabs(particle->Eta),particle->PT); for(int muonNo=0; muonNo<b_Muon->GetEntries(); muonNo++){ Muon *muon=(Muon*) b_Muon->At(muonNo); if(truthMatch(1,muon->Eta,muon->Phi,1,particle->Eta,particle->Phi)){ nTMRMuonsIDIso++; h_TMRMuon_ID_Iso_pT->Fill(muon->PT); h_TMRMuon_ID_Iso_eta->Fill(fabs(muon->Eta)); h_TMRMuon_ID_Iso_eta_pT->Fill(fabs(muon->Eta),muon->PT); break; //To prevent 2 reco mu per truth mu } } } } } h_genMuon_mult->Fill(nGenMuons); h_TMRMuon_ID_Iso_mult->Fill(nTMRMuonsIDIso); } writeOutput(); }
int main(int argc, char*argv[]) { //---------------------------------------------------------------------------------------- ///////////////////////////////////////////// Read Input Parameters //////////////////// //---------------------------------------------------------------------------------------- if (argc < 2) {printf("******Error in input parameters\n");return 1;} CommandLine c1; c1.parse(argc,argv); gROOT->ProcessLine("#include >vector<"); string InputFileName = c1.getValue<string> ("InputFileName"); string OutputFileName = c1.getValue<string> ("OutputFileName"); //string OutputFileTag = c1.getValue<string> ("OutputFileTag"); //string JetAlgo = c1.getValue<string> ("JetAlgo"); //vector<string> HLTbit = c1.getVector<string> ("HLTbit",""); int NENTRIES = c1.getValue<int> ("NEntries"); //bool DATA = c1.getValue<bool> ("DATA"); // bool SaveData = c1.getValue<bool> ("SaveData"); //double MH2 = c1.getValue<double> ("MH2"); //double cross = c1.getValue<double> ("CrossSection"); //double efficiency = c1.getValue<double> ("Efficiency"); //double MUONPT_CUT=23.; //double ELECPT_CUT=33.; //double MET_CUT=40.; // input parametrelerini ekrana yazdiriyor if (!c1.check()) return 0; c1.print(); // Printing the options string outputfile = OutputFileName + ".root"; // output dosyasini olustur. TFile *outf = new TFile(outputfile.c_str(),"RECREATE"); cout << "________________________________________________________________\n"; cout << "\n"; cout << "time start " << endl; gSystem->Exec("date '+%H:%M:%S'"); //---------------------------------------------------------------------------------------- /////////////////////////////////////////////// Histogram Output /////////////////////// //---------------------------------------------------------------------------------------- // Book histograms //---------------------------------------------------------------------------------------- //output dosyasinda jets adinda bir klasor olustur //jetdir adinda olusan dizine git ve asagidaki histogramlari, ilgili degiskenleri uyarinca tanimla //---------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////// //////////Eta'sı 2.5 ' den küçük Jetlerin Pt Kesimine Göre Grafikleri// /////////////////////////////////////////////////////////////////////// /* char jet_ptcut_etacut_hist_title[100]; char jet_ptcut_etacut_hist_name[100]; for(int b=0; b<4;b++) { for (int a =0; a < 4; a++) { sprintf(jet_ptcut_etacut_hist_title,"Ptcut-%i%i Jet Eta < 2.5",a,b); sprintf(jet_ptcut_etacut_hist_name ,"Jet_ptcut_etacut_%i%i",a,b); jet_ptcut_etacut_[a][b] = new TH1F(jet_ptcut_etacut_hist_name , jet_ptcut_etacut_hist_title , 100, 0, 350); } } */ //vector<char> hist_name(100); //vector<char> hist_title(1000); /*for(int i=0; i<4; i++){ cout << JET_NAME[i] << endl; } */ char hist_name[100]; char hist_title[1000]; string JET_NAME[] = {"Leading_Jet","Second_Jet","Third_Jet","Fourth_Jet"}; string Cut_Name[] = {"No_Cut","Eta_Cut","R_Cut","R_Eta_Cut"}; /////////////////////////////////////////////////////////////////////////////////////////// //////////GenJet and CaloJet Ht Distribution ////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// TDirectory *Ht_hist= outf->mkdir("Ht_hist"); Ht_hist->cd(); TH1F *hist_genjetht = new TH1F("Ht_GenJet_All" , "Ht_GenJet_All ", 500.0, 0.0, 10000.0); TH1F *hist_calojetht = new TH1F("Ht_CaloJet_All" , "Ht_CaloJet_All", 500.0, 0.0, 10000.0); TH1F *hist_genjet_R2 = new TH1F("Ht_GenJet_R2" , "Ht_GenJet_R2 ", 500.0, 0.0, 10000.0); TH1F *hist_genjet_R3 = new TH1F("Ht_GenJet_R3" , "Ht_GenJet_R3 ", 500.0, 0.0, 10000.0); TH1F *hist_calojet_R2 = new TH1F("Ht_CaloJet_R2" , "Ht_GenJet_R2 ", 500.0, 0.0, 10000.0); TH1F *hist_calojet_R3 = new TH1F("Ht_CaloJet_R3" , "Ht_GenJet_R3 ", 500.0, 0.0, 10000.0); //hist_genjet_R3 ////////////////////////////////////////////////////////////////////////////////////////// //--------------------------Rapidity Resolution for PT Intervals------------------------// ////////////////////////////////////////////////////////////////////////////////////////// //------------For Each Eta Intervals Between 0 - 2.5, PT Intervals(0-6000)------// //Satırlar PT Aralıklarını ve Sütunlar ise Rapidity Aralıklarını Göstermekedir.--/ TDirectory *Rap_Resolution = outf->mkdir("Rap_Resolution"); Rap_Resolution->cd(); TH1F *hist_deltaY[14][5]; for (int i=0; i<12; i++) { for (int j=0; j<5; j++) { sprintf(hist_name, "DeltaY_%ipt%i_y%i" ,PT_BIN_ARRAY[i] ,PT_BIN_ARRAY[i+1] ,j); sprintf(hist_title,"%i<Pt<%i, Rapidity resolution for %.1f < y < %.1f",PT_BIN_ARRAY[i],PT_BIN_ARRAY[i+1],j*0.5,(j+1)*0.5); hist_deltaY[i][j]=new TH1F(hist_name, hist_title, 100, -0.2, +0.2 ); } } //------------For All Eta Values, PT Intervals(0-6000)---------------------------// TDirectory *Rap_Reso_TH2F = outf->mkdir("Rap_Resolution_TH2F"); Rap_Reso_TH2F->cd(); TH2F *hist_DeltaY_vs_GenY[14]; for(int i=0; i<13; i++) { sprintf(hist_name, "DeltaY_vs_GenY_%ipt%i_y%i" ,PT_BIN_ARRAY[i] ,PT_BIN_ARRAY[i+1] ,i); sprintf(hist_title,"%i<Pt<%i, Rapidity Reso all Y" ,PT_BIN_ARRAY[i],PT_BIN_ARRAY[i+1]); hist_DeltaY_vs_GenY[i] = new TH2F(hist_name, hist_title, 150, -5.0, 5.0 , 150.0, -0.5, 0.5 ); } ////////////////////////////////////////////////////////////////////////////////////////// //--------------------------PT Resolution for Each Jet ---------------------------------// ////////////////////////////////////////////////////////////////////////////////////////// //hist_name.clear(); //hist_title.clear(); TDirectory *PT_Resolution_TH2F= outf->mkdir("PT_Resolution_TH2F"); PT_Resolution_TH2F->cd(); //Satırlar Yapılan Cutları ve Sütunlar İse Kaçıncı Jet Olduğunu Göstermektedir.-// TH2F *hist_PT_Reso[4][4]; for(int i=0; i<4; i++) { for(int j=0; j<4; j++) { sprintf(hist_name, "PT_Reso_%s_%s" ,Cut_Name[i].c_str(),JET_NAME[j].c_str()); sprintf(hist_title, "%s_DeltaPT_over_GenPT_vs_GenPT_for_%s" ,Cut_Name[i].c_str(),JET_NAME[j].c_str()); hist_PT_Reso[i][j] = new TH2F(hist_name, hist_title, 250.0, 0.0, 6500.0 ,250.0, -0.5, 0.5); } } ////////////////////////////////////////////////////////////////////////////////////////// //--------------------------HT Resolution for Each Jet ---------------------------------// ////////////////////////////////////////////////////////////////////////////////////////// //hist_name.clear(); //hist_title.clear(); int jet_num2[] = {1,2,3,4}; TDirectory *HT_Resolution_TH2F= outf->mkdir("HT_Resolution_TH2F"); HT_Resolution_TH2F->cd(); //Satırlar Jet Sayısını Belirtir ve Sütunlar İse Yapılan Cutları Göstermektedir.-// TH2F *hist_HT_Reso[4][4]; for(int i=0; i<4; i++) { for(int j=0; j<4; j++) { sprintf(hist_name, "HT_Reso_Jet_Number_%i_%s" ,jet_num2[i],Cut_Name[j].c_str()); sprintf(hist_title, "HT_Resolution_for_Jet_Number >= %i and %s PT_Cut 50 GeV" ,jet_num2[i],Cut_Name[j].c_str()); hist_HT_Reso[i][j] = new TH2F(hist_name, hist_title, 250.0, 0.0, 6500.0 ,250.0, -0.5, 0.5); } } //---------------------------------------------------------------------------------------- //////////////////////////////////////// My Data STructure ///////////////////////////// //---------------------------------------------------------------------------------------- TH1F::SetDefaultSumw2(true); gSystem->Load("libExRootAnalysis"); gSystem->Load("libDelphes"); // Create chain of root trees TChain chain("Delphes"); //chain.Add(InputFileName.c_str()); char filename[1000]; FILE *input; input = fopen(InputFileName.c_str(),"r"); if (input != NULL) { // lets read each line and get the filename from it while (fscanf(input,"%s\n",filename) != EOF) { printf("%s\n",filename); chain.Add(filename); } } // Create object of class ExRootTreeReader ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t numberOfEntries = treeReader->GetEntries(); // Get pointers to branches used in this analysis TClonesArray *branchJet = treeReader->UseBranch("Jet"); TClonesArray *branchGenJet = treeReader->UseBranch("GenJet"); //TClonesArray *branchSHT = treeReader->UseBranch("ScalarHT"); //---------------------------------------------------------------------------------------- ///////////////////////////////////// LOOP Over the EVENTS //////////////////////////// //---------------------------------------------------------------------------------------- cout << "Set Branch Addresses" << endl; int decade = 0; unsigned entries = 0; if (NENTRIES==-1) entries=numberOfEntries; else entries=NENTRIES; cout << "Reading TREE: " << numberOfEntries << " events available, \n"; cout << "\t\t" << NENTRIES << " of them will be analyzed." << endl; //Jet *genjet; //Jet *calojet; vector<Jet *> mycalojet; vector<Jet *> mygenjet; //TLorentzVector jet_2[2]; //TLorentzVector jet_3[2]; //TLorentzVector jet_4[2]; //vector<Jet *> m2Jets; //vector<Jet *> m3Jets; //vector<Jet *> m4Jets; //GenJet *genjet_2[25]; //GenJet *genjet_3[25]; // Loop over all events for(Long64_t entry = 0; entry < entries; ++entry) { double progress = 10.0*entry/(1.0*entries); int k = TMath::FloorNint(progress); if (k > decade) { cout << 10*k << "%\t"; gSystem->Exec("date '+%H:%M:%S'"); cout << endl; } decade = k; // ROOT dosyalari icindeki her bir veri dallarini okuyor. treeReader->ReadEntry(entry); //################################################################################################################################################# //################################################################################################################################################# /////////////////////////////////////////////////////////////////////////////// //////////////////////////////Jet Grafikleri/////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //CaloJet İçin Ht Hesaplama ve ----------------------------------------------- double calo_jet_ht_sum = 0.0; int jet_counter=0; mycalojet.clear(); if(branchJet->GetEntries() > 0) // Bütün Jetler İçin { for (int i=0; i< branchJet->GetEntries(); i++) { mycalojet.push_back((Jet*) branchJet->At(i)); calo_jet_ht_sum = calo_jet_ht_sum + mycalojet[i]->PT; if(mycalojet[i]->PT > 50 && abs( mycalojet[i]->Eta ) <= 2.5) { jet_counter++; } } hist_calojetht->Fill(calo_jet_ht_sum); if(jet_counter >=2)hist_calojet_R2->Fill(calo_jet_ht_sum); if(jet_counter >=3)hist_calojet_R3->Fill(calo_jet_ht_sum); } //GenJet İçin Ht Hesaplama---------------------------------------------------- double gen_jet_ht_sum = 0.0; jet_counter=0; mygenjet.clear(); if(branchGenJet->GetEntries() > 0) // Bütün Jetler İçin { for (int i=0; i< branchGenJet->GetEntries(); i++) { mygenjet.push_back((Jet*) branchGenJet->At(i)); gen_jet_ht_sum = gen_jet_ht_sum + mygenjet[i]->PT; if(mygenjet[i]->PT > 50 && abs( mygenjet[i]->Eta ) <= 2.5) { jet_counter++; } } hist_genjetht->Fill(gen_jet_ht_sum); if(jet_counter >=2)hist_genjet_R2->Fill(gen_jet_ht_sum); if(jet_counter >=3)hist_genjet_R3->Fill(gen_jet_ht_sum); } //--------------------------------------------------------------------- //Çözünürlük Grafikleri------------------------------------------------ //--------------------------------------------------------------------- //-----------Eta Çözünürlüğü---------------------------------------------------------------------------------------------- mycalojet.clear(); mygenjet.clear(); double delta_Phi = 0.0; double delta_Eta = 0.0; double delta_R = 0.0; //double pt_reso_etacut = 0.0; double pt_reso = 0.0; //int counterjet = 0; jet_counter=0; calo_jet_ht_sum = 0.0; gen_jet_ht_sum = 0.0; double calo_jet_ht_sum_Eta = 0.0; double gen_jet_ht_sum_Eta = 0.0; double calo_jet_ht_sum_delta_R = 0.0; double gen_jet_ht_sum_delta_R = 0.0; double calo_jet_ht_sum_Eta_delta_R = 0.0; double gen_jet_ht_sum_Eta_delta_R = 0.0; double ht_reso = 0.0; double ht_reso_Eta = 0.0; double ht_reso_delta_R = 0.0; double ht_reso_Eta_delta_R = 0.0; if(branchGenJet->GetEntries() > JET_NUMBER && branchJet->GetEntries() > JET_NUMBER && branchGenJet->GetEntries() == branchJet->GetEntries() ) { for (int i=0; i< branchGenJet->GetEntries(); i++) { mycalojet.push_back((Jet*) branchJet->At(i)); mygenjet.push_back((Jet*) branchGenJet->At(i)); jet_counter++; for (int j=0; j <12; j++) { if(mygenjet[i]-> PT > PT_BIN_ARRAY[j] && mygenjet[i]-> PT < PT_BIN_ARRAY[j+1] && mycalojet[i]-> PT > PT_BIN_ARRAY[j] && mycalojet[i]-> PT < PT_BIN_ARRAY[j+1]) { if (abs(mygenjet[i]->Eta)<0.5) hist_deltaY[j][0]->Fill(mygenjet[i]->Eta - mycalojet[i]->Eta); if (abs(mygenjet[i]->Eta)>0.5 && abs(mygenjet[i]->Eta)<1.0) hist_deltaY[j][1]->Fill(mygenjet[i]->Eta - mycalojet[i]->Eta); if (abs(mygenjet[i]->Eta)>1.0 && abs(mygenjet[i]->Eta)<1.5) hist_deltaY[j][2]->Fill(mygenjet[i]->Eta - mycalojet[i]->Eta); if (abs(mygenjet[i]->Eta)>1.5 && abs(mygenjet[i]->Eta)<2.0) hist_deltaY[j][3]->Fill(mygenjet[i]->Eta - mycalojet[i]->Eta); if (abs(mygenjet[i]->Eta)>2.0 && abs(mygenjet[i]->Eta)<2.5) hist_deltaY[j][4]->Fill(mygenjet[i]->Eta - mycalojet[i]->Eta); hist_DeltaY_vs_GenY[j]->Fill( mygenjet[i]->Eta, mygenjet[i]->Eta - mycalojet[i]->Eta); } } //-----PT Resolution Histogramları İÇin---------------------------------// delta_Phi = abs(mygenjet[i]->Phi - mycalojet[i]->Phi); delta_Eta = abs(mygenjet[i]->Eta - mycalojet[i]->Eta); delta_R = sqrt( pow(delta_Phi,2) + pow(delta_Eta,2)); pt_reso = ( mygenjet[i]->PT - mycalojet[i]->PT ) / (mygenjet[i]->PT); if(i<=3) hist_PT_Reso[0][i]->Fill(mygenjet[i]->PT, pt_reso); if(i<=3 && abs(mycalojet[i]->Eta) < 2.5 && abs(mygenjet[i]->Eta) < 2.5 ) hist_PT_Reso[1][i]->Fill(mygenjet[i]->PT, pt_reso); if(delta_R < 0.25 && i<=3) hist_PT_Reso[2][i]->Fill(mygenjet[i]->PT, pt_reso); if(delta_R < 0.25 && i<=3 && abs(mycalojet[i]->Eta) < 2.5 && abs(mygenjet[i]->Eta) < 2.5) hist_PT_Reso[3][i]->Fill(mygenjet[i]->PT, pt_reso); //-----HT Hesapla For Each Cut PT_CUT 50 GeV --------------------------------// if(mygenjet[i]->PT > 50) gen_jet_ht_sum = gen_jet_ht_sum + mygenjet[i]->PT; if(mycalojet[i]->PT > 50)calo_jet_ht_sum = calo_jet_ht_sum + mycalojet[i]->PT; if(mygenjet[i]->PT > 50 && abs(mygenjet[i]->Eta) < 2.5) gen_jet_ht_sum_Eta = gen_jet_ht_sum_Eta + mygenjet[i]->PT; if(mycalojet[i]->PT > 50 && abs(mycalojet[i]->Eta) < 2.5) calo_jet_ht_sum_Eta = calo_jet_ht_sum_Eta + mycalojet[i]->PT; if(mygenjet[i]->PT > 50 && delta_R < 0.25 ) gen_jet_ht_sum_delta_R = gen_jet_ht_sum_delta_R + mygenjet[i]->PT; if(mycalojet[i]->PT > 50 && delta_R < 0.25 ) calo_jet_ht_sum_delta_R = calo_jet_ht_sum_delta_R + mycalojet[i]->PT; if(mygenjet[i]->PT > 50 && delta_R < 0.25 && abs(mygenjet[i]->Eta) < 2.5) gen_jet_ht_sum_Eta_delta_R = gen_jet_ht_sum_Eta_delta_R + mygenjet[i]->PT; if(mycalojet[i]->PT > 50 && delta_R < 0.25 && abs(mycalojet[i]->Eta) < 2.5)calo_jet_ht_sum_Eta_delta_R = calo_jet_ht_sum_Eta_delta_R + mycalojet[i]->PT; } //-----HT Histogramlar ve Resolution Hesapla For Each Cut --------------------------------// ht_reso = abs((gen_jet_ht_sum - calo_jet_ht_sum)) / (gen_jet_ht_sum); ht_reso_Eta = abs((gen_jet_ht_sum_Eta - calo_jet_ht_sum_Eta )) / (gen_jet_ht_sum_Eta ); ht_reso_delta_R = abs((gen_jet_ht_sum_delta_R - calo_jet_ht_sum_delta_R) / (gen_jet_ht_sum_delta_R)); ht_reso_Eta_delta_R = abs((gen_jet_ht_sum_Eta_delta_R - calo_jet_ht_sum_Eta_delta_R) / (gen_jet_ht_sum_Eta_delta_R)); for(int i=0; i<4; i++) { if(jet_counter >= (i+1)) hist_HT_Reso[i][0]->Fill(gen_jet_ht_sum, ht_reso); if(jet_counter >= (i+1)) hist_HT_Reso[i][1]->Fill(gen_jet_ht_sum_Eta, ht_reso_Eta); if(jet_counter >= (i+1)) hist_HT_Reso[i][2]->Fill(gen_jet_ht_sum_delta_R, ht_reso_delta_R); if(jet_counter >= (i+1)) hist_HT_Reso[i][3]->Fill(gen_jet_ht_sum_Eta_delta_R, ht_reso_Eta_delta_R); } } } //end of event loop //////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------------------------------------------- //////////////////////////////// Saving the histograms into output ////////////////////////////////////////// //--------------------------------------------------------------------------------------------------------- // end of event loop //myfile.close(); outf->Write(); outf->Close(); //end of main loop }
int main (int argc, char *argv[]) { if (argc != 3) { cout << "Usage: " << argv[0] << " INPUT_FILE OUTPUT_FILE" << endl; cout << " or: " << argv[0] << " INPUT_LIST OUTPUT_FILE" << endl; cout << "Run VBF H->4mu analysis on INPUT_FILE and store output to OUTPUT_FILE. If the" << endl; cout << "first argument is a text file, analysis is run on each file listed inside." << endl; cout << endl; return 0; } string inputFile = argv[1], outputFile = argv[2], upperInputFile; upperInputFile.resize (inputFile.length ()); transform (inputFile.begin (), inputFile.end (), upperInputFile.begin (), ::toupper); //Create lists of files for each thread vector<string> fileList; if (upperInputFile.length () < 5 || upperInputFile.substr (upperInputFile.length () - 5, 5) != ".ROOT") { ifstream fin (inputFile.c_str ()); string line; while (getline (fin, line)) fileList.push_back (line); fin.close (); } else fileList.push_back (inputFile); TFile *fout = TFile::Open (outputFile.c_str (), "recreate"); fout->cd (); TTree* myTree_ = new TTree("myTree", "myTree"); //----- gen particles myTree_ -> Branch("ngenCand", &ngenCand_, "ngenCand/I") ; myTree_ -> Branch("genCandPt", genCandPt_, "genCandPt[ngenCand]/F") ; myTree_ -> Branch("genCandEta" , genCandEta_, "genCandEta[ngenCand]/F") ; myTree_ -> Branch("genCandPhi", genCandPhi_, "genCandPhi[ngenCand]/F") ; myTree_ -> Branch("genCandMass", genCandMass_, "genCandMass[ngenCand]/F") ; myTree_ -> Branch("genCandStatus", genCandStatus_, "genCandStatus[ngenCand]/F"); myTree_ -> Branch("genCandPdgId", genCandPdgId_, "genCandPdgId[ngenCand]/I"); myTree_ -> Branch("genCandMothPdgId", genCandMothPdgId_, "genCandMothPdgId[ngenCand]/I"); //vbf quarks myTree_ -> Branch("nvbfQuark", &nvbfQuark_, "nvbfQuark/I") ; myTree_ -> Branch("vbfQuarkPt", vbfQuarkPt_, "vbfQuarkPt[nvbfQuark]/F") ; myTree_ -> Branch("vbfQuarkEta" , vbfQuarkEta_, "vbfQuarkEta[nvbfQuark]/F") ; myTree_ -> Branch("vbfQuarkPhi", vbfQuarkPhi_, "vbfQuarkPhi[nvbfQuark]/F") ; myTree_ -> Branch("vbfQuarkMass", vbfQuarkMass_, "vbfQuarkMass[nvbfQuark]/F") ; myTree_ -> Branch("vbfQuarkStatus", vbfQuarkStatus_, "vbfQuarkStatus[nvbfQuark]/F"); myTree_ -> Branch("vbfQuarkPdgId", vbfQuarkPdgId_, "vbfQuarkPdgId[nvbfQuark]/I"); myTree_ -> Branch("vbfQuarkMothPdgId", vbfQuarkMothPdgId_, "vbfQuarkMothPdgId[nvbfQuark]/I"); //genjet myTree_ -> Branch("ngenJet", &ngenJet_, "ngenJet/I"); myTree_ -> Branch("genJetPt", genJetPt_, "genJetPt[ngenJet]/F"); myTree_ -> Branch("genJetMass", genJetMass_, "genJet[ngenJet]/F"); myTree_ -> Branch("genJetEta", genJetEta_, "genJetEta[ngenJet]/F"); myTree_ -> Branch("genJetPhi", genJetPhi_, "genJetPhi[ngenJet]/F"); myTree_ -> Branch("genJetEmE", genJetEmE_, "genJeEmEt[ngenJet]/F"); myTree_ -> Branch("genJetHadrE", genJetHadrE_, "genJetHadrE[ngenJet]/F"); myTree_ -> Branch("genJetInvE", genJetInvE_, "genJetInvE[ngenJet]/F"); myTree_ -> Branch("genJetAuxE", genJetAuxE_, "genJetAuxE[ngenJet]/F"); myTree_ -> Branch("genJetNconst", genJetNconst_, "genJetNconst[ngenJet]/I"); //tracks myTree_ -> Branch("ntrk", &ntrk_, "ntrk/I"); myTree_ -> Branch("trkPt", trkPt_, "trkPt[ntrk]/F"); myTree_ -> Branch("trkEta", trkEta_, "trkEta[ntrk]/F"); myTree_ -> Branch("trkPhi", trkPhi_, "trkPhi[ntrk]/F"); //trkjet myTree_ -> Branch("ntrkJet", &ntrkJet_, "ntrkJet/I"); myTree_ -> Branch("trkJetPt", trkJetPt_, "trkJetPt[ntrkJet]/F"); myTree_ -> Branch("trkJetMass", trkJetMass_, "trkJet[ntrkJet]/F"); myTree_ -> Branch("trkJetEta", trkJetEta_, "trkJetEta[ntrkJet]/F"); myTree_ -> Branch("trkJetPhi", trkJetPhi_, "trkJetPhi[ntrkJet]/F"); myTree_ -> Branch("trkJetNtrk", trkJetNtrk_, "trkJetNtrk[ntrkJet]/F"); myTree_ -> Branch("nJet", &nJet_, "nJet/I"); myTree_ -> Branch("JetPt", JetPt_, "JetPt[nJet]/F"); myTree_ -> Branch("JetMass", JetMass_, "Jet[nJet]/F"); myTree_ -> Branch("JetEta", JetEta_, "JetEta[nJet]/F"); myTree_ -> Branch("JetPhi", JetPhi_, "JetPhi[nJet]/F"); myTree_ -> Branch("JetNtrk", JetNtrk_, "JetNtrk[nJet]/F"); myTree_ -> Branch("ngghQuark", &ngghQuark_, "ngghQuark/I") ; myTree_ -> Branch("gghQuarkPt", gghQuarkPt_, "gghQuarkPt[ngghQuark]/F") ; myTree_ -> Branch("gghQuarkEta" , gghQuarkEta_, "gghQuarkEta[ngghQuark]/F") ; myTree_ -> Branch("gghQuarkPhi", gghQuarkPhi_, "gghQuarkPhi[ngghQuark]/F") ; myTree_ -> Branch("gghQuarkMass", gghQuarkMass_, "gghQuarkMass[ngghQuark]/F") ; myTree_ -> Branch("gghQuarkStatus", gghQuarkStatus_, "gghQuarkStatus[ngghQuark]/F"); myTree_ -> Branch("gghQuarkPdgId", gghQuarkPdgId_, "gghQuarkPdgId[ngghQuark]/I"); myTree_ -> Branch("gghQuarkMothPdgId", gghQuarkMothPdgId_, "gghQuarkMothPdgId[ngghQuark]/I"); myTree_ -> Branch("nZ", &nZ_, "nZ/I") ; myTree_ -> Branch("ZPt", ZPt_, "ZPt[nZ]/F") ; myTree_ -> Branch("ZEta" , ZEta_, "ZEta[nZ]/F") ; myTree_ -> Branch("ZPhi", ZPhi_, "ZPhi[nZ]/F") ; myTree_ -> Branch("ZMass", ZMass_, "ZMass[nZ]/F") ; myTree_ -> Branch("ZStatus", ZStatus_, "ZStatus[nZ]/F"); myTree_ -> Branch("ZPdgId", ZPdgId_, "ZPdgId[nZ]/I"); //myTree_ -> Branch("ZMothPdgId", ZMothPdgId_, "ZMothPdgId[nZ]/I"); myTree_ -> Branch("nMu", &nMu_, "nMu/I") ; myTree_ -> Branch("MuPt", MuPt_, "MuPt[nMu]/F") ; myTree_ -> Branch("MuEta" , MuEta_, "MuEta[nMu]/F") ; myTree_ -> Branch("MuPhi", MuPhi_, "MuPhi[nMu]/F") ; myTree_ -> Branch("MuMass", MuMass_, "MuMass[nMu]/F") ; myTree_ -> Branch("MuStatus", MuStatus_, "MuStatus[nMu]/F"); myTree_ -> Branch("MuPdgId", MuPdgId_, "MuPdgId[nMu]/I"); //myTree_ -> Branch("MuMothPdgId", MuMothPdgId_, "MuMothPdgId[nMu]/I"); myTree_->Branch("npu", &npu_, "npu/I"); myTree_->Branch("pu_zpos", &pu_zpos_, "pu_zpos[npu]/F"); myTree_->Branch("pu_sumpt_lowpt", &pu_sumpt_lowpt_, "pu_sumpt_lowpt[npu]/F"); myTree_->Branch("pu_sumpt_highpt", &pu_sumpt_highpt_, "pu_sumpt_highpt[npu]/F"); myTree_->Branch("pu_ntrks_lowpt", &pu_ntrks_lowpt_, "pu_ntrks_lowpt[npu]/F"); myTree_->Branch("pu_ntrks_highpt", &pu_ntrks_highpt_, "pu_ntrks_highpt[npu]/F"); myTree_->Branch("vxMC",&vxMC_,"vxMC/F"); myTree_->Branch("vyMC",&vyMC_,"vyMC/F"); myTree_->Branch("vzMC",&vzMC_,"vzMC/F"); myTree_->Branch("nvertex",&nvertex_,"nvertex/I"); myTree_->Branch("vx",&vx_,"vx[nvertex]/F"); myTree_->Branch("vy",&vy_,"vy[nvertex]/F"); myTree_->Branch("vz",&vz_,"vz[nvertex]/F"); myTree_->Branch("vntracks",&vntracks_,"vntracks[nvertex]/F"); myTree_->Branch("vchi2",&vchi2_,"vchi2[nvertex]/F"); myTree_->Branch("vndof",&vndof_,"vndof[nvertex]/F"); myTree_->Branch("mH", &mH_, "mH/I"); signal (SIGINT, signalHandler); //Create chain of root trees TChain chain("Delphes"); for (const auto &file : fileList) chain.Add (file.c_str ()); // Create object of class ExRootTreeReader ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t numberOfEntries = treeReader->GetEntries(); cout << "================================================================================" << endl; cout << "processing " << numberOfEntries << " events..." << endl; cout << "================================================================================" << endl << endl; // Get pointers to branches used in this analysis unordered_map<string, TClonesArray *> branches; branches["Event"] = treeReader->UseBranch("Event"); branches["Particle"] = treeReader->UseBranch("Particle"); branches["VBFquarks"] = treeReader->UseBranch("VBFquarks"); branches["UnsortedCluster"] = treeReader->UseBranch("UnsortedCluster"); branches["NPU"] = treeReader->UseBranch("NPU"); branches["Jet"] = treeReader->UseBranch("Jet"); branches["JetTRK"] = treeReader->UseBranch("JetTRK"); //branches["JetGenClosest"] = treeReader->UseBranch("JetGenClosest"); //branches["JetGenBest"] = treeReader->UseBranch("JetGenBest"); branches["JetNoCHS"] = treeReader->UseBranch("JetNoCHS"); branches["BeamSpotParticle"] = treeReader->UseBranch("BeamSpotParticle"); branches["Track"] = treeReader->UseBranch("Track"); branches["Rho"] = treeReader->UseBranch("Rho"); branches["GenJet"] = treeReader->UseBranch("GenJet"); // Loop over all events for(Int_t entry = 0; entry < numberOfEntries && !interrupted; ++entry) { if (!(entry % REPORT_EVERY)) cout << "processing event " << (entry + 1) << "..." << endl; treeReader->ReadEntry(entry); analyze (branches, myTree_); } myTree_->Write(); fout->Close (); delete treeReader; }
void vbf_bbbb_select(const TString confname="test_vbf.txt", const Float_t xsec=1.0, const Float_t totalEvents=100, const TString outputfile="test.root") { // declare constants const Int_t B_ID_CODE = 5; const Int_t H_ID_CODE = 25; const Float_t MAX_MATCH_DIST = 0.5; // read input input file TChain chain("Delphes"); TString inputfile; ifstream ifs; ifs.open(confname); assert(ifs.is_open()); string line; while (getline(ifs, line)) { stringstream ss(line);; ss >> inputfile; chain.Add(inputfile); } ifs.close(); ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t numberOfEntries = treeReader->GetEntries(); TClonesArray *branchJet = treeReader->UseBranch("Jet"); TClonesArray *branchGenJet = treeReader->UseBranch("GenJet"); TClonesArray *branchParticle = treeReader->UseBranch("Particle"); //set up loop variables GenParticle *genParticle=0; Jet *genJet=0; Jet *jet=0; // set up storage variables Jet *jetB1=0, *jetB2=0, *jetB3=0, *jetB4=0; Jet *jet1=0, *jet2=0; GenParticle *genB1=0, *genB2=0, *genB3=0, *genB4=0; GenParticle *genH1=0, *genH2=0; Jet *genJetB1=0, *genJetB2=0, *genJetB3=0, *genJetB4=0; Jet *genJetVBF1=0, *genJetVBF2=0; Int_t iB1=-1, iB2=-1, iB3=-1, iB4=-1; Int_t iH1=-1, iH2=-1; Int_t iJet1=-1, iJet2=-1; Int_t iGenB1=-1, iGenB2=-1, iGenB3=-1, iGenB4=-1; Int_t iGenJetB1=-1, iGenJetB2=-1, iGenJetB3=-1, iGenJetB4=-1; Int_t iGenJetVBF1=-1, iGenJetVBF2=-1; Int_t iHmatch1=-1, iHmatch2=-1, iHmatch3=-1, iHmatch4=-1; LorentzVector *sRecoB1=0, *sRecoB2=0, *sRecoB3=0, *sRecoB4=0; LorentzVector *sGenJetB1=0, *sGenJetB2=0, *sGenJetB3=0, *sGenJetB4=0; LorentzVector *sGenJetVBF1=0, *sGenJetVBF2=0; LorentzVector *sGenB1=0, *sGenB2=0, *sGenB3=0, *sGenB4=0; LorentzVector *sGenH1=0, *sGenH2=0; LorentzVector *sRecoJet1=0, *sRecoJet2=0; TFile *outFile = new TFile(outputfile, "RECREATE"); // tree to hold information about selected events TTree *outTree = new TTree("Events", "Events"); outTree->Branch("iHmatch1", &iHmatch1, "iHmatch1/i"); // which Higgs does b-jet 1 come from outTree->Branch("iHmatch2", &iHmatch2, "iHmatch2/i"); // which Higgs does b-jet 2 come from outTree->Branch("iHmatch3", &iHmatch3, "iHmatch3/i"); // which Higgs does b-jet 3 come from outTree->Branch("iHmatch4", &iHmatch4, "iHmatch4/i"); // which Higgs does b-jet 4 come from outTree->Branch("sGenB1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenB1); // 4-vector for generator leading b-jet outTree->Branch("sGenB2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenB2); // 4-vector for generator b-jet outTree->Branch("sGenB3", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenB3); // 4-vector for generator b-jet outTree->Branch("sGenB4", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenB4); // 4-vector for generator b-jet outTree->Branch("sGenH1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenH1); // 4-vector for generator higgs outTree->Branch("sGenH2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenH2); // 4-vector for generator higgs outTree->Branch("sGenJetB1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetB1); // 4-vector for generator leading b-jet outTree->Branch("sGenJetB2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetB2); // 4-vector for generator b-jet outTree->Branch("sGenJetB3", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetB3); // 4-vector for generator b-jet outTree->Branch("sGenJetB4", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetB4); // 4-vector for generator b-jet outTree->Branch("sGenJetVBF1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetVBF1); // 4-vector for generator leading b-jet outTree->Branch("sGenJetVBF2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetVBF2); // 4-vector for generator b-jet outTree->Branch("sRecoB1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoB1); // 4-vector for reconstructed leading b-jet outTree->Branch("sRecoB2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoB2); // 4-vector for reconstructed b-jet outTree->Branch("sRecoB3", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoB3); // 4-vector for reconstructed b-jet outTree->Branch("sRecoB4", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoB4); // 4-vector for reconstructed b-jet outTree->Branch("sRecoJet1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoJet1); // 4-vector for reconstructed leading forward-jet outTree->Branch("sRecoJet2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoJet2); // 4-vector for reconstructed second forward-jet // define placeholder vector for things that don't exist LorentzVector nothing(-999,-999,0,-999); Int_t iMatched=0; Int_t iNot=0; Int_t iTwo=0; Int_t nM=0; for (Int_t iEntry=0; iEntry<numberOfEntries; iEntry++) { // entry loop treeReader->ReadEntry(iEntry); // ******************** // RESET // ******************** iB1=-1; iB2=-1; iB3=-1; iB4=-1; iGenB1=-1; iGenB2=-1; iGenB3=-1; iGenB4=-1; iGenJetB1=-1; iGenJetB2=-1; iGenJetB3=-1; iGenJetB4=-1; iGenJetVBF1=-1; iGenJetVBF2=-1; iH1=-1; iH2=-1; iJet1=-1; iJet2=-1; iHmatch1=-1; iHmatch2=-1; iHmatch3=-1; iHmatch4=-1; jet1=0; jet2=0; jetB1=0; jetB2=0; jetB3=0; jetB4=0; genB1=0; genB2=0; genB3=0; genB4=0; genJetB1=0; genJetB2=0; genJetB3=0; genJetB4=0; genJetVBF1=0; genJetVBF2=0; sGenB1=0; sGenB2=0; sGenB3=0; sGenB4=0; sGenJetB1=0; sGenJetB2=0; sGenJetB3=0; sGenJetB4=0; sGenJetVBF1=0; sGenJetVBF2=0; sGenH1=0; sGenH2=0; nM=0; for (Int_t iJet=0; iJet<branchJet->GetEntries(); iJet++) { // reconstructed jet loop jet = (Jet*) branchJet->At(iJet); if (fabs(jet->Eta)>4.0) continue; if (jet->PT<30) continue; if (puJetID(jet->Eta, jet->MeanSqDeltaR, jet->BetaStar)==1) continue; if (jet->BTag==0) continue; if ((jetB1)&&(deltaR(jet->Eta, jetB1->Eta, jet->Phi, jetB1->Phi) < MAX_MATCH_DIST)) continue; if ((jetB2)&&(deltaR(jet->Eta, jetB2->Eta, jet->Phi, jetB2->Phi) < MAX_MATCH_DIST)) continue; if ((jetB3)&&(deltaR(jet->Eta, jetB3->Eta, jet->Phi, jetB3->Phi) < MAX_MATCH_DIST)) continue; if ((jetB4)&&(deltaR(jet->Eta, jetB4->Eta, jet->Phi, jetB4->Phi) < MAX_MATCH_DIST)) continue; if (iB1==-1) { iB1=iJet; jetB1 = (Jet*) branchJet->At(iB1); } else if (jet->PT > jetB1->PT) { iB4=iB3; jetB4 = (Jet*) branchJet->At(iB4); iB3=iB2; jetB3 = (Jet*) branchJet->At(iB3); iB2=iB1; jetB2 = (Jet*) branchJet->At(iB2); iB1=iJet; jetB1 = (Jet*) branchJet->At(iB1); } else if (iB2==-1) { iB2=iJet; jetB2 = (Jet*) branchJet->At(iB2); } else if (jet->PT > jetB2->PT) { iB4=iB3; jetB4 = (Jet*) branchJet->At(iB4); iB3=iB2; jetB3 = (Jet*) branchJet->At(iB3); iB2=iJet; jetB2 = (Jet*) branchJet->At(iB2); } else if (iB3==-1) { iB3=iJet; jetB3 = (Jet*) branchJet->At(iB3); } else if (jet->PT > jetB3->PT) { iB4=iB3; jetB4 = (Jet*) branchJet->At(iB4); iB3=iB2; jetB3 = (Jet*) branchJet->At(iB3); } else if (iB4==-1) { iB4=iJet; jetB4 = (Jet*) branchJet->At(iB4); } else if (jet->PT > jetB4->PT) { iB4=iJet; jetB4 = (Jet*) branchJet->At(iB4); } } // end reco jet loop // get VBF jets for (Int_t iJet=0; iJet<branchJet->GetEntries(); iJet++) { // reconstructed jet loop jet = (Jet*) branchJet->At(iJet); if (fabs(jet->Eta)>4.7) continue; if (jet->PT<30) continue; if (puJetID(jet->Eta, jet->MeanSqDeltaR, jet->BetaStar)==1) continue; if ((jetB1)&&(deltaR(jet->Eta, jetB1->Eta, jet->Phi, jetB1->Phi) < MAX_MATCH_DIST)) continue; if ((jetB2)&&(deltaR(jet->Eta, jetB2->Eta, jet->Phi, jetB2->Phi) < MAX_MATCH_DIST)) continue; if ((jetB3)&&(deltaR(jet->Eta, jetB3->Eta, jet->Phi, jetB3->Phi) < MAX_MATCH_DIST)) continue; if ((jetB4)&&(deltaR(jet->Eta, jetB4->Eta, jet->Phi, jetB4->Phi) < MAX_MATCH_DIST)) continue; if (iJet1==-1) { iJet1=iJet; jet1 = (Jet*) branchJet->At(iJet1); } else if (jet->PT > jet1->PT) { iJet2=iJet1; jet2 = (Jet*) branchJet->At(iJet2); iJet1=iJet; jet1 = (Jet*) branchJet->At(iJet1); } else if (iJet2==-1) { iJet2=iJet; jet2 = (Jet*) branchJet->At(iJet2); } else if (jet->PT > jet2->PT) { iJet2=iJet; jet2 = (Jet*) branchJet->At(iJet2); } } if ( (!jetB1) || (!jetB2) || (!jetB3) || (!jetB4) || (!jet1) || (!jet2) ) continue; /* cout << "stored jets" << endl; if (jetB1) cout << "1 " << jetB1->PT << " " << jetB1->Eta << endl; if (jetB2) cout << "2 " << jetB2->PT << " " << jetB2->Eta << endl; if (jetB3) cout << "3 " << jetB3->PT << " " << jetB3->Eta << endl; if (jetB4) cout << "4 " << jetB4->PT << " " << jetB4->Eta << endl; if (jet1) cout << "V1 " << jet1->PT << " " << jet1->Eta << endl; if (jet2) cout << "V2 " << jet2->PT << " " << jet2->Eta << endl; cout << endl;*/ // fill 4-vector for leading b-jet LorentzVector vRecoB1(0,0,0,0); if (jetB1) { vRecoB1.SetPt(jetB1->PT); vRecoB1.SetEta(jetB1->Eta); vRecoB1.SetPhi(jetB1->Phi); vRecoB1.SetM(jetB1->Mass); sRecoB1 = &vRecoB1; } else sRecoB1 = ¬hing; // fill 4-vector for b-jet LorentzVector vRecoB2(0,0,0,0); if (jetB2) { vRecoB2.SetPt(jetB2->PT); vRecoB2.SetEta(jetB2->Eta); vRecoB2.SetPhi(jetB2->Phi); vRecoB2.SetM(jetB2->Mass); sRecoB2 = &vRecoB2; } else sRecoB2 = ¬hing; // fill 4-vector for b-jet LorentzVector vRecoB3(0,0,0,0); if (jetB3) { vRecoB3.SetPt(jetB3->PT); vRecoB3.SetEta(jetB3->Eta); vRecoB3.SetPhi(jetB3->Phi); vRecoB3.SetM(jetB3->Mass); sRecoB3 = &vRecoB3; } else sRecoB3 = ¬hing; // fill 4-vector for b-jet LorentzVector vRecoB4(0,0,0,0); if (jetB4) { vRecoB4.SetPt(jetB4->PT); vRecoB4.SetEta(jetB4->Eta); vRecoB4.SetPhi(jetB4->Phi); vRecoB4.SetM(jetB4->Mass); sRecoB4 = &vRecoB4; } else sRecoB4 = ¬hing; // ******************** // GEN PARTICLES // ******************** //cout << "B-QUARKS: " << endl; for (Int_t iParticle=0; iParticle<branchParticle->GetEntries(); iParticle++) { // generator particle loop genParticle = (GenParticle*) branchParticle->At(iParticle); if ( fabs(genParticle->PID) != B_ID_CODE ) continue; if (genParticle->Status != 3) continue; //cout << genParticle->PT << " " << genParticle->Eta << " " << genParticle->Phi << " " << genParticle->Status << endl; if ( deltaR(genParticle->Eta, vRecoB1.Eta(), genParticle->Phi, vRecoB1.Phi()) < MAX_MATCH_DIST ) { iGenB1 = iParticle; genB1 = (GenParticle*) branchParticle->At(iGenB1); } else if ( deltaR(genParticle->Eta, vRecoB2.Eta(), genParticle->Phi, vRecoB2.Phi()) < MAX_MATCH_DIST ) { iGenB2 = iParticle; genB2 = (GenParticle*) branchParticle->At(iGenB2); } else if ( deltaR(genParticle->Eta, vRecoB3.Eta(), genParticle->Phi, vRecoB3.Phi()) < MAX_MATCH_DIST ) { iGenB3 = iParticle; genB3 = (GenParticle*) branchParticle->At(iGenB3); } else if ( deltaR(genParticle->Eta, vRecoB4.Eta(), genParticle->Phi, vRecoB4.Phi()) < MAX_MATCH_DIST ) { iGenB4 = iParticle; genB4 = (GenParticle*) branchParticle->At(iGenB4); } } /* cout << "Gen Particles " << endl; if (genB1) cout << "1 " << genB1->PT << " " << genB1->Eta << endl; if (genB2) cout << "2 " << genB2->PT << " " << genB2->Eta << endl; if (genB3) cout << "3 " << genB3->PT << " " << genB3->Eta << endl; if (genB4) cout << "4 " << genB4->PT << " " << genB4->Eta << endl; */ for (Int_t iParticle=0; iParticle<branchParticle->GetEntries(); iParticle++) { // generator particle loop genParticle = (GenParticle*) branchParticle->At(iParticle); if (fabs(genParticle->PID) != H_ID_CODE) continue; if (iH1==-1) { iH1 = iParticle; genH1 = (GenParticle*) branchParticle->At(iH1); } else if (iH2==-1) { iH2 = iParticle; genH2 = (GenParticle*) branchParticle->At(iH2); } } /* if (genH1) cout << "H1 " << genH1->PT << " " << genH1->Eta << " " << genH1->Phi << endl; if (genH2) cout << "H2 " << genH2->PT << " " << genH2->Eta << " " << genH2->Phi << endl; cout << endl;*/ LorentzVector vGenB1(0,0,0,0); if (genB1) { vGenB1.SetPt(genB1->PT); vGenB1.SetEta(genB1->Eta); vGenB1.SetPhi(genB1->Phi); vGenB1.SetM(genB1->Mass); sGenB1 = &vGenB1; } else sGenB1 = ¬hing; LorentzVector vGenB2(0,0,0,0); if (genB2) { vGenB2.SetPt(genB2->PT); vGenB2.SetEta(genB2->Eta); vGenB2.SetPhi(genB2->Phi); vGenB2.SetM(genB2->Mass); sGenB2 = &vGenB2; } else sGenB2 = ¬hing; LorentzVector vGenB3(0,0,0,0); if (genB3) { vGenB3.SetPt(genB3->PT); vGenB3.SetEta(genB3->Eta); vGenB3.SetPhi(genB3->Phi); vGenB3.SetM(genB3->Mass); sGenB3 = &vGenB3; } else sGenB3 = ¬hing; LorentzVector vGenB4(0,0,0,0); if (genB4) { vGenB4.SetPt(genB4->PT); vGenB4.SetEta(genB4->Eta); vGenB4.SetPhi(genB4->Phi); vGenB4.SetM(genB4->Mass); sGenB4 = &vGenB4; } else sGenB4 = ¬hing; LorentzVector vGenH1(0,0,0,0); if (genH1) { vGenH1.SetPt(genH1->PT); vGenH1.SetEta(genH1->Eta); vGenH1.SetPhi(genH1->Phi); vGenH1.SetM(genH1->Mass); sGenH1 = &vGenH1; } else sGenH1 = ¬hing; LorentzVector vGenH2(0,0,0,0); if (genH2) { vGenH2.SetPt(genH2->PT); vGenH2.SetEta(genH2->Eta); vGenH2.SetPhi(genH2->Phi); vGenH2.SetM(genH2->Mass); sGenH2 = &vGenH2; } else sGenH2 = ¬hing; LorentzVector vTestBB1=vGenB1+vGenB2; LorentzVector vTestBB2=vGenB3+vGenB4; //cout << "test1 " << vTestBB1.Pt() << " " << vTestBB1.Eta() << " " << vTestBB1.Phi() << endl; //cout << "test1 " << vTestBB2.Pt() << " " << vTestBB2.Eta() << " " << vTestBB2.Phi() << endl; cout << "---" << endl; if ( (deltaR(vTestBB1.Eta(), vGenH1.Eta(), vTestBB1.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB2.Eta(), vGenH2.Eta(), vTestBB2.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=1; iHmatch2=1; iHmatch3=2; iHmatch4=2; } else if ( (deltaR(vTestBB2.Eta(), vGenH1.Eta(), vTestBB2.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB1.Eta(), vGenH2.Eta(), vTestBB1.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=2; iHmatch2=2; iHmatch3=1; iHmatch4=1; } vTestBB1=vGenB1+vGenB3; vTestBB2=vGenB2+vGenB4; //cout << "test2 " << vTestBB1.Pt() << " " << vTestBB1.Eta() << " " << vTestBB1.Phi() << endl; //cout << "test2 " << vTestBB2.Pt() << " " << vTestBB2.Eta() << " " << vTestBB2.Phi() << endl; if ( (deltaR(vTestBB1.Eta(), vGenH1.Eta(), vTestBB1.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB2.Eta(), vGenH2.Eta(), vTestBB2.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=1; iHmatch2=2; iHmatch3=1; iHmatch4=2; } else if ( (deltaR(vTestBB2.Eta(), vGenH1.Eta(), vTestBB2.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB1.Eta(), vGenH2.Eta(), vTestBB1.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=2; iHmatch2=1; iHmatch3=2; iHmatch4=1; } vTestBB1=vGenB1+vGenB4; vTestBB2=vGenB3+vGenB2; //cout << "test3 " << vTestBB1.Pt() << " " << vTestBB1.Eta() << " " << vTestBB1.Phi() << endl; //cout << "test3 " << vTestBB2.Pt() << " " << vTestBB2.Eta() << " " << vTestBB2.Phi() << endl; if ( (deltaR(vTestBB1.Eta(), vGenH1.Eta(), vTestBB1.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB2.Eta(), vGenH2.Eta(), vTestBB2.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=1; iHmatch2=2; iHmatch3=2; iHmatch4=1; } else if ( (deltaR(vTestBB2.Eta(), vGenH1.Eta(), vTestBB2.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB1.Eta(), vGenH2.Eta(), vTestBB1.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=2; iHmatch2=1; iHmatch3=1; iHmatch4=2; } if (iHmatch1==-1) { iHmatch1=0; iHmatch2=0; iHmatch3=0; iHmatch4=0; } //cout << iHmatch1 << " " << iHmatch2 << " " << iHmatch3 << " " << iHmatch4 << endl; //cout << endl; if (nM==0) iNot++; else if (nM==1) iMatched++; else if (nM>1) iTwo++; // match gen jets to reco jets for (Int_t iJet=0; iJet<branchGenJet->GetEntries(); iJet++) { // generator level jet loop genJet = (Jet*) branchGenJet->At(iJet); if ((jetB1) && (deltaR(genJet->Eta, jetB1->Eta, genJet->Phi, jetB1->Phi) < MAX_MATCH_DIST) ) { iGenJetB1=iJet; genJetB1 = (Jet*) branchGenJet->At(iGenJetB1); } else if ((jetB2) && (deltaR(genJet->Eta, jetB2->Eta, genJet->Phi, jetB2->Phi) < MAX_MATCH_DIST) ) { iGenJetB2=iJet; genJetB2 = (Jet*) branchGenJet->At(iGenJetB2); } else if ((jetB3) && (deltaR(genJet->Eta, jetB3->Eta, genJet->Phi, jetB3->Phi) < MAX_MATCH_DIST) ) { iGenJetB3=iJet; genJetB3 = (Jet*) branchGenJet->At(iGenJetB3); } else if ((jetB4) && (deltaR(genJet->Eta, jetB4->Eta, genJet->Phi, jetB4->Phi) < MAX_MATCH_DIST) ) { iGenJetB4=iJet; genJetB4 = (Jet*) branchGenJet->At(iGenJetB4); } else if ((jet1) && (deltaR(genJet->Eta, jet1->Eta, genJet->Phi, jet1->Phi) < MAX_MATCH_DIST) ) { iGenJetVBF1=iJet; genJetVBF1 = (Jet*) branchGenJet->At(iGenJetVBF1); } else if ((jet2) && (deltaR(genJet->Eta, jet2->Eta, genJet->Phi, jet2->Phi) < MAX_MATCH_DIST) ) { iGenJetVBF2=iJet; genJetVBF2 = (Jet*) branchGenJet->At(iGenJetVBF2); } } LorentzVector vGenJetB1(0,0,0,0); if (genJetB1) { vGenJetB1.SetPt(genJetB1->PT); vGenJetB1.SetEta(genJetB1->Eta); vGenJetB1.SetPhi(genJetB1->Phi); vGenJetB1.SetM(genJetB1->Mass); sGenJetB1 = &vGenJetB1; } else sGenJetB1 = ¬hing; LorentzVector vGenJetB2(0,0,0,0); if (genJetB2) { vGenJetB2.SetPt(genJetB2->PT); vGenJetB2.SetEta(genJetB2->Eta); vGenJetB2.SetPhi(genJetB2->Phi); vGenJetB2.SetM(genJetB2->Mass); sGenJetB2 = &vGenJetB2; } else sGenJetB2 = ¬hing; LorentzVector vGenJetB3(0,0,0,0); if (genJetB3) { vGenJetB3.SetPt(genJetB3->PT); vGenJetB3.SetEta(genJetB3->Eta); vGenJetB3.SetPhi(genJetB3->Phi); vGenJetB3.SetM(genJetB3->Mass); sGenJetB3 = &vGenJetB3; } else sGenJetB3 = ¬hing; LorentzVector vGenJetB4(0,0,0,0); if (genJetB4) { vGenJetB4.SetPt(genJetB4->PT); vGenJetB4.SetEta(genJetB4->Eta); vGenJetB4.SetPhi(genJetB4->Phi); vGenJetB4.SetM(genJetB4->Mass); sGenJetB4 = &vGenJetB4; } else sGenJetB4 = ¬hing; LorentzVector vGenJetVBF1(0,0,0,0); if (genJetVBF1) { vGenJetVBF1.SetPt(genJetVBF1->PT); vGenJetVBF1.SetEta(genJetVBF1->Eta); vGenJetVBF1.SetPhi(genJetVBF1->Phi); vGenJetVBF1.SetM(genJetVBF1->Mass); sGenJetVBF1 = &vGenJetVBF1; } else sGenJetVBF1 = ¬hing; LorentzVector vGenJetVBF2(0,0,0,0); if (genJetVBF2) { vGenJetVBF2.SetPt(genJetVBF2->PT); vGenJetVBF2.SetEta(genJetVBF2->Eta); vGenJetVBF2.SetPhi(genJetVBF2->Phi); vGenJetVBF2.SetM(genJetVBF2->Mass); sGenJetVBF2 = &vGenJetVBF2; } else sGenJetVBF2 = ¬hing; /* cout << "Gen Jets " << endl; if (genJetB1) cout << "1 " << genJetB1->PT << " " << genJetB1->Eta << endl; if (genJetB2) cout << "2 " << genJetB2->PT << " " << genJetB2->Eta << endl; if (genJetB3) cout << "3 " << genJetB3->PT << " " << genJetB3->Eta << endl; if (genJetB4) cout << "4 " << genJetB4->PT << " " << genJetB4->Eta << endl; if (genJetVBF1) cout << "V1 " << genJetVBF1->PT << " " << genJetVBF1->Eta << endl; if (genJetVBF2) cout << "V2 " << genJetVBF2->PT << " " << genJetVBF2->Eta << endl; cout << endl; */ outTree->Fill(); } // end event loop outFile->Write(); outFile->Save(); cout << endl; cout << "matched : " << iMatched << endl; cout << "not : " << iNot << endl; cout << "too much : " << iTwo << endl; cout << "total : " << iMatched+iNot+iTwo << endl; }
void MetResolution_NVtx_Zee() { gSystem->Load("libDelphes"); // Load shared library gSystem->Load("libExRootAnalysis.so"); gSystem->Load("libPhysics"); // Create chain of root trees TChain chain("Delphes"); //chain.Add("DY140_14TeV_upgrade.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/001.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/003.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/006.root"); //chain.Add("/afs/cern.ch/work/g/gkarapin/sample/007.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/009.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/011.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/012.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/013.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/015.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/016.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/017.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/018.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/021.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/022.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/024.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/026.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/027.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/028.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/029.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/030.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/032.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/034.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/035.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/036.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/038.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/039.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/040.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/043.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/044.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/046.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/048.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/049.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/050.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/051.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/052.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/053.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/054.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/055.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/057.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/058.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/061.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/062.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/063.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/065.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/066.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/068.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/069.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/070.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/072.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/073.root"); //chain.Add("/afs/cern.ch/work/g/gkarapin/sample/075.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/077.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/078.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/079.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/080.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/081.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/082.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/083.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/084.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/085.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/086.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/087.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/089.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/090.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/091.root"); //chain.Add("/afs/cern.ch/work/g/gkarapin/sample/093.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/095.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/096.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/097.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/102.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/103.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/113.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/114.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/115.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/117.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/118.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/123.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/124.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/125.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/126.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/127.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/129.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/130.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/140.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/141.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/142.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/144.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/145.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/147.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/148.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/149.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/150.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/151.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/152.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/154.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/164.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/165.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/167.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/168.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/170.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/171.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/172.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/173.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/175.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/177.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/178.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/179.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/193.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/194.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/195.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/196.root"); //chain.Add("/afs/cern.ch/work/g/gkarapin/sample/197.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/198.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/199.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/202.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/205.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/206.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/207.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/208.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/218.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/219.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/220.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/221.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/223.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/224.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/225.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/226.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/227.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/228.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/229.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/230.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/232.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/233.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/234.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/235.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/236.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/237.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/238.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/240.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/243.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/244.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/247.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/248.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/249.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/250.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/251.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/256.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/257.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/259.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/260.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/262.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/263.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/264.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/266.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/267.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/268.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/269.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/272.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/273.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/274.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/277.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/278.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/279.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/280.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/281.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/283.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/284.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/286.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/287.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/289.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/290.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/291.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/293.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/295.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/296.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/297.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/299.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/300.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/301.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/302.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/303.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/304.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/306.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/310.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/311.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/313.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/314.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/315.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/316.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/317.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/318.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/319.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/320.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/321.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/322.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/323.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/324.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/325.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/327.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/330.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/331.root"); //chain.Add("/afs/cern.ch/work/g/gkarapin/sample/333.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/334.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/338.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/339.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/342.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/344.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/345.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/346.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/347.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/349.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/350.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/352.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/353.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/354.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/355.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/356.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/357.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/360.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/361.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/362.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/363.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/364.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/365.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/366.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/367.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/369.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/371.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/372.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/373.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/374.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/375.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/376.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/377.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/378.root"); //chain.Add("/afs/cern.ch/work/g/gkarapin/sample/380.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/381.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/382.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/383.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/385.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/386.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/387.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/389.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/391.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/392.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/393.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/394.root"); //chain.Add("/afs/cern.ch/work/g/gkarapin/sample/395.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/397.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/399.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/400.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/401.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/402.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/403.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/405.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/407.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/409.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/410.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/411.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/412.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/413.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/414.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/415.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/416.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/417.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/419.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/420.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/421.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/424.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/425.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/426.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/427.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/428.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/429.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/430.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/431.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/432.root"); //chain.Add("/afs/cern.ch/work/g/gkarapin/sample/433.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/434.root"); chain.Add("/afs/cern.ch/work/g/gkarapin/sample/435.root"); //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Create object of class ExRootTreeReader ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t nentries = treeReader->GetEntries(); std::cout << "can you read my tree ?" << std::endl; // Get pointers to branches used in this analysis TClonesArray *branchElectron = treeReader->UseBranch("Electron"); TClonesArray *branchMissingET = treeReader->UseBranch("MissingET"); TClonesArray *branchNPU = treeReader->UseBranch("NPU"); Long64_t nentries = treeReader->GetEntries(); const int qTnbins = 35; double qTxbins[qTnbins+1] = {0., 2, 4., 6, 8., 10, 12.5, 15, 17.5, 20., 22.5, 25.,28, 31,34,37, 40,43.5, 47, 51,55, 60, 65,70,76,82,89,97,106,116,127,139,152, 166,181,200} //Define histograms TH1D * histElectronEta = new TH1D("histElectronEta",";Electron #eta; number of events", 60, -3, 3); TH1D * histElectron1Pt = new TH1D("histElectron1Pt",";Electron1 P_{T} [GeV]; number of events", 200, 0.0, 200.0); TH1D * histElectron2Pt = new TH1D("histElectron2Pt",";Electron2 P_{T} [GeV]; number of events", 200, 0.0, 200.0); TH1D * histZmass = new TH1D("histZmass","; Invariant mass of Z [GeV]; number of events", 120, 60.0, 120.0); TH1D * histZpT = new TH1D("histZpT",";transverse momentum of Z, q_{T} [GeV]; number of events", 200, 0.0, 400.0); TH1D * histnvtx = new TH1D("histnvtx",";number of vertices; number of events", 200, 0.0, 200); TH1D * histMet = new TH1D("histMet",";#slash{E}_{T} [GeV]; number of events", 200, 0.0, 800.0); TH1D * histMetx = new TH1D("histMetx",";#slash{E}_{T}x [GeV]; number of events", 200, -400.0, 400.0); TH1D * histMety = new TH1D("histMety",";#slash{E}_{T}y [GeV]; number of events", 200, -400.0, 400.0); TH1D * histuperp = new TH1D("histuperp",";u_{#perp} [GeV]; number of events",100,-400.,400.); TH1D * histux = new TH1D("histux",";u_{x} [GeV]; number of events",100,-400.,400.); TH1D * histuy = new TH1D("histuy",";u_{y} [GeV]; number of events",100,-400.,400.); TH1D * histupara = new TH1D("histupara",";u_{#parallel} [GeV]; number of events",100,-400,+400); TH1D * histuparaqT = new TH1D("histuparaqT","; -(u_{#parallel}+q_{T}) [GeV]; number of events",100,-400,+400); TH2F * histMetx_vs_nvtx = new TH2F("histMetx_vs_nvtx",";number of vertices; #slash{E}_{T}x [GeV]",100,100.5,200.5,200,-100,100); TH2F * histMety_vs_nvtx= new TH2F("histMety_vs_nvtx",";number of vertices; #slash{E}_{T}y [GeV]",100,100.5,200.5,200,-100,100); TH2F * histuperp_vs_qT= new TH2F("histuperp_vs_qT",";q_{T} [GeV]; #sigma ( u_{#perp} ) ",qTnbins,qTxbins,200,-100,+100); TH2F * histuperp_vs_nvtx= new TH2F("histuperp_vs_nvtx","number of vertices; #sigma ( u_{#perp} ) ",100,100.5,200.5, 200,-100,100); TH2F * histupara_vs_qT= new TH2F("histupara_vs_qT",";q_{T} [GeV];u_{#parallel} [GeV]",qTnbins,qTxbins,200,-100,100); TH2F * histuparaDivqT_vs_qT= new TH2F("histuparaDivqT_vs_qT",";q_{T} [GeV];-u_{#parallel}/q_{T}",qTnbins,qTxbins,1200,-30,30); TH2F * histupara_vs_nvtx= new TH2F("histupara_vs_nvtx",";number of vertices;u_{#parallel} [GeV]",100,100.5,200.5,200,-100,100); TH2F * histuparaDivqT_vs_nvtx= new TH2F("histuparaDivqT_vs_nvtx",";number of vertices;-u_{#parallel}/q_{T}",100,100.5,200.5,1200,-30,30); //Loop over events Long64_t entry; Int_t i, j; for(Long64_t entry = 0; entry < nentries; ++entry) { treeReader->ReadEntry(entry); Electron *elec; Electron *elec1, *elec2; TLorentzVector vec1, vec2; double Zmass,ZpT, Zpx, Zpy, Zpz; TVector2 MET_Final, u_Final, q_Final; int nvtx; std::cout << " events: " << entry << std::endl; int theNumberOfElectrons = 0; // Loop over all electrons in events for ( i = 0; i < branchElectron->GetEntriesFast(); ++i) { theNumberOfElectrons++; std::cout << "how many electrons I have ? =" << theNumberOfElectrons << std::endl; Electron *elec = (Electron*) branchElectron->At(i); // electron |eta| < 1.444 or 1.57 < |eta| < 2.5. //if(fabs(elec->Eta) > 1.444 && fabs(elec->Eta) < 1.57 ) continue; //if(fabs(elec->Eta) > 2.5 ) continue; if (elec->PT > 20 && fabs(elec->Eta) < 1.4442){ // If event contains at least 2 electron if( branchMissingET->GetEntriesFast() > 0 && branchElectron->GetEntriesFast() > 1 && branchNPU->GetEntriesFast()>0 ){ // Take first two electrons elec1 = (Electron*) branchElectron->At(0); elec2 = (Electron*) branchElectron->At(1); // Print transverse momentum of first two electron std::cout << "first electron pT =" << elec1->PT << std::endl; std::cout << "second electron pT =" << elec2->PT << std::endl; // Fill transverse momentum of first two electrons histElectron1Pt->Fill(elec1->PT); histElectron2Pt->Fill(elec2->PT); // Print eta of first two electron std::cout << "first electron Eta =" << elec1->Eta << std::endl; std::cout << "second electron Eta =" << elec2->Eta << std::endl; // Create two 4-vectors for the electrons vec1.SetPtEtaPhiM(elec1->PT, elec1->Eta, elec1->Phi, 0.0); vec2.SetPtEtaPhiM(elec2->PT, elec2->Eta, elec2->Phi, 0.0); // Define their invariant mass ( mass of Z(ee) ) Zmass = (vec1 + vec2).M(); // Print their invariant mass std::cout << "mass of Z boson =" << (vec1 + vec2).M() << std::endl; if(Zmass < 60 || Zmass > 120) continue; std::cout << "Is mass of Z boson in mass window ? =" << (vec1 + vec2).M() << std::endl; //Fill their invariant mass histZmass->Fill((vec1 + vec2).M()); //Define transverse momentum of Z boson ( qT ) double ZpT = (vec1+vec2).Pt(); std::cout << " Transverse momentum of Z boson ? =" << (vec1 + vec2).Pt() << std::endl; //Fill qT histZpT->Fill((vec1 + vec2).Pt()); Zpx = vec2.Px()+vec1.Px(); Zpy = vec2.Py()+vec1.Py(); //Zpz = vec2.Pz()+vec1.Pz(); std::cout << "Zpx =" << vec2.Px()+vec1.Px() << std::endl; std::cout << "Zpy =" << vec2.Py()+vec1.Py() << std::endl; //std::cout << "Zpz =" << vec2.Pz()+vec1.Pz() << std::endl; TVector2 q_Final(Zpx, Zpy); //+++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Loop over MissingET //for(j = 0; j < branchMissingET->GetEntriesFast(); ++j){ MissingET *Met = (MissingET*) branchMissingET->At(j); histMet->Fill(Met->MET); double METx = Met->MET*cos(Met->Phi); double METy = Met->MET*sin(Met->Phi); TVector2 MET_Final(METx, METy); std::cout << " METx: =" << Met->MET*cos(Met->Phi) << std::endl; std::cout << " METy: =" << Met->MET*sin(Met->Phi) << std::endl; //Fill METx, METy histMetx->Fill(METx); histMety->Fill(METy); //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // loop over number of vertices // the true number of pileup vertices in a "ScalarHT" object! ScalarHT *NPU = (ScalarHT*) branchNPU->At(0); int nvtx = (int)NPU->HT; std::cout << " Number of pileup vertices: " << nvtx << std::endl; //Fill number of vertices histnvtx->Fill(NPU->HT); //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //Fill METx, METy vs nvtx histMetx_vs_nvtx->Sumw2(); histMetx_vs_nvtx->Fill(nvtx,METx); histMety_vs_nvtx->Sumw2(); histMety_vs_nvtx->Fill(nvtx,METy); // Calculate u_perp double ux = -(METx + Zpx); double uy = -(METy + Zpy); std::cout << " ux: =" << -(METx + Zpx) << std::endl; std::cout << " uy: =" << -(METy + Zpy) << std::endl; TVector2 u_Final(ux, uy); double u_perp = u_Final.Norm(q_Final)*(q_Final.Unit()).Rotate(TMath::Pi()/2.0); std::cout << " u_perp=" << u_Final.Norm(q_Final)*(q_Final.Unit()).Rotate(TMath::Pi()/2.0) << std::endl; std::cout << " events: " << entry << " |u_perp|=" << fabs(u_perp) << std::endl; //Fill u_perp histux->Fill(ux); histuy->Fill(uy); histuperp->Fill(u_perp); //Fill uperp vs qT histuperp_vs_qT->Sumw2(); histuperp_vs_qT->Fill(ZpT, u_perp); TProfile *histuperp_vs_qT_pfx = histuperp_vs_qT->ProfileX(); //Fill uperp vs nvertices histuperp_vs_nvtx->Sumw2(); histuperp_vs_nvtx->Fill(nvtx,u_perp,1); TProfile *histuperp_vs_nvtx_pfx = histuperp_vs_nvtx->ProfileX(); //calculate u_para double u_para = u_Final.Proj(q_Final)*q_Final.Unit(); std::cout << " Finally u_para:=" << u_Final.Proj(q_Final)*q_Final.Unit() << std::endl; //Fill u_para histupara->Sumw2(); histupara->Fill(u_para); //calculate uparaqT double uparaqT = u_para+((vec1 + vec2).Pt()); histuparaqT->Fill(uparaqT); //Fill <u_para> Vs qT histupara_vs_qT->Sumw2(); histupara_vs_qT->Fill(ZpT,u_para,1); TProfile *histupara_vs_qT_pfx = histupara_vs_qT->ProfileX(); //Fill upara/qT vs qT histuparaDivqT_vs_qT->Sumw2(); double uparaDivqT = - (u_para/ZpT); histuparaDivqT_vs_qT->Fill(ZpT,uparaDivqT,1); TProfile *histuparaDivqT_vs_qT_pfx = histuparaDivqT_vs_qT->ProfileX(); //Fill upara vs nvertices histupara_vs_nvtx->Sumw2(); histupara_vs_nvtx->Fill(nvtx,u_para,1); TProfile *histupara_vs_nvtx_pfx = histupara_vs_nvtx->ProfileX(); //Fill upara/qT vs nvtx histuparaDivqT_vs_nvtx->Sumw2(); histuparaDivqT_vs_nvtx->Fill(nvtx,uparaDivqT,1); TProfile *histuparaDivqT_vs_nvtx_pfx = histuparaDivqT_vs_nvtx->ProfileX(); //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ } } } } //Draw Plots TCanvas *c1 = new TCanvas("c1","c1",600,800); c1->SetLineStyle(1); c1->SetLineWidth(2); c1->SetLineColor(1); c1->Divide(1,1); c1->cd(23); histnvtx->SetFillColor(5); histnvtx->Draw(); c1->SaveAs("histnvtx.png"); TCanvas *c2 = new TCanvas("c2","c2",600,800); c2->SetFillColor(10); c2->Divide(1,1); c2->cd(2); c2->SetLogy(); histElectronEta->SetFillColor(5); histElectronEta->Draw(); c2 -> SaveAs("histElectronEta_v4.png"); TCanvas *c3 = new TCanvas("c3","c3",600,800); c3->SetFillColor(10); c3->Divide(1,1); c3->cd(3); c3->SetLogy(); histElectron1Pt->SetFillColor(5); histElectron1Pt->Draw(); c3 -> SaveAs("histElectron1Pt_v4.png"); TCanvas *c4 = new TCanvas("c4","c4",600,800); c4->SetFillColor(10); c4->Divide(1,1); c4->cd(4); c4->SetLogy(); histElectron2Pt->SetFillColor(5); histElectron2Pt->Draw(); c4 -> SaveAs("histElectron2Pt_v4.png"); TCanvas *c5 = new TCanvas("c5","c5",600,800); c5->SetFillColor(10); c5->Divide(1,1); c5->cd(5); c5->SetLogy(); histZmass->SetFillColor(5); histZmass->Draw(); c5 -> SaveAs("histZmass_v4.png"); TCanvas *c6 = new TCanvas("c6","c6",600,800); c6->SetFillColor(10); c6->Divide(1,1); c6->cd(6); c6->SetLogy(); histZpT->SetFillColor(5); histZpT->Draw(); c6 -> SaveAs("histZpT_v4.png"); TCanvas *c7 = new TCanvas("c7","c7",600,800); c7->SetFillColor(10); c7->Divide(1,1); c7->cd(7); c7->SetLogy(); histMet->SetFillColor(5); histMet->Draw(); c7 -> SaveAs("histMet_v5.png"); TCanvas *c8 = new TCanvas("c8","c8",600,800); c8->SetFillColor(10); c8->Divide(1,1); c8->cd(8); c8->SetLogy(); histMetx->SetFillColor(5); histMetx->Draw(); c8 -> SaveAs("histMetx_v5.png"); TCanvas *c9 = new TCanvas("c9","c9",600,800); c9->SetFillColor(10); c9->Divide(1,1); c9->cd(9); c9->SetLogy(); histMety->SetFillColor(5); histMety->Draw(); c9 -> SaveAs("histMety_v5.png"); TCanvas *c10 = new TCanvas("c10","c10",600,800); c10->SetFillColor(10); c10->SetLineStyle(1); c10->SetLineWidth(2); c10->SetLineColor(1); c10->Divide(1,1); c10->cd(10); histMetx_vs_nvtx->GetYaxis()->SetTitle(" #slash{E}_{T}x [GeV]"); histMetx_vs_nvtx->GetYaxis()->SetTitleSize(0.0425); histMetx_vs_nvtx->GetYaxis()->SetTitleOffset(1.10); histMetx_vs_nvtx->GetYaxis()->SetLabelSize(0.04); histMetx_vs_nvtx->GetYaxis()->SetLabelOffset(0.007); histMetx_vs_nvtx->GetXaxis()->SetTitle("number of vertices"); histMetx_vs_nvtx->GetXaxis()->SetTitleSize(0.04); histMetx_vs_nvtx->GetXaxis()->SetTitleOffset(1.10); histMetx_vs_nvtx->GetXaxis()->SetLabelSize(0.04); histMetx_vs_nvtx->GetXaxis()->SetLabelOffset(0.007); histMetx_vs_nvtx->SetLineColor(1); histMetx_vs_nvtx->SetMarkerSize(1); histMetx_vs_nvtx->SetLineWidth(1); histMetx_vs_nvtx->SetMarkerStyle(9); histMetx_vs_nvtx->SetMarkerColor(1); histMetx_vs_nvtx->Draw("P"); c10->SaveAs("histMetx_vs_nvtx.png"); TCanvas *c11 = new TCanvas("c11","c11",600,800); c11->SetFillColor(10); c11->SetLineStyle(1); c11->SetLineWidth(2); c11->SetLineColor(1); c11->Divide(1,1); c11->cd(11); histMety_vs_nvtx->GetYaxis()->SetTitle(" #slash{E}_{T}y [GeV]"); histMety_vs_nvtx->GetYaxis()->SetTitleSize(0.0425); histMety_vs_nvtx->GetYaxis()->SetTitleOffset(1.10); histMety_vs_nvtx->GetYaxis()->SetLabelSize(0.04); histMety_vs_nvtx->GetYaxis()->SetLabelOffset(0.007); histMety_vs_nvtx->GetXaxis()->SetTitle("number of vertices"); histMety_vs_nvtx->GetXaxis()->SetTitleSize(0.04); histMety_vs_nvtx->GetXaxis()->SetTitleOffset(1.10); histMety_vs_nvtx->GetXaxis()->SetLabelSize(0.04); histMety_vs_nvtx->GetXaxis()->SetLabelOffset(0.007); histMety_vs_nvtx->SetLineColor(1); histMety_vs_nvtx->SetMarkerSize(1); histMety_vs_nvtx->SetLineWidth(1); histMety_vs_nvtx->SetMarkerStyle(9); histMety_vs_nvtx->SetMarkerColor(1); histMety_vs_nvtx->Draw("P"); c11->SaveAs("histMety_vs_nvtx.png"); TCanvas *c12 = new TCanvas("c12","c12",600,800); c12->SetLineStyle(1); c12->SetLineWidth(2); c12->SetLineColor(1); c12->Divide(1,1); c12->cd(12); c12->SetLogy(); histux->SetFillColor(5); histux->Draw(); c12->SaveAs("histux_v5.png"); TCanvas *c13 = new TCanvas("c13","c13",600,800); c13->SetLineStyle(1); c13->SetLineWidth(2); c13->SetLineColor(1); c13->Divide(1,1); c13->cd(13); c13->SetLogy(); histuy->SetFillColor(5); histuy->Draw(); c13 -> SaveAs("histuy_v5.png"); TCanvas *c14 = new TCanvas("c14","c14",600,800); c14->SetLineStyle(1); c14->SetLineWidth(2); c14->SetLineColor(1); c14->Divide(1,1); c14->cd(14); c14->SetLogy(); histuperp->SetFillColor(5); histuperp->Draw(); c14->SaveAs("histuperp_v5.png"); TCanvas *c15 = new TCanvas("c15","c15",600,800); c15->SetLineStyle(1); c15->SetLineWidth(2); c15->SetLineColor(1); c15->Divide(1,2); c15->cd(1); histuperp_vs_qT->Draw( ); c15->cd(2); histuperp_vs_qT_pfx->GetYaxis()->SetTitle(" #sigma( u_{#perp} )"); histuperp_vs_qT_pfx->GetYaxis()->SetTitleSize(0.0425); histuperp_vs_qT_pfx->GetYaxis()->SetTitleOffset(1.10); histuperp_vs_qT_pfx->GetYaxis()->SetLabelSize(0.04); histuperp_vs_qT_pfx->GetYaxis()->SetLabelOffset(0.007); histuperp_vs_qT_pfx->GetXaxis()->SetTitle("q_{T} [GeV]"); histuperp_vs_qT_pfx->GetXaxis()->SetTitleSize(0.04); histuperp_vs_qT_pfx->GetXaxis()->SetTitleOffset(1.10); histuperp_vs_qT_pfx->GetXaxis()->SetLabelSize(0.04); histuperp_vs_qT_pfx->GetXaxis()->SetLabelOffset(0.007); histuperp_vs_qT_pfx->SetLineColor(1); histuperp_vs_qT_pfx->SetMarkerSize(0.7); histuperp_vs_qT_pfx->SetLineWidth(1); histuperp_vs_qT_pfx->SetMarkerStyle(21); histuperp_vs_qT_pfx->SetMarkerColor(1); histuperp_vs_qT_pfx->Draw("P"); c15->SaveAs("histuperp_vs_qT_pfx.png"); c15->Close(); TCanvas *c18 = new TCanvas("c18","c18",600,800); c18->SetLineStyle(1); c18->SetLineWidth(2); c18->SetLineColor(1); c18->Divide(1,1); c18->cd(18); c18->SetLogy(); histuparaqT->SetFillColor(5); histuparaqT->Draw(); c18->SaveAs("histuparaqT.png"); TCanvas *c17 = new TCanvas("c17","c17",600,800); c17->SetLineStyle(1); c17->SetLineWidth(2); c17->SetLineColor(1); c17->Divide(1,1); c17->cd(17); c17->SetLogy(); histupara->SetFillColor(5); histupara->Draw(); c17->SaveAs("histupara_v5.png"); TCanvas *c18 = new TCanvas("c18","c18",600,800); c18->SetLineStyle(1); c18->SetLineWidth(2); c18->SetLineColor(1); c18->Divide(1,1); c18->cd(18); c18->SetLogy(); histuparaqT->SetFillColor(5); histuparaqT->Draw(); c18->SaveAs("histuparaqT_v5.png"); TCanvas *c19 = new TCanvas("c19","c19",600,800); c19->SetLineStyle(1); c19->SetLineWidth(2); c19->SetLineColor(1); c19->Divide(1,2); c19->cd(1); histupara_vs_qT->Draw(); c19->cd(2); histupara_vs_qT_pfx->GetYaxis()->SetTitle(" #sigma( u_{#parallel} )"); histupara_vs_qT_pfx->GetYaxis()->SetTitleSize(0.0425); histupara_vs_qT_pfx->GetYaxis()->SetTitleOffset(1.10); histupara_vs_qT_pfx->GetYaxis()->SetLabelSize(0.04); histupara_vs_qT_pfx->GetYaxis()->SetLabelOffset(0.007); histupara_vs_qT_pfx->GetXaxis()->SetTitle("q_{T} [GeV]"); histupara_vs_qT_pfx->GetXaxis()->SetTitleSize(0.04); histupara_vs_qT_pfx->GetXaxis()->SetTitleOffset(1.10); histupara_vs_qT_pfx->GetXaxis()->SetLabelSize(0.04); histupara_vs_qT_pfx->GetXaxis()->SetLabelOffset(0.007); histupara_vs_qT_pfx->SetLineColor(1); histupara_vs_qT_pfx->SetMarkerSize(0.7); histupara_vs_qT_pfx->SetLineWidth(1); histupara_vs_qT_pfx->SetMarkerStyle(21); histupara_vs_qT_pfx->SetMarkerColor(1); histupara_vs_qT_pfx->Draw("P"); c19->SaveAs("histupara_vs_qT_pfx.png"); c19->Close(); TCanvas *c20 = new TCanvas("c20","c20",600,800); c20->SetLineStyle(1); c20->SetLineWidth(2); c20->SetLineColor(1); c20->Divide(1,2); c20->cd(1); histuparaDivqT_vs_qT->Draw(); c20->cd(2); histuparaDivqT_vs_qT_pfx->GetYaxis()->SetTitle(" -u_{#parallel}/q_{T}"); histuparaDivqT_vs_qT_pfx->GetYaxis()->SetTitleSize(0.0425); histuparaDivqT_vs_qT_pfx->GetYaxis()->SetTitleOffset(1.10); histuparaDivqT_vs_qT_pfx->GetYaxis()->SetLabelSize(0.04); histuparaDivqT_vs_qT_pfx->GetYaxis()->SetLabelOffset(0.007); histuparaDivqT_vs_qT_pfx->GetXaxis()->SetTitle("q_{T} [GeV/c]"); histuparaDivqT_vs_qT_pfx->GetXaxis()->SetTitleSize(0.04); histuparaDivqT_vs_qT_pfx->GetXaxis()->SetTitleOffset(1.10); histuparaDivqT_vs_qT_pfx->GetXaxis()->SetLabelSize(0.04); histuparaDivqT_vs_qT_pfx->GetXaxis()->SetLabelOffset(0.007); histuparaDivqT_vs_qT_pfx->SetLineColor(1); histuparaDivqT_vs_qT_pfx->SetMarkerSize(1); histuparaDivqT_vs_qT_pfx->SetLineWidth(1); histuparaDivqT_vs_qT_pfx->SetMarkerStyle(21); histuparaDivqT_vs_qT_pfx->SetMarkerSize(.7); histuparaDivqT_vs_qT_pfx->SetMarkerColor(1); histuparaDivqT_vs_qT_pfx->Draw("P"); c20->SaveAs("histuparaDivqT_vs_qT_pfx.png"); c20->Close(); TCanvas *c21 = new TCanvas("c21","c21",600,800); c21->SetLineStyle(1); c21->SetLineWidth(2); c21->SetLineColor(1); c21->Divide(1,2); c21->cd(1); histupara_vs_nvtx->Draw(); c21->cd(2); histupara_vs_nvtx_pfx->GetYaxis()->SetTitle(" -u_{#parallel}/q_{T}"); histupara_vs_nvtx_pfx->GetYaxis()->SetTitleSize(0.0425); histupara_vs_nvtx_pfx->GetYaxis()->SetTitleOffset(1.10); histupara_vs_nvtx_pfx->GetYaxis()->SetLabelSize(0.04); histupara_vs_nvtx_pfx->GetYaxis()->SetLabelOffset(0.007); histupara_vs_nvtx_pfx->GetXaxis()->SetTitle(" number of vertices "); histupara_vs_nvtx_pfx->GetXaxis()->SetTitleSize(0.04); histupara_vs_nvtx_pfx->GetXaxis()->SetTitleOffset(1.10); histupara_vs_nvtx_pfx->GetXaxis()->SetLabelSize(0.04); histupara_vs_nvtx_pfx->GetXaxis()->SetLabelOffset(0.007); histupara_vs_nvtx_pfx->SetLineColor(1); histupara_vs_nvtx_pfx->SetMarkerSize(1); histupara_vs_nvtx_pfx->SetLineWidth(1); histupara_vs_nvtx_pfx->SetMarkerStyle(21); histupara_vs_nvtx_pfx->SetMarkerSize(.7); histupara_vs_nvtx_pfx->SetMarkerColor(1); histupara_vs_nvtx_pfx->Draw("P"); c21->SaveAs("histupara_vs_nvtx_pfx.png"); c21->Close(); TCanvas *c22 = new TCanvas("c22","c22",600,800); c22->SetLineStyle(1); c22->SetLineWidth(2); c22->SetLineColor(1); c22->Divide(1,2); c22->cd(1); histuparaDivqT_vs_nvtx->Draw(" "); c22->cd(2); histuparaDivqT_vs_nvtx_pfx->GetYaxis()->SetTitle(" -u_{#parallel}/q_{T}"); histuparaDivqT_vs_nvtx_pfx->GetYaxis()->SetTitleSize(0.0425); histuparaDivqT_vs_nvtx_pfx->GetYaxis()->SetTitleOffset(1.10); histuparaDivqT_vs_nvtx_pfx->GetYaxis()->SetLabelSize(0.04); histuparaDivqT_vs_nvtx_pfx->GetYaxis()->SetLabelOffset(0.007); histuparaDivqT_vs_nvtx_pfx->GetXaxis()->SetTitle(" number of vertices "); histuparaDivqT_vs_nvtx_pfx->GetXaxis()->SetTitleSize(0.04); histuparaDivqT_vs_nvtx_pfx->GetXaxis()->SetTitleOffset(1.10); histuparaDivqT_vs_nvtx_pfx->GetXaxis()->SetLabelSize(0.04); histuparaDivqT_vs_nvtx_pfx->GetXaxis()->SetLabelOffset(0.007); histuparaDivqT_vs_nvtx_pfx->SetLineColor(1); histuparaDivqT_vs_nvtx_pfx->SetMarkerSize(1); histuparaDivqT_vs_nvtx_pfx->SetLineWidth(1); histuparaDivqT_vs_nvtx_pfx->SetMarkerStyle(21); histuparaDivqT_vs_nvtx_pfx->SetMarkerSize(.7); histuparaDivqT_vs_nvtx_pfx->SetMarkerColor(1); histuparaDivqT_vs_nvtx_pfx->Draw("P"); c22->SaveAs("histuparaDivqT_vs_nvtx_pfx.png"); c22->Close(); std::cout << " Plots are done " << std::endl; }
int main(int argc, char*argv[]) { gSystem->Load("libDelphes"); gSystem->Load("libExRootAnalysis"); //arg string inputFile=argv[1]; string outputFile=argv[2]; TFile *out = TFile::Open(outputFile.c_str(),"RECREATE"); // Create chain of root trees TChain chain("Delphes"); chain.Add(inputFile.c_str()); // Create object of class ExRootTreeReader ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t numberOfEntries = treeReader->GetEntries(); // Get pointers to branches used in this analysis TClonesArray *branchJet = treeReader->UseBranch("Jet"); TClonesArray *branchGenJet = treeReader->UseBranch("GenJet"); TClonesArray *scalarht = treeReader->UseBranch("ScalarHT"); ///////////////////////////// //Histograms///////////////// ///////////////////////////// TH2 *hist_deltaY_60_100 = new TH2F("hist_deltaY_60_100","hist_deltaY_60_100",500,-5.0,5.0,500,-0.2,0.2); TH2 *hist_deltaY_100_150 = new TH2F("hist_deltaY_100_150","hist_deltaY_100_150",500,-5.0,5.0,500,-0.2,0.2); TH2 *hist_deltaY_150_200 = new TH2F("hist_deltaY_150_200","hist_deltaY_150_200",500,-5.0,5.0,500,-0.2,0.2); TH1 *histevent60100 = new TH1F("histevent60100","histevent60100",500,-0.5,0.5); TH1 *histevent100150 = new TH1F("histevent100150","histevent60100",500,-0.5,0.5); TH1 *histevent150200 = new TH1F("histevent150200","histevent60100",500,-0.5,0.5); TH1 *hist_PT_resolution = new TH1F("hist_PT_resolution","hist_PT_resolution",500,-1.0,1); TH2 *hist_PT_resolution_for_each[3]; hist_PT_resolution_for_each[0] = new TH2F("hist_leading_pt_res","hist_PT_resolution_for_each",500,0.0,4000,500,-1.0,1.0); hist_PT_resolution_for_each[1] = new TH2F("hist_nleading_pt_res","hist_PT_resolution_for_each",500,0.0,4000,500,-1.0,1.0); hist_PT_resolution_for_each[2] = new TH2F("hist_nnleading_pt_res","hist_PT_resolution_for_each",500,0.0,4000,500,-1.0,1.0); TH1 *histleadingcolojetpt = new TH1F("leadingcolojetpt", "leadingcolojetpt", 50, 0.0, 400.0); TH1 *histnleadingcolojetpt = new TH1F("nleadingcolojetpt", "nleadingcolojetpt", 50, 0.0, 400.0); TH1 *histnnleadingcolojetpt = new TH1F("nnleadingcolojetpt", "nnleadingcolojetpt", 50, 0.0, 400.0); TH1 *histcolojetht = new TH1F("histcolojetht","histcolojetht",1000, 0.0, 10000.0); TH2 *histresleadingjet = new TH2F("histresleadingjet","histresleadingjet",500,0.0,4000,500,-1.0,1.0); TH2 *histres2leadingjet = new TH2F("histres2leadingjet","histresleadingjet",500,0.0,4000,500,-1.0,1.0); TH2 *histres3leadingjet = new TH2F("histres3leadingjet","histresleadingjet",500,0.0,2500,500,-1.0,1.0); TH1 *histcolo2jetht = new TH1F("histcolo2jetht",">2jet ht",500,0.0,10000.0); TH1 *histcolo3jetht = new TH1F("histcolo3jetht",">3jet ht",500,0.0,10000.0); TH1 *histgen2jetht = new TH1F("histgen2jetht",">2jet ht",500,0.0,10000.0); TH1 *histgen3jetht = new TH1F("histgen3jetht",">3jet ht",500,0.0,10000.0); //Definition vector<Jet *> colojet; vector<Jet *> genjet; ScalarHT* scht=0; Jet *cjet; Jet *gjet; int nocolojet = 0; //double ptrescut = 0; for(int entry = 0; entry < numberOfEntries; ++entry) { //her 10000 olayda bıze bılgı verıyor if(entry%10000 == 0) cout << "event number: " << entry << endl; // Load selected branches with data from specified event treeReader->ReadEntry(entry); ////////////////////////////////////// ///Scalerht yı scht ye dolduruyor.//// ////////////////////////////////////// for(int i =0 ;i<scalarht->GetEntriesFast();++i ) { scht =(ScalarHT*) scalarht->At(i); } /////////////////////////////////////////////// ////genjet bilgilerini alıyor////////////////// /////////////////////////////////////////////// genjet.clear(); for(int i=0;i < branchGenJet->GetEntriesFast();++i) { gjet = (Jet*) branchGenJet->At(i); genjet.push_back(gjet); } ////////////////////////////////////////////// ///colojet bilgilerini alıyor //////////////// ////////////////////////////////////////////// colojet.clear(); for(int i=0;i < branchJet->GetEntriesFast(); ++i) { cjet = (Jet*) branchJet->At(i); colojet.push_back(cjet); } ///////////////////////////////////////////// /////// delta(y) for (60 - (100) - (150) - 250)/////////// ///////////////////////////////////////////// double ptbins=0; if(genjet.size()==colojet.size()) { for(unsigned i = 0; i< genjet.size();++i) { ptbins=genjet[i]->PT; if( ptbins > 60 && ptbins < 100) { hist_deltaY_60_100->Fill(genjet[i]->Eta,genjet[i]->Eta - colojet[i]->Eta); histevent60100->Fill(genjet[i]->Eta - colojet[i]->Eta); } if(ptbins > 100 && ptbins < 150) { hist_deltaY_100_150->Fill(genjet[i]->Eta,genjet[i]->Eta - colojet[i]->Eta); histevent100150->Fill(genjet[i]->Eta - colojet[i]->Eta); } if(ptbins > 150 && ptbins < 200) { hist_deltaY_150_200->Fill(genjet[i]->Eta,genjet[i]->Eta - colojet[i]->Eta); histevent150200->Fill(genjet[i]->Eta - colojet[i]->Eta); } } } ////////////////////////////////////////////////////////////////////// //R parametresi buluyor ve pt resolution yapıyor////////////////////// ////////////////////////////////////////////////////////////////////// double r =0; double pt_res_cut=0; if(genjet.size()> 1 && colojet.size()>1) { for(unsigned i = 0; i<3;i++) { if(abs(genjet[i]->Eta) <= 2.5 && abs(colojet[i]->Eta) <= 2.5) { double deltaPhi = abs(genjet[i]->Phi - colojet[i]->Phi); double deltaEta = abs(genjet[i]->Eta - colojet[i]->Eta); r = sqrt( pow(deltaPhi,2) + pow(deltaEta,2)); if(r<0.25) { pt_res_cut = ((genjet[i]->PT - colojet[i]->PT) / (genjet[i]->PT)); } hist_PT_resolution->Fill(pt_res_cut); hist_PT_resolution_for_each[i]->Fill(genjet[i]->PT,pt_res_cut); } } } /////////////////////////////////// ////jet > 2 ve jet > 3 için HT//// /////////////////////////////////// int genjetsay=0; double genjetht2=0; double genjetht3=0; if(genjet.size() >= 2) { if(r<2.5) { for(unsigned i = 0; i<genjet.size();++i) { if(genjet[i]->PT > 50 && abs( genjet[i]->Eta ) <= 2.5) { genjetsay++; } } } } if(genjetsay>=2) { for(unsigned i =0;i<genjet.size();++i) { genjetht2=genjetht2+genjet[i]->PT; } } if(genjetsay>=3) { for(unsigned i = 0;i<genjet.size();++i) { genjetht3=genjetht3+genjet[i]->PT; } } histgen2jetht->Fill(genjetht2); histgen3jetht->Fill(genjetht3); /////////////////////////////////// ///R32 Colo /////////////////////// /////////////////////////////////// int say=0; for(unsigned i=0; i < colojet.size() ; i++) { if(colojet[i]->PT >= 50.0 && abs( colojet[i]->Eta ) <= 2.5) { say++; } } if( say >= 2 ) { histcolo2jetht->Fill(scht->HT); } if( say >= 3 ) { histcolo3jetht->Fill(scht->HT); } if(colojet.size()<1) { nocolojet=nocolojet+1; } else { double colojetht=0; for(unsigned i = 0 ; i < colojet.size();++i) { colojetht=colojetht+colojet[i]->PT; } histcolojetht->Fill(colojetht); } if(colojet.size()==1) { histleadingcolojetpt->Fill(colojet[0]->PT); } if(colojet.size()==2) { histnleadingcolojetpt->Fill(colojet[1]->PT); } if(colojet.size()==3) { histnnleadingcolojetpt->Fill(colojet[2]->PT); } ////////////// if(genjet.size()>0 && colojet.size()>0) { if(abs(genjet[0]->Eta)<=2.5 ){ histresleadingjet->Fill(genjet[0]->PT,((genjet[0]->PT - colojet[0]->PT)/genjet[0]->PT)); } } if(genjet.size()>1 && colojet.size()>1) { if(abs(genjet[1]->Eta)<=2.5 ){ histres2leadingjet->Fill(genjet[1]->PT,((genjet[1]->PT - colojet[1]->PT)/genjet[1]->PT)); } } if(genjet.size()>2 && colojet.size()>2) { if(abs(genjet[2]->Eta)<=2.5 ){ histres3leadingjet->Fill(genjet[2]->PT,((genjet[2]->PT - colojet[2]->PT)/genjet[2]->PT)); } } } out->Write(); out->Close(); }
//void LeptonEnergy(const char *inputFile = "sourceFiles/LO/ttbar_LO_total.root") void LeptonEnergy(const TString & file) { //const char *inputFile = Form("/home/tjkim/work/pheno/topmass/sourceFiles/LO/fromSayaka/ttbar_%s.root",file.Data()); //gSystem->Load("/export/apps/delphes//libDelphes"); const char *inputFile = Form("/data/users/seohyun/analysis/ttbar_%s.root",file.Data()); gSystem->Load("/home/seohyun/delphes/libDelphes.so"); /* TFile *f2 = TFile::Open("weightfunc2.root"); TFile *f3 = TFile::Open("weightfunc3.root"); TFile *f5 = TFile::Open("weightfunc5.root"); TFile *f15 = TFile::Open("weightfunc15.root"); const int nmass = 151; float mymass[ nmass ]; float integral2[ nmass ]; float integral3[ nmass ]; float integral5[ nmass ]; float integral15[ nmass ]; for(int i=0; i < nmass ; i++){ integral2[i] = 0.0; integral3[i] = 0.0; integral5[i] = 0.0; integral15[i] = 0.0; } TGraph * g2[nmass]; TGraph * g3[nmass]; TGraph * g5[nmass]; TGraph * g15[nmass]; TIter next(f2->GetListOfKeys()); TKey *key; int i = 0; while( (key = (TKey*) next())) { TClass *cl = gROOT->GetClass( key->GetClassName()); if( !cl->InheritsFrom("TGraph")) continue; g2[i] = (TGraph*) key->ReadObj(); string mass = g2[i]->GetName(); float temp = atof(mass.c_str()); mymass[i] = temp; i++; } TIter next(f3->GetListOfKeys()); i = 0; while( (key = (TKey*) next())) { TClass *cl = gROOT->GetClass( key->GetClassName()); if( !cl->InheritsFrom("TGraph")) continue; g3[i] = (TGraph*) key->ReadObj(); i++; } TIter next(f5->GetListOfKeys()); i = 0; while( (key = (TKey*) next())) { TClass *cl = gROOT->GetClass( key->GetClassName()); if( !cl->InheritsFrom("TGraph")) continue; g5[i] = (TGraph*) key->ReadObj(); i++; } TIter next(f15->GetListOfKeys()); i = 0; while( (key = (TKey*) next())) { TClass *cl = gROOT->GetClass( key->GetClassName()); if( !cl->InheritsFrom("TGraph")) continue; g15[i] = (TGraph*) key->ReadObj(); i++; } TFile * res = TFile::Open("hist_LO_res_v3.root"); TH1F * h_acc = (TH1F*) res->Get("h_totalacc_lepton"); */ //TFile* f = TFile::Open("hist_LO_res_60.root", "recreate"); TFile* f = TFile::Open(Form("170717/hist_%s.root",file.Data()), "recreate"); // Create chain of root trees TChain chain("Delphes"); chain.Add(inputFile); // Create object of class ExRootTreeReader ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t numberOfEntries = treeReader->GetEntries(); // Get pointers to branches used in this analysis TClonesArray *branchParticle = treeReader->UseBranch("Particle"); TClonesArray *branchMuon = treeReader->UseBranch("Muon"); TClonesArray *branchElectron = treeReader->UseBranch("Electron"); TClonesArray *branchJet = treeReader->UseBranch("Jet"); TClonesArray *branchEvent = treeReader->UseBranch("Event"); GenParticle *particle; GenParticle *daughter1; GenParticle *daughter2; GenParticle *granddaughter1_1; GenParticle *granddaughter1_2; GenParticle *granddaughter2_1; GenParticle *granddaughter2_2; GenParticle *genelectron; GenParticle *genmuon; LHEFEvent * event; // Create TTree //Float_t Muon_E; //Float_t Electron_E; //Float_t Lepton_E; //Float_t Lepton_E_reco; //TTree * tree = new TTree("tree","lepton energy"); //tree->Branch("Lepton_E",&Lepton_E,"Lepton_E/F"); //tree->Branch("Lepton_E_reco",&Lepton_E_reco,"Lepton_E_reco/F"); //tree->Branch("Muon_E",&Muon_E,"Muon_E/F"); //tree->Branch("Electron_E",&Electron_E,"Electron_E/F"); // Book histograms TH1 * channel = new TH1F("channel", "ttbar event categorization", 7, 0.0, 7.0); TH1 * h_muon_energy = new TH1F("h_muon_energy", "muon energy distribution", 5000, 0, 500); TH1 * h_electron_energy = new TH1F("h_electron_energy", "electron energy distribution", 5000, 0, 500); TH1 * h_lepton_energy = new TH1F("h_lepton_energy", "lepton energy distribution", 5000, 0, 500); //TH1 * h_muon_energy_acc = new TH1F("h_muon_energy_acc", "muon energy distribution", 5000, 0, 500); //TH1 * h_electron_energy_acc = new TH1F("h_electron_energy_acc", "electron energy distribution", 5000, 0, 500); TH1 * h_lepton_energy_acc = new TH1F("h_lepton_energy_acc", "lepton energy distribution", 5000, 0, 500); //TH1 * h_muon_energy_reco = new TH1F("h_muon_energy_reco", "muon energy distribution at RECO", 5000, 0, 500); //TH1 * h_electron_energy_reco = new TH1F("h_electron_energy_reco", "electron energy distribution at RECO", 5000, 0, 500); TH1 * h_lepton_energy_reco = new TH1F("h_lepton_energy_reco", "lepton energy distribution at RECO", 5000, 0, 500); TH2 * h2_lepton_energy_response = new TH2F("h2_lepton_energy_response", "lepton energy response", 5000, 0, 500,5000,0,500); //TH1 * h_muon_energy_reco_S2 = new TH1F("h_muon_energy_reco_S2", "muon energy distribution at RECO", 5000, 0, 500); //TH1 * h_electron_energy_reco_S2 = new TH1F("h_electron_energy_reco_S2", "electron energy distribution at RECO", 5000, 0, 500); //TH1 * h_lepton_energy_reco_S2 = new TH1F("h_lepton_energy_reco_S2", "lepton energy distribution at RECO", 5000, 0, 500); //TH1 * h_lepton_nbjets_reco_S2 = new TH1F("h_lepton_nbjets_reco_S2","number of b jets",5,0,5); //TH1 * h_muon_energy_reco_final = new TH1F("h_muon_energy_reco_final", "muon energy distribution at RECO", 5000, 0, 500); //TH1 * h_electron_energy_reco_final = new TH1F("h_electron_energy_reco_final", "electron energy distribution at RECO", 5000, 0, 500); TH1 * h_lepton_energy_reco_final = new TH1F("h_lepton_energy_reco_final", "lepton energy distribution at RECO", 5000, 0, 500); TH2 * h2_lepton_energy_final_response = new TH2F("h2_lepton_energy_final_response", "lepton energy response", 5000, 0, 500,5000,0,500); //std::vector<float> lepton_E; //std::vector<float> lepton_E_final; int ndileptonic = 0; //ee, mm, tautau int ndileptonic2 = 0; //ee, mm, tau->ee, mm int ndileptonic3 = 0; //ee, mm int nsemileptonic = 0; int nsemileptonic2 = 0; int nsemileptonic3 = 0; int nhadronic = 0; // Loop over all events for(Int_t entry = 0; entry < numberOfEntries; ++entry) { //if( entry == 100000) break; if( entry%1000 == 0) cout << "starting with " << entry << endl; // Load selected branches with data from specified event treeReader->ReadEntry(entry); int nmuons = 0; int nelectrons= 0; int ntaumuons = 0; int ntauelectrons= 0; int ntaus = 0 ; int nhadrons = 0 ; // If event contains at least 1 particle int ntop = 0; double genweight = 1.0; if(branchEvent->GetEntries() > 0) { event = (LHEFEvent * ) branchEvent->At(0); genweight = event->Weight; //cout << "event number = " << event->Number << endl; //cout << "event weight = " << event->Weight << endl; } //Lepton_E = -1.0; if(branchParticle->GetEntries() > 0) { for(int i = 0; i < branchParticle->GetEntriesFast() ; i++){ if(ntop == 2) break; particle = (GenParticle *) branchParticle->At(i); int status = particle->Status; bool LO = true; //if( LO ) cout << "THIS IS LO..." << endl; if( status != 3) continue; int id = particle->PID; double gen_pt = particle->PT; double gen_eta = particle->Eta; //Leading order if( LO) { if( abs(id) == 11 ){ genelectron = particle; double energy = genelectron->E; h_electron_energy->Fill( energy, genweight ); h_lepton_energy->Fill( energy, genweight ); //Lepton_E = energy; //for(int i=0; i < nmass; i++){ // float w = g2[i]->Eval( energy ); // integral2[i] = integral2[i] + w ; //} //lepton_E.push_back( energy ); if( energy > 20 && fabs(gen_eta) < 2.4) { //h_electron_energy_acc->Fill( energy, genweight ); h_lepton_energy_acc->Fill( energy, genweight ); nmuons++; } //daughter1 = (GenParticle*) branchParticle->At( particle->D1); //daughter2 = (GenParticle*) branchParticle->At( particle->D2); //int d1_id = abs(daughter1->PID); //int d2_id = abs(daughter2->PID); //cout << "electron daughter " << d1_id << " , " << d2_id << endl; }else if( abs(id) == 13 ){ genmuon = particle; double energy = genmuon->E; h_muon_energy->Fill( energy, genweight ); h_lepton_energy->Fill( energy, genweight ); //Lepton_E = energy; //for(int i=0; i < nmass; i++){ // float w = g2[i]->Eval( energy ); // integral2[i] = integral2[i] + w ; //} //lepton_E.push_back( energy ); if( energy > 20 && fabs(gen_eta) < 2.4) { //h_muon_energy_acc->Fill( energy, genweight ); h_lepton_energy_acc->Fill( energy, genweight ); nelectrons++; } //int d1_id = -1; //int d2_id = -1; //if( particle->D1 >= branchParticle->GetEntries()){ // daughter1 = (GenParticle*) branchParticle->At( particle->D1); // int d1_id = abs(daughter1->PID); //} //if( particle->D1 >= branchParticle->GetEntries()){ // daughter1 = (GenParticle*) branchParticle->At( particle->D1); // int d1_id = abs(daughter1->PID); //} //cout << "muon daughter " << d1_id << " , " << d2_id << endl; } //NLO }else if( abs(id) == 6 ) { ntop++; particle = (GenParticle*) branchParticle->At( i ) ; if( particle->D1 >= branchParticle->GetEntries() ) continue; bool lasttop = false ; while( !lasttop ){ if( particle->D1 >= branchParticle->GetEntries() ) break; GenParticle * d = (GenParticle *) branchParticle->At( particle->D1 ); if( abs(d->PID) != 6 ) { lasttop = true; } else { particle = d ; } } if( particle->D1 >= branchParticle->GetEntries() || particle->D2 >= branchParticle->GetEntries() ){ continue; } daughter1 = (GenParticle*) branchParticle->At( particle->D1) ; daughter2 = (GenParticle*) branchParticle->At( particle->D2) ; bool lastW = false; int d1_id = abs(daughter1->PID); int d2_id = abs(daughter2->PID); //cout << "top daughter " << d1_id << " , " << d2_id << endl; while( !lastW) { if( daughter1->D1 >= branchParticle->GetEntries() ) break; GenParticle * d = (GenParticle *) branchParticle->At( daughter1->D1 ); if( abs(d->PID) != 24 ) { lastW = true; } else { daughter1 = d ; } } if( daughter1->D1 >= branchParticle->GetEntries() || daughter1->D2 >= branchParticle->GetEntries() ){ continue; } granddaughter1_1 = (GenParticle*) branchParticle->At( daughter1->D1) ; granddaughter1_2 = (GenParticle*) branchParticle->At( daughter1->D2) ; granddaughter2_1 = (GenParticle*) branchParticle->At( daughter2->D1) ; granddaughter2_2 = (GenParticle*) branchParticle->At( daughter2->D2) ; int gd1_1_id = abs(granddaughter1_1->PID); int gd1_2_id = abs(granddaughter1_2->PID); int gd2_1_id = abs(granddaughter2_1->PID); int gd2_2_id = abs(granddaughter2_2->PID); //cout << "W daughters = " << gd1_1_id << " , " << gd1_2_id << " , " << gd2_1_id << " , " << gd2_2_id << endl; int W_dau_status = granddaughter1_1->Status ; //if( gd1_1_id > gd1_2_id ) cout << "Something is WRONG ! " << endl; GenParticle * le = (GenParticle * ) branchParticle->At( granddaughter1_1->D1 ); //GenParticle * leda = (GenParticle * ) branchParticle->At( le->D1); if( gd1_1_id == 11 || gd1_1_id == 13 ){ cout << le->D1 << " , " << le->D2 << endl; // cout << " original id and status = " << gd1_1_id << " , " << W_dau_status << " le id and status = " << le->PID << " , " << le->Status << " leda id and status = " << leda->PID << " , " << leda->Status << endl; } if( gd1_1_id == 11 ) { nelectrons++; //genelectron = granddaughter1_2; genelectron = le; } else if( gd1_1_id == 13 ) { nmuons++; //genmuon = granddaughter1_2; genmuon = le; } else if( gd1_1_id == 15 ) { ntaus++; /* if( granddaughter1_2->D1 >= branchParticle->GetEntries() || granddaughter1_2->D2 >= branchParticle->GetEntries() ){ continue; } GenParticle * taudaughter1 = (GenParticle*) branchParticle->At( granddaughter1_2->D1) ; GenParticle * taudaughter2 = (GenParticle*) branchParticle->At( granddaughter1_2->D2) ; int taud1_id = abs(taudaughter1->PID); int taud2_id = abs(taudaughter2->PID); //cout << "tau daughter = " << taud1_id << " " << taud2_id << endl; if( taud1_id == 11 || taud1_id == 12 ) ntauelectrons++; else if( taud1_id == 13 || taud1_id == 14 ) ntaumuons++; else if( taud1_id == 15 || taud1_id == 16 ) { if( taudaughter1->D1 >= branchParticle->GetEntries() || taudaughter1->D2 >= branchParticle->GetEntries() ){ continue; } GenParticle * taugranddaughter1 = (GenParticle*) branchParticle->At( taudaughter1->D1) ; GenParticle * taugranddaughter2 = (GenParticle*) branchParticle->At( taudaughter1->D2) ; int taugd1_id = abs(taugranddaughter1->PID); int taugd2_id = abs(taugranddaughter2->PID); //cout << "tau grand daughter = " << taugd1_id << " " << taugd2_id << endl; if( taugd1_id == 11 || taugd1_id == 12 ) ntauelectrons++; else if( taugd1_id == 13 || taugd1_id == 14 ) ntaumuons++; ㅜㅜ else { continue; } } else { continue; } */ }else{ nhadrons++; } //cout << "nelectrons = " << nelectrons << " nmuons = " << nmuons << " ntaus = " << ntaus << " nhadrons = " << nhadrons << endl; } } } if( LO ){ }else{ int remaining = 0 ; int nleptons = nelectrons + nmuons + ntaus; if( nleptons == 2 && nhadrons == 0){ //cout << "dilepton" << endl; ndileptonic++; if( ntaus ==0 || ( ntaus == 1 && (ntauelectrons+ntaumuons) == 1) || (ntaus == 2 && (ntauelectrons+ntaumuons) == 2) ) { ndileptonic2++; } if( ntaus == 0) ndileptonic3++; }else if( nleptons == 1 && nhadrons == 1){ //cout << "lepton+jets" << endl; nsemileptonic++; if( ntaus ==0 || ( ntaus == 1 && (ntauelectrons+ntaumuons) == 1) ) nsemileptonic2++; if( ntaus == 0 ) { nsemileptonic3++; if( nmuons ) { h_muon_energy->Fill(genmuon->E, genweight); h_lepton_energy->Fill(genmuon->E, genweight); } if( nelectrons ) { h_electron_energy->Fill(genelectron->E, genweight); h_lepton_energy->Fill(genelectron->E, genweight); } } }else if ( nleptons == 0 && nhadrons == 2 ){ //cout << "hadronic" << endl; nhadronic++; }else{ //cout << "remaining" << endl; remaining++; } } Muon * mymuon; Electron * myelectron; bool passmuon = false; bool passelectron = false; if(branchMuon->GetEntries() > 0) { bool mymuonpass = false; for(int i = 0; i < branchMuon->GetEntriesFast() ; i++){ Muon * muon = (Muon *) branchMuon->At(i); if( muon->P4().E() > 20 && fabs( muon->P4().Eta() < 2.4) ){ mymuon = muon; mymuonpass = true; } break; } if( mymuonpass && ( nmuons > 0 || nelectrons > 0 ) ){ //h_muon_energy_reco->Fill(mymuon->P4().E(), genweight); h_lepton_energy_reco->Fill(mymuon->P4().E(), genweight); h2_lepton_energy_response->Fill(mymuon->P4().E(), genmuon->E, genweight); passmuon = true; } } if(branchElectron->GetEntries() > 0) { bool myelectronpass = false; for(int i = 0; i < branchElectron->GetEntriesFast() ; i++){ Electron * electron = (Electron *) branchElectron->At(i); if( electron->P4().E() > 20 && fabs( electron->P4().Eta() < 2.4) ){ myelectron = electron; myelectronpass = true; } break; } if( myelectronpass && ( nmuons > 0 || nelectrons > 0 ) ){ //h_electron_energy_reco->Fill(myelectron->P4().E(), genweight); h_lepton_energy_reco->Fill(myelectron->P4().E(), genweight); h2_lepton_energy_response->Fill(myelectron->P4().E(), genelectron->E, genweight); passelectron = true; } } if(branchJet->GetEntries() > 0 ) { int njets = 0; int nbjets = 0; for(int i = 0; i < branchJet->GetEntriesFast() ; i++){ Jet * jet = (Jet *) branchJet->At(i); if( jet->P4().Pt() > 30 && fabs( jet->P4().Eta() < 2.5) ){ njets++; if( jet->BTag ) nbjets++; } } } //Muon_E = -9.0; //Electron_E = -9.0; //Lepton_E_reco = -1.0; float Energy = 9.0; if( passelectron && !passmuon && njets >= 4){ float myele_energy = myelectron->P4().E(); //h_electron_energy_reco_S2->Fill(myele_energy, genweight); //h_lepton_energy_reco_S2->Fill(myele_energy, genweight); //h_lepton_nbjets_reco_S2->Fill(nbjets); if( nbjets >= 2 ){ //h_electron_energy_reco_final->Fill(myele_energy, genweight); h_lepton_energy_reco_final->Fill(myele_energy, genweight); h2_lepton_energy_final_response->Fill(myele_energy, genelectron->E, genweight); } //lepton_E_final.push_back( myelectron->P4().E() ); //for(int i=0; i < nmass; i++){ // float corr = 1.0/ h_acc->Interpolate( myelectron->P4().E() ); // float w = g2[i]->Eval( myelectron->P4().E() ); //integral2[i] = integral2[i] + w*corr ; //} //Electron_E = myele_energy; //Lepton_E_reco = myele_energy; } if( passmuon && !passelectron && njets >= 4){ float mymuon_energy = mymuon->P4().E(); //h_muon_energy_reco_S2->Fill(mymuon_energy, genweight); //h_lepton_energy_reco_S2->Fill(mymuon_energy, genweight); //h_lepton_nbjets_reco_S2->Fill(nbjets); if( nbjets >= 2 ){ // h_muon_energy_reco_final->Fill(mymuon_energy, genweight); h_lepton_energy_reco_final->Fill(mymuon_energy, genweight); h2_lepton_energy_final_response->Fill(mymuon_energy, genmuon->E, genweight); } //lepton_E_final.push_back( mymuon->P4().E() ); //for(int i=0; i < nmass; i++){ // float corr = 1.0/ h_acc->Interpolate( mymuon->P4().E() ); // float w = g2[i]->Eval( mymuon->P4().E() ); //integral2[i] = integral2[i] + w*corr ; //} //Muon_E = mymuon_energy; //Lepton_E_reco = mymuon_energy; } /* for(int i=0; i < nmass; i++){ //for(int i=0; i < 0; i++){ float lenergy = -9; if( Muon_E > 0 && Electron_E < 0 ) lenergy = Muon_E; if( Muon_E < 0 && Electron_E > 0 ) lenergy = Electron_E; float acc = h_acc->Interpolate( lenergy ); integral2[i] = integral2[i] + g2[i]->Eval( lenergy ) /acc ; integral3[i] = integral3[i] + g3[i]->Eval( lenergy ) /acc ; integral5[i] = integral5[i] + g5[i]->Eval( lenergy ) /acc ; integral15[i] = integral15[i] + g15[i]->Eval( lenergy ) /acc ; } */ //if( passmuon && passelectron) cout << "Lepton E = " << Lepton_E << endl; //tree->Fill(); } //tree->Print(); // for(int m=0; m < nmass; m++){ // for(int i=0; i < 400;i++){ // float bincenter = h_lepton_energy->GetBinCenter(i+1); // float binconten = h_lepton_energy->GetBinContent(i+1); // float weight_value = g2[m]->Eval( bincenter ); // integral2[m] = integral2[m] + weight_value*binconten; // } // } /* for(int m=0; m < nmass; m++){ for(int i=0; i < lepton_E_final.size() ;i++){ float energy = lepton_E_final[i]; float corr = 1.0/ h_acc->Interpolate( energy ); float weight_value2 = g2[m]->Eval( bincenter ); float weight_value3 = g3[m]->Eval( bincenter ); float weight_value5 = g5[m]->Eval( bincenter ); float weight_value15 = g15[m]->Eval( bincenter ); integral2[m] = integral2[m] + weight_value2*corr; integral3[m] = integral3[m] + weight_value3*corr; integral5[m] = integral5[m] + weight_value5*corr; integral15[m] = integral15[m] + weight_value15*corr; } } TGraph * final2 = new TGraph(); TGraph * final3 = new TGraph(); TGraph * final5 = new TGraph(); TGraph * final15 = new TGraph(); for (Int_t i=0;i<nmass;i++) { final2->SetPoint(i, mymass[i], integral2[i]); final3->SetPoint(i, mymass[i], integral3[i]); final5->SetPoint(i, mymass[i], integral5[i]); final15->SetPoint(i, mymass[i], integral15[i]); } final2->SetName("n2"); final3->SetName("n3"); final5->SetName("n5"); final15->SetName("n15"); final2->Write(); final3->Write(); final5->Write(); final15->Write(); */ if( remaining != 0 ) cout << "Someting is wrong" << endl; //TCanvas * c = new TCanvas("c","c",1000,600); channel->SetBinContent(1,ndileptonic); channel->SetBinContent(2,ndileptonic2); channel->SetBinContent(3,ndileptonic3); channel->SetBinContent(4,nsemileptonic); channel->SetBinContent(5,nsemileptonic2); channel->SetBinContent(6,nsemileptonic3); channel->SetBinContent(7,nhadronic); channel->GetXaxis()->SetBinLabel(1,"Dileptonic"); channel->GetXaxis()->SetBinLabel(2,"DileptonicTau"); channel->GetXaxis()->SetBinLabel(3,"DileptonicNoTau"); channel->GetXaxis()->SetBinLabel(4,"Semileptonic"); channel->GetXaxis()->SetBinLabel(5,"SemileptonicTau"); channel->GetXaxis()->SetBinLabel(6,"SemileptonicNoTau"); channel->GetXaxis()->SetBinLabel(7,"Hadronic"); //int nBins = 400; //h_lepton_energy->AddBinContent(nBins, h_lepton_energy->GetBinContent(nBins+1)); //h_lepton_energy_reco_final->AddBinContent(nBins, h_lepton_energy_reco_final->GetBinContent(nBins+1)); // Show resulting histograms channel->SetStats(0000); double scale = 1.0/numberOfEntries; channel->Scale( scale ); //channel->Draw("HText0"); /* channel->Write(); h_muon_energy->Write(); h_electron_energy->Write(); h_lepton_energy->Write(); h_muon_energy_acc->Write(); h_electron_energy_acc->Write(); h_lepton_energy_acc->Write(); h_muon_energy_reco->Write(); h_electron_energy_reco->Write(); h_lepton_energy_reco->Write(); h_muon_energy_reco_final->Write(); h_electron_energy_reco_final->Write(); h_lepton_energy_reco_final->Write(); */ f->Write(); f->Close(); }
void whbb_trigger(const TString input="whbb.txt", const TString outputfile="/afs/cern.ch/work/j/jlawhorn/whbb.root") { // declare constants //const Double_t MUON_MASS = 0.105658369; //const Double_t ELE_MASS = 0.000511; //const Double_t TAU_MASS = 1.77682; const Int_t GAM_ID_CODE = 22; const Int_t TAU_ID_CODE = 15; const Int_t MU_ID_CODE = 13; const Int_t ELE_ID_CODE = 11; const Float_t MAX_MATCH_DIST = 0.4; TChain chain("Delphes"); ifstream ifs; ifs.open(input.Data()); assert(ifs.is_open()); string line; while(getline(ifs,line)) { TString inputfile; stringstream ss(line); ss >> inputfile; chain.Add(inputfile); } ifs.close(); ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t n = treeReader->GetEntries(); //TClonesArray *branchJet = treeReader->UseBranch("Jet"); //if (!(branchJet)) { //cout << "File broken" << endl; //return; //} //TClonesArray *branchElectron = treeReader->UseBranch("Electron"); //TClonesArray *branchMuon = treeReader->UseBranch("Muon"); TClonesArray *branchGenJet = treeReader->UseBranch("GenJet"); TClonesArray *branchGenMET = treeReader->UseBranch("GenMissingET"); TClonesArray *branchHT = treeReader->UseBranch("ScalarHT"); TClonesArray *branchParticle = treeReader->UseBranch("Particle"); GenParticle *part=0, *mama=0; Jet *jet=0; MissingET *metObj=0; ScalarHT *htObj=0; //Electron *ele=0; Muon *mu=0; UInt_t isReco=0; Float_t e1pt, e1eta, e1phi; Float_t e2pt, e2eta, e2phi; Float_t m1pt, m1eta, m1phi; Float_t m2pt, m2eta, m2phi; Float_t g1pt, g1eta, g1phi; Float_t g2pt, g2eta, g2phi; Float_t t1pt, t1eta, t1phi; Float_t t2pt, t2eta, t2phi; Float_t j1pt, j1eta, j1phi; Float_t j2pt, j2eta, j2phi; Float_t j3pt, j3eta, j3phi; Float_t j4pt, j4eta, j4phi; Float_t mht, ht; UInt_t triggerBits126; UInt_t triggerBits180; UInt_t triggerBits250; UInt_t triggerBits350; TFile *outfile = new TFile(outputfile, "RECREATE"); TTree *outtree = new TTree("Events", "Events"); Trigger::Event data; outtree->Branch("Events", &data.isReco, "isReco/i:e1pt/F:e1eta:e1phi:e2pt:e2eta:e2phi:m1pt:m1eta:m1phi:m2pt:m2eta:m2phi:g1pt:g1eta:g1phi:g2pt:g2eta:g2phi:t1pt:t1eta:t1phi:t2pt:t2eta:t2phi:j1pt:j1eta:j1phi:j2pt:j2eta:j2phi:j3pt:j3eta:j3phi:j4pt:j4eta:j4phi:mht:ht:triggerBits126/i:triggerBits180:triggerBits250:triggerBits350"); //n=50; for (Int_t iEntry=0; iEntry<n; iEntry++) { // entry loop treeReader->ReadEntry(iEntry); e1pt=-99; e1eta=-99; e1phi=-99; e2pt=-99; e2eta=-99; e2phi=-99; m1pt=-99; m1eta=-99; m1phi=-99; m2pt=-99; m2eta=-99; m2phi=-99; g1pt=-99; g1eta=-99; g1phi=-99; g2pt=-99; g2eta=-99; g2phi=-99; t1pt=-99; t1eta=-99; t1phi=-99; t2pt=-99; t2eta=-99; t2phi=-99; j1pt=-99; j1eta=-99; j1phi=-99; j2pt=-99; j2eta=-99; j2phi=-99; j3pt=-99; j3eta=-99; j3phi=-99; j4pt=-99; j4eta=-99; j4phi=-99; mht=-99; ht=-99; if (branchGenMET) { metObj=(MissingET*) branchGenMET->At(0); mht=metObj->MET; } else mht=3; if (branchHT) { htObj=(ScalarHT*) branchHT->At(0); ht=htObj->HT; } else ht=5; //cout << "----" << endl; //cout << " fUID i PID Status M1 M2 D1 D2" << endl; for (Int_t i=0; i<branchParticle->GetEntries(); i++) { part = (GenParticle*) branchParticle->At(i); if (part->Status==1) continue; if (fabs(part->PID) == ELE_ID_CODE) { //cout << "electron " << part->Status << endl; if (part->PT>e1pt) { if (deltaR(part->Eta, e1eta, part->Phi, e1phi)>MAX_MATCH_DIST) { e2pt=e1pt; e2eta=e1eta; e2phi=e1phi; } e1pt=part->PT; e1eta=part->Eta; e1phi=part->Phi; } else if (part->PT>e2pt && deltaR(part->Eta, e1eta, part->Phi, e1phi)>MAX_MATCH_DIST) { e2pt=e1pt; e2eta=e1eta; e2phi=e1phi; } } if (fabs(part->PID) == MU_ID_CODE) { //cout << "muon " << part->Status << endl; if (part->PT>m1pt) { if (deltaR(part->Eta, m1eta, part->Phi, m1phi)>MAX_MATCH_DIST) { m2pt=m1pt; m2eta=m1eta; m2phi=m1phi; } m1pt=part->PT; m1eta=part->Eta; m1phi=part->Phi; } else if (part->PT>m2pt && deltaR(part->Eta, m1eta, part->Phi, m1phi)>MAX_MATCH_DIST) { m2pt=m1pt; m2eta=m1eta; m2phi=m1phi; } } if (fabs(part->PID) == TAU_ID_CODE) { //cout << "tau " << part->Status << endl; if (part->PT>t1pt) { if (deltaR(part->Eta, t1eta, part->Phi, t1phi)>MAX_MATCH_DIST) { t2pt=t1pt; t2eta=t1eta; t2phi=t1phi; } t1pt=part->PT; t1eta=part->Eta; t1phi=part->Phi; } else if (part->PT>t2pt && deltaR(part->Eta, t1eta, part->Phi, t1phi)>MAX_MATCH_DIST) { t2pt=t1pt; t2eta=t1eta; t2phi=t1phi; } } } /* for (Int_t i=0; i<branchParticle->GetEntries(); i++) { part = (GenParticle*) branchParticle->At(i); if (fabs(part->PID)==ELE_ID_CODE || fabs(part->PID)==MU_ID_CODE) { ////cout << "lepton cleaning" << endl; if (deltaR(part->Eta, t1eta, part->Phi, t1phi)<MAX_MATCH_DIST) { //cout << "match to tau 1" << endl; t1pt=-99; t1eta=-99; t1phi=-99; } if (deltaR(part->Eta, t2eta, part->Phi, t2phi)<MAX_MATCH_DIST) { //cout << "match to tau 2" << endl; t2pt=-99; t2eta=-99; t2phi=-99; } } }*/ /* cout << m1pt << " " << m1eta << " " << m1phi << endl; cout << m2pt << " " << m2eta << " " << m2phi << endl; cout << e1pt << " " << e1eta << " " << e1phi << endl; cout << e2pt << " " << e2eta << " " << e2phi << endl; cout << t1pt << " " << t1eta << " " << t1phi << endl; cout << t2pt << " " << t2eta << " " << t2phi << endl; */ if (deltaR(e1eta, t1eta, e1phi, t1phi)<MAX_MATCH_DIST) { //cout << "e1 matches t1, removing t1" << endl; t1pt=-99; t1eta=-99; t1phi=-99; } if (deltaR(e2eta, t1eta, e2phi, t1phi)<MAX_MATCH_DIST) { //cout << "e2 matches t1, removing t1" << endl; t1pt=-99; t1eta=-99; t1phi=-99; } if (deltaR(e1eta, t2eta, e1phi, t2phi)<MAX_MATCH_DIST) { //cout << "e1 matches t2, removing t2" << endl; t2pt=-99; t2eta=-99; t2phi=-99; } if (deltaR(e2eta, t2eta, e2phi, t2phi)<MAX_MATCH_DIST) { //cout << "e2 matches t2, removing t2" << endl; t2pt=-99; t2eta=-99; t2phi=-99; } if (deltaR(m1eta, t1eta, m1phi, t1phi)<MAX_MATCH_DIST) { //cout << "m1 matches t1, removing t1" << endl; t1pt=-99; t1eta=-99; t1phi=-99; } if (deltaR(m2eta, t1eta, m2phi, t1phi)<MAX_MATCH_DIST) { //cout << "m2 matches t1, removing t1" << endl; t1pt=-99; t1eta=-99; t1phi=-99; } if (deltaR(m1eta, t2eta, m1phi, t2phi)<MAX_MATCH_DIST) { //cout << "m1 matches t2, removing t2" << endl; t2pt=-99; t2eta=-99; t2phi=-99; } if (deltaR(m2eta, t2eta, m2phi, t2phi)<MAX_MATCH_DIST) { //cout << "m2 matches t2, removing t2" << endl; t2pt=-99; t2eta=-99; t2phi=-99; } if (t1pt>-99 || t2pt>-99) { Float_t t1pt_p=t1pt; Float_t t2pt_p=t2pt; for (Int_t i=0; i<branchGenJet->GetEntries(); i++) { jet = (Jet*) branchGenJet->At(i); if (deltaR(jet->Eta, t1eta, jet->Phi, t1phi)<MAX_MATCH_DIST && (t1pt==t1pt_p || jet->PT>t1pt)) { ////cout << "found jet for tau 1" << endl; t1pt=jet->PT; t1eta=jet->Eta; t1phi=jet->Phi; } if (deltaR(jet->Eta, t2eta, jet->Phi, t2phi)<MAX_MATCH_DIST && (t2pt==t2pt_p || jet->PT>t2pt)) { ////cout << "found jet for tau 2" << endl; t2pt=jet->PT; t2eta=jet->Eta; t2phi=jet->Phi; } } if (t1pt_p==t1pt) { ////cout << "no jet match for tau 1" << endl; t1pt=-99; t1eta=-99; t1phi=-99; } if (t2pt_p==t2pt) { ////cout << "no jet match for tau 2" << endl; t2pt=-99; t2eta=-99; t2phi=-99; } } /* cout << m1pt << " " << m1eta << " " << m1phi << endl; cout << m2pt << " " << m2eta << " " << m2phi << endl; cout << e1pt << " " << e1eta << " " << e1phi << endl; cout << e2pt << " " << e2eta << " " << e2phi << endl; cout << t1pt << " " << t1eta << " " << t1phi << endl; cout << t2pt << " " << t2eta << " " << t2phi << endl; */ for (Int_t i=0; i<branchGenJet->GetEntries(); i++) { jet = (Jet*) branchGenJet->At(i); if (jet->PT > j1pt) { j4pt=j3pt; j4eta=j3eta; j4phi=j3phi; j3pt=j2pt; j3eta=j2eta; j3phi=j2phi; j2pt=j1pt; j2eta=j1eta; j2phi=j1phi; j1pt=jet->PT; j1eta=jet->Eta; j1phi=jet->Phi; } else if (jet->PT > j2pt) { j4pt=j3pt; j4eta=j3eta; j4phi=j3phi; j3pt=j2pt; j3eta=j2eta; j3phi=j2phi; j2pt=jet->PT; j2eta=jet->Eta; j2phi=jet->Phi; } else if (jet->PT > j3pt) { j4pt=j3pt; j4eta=j3eta; j4phi=j3phi; j3pt=jet->PT; j3eta=jet->Eta; j3phi=jet->Phi; } else if (jet->PT > j4pt) { j4pt=jet->PT; j4eta=jet->Eta; j4phi=jet->Phi; } } data.isReco=0; data.e1pt=e1pt; data.e1eta=e1eta; data.e1phi=e1phi; data.e2pt=e2pt; data.e2eta=e2eta; data.e2phi=e2phi; data.m1pt=m1pt; data.m1eta=m1eta; data.m1phi=m1phi; data.m2pt=m2pt; data.m2eta=m2eta; data.m2phi=m2phi; data.g1pt=g1pt; data.g1eta=g1eta; data.g1phi=g1phi; data.g2pt=g2pt; data.g2eta=g2eta; data.g2phi=g2phi; data.t1pt=t1pt; data.t1eta=t1eta; data.t1phi=t1phi; data.t2pt=t2pt; data.t2eta=t2eta; data.t2phi=t2phi; data.j1pt=j1pt; data.j1eta=j1eta; data.j1phi=j1phi; data.j2pt=j2pt; data.j2eta=j2eta; data.j2phi=j2phi; data.j3pt=j3pt; data.j3eta=j3eta; data.j3phi=j3phi; data.j4pt=j4pt; data.j4eta=j4eta; data.j4phi=j4phi; data.mht=mht; data.ht=ht; triggerBits126 = Trigger::checkTriggers126(data); triggerBits180 = Trigger::checkTriggers180(data); triggerBits250 = Trigger::checkTriggers250(data); triggerBits350 = Trigger::checkTriggers350(data); data.triggerBits126=triggerBits126; data.triggerBits180=triggerBits180; data.triggerBits250=triggerBits250; data.triggerBits350=triggerBits350; ////cout << " " << triggerBits << endl; outtree->Fill(); //if ( (data.triggerBits & Trigger::kTauMu) >0 ) { ////cout << "mutau" << endl; //} TString tt="t1pt>0 && t2pt>0"; TString mt="m1pt>0 && (t1pt>0 || t2pt>0)"; TString et="e1pt>0 && (t1pt>0 || t2pt>0)"; TString em="m1pt>0 && e1pt>0"; TString ee="e1pt>0 && e2pt>0"; TString mm="m1pt>0 && m2pt>0"; /* if ( m1pt>0 && (t1pt>0||t2pt>0) && e1pt>0) { cout << "problem child" << endl; } if (!(t1pt>0 && t2pt>0)*!(m1pt>0 && (t1pt>0 || t2pt>0))*!(e1pt>0 && (t1pt>0 || t2pt>0))*!(m1pt>0 && e1pt>0)*!(e1pt>0 && e2pt>0)*!(m1pt>0 && m2pt>0) ) { cout << "!!!!" << endl; cout << " fUID i PID Status M1 M2 D1 D2" << endl; for (Int_t i=0; i<branchParticle->GetEntries(); i++) { part = (GenParticle*) branchParticle->At(i); //if ( part->M1>20 ) continue; cout << part->fUniqueID << " " << setw(3) << i << " " << setw(3) << part->PID << " " << setw(3) << part->Status << " " << setw(3) << part->M1 << " " << setw(3) << part->M2 << " " << setw(3) << part->D1 << " " << setw(3) << part->D2 << endl; } }*/ } outfile->Write(); outfile->Close(); delete outfile; }
// Takes as input a given process with corresponding luminosity, as well as sample CME, cuts, directory location, and output file name - saves corresponding histogram in root file. void processsimulation(TString sample, Double_t crosssection, TLorentzVector CME, Double_t luminosity, TString filename, TString directory, std::map<TString, Int_t> cut, std::map<TString, Int_t> particletype, std::clock_t start){ cout << "Processing " << sample << endl; // Defines which sample to read from TString samplename = directory + sample + root; TChain chain("Delphes"); chain.Add(samplename); ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); // Reads sample from delphes root fiile //Branches to be read from the collision file std::array<TString, 5> branchnames = {(TString)"Muon",(TString)"Electron",(TString)"Photon",(TString)"Jet", (TString)"Particle" }; // (TString)"Tower",(TString)"Track",(TString)"EFlowTrack",(TString)"EFlowPhoton",(TString)"EFlowNeutralHadron"}; std::map<TString, TClonesArray*> branches; for (int i=0; i<(int)branchnames.size(); i++){ branches.insert ( std::pair<TString, TClonesArray*> (branchnames[i], treeReader->UseBranch(branchnames[i]))); } // Variables to store particles Electron *electron = 0; Muon *muon = 0; Jet *jet = 0; Double_t numberOfEntries = treeReader->GetEntries(); Double_t norm_const = (crosssection*luminosity)/numberOfEntries; // Normalizes samples based on cross section and luminosity TTree *ttree = new TTree(sample, sample); //Creates a branch for each variable listed in "parameters" in the main function std::map<TString, Float_t> *parameters = new std::map<TString, Float_t>; std::map<TString, Int_t>::iterator setparameters; for ( setparameters = cut.begin(); setparameters != cut.end(); setparameters++){ parameters->insert( std::pair<TString, Float_t> (setparameters->first, 0)); } std::map<TString, Float_t>::iterator setbranch; for (setbranch = parameters->begin(); setbranch != parameters->end(); setbranch++){ TString type = "/F"; TString vartype = setbranch->first + type; ttree->Branch(setbranch->first, &(*parameters)[setbranch->first],vartype); } //Timer double duration = 0; double durationnew = 0; for (Int_t iEntry = 0; iEntry < numberOfEntries; iEntry++){ treeReader->ReadEntry(iEntry); TString skip = ""; durationnew = (( std::clock() - start ) / (double) CLOCKS_PER_SEC)/60; if (durationnew - duration > 1){ cout << "Still running - it has been "<< durationnew << " minutes" <<'\n'; duration = durationnew; } if (particletype["muon"]==1){ // Event selection process on Jets skip = parameter_functions(branches["Muon"], muon, "muon", branches, cut, CME, ttree, parameters); if (skip == "fill" || skip == "skip") continue; } if (particletype["electron"]==1){ // Event selection process on Jets skip = parameter_functions(branches["Electron"], electron, "electron", branches, cut, CME, ttree, parameters); if (skip == "fill" || skip == "skip") continue; } // if (particletype["jet"]==1){ // // Event selection process on Jets // skip = parameter_functions(branches["Jet"], jet, "jet", branches, cut, CME, ttree, parameters); // if (skip == "fill" || skip == "skip") continue; // } } TFile f(filename, "update"); ttree->Write(); f.Close(); ofstream myfile; myfile.open ("normalization.txt", ios::app); cout << "Normalization constant for " << sample << " is " << norm_const << endl; cout << "The sample " << sample << " has unweighted " << numberOfEntries << " entries" << endl; myfile << sample << " " << norm_const << "\n"; //write to file myfile << sample << " " << numberOfEntries << "\n"; myfile.close(); }
void e6_rootMacro1vTree(const char *inputFile) { gSystem->Load("libDelphes"); // Create chain of root trees // TChain chain("Delphes"); // chain.Add(inputFile); TChain *chain = new TChain("Delphes"); // adopted from Example3.C of Delphes chain->Add(inputFile); // Create object of class ExRootTreeReader //ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); ExRootTreeReader *treeReader = new ExRootTreeReader(chain); // adopted from Example3.C of Delphes Long64_t numberOfEntries = treeReader->GetEntries(); string histoFile_str = "e6_rootMacro1vTree.root"; // TFile constructor accepts type "const char*" const char* histoFile_char = histoFile_str.c_str(); // overwrite existing ".root" file TFile f(histoFile_char, "recreate"); // number of particles in an event Long64_t numParticles = -1; Long64_t numElectrons = -1; Long64_t numMuons = -1; Long64_t numJets = -1; Double_t maxPT = -1; Double_t max2ndPT = 0; // 2nd highest PT Double_t currentPT = 0; // initially currentPT>maxPT so that first particle in the loop will have max. PT Double_t currentMass = 0; // Get pointers to branches used in this analysis TClonesArray *branchParticle = treeReader->UseBranch("Particle"); TClonesArray *branchElectron = treeReader->UseBranch("Electron"); TClonesArray *branchMuon = treeReader->UseBranch("Muon"); TClonesArray *branchJet = treeReader->UseBranch("Jet"); // Book histograms //////////// I will use a tree to study electron with maximum PT. TTree t_electron_with_max_PT("electron_with_max_PT", "ein Baum über Elektronen mit höchsten PT"); int electron_id = 11; Double_t ch_e, mass_e, E_e, px_e, py_e, pz_e, pt_e, eta_e, phi_e, rapidity_e, stat_e, pid_e; t_electron_with_max_PT.Branch("electron.charge", &ch_e, "ch_e/D"); // t_electron_with_max_PT.Branch("electron.mass", &mass_e, "mass_e/D"); // t_electron_with_max_PT.Branch("electron.energy", &E_e, "E_e/D"); // t_electron_with_max_PT.Branch("electron.Px", &px_e, "px_e/D"); // t_electron_with_max_PT.Branch("electron.Py", &py_e, "py_e/D"); // t_electron_with_max_PT.Branch("electron.Pz", &pz_e, "pz_e/D"); t_electron_with_max_PT.Branch("electron.PT", &pt_e, "pt_e/D"); t_electron_with_max_PT.Branch("electron.Eta", &eta_e, "eta_e/D"); t_electron_with_max_PT.Branch("electron.Phi", &phi_e, "phi_e/D"); // t_electron_with_max_PT.Branch("electron.Rapidity", &rapidity_e, "rapidity_e/D"); // t_electron_with_max_PT.Branch("electron.status", &stat_e, "stat_e/D"); // t_electron_with_max_PT.Branch("electron.PID", &pid_e, "pid_e/D"); //////////// I will use a tree to study muon with maximum PT. TTree t_muon_with_max_PT("muon_with_max_PT", "ein Baum über Muonen mit höchsten PT"); int muon_id = 13; Double_t ch_muon, mass_muon, E_muon, px_muon, py_muon, pz_muon, pt_muon, eta_muon, phi_muon, rapidity_muon, stat_muon, pid_muon; t_muon_with_max_PT.Branch("muon.charge", &ch_muon, "ch_muon/D"); // t_muon_with_max_PT.Branch("muon.mass", &mass_muon, "mass_muon/D"); // t_muon_with_max_PT.Branch("muon.energy", &E_muon, "E_muon/D"); // t_muon_with_max_PT.Branch("muon.Px", &px_muon, "px_muon/D"); // t_muon_with_max_PT.Branch("muon.Py", &py_muon, "py_muon/D"); // t_muon_with_max_PT.Branch("muon.Pz", &pz_muon, "pz_muon/D"); t_muon_with_max_PT.Branch("muon.PT", &pt_muon, "pt_muon/D"); t_muon_with_max_PT.Branch("muon.Eta", &eta_muon, "eta_muon/D"); t_muon_with_max_PT.Branch("muon.Phi", &phi_muon, "phi_muon/D"); // t_muon_with_max_PT.Branch("muon.Rapidity", &rapidity_muon, "rapidity_muon/D"); // t_muon_with_max_PT.Branch("muon.status", &stat_muon, "stat_muon/D"); // t_muon_with_max_PT.Branch("muon.PID", &pid_muon, "pid_muon/D"); //////////// I will use a tree to study jet with maximum PT. TTree t_jet_with_max_PT("jet_with_max_PT", "ein Baum über jets mit höchsten PT"); Double_t ch_jet, mass_jet, E_jet, px_jet, py_jet, pz_jet, pt_jet, eta_jet, phi_jet, rapidity_jet, stat_jet, pid_jet; t_jet_with_max_PT.Branch("jet.charge", &ch_jet, "ch_jet/D"); t_jet_with_max_PT.Branch("jet.mass", &mass_jet, "mass_jet/D"); // t_jet_with_max_PT.Branch("jet.energy", &E_jet, "E_jet/D"); // t_jet_with_max_PT.Branch("jet.Px", &px_jet, "px_jet/D"); // t_jet_with_max_PT.Branch("jet.Py", &py_jet, "py_jet/D"); // t_jet_with_max_PT.Branch("jet.Pz", &pz_jet, "pz_jet/D"); t_jet_with_max_PT.Branch("jet.PT", &pt_jet, "pt_jet/D"); t_jet_with_max_PT.Branch("jet.Eta", &eta_jet, "eta_jet/D"); t_jet_with_max_PT.Branch("jet.Phi", &phi_jet, "phi_jet/D"); // t_jet_with_max_PT.Branch("jet.Rapidity", &rapidity_jet, "rapidity_jet/D"); // t_jet_with_max_PT.Branch("jet.status", &stat_jet, "stat_jet/D"); // t_jet_with_max_PT.Branch("jet.PID", &pid_jet, "pid_jet/D"); //////////// I will use a tree to study jet with 2nd maximum PT. TTree t_jet_with_2ndmax_PT("jet_with_2ndmax_PT", "ein Baum über jets mit zweiten höchsten PT"); Double_t ch_jet2nd, mass_jet2nd, E_jet2nd, px_jet2nd, py_jet2nd, pz_jet2nd, pt_jet2nd, eta_jet2nd, phi_jet2nd, rapidity_jet2nd, stat_jet2nd, pid_jet2nd; t_jet_with_2ndmax_PT.Branch("jet.charge", &ch_jet2nd, "ch_jet2nd/D"); t_jet_with_2ndmax_PT.Branch("jet.mass", &mass_jet2nd, "mass_jet2nd/D"); // t_jet_with_2ndmax_PT.Branch("jet.energy", &E_jet2nd, "E_jet2nd/D"); // t_jet_with_2ndmax_PT.Branch("jet.Px", &px_jet2nd, "px_jet2nd/D"); // t_jet_with_2ndmax_PT.Branch("jet.Py", &py_jet2nd, "py_jet2nd/D"); // t_jet_with_2ndmax_PT.Branch("jet.Pz", &pz_jet2nd, "pz_jet2nd/D"); t_jet_with_2ndmax_PT.Branch("jet.PT", &pt_jet, "pt_jet/D"); t_jet_with_2ndmax_PT.Branch("jet.Eta", &eta_jet2nd, "eta_jet2nd/D"); t_jet_with_2ndmax_PT.Branch("jet.Phi", &phi_jet2nd, "phi_jet2nd/D"); // t_jet_with_2ndmax_PT.Branch("jet.Rapidity", &rapidity_jet2nd, "rapidity_jet2nd/D"); // t_jet_with_2ndmax_PT.Branch("jet.status", &stat_jet, "stat_jet/D"); // t_jet_with_2ndmax_PT.Branch("jet.PID", &pid_jet2nd, "pid_jet2nd/D"); // 1) e+e- ve mu+mu- invariant mass histogramlarini ekleyelim, Z bozonunu gorelim. // 1) e+e- ve mu+mu- invariant mass histogramlarini ekleyelim, Double_t histMassElectron_upper = 0.001; Double_t histMassMuon_upper = 0.2; TH1 *histMass_electron = new TH1F("Mass_electron", "mass of electron (e+e-)", 100, 0.0, histMassElectron_upper); TH1 *histMass_muon = new TH1F("Mass_muon", "mass of muon (mu+mu-)", 100, 0.0, histMassMuon_upper); // Z bozonunu gorelim. // I will use a tree to study Z boson. TTree t_Zboson("Z", "ein Baum über Z Boson"); int Zboson_id = 23; Double_t ch_Z, mass_Z, E_Z, px_Z, py_Z, pz_Z, pt_Z, eta_Z, phi_Z, rapidity_Z, stat_Z, pid_Z; t_Zboson.Branch("Z.charge", &ch_Z, "ch_Z/D"); t_Zboson.Branch("Z.mass", &mass_Z, "mass_Z/D"); t_Zboson.Branch("Z.energy", &E_Z, "E_Z/D"); t_Zboson.Branch("Z.Px", &px_Z, "px_Z/D"); t_Zboson.Branch("Z.Py", &py_Z, "py_Z/D"); t_Zboson.Branch("Z.Pz", &pz_Z, "pz_Z/D"); t_Zboson.Branch("Z.PT", &pt_Z, "pt_Z/D"); t_Zboson.Branch("Z.Eta", &eta_Z, "eta_Z/D"); t_Zboson.Branch("Z.Phi", &phi_Z, "phi_Z/D"); t_Zboson.Branch("Z.Rapidity", &rapidity_Z, "rapidity_Z/D"); t_Zboson.Branch("Z.status", &stat_Z, "stat_Z/D"); t_Zboson.Branch("Z.PID", &pid_Z, "pid_Z/D"); // 2) Z bozonu ile olaydaki en yuksek pt'li jeti birlestirip invariant mass histogramina bakalim. TTree t_Other("Other", "ein Baum über die anderen Sachen"); Double_t mass_Jet_AND_Z; Double_t massJet_with_maxPT = -1; // isim aralarında "boşluk, +, (, ), ]" vs. gibi karakterler kabul edilmiyor ==> totalMass_of_Z_AND_Jet_with_max_PT t_Other.Branch("totalMass_of_Z_AND_Jet_with_max_PT", &mass_Jet_AND_Z, "mass_Jet_AND_Z/D"); GenParticle *particle; Electron *electron; Muon *muon; Jet *jet; Bool_t isParticleFoundInThatEvent = false; Int_t tmp = 0; // Loop over all events for (Int_t entry = 0; entry < numberOfEntries; ++entry) { // Load selected branches with data from specified event treeReader->ReadEntry(entry); numParticles = branchParticle->GetEntries(); numElectrons = branchElectron->GetEntries(); numMuons = branchMuon->GetEntries(); numJets = branchJet->GetEntries(); maxPT = -1; currentPT = 0; isParticleFoundInThatEvent=false; // loop over electrons in the event for (int i = 0; i < numElectrons; i++) { isParticleFoundInThatEvent = true; electron = (Electron *) branchElectron->At(i); particle = (GenParticle*) electron->Particle.GetObject(); currentMass = particle->Mass; histMass_electron->Fill(currentMass); currentPT = electron->PT; // electron with maximum PT. if (maxPT < currentPT) { maxPT = currentPT; ch_e = electron->Charge; pt_e = electron->PT; eta_e = electron->Eta; phi_e = electron->Phi; } } if (isParticleFoundInThatEvent) { t_electron_with_max_PT.Fill(); } maxPT = -1; currentPT = 0; isParticleFoundInThatEvent = false; // loop over muons in the event for (int i = 0; i < numMuons; i++) { isParticleFoundInThatEvent = true; muon = (Muon *) branchMuon->At(i); particle = (GenParticle*) muon->Particle.GetObject(); currentMass = particle->Mass; histMass_muon->Fill(currentMass); currentPT = muon->PT; // muon with maximum PT. if (maxPT < currentPT) { maxPT = currentPT; ch_muon = muon->Charge; pt_muon = muon->PT; eta_muon = muon->Eta; phi_muon = muon->Phi; } } if (isParticleFoundInThatEvent) { t_muon_with_max_PT.Fill(); } maxPT = -1; max2ndPT = 0; currentPT = 0; isParticleFoundInThatEvent = false; // loop over jets in the event for (int i = 0; i < numJets; i++) { isParticleFoundInThatEvent = true; jet = (Jet *) branchJet->At(i); currentPT = jet->PT; currentMass = jet->Mass; if (maxPT < currentPT) { max2ndPT = maxPT; // the current maximum becomes the new 2nd maximum. ch_jet2nd = ch_jet; pt_jet2nd = pt_jet; eta_jet2nd = eta_jet; phi_jet2nd = phi_jet; mass_jet2nd = mass_jet; maxPT = currentPT; massJet_with_maxPT = currentMass; ch_jet = jet->Charge; pt_jet = jet->PT; eta_jet = jet->Eta; phi_jet = jet->Phi; mass_jet = jet->Mass; } else if (max2ndPT < currentPT) { max2ndPT = currentPT; ch_jet2nd = jet->Charge; pt_jet2nd = jet->PT; eta_jet2nd = jet->Eta; phi_jet2nd = jet->Phi; mass_jet2nd = jet->Mass; } } if (isParticleFoundInThatEvent) { t_jet_with_max_PT.Fill(); t_jet_with_2ndmax_PT.Fill(); } // loop over all particles in the event for (int i = 0; i < numParticles; i++) { particle = (GenParticle*) branchParticle->At(i); tmp = particle->PID; // Z bozonunu gorelim. if (abs(tmp) == Zboson_id) { ch_Z = particle->Charge; mass_Z = particle->Mass; E_Z = particle->E; px_Z = particle->Px; py_Z = particle->Py; pz_Z = particle->Pz; pt_Z = particle->PT; eta_Z = particle->Eta; phi_Z = particle->Phi; rapidity_Z = particle->Rapidity; stat_Z = particle->Status; pid_Z = particle->PID; t_Zboson.Fill(); // 2) Z bozonu ile olaydaki en yuksek pt'li jeti birlestirip invariant mass histogramina bakalim. mass_Jet_AND_Z = massJet_with_maxPT + mass_Z; t_Other.Fill(); } } //cout << numJets << endl; } /* // Show resulting histograms histMaxPT_electron->Draw(); histMaxPT_muon->Draw(); histMaxPT_jet->Draw(); hist2ndMaxPT_jet->Draw(); */ f.Write(); delete treeReader; delete chain; }
void fillHistogram(TH1F * hist, std::string filename, float xs){ hist->Sumw2(); //see https://answers.launchpad.net/mg5amcnlo/+question/200336 int n_events_nonzero_met = 0; // Load shared library gSystem->Load("lib/libExRootAnalysis.so"); gSystem->Load("libPhysics"); // Create chain of root trees TChain chain("LHCO"); //chain.Add("/scratch3/anlevin/MG5_aMC_v2_0_0/ww_qed_4_qcd_99_pythia_matching/Events/run_01/tag_1_pgs_events.root"); chain.Add(filename.c_str()); // Create object of class ExRootTreeReader ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t numberOfEntries = treeReader->GetEntries(); // Get pointers to branches used in this analysis TClonesArray *branchJet = treeReader->UseBranch("Jet"); TClonesArray *branchElectron = treeReader->UseBranch("Electron"); TClonesArray *branchMuon = treeReader->UseBranch("Muon"); TClonesArray *branchMET = treeReader->UseBranch("MissingET"); // Loop over all events for(Int_t entry = 0; entry < numberOfEntries; ++entry) { // Load selected branches with data from specified event treeReader->ReadEntry(entry); if (branchMET->GetEntries() == 0) continue; else assert (branchMET->GetEntries() == 1); n_events_nonzero_met++; // If event contains at least 1 jet if(branchJet->GetEntries() <= 2) continue; TRootJet *jet1 = 0; TRootJet *jet2 = 0; for (int i = 0; i < branchJet->GetEntries(); i++){ TRootJet *jet = (TRootJet*) branchJet->At(i); if (jet1 == 0) jet1 = jet; else if (jet2 == 0 ) jet2 = jet; else if (jet->PT > jet1->PT) jet1 = jet; else if (jet->PT > jet2->PT) jet2 = jet; } if (!jet1 || !jet2 ) continue; if (jet1->PT < 30) continue; if (jet2->PT < 30) continue; TLorentzVector vec1, vec2; bool found1 = false; bool found2 = false; int charge1 = 0; int charge2 = 0; for (int i = 0; i < branchMuon->GetEntries(); i++){ TRootMuon * muon = (TRootMuon*) branchJet->At(i); TLorentzVector vec; vec.SetPtEtaPhiM(muon->PT, muon->Eta, muon->Phi, muon_mass); if (!found1){ found1 = true; vec1 = vec; charge1=muon->Charge; } else if (!found2){ found2 = true; vec2 = vec; charge2=muon->Charge; } else if (vec.Pt() > vec1.Pt()) { vec1 = vec; charge1=muon->Charge; } else if (vec.Pt() > vec2.Pt()) { vec2 = vec; charge2=muon->Charge; } } for (int i = 0; i < branchElectron->GetEntries(); i++){ TRootElectron *electron = (TRootElectron*) branchElectron->At(i); TLorentzVector vec; vec.SetPtEtaPhiM(electron->PT, electron->Eta, electron->Phi, electron_mass); if (!found1){ found1 = true; vec1 = vec; charge1=electron->Charge; } else if (!found2){ found2 = true; vec2 = vec; charge2=electron->Charge; } else if (vec.Pt() > vec1.Pt()) { vec1 = vec; charge1=electron->Charge; } else if (vec.Pt() > vec2.Pt()) { vec2 = vec; charge2=electron->Charge; } } if (!found1 || !found2) continue; if (vec1.Pt() < 20) continue; if (vec2.Pt() < 20) continue; if (charge1 * charge2 < 0) continue; TLorentzVector vec1_jet, vec2_jet; vec1_jet.SetPtEtaPhiM(jet1->PT, jet1->Eta, jet1->Phi, jet1->Mass); vec2_jet.SetPtEtaPhiM(jet2->PT, jet2->Eta, jet2->Phi, jet2->Mass); if (abs(jet1->Eta - jet2->Eta) < 2.5) continue; if((vec1_jet + vec2_jet).M() < 500) continue; TRootMissingET * met =(TRootMissingET *) branchMET->At(0); if (met->MET < 30) continue; hist->Fill( (vec1_jet + vec2_jet).M()); } std::cout << "n_events_nonzero_met = " << n_events_nonzero_met << std::endl; hist->Scale(xs * luminosity/ n_events_nonzero_met); }
int main(int argc, char *argv[]) { char appName[] = "root2pileup"; stringstream message; TChain *inputChain = 0; ExRootTreeReader *treeReader = 0; TClonesArray *branchParticle = 0; TIterator *itParticle = 0; GenParticle *particle = 0; DelphesPileUpWriter *writer = 0; Long64_t entry, allEntries; Int_t i; if(argc < 3) { cout << " Usage: " << appName << " output_file" << " input_file(s)" << endl; cout << " output_file - output binary pile-up file," << endl; cout << " input_file(s) - input file(s) in ROOT format." << endl; return 1; } signal(SIGINT, SignalHandler); gROOT->SetBatch(); int appargc = 1; char *appargv[] = {appName}; TApplication app(appName, &appargc, appargv); try { inputChain = new TChain("Delphes"); for(i = 2; i < argc && !interrupted; ++i) { inputChain->Add(argv[i]); } treeReader = new ExRootTreeReader(inputChain); branchParticle = treeReader->UseBranch("Particle"); itParticle = branchParticle->MakeIterator(); writer = new DelphesPileUpWriter(argv[1]); allEntries = treeReader->GetEntries(); cout << "** Input file(s) contain(s) " << allEntries << " events" << endl; if(allEntries > 0) { ExRootProgressBar progressBar(allEntries - 1); // Loop over all events in the input file for(entry = 0; entry < allEntries && !interrupted; ++entry) { if(!treeReader->ReadEntry(entry)) { cerr << "** ERROR: cannot read event " << entry << endl; break; } itParticle->Reset(); while((particle = static_cast<GenParticle*>(itParticle->Next()))) { writer->WriteParticle(particle->PID, particle->X, particle->Y, particle->Z, particle->T, particle->Px, particle->Py, particle->Pz, particle->E); } writer->WriteEntry(); progressBar.Update(entry); } progressBar.Finish(); writer->WriteIndex(); } cout << "** Exiting..." << endl; delete writer; delete itParticle; delete treeReader; delete inputChain; return 0; } catch(runtime_error &e) { if(writer) delete writer; if(itParticle) delete itParticle; if(treeReader) delete treeReader; if(inputChain) delete inputChain; cerr << "** ERROR: " << e.what() << endl; return 1; } }
int main (int argc, char *argv[]) { if (argc != 3) { cout << "Usage: " << argv[0] << " INPUT_FILE OUTPUT_FILE" << endl; cout << " or: " << argv[0] << " INPUT_LIST OUTPUT_FILE" << endl; cout << "Run vertexing performance analysis on INPUT_FILE and store output to OUTPUT_FILE. If the" << endl; cout << "first argument is a text file, analysis is run on each file listed inside." << endl; cout << endl; return 0; } string inputFile = argv[1], outputFile = argv[2], upperInputFile; upperInputFile.resize (inputFile.length ()); transform (inputFile.begin (), inputFile.end (), upperInputFile.begin (), ::toupper); // so canvases don't appear on the screen when being created // very useful when running on the OSU T3 from CERN gROOT->SetBatch(); //Create chain of root trees TChain chain("Delphes"); if (upperInputFile.length () < 5 || upperInputFile.substr (upperInputFile.length () - 5, 5) != ".ROOT") { ifstream fin (inputFile); string line; while(getline(fin, line)) { chain.Add(line.c_str()); } fin.close(); } else chain.Add(inputFile.c_str()); // Create object of class ExRootTreeReader ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t numberOfEntries = treeReader->GetEntries(); cout << "processing " << numberOfEntries << " events..." << endl << endl; // Get pointers to branches used in this analysis TClonesArray *branchTrack = treeReader->UseBranch("Track"); TClonesArray *branchNPU = treeReader->UseBranch("NPU"); TClonesArray *branchCluster = treeReader->UseBranch("Cluster"); TClonesArray *branchVBFquarks = treeReader->UseBranch("VBFquarks"); /////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// // Book histograms /////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// TH1::SetDefaultSumw2(); // VBF Quark Histograms TH1D *hVBFQuarkEta = new TH1D("VBFQuarkEta", ";VBF quark #eta", 1000, -5.0, 5.0); TH1D *hVBFQuarkPt = new TH1D("VBFQuarkPt", ";VBF quark p_{T} [GeV]", 1000, 0.0, 1000.0); TH2D *hVBFQuarkEtaVsPhi = new TH2D("VBFQuarkPt", ";VBF quark #phi;VBF quark #eta", 500, -3.5, 3.5, 500, -5.0, 5.0); // Track Histograms TH1D *hTrackPt = new TH1D("TrackPt", "; Track p_{T} [GeV]", 400, 0.0, 200.0); TH1D *hVBFTrackPt = new TH1D("VBFTrackPt", ";VBF track p_{T} [GeV]", 400, 0.0, 200.0); TH1D *hPUTrackPt = new TH1D("PUTrackPt", ";PU track p_{T} [GeV]", 400, 0.0, 200.0); TH1D *hTrackX = new TH1D("TrackX", "; Track x [mm]", 300, -3, 3); TH1D *hTrackY = new TH1D("TrackY", "; Track y [mm]", 300, -3, 3); TH1D *hTrackZ = new TH1D("TrackZ", "; Track z [mm]", 300, -300, 300); TH1D *hTrackEX = new TH1D("TrackEX", "; Track #sigma_{x} [mm]", 100, 0, 1); TH1D *hTrackEY = new TH1D("TrackEY", "; Track #sigma_{y} [mm]", 100, 0, 1); TH1D *hTrackEZ = new TH1D("TrackEZ", "; Track #sigma_{z} [mm]", 100, 0, 20); TH1D *hTrackXSmearingShift = new TH1D("TrackXSmearingShift", "; Track x_{smeared} - x_{true} [mm]", 100, -2, 2); TH1D *hTrackYSmearingShift = new TH1D("TrackYSmearingShift", "; Track y_{smeared} - y_{true} [mm]", 100, -2, 2); TH1D *hTrackZSmearingShift = new TH1D("TrackZSmearingShift", "; Track z_{smeared} - z_{true} [mm]", 100, -50, 50); TH1D *hTrackDisplacementClusterX = new TH1D("TrackDisplacementClusterX", "; |Track x - Cluster x| [mm]", 100, 0, 10); TH1D *hTrackDisplacementClusterY = new TH1D("TrackDisplacementClusterY", "; |Track y - Cluster y| [mm]", 100, 0, 10); TH1D *hTrackDisplacementClusterZ = new TH1D("TrackDisplacementClusterZ", "; |Track z - Cluster z| [mm]", 100, 0, 300); TH1D *hTrackDisplacementInteractionX = new TH1D("TrackDisplacementInteractionX", "; |Track x - Interaction x| [mm]", 100, 0, 10); TH1D *hTrackDisplacementInteractionY = new TH1D("TrackDisplacementInteractionY", "; |Track y - Interaction y| [mm]", 100, 0, 10); TH1D *hTrackDisplacementInteractionZ = new TH1D("TrackDisplacementInteractionZ", "; |Track z - Interaction z| [mm]", 100, 0, 50); // Cluster Histograms TH1D *hClusterX = new TH1D("ClusterX", "; Cluster x [mm]", 300, -3, 3); TH1D *hClusterEX = new TH1D("ClusterEX", "; Cluster #sigmax [mm]", 100, 0, 0.1); TH1D *hClusterY = new TH1D("ClusterY", "; Cluster y [mm]", 300, -3, 3); TH1D *hClusterEY = new TH1D("ClusterEY", "; Cluster #sigmay [mm]", 100, 0, 0.1); TH1D *hClusterZ = new TH1D("ClusterZ", "; Cluster z [mm]", 300, -300, 300); TH1D *hClusterEZ = new TH1D("ClusterEZ", "; Cluster #sigmaz [mm]", 100, 0, 0.1); TH2D *hClusterTransversePosition = new TH2D("ClusterTransversePosition", "; Cluster x [mm]; Cluster y [mm]", 300, -3,3, 300, -3, 3); TH2D *hClusterRZPosition = new TH2D("ClusterRZPosition", "; Cluster z [mm]; Cluster r [mm]", 100, -300, 300, 100, 0, 1.5); // Reco PV Histograms TH1D *hRecoPVX = new TH1D("RecoPVX", "; Reco PV x [mm]", 300, -3, 3); TH1D *hRecoPVY = new TH1D("RecoPVY", "; Reco PV y [mm]", 300, -3, 3); TH1D *hRecoPVZ = new TH1D("RecoPVZ", "; Reco PV z [mm]", 300, -300, 300); TH1D *hRecoPVTrackPurity = new TH1D("RecoPVTrackPurity", "; Fraction of Reco PV tracks from primary interaction", 101, 0, 1.01); TH1D *hRecoPVMomentumPurity = new TH1D("RecoPVMomentumPurity", "; Fraction of Reco PV momentum from primary interaction", 101, 0, 1.01); TH2D *hRecoPVTransversePosition = new TH2D("RecoPVTransversePosition", "; Reco PV x [mm]; Reco PV y [mm]", 300, -3, 3, 300, -3, 3); TH2D *hRecoPVRZPosition = new TH2D("RecoPVRZPosition", "; RecoPV z [mm]; RecoPV r [mm]", 100, -300, 300, 100, 0, 1.5); // Gen PV Histograms TH1D *hGenPVX = new TH1D("GenPVX", "; Gen PV x [mm]", 300, -3, 3); TH1D *hGenPVY = new TH1D("GenPVY", "; Gen PV y [mm]", 300, -3, 3); TH1D *hGenPVZ = new TH1D("GenPVZ", "; Gen PV z [mm]", 300, -300, 300); TH2D *hGenPVTransversePosition = new TH2D("GenPVTransversePosition", "; Gen PV x [mm]; Gen PV y [mm]", 300, -3, 3, 300, -3, 3); TH2D *hGenPVRZPosition = new TH2D("GenPVRZPosition", "; Gen PV z [mm]; Gen PV r [mm]", 100, -300, 300, 100, 0, 1.5); // PV Comparison Histograms TH1D *hPVdisplacementZ = new TH1D("PVdisplacementZ", "; z_{gen PV} - z_{reco PV} [mm]", 200, -10, 10); TH1D *hAbsPVdisplacementZ = new TH1D("AbsPVdisplacementZ", ";|z_{gen PV} - z_{reco PV}| [mm]", 200, 0, 10); TH2D *hZRecoPVVsZGenPV = new TH2D("ZRecoPVVsZGenPV", "; z_{gen PV} [mm]; z_{reco PV} [mm]", 1000, -150, 150, 1000, -150, 150); TH2D *hNumTracksRecoPVVsNumTracksGenPV = new TH2D("NumTracksRecoPVVsNumTracksGenPV", ";number of tracks in Gen PV;number of tracks in Reco PV", 300, 0, 300, 300, 0, 300); TH2D *hPtRecoPVVsPtGenPV = new TH2D("PtRecoPVVsPtGenPV", ";#Sigma p_{T} of tracks in Gen PV;#Sigma p_{T} of tracks in Reco PV", 200, 0, 600, 200, 0, 600); // Size Histograms TH1D *hNumTracksPerEvent = new TH1D("NumTracksPerEvent", "; Num. of Tracks Per Event", 100, 0.0, 10000); TH1D *hNumTracksPerCluster = new TH1D("NumTracksPerCluster", "; Num. of Tracks Per Cluster", 100, 0.0, 500.0); TH1D *hNumClustersPerEvent = new TH1D("NumClustersPerEvent", "; Num. of Clusters Per Event", 100, 0.0, 100.0 ); TH1D *hNumInteractionsPerEvent = new TH1D("NumInteractionsPerEvent", "; Num. of Interactions Per Event", 201, 0.0, 201.0 ); TH2D *hNumClustersVsNumInteractions = new TH2D("NumClustersVsNumInteractions", ";number of interactions;number of clusters", 200, 0.0, 200.0, 200, 0.0, 200.0); TH2D *hPVDisplacementVsNumInteractions = new TH2D("PVDisplacementVsNInteractions", ";|z_{gen PV} - z_{reco PV}| [mm];number of interactions", 1000, 0, 10, 201, 0.0, 201.0); // Other Histograms TH1D *hClusteredTrackFraction = new TH1D("ClusteredTrackFraction", "; Fraction of tracks successfully clustered", 101, 0, 1.01); TH1D *hClusteredMomentumFraction = new TH1D("ClusteredMomentumFraction", "; Fraction of track p_{T} successfully clustered", 101, 0, 1.01); TH2D *hCorrectPrimaryVertex = new TH2D("CorrectPrimaryVertex", "; Number of Pileup Vertices; True/False Correct PV", 200, 0, 200, 2, 0, 1); /////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// // Begin loop over all events /////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// signal (SIGINT, signalHandler); for (Int_t entry = 0; entry < numberOfEntries && !interrupted; ++entry) { // Load selected branches with data from specified event if(!(entry % REPORT_EVERY)) cout << "processing event " << (entry + 1) << "..." << endl; treeReader->ReadEntry(entry); // N.B. this is a hack put in by Andrew using the ScalarHT class // it's the number of pileup interactions, it's not actually the HT unsigned nInteractions = (unsigned) ((ScalarHT *) branchNPU->At(0))->HT + 1; unsigned nClusters = branchCluster->GetEntries(); hNumInteractionsPerEvent->Fill(nInteractions); hNumClustersPerEvent->Fill(nClusters); hNumClustersVsNumInteractions->Fill(nInteractions,nClusters); hNumTracksPerEvent->Fill(branchTrack->GetEntries()); // the cluster branch is sorted by sum pt**2, so first entry is the reconstructed primary vertex Cluster *recoPV = (Cluster *) branchCluster->At(0); double genPVX = 0; double genPVY = 0; double genPVZ = 0; int nUnclusteredTracks = 0; int nClusteredTracks = 0; double unclusteredMomentum = 0; double clusteredMomentum = 0; int nTracksInGenPV = 0; int nTracksInRecoPV = 0; double momentumInGenPV = 0; double momentumInRecoPV = 0; double recoPVtrackPurity = 0; double recoPVmomentumPurity = 0; map<int, double> clusterXPositionMap; // < cluster index , weighted average X position > map<int, double> clusterYPositionMap; // < cluster index , weighted average Y position > map<int, double> clusterZPositionMap; // < cluster index , weighted average Z position > map<int, double> interactionXPositionMap; // < interaction index , weighted average X position > map<int, double> interactionXWeightMap; // < interaction index , sum of weights > map<int, double> interactionYPositionMap; // < interaction index , weighted average Y position > map<int, double> interactionYWeightMap; // < interaction index , sum of weights > map<int, double> interactionZPositionMap; // < interaction index , weighted average Z position > map<int, double> interactionZWeightMap; // < interaction index , sum of weights > for (int iVBFquark = 0; iVBFquark < branchVBFquarks->GetEntries (); iVBFquark++) { GenParticle *vbfQuark = (GenParticle *) branchVBFquarks->At (iVBFquark); hVBFQuarkEta->Fill (vbfQuark->Eta); hVBFQuarkPt->Fill (vbfQuark->PT); hVBFQuarkEtaVsPhi->Fill (vbfQuark->Phi, vbfQuark->Eta); } /////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// // Begin loop over all clusters in the event /////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// for(int iCluster = 0; iCluster < branchCluster->GetEntries(); iCluster++) { Cluster *cluster = (Cluster *) branchCluster->At(iCluster); hNumTracksPerCluster->Fill(cluster->NDF); clusterXPositionMap[cluster->Index] = cluster->X; clusterYPositionMap[cluster->Index] = cluster->Y; clusterZPositionMap[cluster->Index] = cluster->Z; //fill corresponding histograms hClusterX->Fill(cluster->X); hClusterEX->Fill(cluster->ErrorX); hClusterY->Fill(cluster->Y); hClusterEY->Fill(cluster->ErrorY); hClusterZ->Fill(cluster->Z); hClusterEZ->Fill(cluster->ErrorZ); hClusterTransversePosition->Fill(cluster->X,cluster->Y); double clusterRadius = sqrt(cluster->X * cluster->X + cluster->Y * cluster->Y); hClusterRZPosition->Fill(cluster->Z,clusterRadius); } /////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// // Begin loop over all tracks in the event /////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// for(int iTrack = 0; iTrack < branchTrack->GetEntries(); iTrack++){ Track *track = (Track *) branchTrack->At(iTrack); if (abs (track->PID) != 13) // N.B.: this will only work for H->4mu { if (track->IsPU) hPUTrackPt->Fill (track->PT); else hVBFTrackPt->Fill (track->PT); } hTrackPt->Fill(track->PT); hTrackX->Fill(track->X); hTrackY->Fill(track->Y); hTrackZ->Fill(track->Z); // hTrackEX->Fill(track->ErrorX); FIXME // hTrackEY->Fill(track->ErrorY); FIXME // hTrackEZ->Fill(track->ErrorZ); FIXME // hTrackXSmearingShift->Fill(track->X-track->TrueX); FIXME // hTrackYSmearingShift->Fill(track->Y-track->TrueY); FIXME // hTrackZSmearingShift->Fill(track->Z-track->TrueZ); FIXME // calculate amount of tracks/pt that was clustered if(track->ClusterIndex >= 0){ //this means it was clustered nClusteredTracks++; clusteredMomentum += track->PT; } else{ nUnclusteredTracks++; unclusteredMomentum += track->PT; } // calculate and store useful information about the generated and reconstructed primary vertices if (track->IsPU==0){ // it's a track from the GEN PV // genPVX += track->TrueX; FIXME // genPVY += track->TrueY; FIXME // genPVZ += track->TrueZ; FIXME nTracksInGenPV++; momentumInGenPV += track->PT; } if (track->ClusterIndex==recoPV->Index){ // comes from the RECO primary vertex nTracksInRecoPV++; momentumInRecoPV += track->PT; if (track->IsPU==0){ // also comes from the GEN primary vertex recoPVtrackPurity++; recoPVmomentumPurity += track->PT; } } // store the positions of each generated interaction if (!interactionXPositionMap.count (track->IsPU)) { interactionXPositionMap[track->IsPU] = 0.0; interactionXWeightMap[track->IsPU] = 0.0; } // interactionXPositionMap[track->IsPU] += track->TrueX; FIXME interactionXWeightMap[track->IsPU] += 1.0; if (!interactionYPositionMap.count (track->IsPU)) { interactionYPositionMap[track->IsPU] = 0.0; interactionYWeightMap[track->IsPU] = 0.0; } // interactionYPositionMap[track->IsPU] += track->TrueY; FIXME interactionYWeightMap[track->IsPU] += 1.0; if (!interactionZPositionMap.count (track->IsPU)) { interactionZPositionMap[track->IsPU] = 0.0; interactionZWeightMap[track->IsPU] = 0.0; } // interactionZPositionMap[track->IsPU] += track->TrueZ; FIXME interactionZWeightMap[track->IsPU] += 1.0; } // end loop over all tracks for(map<int, double>::const_iterator interaction = interactionXPositionMap.begin (); interaction != interactionXPositionMap.end (); interaction++) { interactionXPositionMap.at(interaction->first) /= interactionXWeightMap.at(interaction->first); interactionYPositionMap.at(interaction->first) /= interactionYWeightMap.at(interaction->first); interactionZPositionMap.at(interaction->first) /= interactionZWeightMap.at(interaction->first); } if(recoPVtrackPurity == 0) { hCorrectPrimaryVertex->Fill(nInteractions, 0); } if(recoPVtrackPurity > 0 && recoPVtrackPurity <=1) { hCorrectPrimaryVertex->Fill(nInteractions, 1); } genPVX /= nTracksInGenPV; genPVY /= nTracksInGenPV; genPVZ /= nTracksInGenPV; recoPVtrackPurity /= nTracksInRecoPV; recoPVmomentumPurity /= momentumInRecoPV; hRecoPVTrackPurity->Fill(recoPVtrackPurity); hRecoPVMomentumPurity->Fill(recoPVmomentumPurity); hNumTracksRecoPVVsNumTracksGenPV->Fill(nTracksInGenPV,recoPV->NDF); hPtRecoPVVsPtGenPV->Fill(momentumInGenPV,momentumInRecoPV); hClusteredTrackFraction->Fill(float(nClusteredTracks)/(nClusteredTracks+nUnclusteredTracks)); hClusteredMomentumFraction->Fill(clusteredMomentum/(clusteredMomentum+unclusteredMomentum)); hRecoPVX->Fill(recoPV->X); hRecoPVY->Fill(recoPV->Y); hRecoPVZ->Fill(recoPV->Z); hRecoPVTransversePosition->Fill(recoPV->X,recoPV->Y); hGenPVX->Fill(genPVX); hGenPVY->Fill(genPVY); hGenPVZ->Fill(genPVZ); hGenPVTransversePosition->Fill(genPVX,genPVY); double pvRadius = sqrt(recoPV->X * recoPV->X + recoPV->Y * recoPV->Y); double genPVRadius = sqrt(genPVX * genPVX + genPVY * genPVY); hRecoPVRZPosition->Fill(recoPV->Z,pvRadius); hGenPVRZPosition->Fill(genPVZ,genPVRadius); hPVdisplacementZ->Fill(genPVZ - recoPV->Z); hAbsPVdisplacementZ->Fill(fabs(genPVZ - recoPV->Z)); hZRecoPVVsZGenPV->Fill(genPVZ, recoPV->Z); hPVDisplacementVsNumInteractions->Fill(fabs(genPVZ - recoPV->Z), nInteractions); //re-loop over all the tracks and fill the special histograms for(int iTrack = 0; iTrack < branchTrack->GetEntries(); iTrack++) { Track *track = (Track *) branchTrack->At(iTrack); if (track->ClusterIndex >=0){//only include clustered tracks hTrackDisplacementClusterX->Fill(fabs(track->X - clusterXPositionMap.at(track->ClusterIndex))); hTrackDisplacementClusterY->Fill(fabs(track->Y - clusterYPositionMap.at(track->ClusterIndex))); hTrackDisplacementClusterZ->Fill(fabs(track->Z - clusterZPositionMap.at(track->ClusterIndex))); } hTrackDisplacementInteractionX->Fill(fabs(track->X - interactionXPositionMap.at(track->IsPU))); hTrackDisplacementInteractionY->Fill(fabs(track->Y - interactionYPositionMap.at(track->IsPU))); hTrackDisplacementInteractionZ->Fill(fabs(track->Z - interactionZPositionMap.at(track->IsPU))); } } // end loop over events // Save resulting histograms TFile *fout = TFile::Open(outputFile.c_str(), "recreate"); fout->cd(); TDirectory *vbfQuarkFolder = fout->mkdir("VBF Quark Histograms"); vbfQuarkFolder->cd(); // VBF Quark Histograms hVBFQuarkEta->Write (); hVBFQuarkPt->Write (); hVBFQuarkEtaVsPhi->Write (); fout->cd(); TDirectory *trackFolder = fout->mkdir("Track Histograms"); trackFolder->cd(); // Track Histograms hTrackPt->Write(); hVBFTrackPt->Write(); hPUTrackPt->Write(); hTrackX->Write(); hTrackY->Write(); hTrackZ->Write(); hTrackEX->Write(); hTrackEY->Write(); hTrackEZ->Write(); hTrackXSmearingShift->Write(); hTrackYSmearingShift->Write(); hTrackZSmearingShift->Write(); hTrackDisplacementClusterX->Write(); hTrackDisplacementClusterY->Write(); hTrackDisplacementClusterZ->Write(); hTrackDisplacementInteractionX->Write(); hTrackDisplacementInteractionY->Write(); hTrackDisplacementInteractionZ->Write(); fout->cd(); TDirectory *clusterFolder = fout->mkdir("Cluster Histograms"); clusterFolder->cd(); // Cluster Histograms hClusterX->Write(); hClusterEX->Write(); hClusterY->Write(); hClusterEY->Write(); hClusterZ->Write(); hClusterEZ->Write(); hNumTracksPerCluster->Write(); hClusterTransversePosition->Write(); hClusterRZPosition->Write(); fout->cd(); TDirectory *eventFolder = fout->mkdir("Event Histograms"); eventFolder->cd(); // Reco PV Histograms hRecoPVX->Write(); hRecoPVY->Write(); hRecoPVZ->Write(); hRecoPVTrackPurity->Write(); hRecoPVMomentumPurity->Write(); // Gen PV Histograms hGenPVX->Write(); hGenPVY->Write(); hGenPVZ->Write(); // Size Histograms hNumTracksPerEvent->Write(); hNumClustersPerEvent->Write(); hNumInteractionsPerEvent->Write(); // 2D Histograms hNumClustersVsNumInteractions->Write(); hRecoPVTransversePosition->Write(); hGenPVTransversePosition->Write(); hRecoPVRZPosition->Write(); hGenPVRZPosition->Write(); hPVDisplacementVsNumInteractions->Write(); hCorrectPrimaryVertex->Write(); // Gen/Reco PV Comparison Histograms hNumTracksRecoPVVsNumTracksGenPV->Write(); hPtRecoPVVsPtGenPV->Write(); hPVdisplacementZ->Write(); hAbsPVdisplacementZ->Write(); hZRecoPVVsZGenPV->Write(); // Other Histograms hClusteredTrackFraction->Write(); hClusteredMomentumFraction->Write(); fout->Close(); }
void delphes(const char *inputFile, const char* outputFileName) { gSystem->Load("libDelphes"); TChain *chain = new TChain("Delphes"); chain->Add(inputFile); ExRootTreeReader *treeReader = new ExRootTreeReader(chain); ExRootResult *result = new ExRootResult(); TH1* hNJet = result->AddHist1D("hNJets", "Jet multiplicity", "Multiplicity", "Events", 20, 0., 20.); TH1* hNLeptons = result->AddHist1D("hNLeptons", "Lepton multiplicity", "Multiplicity", "Events", 20, 0., 20.); TH1* hJetPt = result->AddHist1D("hJetPt", "Jet pT", "Transverse momentum p_{T} (GeV/c)", "Entries per 10GeV/c", 50, 0., 500.); TH1* hNBjets = result->AddHist1D("hNBjets", "B Jet multiplicity", "B jet multiplicity", "Events", 20, 0., 20.); TH1* hBjetPt = result->AddHist1D("hBjetPt", "B jet pT", "Transverse momentum p_{T} (GeV/c)", "Entries per 10GeV/c", 50, 0., 500.); TH1* hST = result->AddHist1D("hST", "ST", "Scalar sum S_{T} (GeV/c)", "Events per 500GeV/c", 40, 0., 20000.); // Analyze TClonesArray *branchJet = treeReader->UseBranch("Jet"); TClonesArray *branchElectron = treeReader->UseBranch("Electron"); TClonesArray *branchMuon = treeReader->UseBranch("Muon"); TClonesArray *branchMissingET = treeReader->UseBranch("MissingET"); int nEventsTotal = 0, nEvents4J = 0, nEvents2B = 0, nEvents3B = 0, nEvents4B = 0; int nEvents4J2B = 0, nEvents6J2B = 0, nEvents6J3B = 0; // Loop over all events for(Long64_t entry = 0, allEntries = treeReader->GetEntries(); entry < allEntries; ++entry) { double sT = 0; int nLeptons = 0, nJets = 0, nBjets = 0; treeReader->ReadEntry(entry); for ( int i=0, n=branchMuon->GetEntriesFast(); i<n; ++i ) { const Muon* muon = (Muon*)branchMuon->At(i); const double muonPt = muon->PT; if ( muonPt < 50 || fabs(muon->Eta) > 2.5 ) continue; sT += muonPt; nLeptons += 1; } for ( int i=0, n=branchElectron->GetEntriesFast(); i<n; ++i ) { const Electron* electron = (Electron*)branchElectron->At(i); const double electronPt = electron->PT; if ( electronPt < 50 || fabs(electron->Eta) > 2.5 ) continue; sT += electronPt; nLeptons += 1; } for ( int i=0, n=branchJet->GetEntriesFast(); i<n; ++i ) { const Jet* jet = (Jet*)branchJet->At(i); const double jetPt = jet->PT; if ( jetPt < 50 ) continue; if ( fabs(jet->Eta) > 2.5 ) continue; ++nJets; hJetPt->Fill(jetPt); sT += jetPt; if ( !jet->BTag ) continue; ++nBjets; hBjetPt->Fill(jetPt); } hNLeptons->Fill(nLeptons); hNJets->Fill(nJets); hNBjets->Fill(nBjets); // Analyse missing ET if( branchMissingET->GetEntriesFast() > 0 ) { const MissingET* met = (MissingET*)branchMissingET->At(0); sT += met->MET; } hST->Fill(sT); ++nEventsTotal; if ( nJets >= 4 ) ++nEvents4J; if ( nBjets >= 2 ) ++nEvents2B; if ( nBjets >= 3 ) ++nEvents3B; if ( nBjets >= 4 ) ++nEvents4B; if ( nJets >= 4 && nBjets >= 2 ) ++nEvents4J2B; if ( nJets >= 6 && nBjets >= 2 ) ++nEvents6J2B; if ( nJets >= 6 && nBjets >= 3 ) ++nEvents6J3B; } cout << inputFile << endl; cout << "nJet4 " << 1.*nEvents4J/nEventsTotal << endl; cout << "nBjet2 " << 1.*nEvents2B/nEventsTotal << endl; cout << "nBjet3 " << 1.*nEvents3B/nEventsTotal << endl; cout << "nBjet4 " << 1.*nEvents4B/nEventsTotal << endl; cout << "nJet4 nBjet2 " << 1.*nEvents4J2B/nEventsTotal << endl; cout << "nJet6 nBjet2 " << 1.*nEvents6J2B/nEventsTotal << endl; cout << "nJet6 nBjet3 " << 1.*nEvents6J3B/nEventsTotal << endl; //result->Print("png"); result->Write(outputFileName); delete result; delete treeReader; delete chain; }
void Example1(const char *inputFile) { gSystem->Load("libDelphes"); // Create chain of root trees TChain chain("Delphes"); chain.Add(inputFile); // Create object of class ExRootTreeReader ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t numberOfEntries = treeReader->GetEntries(); // Get pointers to branches used in this analysis TClonesArray *branchJet = treeReader->UseBranch("Jet"); TClonesArray *branchElectron = treeReader->UseBranch("Electron"); TClonesArray *branchEvent = treeReader->UseBranch("Event"); // Book histograms TH1 *histJetPT = new TH1F("jet_pt", "jet P_{T}", 100, 0.0, 100.0); TH1 *histMass = new TH1F("mass", "M_{inv}(e_{1}, e_{2})", 100, 40.0, 140.0); // Loop over all events for(Int_t entry = 0; entry < numberOfEntries; ++entry) { // Load selected branches with data from specified event treeReader->ReadEntry(entry); //HepMCEvent *event = (HepMCEvent*) branchEvent -> At(0); //LHEFEvent *event = (LHEFEvent*) branchEvent -> At(0); //Float_t weight = event->Weight; // If event contains at least 1 jet if(branchJet->GetEntries() > 0) { // Take first jet Jet *jet = (Jet*) branchJet->At(0); // Plot jet transverse momentum histJetPT->Fill(jet->PT); // Print jet transverse momentum cout << "Jet pt: "<<jet->PT << endl; } Electron *elec1, *elec2; // If event contains at least 2 electrons if(branchElectron->GetEntries() > 1) { // Take first two electrons elec1 = (Electron *) branchElectron->At(0); elec2 = (Electron *) branchElectron->At(1); // Plot their invariant mass histMass->Fill(((elec1->P4()) + (elec2->P4())).M()); } } // Show resulting histograms histJetPT->Draw(); histMass->Draw(); }
int main (int argc, char *argv[]) { if (argc != 2) { cout << "Usage: " << argv[0] << " INPUT_FILE" << endl; cout << " or: " << argv[0] << " INPUT_LIST" << endl; cout << "" << endl; cout << endl; return 0; } string inputFile = argv[1], upperInputFile; upperInputFile.resize (inputFile.length ()); transform (inputFile.begin (), inputFile.end (), upperInputFile.begin (), ::toupper); // so canvases don't appear on the screen when being created // very useful when running on the OSU T3 from CERN gROOT->SetBatch(); gStyle->SetPadTopMargin(0.1); gStyle->SetPadBottomMargin(0.1); gStyle->SetPadLeftMargin(0.03); gStyle->SetPadRightMargin(0.08); //Create chain of root trees TChain chain("Delphes"); if (upperInputFile.length () < 5 || upperInputFile.substr (upperInputFile.length () - 5, 5) != ".ROOT") { ifstream fin (inputFile); string line; while(getline(fin, line)) { chain.Add(line.c_str()); } fin.close(); } else chain.Add(inputFile.c_str()); // Create object of class ExRootTreeReader ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); // Get pointers to branches used in this analysis TClonesArray *branchTrack = treeReader->UseBranch("Track"); TClonesArray *branchCluster = treeReader->UseBranch("Cluster"); TClonesArray *branchNPU = treeReader->UseBranch("NPU"); //gStyle->SetOptStat(10011); //actually, let's turn this off for now gStyle->SetOptStat(0); TH2D *hist[LEN]; signal (SIGINT, signalHandler); //Loop over a LEN Events for (int event = 0; event < LEN && !interrupted; event++) { //Load Branches treeReader->ReadEntry(event); // N.B. this is a hack put in by Andrew using the ScalarHT class // it's the number of pileup interactions, it's not actually the HT unsigned nInteractions = (unsigned) ((ScalarHT *) branchNPU->At(0))->HT + 1; int nClusters = branchCluster->GetEntries(); // create and format the histogram for this event TString name = "TrackPtVsTrackZ_" + TString(Form("%d",event+1)); TCanvas *can = new TCanvas(name,name,1600,500); TString title = "Event " + TString(Form("%d",event+1)) + ": "; title += TString(Form("%d",nInteractions)) + " Interactions, "; title += TString(Form("%d",nClusters)) + " Clusters"; hist[event] = new TH2D(name, title, X_BIN, X_MIN, X_MAX, Y_BIN, Y_MIN, Y_MAX); hist[event]->GetXaxis()->SetTitle("track z [mm]"); hist[event]->GetXaxis()->SetLabelOffset(0.02); hist[event]->GetXaxis()->SetTitleOffset(1.2); hist[event]->GetYaxis()->SetTitle("track p_{T} [GeV]"); hist[event]->GetYaxis()->SetTitleOffset(0.35); TArrow *genPVArrow = new TArrow(0,0,0,0.01,0.01,"|>"); genPVArrow->SetLineColor(3); genPVArrow->SetFillColor(3); genPVArrow->SetLineWidth(0.1); genPVArrow->SetAngle(40); vector<float> interactionPositions; vector<TLine *> clusterLineVector; Cluster *recoPV = (Cluster *) branchCluster->At(0); TLine *highELine = new TLine(recoPV->Z,0,recoPV->Z,Y_MAX); highELine->SetLineColor(1); highELine->SetLineWidth(0.8); highELine->SetLineStyle(3); // Draw cluster lines // Skip first cluster since we've already drawn it (start from 1) for(int iCluster = 1; iCluster < branchCluster->GetEntries(); iCluster++) { Cluster *cluster = (Cluster *) branchCluster->At(iCluster); TLine *clusterLine = new TLine(cluster->Z,0,cluster->Z,Y_MAX); clusterLine->SetLineWidth(0.5); clusterLineVector.push_back(clusterLine); } for(int iTrack = 0; iTrack < branchTrack->GetEntries(); iTrack++) { Track *track = (Track *) branchTrack->At(iTrack); if (track->PT < Y_MAX) hist[event]->Fill(track->Z, track->PT); else hist[event]->Fill(track->Z, Y_MAX-0.01); // if entry would be off the y-scale, draw it in the last bin if(track->IsPU==0) { // track comes from primary interaction // genPVArrow->SetX1(track->TrueZ); FIXME // genPVArrow->SetX2(track->TrueZ); FIXME } // else if (find(interactionPositions.begin(), interactionPositions.end(), track->TrueZ) == interactionPositions.end()){ FIXME // interactionPositions.push_back(track->TrueZ); FIXME // } FIXME } //create arrows for all the generated pileup interactions vector<TArrow *> interactionArrowVector; for(uint iInteraction = 0; iInteraction < interactionPositions.size() ; iInteraction++) { TArrow *interactionArrow = new TArrow(interactionPositions.at(iInteraction),0,interactionPositions.at(iInteraction),0.01,0.01,"|>"); interactionArrow->SetLineWidth(0.1); interactionArrow->SetAngle(20); interactionArrow->SetLineColor(2); interactionArrow->SetFillColor(2); interactionArrowVector.push_back(interactionArrow); } //Draw and save images hist[event]->Draw("contz"); for(uint iCluster = 0; iCluster < clusterLineVector.size(); iCluster++) { clusterLineVector.at(iCluster)->Draw(); } for(uint iInteraction = 0; iInteraction < interactionArrowVector.size(); iInteraction++) { interactionArrowVector.at(iInteraction)->Draw(); } highELine->Draw(); genPVArrow->Draw(); TLegend *leg = new TLegend(0.07,0.6,0.25,0.89); leg->SetBorderSize(0); leg->SetFillColor(0); leg->SetFillStyle(0); leg->AddEntry(genPVArrow, "Primary Gen. Interaction", ""); if (interactionArrowVector.size() > 0) leg->AddEntry(interactionArrowVector.at(0), "Pileup Interactions", ""); leg->AddEntry(highELine, "Highest #Sigmap_{T}^{2} Cluster", "l"); if (clusterLineVector.size() > 0) leg->AddEntry(clusterLineVector.at(0), "Other Clusters", "l"); leg->Draw(); //hack to get the triangles to draw in the legend double x_left = X_MIN + (X_MAX-X_MIN)/13; double x_right = X_MIN + (X_MAX-X_MIN)/13; if (interactionArrowVector.size() > 0){ TArrow *interactionArrowLabel = new TArrow(x_left,Y_MAX*0.86,x_right,Y_MAX*0.86,0.02,"|>"); interactionArrowLabel->SetLineWidth(1); interactionArrowLabel->SetAngle(20); interactionArrowLabel->SetLineColor(2); interactionArrowLabel->SetFillColor(2); interactionArrowLabel->Draw(); } TArrow *genPVArrowLabel = new TArrow(x_left,Y_MAX*0.94,x_right,Y_MAX*0.94,0.02,"|>"); genPVArrowLabel->SetLineWidth(1); genPVArrowLabel->SetAngle(40); genPVArrowLabel->SetLineColor(3); genPVArrowLabel->SetFillColor(3); genPVArrowLabel->Draw(); can->SaveAs("output/" + name + ".pdf"); //can->Write(); } }
void GeneralExample(const char *inputFile, const char *outputFile) { // gSystem->Load("libDelphes"); // Create chain of root trees TChain chain("Delphes"); chain.Add(inputFile); // Create object of class ExRootTreeReader ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t numberOfEntries = treeReader->GetEntries(); // Get pointers to branches used in this analysis TClonesArray *branchGenJet = treeReader->UseBranch("GenJet"); TClonesArray *branchJet = treeReader->UseBranch("Jet"); TClonesArray *branchRho = treeReader->UseBranch("Rho"); TClonesArray *branchGlobalRho = treeReader->UseBranch("GlobalRho"); TClonesArray *branchNPU = treeReader->UseBranch("NPU"); TClonesArray *branchElectron = treeReader->UseBranch("Electron"); TClonesArray *branchMuon = treeReader->UseBranch("Muon"); TClonesArray *branchPhoton = treeReader->UseBranch("Photon"); // Constituents will be 0 otherwise TClonesArray *branchEFlowTrack = treeReader->UseBranch("EFlowTrack"); TClonesArray *branchEFlowTower = treeReader->UseBranch("EFlowTower"); TClonesArray *branchEFlowMuon = treeReader->UseBranch("EFlowMuon"); TClonesArray *branchGenParticle = treeReader->UseBranch("Particle"); TClonesArray *branchBeamSpotParticle = treeReader->UseBranch("BeamSpotParticle"); TClonesArray *branchMissingET = treeReader->UseBranch("MissingET"); TClonesArray *branchGenMissingET = treeReader->UseBranch("GenMissingET"); TClonesArray *branchPileUpJetIDMissingET = treeReader->UseBranch("PileUpJetIDMissingET"); TClonesArray *branchPuppiMissingET = treeReader->UseBranch("PuppiMissingET"); bool verbose = true; bool listJetTowers = false; bool listMET = true; bool listRho = false; bool treeMET = true; TFile *f; TTree *t; // TH1F *hdmet, hdpujidmet, hdpuppimet; // TH1F *hfdmet, hfdpujidmet, hfdpuppimet; // TH2F *h2met, h2pujidmet, h2puppimet; float genmet, met, puppimet, pujidmet; float genmetx, metx, puppimetx, pujidmetx; float genmety, mety, puppimety, pujidmety; if (treeMET) { f = new TFile(outputFile,"RECREATE"); t = new TTree("t","t"); t->Branch("genmet",&genmet,"genmet/F"); t->Branch("met",&met,"met/F"); t->Branch("pujidmet",&pujidmet,"pujidmet/F"); t->Branch("puppimet",&puppimet,"puppimet/F"); t->Branch("genmetx",&genmetx,"genmetx/F"); t->Branch("metx",&metx,"metx/F"); t->Branch("pujidmetx",&pujidmetx,"pujidmetx/F"); t->Branch("puppimetx",&puppimetx,"puppimetx/F"); t->Branch("genmety",&genmety,"genmety/F"); t->Branch("mety",&mety,"mety/F"); t->Branch("pujidmety",&pujidmety,"pujidmety/F"); t->Branch("puppimety",&puppimety,"puppimety/F"); } // Loop over all events for(Int_t entry = 0; entry < numberOfEntries; ++entry) { // Load selected branches with data from specified event treeReader->ReadEntry(entry); if (listMET||verbose||entry%5000==0) cout << "Event " << entry << " / " << numberOfEntries << endl; for (int i = 0 ; i < branchGenMissingET->GetEntries() ; i++) { MissingET *m = (MissingET*) branchGenMissingET->At(i); if (verbose || listMET) cout << "Gen MissingET: " << m->MET << endl; genmet = m->MET; genmetx = m->MET*cos(m->Phi); genmety = m->MET*sin(m->Phi); } for (int i = 0 ; i < branchMissingET->GetEntries() ; i++) { MissingET *m = (MissingET*) branchMissingET->At(i); if (verbose || listMET) cout << "MissingET: " << m->MET << endl; met = m->MET; metx = m->MET*cos(m->Phi); mety = m->MET*sin(m->Phi); } for (int i = 0 ; i < branchPileUpJetIDMissingET->GetEntries() ; i++) { MissingET *m = (MissingET*) branchPileUpJetIDMissingET->At(i); if (verbose || listMET) cout << "MissingET using PileUpJetID: " << m->MET << endl; pujidmet = m->MET; pujidmetx = m->MET*cos(m->Phi); pujidmety = m->MET*sin(m->Phi); } for (int i = 0 ; i < branchPuppiMissingET->GetEntries() ; i++) { MissingET *m = (MissingET*) branchPuppiMissingET->At(i); if (verbose || listMET) cout << "Puppi MissingET: " << m->MET << endl; puppimet = m->MET; puppimetx = m->MET*cos(m->Phi); puppimety = m->MET*sin(m->Phi); } if (treeMET) t->Fill(); for (int i = 0 ; i < branchRho->GetEntries() ; i++) { Rho *rho = (Rho*) branchRho->At(i); if (verbose || listRho) cout << " Rho (" << rho->Edges[0] << "-" << rho->Edges[1] << "): " << rho->Rho << endl; } for (int i = 0 ; i < branchGlobalRho->GetEntries() ; i++) { Rho *rho = (Rho*) branchGlobalRho->At(i); if (verbose || listRho) cout << " GlobalRho (" << rho->Edges[0] << "-" << rho->Edges[1] << "): " << rho->Rho << endl; } // cout << "before scalarHT" << endl; // I have cheated and recorded the true number of pileup vertices in a "ScalarHT" object! ScalarHT *NPU = (ScalarHT*) branchNPU->At(0); int nPUvertices_true = (int)NPU->HT; if (verbose) cout << " Number of true pileup vertices: " << nPUvertices_true << endl; // One particle from primary vertex if (verbose && branchBeamSpotParticle) { cout << branchBeamSpotParticle->GetEntries() << endl; GenParticle *part = (GenParticle*) branchBeamSpotParticle->At(0); cout << " True primary vertex X Y Z T: " << part->X << " " << part->Y << " " << part->Z << " " << part->T << endl; } // Status code 3 (+high pt leptons, b+t quarks, etc) particle collection if (verbose && branchGenParticle) { for (int i = 0 ; i < branchGenParticle->GetEntries() ; i++ ) { GenParticle *part = (GenParticle*) branchGenParticle->At(i); cout << " Status code" << part->Status << " generator particle PID Pt Eta Phi Z T (at origin) " << part->PID << " " << part->PT << " " << part->Eta << " " << part->Phi << " " << part->Z << " " << part->T << endl; } } if (verbose) { for (int i = 0 ; i < branchElectron->GetEntries() ; i++) { Electron *ele = (Electron*) branchElectron->At(i); cout << " Electron " << i << ": PT Eta Phi Isolation " << ele->PT << " " << ele->Eta << " " << ele->Phi << " " << ele->IsolationVar << endl; GenParticle *part = (GenParticle*) ele->Particle.GetObject(); if (part) { cout << " Electron matches to generated particle with Status code" << part->Status << " generator particle PID Pt Eta Phi Z T (at origin) " << part->PID << " " << part->PT << " " << part->Eta << " " << part->Phi << " " << part->Z << " " << part->T << endl; } else { cout << " Electron does not match to a generated particle" << endl; } } for (int i = 0 ; i < branchPhoton->GetEntries() ; i++) { Photon *pho = (Photon*) branchPhoton->At(i); cout << " Photon " << i << ": PT Eta Phi Isolation T " << pho->PT << " " << pho->Eta << " " << pho->Phi << " " << pho->IsolationVar << " " << pho->TOuter << endl; } for (int i = 0 ; i < branchMuon->GetEntries() ; i++) { Muon *mu = (Muon*) branchMuon->At(i); cout << " Muon " << i << ": PT Eta Phi Isolation " << mu->PT << " " << mu->Eta << " " << mu->Phi << " " << mu->IsolationVar << endl; } for (int i = 0 ; i < branchGenJet->GetEntries() ; i++) { Jet *jet = (Jet*) branchGenJet->At(i); if (jet->PT > 30.) { cout << " Gen Jet " << i << endl; cout << " pT: " << jet->PT << endl; cout << " Eta: " << jet->Eta << endl; cout << " Phi: " << jet->Phi << endl; /* cout << " Area: " << jet->AreaP4().Pt() << endl; cout << " Constituents: " << jet->Constituents.GetEntries() << endl; if (branchGenParticleWithPU) { // now same colection for (int j = 0 ; j < jet->Constituents.GetEntries() ; j++) { TObject *obj = jet->Constituents[j]; if (obj && obj->IsA() == GenParticle::Class()) { GenParticle *part = static_cast<GenParticle *> ( obj ) ; cout << " Jet constituent Pt Eta Phi Z T (at origin) " << part->PT << " " << part->Eta << " " << part->Phi << " " << part->Z << " " << part->T << endl; } else { cout << " Jet constituent is not a particle (?)" << endl; } } } */ } } // Loop over jets for (int i = 0 ; i < branchJet->GetEntries() ; i++) { Jet *jet = (Jet*) branchJet->At(i); if (jet->PT > 30.) { cout << " Jet " << i << endl; cout << " pT: " << jet->PT << endl; cout << " Eta: " << jet->Eta << endl; cout << " BTag: " << bool(jet->BTag&1) << " | " << bool(jet->BTag&2) << endl; cout << " TauTag: " << jet->TauTag << endl; // cout << " Area: " << jet->AreaP4().Pt() << endl; cout << " Jet Pileup ID" << endl; cout << " Beta*: " << jet->BetaStar << endl; cout << " Fractional pT in annuli (<0.1, 0.1-0.2, ..., 0.4-0.5) " << jet->FracPt[0] << " " << jet->FracPt[1] << " " << jet->FracPt[2] << " " << jet->FracPt[3] << " " << jet->FracPt[4] << endl; cout << " <dR^2>: " << jet->MeanSqDeltaR << endl; cout << " NNeutrals: " << jet->NNeutrals << endl; cout << " NCharged: " << jet->NCharged << endl; cout << " Number of constituents: " << jet->Constituents.GetEntries() << endl; if (listJetTowers && branchEFlowTrack && branchEFlowTower && branchEFlowMuon) { for (int j = 0 ; j < jet->Constituents.GetEntries() ; j++) { TObject *obj = jet->Constituents[j]; if (obj && obj->IsA() == Tower::Class()) { Tower *tow = static_cast<Tower *> ( obj ) ; cout << " Jet constituent Et Eta Phi Time (at calo) " << tow->ET << " " << tow->Eta << " " << tow->Phi << " " << tow->TOuter << endl; } else { // cout << " not a tower - could check if it's a track instead (cf. Example3.C)" << endl; } } } } } } // verbose } // event if (treeMET) { f->cd(); t->Write(); f->Close(); } }
int delphes2csv(const char* input) { gSystem->Load("libDelphes"); TChain* chain = new TChain("Delphes"); chain->Add(input); ExRootTreeReader *treeReader = new ExRootTreeReader(chain); int64_t nentries = treeReader->GetEntries(); // Branches in the Delphes output TClonesArray *b_DEvent = treeReader->UseBranch("Event"); TClonesArray *b_DParticle = treeReader->UseBranch("Particle"); //TClonesArray *b_DTrack = treeReader->UseBranch("Track"); //TClonesArray *b_DTower = treeReader->UseBranch("Tower"); //TClonesArray *b_DEFlowTrack = treeReader->UseBranch("EFlowTrack"); //TClonesArray *b_DEFlowPhotoon = treeReader->UseBranch("EFlowPhoton"); //TClonesArray *b_DEFlowNeutralHadron = treeReader->UseBranch("EFlowNeutralHadron"); //TClonesArray *b_DGenJet = treeReader->UseBranch("GenJet"); //TClonesArray *b_DGenMissingET = treeReader->UseBranch("GenMissingET"); TClonesArray *b_DJet = treeReader->UseBranch("Jet"); //TClonesArray *b_DElectron = treeReader->UseBranch("Electron"); //TClonesArray *b_DPhoton = treeReader->UseBranch("Photon"); //TClonesArray *b_DMuon = treeReader->UseBranch("Muon"); TClonesArray *b_DMissingET = treeReader->UseBranch("MissingET"); //TClonesArray *b_DScalarHT = treeReader->UseBranch("ScalarHT"); std::stringstream ss; ss << input << ".test.csv"; FILE* stream = fopen(ss.str().c_str(), "w"); fprintf(stream, "# eventNumber,"); fprintf(stream, "pt(mc h+),eta(mc h+),phi(mc h+),e(mc h+),"); fprintf(stream, "pt(mc tau),eta(mc tau),phi(mc tau),e(mc tau),"); fprintf(stream, "pt(mc nuH),eta(mc nuH),phi(mc nuH),e(mc nuH),"); fprintf(stream, "pt(mc nuTau),eta(mc nuTau),phi(mc nuTau),e(mc nuTau),"); fprintf(stream, "et(met),phi(met),"); fprintf(stream, "ntau,"); fprintf(stream, "nbjet,"); fprintf(stream, "njet,"); GenParticle* hplus = 0; GenParticle* nuH = 0; GenParticle* Tau = 0; GenParticle* nuTau = 0; int maxjet = 4; int maxbjet = 4; int maxtau = 1; int njet = 0; int nbjet = 0; int ntau = 0; for (int i = 0; i < maxtau; ++i) fprintf(stream, "pt(reco tau%i),eta(reco tau%i),phi(reco tau%i),m(reco tau%i),", i+1, i+1, i+1, i+1); for (int i = 0; i < maxbjet; ++i) fprintf(stream, "pt(reco bjet%i),eta(reco bjet%i),phi(reco bjet%i),m(reco bjet%i),", i+1, i+1, i+1, i+1); for (int i = 0; i < maxjet; ++i) fprintf(stream, "pt(reco jet%i),eta(reco jet%i),phi(reco jet%i),m(reco jet%i),", i+1, i+1, i+1, i+1); fprintf(stream, "\n"); std::vector<Jet*> jets; std::vector<Jet*> bjets; std::vector<Jet*> taus; // Begin event loop for (int64_t ientry = 0; ientry < nentries; ++ientry) { if (ientry%1000 == 0) std::cout << "--- " << ientry << " / " << nentries << std::endl; treeReader->ReadEntry(ientry); HepMCEvent* event = (HepMCEvent*)b_DEvent->At(0); GenParticle* hplus = getChargedHiggs(b_DParticle); GenParticle* nuH = getChargedHiggsNeutrino(hplus, b_DParticle); GenParticle* Tau = getChargedHiggsTau(hplus, b_DParticle); Tau = getFinalState(Tau, b_DParticle); GenParticle* nuTau = getChargedHiggsTauNeutrino(Tau, b_DParticle); if (hplus && nuH && Tau && nuTau) { jets.clear(); bjets.clear(); taus.clear(); njet = 0; nbjet = 0; ntau = 0; for (int ijet = 0; ijet < b_DJet->GetEntries(); ++ijet) { Jet* jet = (Jet*)b_DJet->At(ijet); if (jet->BTag) { bjets.push_back(jet); if (nbjet < maxbjet) ++nbjet; } else if (jet->TauTag) { taus.push_back(jet); if (ntau < maxtau) ++ntau; } else { jets.push_back(jet); if (njet < maxjet) ++njet; } } if (ntau < 1) continue; if (nbjet < 1) continue; if (njet < 2) continue; std::sort(bjets.begin(), bjets.end(), [](Jet* j1, Jet* j2){return j1->PT > j2->PT;}); std::sort(jets.begin(), jets.end(), [](Jet* j1, Jet* j2){return j1->PT > j2->PT;}); std::sort(taus.begin(), taus.end(), [](Jet* j1, Jet* j2){return j1->PT > j2->PT;}); // Fill in truth information about the H+->tau nu decay fprintf(stream, "%lli,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,", event->Number, hplus->PT, hplus->Eta, hplus->Phi, hplus->E, Tau->PT, Tau->Eta, Tau->Phi, Tau->E, nuH->PT, nuH->Eta, nuH->Phi, nuH->E, nuTau->PT, nuTau->Eta, nuTau->Phi, nuTau->E); // Reco ETMiss information MissingET* met = (MissingET*)b_DMissingET->At(0); fprintf(stream, "%f,%f,", met->MET, met->Phi); // Multiplicities fprintf(stream, "%i,", ntau); fprintf(stream, "%i,", nbjet); fprintf(stream, "%i,", njet); // Reco Taus int itau = 0; for (; itau < ntau; ++itau) fprintf(stream, "%f,%f,%f,%f,", taus[itau]->PT, taus[itau]->Eta, taus[itau]->Phi, taus[itau]->Mass); for (int jtau = itau; jtau < maxtau; ++jtau) fprintf(stream, "%f,%f,%f,%f,", -999., -999., -999., -999.); // Reco bjets int ibjet = 0; for (; ibjet < nbjet; ++ibjet) fprintf(stream, "%f,%f,%f,%f,", bjets[ibjet]->PT, bjets[ibjet]->Eta, bjets[ibjet]->Phi, bjets[ibjet]->Mass); for (int jbjet = ibjet; jbjet < maxbjet; ++jbjet) fprintf(stream, "%f,%f,%f,%f,", -999., -999., -999., -999.); // Reco jets int ijet = 0; for (; ijet < njet; ++ijet) fprintf(stream, "%f,%f,%f,%f,", jets[ijet]->PT, jets[ijet]->Eta, jets[ijet]->Phi, jets[ijet]->Mass); for (int jjet = ijet; jjet < maxjet; ++jjet) fprintf(stream, "%f,%f,%f,%f,", -999., -999., -999., -999.); fprintf(stream, "\n"); } } // End event loop fclose(stream); return 0; }