CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuScleFit.h
Go to the documentation of this file.
1 #ifndef MuScleFit_H
2 #define MuScleFit_H
3 
12 // Base Class Headers
13 // ------------------
17 #include <CLHEP/Vector/LorentzVector.h>
18 #include <vector>
19 // #include "Histograms.h"
23 #include "MuScleFitBase.h"
24 
28 // The following is required in CMSSW v2.0.x (was contained in Muon.h in 1.6.7)
34 
35 #include "MuScleFitMuonSelector.h"
36 
37 namespace edm {
38  class ParameterSet;
39  class Event;
40  class EventSetup;
41 }
42 
43 class TH1F;
44 class TH2F;
45 class TProfile;
46 class MuonServiceProxy;
47 class TTree;
48 class MuScleFitPlotter;
49 
51 {
52  public:
53  // Constructor
54  // -----------
55  MuScleFit( const edm::ParameterSet& pset );
56 
57  // Destructor
58  // ----------
59  virtual ~MuScleFit();
60 
61  // Operations
62  // ----------
64  // void beginOfJob( const edm::EventSetup& eventSetup );
65  // virtual void beginOfJob();
66  virtual void endOfJob();
67 
68  virtual void startingNewLoop( unsigned int iLoop );
69 
70  virtual edm::EDLooper::Status endOfLoop( const edm::EventSetup& eventSetup, unsigned int iLoop );
71  virtual void endOfFastLoop( const unsigned int iLoop );
72 
73  virtual edm::EDLooper::Status duringLoop( const edm::Event & event, const edm::EventSetup& eventSetup );
78  virtual void duringFastLoop();
79 
80  template<typename T>
81  std::vector<reco::LeafCandidate> fillMuonCollection( const std::vector<T>& tracks );
82  private:
83 
84  protected:
89  void selectMuons(const edm::Event & event);
95  void selectMuons(const int maxEvents, const TString & treeFileName);
96 
98  template<typename T>
99  void takeSelectedMuonType(const T & muon, std::vector<reco::Track> & tracks);
101  bool selGlobalMuon(const pat::Muon* aMuon);
102  bool selTrackerMuon(const pat::Muon* aMuon);
103 
107  void fillComparisonHistograms( const reco::Particle::LorentzVector & genMu, const reco::Particle::LorentzVector & recoMu, const std::string & inputName, const int charge );
108 
112  void applyBias( reco::Particle::LorentzVector & mu, const int charge );
113 
118  void checkParameters();
119 
121 
122  // Counters
123  // --------
124  int numberOfSimTracks;
125  int numberOfSimMuons;
127  int numberOfEwkZ;
128 
129  bool ifHepMC;
130  bool ifGenPart;
131 
132  // Constants
133  // ---------
134  double minResMass_hwindow[6];
135  double maxResMass_hwindow[6];
136 
137  // Total number of loops
138  // ---------------------
139  unsigned int maxLoopNumber;
140  unsigned int loopCounter;
141 
142  bool fastLoop;
143 
145 
146  // The reconstructed muon 4-momenta to be put in the tree
147  // ------------------------------------------------------
149  int iev;
150  int totalEvents_;
151 
152  bool compareToSimTracks_;
154  bool PATmuons_;
156 
157  // Input Root Tree file name. If empty events are read from the edm root file.
159  // Output Root Tree file name. If not empty events are dumped to this file at the end of the last iteration.
161  // Maximum number of events from root tree. It works in the same way as the maxEvents to configure a input source.
163 
167  bool negateTrigger_;
168  bool saveAllToTree_;
169 
170  std::auto_ptr<MuScleFitMuonSelector> muonSelector_;
171 };
172 
173 template<typename T>
174 std::vector<reco::LeafCandidate> MuScleFit::fillMuonCollection( const std::vector<T>& tracks )
175 {
176  std::vector<reco::LeafCandidate> muons;
177  typename std::vector<T>::const_iterator track;
178  for( track = tracks.begin(); track != tracks.end(); ++track ) {
180  mu = reco::Particle::LorentzVector(track->px(),track->py(),track->pz(),
181  sqrt(track->p()*track->p() + MuScleFitUtils::mMu2));
182  // Apply smearing if needed, and then bias
183  // ---------------------------------------
185  if (debug_>0)
186  std::cout <<std::setprecision(9)<< "Muon #" << MuScleFitUtils::goodmuon
187  << ": initial value Pt = " << mu.Pt() << std::endl;
188 
189  applySmearing(mu);
190  applyBias(mu, track->charge());
191 
192  reco::LeafCandidate muon(track->charge(),mu);
193  // Store modified muon
194  // -------------------
195  muons.push_back (muon);
196  }
197  return muons;
198 }
199 
200 template<typename T>
201 void MuScleFit::takeSelectedMuonType(const T & muon, std::vector<reco::Track> & tracks)
202 {
203  // std::cout<<"muon "<<muon->isGlobalMuon()<<muon->isStandAloneMuon()<<muon->isTrackerMuon()<<std::endl;
204  //NNBB: one muon can be of many kinds at once but with the theMuonType_ we are sure
205  // to avoid double counting of the same muon
206  if(muon->isGlobalMuon() && theMuonType_==1)
207  tracks.push_back(*(muon->globalTrack()));
208  else if(muon->isStandAloneMuon() && theMuonType_==2)
209  tracks.push_back(*(muon->outerTrack()));
210  else if(muon->isTrackerMuon() && theMuonType_==3)
211  tracks.push_back(*(muon->innerTrack()));
212 
213  else if( theMuonType_ == 10 && !(muon->isStandAloneMuon()) ) //particular case!!
214  tracks.push_back(*(muon->innerTrack()));
215  else if( theMuonType_ == 11 && muon->isGlobalMuon() )
216  tracks.push_back(*(muon->innerTrack()));
217  else if( theMuonType_ == 13 && muon->isTrackerMuon() )
218  tracks.push_back(*(muon->innerTrack()));
219 }
220 
221 #endif
void selectMuons(const edm::Event &event)
Definition: MuScleFit.cc:825
virtual edm::EDLooper::Status endOfLoop(const edm::EventSetup &eventSetup, unsigned int iLoop)
Definition: MuScleFit.cc:665
double maxResMass_hwindow[6]
Definition: MuScleFit.cc:270
bool selGlobalMuon(const pat::Muon *aMuon)
Function for onia selections.
Definition: MuScleFit.cc:1358
unsigned int loopCounter
Definition: MuScleFit.cc:275
int totalEvents_
Definition: MuScleFit.cc:285
std::string triggerResultsProcess_
Definition: MuScleFit.cc:300
bool saveAllToTree_
Definition: MuScleFit.cc:303
virtual void duringFastLoop()
Definition: MuScleFit.cc:966
void checkParameters()
Definition: MuScleFit.cc:1271
bool selTrackerMuon(const pat::Muon *aMuon)
Definition: MuScleFit.cc:1379
bool ifHepMC
Definition: MuScleFit.cc:264
edm::InputTag simTracksCollection_
Definition: MuScleFit.cc:288
void fillComparisonHistograms(const reco::Particle::LorentzVector &genMu, const reco::Particle::LorentzVector &recoMu, const std::string &inputName, const int charge)
Fill the reco vs gen and reco vs sim comparison histograms.
Definition: MuScleFit.cc:1234
double charge(const std::vector< uint8_t > &Ampls)
std::vector< reco::LeafCandidate > fillMuonCollection(const std::vector< T > &tracks)
Definition: MuScleFit.cc:309
MuonServiceProxy * theService
Definition: MuScleFit.cc:255
std::string outputRootTreeFileName_
Definition: MuScleFit.cc:295
int numberOfSimVertices
Definition: MuScleFit.cc:261
virtual void startingNewLoop(unsigned int iLoop)
Definition: MuScleFit.cc:638
reco::Particle::LorentzVector recMu2
Definition: MuScleFit.cc:283
double minResMass_hwindow[6]
Definition: MuScleFit.cc:269
bool PATmuons_
Definition: MuScleFit.cc:289
virtual void endOfJob()
Definition: MuScleFit.cc:632
reco::Particle::LorentzVector recMu1
Definition: MuScleFit.cc:283
T sqrt(T t)
Definition: SSEVec.h:48
unsigned int maxLoopNumber
Definition: MuScleFit.cc:274
std::string genParticlesName_
Definition: MuScleFit.cc:290
bool compareToSimTracks_
Definition: MuScleFit.cc:287
const int mu
Definition: Constants.h:23
MuScleFit(const edm::ParameterSet &pset)
Definition: MuScleFit.cc:359
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
void beginOfJobInConstructor()
Definition: MuScleFit.cc:603
std::string triggerPath_
Definition: MuScleFit.h:166
bool fastLoop
Definition: MuScleFit.cc:277
int numberOfSimMuons
Definition: MuScleFit.cc:260
void applySmearing(reco::Particle::LorentzVector &mu)
Apply the smearing if needed using the function in MuScleFitUtils.
Definition: MuScleFit.cc:1251
virtual ~MuScleFit()
Definition: MuScleFit.cc:577
int numberOfSimTracks
Definition: MuScleFit.cc:259
tuple tracks
Definition: testEve_cfg.py:39
std::string triggerResultsLabel_
Definition: MuScleFit.cc:299
static int goodmuon
static const double mMu2
tuple muons
Definition: patZpeak.py:38
std::string inputRootTreeFileName_
Definition: MuScleFit.cc:293
bool checkDeltaR(reco::Particle::LorentzVector &genMu, reco::Particle::LorentzVector &recMu)
Check if two lorentzVector are near in deltaR.
Definition: MuScleFit.cc:1220
std::auto_ptr< MuScleFitMuonSelector > muonSelector_
Definition: MuScleFit.cc:305
int maxEventsFromRootTree_
Definition: MuScleFit.cc:297
tuple cout
Definition: gather_cfg.py:121
void takeSelectedMuonType(const T &muon, std::vector< reco::Track > &tracks)
Template method used to fill the track collection starting from reco::muons or pat::muons.
Definition: MuScleFit.cc:336
long double T
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:25
Analysis-level muon class.
Definition: Muon.h:51
void applyBias(reco::Particle::LorentzVector &mu, const int charge)
Apply the bias if needed using the function in MuScleFitUtils.
Definition: MuScleFit.cc:1260
bool negateTrigger_
Definition: MuScleFit.cc:302
bool ifGenPart
Definition: MuScleFit.cc:265
MuScleFitPlotter * plotter
Definition: MuScleFit.cc:279
virtual edm::EDLooper::Status duringLoop(const edm::Event &event, const edm::EventSetup &eventSetup)
Definition: MuScleFit.cc:748
virtual void endOfFastLoop(const unsigned int iLoop)
Definition: MuScleFit.cc:712
int numberOfEwkZ
Definition: MuScleFit.cc:262