CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuTriggerAnalyzer Class Reference
Inheritance diagram for MuTriggerAnalyzer:
edm::EDAnalyzer

Public Member Functions

 MuTriggerAnalyzer (const edm::ParameterSet &pset)
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

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

Private Attributes

TH1D * deltaPtOverPt_
 
TH1D * deltaR_
 
double etaMuCut_
 
edm::Handle
< trigger::TriggerEvent
handleTriggerEvent_
 
std::string hltPath_
 
TH1D * hTrigMuonPtDenS_
 
TH1D * hTrigMuonPtNumS_
 
std::string L3FilterName_
 
double maxDeltaR_
 
double maxDPtRel_
 
edm::InputTag muonTag_
 
const int nbins_
 
const double ptMax_
 
double ptMuCut_
 
edm::InputTag trigEv_
 
edm::Handle< edm::TriggerResultstriggerResults_
 
edm::TriggerNames const * trigNames_
 
edm::InputTag trigTag_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 49 of file MuTriggerAnalyzer.cc.

Constructor & Destructor Documentation

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

Definition at line 112 of file MuTriggerAnalyzer.cc.

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

112  :
113  trigTag_(cfg.getParameter<edm::InputTag> ("TrigTag")),
114  trigEv_(cfg.getParameter<edm::InputTag> ("triggerEvent")),
115  muonTag_(cfg.getUntrackedParameter<edm::InputTag>("muons")),
116  ptMuCut_(cfg.getUntrackedParameter<double>("ptMuCut")),
117  etaMuCut_(cfg.getUntrackedParameter<double>("etaMuCut")),
118  hltPath_(cfg.getParameter<std::string >("hltPath")),
119  L3FilterName_(cfg.getParameter<std::string >("L3FilterName")),
120  maxDPtRel_(cfg.getParameter<double>("maxDPtRel")),
121  maxDeltaR_(cfg.getParameter<double>("maxDeltaR")),
122  nbins_(cfg.getParameter<double>("ptMax_")),
123  ptMax_(cfg.getParameter<double>("ptMax_")){
125 
126  hTrigMuonPtNumS_ = fs->make<TH1D>("hTrigMuonPtNumS", "hTrigMuonPtNumS", nbins_ + 1, 0, ptMax_);
127  hTrigMuonPtDenS_ = fs->make<TH1D>("hTrigMuonPtDenS", "hTrigMuonPtDenS", nbins_ +1 , 0, ptMax_);
128  deltaR_ = fs->make<TH1D>("deltaR", "deltaR", nbins_+1, 0, maxDeltaR_);
129  deltaPtOverPt_ = fs->make<TH1D>("deltaPtOverPt", "deltaPtOverPt", nbins_ + 1, 0, maxDPtRel_);
130 
131 }
edm::InputTag trigEv_
edm::InputTag muonTag_
T * make() const
make new ROOT object
edm::InputTag trigTag_
std::string L3FilterName_

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 142 of file MuTriggerAnalyzer.cc.

References gather_cfg::cout, edm::InputTag::encode(), reco::LeafCandidate::eta(), eta(), etaMuCut_, edm::Event::getByLabel(), hltPath_, i, reco::Muon::isGlobalMuon(), IsMuMatchedToHLTMu(), gen::k, L3FilterName_, maxDeltaR_, maxDPtRel_, patZpeak::muons, muonTag_, mergeVDriftHistosByStation::name, L1TEmulatorMonitor_cff::p, reco::LeafCandidate::p4(), reco::LeafCandidate::pt(), ptMuCut_, trigEv_, edm::TriggerNames::triggerName(), edm::Event::triggerNames(), trigNames, trigNames_, and trigTag_.

