CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuTriggerAnalyzer Class Reference
Inheritance diagram for MuTriggerAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 MuTriggerAnalyzer (const edm::ParameterSet &pset)
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

virtual void analyze (const edm::Event &event, const edm::EventSetup &setup) override
 
virtual void endJob () override
 
bool IsMuMatchedToHLTMu (const reco::Muon &, std::vector< reco::Particle > &, double, double)
 

Private Attributes

TH1D * deltaPtOverPt_
 
TH1D * deltaR_
 
double etaMuCut_
 
edm::Handle< trigger::TriggerEventhandleTriggerEvent_
 
std::string hltPath_
 
TH1D * hTrigMuonPtDenS_
 
TH1D * hTrigMuonPtNumS_
 
std::string L3FilterName_
 
double maxDeltaR_
 
double maxDPtRel_
 
edm::EDGetTokenT< View< Muon > > muonToken_
 
const int nbins_
 
const double ptMax_
 
double ptMuCut_
 
edm::InputTag trigEvTag_
 
edm::EDGetTokenT< trigger::TriggerEventtrigEvToken_
 
edm::Handle< edm::TriggerResultstriggerResults_
 
edm::TriggerNames const * trigNames_
 
edm::EDGetTokenT< TriggerResultstrigToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 49 of file MuTriggerAnalyzer.cc.

Constructor & Destructor Documentation

MuTriggerAnalyzer::MuTriggerAnalyzer ( const edm::ParameterSet pset)

Definition at line 113 of file MuTriggerAnalyzer.cc.

References deltaPtOverPt_, deltaR_, hTrigMuonPtDenS_, hTrigMuonPtNumS_, TFileService::make(), maxDeltaR_, maxDPtRel_, nbins_, and ptMax_.

113  :
114  trigToken_(consumes<TriggerResults>(cfg.getParameter<edm::InputTag> ("TrigTag"))),
115  trigEvTag_(cfg.getParameter<edm::InputTag> ("triggerEvent")),
116  trigEvToken_(consumes< trigger::TriggerEvent >(trigEvTag_)),
117  muonToken_(consumes<View<Muon> > (cfg.getUntrackedParameter<edm::InputTag>("muons"))),
118  ptMuCut_(cfg.getUntrackedParameter<double>("ptMuCut")),
119  etaMuCut_(cfg.getUntrackedParameter<double>("etaMuCut")),
120  hltPath_(cfg.getParameter<std::string >("hltPath")),
121  L3FilterName_(cfg.getParameter<std::string >("L3FilterName")),
122  maxDPtRel_(cfg.getParameter<double>("maxDPtRel")),
123  maxDeltaR_(cfg.getParameter<double>("maxDeltaR")),
124  nbins_(cfg.getParameter<double>("ptMax_")),
125  ptMax_(cfg.getParameter<double>("ptMax_")){
127 
128  hTrigMuonPtNumS_ = fs->make<TH1D>("hTrigMuonPtNumS", "hTrigMuonPtNumS", nbins_ + 1, 0, ptMax_);
129  hTrigMuonPtDenS_ = fs->make<TH1D>("hTrigMuonPtDenS", "hTrigMuonPtDenS", nbins_ +1 , 0, ptMax_);
130  deltaR_ = fs->make<TH1D>("deltaR", "deltaR", nbins_+1, 0, maxDeltaR_);
131  deltaPtOverPt_ = fs->make<TH1D>("deltaPtOverPt", "deltaPtOverPt", nbins_ + 1, 0, maxDPtRel_);
132 
133 }
edm::EDGetTokenT< View< Muon > > muonToken_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< TriggerResults > trigToken_
edm::InputTag trigEvTag_
std::string L3FilterName_
edm::EDGetTokenT< trigger::TriggerEvent > trigEvToken_

Member Function Documentation

void MuTriggerAnalyzer::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
overrideprivatevirtual

Definition at line 144 of file MuTriggerAnalyzer.cc.

