CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TriggerMatcherToHLTDebug.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MuonAnalysis/MuonAssociators
4 // Class: TriggerMatcherToHLTDebug
5 //
13 //
14 // Original Author: Cristina Botta (Torino), Giovanni Petrucciani (UCSD)
15 // Created: Fri 30 Apr 2010
16 // $Id: TriggerMatcherToHLTDebug.cc,v 1.6 2013/02/27 20:42:46 wmtan Exp $
17 //
18 
19 
21 
23 
27 
30 
39 
40 //new for association map
49 
50 
55 
64 
68 
69 
70 
71 
72 
73 
75 
76  public:
77  // Constructor
78  explicit TriggerMatcherToHLTDebug(const edm::ParameterSet &pset);
79 
81  virtual ~TriggerMatcherToHLTDebug();
82 
83  // Operations
84  void produce(edm::Event & event, const edm::EventSetup& eventSetup) override;
85  void beginRun(const edm::Run &run, const edm::EventSetup &eventSetup) override;
86 
87  private:
90 
92 
93  //ForL1Assoc
94  double deltaR_;
95 
96  //ForL1Quality
98 
99  //ForL2Filter
101  int min_N_L2;
102  double max_Eta_L2;
104  double max_Dr_L2;
105  double max_Dz_L2;
106  double min_Pt_L2;
107  double nsigma_Pt_L2;
108 
109  //ForL3Filter
110  int min_N_L3;
111  double max_Eta_L3;
113  double max_Dr_L3;
114  double max_Dz_L3;
115  double min_Pt_L3;
116  double nsigma_Pt_L3;
117 
124 
125 
127 
128 
130  template<typename T>
133  const std::vector<T> & values,
134  const std::string & label) const ;
135 
136 };
137 
138 using namespace std;
139 using namespace edm;
140 using namespace l1extra;
141 using namespace reco;
142 
143 // Constructor
145  tagTag_(pset.getParameter<edm::InputTag>("tags")),
146  l1Tag_(pset.getParameter<edm::InputTag>("l1s")),
147  l1matcher_(pset.getParameter<edm::ParameterSet>("l1matcherConfig")),
148  deltaR_(pset.getParameter<double>("deltaR")),
149  minL1Quality_(pset.getParameter<int32_t>("MinL1Quality")),
150  beamspotTag_(pset.getParameter<edm::InputTag>("BeamSpotTag")),
151  min_N_L2(pset.getParameter<int> ("MinN_L2")),
152  max_Eta_L2(pset.getParameter<double> ("MaxEta_L2")),
153  min_Nhits_L2(pset.getParameter<int> ("MinNhits_L2")),
154  max_Dr_L2(pset.getParameter<double> ("MaxDr_L2")),
155  max_Dz_L2(pset.getParameter<double> ("MaxDz_L2")),
156  min_Pt_L2(pset.getParameter<double> ("MinPt_L2")),
157  nsigma_Pt_L2(pset.getParameter<double> ("NSigmaPt_L2")),
158  min_N_L3(pset.getParameter<int> ("MinN_L3")),
159  max_Eta_L3(pset.getParameter<double> ("MaxEta_L3")),
160  min_Nhits_L3(pset.getParameter<int> ("MinNhits_L3")),
161  max_Dr_L3(pset.getParameter<double> ("MaxDr_L3")),
162  max_Dz_L3(pset.getParameter<double> ("MaxDz_L3")),
163  min_Pt_L3(pset.getParameter<double> ("MinPt_L3")),
164  nsigma_Pt_L3(pset.getParameter<double> ("NSigmaPt_L3")),
165  seedMapTag_(pset.getParameter<edm::InputTag >("SeedMapTag"))
166 {
167 
168 
169  theL2SeedsLabel = pset.getParameter<InputTag>("L2Seeds_Collection");
170  theL2MuonsLabel = pset.getParameter<InputTag>("L2Muons_Collection");
171  theL3SeedsLabel = pset.getParameter<InputTag>("L3Seeds_Collection");
172  theL3TkTracksLabel = pset.getParameter<InputTag>("L3TkTracks_Collection");
173  theL3MuonsLabel = pset.getParameter<InputTag>("L3Muons_Collection");
174 
175 
176  metname = "TriggerMatcherToHLTDebug";
177 
178  produces<edm::ValueMap<int> > ("propagatesToM2");
179  produces<edm::ValueMap<int> > ("hasL1Particle");
180  produces<edm::ValueMap<int> > ("hasL1Filtered");
181  produces<edm::ValueMap<int> > ("hasL2Seed");
182  produces<edm::ValueMap<int> > ("hasL2Muon");
183  produces<edm::ValueMap<int> > ("hasL2MuonFiltered");
184  produces<edm::ValueMap<int> > ("hasL3Seed");
185  produces<edm::ValueMap<int> > ("hasL3Track");
186  produces<edm::ValueMap<int> > ("hasL3Muon");
187  produces<edm::ValueMap<int> > ("hasL3MuonFiltered");
188 
189  produces<edm::ValueMap<reco::CandidatePtr> > ("l1Candidate");
190  produces<edm::ValueMap<reco::CandidatePtr> > ("l2Candidate");
191  produces<edm::ValueMap<reco::CandidatePtr> > ("l3Candidate");
192 }
193 
194 
195 
196 // Destructor
198 
199 // Analyzer
201 
203  event.getByLabel(tagTag_,muons);
204 
206  event.getByLabel(l1Tag_,L1Muons);
207 
209  event.getByLabel(theL2SeedsLabel,L2Seeds);
210 
212  event.getByLabel(theL2MuonsLabel,L2Muons);
213 
215  event.getByLabel(theL3SeedsLabel,L3Seeds);
216 
218  event.getByLabel(theL3TkTracksLabel,L3TkTracks);
219 
221  event.getByLabel(theL3MuonsLabel,L3Muons);
222 
223  //beam spot
225  Handle<BeamSpot> recoBeamSpotHandle;
226  event.getByLabel(beamspotTag_,recoBeamSpotHandle);
227  beamSpot = *recoBeamSpotHandle;
228 
229  //new for the MAP!!!!
230  edm::Handle<SeedMap> seedMapHandle;
231  event.getByLabel(seedMapTag_, seedMapHandle);
232 
233 
234  size_t nmu = muons->size();
235  std::vector<int> propagatesToM2(nmu), hasL1Particle(nmu), hasL1Filtered(nmu);
236  std::vector<int> hasL2Seed(nmu), hasL2Muon(nmu), hasL2MuonFiltered(nmu);
237  std::vector<int> hasL3Seed(nmu), hasL3Track(nmu), hasL3TrackFiltered(nmu), hasL3Muon(nmu), hasL3MuonFiltered(nmu);
238  std::vector<reco::CandidatePtr> l1ptr(nmu), l2ptr(nmu), l3ptr(nmu);
239 
240  for (size_t i = 0; i < nmu; ++i) {
241  const reco::Muon &mu = (*muons)[i];
242 
243  // Propagate to muon station (using the L1 tool)
245  if (!stateAtMB2.isValid()) continue;
246  propagatesToM2[i] = 1;
247 
248  double etaTk = stateAtMB2.globalPosition().eta();
249  double phiTk = stateAtMB2.globalPosition().phi();
250  l1extra::L1MuonParticleCollection::const_iterator it;
251  vector<l1extra::L1MuonParticleRef>::const_iterator itMu3;
252  L2MuonTrajectorySeedCollection::const_iterator iSeed;
253  L3MuonTrajectorySeedCollection::const_iterator iSeedL3;
254  RecoChargedCandidateCollection::const_iterator iL2Muon;
255  reco::TrackCollection::const_iterator tktrackL3;
256  RecoChargedCandidateCollection::const_iterator iL3Muon;
257 
258  reco::CandidatePtr thisL1, thisL2, thisL3;
259  for(it = L1Muons->begin(); it != L1Muons->end(); ++it) {
260 
261  const L1MuGMTExtendedCand muonCand = (*it).gmtMuonCand();
262  unsigned int quality = muonCand.quality();
263 
264  double L1phi =(*it).phi();
265  double L1eta =(*it).eta();
266  double L1pt =(*it).pt();
267  double dR=deltaR(etaTk,phiTk,L1eta,L1phi);
268 
269  //CONDIZIONE-> CE NE E' UNA ASSOCIATA?
270  if (dR >= deltaR_) continue;
271  thisL1 = reco::CandidatePtr(L1Muons, it - L1Muons->begin());
272  if (!hasL1Particle[i]) l1ptr[i] = thisL1; // if nobody reached L1 before, then we're the best L1 found up to now.
273  hasL1Particle[i]++;
274 
275  if ((quality <= 3) || (L1pt<7)) continue;
276  if (!hasL1Filtered[i]) l1ptr[i] = thisL1; // if nobody reached L1 before, then we're the best L1 found up to now.
277  hasL1Filtered[i]++;
278 
279  if(!L2Seeds.isValid()) continue;
280  //LOOP SULLA COLLEZIONE DEI SEED
281  for( iSeed = L2Seeds->begin(); iSeed != L2Seeds->end(); ++iSeed) {
282 
283  l1extra::L1MuonParticleRef l1FromSeed = iSeed->l1Particle();
284  if (l1FromSeed.id() != L1Muons.id()) throw cms::Exception("CorruptData") << "You're using a different L1 collection than the one used by L2 seeds.\n";
285  if (l1FromSeed.key() != thisL1.key()) continue;
286  if (!hasL2Seed[i]) l1ptr[i] = thisL1; // if nobody reached here before, we're the best L1
287  hasL2Seed[i]++;
288 
289  if(!L2Muons.isValid()) continue;
290  //LOOP SULLA COLLEZIONE L2MUON
291  for( iL2Muon = L2Muons->begin(); iL2Muon != L2Muons->end(); ++iL2Muon) {
292 
293 
294  //MI FACCIO DARE REF E GUARDO SE E' UGUALE AL L2SEED ASSOCIATO
295  //BEFORE THE ASSOCIATION MAP!!!!!
296  //edm::Ref<L2MuonTrajectorySeedCollection> l2seedRef = iL2Muon->track()->seedRef().castTo<edm::Ref<L2MuonTrajectorySeedCollection> >();
297  //l1extra::L1MuonParticleRef l1FromL2 = l2seedRef->l1Particle();
298 
299  //if (l1FromL2.id() != l1FromSeed.id()) throw cms::Exception("CorruptData") << "You're using L2s with a different L1 collection than the one used by L2 seeds.\n";
300  //if (l1FromL2 != l1FromSeed) continue;
301 
302  //AFTER THE ASSOCIATION MAP
303  const edm::RefVector<L2MuonTrajectorySeedCollection>& seeds = (*seedMapHandle)[iL2Muon->track()->seedRef().castTo<edm::Ref<L2MuonTrajectorySeedCollection> >()];
304  // bool isTriggered = false;
305  for(size_t jjj=0; jjj<seeds.size(); jjj++){
306 
307  if(seeds[jjj]->l1Particle()!= l1FromSeed) continue;
308 
309  }
310 
311 
312  thisL2 = reco::CandidatePtr(L2Muons, iL2Muon - L2Muons->begin()) ;
313  if (!hasL2Muon[i]) { l1ptr[i] = thisL1; l2ptr[i] = thisL2; } // if nobody reached here before, we're the best L1 and L2)
314  hasL2Muon[i]++;
315 
316  LogTrace(metname) <<"L2MUON TROVATO!"<<endl;
317  const reco::Track & L2Track = *iL2Muon->track();
318  double Eta_L2= L2Track.eta();
319  double Pt_L2= L2Track.pt();
320  int nValidHits_L2= L2Track.numberOfValidHits();
321  double BSPos_L2 = L2Track.dxy(beamSpot.position());
322  double dz_L2 =L2Track.dz();
323  double err0_L2 = L2Track.error(0);
324  double abspar0_L2 = fabs(L2Track.parameter(0));
325  double ptLx_L2 = Pt_L2;
326  if (abspar0_L2>0) ptLx_L2 += nsigma_Pt_L2*err0_L2/abspar0_L2*Pt_L2;
327 
328  //GUARDO SE L2MUON ASSOCIATO AVREBBE PASSATO IL FILTRO
329  bool passFilter = (((fabs(Eta_L2))<=max_Eta_L2)&&(nValidHits_L2>=min_Nhits_L2)&&((fabs(BSPos_L2))<=max_Dr_L2)&&((fabs(dz_L2))<=max_Dz_L2)&&(ptLx_L2>=min_Pt_L2));
330  if (!passFilter) continue;
331  if (!hasL2MuonFiltered[i]) { l1ptr[i] = thisL1; l2ptr[i] = thisL2; } // if nobody reached here before, we're the best L1 and L2)
332  hasL2MuonFiltered[i]++;
333 
334  const reco::TrackRef L2FilteredRef = iL2Muon->track();
335 
336  //########L3 PART##############
337  if (!L3Seeds.isValid()) continue;
338  for (iSeedL3 = L3Seeds->begin(); iSeedL3!= L3Seeds->end(); ++iSeedL3){
339 
340  TrackRef staTrack = iSeedL3->l2Track();
341  if (staTrack!=L2FilteredRef) continue;
342  if (!hasL3Seed[i]) { l1ptr[i] = thisL1; l2ptr[i] = thisL2; } // if nobody reached here before, we're the best L1 and L2)
343  hasL3Seed[i]++;
344 
345  if (!L3TkTracks.isValid()) continue;
346  for (tktrackL3 = L3TkTracks->begin(); tktrackL3!= L3TkTracks->end(); ++tktrackL3){
347 
349  TrackRef staTrack2 = l3seedRef->l2Track();
350 
351  if (staTrack2!=L2FilteredRef) continue;
352  if (!hasL3Track[i]) { l1ptr[i] = thisL1; l2ptr[i] = thisL2; } // if nobody reached here before, we're the best L1 and L2)
353  hasL3Track[i]++;
354 
355  if (!L3Muons.isValid()) continue;
356  for (iL3Muon = L3Muons->begin(); iL3Muon != L3Muons->end(); ++iL3Muon) {
357 
358  edm::Ref<L3MuonTrajectorySeedCollection> l3seedRef2 = iL3Muon->track()->seedRef().castTo<edm::Ref<L3MuonTrajectorySeedCollection> >();
359  TrackRef staTrack3 = l3seedRef2->l2Track();
360 
361  if (staTrack3!=L2FilteredRef) continue;
362  thisL3 = reco::CandidatePtr(L3Muons, iL3Muon - L3Muons->begin());
363 
364  if (!hasL3Muon[i]) { l1ptr[i] = thisL1; l2ptr[i] = thisL2; l3ptr[i] = thisL3; } // if nobody reached here before, we're the best L1, L2, L3
365  hasL3Muon[i]++;
366 
367  const reco::Track &L3Track = *iL3Muon->track();
368  double Eta_L3= L3Track.eta();
369  double Pt_L3= L3Track.pt();
370  int nValidHits_L3= L3Track.numberOfValidHits();
371  double BSPos_L3 = L3Track.dxy(beamSpot.position());
372  double dz_L3 =L3Track.dz();
373  double err0_L3 = L3Track.error(0);
374  double abspar0_L3 = fabs(L3Track.parameter(0));
375  double ptLx_L3 = Pt_L3;
376 
377  if (abspar0_L3>0) ptLx_L3 += nsigma_Pt_L3*err0_L3/abspar0_L3*Pt_L3;
378 
379  if(((fabs(Eta_L3))<=max_Eta_L3)&&(nValidHits_L3>=min_Nhits_L3)&&((fabs(BSPos_L3))<=max_Dr_L3)&&((fabs(dz_L3))<=max_Dz_L3)&&(ptLx_L3>=min_Pt_L3)){
380 
381  if (!hasL3MuonFiltered[i]) { l1ptr[i] = thisL1; l2ptr[i] = thisL2; l3ptr[i] = thisL3; } // if nobody reached here before, we're the best L1, L2, L3
382  hasL3MuonFiltered[i]++;
383 
384  }//L3MUON FILTERED ASSOCIATO TROVATO
385  }//L3MUON LOOP
386  }// L3 TRACKS
387  }// L3 SEEDS
388  }//T L2 MUONS
389  }// L2 SEEDS
390  }//L1 MUONS
391  } // RECO MUONS
392  storeValueMap<int>(event, muons, propagatesToM2, "propagatesToM2");
393  storeValueMap<int>(event, muons, hasL1Particle, "hasL1Particle");
394  storeValueMap<int>(event, muons, hasL1Filtered, "hasL1Filtered");
395  storeValueMap<int>(event, muons, hasL2Seed, "hasL2Seed");
396  storeValueMap<int>(event, muons, hasL2Muon, "hasL2Muon");
397  storeValueMap<int>(event, muons, hasL2MuonFiltered, "hasL2MuonFiltered");
398  storeValueMap<int>(event, muons, hasL3Seed, "hasL3Seed");
399  storeValueMap<int>(event, muons, hasL3Track, "hasL3Track");
400  storeValueMap<int>(event, muons, hasL3Muon, "hasL3Muon");
401  storeValueMap<int>(event, muons, hasL3MuonFiltered, "hasL3MuonFiltered");
402  storeValueMap<reco::CandidatePtr>(event, muons, l1ptr, "l1Candidate");
403  storeValueMap<reco::CandidatePtr>(event, muons, l2ptr, "l2Candidate");
404  storeValueMap<reco::CandidatePtr>(event, muons, l3ptr, "l3Candidate");
405 } // METHOD
406 
407 void
409  l1matcher_.init(iSetup);
410 }
411 
412 template<typename T>
413 void
416  const std::vector<T> & values,
417  const std::string & label) const {
418  using namespace edm; using namespace std;
419  auto_ptr<ValueMap<T> > valMap(new ValueMap<T>());
420  typename edm::ValueMap<T>::Filler filler(*valMap);
421  filler.insert(handle, values.begin(), values.end());
422  filler.fill();
423  iEvent.put(valMap, label);
424 }
425 
426 
427 
428 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
TrajectoryStateOnSurface extrapolate(const reco::Track &tk) const
Extrapolate reco::Track to the muon station 2, return an invalid TSOS if it fails.
tuple L3Muons
Definition: L3Muons_cfi.py:30
ProductID id() const
Definition: HandleBase.cc:15
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void storeValueMap(edm::Event &iEvent, const edm::Handle< edm::View< reco::Muon > > &handle, const std::vector< T > &values, const std::string &label) const
Store extra information in a ValueMap.
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
double deltaR_
GlobalPoint globalPosition() const
edm::AssociationMap< edm::OneToMany< std::vector< L2MuonTrajectorySeed >, std::vector< L2MuonTrajectorySeed > > > SeedMap
tuple L2Muons
Definition: L2Muons_cfi.py:6
int iEvent
Definition: GenABIO.cc:243
Propagate an object (usually a track) to the second muon station. Support for other muon stations wil...
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:141
TriggerMatcherToHLTDebug(const edm::ParameterSet &pset)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
virtual ~TriggerMatcherToHLTDebug()
Destructor.
double pt() const
track transverse momentum
Definition: TrackBase.h:131
tuple handle
Definition: patZpeak.py:22
double error(int i) const
error on specified element
Definition: TrackBase.h:189
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:232
const int mu
Definition: Constants.h:23
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:76
#define LogTrace(id)
double parameter(int i) const
i-th parameter ( i = 0, ... 4 )
Definition: TrackBase.h:185
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:127
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
unsigned int quality() const
get quality
Definition: L1MuGMTCand.h:95
key_type key() const
Definition: Ptr.h:169
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
key_type key() const
Accessor for product key.
Definition: Ref.h:266
void init(const edm::EventSetup &iSetup)
Call this method at the beginning of each run, to initialize geometry, magnetic field and propagators...
void beginRun(const edm::Run &run, const edm::EventSetup &eventSetup) override
void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
T eta() const
Definition: PV3DBase.h:76
tuple muons
Definition: patZpeak.py:38
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
const Point & position() const
position
Definition: BeamSpot.h:63
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:121
Definition: Run.h:36