CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuScleFit.cc
Go to the documentation of this file.
1 
9 // \class MuScleFit
10 // Fitter of momentum scale and resolution from resonance decays to muon track pairs
11 //
12 // $Date: 2012/12/20 16:09:21 $
13 // $Revision: 1.112 $
14 // \author R. Bellan, C.Mariotti, S.Bolognesi - INFN Torino / T.Dorigo, M.De Mattia - INFN Padova
15 //
16 // Recent additions:
17 // - several parameters allow a more flexible use, tests, and control handles
18 // for the likelihood. In particular, a set of integers controls the order
19 // with which parameters are released; another controls which parameters are
20 // fixed. A function allows to smear momenta and angles of muons from the
21 // resonance before any correction, using a set of random numbers generated
22 // once and for all in the constructor (this way the smearing remains the same
23 // for any given muon no matter how many times one loops and what corrections
24 // one applies).
25 // For a correct use of these flags, please see the function minimizeLikelihood() in
26 // MuScleFitUtils.cc
27 // - the fit now allows to extract resolution functions simultaneously with the
28 // momentum scale. So far a simple parametrization
29 // of muon momentum resolution and angle resolution has been implemented, but
30 // extensions are straightforward.
31 // - It is however advisable to fit separately resolution and scale. The suggested
32 // course of action is:
33 // 1) fit the scale with a simple parametrization
34 // 2) check results, fit with more complicated forms
35 // 3) verify which is a sufficiently accurate description of the data
36 // 4) fix scale parameters and fit for the resolution
37 // 5) go back to fitting the scale with resolution parameters fixed to fitted values
38 // - Also note that resolution fits may fail to converge due to instability of the
39 // probability distribution to the limit of large widths. Improvements here are
40 // advisable.
41 // - The treatment of signal windows in the Y region
42 // has to be refined because of overlaps. More work is needed here, assigning a different
43 // weight to different hypothesis of the resonance producing a given mass, if there are
44 // multiple candidates.
45 // - Also, larger windows are to be allowed for fits to SA muons.
46 // - File Probs_1000.root contains the probability distribution of lorentzians convoluted
47 // with gaussian smearing functions, for the six resonances. A 1000x1000 grid
48 // in mass,sigma has been computed (using root macro Probs.C).
49 // A wider interval of masses for each resonance should be computed, to be used for standalone muons
50 //
51 //
52 // Notes on additions, TD 31/3/08
53 //
54 // - background model: at least a couple of different models, with two parameters,
55 // should be included in the fitting procedure such that the function massprob(),
56 // which produces the probability in the likelihood computation, incorporates the
57 // probability that the event is from background. That is, if the fitting function
58 // knows the shape of the mass spectrum ( say, a falling exponential plus a gaussian
59 // signal) it becomes possible to fit the scale together with the background shape
60 // and normalization parameters. Of course, one should do one thing at a time: first
61 // a scale fit, then a shape fit with scale parameters fixed, and then a combined
62 // fit. Convergence issues should be handled case by case.
63 // - The correct implementation of the above idea requires a reorganization of pass
64 // parameters (in the cfg) and fit parameters. The user has to be able to smear,
65 // bias, fix parameters, choose scale fitting functions, resolution fitting functions,
66 // and background functions. It should be possible to separate the fit functions from
67 // the biasing ones, which would allow a more thorough testing.
68 // - all the above can be obtained by making the .cfg instructions heavier. Since this
69 // is a routine operated by experts only, it is a sensible choice.
70 // - One should thus envision the following:
71 // 1) a set of parameters controlling the biasing function: parBias()
72 // 2) a set of parameters controlling the smearing function: parSmear()
73 // 3) a set of parameters to define resolution modeling and initial values: parResol()
74 // 3b) parResol() gets fix and order bits by parResolFix() and parResolOrder()
75 // 4) a set of parameters to define scale modeling and initial values: parScale()
76 // 4b) parScale() gets fix and order bits by parScaleFix() and parScaleOrder()
77 // 5) a set of parameters controlling the background shape and normalization: parNorm()
78 // 5b) parNorm() gets fix and order bits by parNormFix() and parNormOrder()
79 // The likelihood parameters then become a vector which is dynamically composed of
80 // sets 3), 4), and 5): parval() = parResol()+parScale()+parNorm()
81 // - In order to study better the likelihood behavior it would be advisable to introduce
82 // some histogram filling on the last iteration of the likelihood. It is not clear
83 // how best to achieve that: probably the simplest way is to make a histogram filling
84 // function run just after the likelihood computation, such that the best value of the
85 // fit parameters is used.
86 // - The muon pair which we call our resonance must be chosen in a way which does not
87 // bias our likelihood: we cannot just choose the pair closest to a resonance.
88 //
89 //
90 // Notes on additions, T.Dorigo 22/12/2008
91 // ---------------------------------------
92 //
93 // - File Probs_new_1000_CTEQ.root now contains a set of 24 additional two-dim histograms,
94 // defining the probability distribution of Z boson decays as a function of measured mass
95 // and expected sigma in 24 different bins of Z rapidity, extracted from CTEQ 6 PDF (at
96 // Leading Order) from the convolution in the factorization integral. See programs CTEQ.cpp
97 // and Fits.C.
98 // - The probability for Z boson events now thus depends on the measured rapidity of the dimuon
99 // system. All functions in file MuScleFitUtils.cc have been suitably changed.
100 //
101 // ----------------------------------------------------------------------------------
102 // Modifications by M. De Mattia 13/3/2009
103 // ---------------------------------------
104 // - The histograms map was moved to a base class (MuScleFitBase) from which this one inherits.
105 //
106 // Modifications by M. De Mattia 20/7/2009
107 // ---------------------------------------
108 // - Reworked background fit based on ranges. See comments in the code for more details.
109 // ---------------------------------------------------------------------------------------------
110 // Base Class Headers
111 // ------------------
118 
119 #include <CLHEP/Vector/LorentzVector.h>
120 #include <vector>
121 
125 
126 #include "MuScleFitBase.h"
127 #include "Histograms.h"
128 #include "MuScleFitPlotter.h"
131 #include "MuScleFitMuonSelector.h"
132 
137 
140 
146 
148 
149 #include "HepPDT/defs.h"
150 #include "HepPDT/TableBuilder.hh"
151 #include "HepPDT/ParticleDataTable.hh"
152 
153 #include "HepMC/GenParticle.h"
154 #include "HepMC/GenEvent.h"
155 
160 
161 #include "TFile.h"
162 #include "TTree.h"
163 #include "TMinuit.h"
164 
165 
166 // To use callgrind for code profiling uncomment also the following define.
167 // #define USE_CALLGRIND
168 
169 #ifdef USE_CALLGRIND
170 #include "valgrind/callgrind.h"
171 #endif
172 
173 
174 // To read likelihood distributions from the database.
175  //#include "CondFormats/RecoMuonObjects/interface/MuScleFitLikelihoodPdf.h"
176  //#include "CondFormats/DataRecord/interface/MuScleFitLikelihoodPdfRcd.h"
177 
178 namespace edm {
179  class ParameterSet;
180  class Event;
181  class EventSetup;
182 }
183 
184 
186 {
187  public:
188  // Constructor
189  // -----------
190  MuScleFit( const edm::ParameterSet& pset );
191 
192  // Destructor
193  // ----------
194  virtual ~MuScleFit();
195 
196  // Operations
197  // ----------
199  // void beginOfJob( const edm::EventSetup& eventSetup );
200  // virtual void beginOfJob();
201  virtual void endOfJob();
202 
203  virtual void startingNewLoop( unsigned int iLoop );
204 
205  virtual edm::EDLooper::Status endOfLoop( const edm::EventSetup& eventSetup, unsigned int iLoop );
206  virtual void endOfFastLoop( const unsigned int iLoop );
207 
208  virtual edm::EDLooper::Status duringLoop( const edm::Event & event, const edm::EventSetup& eventSetup );
213  virtual void duringFastLoop();
214 
215  template<typename T>
216  std::vector<reco::LeafCandidate> fillMuonCollection( const std::vector<T>& tracks );
217  private:
218 
219  protected:
224  void selectMuons(const edm::Event & event);
230  void selectMuons(const int maxEvents, const TString & treeFileName);
231 
233  template<typename T>
234  void takeSelectedMuonType(const T & muon, std::vector<reco::Track> & tracks);
236  bool selGlobalMuon(const pat::Muon* aMuon);
237  bool selTrackerMuon(const pat::Muon* aMuon);
238 
242  void fillComparisonHistograms( const reco::Particle::LorentzVector & genMu, const reco::Particle::LorentzVector & recoMu, const std::string & inputName, const int charge );
243 
247  void applyBias( reco::Particle::LorentzVector & mu, const int charge );
248 
253  void checkParameters();
254 
256 
257  // Counters
258  // --------
263 
264  bool ifHepMC;
265  bool ifGenPart;
266 
267  // Constants
268  // ---------
271 
272  // Total number of loops
273  // ---------------------
274  unsigned int maxLoopNumber;
275  unsigned int loopCounter;
276 
277  bool fastLoop;
278 
280 
281  // The reconstructed muon 4-momenta to be put in the tree
282  // ------------------------------------------------------
284  int iev;
286 
289  bool PATmuons_;
291 
292  // Input Root Tree file name. If empty events are read from the edm root file.
294  // Output Root Tree file name. If not empty events are dumped to this file at the end of the last iteration.
296  // Maximum number of events from root tree. It works in the same way as the maxEvents to configure a input source.
298 
301  std::vector<std::string> triggerPath_;
304 
305  std::auto_ptr<MuScleFitMuonSelector> muonSelector_;
306 };
307 
308 template<typename T>
309 std::vector<reco::LeafCandidate> MuScleFit::fillMuonCollection( const std::vector<T>& tracks )
310 {
311  std::vector<reco::LeafCandidate> muons;
312  typename std::vector<T>::const_iterator track;
313  for( track = tracks.begin(); track != tracks.end(); ++track ) {
315  mu = reco::Particle::LorentzVector(track->px(),track->py(),track->pz(),
316  sqrt(track->p()*track->p() + MuScleFitUtils::mMu2));
317  // Apply smearing if needed, and then bias
318  // ---------------------------------------
320  if (debug_>0)
321  std::cout <<std::setprecision(9)<< "Muon #" << MuScleFitUtils::goodmuon
322  << ": initial value Pt = " << mu.Pt() << std::endl;
323 
324  applySmearing(mu);
325  applyBias(mu, track->charge());
326 
327  reco::LeafCandidate muon(track->charge(),mu);
328  // Store modified muon
329  // -------------------
330  muons.push_back (muon);
331  }
332  return muons;
333 }
334 
335 template<typename T>
336 void MuScleFit::takeSelectedMuonType(const T & muon, std::vector<reco::Track> & tracks)
337 {
338  // std::cout<<"muon "<<muon->isGlobalMuon()<<muon->isStandAloneMuon()<<muon->isTrackerMuon()<<std::endl;
339  //NNBB: one muon can be of many kinds at once but with the theMuonType_ we are sure
340  // to avoid double counting of the same muon
341  if(muon->isGlobalMuon() && theMuonType_==1)
342  tracks.push_back(*(muon->globalTrack()));
343  else if(muon->isStandAloneMuon() && theMuonType_==2)
344  tracks.push_back(*(muon->outerTrack()));
345  else if(muon->isTrackerMuon() && theMuonType_==3)
346  tracks.push_back(*(muon->innerTrack()));
347 
348  else if( theMuonType_ == 10 && !(muon->isStandAloneMuon()) ) //particular case!!
349  tracks.push_back(*(muon->innerTrack()));
350  else if( theMuonType_ == 11 && muon->isGlobalMuon() )
351  tracks.push_back(*(muon->innerTrack()));
352  else if( theMuonType_ == 13 && muon->isTrackerMuon() )
353  tracks.push_back(*(muon->innerTrack()));
354 }
355 
356 
357 // Constructor
358 // -----------
360  MuScleFitBase( pset ),
361  totalEvents_(0)
362 {
364  if (debug_>0) std::cout << "[MuScleFit]: Constructor" << std::endl;
365 
366  if ((theMuonType_<-4 || theMuonType_>5) && theMuonType_<10) {
367  std::cout << "[MuScleFit]: Unknown muon type! Aborting." << std::endl;
368  abort();
369  }
370 
371  loopCounter = 0;
372 
373  // Boundaries for h-function computation (to be improved!)
374  // -------------------------------------------------------
375  minResMass_hwindow[0] = 71.1876; // 76.;
376  maxResMass_hwindow[0] = 111.188; // 106.;
377  minResMass_hwindow[1] = 10.15;
378  maxResMass_hwindow[1] = 10.55;
379  minResMass_hwindow[2] = 9.8;
380  maxResMass_hwindow[2] = 10.2;
381  minResMass_hwindow[3] = 9.25;
382  maxResMass_hwindow[3] = 9.65;
383  minResMass_hwindow[4] = 3.58;
384  maxResMass_hwindow[4] = 3.78;
385  minResMass_hwindow[5] = 3.0;
386  maxResMass_hwindow[5] = 3.2;
387 
388  // Max number of loops (if > 2 then try to minimize likelihood more than once)
389  // ---------------------------------------------------------------------------
390  maxLoopNumber = pset.getUntrackedParameter<int>("maxLoopNumber", 2);
391  fastLoop = pset.getUntrackedParameter<bool>("FastLoop", true);
392 
393  // Selection of fits according to loop
394  MuScleFitUtils::doResolFit = pset.getParameter<std::vector<int> >("doResolFit");
395  MuScleFitUtils::doScaleFit = pset.getParameter<std::vector<int> >("doScaleFit");
396  MuScleFitUtils::doCrossSectionFit = pset.getParameter<std::vector<int> >("doCrossSectionFit");
397  MuScleFitUtils::doBackgroundFit = pset.getParameter<std::vector<int> >("doBackgroundFit");
398 
399  // Bias and smear types
400  // --------------------
401  int biasType = pset.getParameter<int>("BiasType");
402  MuScleFitUtils::BiasType = biasType;
403  // No error, the scale functions are used also for the bias
405  int smearType = pset.getParameter<int>("SmearType");
406  MuScleFitUtils::SmearType = smearType;
408 
409  // Fit types
410  // ---------
411  int resolFitType = pset.getParameter<int>("ResolFitType");
412  MuScleFitUtils::ResolFitType = resolFitType;
415  int scaleType = pset.getParameter<int>("ScaleFitType");
416  MuScleFitUtils::ScaleFitType = scaleType;
419 
420  // Initial parameters values
421  // -------------------------
422  MuScleFitUtils::parBias = pset.getParameter<std::vector<double> >("parBias");
423  MuScleFitUtils::parSmear = pset.getParameter<std::vector<double> >("parSmear");
424  MuScleFitUtils::parResol = pset.getParameter<std::vector<double> >("parResol");
425  MuScleFitUtils::parResolStep = pset.getUntrackedParameter<std::vector<double> >("parResolStep", std::vector<double>());
426  MuScleFitUtils::parResolMin = pset.getUntrackedParameter<std::vector<double> >("parResolMin", std::vector<double>());
427  MuScleFitUtils::parResolMax = pset.getUntrackedParameter<std::vector<double> >("parResolMax", std::vector<double>());
428  MuScleFitUtils::parScale = pset.getParameter<std::vector<double> >("parScale");
429  MuScleFitUtils::parScaleStep = pset.getUntrackedParameter<std::vector<double> >("parScaleStep", std::vector<double>());
430  MuScleFitUtils::parScaleMin = pset.getUntrackedParameter<std::vector<double> >("parScaleMin", std::vector<double>());
431  MuScleFitUtils::parScaleMax = pset.getUntrackedParameter<std::vector<double> >("parScaleMax", std::vector<double>());
432  MuScleFitUtils::parCrossSection = pset.getParameter<std::vector<double> >("parCrossSection");
433  MuScleFitUtils::parBgr = pset.getParameter<std::vector<double> >("parBgr");
434  MuScleFitUtils::parResolFix = pset.getParameter<std::vector<int> >("parResolFix");
435  MuScleFitUtils::parScaleFix = pset.getParameter<std::vector<int> >("parScaleFix");
436  MuScleFitUtils::parCrossSectionFix = pset.getParameter<std::vector<int> >("parCrossSectionFix");
437  MuScleFitUtils::parBgrFix = pset.getParameter<std::vector<int> >("parBgrFix");
438  MuScleFitUtils::parResolOrder = pset.getParameter<std::vector<int> >("parResolOrder");
439  MuScleFitUtils::parScaleOrder = pset.getParameter<std::vector<int> >("parScaleOrder");
440  MuScleFitUtils::parCrossSectionOrder = pset.getParameter<std::vector<int> >("parCrossSectionOrder");
441  MuScleFitUtils::parBgrOrder = pset.getParameter<std::vector<int> >("parBgrOrder");
442 
443  MuScleFitUtils::resfind = pset.getParameter<std::vector<int> >("resfind");
444  MuScleFitUtils::FitStrategy = pset.getParameter<int>("FitStrategy");
445 
446  // Option to skip unnecessary stuff
447  // --------------------------------
448  MuScleFitUtils::speedup = pset.getParameter<bool>("speedup");
449 
450  // Option to skip simTracks comparison
451  compareToSimTracks_ = pset.getParameter<bool>("compareToSimTracks");
452  simTracksCollection_ = pset.getUntrackedParameter<edm::InputTag>("SimTracksCollection", edm::InputTag("g4SimHits"));
453 
454  triggerResultsLabel_ = pset.getUntrackedParameter<std::string>("TriggerResultsLabel");
455  triggerResultsProcess_ = pset.getUntrackedParameter<std::string>("TriggerResultsProcess");
456  triggerPath_ = pset.getUntrackedParameter<std::vector<std::string> >("TriggerPath");
457  negateTrigger_ = pset.getUntrackedParameter<bool>("NegateTrigger", false);
458  saveAllToTree_ = pset.getUntrackedParameter<bool>("SaveAllToTree", false);
459 
460  PATmuons_ = pset.getUntrackedParameter<bool>("PATmuons", false);
461  genParticlesName_ = pset.getUntrackedParameter<std::string>("GenParticlesName", "genParticles");
462 
463  // Use the probability file or not. If not it will perform a simpler selection taking the muon pair with
464  // invariant mass closer to the pdf value and will crash if some fit is attempted.
465  MuScleFitUtils::useProbsFile_ = pset.getUntrackedParameter<bool>("UseProbsFile", true);
466 
467  // This must be set to true if using events generated with Sherpa
468  MuScleFitUtils::sherpa_ = pset.getUntrackedParameter<bool>("Sherpa", false);
469 
470  MuScleFitUtils::rapidityBinsForZ_ = pset.getUntrackedParameter<bool>("RapidityBinsForZ", true);
471 
472  // Set the cuts on muons to be used in the fit
473  MuScleFitUtils::separateRanges_ = pset.getUntrackedParameter<bool>("SeparateRanges", true);
474  MuScleFitUtils::maxMuonPt_ = pset.getUntrackedParameter<double>("MaxMuonPt", 100000000.);
475  MuScleFitUtils::minMuonPt_ = pset.getUntrackedParameter<double>("MinMuonPt", 0.);
476  MuScleFitUtils::minMuonEtaFirstRange_ = pset.getUntrackedParameter<double>("MinMuonEtaFirstRange", -6.);
477  MuScleFitUtils::maxMuonEtaFirstRange_ = pset.getUntrackedParameter<double>("MaxMuonEtaFirstRange", 6.);
478  MuScleFitUtils::minMuonEtaSecondRange_ = pset.getUntrackedParameter<double>("MinMuonEtaSecondRange", -100.);
479  MuScleFitUtils::maxMuonEtaSecondRange_ = pset.getUntrackedParameter<double>("MaxMuonEtaSecondRange", 100.);
480  MuScleFitUtils::deltaPhiMinCut_ = pset.getUntrackedParameter<double>("DeltaPhiMinCut", -100.);
481  MuScleFitUtils::deltaPhiMaxCut_ = pset.getUntrackedParameter<double>("DeltaPhiMaxCut", 100.);
482 
483  MuScleFitUtils::debugMassResol_ = pset.getUntrackedParameter<bool>("DebugMassResol", false);
484  // MuScleFitUtils::massResolComponentsStruct MuScleFitUtils::massResolComponents;
485 
486  // Check for parameters consistency
487  // it will abort in case of errors.
488  checkParameters();
489 
490  // Generate array of gaussian-distributed numbers for smearing
491  // -----------------------------------------------------------
492  if (MuScleFitUtils::SmearType>0) {
493  std::cout << "[MuScleFit-Constructor]: Generating random values for smearing" << std::endl;
494  TF1 G("G", "[0]*exp(-0.5*pow(x,2))", -5., 5.);
495  double norm = 1/sqrt(2*TMath::Pi());
496  G.SetParameter (0,norm);
497  for (int i=0; i<10000; i++) {
498  for (int j=0; j<7; j++) {
499  MuScleFitUtils::x[j][i] = G.GetRandom();
500  }
501  }
502  }
504 
505  if(theMuonType_ > 0 && theMuonType_ < 4) {
508  }
509  else if(theMuonType_ == 0 || theMuonType_ == 4 || theMuonType_ == 5 || theMuonType_ >= 10 || theMuonType_==-1 || theMuonType_==-2 || theMuonType_==-3 || theMuonType_==-4) {
512  }
513  else{
514  std::cout<<"Wrong muon type "<<theMuonType_<<std::endl;
515  exit(1);
516  }
517 
518  // When using standalone muons switch to the single Z pdf
519  if( theMuonType_ == 2 ) {
520  MuScleFitUtils::rapidityBinsForZ_ = false;
521  }
522 
523  // Initialize ResMaxSigma And ResHalfWidth - 0 = global, 1 = SM, 2 = tracker
524  // -------------------------------------------------------------------------
543 
545  MuScleFitUtils::resfind,
546  MuScleFitUtils::speedup, genParticlesName_,
547  compareToSimTracks_, simTracksCollection_,
548  MuScleFitUtils::sherpa_, debug_));
549 
550  MuScleFitUtils::backgroundHandler = new BackgroundHandler( pset.getParameter<std::vector<int> >("BgrFitType"),
551  pset.getParameter<std::vector<double> >("LeftWindowBorder"),
552  pset.getParameter<std::vector<double> >("RightWindowBorder"),
555 
557 
558  // Build cross section scale factors
559  // MuScleFitUtils::resfind
560 
561  MuScleFitUtils::normalizeLikelihoodByEventNumber_ = pset.getUntrackedParameter<bool>("NormalizeLikelihoodByEventNumber", true);
562  if(debug_>0) std::cout << "End of MuScleFit constructor" << std::endl;
563 
564  inputRootTreeFileName_ = pset.getParameter<std::string>("InputRootTreeFileName");
565  outputRootTreeFileName_ = pset.getParameter<std::string>("OutputRootTreeFileName");
566  maxEventsFromRootTree_ = pset.getParameter<int>("MaxEventsFromRootTree");
567 
568  MuScleFitUtils::startWithSimplex_ = pset.getParameter<bool>("StartWithSimplex");
569  MuScleFitUtils::computeMinosErrors_ = pset.getParameter<bool>("ComputeMinosErrors");
570  MuScleFitUtils::minimumShapePlots_ = pset.getParameter<bool>("MinimumShapePlots");
571 
573 }
574 
575 // Destructor
576 // ----------
578  if (debug_>0) std::cout << "[MuScleFit]: Destructor" << std::endl;
579  std::cout << "Total number of analyzed events = " << totalEvents_ << std::endl;
580 
581  if( !(outputRootTreeFileName_.empty()) ) {
582  // Save the events to a root tree unless we are reading from the edm root file and the SavedPair size is different from the totalEvents_
583  if( !(inputRootTreeFileName_.empty() && (int(MuScleFitUtils::SavedPair.size()) != totalEvents_)) ) {
584  std::cout << "Saving muon pairs to root tree" << std::endl;
585  RootTreeHandler rootTreeHandler;
587  // rootTreeHandler.writeTree(outputRootTreeFileName_, &(MuScleFitUtils::SavedPair), theMuonType_, 0, saveAllToTree_);
589  }
590  else {
591  // rootTreeHandler.writeTree(outputRootTreeFileName_, &(MuScleFitUtils::SavedPair), theMuonType_, &(MuScleFitUtils::genPair), saveAllToTree_ );
593  }
594  }
595  else {
596  std::cout << "ERROR: events in the vector = " << MuScleFitUtils::SavedPair.size() << " != totalEvents = " << totalEvents_ << std::endl;
597  }
598  }
599 }
600 
601 // Begin job
602 // ---------
604 // void MuScleFit::beginOfJob ()
605 // void MuScleFit::beginOfJob( const edm::EventSetup& eventSetup )
606 {
607  if (debug_>0) std::cout << "[MuScleFit]: beginOfJob" << std::endl;
608  //if(maxLoopNumber>1)
611  }
612 
613  if (debug_>0) std::cout << "[MuScleFit]: beginOfJob" << std::endl;
614 
615  // Create the root file
616  // --------------------
617  for (unsigned int i=0; i<(maxLoopNumber); i++) {
618  std::stringstream ss;
619  ss << i;
620  std::string rootFileName = ss.str() + "_" + theRootFileName_;
621  theFiles_.push_back (new TFile(rootFileName.c_str(), "RECREATE"));
622  }
623  if (debug_>0) std::cout << "[MuScleFit]: Root file created" << std::endl;
624 
625  std::cout << "creating plotter" << std::endl;
627  plotter->debug = debug_;
628 }
629 
630 // End of job method
631 // -----------------
633  if (debug_>0) std::cout << "[MuScleFit]: endOfJob" << std::endl;
634 }
635 
636 // New loop
637 // --------
638 void MuScleFit::startingNewLoop( unsigned int iLoop )
639 {
640  if (debug_>0) std::cout << "[MuScleFit]: Starting loop # " << iLoop << std::endl;
641 
642  // Number of muons used
643  // --------------------
645 
646  // Counters for problem std::cout-ing
647  // -----------------------------
649 
650  // Create the root file
651  // --------------------
652  fillHistoMap(theFiles_[iLoop], iLoop);
653 
654  loopCounter = iLoop;
656 
657  iev = 0;
659 
661 }
662 
663 // End of loop routine
664 // -------------------
665 edm::EDLooper::Status MuScleFit::endOfLoop( const edm::EventSetup& eventSetup, unsigned int iLoop )
666 {
667  unsigned int iFastLoop = 1;
668 
669  // Read the events from the root tree if requested
670  if( !(inputRootTreeFileName_.empty()) ) {
672  // When reading from local file all the loops are done here
674  iFastLoop = 0;
675  }
676  else {
677  endOfFastLoop(iLoop);
678  }
679 
680  // If a fastLoop is required we do all the remaining iterations here
681  if( fastLoop == true ) {
682  for( ; iFastLoop<maxLoopNumber; ++iFastLoop ) {
683 
684  std::cout << "Starting fast loop number " << iFastLoop << std::endl;
685 
686  // In the first loop is called by the framework
687  // if( iFastLoop > 0 ) {
688  startingNewLoop(iFastLoop);
689  // }
690 
691  // std::vector<std::pair<lorentzVector,lorentzVector> >::const_iterator it = MuScleFitUtils::SavedPair.begin();
692  // for( ; it != SavedPair.end(); ++it ) {
693  while( iev<totalEvents_ ) {
694  if( iev%50000 == 0 ) {
695  std::cout << "Fast looping on event number " << iev << std::endl;
696  }
697  // This reads muons from SavedPair using iev to keep track of the event
698  duringFastLoop();
699  }
700  std::cout << "End of fast loop number " << iFastLoop << ". Ran on " << iev << " events" << std::endl;
701  endOfFastLoop(iFastLoop);
702  }
703  }
704 
705  if (iFastLoop>=maxLoopNumber-1) {
706  return kStop;
707  } else {
708  return kContinue;
709  }
710 }
711 
712 void MuScleFit::endOfFastLoop( const unsigned int iLoop )
713 {
714  // std::cout<< "Inside endOfFastLoop, iLoop = " << iLoop << " and loopCounter = " << loopCounter << std::endl;
715 
716  if( loopCounter == 0 ) {
717  // plotter->writeHistoMap();
718  // The destructor will call the writeHistoMap after the cd to the output file
719  delete plotter;
720  }
721 
722  std::cout << "Ending loop # " << iLoop << std::endl;
723 
724  // Write the histos to file
725  // ------------------------
726  // theFiles_[iLoop]->cd();
727  writeHistoMap(iLoop);
728 
729  // Likelihood minimization to compute corrections
730  // ----------------------------------------------
731  // theFiles_[iLoop]->cd();
732  TDirectory * likelihoodDir = theFiles_[iLoop]->mkdir("likelihood");
733  likelihoodDir->cd();
735 
736  // ATTENTION, this was put BEFORE the minimizeLikelihood. Check for problems.
737  theFiles_[iLoop]->Close();
738  // ATTENTION: Check that this delete does not give any problem
739  delete theFiles_[iLoop];
740 
741  // Clear the histos
742  // ----------------
743  clearHistoMap();
744 }
745 
746 // Stuff to do during loop
747 // -----------------------
749 {
751  event.getByLabel(edm::InputTag(triggerResultsLabel_.c_str(), "", triggerResultsProcess_.c_str()), triggerResults);
752  //event.getByLabel(InputTag(triggerResultsLabel_),triggerResults);
753  bool isFired = false;
754 
755  if(triggerPath_[0] == "")
756  isFired = true;
757  else if(triggerPath_[0] == "All"){
758  isFired =triggerResults->accept();
759  if(debug_>0)
760  std::cout<<"Trigger "<<isFired<<std::endl;
761  }
762  else{
763  bool changed;
765  hltConfig.init(event.getRun(), eventSetup, triggerResultsProcess_, changed);
766 
767 
768  const edm::TriggerNames triggerNames = event.triggerNames(*triggerResults);
769 
770  for (unsigned i=0; i<triggerNames.size(); i++) {
771  std::string hltName = triggerNames.triggerName(i);
772 
773  // match the path in the pset with the true name of the trigger
774  for ( unsigned int ipath=0; ipath<triggerPath_.size(); ipath++ ) {
775  if ( hltName.find(triggerPath_[ipath]) != std::string::npos ) {
776  unsigned int triggerIndex( hltConfig.triggerIndex(hltName) );
777 
778  // triggerIndex must be less than the size of HLTR or you get a CMSException: _M_range_check
779  if (triggerIndex < triggerResults->size()) {
780  isFired = triggerResults->accept(triggerIndex);
781  if(debug_>0)
782  std::cout << triggerPath_[ipath] <<" "<< hltName << " " << isFired<<std::endl;
783  }
784  } // end if (matching the path in the pset with the true trigger name
785  }
786  }
787 
788  }
789 
790  if( negateTrigger_ && isFired ) return kContinue;
791  else if( !(negateTrigger_) && !isFired ) return kContinue;
792 
793 #ifdef USE_CALLGRIND
794  CALLGRIND_START_INSTRUMENTATION;
795 #endif
796 
797  if (debug_>0) {
798  std::cout << "[MuScleFit-duringLoop]: loopCounter = " << loopCounter
799  << " Run: " << event.id().run() << " Event: " << event.id().event() << std::endl;
800  }
801 
802  // On the first iteration we read the bank, otherwise we fetch the information from the muon tree
803  // ------------------------------------ Important Note --------------------------------------- //
804  // The fillMuonCollection method applies any smearing or bias to the muons, so we NEVER use
805  // unbiased muons.
806  // ----------------------------------------------------------------------------------------------
807  if( loopCounter == 0 ) {
808 
809  if( !fastLoop || inputRootTreeFileName_.empty() ) {
810  if( debug_ > 0 ) std::cout << "Reading from edm event" << std::endl;
811  selectMuons(event);
812  duringFastLoop();
813  ++totalEvents_;
814  }
815  }
816 
817  return kContinue;
818 
819 #ifdef USE_CALLGRIND
820  CALLGRIND_STOP_INSTRUMENTATION;
821  CALLGRIND_DUMP_STATS;
822 #endif
823 }
824 
826 {
829 
830  std::vector<reco::LeafCandidate> muons;
831  muonSelector_->selectMuons(event, muons, genMuonPairs_, MuScleFitUtils::simPair, plotter);
832  // plotter->fillRec(muons); // @EM method already invoked inside MuScleFitMuonSelector::selectMuons()
833 
834  // Find the two muons from the resonance, and set ResFound bool
835  // ------------------------------------------------------------
836  std::pair<reco::Particle::LorentzVector, reco::Particle::LorentzVector> recMuFromBestRes =
838 
840  if (debug_>0) {
841  std::cout <<std::setprecision(9)<< "Pt after findbestrecores: " << (recMuFromBestRes.first).Pt() << " "
842  << (recMuFromBestRes.second).Pt() << std::endl;
843  std::cout << "recMu1 = " << recMu1 << std::endl;
844  std::cout << "recMu2 = " << recMu2 << std::endl;
845  }
846  recMu1 = recMuFromBestRes.first;
847  recMu2 = recMuFromBestRes.second;
848  if (debug_>0) {
849  std::cout << "after recMu1 = " << recMu1 << std::endl;
850  std::cout << "after recMu2 = " << recMu2 << std::endl;
851  std::cout << "mu1.pt = " << recMu1.Pt() << std::endl;
852  std::cout << "mu2.pt = " << recMu2.Pt() << std::endl;
853  }
854  MuScleFitUtils::SavedPair.push_back( std::make_pair( recMu1, recMu2 ) );
855  } else {
856  MuScleFitUtils::SavedPair.push_back( std::make_pair( lorentzVector(0.,0.,0.,0.), lorentzVector(0.,0.,0.,0.) ) );
857  }
858  // Save the events also in the external tree so that it can be saved late
859 
860  // std::cout << "SavedPair->size() " << MuScleFitUtils::SavedPair.size() << std::endl;
863  event.run(), event.id().event()));
864  // Fill the internal genPair tree from the external one
865  if( MuScleFitUtils::speedup == false ) {
866  MuScleFitUtils::genPair.push_back(std::make_pair( genMuonPairs_.back().mu1, genMuonPairs_.back().mu2 ));
867  }
868 }
869 
870 void MuScleFit::selectMuons(const int maxEvents, const TString & treeFileName)
871 {
872  std::cout << "Reading muon pairs from Root Tree in " << treeFileName << std::endl;
873  RootTreeHandler rootTreeHandler;
874  std::vector<std::pair<int, int> > evtRun;
876  rootTreeHandler.readTree(maxEvents, inputRootTreeFileName_, &(MuScleFitUtils::SavedPair), theMuonType_, &evtRun);
877  }
878  else {
880  }
881  // Now loop on all the pairs and apply any smearing and bias if needed
882  std::vector<std::pair<int, int> >::iterator evtRunIt = evtRun.begin();
883  std::vector<std::pair<lorentzVector,lorentzVector> >::iterator it = MuScleFitUtils::SavedPair.begin();
884  std::vector<std::pair<lorentzVector,lorentzVector> >::iterator genIt;
885  if(MuScleFitUtils::speedup == false) genIt = MuScleFitUtils::genPair.begin();
886  for( ; it != MuScleFitUtils::SavedPair.end(); ++it, ++evtRunIt ) {
887 
888  // Apply any cut if requested
889  // Note that cuts here are only applied to already selected muons. They should not be used unless
890  // you are sure that the difference is negligible (e.g. the number of events with > 2 muons is negligible).
891  double pt1 = it->first.pt();
892  // std::cout << "pt1 = " << pt1 << std::endl;
893  double pt2 = it->second.pt();
894  // std::cout << "pt2 = " << pt2 << std::endl;
895  double eta1 = it->first.eta();
896  // std::cout << "eta1 = " << eta1 << std::endl;
897  double eta2 = it->second.eta();
898  // std::cout << "eta2 = " << eta2 << std::endl;
899  // If they don't pass the cuts set to null vectors
900  bool dontPass = false;
901  bool eta1InFirstRange;
902  bool eta2InFirstRange;
903  bool eta1InSecondRange;
904  bool eta2InSecondRange;
905 
911 
912  // This is my logic, which should be erroneous, but certainly simpler...
915  eta1InFirstRange && eta2InSecondRange ) ) {
916  dontPass = true;
917  }
918  }
919  else {
920  eta1 = fabs(eta1);
921  eta2 = fabs(eta2);
928  ( ((eta1InFirstRange && !eta2InFirstRange) && (eta2InSecondRange && !eta1InSecondRange)) ||
929  ((eta2InFirstRange && !eta1InFirstRange) && (eta1InSecondRange && !eta2InSecondRange)) )) ) {
930  dontPass = true;
931  }
932  }
933 
934  // Additional check on deltaPhi
935  double deltaPhi = MuScleFitUtils::deltaPhi(it->first.phi(), it->second.phi());
936  if( (deltaPhi <= MuScleFitUtils::deltaPhiMinCut_) || (deltaPhi >= MuScleFitUtils::deltaPhiMaxCut_) ) dontPass = true;
937 
938  if( dontPass ) {
939  // std::cout << "removing muons not passing cuts" << std::endl;
940  it->first = reco::Particle::LorentzVector(0,0,0,0);
941  it->second = reco::Particle::LorentzVector(0,0,0,0);
942  }
943 
944  // First is always mu-, second mu+
945  if( (MuScleFitUtils::SmearType != 0) || (MuScleFitUtils::BiasType != 0) ) {
946  applySmearing(it->first);
947  applyBias(it->first, -1);
948  applySmearing(it->second);
949  applyBias(it->second, 1);
950  }
951  muonPairs_.push_back(MuonPair(it->first, it->second,
952  evtRunIt->second, evtRunIt->first));
953 
954  // Fill the internal genPair tree from the external one
955  if( MuScleFitUtils::speedup == false ) {
956  genMuonPairs_.push_back(GenMuonPair(genIt->first, genIt->second, 0));
957  ++genIt;
958  }
959  }
961  if( !(MuScleFitUtils::speedup) ) {
963  }
964 }
965 
967 {
968  // On loops>0 the two muons are directly obtained from the SavedMuon array
969  // -----------------------------------------------------------------------
970  MuScleFitUtils::ResFound = false;
973  if (recMu1.Pt()>0 && recMu2.Pt()>0) {
975  if (debug_>0) std::cout << "Ev = " << iev << ": found muons in tree with Pt = "
976  << recMu1.Pt() << " " << recMu2.Pt() << std::endl;
977  }
978 
979  if( debug_>0 ) std::cout << "About to start lik par correction and histo filling; ResFound is "
980  << MuScleFitUtils::ResFound << std::endl;
981  // If resonance found, do the hard work
982  // ------------------------------------
984 
985  // Find weight and reference mass for this muon pair
986  // -------------------------------------------------
987  // The last parameter = true means that we want to use always the background window to compute the weight,
988  // otherwise the probability will be filled only for the resonance region.
989  double weight = MuScleFitUtils::computeWeight( (recMu1+recMu2).mass(), iev, true );
990  if (debug_>0) {
991  std::cout << "Loop #" << loopCounter << "Event #" << iev << ": before correction Pt1 = "
992  << recMu1.Pt() << " Pt2 = " << recMu2.Pt() << std::endl;
993  }
994  // For successive iterations, correct the muons only if the previous iteration was a scale fit.
995  // --------------------------------------------------------------------------------------------
996  if ( loopCounter>0 ) {
1000  }
1001  }
1002  if (debug_>0) {
1003  std::cout << "Loop #" << loopCounter << "Event #" << iev << ": after correction Pt1 = "
1004  << recMu1.Pt() << " Pt2 = " << recMu2.Pt() << std::endl;
1005  }
1006 
1008 
1009  //Fill histograms
1010  //------------------
1011 
1012  mapHisto_["hRecBestMu"]->Fill(recMu1, -1,weight);
1013  mapHisto_["hRecBestMuVSEta"]->Fill(recMu1);
1014  mapHisto_["hRecBestMu"]->Fill(recMu2, +1,weight);
1015  mapHisto_["hRecBestMuVSEta"]->Fill(recMu2);
1016  mapHisto_["hDeltaRecBestMu"]->Fill(recMu1, recMu2);
1017  // Reconstructed resonance
1018  mapHisto_["hRecBestRes"]->Fill(bestRecRes,+1, weight);
1019  mapHisto_["hRecBestResAllEvents"]->Fill(bestRecRes,+1, 1.);
1020 // // Fill histogram of Res mass vs muon variables
1021 // mapHisto_["hRecBestResVSMu"]->Fill (recMu1, bestRecRes, -1);
1022 // mapHisto_["hRecBestResVSMu"]->Fill (recMu2, bestRecRes, +1);
1023 // // Fill also the mass mu+/mu- comparisons
1024 // mapHisto_["hRecBestResVSMu"]->Fill(recMu1, recMu2, bestRecRes);
1025 
1026  mapHisto_["hRecBestResVSMu"]->Fill (recMu1, bestRecRes, -1, weight);
1027  mapHisto_["hRecBestResVSMu"]->Fill (recMu2, bestRecRes, +1, weight);
1028  // Fill also the mass mu+/mu- comparisons
1029  mapHisto_["hRecBestResVSMu"]->Fill(recMu1, recMu2, bestRecRes, weight);
1030 
1031  //-- rc 2010 filling histograms for mu+ /mu- ------
1032  // mapHisto_["hRecBestResVSMuMinus"]->Fill (recMu1, bestRecRes, -1);
1033  // mapHisto_["hRecBestResVSMuPlus"]->Fill (recMu2, bestRecRes, +1);
1034 
1035  //-- rc 2010 filling histograms MassVsMuEtaPhi------
1036  // mapHisto_["hRecBestResVSMuEtaPhi"]->Fill (recMu1, bestRecRes,-1);
1037  // mapHisto_["hRecBestResVSMuEtaPhi"]->Fill (recMu2, bestRecRes,+1);
1038 
1039  // Fill histogram of Res mass vs Res variables
1040  // mapHisto_["hRecBestResVSRes"]->Fill (bestRecRes, bestRecRes, +1);
1041  mapHisto_["hRecBestResVSRes"]->Fill (bestRecRes, bestRecRes, +1, weight);
1042 
1043 
1044 
1045 
1046 
1047 
1048  std::vector<double> * parval;
1049  std::vector<double> initpar;
1050  // Store a pointer to the vector of parameters of the last iteration, or the initial
1051  // parameters if this is the first iteration
1052  if (loopCounter==0) {
1053  initpar = MuScleFitUtils::parResol;
1054  initpar.insert( initpar.end(), MuScleFitUtils::parScale.begin(), MuScleFitUtils::parScale.end() );
1055  initpar.insert( initpar.end(), MuScleFitUtils::parCrossSection.begin(), MuScleFitUtils::parCrossSection.end() );
1056  initpar.insert( initpar.end(), MuScleFitUtils::parBgr.begin(), MuScleFitUtils::parBgr.end() );
1057  parval = &initpar;
1058  } else {
1059  parval = &(MuScleFitUtils::parvalue[loopCounter-1]);
1060  }
1061 
1062  //Compute pt resolution w.r.t generated and simulated muons
1063  //--------------------------------------------------------
1064  if( !MuScleFitUtils::speedup ) {
1065 
1066  //first is always mu-, second is always mu+
1069  }
1072  }
1073  if( compareToSimTracks_ ) {
1074  //first is always mu-, second is always mu+
1077  }
1080  }
1081  }
1082  }
1083 
1084  // ATTENTION: this was done only when a matching was found. Moved it outside because, genInfo or not, we still want to see the resolution function
1085  // Fill also the resolution histogramsm using the resolution functions:
1086  // the parameters are those from the last iteration, as the muons up to this point have also the corrections from the same iteration.
1087  // Need to use a different array (ForVec), containing functors able to operate on std::vector<double>
1088  mapHisto_["hFunctionResolPt"]->Fill( recMu1, MuScleFitUtils::resolutionFunctionForVec->sigmaPt(recMu1.Pt(), recMu1.Eta(), *parval ), -1 );
1089  mapHisto_["hFunctionResolCotgTheta"]->Fill( recMu1, MuScleFitUtils::resolutionFunctionForVec->sigmaCotgTh(recMu1.Pt(), recMu1.Eta(), *parval ), -1 );
1090  mapHisto_["hFunctionResolPhi"]->Fill( recMu1, MuScleFitUtils::resolutionFunctionForVec->sigmaPhi(recMu1.Pt(), recMu1.Eta(), *parval ), -1 );
1091  mapHisto_["hFunctionResolPt"]->Fill( recMu2, MuScleFitUtils::resolutionFunctionForVec->sigmaPt(recMu2.Pt(), recMu2.Eta(), *parval ), +1 );
1092  mapHisto_["hFunctionResolCotgTheta"]->Fill( recMu2, MuScleFitUtils::resolutionFunctionForVec->sigmaCotgTh(recMu2.Pt(), recMu2.Eta(), *parval ), +1 );
1093  mapHisto_["hFunctionResolPhi"]->Fill( recMu2, MuScleFitUtils::resolutionFunctionForVec->sigmaPhi(recMu2.Pt(), recMu2.Eta(), *parval ), +1 );
1094 
1095  // Compute likelihood histograms
1096  // -----------------------------
1097  if( debug_ > 0 ) std::cout << "mass = " << bestRecRes.mass() << std::endl;
1098  if (weight!=0.) {
1099  double massResol;
1100  double prob;
1101  double deltalike;
1102  if (loopCounter==0) {
1103  std::vector<double> initpar;
1104  for (int i=0; i<(int)(MuScleFitUtils::parResol.size()); i++) {
1105  initpar.push_back(MuScleFitUtils::parResol[i]);
1106  }
1107  for (int i=0; i<(int)(MuScleFitUtils::parScale.size()); i++) {
1108  initpar.push_back(MuScleFitUtils::parScale[i]);
1109  }
1110 // for (int i=0; i<(int)(MuScleFitUtils::parCrossSection.size()); i++) {
1111 // initpar.push_back(MuScleFitUtils::parCrossSection[i]);
1112 // }
1114 
1115  for (int i=0; i<(int)(MuScleFitUtils::parBgr.size()); i++) {
1116  initpar.push_back(MuScleFitUtils::parBgr[i]);
1117  }
1118  massResol = MuScleFitUtils::massResolution( recMu1, recMu2, initpar );
1119  // prob = MuScleFitUtils::massProb( bestRecRes.mass(), bestRecRes.Eta(), bestRecRes.Rapidity(), massResol, initpar, true );
1120  prob = MuScleFitUtils::massProb( bestRecRes.mass(), bestRecRes.Eta(), bestRecRes.Rapidity(), massResol,
1121  initpar, true, recMu1.eta(), recMu2.eta() );
1122  } else {
1125  // prob = MuScleFitUtils::massProb( bestRecRes.mass(), bestRecRes.Eta(), bestRecRes.Rapidity(),
1126  // massResol, MuScleFitUtils::parvalue[loopCounter-1], true );
1127  prob = MuScleFitUtils::massProb( bestRecRes.mass(), bestRecRes.Eta(), bestRecRes.Rapidity(),
1128  massResol, MuScleFitUtils::parvalue[loopCounter-1], true,
1129  recMu1.eta(), recMu2.eta() );
1130  }
1131  if( debug_ > 0 ) std::cout << "inside weight: mass = " << bestRecRes.mass() << ", prob = " << prob << std::endl;
1132  if (prob>0) {
1133  if( debug_ > 0 ) std::cout << "inside prob: mass = " << bestRecRes.mass() << ", prob = " << prob << std::endl;
1134 
1135  deltalike = log(prob)*weight; // NB maximum likelihood --> deltalike is maximized
1136  mapHisto_["hLikeVSMu"]->Fill(recMu1, deltalike);
1137  mapHisto_["hLikeVSMu"]->Fill(recMu2, deltalike);
1138  mapHisto_["hLikeVSMuMinus"]->Fill(recMu1, deltalike);
1139  mapHisto_["hLikeVSMuPlus"]->Fill(recMu2, deltalike);
1140 
1141  double recoMass = (recMu1+recMu2).mass();
1142  if( recoMass != 0 ) {
1143  // IMPORTANT: massResol is not a relative resolution
1144  mapHisto_["hResolMassVSMu"]->Fill(recMu1, massResol, -1);
1145  mapHisto_["hResolMassVSMu"]->Fill(recMu2, massResol, +1);
1146  mapHisto_["hFunctionResolMassVSMu"]->Fill(recMu1, massResol/recoMass, -1);
1147  mapHisto_["hFunctionResolMassVSMu"]->Fill(recMu2, massResol/recoMass, +1);
1148  }
1149 
1151  mapHisto_["hdMdPt1"]->Fill(recMu1, MuScleFitUtils::massResolComponents.dmdpt1, -1);
1152  mapHisto_["hdMdPt2"]->Fill(recMu2, MuScleFitUtils::massResolComponents.dmdpt2, +1);
1153  mapHisto_["hdMdPhi1"]->Fill(recMu1, MuScleFitUtils::massResolComponents.dmdphi1, -1);
1154  mapHisto_["hdMdPhi2"]->Fill(recMu2, MuScleFitUtils::massResolComponents.dmdphi2, +1);
1155  mapHisto_["hdMdCotgTh1"]->Fill(recMu1, MuScleFitUtils::massResolComponents.dmdcotgth1, -1);
1156  mapHisto_["hdMdCotgTh2"]->Fill(recMu2, MuScleFitUtils::massResolComponents.dmdcotgth2, +1);
1157  }
1158 
1159  if( !MuScleFitUtils::speedup ) {
1160  double genMass = (MuScleFitUtils::genPair[iev].first + MuScleFitUtils::genPair[iev].second).mass();
1161  // Fill the mass resolution (computed from MC), we use the covariance class to compute the variance
1162  if( genMass != 0 ) {
1164  mapHisto_["hGenResVSMu"]->Fill((MuScleFitUtils::genPair[iev].second), (MuScleFitUtils::genPair[iev].first + MuScleFitUtils::genPair[iev].second), +1);
1165  double diffMass = (recoMass - genMass)/genMass;
1166  // double diffMass = recoMass - genMass;
1167  // Fill if for both muons
1168  double pt1 = recMu1.pt();
1169  double eta1 = recMu1.eta();
1170  double pt2 = recMu2.pt();
1171  double eta2 = recMu2.eta();
1172  // This is to avoid nan
1173  if( diffMass == diffMass ) {
1174  // Mass relative difference vs Pt and Eta. To be used to extract the true mass resolution
1175  mapHisto_["hDeltaMassOverGenMassVsPt"]->Fill(pt1, diffMass);
1176  mapHisto_["hDeltaMassOverGenMassVsPt"]->Fill(pt2, diffMass);
1177  mapHisto_["hDeltaMassOverGenMassVsEta"]->Fill(eta1, diffMass);
1178  mapHisto_["hDeltaMassOverGenMassVsEta"]->Fill(eta2, diffMass);
1179  // This is used for the covariance comparison
1180  mapHisto_["hMassResolutionVsPtEta"]->Fill(pt1, eta1, diffMass, diffMass);
1181  mapHisto_["hMassResolutionVsPtEta"]->Fill(pt2, eta2, diffMass, diffMass);
1182  }
1183  else {
1184  std::cout << "Error, there is a nan: recoMass = " << recoMass << ", genMass = " << genMass << std::endl;
1185  }
1186  }
1187  // Fill with mass resolution from resolution function
1189  mapHisto_["hFunctionResolMass"]->Fill( recMu1, std::pow(massRes,2), -1 );
1190  mapHisto_["hFunctionResolMass"]->Fill( recMu2, std::pow(massRes,2), +1 );
1191  }
1192 
1193  mapHisto_["hMass_P"]->Fill(bestRecRes.mass(), prob);
1194  if( debug_ > 0 ) std::cout << "mass = " << bestRecRes.mass() << ", prob = " << prob << std::endl;
1195  mapHisto_["hMass_fine_P"]->Fill(bestRecRes.mass(), prob);
1196 
1197  mapHisto_["hMassProbVsRes"]->Fill(bestRecRes, bestRecRes, +1, prob);
1198  mapHisto_["hMassProbVsMu"]->Fill(recMu1, bestRecRes, -1, prob);
1199  mapHisto_["hMassProbVsMu"]->Fill(recMu2, bestRecRes, +1, prob);
1200  mapHisto_["hMassProbVsRes_fine"]->Fill(bestRecRes, bestRecRes, +1, prob);
1201  mapHisto_["hMassProbVsMu_fine"]->Fill(recMu1, bestRecRes, -1, prob);
1202  mapHisto_["hMassProbVsMu_fine"]->Fill(recMu2, bestRecRes, +1, prob);
1203  }
1204  }
1205  } // end if ResFound
1206 
1207  // Fill the pair
1208  // -------------
1209  if (loopCounter>0) {
1210  if (debug_>0) std::cout << "[MuScleFit]: filling the pair" << std::endl;
1211  MuScleFitUtils::SavedPair[iev] = std::make_pair( recMu1, recMu2 );
1212  }
1213 
1214  iev++;
1216 
1217  // return kContinue;
1218 }
1219 
1221  //first is always mu-, second is always mu+
1222  double deltaR = sqrt(MuScleFitUtils::deltaPhi(recMu.Phi(),genMu.Phi()) * MuScleFitUtils::deltaPhi(recMu.Phi(),genMu.Phi()) +
1223  ((recMu.Eta()-genMu.Eta()) * (recMu.Eta()-genMu.Eta())));
1224  if(deltaR<0.01)
1225  return true;
1226  else if( debug_ > 0 ) {
1227  std::cout<<"Reco muon "<<recMu<<" with eta "<<recMu.Eta()<<" and phi "<<recMu.Phi()<<std::endl
1228  <<" DOES NOT MATCH with generated muon from resonance: "<<std::endl
1229  <<genMu<<" with eta "<<genMu.Eta()<<" and phi "<<genMu.Phi()<<std::endl;
1230  }
1231  return false;
1232 }
1233 
1235  const std::string & inputName, const int charge )
1236 {
1237  std::string name(inputName + "VSMu");
1238  mapHisto_["hResolPt"+name]->Fill(recMu, (-genMu.Pt()+recMu.Pt())/genMu.Pt(), charge);
1239  mapHisto_["hResolTheta"+name]->Fill(recMu, (-genMu.Theta()+recMu.Theta()), charge);
1240  mapHisto_["hResolCotgTheta"+name]->Fill(recMu,(-cos(genMu.Theta())/sin(genMu.Theta())
1241  +cos(recMu.Theta())/sin(recMu.Theta())), charge);
1242  mapHisto_["hResolEta"+name]->Fill(recMu, (-genMu.Eta()+recMu.Eta()),charge);
1243  mapHisto_["hResolPhi"+name]->Fill(recMu, MuScleFitUtils::deltaPhiNoFabs(recMu.Phi(), genMu.Phi()), charge);
1244 
1245  // Fill only if it was matched to a genMu and this muon is valid
1246  if( (genMu.Pt() != 0) && (recMu.Pt() != 0) ) {
1247  mapHisto_["hPtRecoVsPt"+inputName]->Fill(genMu.Pt(), recMu.Pt());
1248  }
1249 }
1250 
1252 {
1253  if( MuScleFitUtils::SmearType>0 ) {
1254  mu = MuScleFitUtils::applySmearing( mu );
1255  if (debug_>0) std::cout << "Muon #" << MuScleFitUtils::goodmuon
1256  << ": after smearing Pt = " << mu.Pt() << std::endl;
1257  }
1258 }
1259 
1261 {
1262  if( MuScleFitUtils::BiasType>0 ) {
1263  mu = MuScleFitUtils::applyBias( mu, charge );
1264  if (debug_>0) std::cout << "Muon #" << MuScleFitUtils::goodmuon
1265  << ": after bias Pt = " << mu.Pt() << std::endl;
1266  }
1267 }
1268 
1269 // Simple method to check parameters consistency. It aborts the job if the parameters
1270 // are not consistent.
1272 
1273  // Fits selection dimension check
1275  std::cout << "[MuScleFit-Constructor]: wrong size of resolution fits selector = " << MuScleFitUtils::doResolFit.size() << std::endl;
1276  std::cout << "it must have as many values as the number of loops, which is = " << maxLoopNumber << std::endl;
1277  abort();
1278  }
1280  std::cout << "[MuScleFit-Constructor]: wrong size of scale fits selector = " << MuScleFitUtils::doScaleFit.size() << std::endl;
1281  std::cout << "it must have as many values as the number of loops, which is = " << maxLoopNumber << std::endl;
1282  abort();
1283  }
1285  std::cout << "[MuScleFit-Constructor]: wrong size of cross section fits selector = " << MuScleFitUtils::doCrossSectionFit.size() << std::endl;
1286  std::cout << "it must have as many values as the number of loops, which is = " << maxLoopNumber << std::endl;
1287  abort();
1288  }
1290  std::cout << "[MuScleFit-Constructor]: wrong size of background fits selector = " << MuScleFitUtils::doBackgroundFit.size() << std::endl;
1291  std::cout << "it must have as many values as the number of loops, which is = " << maxLoopNumber << std::endl;
1292  abort();
1293  }
1294 
1295  // Bias parameters: dimension check
1296  // --------------------------------
1297  if ((MuScleFitUtils::BiasType==1 && MuScleFitUtils::parBias.size()!=2) || // linear in pt
1298  (MuScleFitUtils::BiasType==2 && MuScleFitUtils::parBias.size()!=2) || // linear in |eta|
1299  (MuScleFitUtils::BiasType==3 && MuScleFitUtils::parBias.size()!=4) || // sinusoidal in phi
1300  (MuScleFitUtils::BiasType==4 && MuScleFitUtils::parBias.size()!=3) || // linear in pt and |eta|
1301  (MuScleFitUtils::BiasType==5 && MuScleFitUtils::parBias.size()!=3) || // linear in pt and sinusoidal in phi
1302  (MuScleFitUtils::BiasType==6 && MuScleFitUtils::parBias.size()!=3) || // linear in |eta| and sinusoidal in phi
1303  (MuScleFitUtils::BiasType==7 && MuScleFitUtils::parBias.size()!=4) || // linear in pt and |eta| and sinusoidal in phi
1304  (MuScleFitUtils::BiasType==8 && MuScleFitUtils::parBias.size()!=4) || // linear in pt and parabolic in |eta|
1305  (MuScleFitUtils::BiasType==9 && MuScleFitUtils::parBias.size()!=2) || // exponential in pt
1306  (MuScleFitUtils::BiasType==10 && MuScleFitUtils::parBias.size()!=3) || // parabolic in pt
1307  (MuScleFitUtils::BiasType==11 && MuScleFitUtils::parBias.size()!=4) || // linear in pt and sin in phi with chg
1308  (MuScleFitUtils::BiasType==12 && MuScleFitUtils::parBias.size()!=6) || // linear in pt and para in plus sin in phi with chg
1309  (MuScleFitUtils::BiasType==13 && MuScleFitUtils::parBias.size()!=8) || // linear in pt and para in plus sin in phi with chg
1310  MuScleFitUtils::BiasType<0 || MuScleFitUtils::BiasType>13) {
1311  std::cout << "[MuScleFit-Constructor]: Wrong bias type or number of parameters: aborting!" << std::endl;
1312  abort();
1313  }
1314  // Smear parameters: dimension check
1315  // ---------------------------------
1323  MuScleFitUtils::SmearType<0 || MuScleFitUtils::SmearType>7) {
1324  std::cout << "[MuScleFit-Constructor]: Wrong smear type or number of parameters: aborting!" << std::endl;
1325  abort();
1326  }
1327  // Protect against bad size of parameters
1328  // --------------------------------------
1331  std::cout << "[MuScleFit-Constructor]: Mismatch in number of parameters for Resol: aborting!" << std::endl;
1332  abort();
1333  }
1336  std::cout << "[MuScleFit-Constructor]: Mismatch in number of parameters for Scale: aborting!" << std::endl;
1337  abort();
1338  }
1341  std::cout << "[MuScleFit-Constructor]: Mismatch in number of parameters for Bgr: aborting!" << std::endl;
1342  abort();
1343  }
1346  std::cout << "[MuScleFit-Constructor]: Mismatch in number of parameters for Bgr: aborting!" << std::endl;
1347  abort();
1348  }
1349 
1350  // Protect against an incorrect number of resonances
1351  // -------------------------------------------------
1352  if (MuScleFitUtils::resfind.size()!=6) {
1353  std::cout << "[MuScleFit-Constructor]: resfind must have 6 elements (1 Z, 3 Y, 2 Psi): aborting!" << std::endl;
1354  abort();
1355  }
1356 }
1357 
1359 
1360  reco::TrackRef iTrack = aMuon->innerTrack();
1361  const reco::HitPattern& p = iTrack->hitPattern();
1362 
1363  reco::TrackRef gTrack = aMuon->globalTrack();
1364  const reco::HitPattern& q = gTrack->hitPattern();
1365 
1366  return (//isMuonInAccept(aMuon) &&// no acceptance cuts!
1367  iTrack->found() > 11 &&
1368  gTrack->chi2()/gTrack->ndof() < 20.0 &&
1369  q.numberOfValidMuonHits() > 0 &&
1370  iTrack->chi2()/iTrack->ndof() < 4.0 &&
1371  aMuon->muonID("TrackerMuonArbitrated") &&
1372  aMuon->muonID("TMLastStationAngTight") &&
1373  p.pixelLayersWithMeasurement() > 1 &&
1374  fabs(iTrack->dxy()) < 3.0 && //should be done w.r.t. PV!
1375  fabs(iTrack->dz()) < 15.0 );//should be done w.r.t. PV!
1376 }
1377 
1378 
1380 
1381  reco::TrackRef iTrack = aMuon->innerTrack();
1382  const reco::HitPattern& p = iTrack->hitPattern();
1383 
1384  return (//isMuonInAccept(aMuon) // no acceptance cuts!
1385  iTrack->found() > 11 &&
1386  iTrack->chi2()/iTrack->ndof() < 4.0 &&
1387  aMuon->muonID("TrackerMuonArbitrated") &&
1388  aMuon->muonID("TMLastStationAngTight") &&
1389  p.pixelLayersWithMeasurement() > 1 &&
1390  fabs(iTrack->dxy()) < 3.0 && //should be done w.r.t. PV!
1391  fabs(iTrack->dz()) < 15.0 );//should be done w.r.t. PV!
1392 
1393 }
1394 
1395 
static double deltaPhiNoFabs(const double &phi1, const double &phi2)
Without fabs at the end, used to have a symmetric distribution for the resolution fits and variance c...
static std::vector< std::pair< lorentzVector, lorentzVector > > simPair
const double Pi
static std::vector< int > doScaleFit
void readTree(const int maxEvents, const TString &fileName, MuonPairVector *savedPair, const int muonType, std::vector< std::pair< int, int > > *evtRun, MuonPairVector *genPair=0)
static std::vector< int > doResolFit
T getParameter(std::string const &) const
scaleFunctionBase< double * > * scaleFunctionService(const int identifier)
Service to build the scale functor corresponding to the passed identifier.
Definition: Functions.cc:3
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
static std::vector< double > parBias
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
static std::vector< int > parCrossSectionOrder
std::vector< GenMuonPair > genMuonPairs_
Stores the genMuon pairs and the motherId prior to the creation of the internal tree.
Definition: MuScleFitBase.h:82
reco::TrackRef innerTrack() const
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.h:74
static smearFunctionBase * smearFunction
static std::vector< int > parScaleOrder
edm::InputTag theMuonLabel_
Definition: MuScleFitBase.h:46
static std::vector< int > doCrossSectionFit
double maxResMass_hwindow[6]
Definition: MuScleFit.cc:270
static void minimizeLikelihood()
static double maxMuonEtaSecondRange_
static std::vector< int > parBgrOrder
bool selGlobalMuon(const pat::Muon *aMuon)
Function for onia selections.
Definition: MuScleFit.cc:1358
static unsigned int loopCounter
static double deltaPhiMaxCut_
static std::vector< double > parResolMax
unsigned int loopCounter
Definition: MuScleFit.cc:275
bool muonID(const std::string &name) const
Definition: Muon.cc:308
int totalEvents_
Definition: MuScleFit.cc:285
static bool startWithSimplex_
std::string triggerResultsProcess_
Definition: MuScleFit.cc:300
static std::vector< int > doBackgroundFit
static std::vector< double > parResol
static bool debugMassResol_
bool saveAllToTree_
Definition: MuScleFit.cc:303
virtual void duringFastLoop()
Definition: MuScleFit.cc:966
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
void checkParameters()
Definition: MuScleFit.cc:1271
static BackgroundHandler * backgroundHandler
static double x[7][10000]
static int debug
static double ResMass[6]
int pixelLayersWithMeasurement() const
Definition: HitPattern.h:726
static double massWindowHalfWidth[3][6]
static bool speedup
#define DEFINE_FWK_LOOPER(type)
Run const & getRun() const
Definition: Event.cc:53
std::map< std::string, Histograms * > mapHisto_
The map of histograms.
Definition: MuScleFitBase.h:77
static bool ResFound
void fillTreeRec(const std::vector< std::pair< reco::Particle::LorentzVector, reco::Particle::LorentzVector > > &savedPairs)
Used when running on the root tree containing preselected muon pairs.
static scaleFunctionBase< std::vector< double > > * biasFunction
bool selTrackerMuon(const pat::Muon *aMuon)
Definition: MuScleFit.cc:1379
bool ifHepMC
Definition: MuScleFit.cc:264
Strings::size_type size() const
Definition: TriggerNames.cc:39
static std::vector< int > parBgrFix
static std::vector< double > parResolMin
static bool minimumShapePlots_
edm::InputTag simTracksCollection_
Definition: MuScleFit.cc:288
static int MuonTypeForCheckMassWindow
static double minMuonEtaFirstRange_
static double massProb(const double &mass, const double &rapidity, const int ires, const double &massResol)
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
static struct MuScleFitUtils::massResolComponentsStruct massResolComponents
Strings const & triggerNames() const
Definition: TriggerNames.cc:24
double charge(const std::vector< uint8_t > &Ampls)
std::vector< reco::LeafCandidate > fillMuonCollection(const std::vector< T > &tracks)
Definition: MuScleFit.cc:309
static int BiasType
std::vector< std::string > triggerPath_
Definition: MuScleFit.cc:301
static std::vector< int > parScaleFix
static bool computeMinosErrors_
reco::Particle::LorentzVector lorentzVector
Definition: GenMuonPair.h:8
static scaleFunctionBase< std::vector< double > > * scaleFunctionForVec
static std::vector< std::vector< double > > parvalue
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
MuonServiceProxy * theService
Definition: MuScleFit.cc:255
U second(std::pair< T, U > const &p)
static double maxMuonPt_
static int ScaleFitType
static std::vector< std::pair< lorentzVector, lorentzVector > > genPair
std::string outputRootTreeFileName_
Definition: MuScleFit.cc:295
std::string theGenInfoRootFileName_
Definition: MuScleFitBase.h:48
int numberOfSimVertices
Definition: MuScleFit.cc:261
resolutionFunctionBase< std::vector< double > > * resolutionFunctionVecService(const int identifier)
Service to build the resolution functor corresponding to the passed identifier when receiving a std::...
Definition: Functions.cc:156
virtual void startingNewLoop(unsigned int iLoop)
Definition: MuScleFit.cc:638
static double massResolution(const lorentzVector &mu1, const lorentzVector &mu2)
reco::Particle::LorentzVector recMu2
Definition: MuScleFit.cc:283
double minResMass_hwindow[6]
Definition: MuScleFit.cc:269
bool PATmuons_
Definition: MuScleFit.cc:289
static std::vector< double > parScaleMin
virtual void endOfJob()
Definition: MuScleFit.cc:632
reco::Particle::LorentzVector recMu1
Definition: MuScleFit.cc:283
static lorentzVector applyBias(const lorentzVector &muon, const int charge)
T sqrt(T t)
Definition: SSEVec.h:48
static std::vector< double > parBgr
unsigned int maxLoopNumber
Definition: MuScleFit.cc:274
static int SmearType
std::string genParticlesName_
Definition: MuScleFit.cc:290
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
RunNumber_t run() const
Definition: Event.h:76
void clearHistoMap()
Clean the histograms map.
int j
Definition: DBlmapReader.cc:9
bool compareToSimTracks_
Definition: MuScleFit.cc:287
static double computeWeight(const double &mass, const int iev, const bool doUseBkgrWindow=false)
static std::vector< double > parScaleStep
static std::vector< std::pair< lorentzVector, lorentzVector > > SavedPair
const int mu
Definition: Constants.h:23
MuScleFit(const edm::ParameterSet &pset)
Definition: MuScleFit.cc:359
static lorentzVector applyScale(const lorentzVector &muon, const std::vector< double > &parval, const int charge)
static std::vector< int > parResolFix
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 first
Definition: L1TdeRCT.cc:94
static std::vector< double > parSmear
void beginOfJobInConstructor()
Definition: MuScleFit.cc:603
smearFunctionBase * smearFunctionService(const int identifier)
Service to build the smearing functor corresponding to the passed identifier.
Definition: Functions.cc:101
reco::TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon) ...
Definition: Muon.h:82
static std::vector< int > parResolOrder
static bool sherpa_
bool fastLoop
Definition: MuScleFit.cc:277
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
int numberOfSimMuons
Definition: MuScleFit.cc:260
void writeTree(const TString &fileName, const std::vector< MuonPair > *savedPair, const int muonType=0, const std::vector< GenMuonPair > *genPair=0, const bool saveAll=false)
static std::vector< double > parScaleMax
scaleFunctionBase< std::vector< double > > * scaleFunctionVecService(const int identifier)
Service to build the scale functor corresponding to the passed identifier when receiving a std::vecto...
Definition: Functions.cc:52
void writeHistoMap(const unsigned int iLoop)
Save the histograms map to file.
static std::vector< double > parScale
static double oldNormalization_
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 const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
std::string theRootFileName_
Definition: MuScleFitBase.h:47
void fillTreeGen(const std::vector< std::pair< reco::Particle::LorentzVector, reco::Particle::LorentzVector > > &genPairs)
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
static double deltaPhiMinCut_
std::string triggerResultsLabel_
Definition: MuScleFit.cc:299
static bool rapidityBinsForZ_
void fillHistoMap(TFile *outputFile, unsigned int iLoop)
Create the histograms map.
Definition: MuScleFitBase.cc:7
std::vector< TFile * > theFiles_
The files were the histograms are saved.
Definition: MuScleFitBase.h:74
static int ResolFitType
static int goodmuon
static bool separateRanges_
static double minMuonEtaSecondRange_
static int iev_
static std::vector< double > parCrossSection
static const double mMu2
tuple muons
Definition: patZpeak.py:38
static lorentzVector applySmearing(const lorentzVector &muon)
static bool normalizeLikelihoodByEventNumber_
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
resolutionFunctionBase< double * > * resolutionFunctionService(const int identifier)
Service to build the resolution functor corresponding to the passed identifier.
Definition: Functions.cc:116
int maxEventsFromRootTree_
Definition: MuScleFit.cc:297
static int MuonType
std::vector< MuonPair > muonPairs_
Used to store the muon pairs plus run and event number prior to the creation of the internal tree...
Definition: MuScleFitBase.h:80
static double deltaPhi(const double &phi1, const double &phi2)
tuple cout
Definition: gather_cfg.py:121
static double minMuonPt_
static scaleFunctionBase< double * > * scaleFunction
int numberOfValidMuonHits() const
Definition: HitPattern.h:578
static bool useProbsFile_
int weight
Definition: histoStyle.py:50
static std::vector< int > resfind
void readProbabilityDistributionsFromFile()
Read probability distributions from a local root file.
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
static int counter_resprob
static resolutionFunctionBase< std::vector< double > > * resolutionFunctionForVec
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:25
static int FitStrategy
Analysis-level muon class.
Definition: Muon.h:51
static double maxMuonEtaFirstRange_
tuple size
Write out results.
static std::pair< lorentzVector, lorentzVector > findBestRecoRes(const std::vector< reco::LeafCandidate > &muons)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
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
static CrossSectionHandler * crossSectionHandler
MuScleFitPlotter * plotter
Definition: MuScleFit.cc:279
static std::vector< double > parResolStep
static std::vector< int > parCrossSectionFix
static resolutionFunctionBase< double * > * resolutionFunction
virtual edm::EDLooper::Status duringLoop(const edm::Event &event, const edm::EventSetup &eventSetup)
Definition: MuScleFit.cc:748
void addParameters(std::vector< double > &initpar)
Inputs the vars in a vector.
virtual void endOfFastLoop(const unsigned int iLoop)
Definition: MuScleFit.cc:712
int numberOfEwkZ
Definition: MuScleFit.cc:262