References edm::HLTGlobalStatus::accept(), gather_cfg::cout, DEFINE_FWK_MODULE, edm::InputTag::encode(), stringResolutionProvider_cfi::eta, reco::LeafCandidate::eta(), etaMuCut_, trigger::TriggerEvent::filterKeys(), trigger::TriggerEvent::filterTag(), edm::Event::getByToken(), trigger::TriggerEvent::getObjects(), hltPath_, mps_fire::i, reco::Muon::isGlobalMuon(), IsMuMatchedToHLTMu(), gen::k, L3FilterName_, maxDeltaR_, maxDPtRel_, RPCpg::mu, electronCleaner_cfi::muons, muonToken_, dataset::name, AlCaHLTBitMon_ParallelJobs::p, reco::LeafCandidate::p4(), EnergyCorrector::pt, reco::LeafCandidate::pt(), ptMuCut_, edm::HLTGlobalStatus::size(), trigger::TriggerEvent::sizeFilters(), AlCaHLTBitMon_QueryRunRegistry::string, trigEvTag_, trigEvToken_, edm::TriggerNames::triggerName(), edm::Event::triggerNames(), triggerResults, trigNames, trigNames_, and trigToken_.

144  {
145  // bool overlap = false;
146 
147  // Trigger
150  if (!ev.getByToken(trigToken_, triggerResults)) {
151  LogWarning("") << ">>> TRIGGER collection does not exist !!!";
152  return;
153  }
154  // trigNames.init(*triggerResults);
155  trigNames_ = &ev.triggerNames(*triggerResults);
156  //bool trigger_fired = false;
157  for (unsigned int i=0; i<triggerResults->size(); i++) {
158 
159 
160  std::string trigName = trigNames_->triggerName(i);
161  if ( trigName == hltPath_ && triggerResults->accept(i)) {
162  //trigger_fired = true;
163  }
164  }
165  edm::Handle< trigger::TriggerEvent > handleTriggerEvent;
166  // LogTrace("") << ">>> Trigger bit: " << trigger_fired << " (" << hltPath_ << ")";
167  if ( ! ev.getByToken( trigEvToken_, handleTriggerEvent )) {
168  LogWarning( "errorTriggerEventValid" ) << "trigger::TriggerEvent product with InputTag " << trigEvTag_.encode() << " not in event";
169  return;
170  }
171  const trigger::TriggerObjectCollection & toc(handleTriggerEvent->getObjects());
172  size_t nMuHLT =0;
173  std::vector<reco::Particle> HLTMuMatched;
174  for ( size_t ia = 0; ia < handleTriggerEvent->sizeFilters(); ++ ia) {
175  std::string fullname = handleTriggerEvent->filterTag(ia).encode();
177  size_t p = fullname.find_first_of(':');
178  if ( p != std::string::npos) {
179  name = fullname.substr(0, p);
180  }
181  else {
182  name = fullname;
183  }
184  if ( toc.size() != 0 ) {
185  const trigger::Keys & k = handleTriggerEvent->filterKeys(ia);
186  for (trigger::Keys::const_iterator ki = k.begin(); ki !=k.end(); ++ki ) {
187  if (name == L3FilterName_ ) {
188  HLTMuMatched.push_back(toc[*ki].particle());
189  nMuHLT++;
190  }
191  }
192  }
193  }
194 
195  // looping on muon....
197  if (!ev.getByToken(muonToken_, muons)) {
198  LogError("") << ">>> muon collection does not exist !!!";
199  return;
200  }
201  //saving only muons with pt> ptMuCut and eta<etaMuCut
202  std::vector<reco::Muon> highPtGlbMuons;
203 
204  for (unsigned int i=0; i<muons->size(); i++ ){
205  const reco::Muon & mu = muons->at(i);
206  double pt = mu.pt();
207  double eta = mu.eta();
208  if (pt> ptMuCut_ && fabs(eta)< etaMuCut_) {
209  if (mu.isGlobalMuon()) highPtGlbMuons.push_back(mu);
210  }
211  }
212  unsigned int nHighPtGlbMu = highPtGlbMuons.size();
213  std::cout << "I've got " << nHighPtGlbMu << " nHighPtGlbMu" << std::endl;
214  // unsigned int nHighPtStaMu = highPtStaMuons.size();
215 
216  // stop the loop after 10 cicles....
217  (nHighPtGlbMu> 10)? nHighPtGlbMu=10 : 1;
218 
219  if (nHighPtGlbMu>0 ){
220 
221  for(unsigned int i =0 ; i < nHighPtGlbMu ; i++) {
222  reco::Muon muon1 = highPtGlbMuons[i];
223  math::XYZTLorentzVector mu1(muon1.p4());
224  // double pt1= muon1.pt();
225 
226  /* bool singleTrigFlag1 =*/ IsMuMatchedToHLTMu ( muon1, HLTMuMatched ,maxDeltaR_, maxDPtRel_ );
227 
228  }
229 
230  }
231 
232 }
virtual double pt() const final
transverse momentum
bool IsMuMatchedToHLTMu(const reco::Muon &, std::vector< reco::Particle > &, double, double)
edm::EDGetTokenT< View< Muon > > muonToken_
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:135
virtual double eta() const final
momentum pseudorapidity
bool accept() const
Has at least one path accepted the event?
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:111
bool isGlobalMuon() const
Definition: Muon.h:225
edm::TriggerNames const * trigNames_
bool ev
std::string encode() const
Definition: InputTag.cc:165
edm::EDGetTokenT< TriggerResults > trigToken_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
unsigned int size() const
Get number of paths stored.
const int mu
Definition: Constants.h:22
static std::string const triggerResults
Definition: EdmProvDump.cc:41
int k[5][pyjets_maxn]
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:74
const edm::InputTag filterTag(trigger::size_type index) const
Definition: TriggerEvent.h:103
edm::InputTag trigEvTag_
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
std::vector< size_type > Keys
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
std::string L3FilterName_
edm::EDGetTokenT< trigger::TriggerEvent > trigEvToken_
void MuTriggerAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 135 of file MuTriggerAnalyzer.cc.

