CMS 3D CMS Logo

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

Public Member Functions

 dimuonHLTFilterCheck (const edm::ParameterSet &pset)
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &setup) override
 
void endJob () override
 
vector< int > nDimuonsByType (const Handle< CandidateView > d)
 
vector< int > nMuonsByType (const Handle< CandidateView > d)
 

Private Attributes

EDGetTokenT< CandidateViewanyDimuonToken
 
int counterMatrix [5][5]
 
EDGetTokenT< CandidateViewmuonToken
 
EDGetTokenT< CandidateViewtracksToken
 
EDGetTokenT< TriggerResultstriggerResultsToken
 

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 &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 42 of file dimuonHLTFilterCheck.cc.

Constructor & Destructor Documentation

dimuonHLTFilterCheck::dimuonHLTFilterCheck ( const edm::ParameterSet pset)

Definition at line 74 of file dimuonHLTFilterCheck.cc.

References counterMatrix, and mps_fire::i.

74  :
75  // trigger results
76  triggerResultsToken(consumes<TriggerResults>(pset.getParameter<InputTag>("triggerResults"))),
77  tracksToken(consumes<CandidateView>(pset.getParameter<InputTag>("tracks"))),
78  muonToken(consumes<CandidateView>(pset.getParameter<InputTag>("muons"))),
79  anyDimuonToken(consumes<CandidateView>(pset.getParameter<InputTag>("anyDimuon")))
80 {
82 
83 
84 // general histograms
85 
86 // general counters
87  for (int i=0; i<5; i++) {
88  for (int j=0;j<5;j++) {
89  counterMatrix[i][j]=0;
90  }
91  }
92 }
T getParameter(std::string const &) const
EDGetTokenT< CandidateView > tracksToken
EDGetTokenT< CandidateView > anyDimuonToken
EDGetTokenT< TriggerResults > triggerResultsToken
EDGetTokenT< CandidateView > muonToken

Member Function Documentation

void dimuonHLTFilterCheck::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
overrideprivate

Definition at line 94 of file dimuonHLTFilterCheck.cc.

References edm::HLTGlobalStatus::accept(), anyDimuonToken, counterMatrix, gather_cfg::cout, reco::Candidate::eta(), reco::Candidate::get(), mps_fire::i, reco::Candidate::isGlobalMuon(), extraflags_cff::muons, muons_cff::muonTable, muonToken, nDimuonsByType(), nMuonsByType(), edm::Handle< T >::product(), reco::Candidate::pt(), edm::View< T >::refAt(), edm::HLTGlobalStatus::size(), edm::View< T >::size(), edm::HLTGlobalStatus::state(), l1t::tracks, tracksToken, edm::TriggerNames::triggerName(), edm::TriggerNames::triggerNames(), triggerResults, triggerResultsToken, and edm::HLTGlobalStatus::wasrun().

