/** * Publish completion report of this robot's task */ void MedicationRobot::eventTriggerReply() { // Create response message elderly_care_simulation::EventTrigger msg; msg.msg_type = EVENT_TRIGGER_MSG_TYPE_RESPONSE; msg.event_type = MY_TASK; msg.event_priority = EVENT_TRIGGER_PRIORITY_UNDEFINED; msg.event_weight = getEventWeight(msg.event_type); msg.result = EVENT_TRIGGER_RESULT_SUCCESS; eventTriggerPub.publish(msg); ROS_INFO("MedicationRobot: Reply Message Sent"); }
// // MAIN ANALYZER LOOP // void DileptonAnalyzer::Loop() { // Check you have a file/chain if (fChain == 0) return; // Get number of entries in chain Long64_t nentries = fChain->GetEntries(); double nEventCount=0; double nEventGot=0; // Loop over events for (Long64_t jentry=0; jentry<nentries;jentry++) { nEventCount++; // Checks recommended from TTree:MakeClass Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nEventGot++; fChain->GetEntry(jentry); getEventWeight(); // Study gen level info if this is signal MC // In particular, get total number of exotics decaying to something this analysis is sensitive to? if ( isSignalMC_ ) { // Filter out events where there is no interesting exotics // This can happen when e.g. the generated event is H->XX and both X->jj if ( !interestingExoticInEvent() ) continue; nSensitiveExoticDecayInEvent_=getNumberOfExotics(); // Check which triggers fired studyTriggers(); if ( !signalTriggerFired() ) continue; } // Loop over candidates in event for( unsigned int iTreeCand=0; iTreeCand != candidates->candidates_.size(); ++iTreeCand ) { TreeDipseudoLeptonCandidate cand = candidates->candidates_.at(iTreeCand); // Check what type of leptons make up this candidate if ( !correctLeptonsInCandidate(cand) ) continue; // Get leptons TreeLepton leptonL = getLepton( cand.leptonIndexL ); TreeLepton leptonH = getLepton( cand.leptonIndexH ); // Choose appropiate mass to plot double mass = cand.mass; if (anaType_==_2eTrack) mass=cand.caloCorrMass; // Sign of Lxy/sigma int sign = 1; if( cand.dPhiCorr > TMath::PiOver2() ) sign = -1; // Apply analysis cuts. // And fill histograms_ DileptonAnalysisCuts::PassedWhichCuts finalCuts = dileptonCuts_final_.whichCuts( cand, leptonL, leptonH, anaType_, lxyScale_, d0Scale_ ); DileptonAnalysisCuts::PassedWhichCuts removedLifetimeCuts = dileptonCuts_removedLifetime_.whichCuts( cand, leptonL, leptonH, anaType_, lxyScale_, d0Scale_ ); // Final Selection // n-1 plots // Lxy significance DileptonAnalysisCuts::PassedWhichCuts finalCutsTemp = finalCuts; finalCutsTemp.passMinLxySig = true; finalCutsTemp.passMaxLxySig = true; if ( dileptonCuts_final_.passAllCuts( finalCutsTemp ) ) { histograms_.h_nMinus1_LxySig_finalCuts->Fill( sign*cand.decayLengthSignificance*lxyScale_, eventWeight_ ); } // Also remove deltaPhi cut to see -ve Lxy/sigma distibution finalCutsTemp.passDeltaPhi = true; if ( dileptonCuts_final_.passAllCuts( finalCutsTemp ) ) { histograms_.h_nMinus1_LxySig_removeDeltaPhi_finalCuts->Fill( sign*cand.decayLengthSignificance*lxyScale_, eventWeight_ ); } // Chi^2 finalCutsTemp = finalCuts; finalCutsTemp.passVertexChi2 = true; if ( dileptonCuts_final_.passAllCuts( finalCutsTemp ) ) { histograms_.h_nMinus1_vertexChi2_finalCuts->Fill( cand.vertexChi2, eventWeight_); } // dPhi finalCutsTemp = finalCuts; finalCutsTemp.passDeltaPhi = true; if ( dileptonCuts_final_.passAllCuts( finalCutsTemp ) ) { histograms_.h_nMinus1_deltaPhi_finalCuts->Fill( cand.dPhiCorr, eventWeight_); } // smallest d0/sigma of the two leptons finalCutsTemp = finalCuts; finalCutsTemp.passLeptonAbsD0 = true; if ( dileptonCuts_final_.passAllCuts( finalCutsTemp ) ) { histograms_.h_nMinus1_leptonAbsD0Sig_finalCuts->Fill( std::min(leptonL.d0Significance,leptonH.d0Significance), eventWeight_ ); } // Calo match delta R (largest of two leptons) finalCutsTemp = finalCuts; finalCutsTemp.passCaloMatch = true; // Shouldn't do anything at the moment. Cut at deltaR < 0.2, which is very loose and applied in Tree Producer anyway. if ( dileptonCuts_final_.passAllCuts( finalCutsTemp ) ) { histograms_.h_nMinus1_leptonCaloMatchDeltaR_finalCuts->Fill( std::max(leptonL.cmDeltaR,leptonH.cmDeltaR), eventWeight_ ); histograms_.h_nMinus1_leptonCaloMatchDeltaEta_finalCuts->Fill( std::max(leptonL.cmDeltaEta,leptonH.cmDeltaEta), eventWeight_ ); histograms_.h_nMinus1_leptonCaloMatchDeltaPhi_finalCuts->Fill( std::max(leptonL.cmDeltaPhi,leptonH.cmDeltaPhi), eventWeight_ ); } // Track pt cut finalCutsTemp = finalCuts; finalCutsTemp.passTrackPt = true; if ( dileptonCuts_final_.passAllCuts( finalCutsTemp ) ) { histograms_.h_nMinus1_leptonTrackPt_finalCuts->Fill(std::min(leptonL.pt,leptonH.pt),eventWeight_); } // Isolation // Gen matched signal only if ( isSignalMC_ && correctlyReconstructed( cand ) ) { finalCutsTemp = finalCuts; finalCutsTemp.passIso = true; if ( dileptonCuts_final_.passAllCuts( finalCutsTemp ) ) { histograms_.h_nMinus1_isolationLeptonL_finalCuts_genMatched->Fill( cand.leptonIsoL, eventWeight_ ); histograms_.h_nMinus1_isolationLeptonH_finalCuts_genMatched->Fill( cand.leptonIsoH, eventWeight_ ); histograms_.h_nMinus1_relIsolationLeptonL_finalCuts_genMatched->Fill( cand.leptonIsoL/cand.leptonPtL, eventWeight_ ); histograms_.h_nMinus1_relIsolationLeptonH_finalCuts_genMatched->Fill( cand.leptonIsoH/cand.leptonPtH, eventWeight_ ); histograms_.h_nMinus1_isolationLeptonL_vsPU_finalCuts_genMatched->Fill( cand.leptonIsoL, candidates->numPV, eventWeight_ ); histograms_.h_nMinus1_isolationLeptonH_vsPU_finalCuts_genMatched->Fill( cand.leptonIsoH, candidates->numPV, eventWeight_ ); histograms_.h_nMinus1_relIsolationLeptonL_vsPU_finalCuts_genMatched->Fill( cand.leptonIsoL/cand.leptonPtL, candidates->numPV, eventWeight_ ); histograms_.h_nMinus1_relIsolationLeptonH_vsPU_finalCuts_genMatched->Fill( cand.leptonIsoH/cand.leptonPtH, candidates->numPV, eventWeight_ ); } } // Final selection // All cuts // Monitor cut flow for final selection cuts monitorCutFlow( finalCuts, eventWeight_ ); if ( dileptonCuts_final_.passAllCuts( finalCuts ) ) { // // These candidates have passed all final selection criteria // histograms_.h_mass_finalCuts->Fill( mass, eventWeight_ ); // histograms_.h_mt_finalCuts->Fill( cand.transverseMass, eventWeight_ ); histograms_.h_Lxy_finalCuts->Fill( cand.decayLength, eventWeight_ ); histograms_.h_nRecoPV_finalCuts->Fill(candidates->numPV, eventWeight_ ); // Study efficiencies etc. // Study gen level info // Count number of correctly reconstructed candidates if ( isSignalMC_ ) storeNumberOfExoticsRECO( cand ); } // Removed lifetime cuts // All cuts if ( dileptonCuts_removedLifetime_.passAllCuts( removedLifetimeCuts ) ) { histograms_.h_mass_removedLifetimeCuts->Fill( mass, eventWeight_ ); histograms_.h_nRecoPV_removedLifetimeCuts->Fill( candidates->numPV, eventWeight_ ); // Calculate different event weight with different pu weight double puP5weight = puweights_p5_.weight( candidates->nvtx_true ); double puM5weight = puweights_m5_.weight( candidates->nvtx_true ); histograms_.h_nRecoPV_p5_removedLifetimeCuts->Fill(candidates->numPV, puP5weight * weight_ ); histograms_.h_nRecoPV_m5_removedLifetimeCuts->Fill(candidates->numPV, puM5weight * weight_ ); histograms_.h_leptonLPt_removedLifetimeCuts->Fill( leptonL.pt, eventWeight_ ); histograms_.h_leptonHPt_removedLifetimeCuts->Fill( leptonH.pt, eventWeight_ ); histograms_.h_leptonLEta_removedLifetimeCuts->Fill( leptonL.eta, eventWeight_ ); histograms_.h_leptonHEta_removedLifetimeCuts->Fill( leptonH.eta, eventWeight_ ); histograms_.h_leptonLCaloMatchDeltaR_removedLifetimeCuts->Fill( leptonL.cmDeltaR, eventWeight_ ); histograms_.h_leptonHCaloMatchDeltaR_removedLifetimeCuts->Fill( leptonH.cmDeltaR, eventWeight_ ); histograms_.h_LxySig_removedLifetimeCuts->Fill( sign*cand.decayLengthSignificance*lxyScale_, eventWeight_ ); histograms_.h_leptonAbsD0Sig_removedLifetimeCuts->Fill( std::min(leptonL.d0Significance,leptonH.d0Significance)*d0Scale_, eventWeight_ ); } // n-1 (for isolation) DileptonAnalysisCuts::PassedWhichCuts removedLifetimeCutsTemp = removedLifetimeCuts; removedLifetimeCutsTemp.passIso = true; if ( dileptonCuts_removedLifetime_.passAllCuts( removedLifetimeCutsTemp ) ) { histograms_.h_nMinus1_isolationLeptonL_removedLifetimeCuts->Fill( cand.leptonIsoL, eventWeight_ ); histograms_.h_nMinus1_isolationLeptonH_removedLifetimeCuts->Fill( cand.leptonIsoH, eventWeight_ ); histograms_.h_nMinus1_relIsolationLeptonL_removedLifetimeCuts->Fill( cand.leptonIsoL/cand.leptonPtL, eventWeight_ ); histograms_.h_nMinus1_relIsolationLeptonH_removedLifetimeCuts->Fill( cand.leptonIsoH/cand.leptonPtH, eventWeight_ ); } } // cand loop } // event loop // Draw overflow of histograms_ in final bin histograms_.drawOverflows(); // Save histograms_ TString type("dummy"); if ( anaType_==_2eTrack) type = "2eTrack"; else if ( anaType_==_2muTrack ) type = "2muTrack"; else if ( anaType_==_2globalMu ) type = "2globalMu"; else if ( anaType_==_2trackerMu ) type = "2trackerMu"; else if ( anaType_==_2saMu ) type = "2saMu"; TString outputFileName("WeightedFiles/"+dirName_+"_weighted_"+type+".root"); TFile outputFile(outputFileName, "RECREATE"); outputFile.cd(); histograms_.writeHistograms(outputFile); // Report cut flow reportCutFlow(outputFile); if ( isSignalMC_ ) { // Store signal efficiencies storeSignalEfficiencies(outputFile); // Report trigger info for ( unsigned int iTrig=0; iTrig < signalTriggers_.size(); iTrig++ ) { std::cout << "Trigger : " << signalTriggers_[iTrig].c_str() << " Number times fired : " << triggerFired_[iTrig] << std::endl; } } std::cout << "Writing and closing files" << std::endl; // Close file outputFile.Write(); outputFile.Close(); std::cout << "Deleting histograms" << std::endl; // Delete histograms histograms_.deleteHistograms(); }