References gather_cfg::cout, hTrigMuonPtDenS_, hTrigMuonPtNumS_, mps_fire::i, and nbins_.

135  {
136  for (int i = 0; i < nbins_+1; ++i){
137  std::cout << "number of reco muon in bin " << i << " = " << hTrigMuonPtDenS_->GetBinContent(i) << std::endl;
138  std::cout << "number of hlt muon in bin " << i << " = " << hTrigMuonPtNumS_->GetBinContent(i) << std::endl;
139 
140 
141  }
142 }
bool MuTriggerAnalyzer::IsMuMatchedToHLTMu ( const reco::Muon mu,
std::vector< reco::Particle > &  HLTMu,
double  DR,
double  DPtRel 
)
private

Definition at line 80 of file MuTriggerAnalyzer.cc.

References gather_cfg::cout, deltaR(), deltaR_, reco::LeafCandidate::eta(), HcalObjRepresent::Fill(), gen::k, nJettinessAdder_cfi::nPass, EnergyCorrector::pt, and reco::LeafCandidate::pt().

Referenced by analyze().

80  {
81  size_t dim = HLTMu.size();
82  size_t nPass=0;
83 
84  // filling the denumerator;
85  double muRecoPt= mu.pt();
86  hTrigMuonPtDenS_-> Fill(muRecoPt);
87 
88  if (dim==0) return false;
89  for (size_t k =0; k< dim; k++ ) {
90  if ( (deltaR(HLTMu[k], mu) < DR) && (fabs(HLTMu[k].pt() - mu.pt())/ HLTMu[k].pt()<DPtRel)){
91  nPass++ ;
92  std::cout<< " matching a muon " << std::endl;
93  std::cout << "muon reco pt : " << muRecoPt<< std::endl;
94  std::cout << "muon reco eta " << mu.eta() << std::endl;
95  std::cout << "muon trigger pt "<< HLTMu[k].pt() << std::endl;
96  // filling the numerator, at the same bin as the denum.....
97  hTrigMuonPtNumS_-> Fill(muRecoPt);
98  deltaR_-> Fill(deltaR(HLTMu[k], mu));
99  deltaPtOverPt_-> Fill(fabs(HLTMu[k].pt() - mu.pt())/ HLTMu[k].pt());
100 
101 
102  std::cout << "muon trigger eta : "<< HLTMu[k].eta() << std::endl;
103  std::cout <<"deltaR((HLTMu[k], mu)): "<< deltaR(HLTMu[k], mu) << std::endl;
104  std::cout <<"deltaPtOverPt: "<< fabs(HLTMu[k].pt() - mu.pt())/ HLTMu[k].pt() << std::endl;
105  }
106  }
107 
108  return (nPass>0);
109 }
virtual double pt() const final
transverse momentum
virtual double eta() const final
momentum pseudorapidity
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
int k[5][pyjets_maxn]
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17