142  {
143  bool singleTrigFlag1 = false;
144  // bool overlap = false;
145 
146  // Trigger
147  Handle<TriggerResults> triggerResults;
149  if (!ev.getByLabel(trigTag_, triggerResults)) {
150  LogWarning("") << ">>> TRIGGER collection does not exist !!!";
151  return;
152  }
153  ev.getByLabel(trigTag_, triggerResults);
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.getByLabel( trigEv_, handleTriggerEvent )) {
168  LogWarning( "errorTriggerEventValid" ) << "trigger::TriggerEvent product with InputTag " << trigEv_.encode() << " not in event";
169  return;
170  }
171  ev.getByLabel( trigEv_, handleTriggerEvent );
172  const trigger::TriggerObjectCollection & toc(handleTriggerEvent->getObjects());
173  size_t nMuHLT =0;
174  std::vector<reco::Particle> HLTMuMatched;
175  for ( size_t ia = 0; ia < handleTriggerEvent->sizeFilters(); ++ ia) {
176  std::string fullname = handleTriggerEvent->filterTag(ia).encode();
177  std::string name;
178  size_t p = fullname.find_first_of(':');
179  if ( p != std::string::npos) {
180  name = fullname.substr(0, p);
181  }
182  else {
183  name = fullname;
184  }
185  if ( &toc !=0 ) {
186  const trigger::Keys & k = handleTriggerEvent->filterKeys(ia);
187  for (trigger::Keys::const_iterator ki = k.begin(); ki !=k.end(); ++ki ) {
188  if (name == L3FilterName_ ) {
189  HLTMuMatched.push_back(toc[*ki].particle());
190  nMuHLT++;
191  }
192  }
193  }
194  }
195 
196  // looping on muon....
198  if (!ev.getByLabel(muonTag_, muons)) {
199  LogError("") << ">>> muon collection does not exist !!!";
200  return;
201  }
202 
203  ev.getByLabel(muonTag_, muons);
204  //saving only muons with pt> ptMuCut and eta<etaMuCut
205  std::vector<reco::Muon> highPtGlbMuons;
206 
207  for (unsigned int i=0; i<muons->size(); i++ ){
208  const reco::Muon & mu = muons->at(i);
209  double pt = mu.pt();
210  double eta = mu.eta();
211  if (pt> ptMuCut_ && fabs(eta)< etaMuCut_) {
212  if (mu.isGlobalMuon()) highPtGlbMuons.push_back(mu);
213  }
214  }
215  unsigned int nHighPtGlbMu = highPtGlbMuons.size();
216  std::cout << "I've got " << nHighPtGlbMu << " nHighPtGlbMu" << std::endl;
217  // unsigned int nHighPtStaMu = highPtStaMuons.size();
218 
219  // stop the loop after 10 cicles....
220  (nHighPtGlbMu> 10)? nHighPtGlbMu=10 : 1;
221 
222  if (nHighPtGlbMu>0 ){
223 
224  for(unsigned int i =0 ; i < nHighPtGlbMu ; i++) {
225  reco::Muon muon1 = highPtGlbMuons[i];
226  math::XYZTLorentzVector mu1(muon1.p4());
227  // double pt1= muon1.pt();
228 
229  singleTrigFlag1 = IsMuMatchedToHLTMu ( muon1, HLTMuMatched ,maxDeltaR_, maxDPtRel_ );
230 
231  }
232 
233  }
234 
235 }
int i
Definition: DBlmapReader.cc:9
edm::InputTag trigEv_
bool isGlobalMuon() const
Definition: Muon.h:148
edm::TriggerNames const * trigNames_
T eta() const
Strings const & triggerNames() const
Definition: TriggerNames.cc:24
std::string encode() const
Definition: InputTag.cc:72
virtual double eta() const
momentum pseudorapidity
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
int k[5][pyjets_maxn]
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:83
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:75
virtual double pt() const
transverse momentum
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
std::vector< size_type > Keys
bool IsMuMatchedToHLTMu(const reco::Muon &, std::vector< reco::Particle >, double, double)
edm::InputTag muonTag_
tuple muons
Definition: patZpeak.py:38
tuple cout
Definition: gather_cfg.py:41
edm::InputTag trigTag_
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
std::string L3FilterName_
void MuTriggerAnalyzer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 133 of file MuTriggerAnalyzer.cc.

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

133  {
134  for (int i = 0; i < nbins_+1; ++i){
135  std::cout << "number of reco muon in bin " << i << " = " << hTrigMuonPtDenS_->GetBinContent(i) << std::endl;
136  std::cout << "number of hlt muon in bin " << i << " = " << hTrigMuonPtNumS_->GetBinContent(i) << std::endl;
137 
138 
139  }
140 }
int i
Definition: DBlmapReader.cc:9
tuple cout
Definition: gather_cfg.py:41
bool MuTriggerAnalyzer::IsMuMatchedToHLTMu ( const reco::Muon mu,
std::vector< reco::Particle HLTMu,
double  DR,
double  DPtRel 
)
private

Definition at line 79 of file MuTriggerAnalyzer.cc.

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

Referenced by analyze().

