///::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ///:::::::::::::::::::::::::::::::::: FAST MATRIX ELEMENT TO VBF TOPOLOGY :::::::::::::::::::::::::::::::::: ///:::::::::::::::::::::::::::::::::: Code Author: Miquéias M. de Almeida :::::::::::::::::::::::::::::::::: ///::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ///:: :: ///:: This tool takes Data, MC Signal and Background tridimensional matrix containing leptons pT, eta and phi, and :: ///:: compute the Data-MC event distance in a phase space defined by those leptons properties. In the 4e and 4mu final :: ///:: state there's two choices, so the tool has two ways to make the comparison between the Data-MC leptons (minimum :: ///:: distance between leptons and the media of the possible combinations). The tool use two branches to identify those :: ///:: special final states, one for indicate the final state and one for indicate what particle is being handle. :: ///:: The final states must be identify in the following way: 0 = 4e, 1 = 4mu and 2 = 2e2mu :: ///:: :: ///:: To run the analysis make in Root (compilation mode is the fastest): :: ///:: root -l -b -q FastME.C+ :: ///::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ///To print informations about DR functions running #define debug false #include #include #include #include #include #include #include #include #include #include #include ///Headers to TProcPool #include #include #include #include #include #define pi 3.14159265358979312 #define pedestal -99 ///Reset Value to Variables ///Scale Factors to normalize Deltas #define scale_dPt 50. #define scale_dEta 5. #define scale_dPhi pi ///Final state #define nObjs 6 using namespace std; ///========== Compute Distance Between Events - Minimum Distance Method =============== ///Takes the combination that gives minimum distance when >1 equals final states Double_t ComputeDR_MinDist(TTreeReaderArray DataId, TTreeReaderArray DataPt, TTreeReaderArray DataPtRes, TTreeReaderArray DataEta, TTreeReaderArray DataEtaRes, TTreeReaderArray McId, TTreeReaderArray McPt, TTreeReaderArray McPtRes, TTreeReaderArray McEta, TTreeReaderArray McEtaRes){ Double_t particles_distance, min_particles_distance; Double_t dPt=0, dEta=0; Double_t sum_dPt2=0, sum_dEta2=0, event_distance=-1; int min_imc, vmin_imc[6] = {-1,-1,-1,-1,-1,-1}; for(int idt=0; idt>> "; dPt = (DataPt[idt]-McPt[imc])/(scale_dPt*DataPtRes[idt]); dEta = (DataEta[idt]-McEta[imc])/(scale_dEta*DataEtaRes[idt]); particles_distance = sqrt(dPt*dPt + dEta*dEta); if( debug ) cout<<"particles_distance = "<> MCPos: "< MCs; std::string Data_Path("../VBF_Samples/VBF_QED4_QCD0_BKG_FastME_1.root"); MCs.push_back("../VBF_Samples/VBF_QED4_QCD0_SIG_FastME_2.root"); MCs.push_back("../VBF_Samples/VBF_QED4_QCD0_BKG_FastME_2.root"); ///------------------------------------------------------------------------------------ ///TProcPool declarations auto workItem = [Data_Path](TTreeReader &tread) -> TObject* { TH1D *h = new TH1D("Distances", "Distances between Data and MC events", 200, 0, 100); h->SetDirectory(0); TTreeReaderArray DataId(tread, "Particle.id"); TTreeReaderArray DataPt(tread, "Particle.pt"); TTreeReaderArray DataPtRes(tread, "Particle.pt_res"); TTreeReaderArray DataEta(tread, "Particle.eta"); TTreeReaderArray DataEtaRes(tread, "Particle.eta_res"); TFile *fData = TFile::Open((TString)Data_Path); TTreeReader refReader("VBF",fData); TTreeReaderArray McId(refReader, "Particle.id"); TTreeReaderArray McPt(refReader, "Particle.pt"); TTreeReaderArray McPtRes(refReader, "Particle.pt_res"); TTreeReaderArray McEta(refReader, "Particle.eta"); TTreeReaderArray McEtaRes(refReader, "Particle.eta_res"); while(tread.Next()){ while(refReader.Next()){ //refReader.SetEntriesRange(0,10); Double_t dr_test = -1.; dr_test = ComputeDR_MinDist(DataId, DataPt, DataPtRes, DataEta, DataEtaRes, McId, McPt, McPtRes, McEta, McEtaRes); h->Fill(dr_test); } } delete fData; return h; }; ///For timming the process time_t start, stop, delaied; double seconds, elapsed_time; string unity = "s"; time(&start); ///-------------------------- ///The process TProcPool workers(ncores); auto hf = workers.ProcTree(MCs, workItem); hf->Print(); hf->DrawClone(); /* ///Getting the discriminant value based on event distance if(min_dr_sig == 0 && min_dr_bkg == 0){ min_dr_sig = 1.; min_dr_bkg = 1.; } psb_distance = PsbD(min_dr_sig, min_dr_bkg); if(psb_distance < 0 || psb_distance > 1){ cout<<"[Warning] PSB_Distance: "<= 60){ elapsed_time = seconds/60.; unity = "min."; } if(seconds >= 3600){ elapsed_time = seconds/3600.; unity = "h"; } cout<<":: Time Consumed: "<