Member Data Documentation

TH1D* MuTriggerAnalyzer::deltaPtOverPt_
private

Definition at line 75 of file MuTriggerAnalyzer.cc.

Referenced by MuTriggerAnalyzer().

TH1D* MuTriggerAnalyzer::deltaR_
private

Definition at line 74 of file MuTriggerAnalyzer.cc.

Referenced by MuTriggerAnalyzer().

double MuTriggerAnalyzer::etaMuCut_
private

Definition at line 62 of file MuTriggerAnalyzer.cc.

Referenced by analyze().

edm::Handle< trigger::TriggerEvent > MuTriggerAnalyzer::handleTriggerEvent_
private

Definition at line 67 of file MuTriggerAnalyzer.cc.

std::string MuTriggerAnalyzer::hltPath_
private

Definition at line 63 of file MuTriggerAnalyzer.cc.

Referenced by analyze().

TH1D* MuTriggerAnalyzer::hTrigMuonPtDenS_
private

Definition at line 73 of file MuTriggerAnalyzer.cc.

Referenced by endJob(), and MuTriggerAnalyzer().

TH1D* MuTriggerAnalyzer::hTrigMuonPtNumS_
private

Definition at line 72 of file MuTriggerAnalyzer.cc.

Referenced by endJob(), and MuTriggerAnalyzer().

std::string MuTriggerAnalyzer::L3FilterName_
private

Definition at line 64 of file MuTriggerAnalyzer.cc.

Referenced by analyze().

double MuTriggerAnalyzer::maxDeltaR_
private

Definition at line 69 of file MuTriggerAnalyzer.cc.

Referenced by analyze(), and MuTriggerAnalyzer().

double MuTriggerAnalyzer::maxDPtRel_
private

Definition at line 69 of file MuTriggerAnalyzer.cc.

Referenced by analyze(), and MuTriggerAnalyzer().

edm::EDGetTokenT<View<Muon> > MuTriggerAnalyzer::muonToken_
private

Definition at line 61 of file MuTriggerAnalyzer.cc.

Referenced by analyze().

const int MuTriggerAnalyzer::nbins_
private

Definition at line 70 of file MuTriggerAnalyzer.cc.

Referenced by endJob(), and MuTriggerAnalyzer().

const double MuTriggerAnalyzer::ptMax_
private

Definition at line 71 of file MuTriggerAnalyzer.cc.

Referenced by MuTriggerAnalyzer().

double MuTriggerAnalyzer::ptMuCut_
private

Definition at line 62 of file MuTriggerAnalyzer.cc.

Referenced by analyze().

edm::InputTag MuTriggerAnalyzer::trigEvTag_
private

Definition at line 59 of file MuTriggerAnalyzer.cc.

Referenced by analyze().

edm::EDGetTokenT< trigger::TriggerEvent > MuTriggerAnalyzer::trigEvToken_
private

Definition at line 60 of file MuTriggerAnalyzer.cc.

Referenced by analyze().

edm::Handle<edm::TriggerResults> MuTriggerAnalyzer::triggerResults_
private

Definition at line 65 of file MuTriggerAnalyzer.cc.

edm::TriggerNames const* MuTriggerAnalyzer::trigNames_
private

Definition at line 66 of file MuTriggerAnalyzer.cc.

Referenced by analyze().

edm::EDGetTokenT<TriggerResults> MuTriggerAnalyzer::trigToken_
private

Definition at line 58 of file MuTriggerAnalyzer.cc.

Referenced by analyze().