94  {
95 
96  Handle<TriggerResults> triggerResults; // trigger response
97  Handle<CandidateView> anyDimuon; // any dimuon pair
98  Handle<CandidateView> tracks; // any track
99  Handle<CandidateView> muons; // any muon
100 
101  event.getByToken( triggerResultsToken, triggerResults );
102  event.getByToken( anyDimuonToken, anyDimuon );
103  event.getByToken( tracksToken, tracks );
104  event.getByToken( muonToken, muons );
105 
106  const edm::TriggerNames & triggerNames = event.triggerNames(*triggerResults);
107 
108  // map of MU triggers of interest
109  map<string,int> dimuonHLT_triggers;
110  dimuonHLT_triggers.insert(make_pair("HLT1MuonPrescalePt3",0));
111  dimuonHLT_triggers.insert(make_pair("HLT1MuonPrescalePt7x7",1));
112  dimuonHLT_triggers.insert(make_pair("HLT1MuonIso",2));
113  dimuonHLT_triggers.insert(make_pair("HLT1MuonNonIso15",3));
114  dimuonHLT_triggers.insert(make_pair("HLT2MuonNonIso",4));
115  // map of JET triggers of interest
116  map<string,int> jetHLT_triggers;
117  jetHLT_triggers.insert(make_pair("HLT1jetPE5",0));
118  jetHLT_triggers.insert(make_pair("HLT1jetPE3",1));
119  jetHLT_triggers.insert(make_pair("HLT1jetPE1",2));
120  jetHLT_triggers.insert(make_pair("candHLT1jetPE7",3));
121 
122  bool trgMask[5];
123  for (int i=0; i<5; i++) trgMask[i] = false;
124 
125  // table of possible dimuons
126  string dimuonTableNames[10];
127  dimuonTableNames[0] = "global-global";
128  dimuonTableNames[1] = "global-trackerSta";
129  dimuonTableNames[2] = "global-sta";
130  dimuonTableNames[3] = "global-tracker";
131  dimuonTableNames[4] = "trackerSta-trackerSta";
132  dimuonTableNames[5] = "trackerSta-sta";
133  dimuonTableNames[6] = "trackerSta-tracker";
134  dimuonTableNames[7] = "sta-sta";
135  dimuonTableNames[8] = "sta-tracker";
136  dimuonTableNames[9] = "tracker-tracker";
137  // table of possible muons
138  string muonTableNames[10];
139  muonTableNames[0] = "global";
140  muonTableNames[1] = "trackerSta";
141  muonTableNames[2] = "sta";
142  muonTableNames[3] = "tracker";
143 
144  cout << "-------------------NEW event---------------------------" << endl;
145  // check the dimuon reconstruction
146  vector<int> dimuonTable;
147  dimuonTable = nDimuonsByType(anyDimuon);
148  // check the muon reconstruction
149  vector<int> muonTable;
150  muonTable = nMuonsByType(muons);
151 
152  if ( triggerResults.product()->wasrun() ){
153  // cout << "at least one path out of " << triggerResults.product()->size() << " ran? " << triggerResults.product()->wasrun() << endl;
154 
155  if ( triggerResults.product()->accept() )
156  {
157  // cout << endl << "at least one path accepted? " << triggerResults.product()->accept() << endl;
158 
159  const unsigned int n_TriggerResults( triggerResults.product()->size() );
160  for ( unsigned int itrig( 0 ); itrig < n_TriggerResults; ++itrig )
161  {
162  if ( triggerResults.product()->accept( itrig ) )
163  {
164  map<string,int>::iterator iterMuHLT = dimuonHLT_triggers.find(triggerNames.triggerName( itrig ));
165  if (iterMuHLT != dimuonHLT_triggers.end()) {
166  cout << "ecco la chiave Mu HLT " << (*iterMuHLT).second << endl;
167  if (triggerResults.product()->state( itrig )==1) trgMask[(*iterMuHLT).second] = true;
168  } // end if key found
169  map<string,int>::iterator iterjetHLT = jetHLT_triggers.find(triggerNames.triggerName( itrig ));
170  if (iterjetHLT != jetHLT_triggers.end()) {
171  cout << "ecco la chiave jet HLT " << (*iterjetHLT).second << endl;
172  } // end if key found
173 
174  } // end if trigger accepted
175  } // end loop on triggerResults
176  } // end if at least one triggerResult accepted
177  } // end if wasRun
178  if ( muonTable[0]>1) {
179  for(unsigned int i = 0; i < muons->size(); ++i) { //loop on candidates
180  const Candidate & muCand = (*muons)[i]; //the candidate
181  CandidateBaseRef muCandRef = muons->refAt(i);
182  TrackRef muStaComponentRef = muCand.get<TrackRef,reco::StandAloneMuonTag>(); // standalone part of muon
183  TrackRef muTrkComponentRef = muCand.get<TrackRef>(); // track part of muon
184  if (muCandRef->isGlobalMuon()) {
185  cout << "muCand : " << i << " pt " << muCandRef->pt() << " eta " << muCandRef->eta() << endl;
186  cout << "muCandStaComponent : " << i << " pt " << muStaComponentRef->pt() << " eta " << muStaComponentRef->eta() << endl;
187  }
188  }
189  }
190 
191  // fill counterMatrix
192  for (int i=0; i<5; i++) {
193  for (int j=0; j<5; j++) {
194  if (trgMask[i] && trgMask[j]) counterMatrix[i][j]++;
195  }
196  }
197 } // end analyze
bool wasrun() const
Was at least one path run?
bool accept() const
Has at least one path accepted the event?
stand alone muon component tag
Definition: RecoCandidate.h:78
size_type size() const
Strings const & triggerNames() const
Definition: TriggerNames.cc:20
EDGetTokenT< CandidateView > tracksToken
RefToBase< value_type > refAt(size_type i) const
vector< int > nDimuonsByType(const Handle< CandidateView > d)
unsigned int size() const
Get number of paths stored.
static std::string const triggerResults
Definition: EdmProvDump.cc:45
virtual bool isGlobalMuon() const =0
EDGetTokenT< CandidateView > anyDimuonToken
virtual double eta() const =0
momentum pseudorapidity
T const * product() const
Definition: Handle.h:74
virtual double pt() const =0
transverse momentum
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:22
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:21
vector< int > nMuonsByType(const Handle< CandidateView > d)
EDGetTokenT< TriggerResults > triggerResultsToken
T get() const
get a component
Definition: Candidate.h:217
EDGetTokenT< CandidateView > muonToken
hlt::HLTState state(const unsigned int i) const
Get status of ith path.
void dimuonHLTFilterCheck::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 267 of file dimuonHLTFilterCheck.cc.

