15 #include <boost/foreach.hpp> 16 #include <TLorentzVector.h> 26 fHLTObjTag (iConfig.getParameter<
edm::InputTag>(
"TriggerEvent")),
27 fHLTTag (iConfig.getParameter<
edm::InputTag>(
"TriggerResults")),
28 fPVName (iConfig.getUntrackedParameter<
std::
string>(
"edmPVName",
"offlinePrimaryVertices")),
29 fMuonName (iConfig.getUntrackedParameter<
std::
string>(
"edmName",
"muons")),
30 fTrackName (iConfig.getUntrackedParameter<
std::
string>(
"edmTrackName",
"generalTracks"))
32 edm::LogInfo(
"ZCounting") <<
"Constructor ZCounting::ZCounting " << std::endl;
83 edm::LogInfo(
"ZCounting") <<
"Destructor ZCounting::~ZCounting " << std::endl;
91 edm::LogInfo(
"ZCounting") <<
"ZCounting::beginRun" << std::endl;
102 edm::LogInfo(
"ZCounting") <<
"ZCounting::bookHistograms" << std::endl;
131 edm::LogInfo(
"ZCounting") <<
"ZCounting::beginLuminosityBlock" << std::endl;
141 edm::LogInfo(
"ZCounting") <<
"ZCounting::analyze" << std::endl;
148 if(!hVertexProduct.
isValid())
return;
154 for(
auto const & itVtx : *hVertexProduct) {
155 if(itVtx.isFake())
continue;
159 if(itVtx.position().Rho() >
VtxRhoCut_)
continue;
183 bool config_changed =
false;
186 config_changed =
true;
189 initHLT(*hTrgRes, triggerNames);
193 for(
unsigned int irec=0; irec<
fTrigger->fRecords.size(); irec++) {
194 if(
fTrigger->fRecords[irec].hltPathIndex == (
unsigned int)-1)
continue;
196 triggerBits [
fTrigger->fRecords[irec].baconTrigBit] =
true;
209 if(!hMuonProduct.
isValid())
return;
213 if(!hTrackProduct.
isValid())
return;
215 TLorentzVector vTag(0.,0.,0.,0.);
216 TLorentzVector vProbe(0.,0.,0.,0.);
217 TLorentzVector vTrack(0.,0.,0.,0.);
220 for(
auto const & itMu1 : *hMuonProduct) {
222 float pt1 = itMu1.muonBestTrack()->pt();
223 float eta1 = itMu1.muonBestTrack()->eta();
224 float phi1 = itMu1.muonBestTrack()->phi();
225 float q1 = itMu1.muonBestTrack()->charge();
233 vTag.SetPtEtaPhiM(pt1, eta1, phi1,
MUON_MASS);
236 for(
auto const & itMu2 : *hMuonProduct) {
237 if(&itMu2 == &itMu1)
continue;
239 float pt2 = itMu2.muonBestTrack()->pt();
240 float eta2 = itMu2.muonBestTrack()->eta();
241 float phi2 = itMu2.muonBestTrack()->phi();
242 float q2 = itMu2.muonBestTrack()->charge();
247 if(q1 == q2)
continue;
249 vProbe.SetPtEtaPhiM(pt2, eta2, phi2,
MUON_MASS);
252 TLorentzVector vDilep = vTag + vProbe;
253 float dilepMass = vDilep.M();
256 bool isTagCentral =
false;
257 bool isProbeCentral =
false;
258 if(fabs(eta1) <
MUON_BOUND) isTagCentral =
true;
259 if(fabs(eta2) <
MUON_BOUND) isProbeCentral =
true;
265 if(&itMu1>&itMu2)
continue;
311 else if(itMu2.isGlobalMuon()){
323 else if(itMu2.isStandAloneMuon()){
333 else if(itMu2.innerTrack()->hitPattern().trackerLayersWithMeasurement() >= 6 && itMu2.innerTrack()->hitPattern().numberOfValidPixelHits() >= 1){
347 for(
auto const & itTrk : *hTrackProduct) {
351 for(
auto const & itMu : *hMuonProduct) {
352 if(itMu.innerTrack().isNonnull() && itMu.innerTrack().get() == &itTrk) {
359 float pt2 = itTrk.pt();
360 float eta2 = itTrk.eta();
361 float phi2 = itTrk.phi();
362 float q2 = itTrk.charge();
367 if(q1 == q2)
continue;
369 vTrack.SetPtEtaPhiM(pt2, eta2, phi2,
MUON_MASS);
371 TLorentzVector vDilep = vTag + vTrack;
372 float dilepMass = vDilep.M();
375 bool isTrackCentral =
false;
376 if(fabs(eta2) >
MUON_BOUND) isTrackCentral =
true;
378 if(itTrk.hitPattern().trackerLayersWithMeasurement() >= 6 && itTrk.hitPattern().numberOfValidPixelHits() >= 1){
394 edm::LogInfo(
"ZCounting") <<
"ZCounting::endLuminosityBlock" << std::endl;
403 for(
unsigned int irec=0; irec<
fTrigger->fRecords.size(); irec++) {
404 fTrigger->fRecords[irec].hltPathName =
"";
405 fTrigger->fRecords[irec].hltPathIndex = (
unsigned int)-1;
409 if(matches.empty()) {
410 edm::LogWarning(
"ZCounting") <<
"requested pattern [" << pattern <<
"] does not match any HLT paths" << std::endl;
412 BOOST_FOREACH(std::vector<std::string>::const_iterator
match, matches) {
421 if(index < result.
size()) {
430 return triggerMenu.
pass(
"HLT_IsoMu27_v*",hltBits);
436 return triggerMenu.
passObj(
"HLT_IsoMu27_v*",
"hltL3crIsoL1sMu22Or25L1f0L2f10QL3f27QL3trkIsoFiltered0p07",hltMatchBits);
445 else if(idType ==
NoneID)
return true;
454 else if(isoType ==
NoneIso)
return true;
MonitorElement * h_mass_Sta_fail_central
ZCounting(const edm::ParameterSet &ps)
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * h_mass_Sta_pass_central
MonitorElement * h_mass_SIT_fail_central
float sumPt
sum-pt of tracks
bool isMuon(const Candidate &part)
bool isMediumMuon(const reco::Muon &, bool run2016_hip_mitigation=false)
void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool passObj(const std::string &iName, const std::string &iObjName, const TriggerObjects &iTrigObj) const
#define DEFINE_FWK_MODULE(type)
MonitorElement * h_mass_SIT_pass_forward
bool accept() const
Has at least one path accepted the event?
bool is_glob(std::string const &pattern)
MonitorElement * h_yield_Z
edm::LuminosityBlockNumber_t luminosityBlock() const
std::vector< Vertex > VertexCollection
collection of Vertex objects
bool passMuonID(const reco::Muon &muon, const reco::Vertex &vtx, const MuonIDTypes &idType)
MonitorElement * h_mass_HLT_pass_forward
float sumPhotonEt
sum pt of PF photons
Strings const & triggerNames() const
std::bitset< kNTrigObjectBit > TriggerObjects
bool isLooseMuon(const reco::Muon &)
float sumNeutralHadronEt
sum pt of neutral hadrons
ParameterSetID const & parameterSetID() const
edm::EDGetTokenT< reco::TrackCollection > fTrackName_token
edm::EDGetTokenT< reco::MuonCollection > fMuonName_token
float sumPUPt
sum pt of charged Particles not from PV (for Pu corrections)
MonitorElement * h_mass_Sta_pass_forward
edm::ParameterSetID fTriggerNamesID
unsigned int triggerIndex(std::string const &name) const
edm::EDGetTokenT< reco::VertexCollection > fPVName_token
unsigned int size() const
Get number of paths stored.
std::bitset< kNTrigBit > TriggerBits
bool isMuonTrigger(const ZCountingTrigger::TTrigger &triggerMenu, const TriggerBits &hltBits)
MonitorElement * book1D(Args &&...args)
void initHLT(const edm::TriggerResults &, const edm::TriggerNames &)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * h_mass_Sta_fail_forward
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
edm::EDGetTokenT< trigger::TriggerEvent > fHLTObjTag_token
void endLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup) override
MonitorElement * h_mass_SIT_fail_forward
void setCurrentFolder(const std::string &fullpath)
T const * product() const
MonitorElement * book2D(Args &&...args)
bool pass(const std::string &iName, const TriggerBits &iTrig) const
const MuonPFIsolation & pfIsolationR04() const
MonitorElement * h_mass_HLT_pass_central
edm::EDGetTokenT< edm::TriggerResults > fHLTTag_token
MonitorElement * h_mass_HLT_fail_forward
std::vector< std::vector< std::string >::const_iterator > regexMatch(std::vector< std::string > const &strings, std::regex const ®exp)
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
bool passMuonIso(const reco::Muon &muon, const MuonIsoTypes &isoType, const float isoCut)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
MonitorElement * h_mass_SIT_pass_central
std::unique_ptr< ZCountingTrigger::TTrigger > fTrigger
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
MonitorElement * h_mass_HLT_fail_central
bool isMuonTriggerObj(const ZCountingTrigger::TTrigger &triggerMenu, const TriggerObjects &hltMatchBits)
const MuonIsolation & isolationR03() const
float sumChargedHadronPt
sum-pt of charged Hadron