79  {
80  size_t dim = HLTMu.size();
81  size_t nPass=0;
82 
83  // filling the denumerator;
84  double muRecoPt= mu.pt();
85  hTrigMuonPtDenS_-> Fill(muRecoPt);
86 
87  if (dim==0) return false;
88  for (size_t k =0; k< dim; k++ ) {
89  if ( (deltaR(HLTMu[k], mu) < DR) && (fabs(HLTMu[k].pt() - mu.pt())/ HLTMu[k].pt()<DPtRel)){
90  nPass++ ;
91  std::cout<< " matching a muon " << std::endl;
92  std::cout << "muon reco pt : " << muRecoPt<< std::endl;
93  std::cout << "muon reco eta " << mu.eta() << std::endl;
94  std::cout << "muon trigger pt "<< HLTMu[k].pt() << std::endl;
95  // filling the numerator, at the same bin as the denum.....
96  hTrigMuonPtNumS_-> Fill(muRecoPt);
97  deltaR_-> Fill(deltaR(HLTMu[k], mu));
98  deltaPtOverPt_-> Fill(fabs(HLTMu[k].pt() - mu.pt())/ HLTMu[k].pt());
99 
100 
101  std::cout << "muon trigger eta : "<< HLTMu[k].eta() << std::endl;
102  std::cout <<"deltaR((HLTMu[k], mu)): "<< deltaR(HLTMu[k], mu) << std::endl;
103  std::cout <<"deltaPtOverPt: "<< fabs(HLTMu[k].pt() - mu.pt())/ HLTMu[k].pt() << std::endl;
104  }
105  }
106 
107  return (nPass>0);
108 }
virtual double eta() const
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
virtual double pt() const
transverse momentum
tuple cout
Definition: gather_cfg.py:41

Member Data Documentation

TH1D* MuTriggerAnalyzer::deltaPtOverPt_
private

Definition at line 74 of file MuTriggerAnalyzer.cc.

Referenced by MuTriggerAnalyzer().

TH1D* MuTriggerAnalyzer::deltaR_
private

Definition at line 73 of file MuTriggerAnalyzer.cc.

Referenced by MuTriggerAnalyzer().

double MuTriggerAnalyzer::etaMuCut_
private

Definition at line 61 of file MuTriggerAnalyzer.cc.

Referenced by analyze().

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

Definition at line 66 of file MuTriggerAnalyzer.cc.

std::string MuTriggerAnalyzer::hltPath_
private

Definition at line 62 of file MuTriggerAnalyzer.cc.

Referenced by analyze().

TH1D* MuTriggerAnalyzer::hTrigMuonPtDenS_
private

Definition at line 72 of file MuTriggerAnalyzer.cc.

Referenced by endJob(), and MuTriggerAnalyzer().

TH1D* MuTriggerAnalyzer::hTrigMuonPtNumS_
private

Definition at line 71 of file MuTriggerAnalyzer.cc.

Referenced by endJob(), and MuTriggerAnalyzer().

std::string MuTriggerAnalyzer::L3FilterName_
private

Definition at line 63 of file MuTriggerAnalyzer.cc.

Referenced by analyze().

double MuTriggerAnalyzer::maxDeltaR_
private

Definition at line 68 of file MuTriggerAnalyzer.cc.

Referenced by analyze(), and MuTriggerAnalyzer().

double MuTriggerAnalyzer::maxDPtRel_
private

Definition at line 68 of file MuTriggerAnalyzer.cc.

Referenced by analyze(), and MuTriggerAnalyzer().

edm::InputTag MuTriggerAnalyzer::muonTag_
private

Definition at line 60 of file MuTriggerAnalyzer.cc.

Referenced by analyze().

const int MuTriggerAnalyzer::nbins_
private

Definition at line 69 of file MuTriggerAnalyzer.cc.

Referenced by endJob(), and MuTriggerAnalyzer().

const double MuTriggerAnalyzer::ptMax_
private

Definition at line 70 of file MuTriggerAnalyzer.cc.

Referenced by MuTriggerAnalyzer().

double MuTriggerAnalyzer::ptMuCut_
private

Definition at line 61 of file MuTriggerAnalyzer.cc.

Referenced by analyze().

edm::InputTag MuTriggerAnalyzer::trigEv_
private

Definition at line 59 of file MuTriggerAnalyzer.cc.

Referenced by analyze().

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

Definition at line 64 of file MuTriggerAnalyzer.cc.

edm::TriggerNames const* MuTriggerAnalyzer::trigNames_
private

Definition at line 65 of file MuTriggerAnalyzer.cc.

Referenced by analyze().

edm::InputTag MuTriggerAnalyzer::trigTag_
private

Definition at line 58 of file MuTriggerAnalyzer.cc.

Referenced by analyze().