References counterMatrix, gather_cfg::cout, DEFINE_FWK_MODULE, and mps_fire::i.

267  {
268 
269  cout << "------------------------------------ Counters --------------------------------" << endl;
270  for (int i=0; i<5; i++) {
271  cout << "trg " << i << ": ";
272  for (int j=0; j<5; j++) {
273  cout << counterMatrix[i][j] << " ";
274  }
275  cout << endl;
276  }
277 }
vector< int > dimuonHLTFilterCheck::nDimuonsByType ( const Handle< CandidateView d)
private

Definition at line 199 of file dimuonHLTFilterCheck.cc.

References reco::Candidate::daughter(), mps_fire::i, reco::Candidate::isGlobalMuon(), reco::Candidate::isStandAloneMuon(), reco::Candidate::isTrackerMuon(), edm::View< T >::refAt(), and edm::View< T >::size().

Referenced by analyze().

199  {
200  vector<int> n_;
201  int nCat = 10; // number of dimuon categories (0 = glb-glb, 1 = glb-trkSta, 2 = glb-sta, 3 = glb-trk, 4 = trkSta-trkSta, 5 = trkSta-sta, 6 = trkSta-trk, 7 = sta-sta, 8 = sta-trk, 9 trk-trk)
202  // reset vector
203  for (int i=0; i<nCat; i++) n_.push_back(0);
204  for(unsigned int i = 0; i < d->size(); ++i) { //loop on candidates
205  // const Candidate & dCand = (*d)[i]; //the candidate
206  bool mu0global = false;
207  bool mu0trackerSta = false;
208  bool mu0sta = false;
209  bool mu0tracker = false;
210  bool mu1global = false;
211  bool mu1trackerSta = false;
212  bool mu1sta = false;
213  bool mu1tracker = false;
214  CandidateBaseRef dCandRef = d->refAt(i);
215  const Candidate * mu0 = dCandRef->daughter(0);
216  const Candidate * mu1 = dCandRef->daughter(1);
217  if (mu0->isGlobalMuon()) mu0global=true;
218  if (! mu0->isGlobalMuon() && mu0->isStandAloneMuon() && mu0->isTrackerMuon()) mu0trackerSta=true;
219  if (! mu0->isGlobalMuon() && mu0->isStandAloneMuon() && ! mu0->isTrackerMuon()) mu0sta=true;
220  if (! mu0->isGlobalMuon() && ! mu0->isStandAloneMuon() && mu0->isTrackerMuon()) mu0tracker=true;
221  if (mu1->isGlobalMuon()) mu1global=true;
222  if (! mu1->isGlobalMuon() && mu1->isStandAloneMuon() && mu1->isTrackerMuon()) mu1trackerSta=true;
223  if (! mu1->isGlobalMuon() && mu1->isStandAloneMuon() && ! mu1->isTrackerMuon()) mu1sta=true;
224  if (! mu1->isGlobalMuon() && ! mu1->isStandAloneMuon() && mu1->isTrackerMuon()) mu1tracker=true;
225 
226  if (mu0global && mu1global) n_[0]++;
227  if ( (mu0global && mu1trackerSta) || (mu1global && mu0trackerSta) ) n_[1]++;
228  if ( (mu0global && mu1sta) || (mu1global && mu0sta) ) n_[2]++;
229  if ( (mu0global && mu1tracker) || (mu1global && mu0tracker) ) n_[3]++;
230  if (mu0trackerSta && mu1trackerSta) n_[4]++;
231  if ( (mu0trackerSta && mu1sta) || (mu1trackerSta && mu0sta) ) n_[5]++;
232  if ( (mu0trackerSta && mu1tracker) || (mu1trackerSta && mu0tracker) ) n_[6]++;
233  if (mu0sta && mu1sta) n_[7]++;
234  if ( (mu0sta && mu1tracker) || (mu1sta && mu0tracker) ) n_[8]++;
235  if (mu0tracker && mu1tracker) n_[9]++;
236 
237  }
238  return n_;
239 }
virtual bool isStandAloneMuon() const =0
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
size_type size() const
RefToBase< value_type > refAt(size_type i) const
virtual bool isTrackerMuon() const =0
virtual bool isGlobalMuon() const =0
vector< int > dimuonHLTFilterCheck::nMuonsByType ( const Handle< CandidateView d)
private

