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 
10 // Base Class Headers
11 // ------------------
15 #include <CLHEP/Vector/LorentzVector.h>
16 #include <vector>
17 // #include "Histograms.h"
21 #include "MuScleFitBase.h"
22 
26 // The following is required in CMSSW v2.0.x (was contained in Muon.h in 1.6.7)
32 
33 #include "MuScleFitMuonSelector.h"
34 
35 namespace edm {
36  class ParameterSet;
37  class Event;
38  class EventSetup;
39 }
40 
41 class TH1F;
42 class TH2F;
43 class TProfile;
44 class MuonServiceProxy;
45 class TTree;
46 class MuScleFitPlotter;
47 
49 {
50  public:
51  // Constructor
52  // -----------
53  MuScleFit( const edm::ParameterSet& pset );
54 
55  // Destructor
56  // ----------
57  virtual ~MuScleFit();
58 
59  // Operations
60  // ----------
62  // void beginOfJob( const edm::EventSetup& eventSetup );
63  // virtual void beginOfJob();
64  virtual void endOfJob();
65 
66  virtual void startingNewLoop( unsigned int iLoop );
67 
68  virtual edm::EDLooper::Status endOfLoop( const edm::EventSetup& eventSetup, unsigned int iLoop );
69  virtual void endOfFastLoop( const unsigned int iLoop );
70 
71  virtual edm::EDLooper::Status duringLoop( const edm::Event & event, const edm::EventSetup& eventSetup );
76  virtual void duringFastLoop();
77 
78  template<typename T>
79  std::vector<reco::LeafCandidate> fillMuonCollection( const std::vector<T>& tracks );
80  private:
81 
82  protected:
87  void selectMuons(const edm::Event & event);
93  void selectMuons(const int maxEvents, const TString & treeFileName);
94 
96  template<typename T>
97  void takeSelectedMuonType(const T & muon, std::vector<reco::Track> & tracks);
99  bool selGlobalMuon(const pat::Muon* aMuon);
100  bool selTrackerMuon(const pat::Muon* aMuon);
101 
105  void fillComparisonHistograms( const reco::Particle::LorentzVector & genMu, const reco::Particle::LorentzVector & recoMu, const std::string & inputName, const int charge );
106 
110  void applyBias( reco::Particle::LorentzVector & mu, const int charge );
111 
116  void checkParameters();
117 
119 
120  // Counters
121  // --------
122  int numberOfSimTracks;
123  int numberOfSimMuons;
125  int numberOfEwkZ;
126 
127  bool ifHepMC;
128  bool ifGenPart;
129 
130  // Constants
131  // ---------
132  double minResMass_hwindow[6];
133  double maxResMass_hwindow[6];
134 
135  // Total number of loops
136  // ---------------------
137  unsigned int maxLoopNumber;
138  unsigned int loopCounter;
139 
140  bool fastLoop;
141 
143 
144  // The reconstructed muon 4-momenta to be put in the tree
145  // ------------------------------------------------------
147  int iev;
148  int totalEvents_;
149 
150  bool compareToSimTracks_;
152  bool PATmuons_;
154 
155  // Input Root Tree file name. If empty events are read from the edm root file.
157  // Output Root Tree file name. If not empty events are dumped to this file at the end of the last iteration.
159  // Maximum number of events from root tree. It works in the same way as the maxEvents to configure a input source.
161 
165  bool negateTrigger_;
166  bool saveAllToTree_;
167 
168  std::auto_ptr<MuScleFitMuonSelector> muonSelector_;
169 };
170 
171 template<typename T>
172 std::vector<reco::LeafCandidate> MuScleFit::fillMuonCollection( const std::vector<T>& tracks )
173 {
174  std::vector<reco::LeafCandidate> muons;
175  typename std::vector<T>::const_iterator track;
176  for( track = tracks.begin(); track != tracks.end(); ++track ) {
178  mu = reco::Particle::LorentzVector(track->px(),track->py(),track->pz(),
179  sqrt(track->p()*track->p() + MuScleFitUtils::mMu2));
180  // Apply smearing if needed, and then bias
181  // ---------------------------------------
183  if (debug_>0)
184  std::cout <<std::setprecision(9)<< "Muon #" << MuScleFitUtils::goodmuon
185  << ": initial value Pt = " << mu.Pt() << std::endl;
186 
187  applySmearing(mu);
188  applyBias(mu, track->charge());
189 
190  reco::LeafCandidate muon(track->charge(),mu);
191  // Store modified muon
192  // -------------------
193  muons.push_back (muon);
194  }
195  return muons;
196 }
197 
198 template<typename T>
199 void MuScleFit::takeSelectedMuonType(const T & muon, std::vector<reco::Track> & tracks)
200 {
201  // std::cout<<"muon "<<muon->isGlobalMuon()<<muon->isStandAloneMuon()<<muon->isTrackerMuon()<<std::endl;
202  //NNBB: one muon can be of many kinds at once but with the theMuonType_ we are sure
203  // to avoid double counting of the same muon
204  if(muon->isGlobalMuon() && theMuonType_==1)
205  tracks.push_back(*(muon->globalTrack()));
206  else if(muon->isStandAloneMuon() && theMuonType_==2)
207  tracks.push_back(*(muon->outerTrack()));
208  else if(muon->isTrackerMuon() && theMuonType_==3)
209  tracks.push_back(*(muon->innerTrack()));
210 
211  else if( theMuonType_ == 10 && !(muon->isStandAloneMuon()) ) //particular case!!
212  tracks.push_back(*(muon->innerTrack()));
213  else if( theMuonType_ == 11 && muon->isGlobalMuon() )
214  tracks.push_back(*(muon->innerTrack()));
215  else if( theMuonType_ == 13 && muon->isTrackerMuon() )
216  tracks.push_back(*(muon->innerTrack()));
217 }
218 
219 #endif
void selectMuons(const edm::Event &event)
Definition: MuScleFit.cc:821
double maxResMass_hwindow[6]
Definition: MuScleFit.cc:266
bool selGlobalMuon(const pat::Muon *aMuon)
Function for onia selections.
Definition: MuScleFit.cc:1354
unsigned int loopCounter
Definition: MuScleFit.cc:271
int totalEvents_
Definition: MuScleFit.cc:281
std::string triggerResultsProcess_
Definition: MuScleFit.cc:296
bool saveAllToTree_
Definition: MuScleFit.cc:299
virtual void duringFastLoop()
Definition: MuScleFit.cc:962
void checkParameters()
Definition: MuScleFit.cc:1267
bool selTrackerMuon(const pat::Muon *aMuon)
Definition: MuScleFit.cc:1375
bool ifHepMC
Definition: MuScleFit.cc:260
virtual void startingNewLoop(unsigned int iLoop) override
Definition: MuScleFit.cc:634
edm::InputTag simTracksCollection_
Definition: MuScleFit.cc:284
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:1230
double charge(const std::vector< uint8_t > &Ampls)
std::vector< reco::LeafCandidate > fillMuonCollection(const std::vector< T > &tracks)
Definition: MuScleFit.cc:305
MuonServiceProxy * theService
Definition: MuScleFit.cc:251
std::string outputRootTreeFileName_
Definition: MuScleFit.cc:291
int numberOfSimVertices
Definition: MuScleFit.cc:257
reco::Particle::LorentzVector recMu2
Definition: MuScleFit.cc:279
double minResMass_hwindow[6]
Definition: MuScleFit.cc:265
bool PATmuons_
Definition: MuScleFit.cc:285
reco::Particle::LorentzVector recMu1
Definition: MuScleFit.cc:279
T sqrt(T t)
Definition: SSEVec.h:48
unsigned int maxLoopNumber
Definition: MuScleFit.cc:270
std::string genParticlesName_
Definition: MuScleFit.cc:286
bool compareToSimTracks_
Definition: MuScleFit.cc:283
const int mu
Definition: Constants.h:22
MuScleFit(const edm::ParameterSet &pset)
Definition: MuScleFit.cc:355
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:599
std::string triggerPath_
Definition: MuScleFit.h:164
virtual void endOfJob() override
Definition: MuScleFit.cc:628
bool fastLoop
Definition: MuScleFit.cc:273
virtual edm::EDLooper::Status duringLoop(const edm::Event &event, const edm::EventSetup &eventSetup) override
Definition: MuScleFit.cc:744
int numberOfSimMuons
Definition: MuScleFit.cc:256
void applySmearing(reco::Particle::LorentzVector &mu)
Apply the smearing if needed using the function in MuScleFitUtils.
Definition: MuScleFit.cc:1247
virtual ~MuScleFit()
Definition: MuScleFit.cc:573
int numberOfSimTracks
Definition: MuScleFit.cc:255
tuple tracks
Definition: testEve_cfg.py:39
std::string triggerResultsLabel_
Definition: MuScleFit.cc:295
static int goodmuon
static const double mMu2
tuple muons
Definition: patZpeak.py:38
std::string inputRootTreeFileName_
Definition: MuScleFit.cc:289
bool checkDeltaR(reco::Particle::LorentzVector &genMu, reco::Particle::LorentzVector &recMu)
Check if two lorentzVector are near in deltaR.
Definition: MuScleFit.cc:1216
std::auto_ptr< MuScleFitMuonSelector > muonSelector_
Definition: MuScleFit.cc:301
int maxEventsFromRootTree_
Definition: MuScleFit.cc:293
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:332
long double T
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:27
Analysis-level muon class.
Definition: Muon.h:49
void applyBias(reco::Particle::LorentzVector &mu, const int charge)
Apply the bias if needed using the function in MuScleFitUtils.
Definition: MuScleFit.cc:1256
bool negateTrigger_
Definition: MuScleFit.cc:298
bool ifGenPart
Definition: MuScleFit.cc:261
virtual edm::EDLooper::Status endOfLoop(const edm::EventSetup &eventSetup, unsigned int iLoop) override
Definition: MuScleFit.cc:661
MuScleFitPlotter * plotter
Definition: MuScleFit.cc:275
virtual void endOfFastLoop(const unsigned int iLoop)
Definition: MuScleFit.cc:708
int numberOfEwkZ
Definition: MuScleFit.cc:258