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