Definition at line 241 of file dimuonHLTFilterCheck.cc.

References gather_cfg::cout, mps_fire::i, reco::Candidate::isGlobalMuon(), reco::Candidate::isStandAloneMuon(), reco::Candidate::isTrackerMuon(), edm::View< T >::refAt(), and edm::View< T >::size().

Referenced by analyze().

241  {
242  vector<int> n_;
243  int nCat = 4; // number of muon categories (0 = glb, 1 = trkSta, 2 = sta, 3 = trk)
244  // reset vector
245  for (int i=0; i<nCat; i++) n_.push_back(0);
246  for(unsigned int i = 0; i < d->size(); ++i) { //loop on candidates
247  // const Candidate & dCand = (*d)[i]; //the candidate
248  bool muglobal = false;
249  bool mutrackerSta = false;
250  bool musta = false;
251  bool mutracker = false;
252  CandidateBaseRef muCandRef = d->refAt(i);
253  if (muCandRef->isGlobalMuon()) muglobal=true;
254  if (! muCandRef->isGlobalMuon() && muCandRef->isStandAloneMuon() && muCandRef->isTrackerMuon()) mutrackerSta=true;
255  if (! muCandRef->isGlobalMuon() && muCandRef->isStandAloneMuon() && ! muCandRef->isTrackerMuon()) musta=true;
256  if (! muCandRef->isGlobalMuon() && ! muCandRef->isStandAloneMuon() && muCandRef->isTrackerMuon()) mutracker=true;
257  cout << "muglobal " << muglobal << " mutrackserSta " << mutrackerSta << " must " << musta << " mutracker " << mutracker << endl;
258  if (muglobal) n_[0]++;
259  if (mutrackerSta) n_[1]++;
260  if (musta) n_[2]++;
261  if (mutracker) n_[3]++;
262 
263  }
264  return n_;
265 }
virtual bool isStandAloneMuon() const =0
size_type size() const
RefToBase< value_type > refAt(size_type i) const
virtual bool isTrackerMuon() const =0
virtual bool isGlobalMuon() const =0

Member Data Documentation

EDGetTokenT<CandidateView> dimuonHLTFilterCheck::anyDimuonToken
private

Definition at line 53 of file dimuonHLTFilterCheck.cc.

Referenced by analyze().

int dimuonHLTFilterCheck::counterMatrix[5][5]
private

Definition at line 59 of file dimuonHLTFilterCheck.cc.

Referenced by analyze(), dimuonHLTFilterCheck(), and endJob().

EDGetTokenT<CandidateView> dimuonHLTFilterCheck::muonToken
private

Definition at line 52 of file dimuonHLTFilterCheck.cc.

Referenced by analyze().

EDGetTokenT<CandidateView> dimuonHLTFilterCheck::tracksToken
private

Definition at line 51 of file dimuonHLTFilterCheck.cc.

Referenced by analyze().

EDGetTokenT<TriggerResults> dimuonHLTFilterCheck::triggerResultsToken
private

Definition at line 50 of file dimuonHLTFilterCheck.cc.

Referenced by analyze().