CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
MuScleFit Class Reference
Inheritance diagram for MuScleFit:
edm::EDLooper MuScleFitBase edm::EDLooperBase edm::EDConsumerBase

Public Member Functions

void beginOfJobInConstructor ()
 
virtual void duringFastLoop ()
 
edm::EDLooper::Status duringLoop (const edm::Event &event, const edm::EventSetup &eventSetup) override
 
virtual void endOfFastLoop (const unsigned int iLoop)
 
void endOfJob () override
 
edm::EDLooper::Status endOfLoop (const edm::EventSetup &eventSetup, unsigned int iLoop) override
 
template<typename T >
std::vector< MuScleFitMuonfillMuonCollection (const std::vector< T > &tracks)
 
 MuScleFit (const edm::ParameterSet &pset)
 
void startingNewLoop (unsigned int iLoop) override
 
 ~MuScleFit () override
 
- Public Member Functions inherited from edm::EDLooper
 EDLooper ()
 
 EDLooper (EDLooper const &)=delete
 
EDLooperoperator= (EDLooper const &)=delete
 
 ~EDLooper () override
 
- Public Member Functions inherited from edm::EDLooperBase
virtual void attachTo (ActivityRegistry &)
 Override this method if you need to monitor the state of the processing. More...
 
void beginOfJob (EventSetupImpl const &)
 
virtual void beginOfJob (EventSetup const &)
 
virtual void beginOfJob ()
 
void copyInfo (ScheduleInfo const &)
 
void doBeginLuminosityBlock (LuminosityBlockPrincipal &, EventSetupImpl const &, ProcessContext *)
 
void doBeginRun (RunPrincipal &, EventSetupImpl const &, ProcessContext *)
 
Status doDuringLoop (EventPrincipal &eventPrincipal, EventSetupImpl const &es, ProcessingController &, StreamContext *)
 
void doEndLuminosityBlock (LuminosityBlockPrincipal &, EventSetupImpl const &, ProcessContext *)
 
Status doEndOfLoop (EventSetupImpl const &es)
 
void doEndRun (RunPrincipal &, EventSetupImpl const &, ProcessContext *)
 
void doStartingNewLoop ()
 
 EDLooperBase ()
 
 EDLooperBase (EDLooperBase const &)=delete
 
void esPrefetchAsync (WaitingTaskHolder iTask, EventSetupImpl const &iImpl, Transition iTrans, ServiceToken const &iToken) const
 
virtual std::set< eventsetup::EventSetupRecordKeymodifyingRecords () const
 
EDLooperBaseoperator= (EDLooperBase const &)=delete
 
void prefetchAsync (WaitingTaskHolder iTask, ServiceToken const &token, Transition iTrans, Principal const &iPrincipal, EventSetupImpl const &iImpl) const
 
void prepareForNextLoop (eventsetup::EventSetupProvider *esp)
 
void setActionTable (ExceptionToActionTable const *actionTable)
 
void setModuleChanger (ModuleChanger *)
 
 ~EDLooperBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Member Functions

void applyBias (reco::Particle::LorentzVector &mu, const int charge)
 Apply the bias if needed using the function in MuScleFitUtils. More...
 
void applySmearing (reco::Particle::LorentzVector &mu)
 Apply the smearing if needed using the function in MuScleFitUtils. More...
 
bool checkDeltaR (reco::Particle::LorentzVector &genMu, reco::Particle::LorentzVector &recMu)
 Check if two lorentzVector are near in deltaR. More...
 
void checkParameters ()
 
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. More...
 
void selectMuons (const edm::Event &event)
 
void selectMuons (const int maxEvents, const TString &treeFileName)
 
bool selGlobalMuon (const pat::Muon *aMuon)
 Function for onia selections. More...
 
bool selTrackerMuon (const pat::Muon *aMuon)
 
template<typename T >
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. More...
 
- Protected Member Functions inherited from edm::EDLooperBase
ModuleChangermoduleChanger ()
 This only returns a non-zero value during the call to endOfLoop. More...
 
ScheduleInfo const * scheduleInfo () const
 This returns a non-zero value after the constructor has been called. More...
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Protected Attributes

bool compareToSimTracks_
 
bool fastLoop
 
edm::EDGetTokenT< GenEventInfoProductgenEvtInfoToken_
 
std::string genParticlesName_
 
int iev
 
bool ifGenPart
 
bool ifHepMC
 
std::string inputRootTreeFileName_
 
unsigned int loopCounter
 
int maxEventsFromRootTree_
 
unsigned int maxLoopNumber
 
double maxResMass_hwindow [6]
 
double minResMass_hwindow [6]
 
std::unique_ptr< MuScleFitMuonSelectormuonSelector_
 
bool negateTrigger_
 
int numberOfEwkZ
 
int numberOfSimMuons
 
int numberOfSimTracks
 
int numberOfSimVertices
 
std::string outputRootTreeFileName_
 
bool PATmuons_
 
MuScleFitPlotterplotter
 
edm::InputTag puInfoSrc_
 
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > puInfoToken_
 
reco::Particle::LorentzVector recMu1
 
reco::Particle::LorentzVector recMu2
 
MuScleFitMuon recMuScleMu1
 
MuScleFitMuon recMuScleMu2
 
bool saveAllToTree_
 
edm::InputTag simTracksCollection_
 
MuonServiceProxytheService
 
int totalEvents_
 
std::vector< std::string > triggerPath_
 
std::string triggerResultsLabel_
 
std::string triggerResultsProcess_
 
edm::EDGetTokenT< edm::TriggerResultstriggerResultsToken_
 
edm::InputTag vertexSrc_
 
edm::EDGetTokenT< reco::VertexCollectionvertexToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDLooperBase
enum  Status { kContinue, kStop }
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Private Member Functions inherited from MuScleFitBase
 MuScleFitBase (const edm::ParameterSet &iConfig)
 
virtual ~MuScleFitBase () noexcept(false)
 
void clearHistoMap ()
 Clean the histograms map. More...
 
void fillHistoMap (TFile *outputFile, unsigned int iLoop)
 Create the histograms map. More...
 
void readProbabilityDistributionsFromFile ()
 Read probability distributions from a local root file. More...
 
void writeHistoMap (const unsigned int iLoop)
 Save the histograms map to file. More...
 
- Private Attributes inherited from MuScleFitBase
int debug_
 
std::vector< GenMuonPairgenMuonPairs_
 Stores the genMuon pairs and the motherId prior to the creation of the internal tree. More...
 
std::map< std::string, Histograms * > mapHisto_
 The map of histograms. More...
 
std::vector< MuonPairmuonPairs_
 Used to store the muon pairs plus run and event number prior to the creation of the internal tree. More...
 
std::string probabilitiesFile_
 
std::string probabilitiesFileInPath_
 
int theCompressionSettings_
 
std::vector< TFile * > theFiles_
 The files were the histograms are saved. More...
 
std::string theGenInfoRootFileName_
 
edm::InputTag theMuonLabel_
 
int theMuonType_
 
std::string theRootFileName_
 

Detailed Description

Analyzer of the Global muon tracks

Definition at line 185 of file MuScleFit.cc.

Constructor & Destructor Documentation

◆ MuScleFit()

MuScleFit::MuScleFit ( const edm::ParameterSet pset)

Definition at line 378 of file MuScleFit.cc.

References MuScleFitUtils::backgroundHandler, beginOfJobInConstructor(), MuScleFitUtils::biasFunction, MuScleFitUtils::BiasType, checkParameters(), compareToSimTracks_, MuScleFitUtils::computeMinosErrors_, edm::EDConsumerBase::consumesCollector(), gather_cfg::cout, MuScleFitUtils::crossSectionHandler, MuScleFitUtils::debug, MuScleFitBase::debug_, MuScleFitUtils::debugMassResol_, MuScleFitUtils::deltaPhiMaxCut_, MuScleFitUtils::deltaPhiMinCut_, MuScleFitUtils::doBackgroundFit, MuScleFitUtils::doCrossSectionFit, MuScleFitUtils::doResolFit, MuScleFitUtils::doScaleFit, beamvalidation::exit(), fastLoop, MuScleFitUtils::FitStrategy, cmssw_cycle_finder::G, genEvtInfoToken_, genParticlesName_, MuScleFitUtils::goodmuon, mps_fire::i, inputRootTreeFileName_, ProducerED_cfi::InputTag, dqmiolumiharvest::j, loopCounter, MuScleFitUtils::massWindowHalfWidth, maxEventsFromRootTree_, maxLoopNumber, MuScleFitUtils::maxMuonEtaFirstRange_, MuScleFitUtils::maxMuonEtaSecondRange_, MuScleFitUtils::maxMuonPt_, maxResMass_hwindow, MuScleFitUtils::minimumShapePlots_, MuScleFitUtils::minMuonEtaFirstRange_, MuScleFitUtils::minMuonEtaSecondRange_, MuScleFitUtils::minMuonPt_, minResMass_hwindow, muonSelector_, MuScleFitUtils::MuonType, MuScleFitUtils::MuonTypeForCheckMassWindow, negateTrigger_, MuScleFitUtils::normalizeLikelihoodByEventNumber_, outputRootTreeFileName_, MuScleFitUtils::parBgr, MuScleFitUtils::parBgrFix, MuScleFitUtils::parBgrOrder, MuScleFitUtils::parBias, MuScleFitUtils::parCrossSection, MuScleFitUtils::parCrossSectionFix, MuScleFitUtils::parCrossSectionOrder, MuScleFitUtils::parResol, MuScleFitUtils::parResolFix, MuScleFitUtils::parResolMax, MuScleFitUtils::parResolMin, MuScleFitUtils::parResolOrder, MuScleFitUtils::parResolStep, MuScleFitUtils::parScale, MuScleFitUtils::parScaleFix, MuScleFitUtils::parScaleMax, MuScleFitUtils::parScaleMin, MuScleFitUtils::parScaleOrder, MuScleFitUtils::parScaleStep, MuScleFitUtils::parSmear, PATmuons_, Pi, muonDTDigis_cfi::pset, puInfoSrc_, puInfoToken_, MuScleFitUtils::rapidityBinsForZ_, MuScleFitUtils::resfind, MuScleFitUtils::ResMass, MuScleFitUtils::ResolFitType, MuScleFitUtils::resolutionFunction, MuScleFitUtils::resolutionFunctionForVec, resolutionFunctionService(), resolutionFunctionVecService(), saveAllToTree_, MuScleFitUtils::ScaleFitType, MuScleFitUtils::scaleFunction, MuScleFitUtils::scaleFunctionForVec, scaleFunctionService(), scaleFunctionVecService(), MuScleFitUtils::separateRanges_, MuScleFitUtils::sherpa_, simTracksCollection_, MuScleFitUtils::smearFunction, smearFunctionService(), MuScleFitUtils::SmearType, MuScleFitUtils::speedup, mathSSE::sqrt(), MuScleFitUtils::startWithSimplex_, AlCaHLTBitMon_QueryRunRegistry::string, MuScleFitBase::theMuonLabel_, MuScleFitBase::theMuonType_, triggerPath_, triggerResultsLabel_, triggerResultsProcess_, triggerResultsToken_, MuScleFitUtils::useProbsFile_, vertexSrc_, vertexToken_, and MuScleFitUtils::x.

380  if (debug_ > 0)
381  std::cout << "[MuScleFit]: Constructor" << std::endl;
382 
383  if ((theMuonType_ < -4 || theMuonType_ > 5) && theMuonType_ < 10) {
384  std::cout << "[MuScleFit]: Unknown muon type! Aborting." << std::endl;
385  abort();
386  }
387 
388  loopCounter = 0;
389 
390  // Boundaries for h-function computation (to be improved!)
391  // -------------------------------------------------------
392  minResMass_hwindow[0] = 71.1876; // 76.;
393  maxResMass_hwindow[0] = 111.188; // 106.;
394  minResMass_hwindow[1] = 10.15;
395  maxResMass_hwindow[1] = 10.55;
396  minResMass_hwindow[2] = 9.8;
397  maxResMass_hwindow[2] = 10.2;
398  minResMass_hwindow[3] = 9.25;
399  maxResMass_hwindow[3] = 9.65;
400  minResMass_hwindow[4] = 3.58;
401  maxResMass_hwindow[4] = 3.78;
402  minResMass_hwindow[5] = 3.0;
403  maxResMass_hwindow[5] = 3.2;
404 
405  // Max number of loops (if > 2 then try to minimize likelihood more than once)
406  // ---------------------------------------------------------------------------
407  maxLoopNumber = pset.getUntrackedParameter<int>("maxLoopNumber", 2);
408  fastLoop = pset.getUntrackedParameter<bool>("FastLoop", true);
409 
410  // Selection of fits according to loop
411  MuScleFitUtils::doResolFit = pset.getParameter<std::vector<int> >("doResolFit");
412  MuScleFitUtils::doScaleFit = pset.getParameter<std::vector<int> >("doScaleFit");
413  MuScleFitUtils::doCrossSectionFit = pset.getParameter<std::vector<int> >("doCrossSectionFit");
414  MuScleFitUtils::doBackgroundFit = pset.getParameter<std::vector<int> >("doBackgroundFit");
415 
416  // Bias and smear types
417  // --------------------
418  int biasType = pset.getParameter<int>("BiasType");
419  MuScleFitUtils::BiasType = biasType;
420  // No error, the scale functions are used also for the bias
422  int smearType = pset.getParameter<int>("SmearType");
423  MuScleFitUtils::SmearType = smearType;
425 
426  // Fit types
427  // ---------
428  int resolFitType = pset.getParameter<int>("ResolFitType");
429  MuScleFitUtils::ResolFitType = resolFitType;
432  int scaleType = pset.getParameter<int>("ScaleFitType");
433  MuScleFitUtils::ScaleFitType = scaleType;
436 
437  // Initial parameters values
438  // -------------------------
439  MuScleFitUtils::parBias = pset.getParameter<std::vector<double> >("parBias");
440  MuScleFitUtils::parSmear = pset.getParameter<std::vector<double> >("parSmear");
441  MuScleFitUtils::parResol = pset.getParameter<std::vector<double> >("parResol");
443  pset.getUntrackedParameter<std::vector<double> >("parResolStep", std::vector<double>());
444  MuScleFitUtils::parResolMin = pset.getUntrackedParameter<std::vector<double> >("parResolMin", std::vector<double>());
445  MuScleFitUtils::parResolMax = pset.getUntrackedParameter<std::vector<double> >("parResolMax", std::vector<double>());
446  MuScleFitUtils::parScale = pset.getParameter<std::vector<double> >("parScale");
448  pset.getUntrackedParameter<std::vector<double> >("parScaleStep", std::vector<double>());
449  MuScleFitUtils::parScaleMin = pset.getUntrackedParameter<std::vector<double> >("parScaleMin", std::vector<double>());
450  MuScleFitUtils::parScaleMax = pset.getUntrackedParameter<std::vector<double> >("parScaleMax", std::vector<double>());
451  MuScleFitUtils::parCrossSection = pset.getParameter<std::vector<double> >("parCrossSection");
452  MuScleFitUtils::parBgr = pset.getParameter<std::vector<double> >("parBgr");
453  MuScleFitUtils::parResolFix = pset.getParameter<std::vector<int> >("parResolFix");
454  MuScleFitUtils::parScaleFix = pset.getParameter<std::vector<int> >("parScaleFix");
455  MuScleFitUtils::parCrossSectionFix = pset.getParameter<std::vector<int> >("parCrossSectionFix");
456  MuScleFitUtils::parBgrFix = pset.getParameter<std::vector<int> >("parBgrFix");
457  MuScleFitUtils::parResolOrder = pset.getParameter<std::vector<int> >("parResolOrder");
458  MuScleFitUtils::parScaleOrder = pset.getParameter<std::vector<int> >("parScaleOrder");
459  MuScleFitUtils::parCrossSectionOrder = pset.getParameter<std::vector<int> >("parCrossSectionOrder");
460  MuScleFitUtils::parBgrOrder = pset.getParameter<std::vector<int> >("parBgrOrder");
461 
462  MuScleFitUtils::resfind = pset.getParameter<std::vector<int> >("resfind");
463  MuScleFitUtils::FitStrategy = pset.getParameter<int>("FitStrategy");
464 
465  // Option to skip unnecessary stuff
466  // --------------------------------
467  MuScleFitUtils::speedup = pset.getParameter<bool>("speedup");
468 
469  // Option to skip simTracks comparison
470  compareToSimTracks_ = pset.getParameter<bool>("compareToSimTracks");
471  simTracksCollection_ = pset.getUntrackedParameter<edm::InputTag>("SimTracksCollection", edm::InputTag("g4SimHits"));
472 
473  triggerResultsLabel_ = pset.getUntrackedParameter<std::string>("TriggerResultsLabel");
474  triggerResultsProcess_ = pset.getUntrackedParameter<std::string>("TriggerResultsProcess");
475 
477  consumes<edm::TriggerResults>(edm::InputTag(triggerResultsLabel_.c_str(), "", triggerResultsProcess_.c_str()));
478 
479  triggerPath_ = pset.getUntrackedParameter<std::vector<std::string> >("TriggerPath");
480  negateTrigger_ = pset.getUntrackedParameter<bool>("NegateTrigger", false);
481  saveAllToTree_ = pset.getUntrackedParameter<bool>("SaveAllToTree", false);
482 
483  // input collections for PU related infos
484  puInfoSrc_ = pset.getUntrackedParameter<edm::InputTag>("PileUpSummaryInfo");
485  puInfoToken_ = consumes<std::vector<PileupSummaryInfo> >(puInfoSrc_);
486 
487  vertexSrc_ = pset.getUntrackedParameter<edm::InputTag>("PrimaryVertexCollection");
488  vertexToken_ = consumes<reco::VertexCollection>(vertexSrc_);
489 
490  genEvtInfoToken_ = consumes<GenEventInfoProduct>(edm::InputTag("generator"));
491 
492  PATmuons_ = pset.getUntrackedParameter<bool>("PATmuons", false);
493  genParticlesName_ = pset.getUntrackedParameter<std::string>("GenParticlesName", "genParticles");
494 
495  // Use the probability file or not. If not it will perform a simpler selection taking the muon pair with
496  // invariant mass closer to the pdf value and will crash if some fit is attempted.
497  MuScleFitUtils::useProbsFile_ = pset.getUntrackedParameter<bool>("UseProbsFile", true);
498 
499  // This must be set to true if using events generated with Sherpa
500  MuScleFitUtils::sherpa_ = pset.getUntrackedParameter<bool>("Sherpa", false);
501 
502  MuScleFitUtils::rapidityBinsForZ_ = pset.getUntrackedParameter<bool>("RapidityBinsForZ", true);
503 
504  // Set the cuts on muons to be used in the fit
505  MuScleFitUtils::separateRanges_ = pset.getUntrackedParameter<bool>("SeparateRanges", true);
506  MuScleFitUtils::maxMuonPt_ = pset.getUntrackedParameter<double>("MaxMuonPt", 100000000.);
507  MuScleFitUtils::minMuonPt_ = pset.getUntrackedParameter<double>("MinMuonPt", 0.);
508  MuScleFitUtils::minMuonEtaFirstRange_ = pset.getUntrackedParameter<double>("MinMuonEtaFirstRange", -6.);
509  MuScleFitUtils::maxMuonEtaFirstRange_ = pset.getUntrackedParameter<double>("MaxMuonEtaFirstRange", 6.);
510  MuScleFitUtils::minMuonEtaSecondRange_ = pset.getUntrackedParameter<double>("MinMuonEtaSecondRange", -100.);
511  MuScleFitUtils::maxMuonEtaSecondRange_ = pset.getUntrackedParameter<double>("MaxMuonEtaSecondRange", 100.);
512  MuScleFitUtils::deltaPhiMinCut_ = pset.getUntrackedParameter<double>("DeltaPhiMinCut", -100.);
513  MuScleFitUtils::deltaPhiMaxCut_ = pset.getUntrackedParameter<double>("DeltaPhiMaxCut", 100.);
514 
515  MuScleFitUtils::debugMassResol_ = pset.getUntrackedParameter<bool>("DebugMassResol", false);
516  // MuScleFitUtils::massResolComponentsStruct MuScleFitUtils::massResolComponents;
517 
518  // Check for parameters consistency
519  // it will abort in case of errors.
520  checkParameters();
521 
522  // Generate array of gaussian-distributed numbers for smearing
523  // -----------------------------------------------------------
524  if (MuScleFitUtils::SmearType > 0) {
525  std::cout << "[MuScleFit-Constructor]: Generating random values for smearing" << std::endl;
526  TF1 G("G", "[0]*exp(-0.5*pow(x,2))", -5., 5.);
527  double norm = 1 / sqrt(2 * TMath::Pi());
528  G.SetParameter(0, norm);
529  for (int i = 0; i < 10000; i++) {
530  for (int j = 0; j < 7; j++) {
531  MuScleFitUtils::x[j][i] = G.GetRandom();
532  }
533  }
534  }
536 
537  if (theMuonType_ > 0 && theMuonType_ < 4) {
540  } else if (theMuonType_ == 0 || theMuonType_ == 4 || theMuonType_ == 5 || theMuonType_ >= 10 || theMuonType_ == -1 ||
541  theMuonType_ == -2 || theMuonType_ == -3 || theMuonType_ == -4) {
544  } else {
545  std::cout << "Wrong muon type " << theMuonType_ << std::endl;
546  exit(1);
547  }
548 
549  // When using standalone muons switch to the single Z pdf
550  if (theMuonType_ == 2) {
552  }
553 
554  // Initialize ResMaxSigma And ResHalfWidth - 0 = global, 1 = SM, 2 = tracker
555  // -------------------------------------------------------------------------
574 
576  muonSelector_ = std::make_unique<MuScleFitMuonSelector>(iC,
578  theMuonType_,
579  PATmuons_,
586  debug_);
587 
589  new BackgroundHandler(pset.getParameter<std::vector<int> >("BgrFitType"),
590  pset.getParameter<std::vector<double> >("LeftWindowBorder"),
591  pset.getParameter<std::vector<double> >("RightWindowBorder"),
594 
597 
598  // Build cross section scale factors
599  // MuScleFitUtils::resfind
600 
602  pset.getUntrackedParameter<bool>("NormalizeLikelihoodByEventNumber", true);
603  if (debug_ > 0)
604  std::cout << "End of MuScleFit constructor" << std::endl;
605 
606  inputRootTreeFileName_ = pset.getParameter<std::string>("InputRootTreeFileName");
607  outputRootTreeFileName_ = pset.getParameter<std::string>("OutputRootTreeFileName");
608  maxEventsFromRootTree_ = pset.getParameter<int>("MaxEventsFromRootTree");
609 
610  MuScleFitUtils::startWithSimplex_ = pset.getParameter<bool>("StartWithSimplex");
611  MuScleFitUtils::computeMinosErrors_ = pset.getParameter<bool>("ComputeMinosErrors");
612  MuScleFitUtils::minimumShapePlots_ = pset.getParameter<bool>("MinimumShapePlots");
613 
615 }
const double Pi
static std::vector< int > doScaleFit
static std::vector< int > doResolFit
MuScleFitBase(const edm::ParameterSet &iConfig)
Definition: MuScleFitBase.h:20
static std::vector< double > parBias
static std::vector< int > parCrossSectionOrder
static smearFunctionBase * smearFunction
static std::vector< int > parScaleOrder
edm::InputTag theMuonLabel_
Definition: MuScleFitBase.h:48
static std::vector< int > doCrossSectionFit
static double maxMuonEtaSecondRange_
static std::vector< int > parBgrOrder
static double deltaPhiMaxCut_
static std::vector< double > parResolMax
unsigned int loopCounter
Definition: MuScleFit.cc:277
int totalEvents_
Definition: MuScleFit.cc:288
static bool startWithSimplex_
std::string triggerResultsProcess_
Definition: MuScleFit.cc:308
static std::vector< int > doBackgroundFit
static std::vector< double > parResol
static bool debugMassResol_
bool saveAllToTree_
Definition: MuScleFit.cc:311
void checkParameters()
Definition: MuScleFit.cc:1424
static BackgroundHandler * backgroundHandler
static double x[7][10000]
static int debug
static double ResMass[6]
edm::InputTag vertexSrc_
Definition: MuScleFit.cc:315
static double massWindowHalfWidth[3][6]
static bool speedup
static scaleFunctionBase< std::vector< double > > * biasFunction
static std::vector< int > parBgrFix
static std::vector< double > parResolMin
static bool minimumShapePlots_
edm::InputTag simTracksCollection_
Definition: MuScleFit.cc:291
static int MuonTypeForCheckMassWindow
static double minMuonEtaFirstRange_
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
Definition: MuScleFit.cc:303
static int BiasType
std::vector< std::string > triggerPath_
Definition: MuScleFit.cc:309
static std::vector< int > parScaleFix
static bool computeMinosErrors_
static scaleFunctionBase< std::vector< double > > * scaleFunctionForVec
resolutionFunctionBase< double * > * resolutionFunctionService(const int identifier)
Service to build the resolution functor corresponding to the passed identifier.
Definition: Functions.cc:70
static double maxMuonPt_
static int ScaleFitType
std::string outputRootTreeFileName_
Definition: MuScleFit.cc:298
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:92
bool PATmuons_
Definition: MuScleFit.cc:292
static std::vector< double > parScaleMin
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
T sqrt(T t)
Definition: SSEVec.h:19
static std::vector< double > parBgr
unsigned int maxLoopNumber
Definition: MuScleFit.cc:276
static int SmearType
std::string genParticlesName_
Definition: MuScleFit.cc:293
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > puInfoToken_
Definition: MuScleFit.cc:304
scaleFunctionBase< double * > * scaleFunctionService(const int identifier)
Service to build the scale functor corresponding to the passed identifier.
Definition: Functions.cc:3
bool compareToSimTracks_
Definition: MuScleFit.cc:290
static std::vector< double > parScaleStep
static std::vector< int > parResolFix
static std::vector< double > parSmear
void beginOfJobInConstructor()
Definition: MuScleFit.cc:655
smearFunctionBase * smearFunctionService(const int identifier)
Service to build the smearing functor corresponding to the passed identifier.
Definition: Functions.cc:37
edm::EDGetTokenT< GenEventInfoProduct > genEvtInfoToken_
Definition: MuScleFit.cc:305
static std::vector< int > parResolOrder
static bool sherpa_
bool fastLoop
Definition: MuScleFit.cc:279
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:20
static std::vector< double > parScale
edm::InputTag puInfoSrc_
Definition: MuScleFit.cc:314
static double deltaPhiMinCut_
std::string triggerResultsLabel_
Definition: MuScleFit.cc:307
static bool rapidityBinsForZ_
double minResMass_hwindow[6]
Definition: MuScleFit.cc:271
static int ResolFitType
static int goodmuon
static bool separateRanges_
static double minMuonEtaSecondRange_
static std::vector< double > parCrossSection
static bool normalizeLikelihoodByEventNumber_
std::string inputRootTreeFileName_
Definition: MuScleFit.cc:296
int maxEventsFromRootTree_
Definition: MuScleFit.cc:300
double maxResMass_hwindow[6]
Definition: MuScleFit.cc:272
static int MuonType
static double minMuonPt_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
Definition: MuScleFit.cc:302
static scaleFunctionBase< double * > * scaleFunction
static bool useProbsFile_
static std::vector< int > resfind
static resolutionFunctionBase< std::vector< double > > * resolutionFunctionForVec
static int FitStrategy
static double maxMuonEtaFirstRange_
std::unique_ptr< MuScleFitMuonSelector > muonSelector_
Definition: MuScleFit.cc:317
bool negateTrigger_
Definition: MuScleFit.cc:310
static CrossSectionHandler * crossSectionHandler
static std::vector< double > parResolStep
static std::vector< int > parCrossSectionFix
static resolutionFunctionBase< double * > * resolutionFunction
def exit(msg="")

◆ ~MuScleFit()

MuScleFit::~MuScleFit ( )
override

Definition at line 619 of file MuScleFit.cc.

References gather_cfg::cout, MuScleFitBase::debug_, MuScleFitBase::genMuonPairs_, inputRootTreeFileName_, createfilelist::int, MuScleFitBase::muonPairs_, outputRootTreeFileName_, saveAllToTree_, MuScleFitUtils::SavedPair, findQualityFiles::size, MuScleFitUtils::speedup, MuScleFitBase::theMuonType_, totalEvents_, and RootTreeHandler::writeTree().

619  {
620  if (debug_ > 0)
621  std::cout << "[MuScleFit]: Destructor" << std::endl;
622  std::cout << "Total number of analyzed events = " << totalEvents_ << std::endl;
623 
624  if (!(outputRootTreeFileName_.empty())) {
625  // 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_
627  std::cout << "Saving muon pairs to root tree" << std::endl;
628  RootTreeHandler rootTreeHandler;
630  // rootTreeHandler.writeTree(outputRootTreeFileName_, &(MuScleFitUtils::SavedPair), theMuonType_, 0, saveAllToTree_);
631  if (debug_ > 0) {
632  std::vector<MuonPair>::const_iterator it = muonPairs_.begin();
633  std::cout << "[MuScleFit::~MuScleFit] (Destructor)" << std::endl;
634  for (; it < muonPairs_.end(); ++it) {
635  std::cout << " Debugging pairs that are going to be written to file" << std::endl;
636  std::cout << " muon1 = " << it->mu1 << std::endl;
637  std::cout << " muon2 = " << it->mu2 << std::endl;
638  }
639  }
641  } else {
642  // rootTreeHandler.writeTree(outputRootTreeFileName_, &(MuScleFitUtils::SavedPair), theMuonType_, &(MuScleFitUtils::genPair), saveAllToTree_ );
643  rootTreeHandler.writeTree(
645  }
646  } else {
647  std::cout << "ERROR: events in the vector = " << MuScleFitUtils::SavedPair.size()
648  << " != totalEvents = " << totalEvents_ << std::endl;
649  }
650  }
651 }
size
Write out results.
std::vector< GenMuonPair > genMuonPairs_
Stores the genMuon pairs and the motherId prior to the creation of the internal tree.
Definition: MuScleFitBase.h:84
int totalEvents_
Definition: MuScleFit.cc:288
bool saveAllToTree_
Definition: MuScleFit.cc:311
static bool speedup
void writeTree(const TString &fileName, const std::vector< MuonPair > *savedPair, const int muonType=0, const std::vector< GenMuonPair > *genPair=nullptr, const bool saveAll=false)
std::string outputRootTreeFileName_
Definition: MuScleFit.cc:298
static std::vector< std::pair< lorentzVector, lorentzVector > > SavedPair
std::string inputRootTreeFileName_
Definition: MuScleFit.cc:296
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:82

Member Function Documentation

◆ applyBias()

void MuScleFit::applyBias ( reco::Particle::LorentzVector mu,
const int  charge 
)
protected

Apply the bias if needed using the function in MuScleFitUtils.

Definition at line 1414 of file MuScleFit.cc.

References MuScleFitUtils::applyBias(), MuScleFitUtils::BiasType, ALCARECOTkAlJpsiMuMu_cff::charge, gather_cfg::cout, MuScleFitBase::debug_, MuScleFitUtils::goodmuon, and amptDefaultParameters_cff::mu.

Referenced by fillMuonCollection(), and selectMuons().

1414  {
1415  if (MuScleFitUtils::BiasType > 0) {
1417  if (debug_ > 0)
1418  std::cout << "Muon #" << MuScleFitUtils::goodmuon << ": after bias Pt = " << mu.Pt() << std::endl;
1419  }
1420 }
static int BiasType
static lorentzVector applyBias(const lorentzVector &muon, const int charge)
static int goodmuon

◆ applySmearing()

void MuScleFit::applySmearing ( reco::Particle::LorentzVector mu)
protected

Apply the smearing if needed using the function in MuScleFitUtils.

Definition at line 1406 of file MuScleFit.cc.

References MuScleFitUtils::applySmearing(), gather_cfg::cout, MuScleFitBase::debug_, MuScleFitUtils::goodmuon, amptDefaultParameters_cff::mu, and MuScleFitUtils::SmearType.

Referenced by fillMuonCollection(), and selectMuons().

1406  {
1407  if (MuScleFitUtils::SmearType > 0) {
1409  if (debug_ > 0)
1410  std::cout << "Muon #" << MuScleFitUtils::goodmuon << ": after smearing Pt = " << mu.Pt() << std::endl;
1411  }
1412 }
static int SmearType
static int goodmuon
static lorentzVector applySmearing(const lorentzVector &muon)

◆ beginOfJobInConstructor()

void MuScleFit::beginOfJobInConstructor ( )

Definition at line 655 of file MuScleFit.cc.

References gather_cfg::cout, MuScleFitPlotter::debug, MuScleFitBase::debug_, mps_fire::i, maxLoopNumber, plotter, MuScleFitBase::readProbabilityDistributionsFromFile(), CSCSkim_cfi::rootFileName, contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, MuScleFitBase::theCompressionSettings_, MuScleFitBase::theFiles_, MuScleFitBase::theGenInfoRootFileName_, MuScleFitBase::theRootFileName_, and MuScleFitUtils::useProbsFile_.

Referenced by MuScleFit().

658 {
659  if (debug_ > 0)
660  std::cout << "[MuScleFit]: beginOfJob" << std::endl;
661  //if(maxLoopNumber>1)
664  }
665 
666  if (debug_ > 0)
667  std::cout << "[MuScleFit]: beginOfJob" << std::endl;
668 
669  // Create the root file
670  // --------------------
671  for (unsigned int i = 0; i < (maxLoopNumber); i++) {
672  std::stringstream ss;
673  ss << i;
675  if (theCompressionSettings_ > -1) {
676  theFiles_.push_back(new TFile(rootFileName.c_str(), "RECREATE", "", theCompressionSettings_));
677  } else {
678  theFiles_.push_back(new TFile(rootFileName.c_str(), "RECREATE"));
679  }
680  }
681  if (debug_ > 0)
682  std::cout << "[MuScleFit]: Root file created" << std::endl;
683 
684  std::cout << "creating plotter" << std::endl;
686  plotter->debug = debug_;
687 }
int theCompressionSettings_
Definition: MuScleFitBase.h:49
std::string theGenInfoRootFileName_
Definition: MuScleFitBase.h:51
unsigned int maxLoopNumber
Definition: MuScleFit.cc:276
std::string theRootFileName_
Definition: MuScleFitBase.h:50
MuScleFitPlotter * plotter
Definition: MuScleFit.cc:281
std::vector< TFile * > theFiles_
The files were the histograms are saved.
Definition: MuScleFitBase.h:76
static bool useProbsFile_
void readProbabilityDistributionsFromFile()
Read probability distributions from a local root file.

◆ checkDeltaR()

bool MuScleFit::checkDeltaR ( reco::Particle::LorentzVector genMu,
reco::Particle::LorentzVector recMu 
)
protected

Check if two lorentzVector are near in deltaR.

Definition at line 1373 of file MuScleFit.cc.

References gather_cfg::cout, MuScleFitBase::debug_, MuScleFitUtils::deltaPhi(), PbPb_ZMuSkimMuonDPG_cff::deltaR, and mathSSE::sqrt().

Referenced by duringFastLoop().

1373  {
1374  //first is always mu-, second is always mu+
1375  double deltaR =
1376  sqrt(MuScleFitUtils::deltaPhi(recMu.Phi(), genMu.Phi()) * MuScleFitUtils::deltaPhi(recMu.Phi(), genMu.Phi()) +
1377  ((recMu.Eta() - genMu.Eta()) * (recMu.Eta() - genMu.Eta())));
1378  if (deltaR < 0.01)
1379  return true;
1380  else if (debug_ > 0) {
1381  std::cout << "Reco muon " << recMu << " with eta " << recMu.Eta() << " and phi " << recMu.Phi() << std::endl
1382  << " DOES NOT MATCH with generated muon from resonance: " << std::endl
1383  << genMu << " with eta " << genMu.Eta() << " and phi " << genMu.Phi() << std::endl;
1384  }
1385  return false;
1386 }
T sqrt(T t)
Definition: SSEVec.h:19
static double deltaPhi(const double &phi1, const double &phi2)

◆ checkParameters()

void MuScleFit::checkParameters ( )
protected

Simple method to check parameters consistency. It aborts the job if the parameters are not consistent.

Definition at line 1424 of file MuScleFit.cc.

References MuScleFitUtils::BiasType, gather_cfg::cout, MuScleFitUtils::doBackgroundFit, MuScleFitUtils::doCrossSectionFit, MuScleFitUtils::doResolFit, MuScleFitUtils::doScaleFit, relativeConstraints::empty, maxLoopNumber, MuScleFitUtils::parBgr, MuScleFitUtils::parBgrFix, MuScleFitUtils::parBgrOrder, MuScleFitUtils::parBias, MuScleFitUtils::parCrossSection, MuScleFitUtils::parCrossSectionFix, MuScleFitUtils::parCrossSectionOrder, MuScleFitUtils::parResol, MuScleFitUtils::parResolFix, MuScleFitUtils::parResolOrder, MuScleFitUtils::parScale, MuScleFitUtils::parScaleFix, MuScleFitUtils::parScaleOrder, MuScleFitUtils::parSmear, MuScleFitUtils::resfind, findQualityFiles::size, and MuScleFitUtils::SmearType.

Referenced by MuScleFit().

1424  {
1425  // Fits selection dimension check
1427  std::cout << "[MuScleFit-Constructor]: wrong size of resolution fits selector = "
1428  << MuScleFitUtils::doResolFit.size() << std::endl;
1429  std::cout << "it must have as many values as the number of loops, which is = " << maxLoopNumber << std::endl;
1430  abort();
1431  }
1433  std::cout << "[MuScleFit-Constructor]: wrong size of scale fits selector = " << MuScleFitUtils::doScaleFit.size()
1434  << std::endl;
1435  std::cout << "it must have as many values as the number of loops, which is = " << maxLoopNumber << std::endl;
1436  abort();
1437  }
1439  std::cout << "[MuScleFit-Constructor]: wrong size of cross section fits selector = "
1440  << MuScleFitUtils::doCrossSectionFit.size() << std::endl;
1441  std::cout << "it must have as many values as the number of loops, which is = " << maxLoopNumber << std::endl;
1442  abort();
1443  }
1445  std::cout << "[MuScleFit-Constructor]: wrong size of background fits selector = "
1446  << MuScleFitUtils::doBackgroundFit.size() << std::endl;
1447  std::cout << "it must have as many values as the number of loops, which is = " << maxLoopNumber << std::endl;
1448  abort();
1449  }
1450 
1451  // Bias parameters: dimension check
1452  // --------------------------------
1453  if ((MuScleFitUtils::BiasType == 1 && MuScleFitUtils::parBias.size() != 2) || // linear in pt
1454  (MuScleFitUtils::BiasType == 2 && MuScleFitUtils::parBias.size() != 2) || // linear in |eta|
1455  (MuScleFitUtils::BiasType == 3 && MuScleFitUtils::parBias.size() != 4) || // sinusoidal in phi
1456  (MuScleFitUtils::BiasType == 4 && MuScleFitUtils::parBias.size() != 3) || // linear in pt and |eta|
1457  (MuScleFitUtils::BiasType == 5 && MuScleFitUtils::parBias.size() != 3) || // linear in pt and sinusoidal in phi
1458  (MuScleFitUtils::BiasType == 6 &&
1459  MuScleFitUtils::parBias.size() != 3) || // linear in |eta| and sinusoidal in phi
1460  (MuScleFitUtils::BiasType == 7 &&
1461  MuScleFitUtils::parBias.size() != 4) || // linear in pt and |eta| and sinusoidal in phi
1462  (MuScleFitUtils::BiasType == 8 && MuScleFitUtils::parBias.size() != 4) || // linear in pt and parabolic in |eta|
1463  (MuScleFitUtils::BiasType == 9 && MuScleFitUtils::parBias.size() != 2) || // exponential in pt
1464  (MuScleFitUtils::BiasType == 10 && MuScleFitUtils::parBias.size() != 3) || // parabolic in pt
1465  (MuScleFitUtils::BiasType == 11 &&
1466  MuScleFitUtils::parBias.size() != 4) || // linear in pt and sin in phi with chg
1467  (MuScleFitUtils::BiasType == 12 &&
1468  MuScleFitUtils::parBias.size() != 6) || // linear in pt and para in plus sin in phi with chg
1469  (MuScleFitUtils::BiasType == 13 &&
1470  MuScleFitUtils::parBias.size() != 8) || // linear in pt and para in plus sin in phi with chg
1472  MuScleFitUtils::BiasType > 13) {
1473  std::cout << "[MuScleFit-Constructor]: Wrong bias type or number of parameters: aborting!" << std::endl;
1474  abort();
1475  }
1476  // Smear parameters: dimension check
1477  // ---------------------------------
1486  std::cout << "[MuScleFit-Constructor]: Wrong smear type or number of parameters: aborting!" << std::endl;
1487  abort();
1488  }
1489  // Protect against bad size of parameters
1490  // --------------------------------------
1493  std::cout << "[MuScleFit-Constructor]: Mismatch in number of parameters for Resol: aborting!" << std::endl;
1494  abort();
1495  }
1498  std::cout << "[MuScleFit-Constructor]: Mismatch in number of parameters for Scale: aborting!" << std::endl;
1499  abort();
1500  }
1503  std::cout << "[MuScleFit-Constructor]: Mismatch in number of parameters for Bgr: aborting!" << std::endl;
1504  abort();
1505  }
1508  std::cout << "[MuScleFit-Constructor]: Mismatch in number of parameters for Bgr: aborting!" << std::endl;
1509  abort();
1510  }
1511 
1512  // Protect against an incorrect number of resonances
1513  // -------------------------------------------------
1514  if (MuScleFitUtils::resfind.size() != 6) {
1515  std::cout << "[MuScleFit-Constructor]: resfind must have 6 elements (1 Z, 3 Y, 2 Psi): aborting!" << std::endl;
1516  abort();
1517  }
1518 }
size
Write out results.
static std::vector< int > doScaleFit
static std::vector< int > doResolFit
static std::vector< double > parBias
static std::vector< int > parCrossSectionOrder
static std::vector< int > parScaleOrder
static std::vector< int > doCrossSectionFit
static std::vector< int > parBgrOrder
static std::vector< int > doBackgroundFit
static std::vector< double > parResol
static std::vector< int > parBgrFix
static int BiasType
static std::vector< int > parScaleFix
static std::vector< double > parBgr
unsigned int maxLoopNumber
Definition: MuScleFit.cc:276
static int SmearType
static std::vector< int > parResolFix
static std::vector< double > parSmear
static std::vector< int > parResolOrder
static std::vector< double > parScale
static std::vector< double > parCrossSection
static std::vector< int > resfind
static std::vector< int > parCrossSectionFix

◆ duringFastLoop()

void MuScleFit::duringFastLoop ( )
virtual

This method performs all needed operations on the muon pair. It reads the muons from SavedPair and uses the iev counter to keep track of the event number. The iev is incremented internally and reset to 0 in startingNewLoop.

Definition at line 1097 of file MuScleFit.cc.

References CrossSectionHandler::addParameters(), MuScleFitUtils::applyScale(), checkDeltaR(), compareToSimTracks_, MuScleFitUtils::computeWeight(), gather_cfg::cout, MuScleFitUtils::crossSectionHandler, MuScleFitBase::debug_, MuScleFitUtils::debugMassResol_, MuScleFitUtils::doScaleFit, HLT_2023v12_cff::eta1, HLT_2023v12_cff::eta2, fillComparisonHistograms(), dqmdumpme::first, MuScleFitUtils::genPair, mps_fire::i, iev, MuScleFitUtils::iev_, createfilelist::int, dqm-mbProfile::log, loopCounter, MuScleFitBase::mapHisto_, EgHLTOffHistBins_cfi::mass, MuScleFitUtils::massProb(), MuScleFitUtils::massResolComponents, MuScleFitUtils::massResolution(), MuScleFitUtils::parBgr, MuScleFitUtils::parCrossSection, MuScleFitUtils::parResol, MuScleFitUtils::parScale, MuScleFitUtils::parvalue, conifer::pow(), TtFullHadEvtBuilder_cfi::prob, HLT_2023v12_cff::pt1, HLT_2023v12_cff::pt2, recMu1, recMu2, MuScleFitUtils::ResFound, MuScleFitUtils::resolutionFunctionForVec, MuScleFitUtils::SavedPair, edm::second(), MuScleFitUtils::simPair, findQualityFiles::size, MuScleFitUtils::speedup, and mps_merge::weight.

Referenced by duringLoop(), and endOfLoop().

1097  {
1098  // On loops>0 the two muons are directly obtained from the SavedMuon array
1099  // -----------------------------------------------------------------------
1100  MuScleFitUtils::ResFound = false;
1102  recMu2 = (MuScleFitUtils::SavedPair[iev].second);
1103 
1104  //std::cout << "iev = " << iev << ", recMu1 pt = " << recMu1.Pt() << ", recMu2 pt = " << recMu2.Pt() << std::endl;
1105 
1106  if (recMu1.Pt() > 0 && recMu2.Pt() > 0) {
1107  MuScleFitUtils::ResFound = true;
1108  if (debug_ > 0)
1109  std::cout << "Ev = " << iev << ": found muons in tree with Pt = " << recMu1.Pt() << " " << recMu2.Pt()
1110  << std::endl;
1111  }
1112 
1113  if (debug_ > 0)
1114  std::cout << "About to start lik par correction and histo filling; ResFound is " << MuScleFitUtils::ResFound
1115  << std::endl;
1116  // If resonance found, do the hard work
1117  // ------------------------------------
1119  // Find weight and reference mass for this muon pair
1120  // -------------------------------------------------
1121  // The last parameter = true means that we want to use always the background window to compute the weight,
1122  // otherwise the probability will be filled only for the resonance region.
1123  double weight = MuScleFitUtils::computeWeight((recMu1 + recMu2).mass(), iev, true);
1124  if (debug_ > 0) {
1125  std::cout << "Loop #" << loopCounter << "Event #" << iev << ": before correction Pt1 = " << recMu1.Pt()
1126  << " Pt2 = " << recMu2.Pt() << std::endl;
1127  }
1128  // For successive iterations, correct the muons only if the previous iteration was a scale fit.
1129  // --------------------------------------------------------------------------------------------
1130  if (loopCounter > 0) {
1134  }
1135  }
1136  if (debug_ > 0) {
1137  std::cout << "Loop #" << loopCounter << "Event #" << iev << ": after correction Pt1 = " << recMu1.Pt()
1138  << " Pt2 = " << recMu2.Pt() << std::endl;
1139  }
1140 
1142 
1143  //Fill histograms
1144  //------------------
1145 
1146  mapHisto_["hRecBestMu"]->Fill(recMu1, -1, weight);
1147  mapHisto_["hRecBestMuVSEta"]->Fill(recMu1);
1148  mapHisto_["hRecBestMu"]->Fill(recMu2, +1, weight);
1149  mapHisto_["hRecBestMuVSEta"]->Fill(recMu2);
1150  mapHisto_["hDeltaRecBestMu"]->Fill(recMu1, recMu2);
1151  // Reconstructed resonance
1152  mapHisto_["hRecBestRes"]->Fill(bestRecRes, +1, weight);
1153  mapHisto_["hRecBestResAllEvents"]->Fill(bestRecRes, +1, 1.);
1154  // // Fill histogram of Res mass vs muon variables
1155  // mapHisto_["hRecBestResVSMu"]->Fill (recMu1, bestRecRes, -1);
1156  // mapHisto_["hRecBestResVSMu"]->Fill (recMu2, bestRecRes, +1);
1157  // // Fill also the mass mu+/mu- comparisons
1158  // mapHisto_["hRecBestResVSMu"]->Fill(recMu1, recMu2, bestRecRes);
1159 
1160  mapHisto_["hRecBestResVSMu"]->Fill(recMu1, bestRecRes, -1, weight);
1161  mapHisto_["hRecBestResVSMu"]->Fill(recMu2, bestRecRes, +1, weight);
1162  // Fill also the mass mu+/mu- comparisons
1163  mapHisto_["hRecBestResVSMu"]->Fill(recMu1, recMu2, bestRecRes, weight);
1164 
1165  //-- rc 2010 filling histograms for mu+ /mu- ------
1166  // mapHisto_["hRecBestResVSMuMinus"]->Fill (recMu1, bestRecRes, -1);
1167  // mapHisto_["hRecBestResVSMuPlus"]->Fill (recMu2, bestRecRes, +1);
1168 
1169  //-- rc 2010 filling histograms MassVsMuEtaPhi------
1170  // mapHisto_["hRecBestResVSMuEtaPhi"]->Fill (recMu1, bestRecRes,-1);
1171  // mapHisto_["hRecBestResVSMuEtaPhi"]->Fill (recMu2, bestRecRes,+1);
1172 
1173  // Fill histogram of Res mass vs Res variables
1174  // mapHisto_["hRecBestResVSRes"]->Fill (bestRecRes, bestRecRes, +1);
1175  mapHisto_["hRecBestResVSRes"]->Fill(bestRecRes, bestRecRes, +1, weight);
1176 
1177  std::vector<double>* parval;
1178  std::vector<double> initpar;
1179  // Store a pointer to the vector of parameters of the last iteration, or the initial
1180  // parameters if this is the first iteration
1181  if (loopCounter == 0) {
1182  initpar = MuScleFitUtils::parResol;
1183  initpar.insert(initpar.end(), MuScleFitUtils::parScale.begin(), MuScleFitUtils::parScale.end());
1184  initpar.insert(initpar.end(), MuScleFitUtils::parCrossSection.begin(), MuScleFitUtils::parCrossSection.end());
1185  initpar.insert(initpar.end(), MuScleFitUtils::parBgr.begin(), MuScleFitUtils::parBgr.end());
1186  parval = &initpar;
1187  } else {
1188  parval = &(MuScleFitUtils::parvalue[loopCounter - 1]);
1189  }
1190 
1191  //Compute pt resolution w.r.t generated and simulated muons
1192  //--------------------------------------------------------
1193  if (!MuScleFitUtils::speedup) {
1194  //first is always mu-, second is always mu+
1197  }
1200  }
1201  if (compareToSimTracks_) {
1202  //first is always mu-, second is always mu+
1205  }
1208  }
1209  }
1210  }
1211 
1212  // 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
1213  // Fill also the resolution histogramsm using the resolution functions:
1214  // the parameters are those from the last iteration, as the muons up to this point have also the corrections from the same iteration.
1215  // Need to use a different array (ForVec), containing functors able to operate on std::vector<double>
1216  mapHisto_["hFunctionResolPt"]->Fill(
1217  recMu1, MuScleFitUtils::resolutionFunctionForVec->sigmaPt(recMu1.Pt(), recMu1.Eta(), *parval), -1);
1218  mapHisto_["hFunctionResolCotgTheta"]->Fill(
1219  recMu1, MuScleFitUtils::resolutionFunctionForVec->sigmaCotgTh(recMu1.Pt(), recMu1.Eta(), *parval), -1);
1220  mapHisto_["hFunctionResolPhi"]->Fill(
1221  recMu1, MuScleFitUtils::resolutionFunctionForVec->sigmaPhi(recMu1.Pt(), recMu1.Eta(), *parval), -1);
1222  mapHisto_["hFunctionResolPt"]->Fill(
1223  recMu2, MuScleFitUtils::resolutionFunctionForVec->sigmaPt(recMu2.Pt(), recMu2.Eta(), *parval), +1);
1224  mapHisto_["hFunctionResolCotgTheta"]->Fill(
1225  recMu2, MuScleFitUtils::resolutionFunctionForVec->sigmaCotgTh(recMu2.Pt(), recMu2.Eta(), *parval), +1);
1226  mapHisto_["hFunctionResolPhi"]->Fill(
1227  recMu2, MuScleFitUtils::resolutionFunctionForVec->sigmaPhi(recMu2.Pt(), recMu2.Eta(), *parval), +1);
1228 
1229  // Compute likelihood histograms
1230  // -----------------------------
1231  if (debug_ > 0)
1232  std::cout << "mass = " << bestRecRes.mass() << std::endl;
1233  if (weight != 0.) {
1234  double massResol;
1235  double prob;
1236  double deltalike;
1237  if (loopCounter == 0) {
1238  std::vector<double> initpar;
1239  initpar.reserve((int)(MuScleFitUtils::parResol.size()));
1240  for (int i = 0; i < (int)(MuScleFitUtils::parResol.size()); i++) {
1241  initpar.push_back(MuScleFitUtils::parResol[i]);
1242  }
1243  for (int i = 0; i < (int)(MuScleFitUtils::parScale.size()); i++) {
1244  initpar.push_back(MuScleFitUtils::parScale[i]);
1245  }
1246  // for (int i=0; i<(int)(MuScleFitUtils::parCrossSection.size()); i++) {
1247  // initpar.push_back(MuScleFitUtils::parCrossSection[i]);
1248  // }
1250 
1251  for (int i = 0; i < (int)(MuScleFitUtils::parBgr.size()); i++) {
1252  initpar.push_back(MuScleFitUtils::parBgr[i]);
1253  }
1254  massResol = MuScleFitUtils::massResolution(recMu1, recMu2, initpar);
1255  // prob = MuScleFitUtils::massProb( bestRecRes.mass(), bestRecRes.Eta(), bestRecRes.Rapidity(), massResol, initpar, true );
1256  prob = MuScleFitUtils::massProb(bestRecRes.mass(),
1257  bestRecRes.Eta(),
1258  bestRecRes.Rapidity(),
1259  massResol,
1260  initpar,
1261  true,
1262  recMu1.eta(),
1263  recMu2.eta());
1264  } else {
1266  // prob = MuScleFitUtils::massProb( bestRecRes.mass(), bestRecRes.Eta(), bestRecRes.Rapidity(),
1267  // massResol, MuScleFitUtils::parvalue[loopCounter-1], true );
1268  prob = MuScleFitUtils::massProb(bestRecRes.mass(),
1269  bestRecRes.Eta(),
1270  bestRecRes.Rapidity(),
1271  massResol,
1273  true,
1274  recMu1.eta(),
1275  recMu2.eta());
1276  }
1277  if (debug_ > 0)
1278  std::cout << "inside weight: mass = " << bestRecRes.mass() << ", prob = " << prob << std::endl;
1279  if (prob > 0) {
1280  if (debug_ > 0)
1281  std::cout << "inside prob: mass = " << bestRecRes.mass() << ", prob = " << prob << std::endl;
1282 
1283  deltalike = log(prob) * weight; // NB maximum likelihood --> deltalike is maximized
1284  mapHisto_["hLikeVSMu"]->Fill(recMu1, deltalike);
1285  mapHisto_["hLikeVSMu"]->Fill(recMu2, deltalike);
1286  mapHisto_["hLikeVSMuMinus"]->Fill(recMu1, deltalike);
1287  mapHisto_["hLikeVSMuPlus"]->Fill(recMu2, deltalike);
1288 
1289  double recoMass = (recMu1 + recMu2).mass();
1290  if (recoMass != 0) {
1291  // IMPORTANT: massResol is not a relative resolution
1292  mapHisto_["hResolMassVSMu"]->Fill(recMu1, massResol, -1);
1293  mapHisto_["hResolMassVSMu"]->Fill(recMu2, massResol, +1);
1294  mapHisto_["hFunctionResolMassVSMu"]->Fill(recMu1, massResol / recoMass, -1);
1295  mapHisto_["hFunctionResolMassVSMu"]->Fill(recMu2, massResol / recoMass, +1);
1296  }
1297 
1299  mapHisto_["hdMdPt1"]->Fill(recMu1, MuScleFitUtils::massResolComponents.dmdpt1, -1);
1300  mapHisto_["hdMdPt2"]->Fill(recMu2, MuScleFitUtils::massResolComponents.dmdpt2, +1);
1301  mapHisto_["hdMdPhi1"]->Fill(recMu1, MuScleFitUtils::massResolComponents.dmdphi1, -1);
1302  mapHisto_["hdMdPhi2"]->Fill(recMu2, MuScleFitUtils::massResolComponents.dmdphi2, +1);
1303  mapHisto_["hdMdCotgTh1"]->Fill(recMu1, MuScleFitUtils::massResolComponents.dmdcotgth1, -1);
1304  mapHisto_["hdMdCotgTh2"]->Fill(recMu2, MuScleFitUtils::massResolComponents.dmdcotgth2, +1);
1305  }
1306 
1307  if (!MuScleFitUtils::speedup) {
1308  double genMass = (MuScleFitUtils::genPair[iev].first + MuScleFitUtils::genPair[iev].second).mass();
1309  // Fill the mass resolution (computed from MC), we use the covariance class to compute the variance
1310  if (genMass != 0) {
1311  mapHisto_["hGenResVSMu"]->Fill((MuScleFitUtils::genPair[iev].first),
1313  -1);
1314  mapHisto_["hGenResVSMu"]->Fill((MuScleFitUtils::genPair[iev].second),
1316  +1);
1317  double diffMass = (recoMass - genMass) / genMass;
1318  // double diffMass = recoMass - genMass;
1319  // Fill if for both muons
1320  double pt1 = recMu1.pt();
1321  double eta1 = recMu1.eta();
1322  double pt2 = recMu2.pt();
1323  double eta2 = recMu2.eta();
1324  // This is to avoid nan
1325  if (diffMass == diffMass) {
1326  // Mass relative difference vs Pt and Eta. To be used to extract the true mass resolution
1327  mapHisto_["hDeltaMassOverGenMassVsPt"]->Fill(pt1, diffMass);
1328  mapHisto_["hDeltaMassOverGenMassVsPt"]->Fill(pt2, diffMass);
1329  mapHisto_["hDeltaMassOverGenMassVsEta"]->Fill(eta1, diffMass);
1330  mapHisto_["hDeltaMassOverGenMassVsEta"]->Fill(eta2, diffMass);
1331  // This is used for the covariance comparison
1332  mapHisto_["hMassResolutionVsPtEta"]->Fill(pt1, eta1, diffMass, diffMass);
1333  mapHisto_["hMassResolutionVsPtEta"]->Fill(pt2, eta2, diffMass, diffMass);
1334  } else {
1335  std::cout << "Error, there is a nan: recoMass = " << recoMass << ", genMass = " << genMass << std::endl;
1336  }
1337  }
1338  // Fill with mass resolution from resolution function
1340  mapHisto_["hFunctionResolMass"]->Fill(recMu1, std::pow(massRes, 2), -1);
1341  mapHisto_["hFunctionResolMass"]->Fill(recMu2, std::pow(massRes, 2), +1);
1342  }
1343 
1344  mapHisto_["hMass_P"]->Fill(bestRecRes.mass(), prob);
1345  if (debug_ > 0)
1346  std::cout << "mass = " << bestRecRes.mass() << ", prob = " << prob << std::endl;
1347  mapHisto_["hMass_fine_P"]->Fill(bestRecRes.mass(), prob);
1348 
1349  mapHisto_["hMassProbVsRes"]->Fill(bestRecRes, bestRecRes, +1, prob);
1350  mapHisto_["hMassProbVsMu"]->Fill(recMu1, bestRecRes, -1, prob);
1351  mapHisto_["hMassProbVsMu"]->Fill(recMu2, bestRecRes, +1, prob);
1352  mapHisto_["hMassProbVsRes_fine"]->Fill(bestRecRes, bestRecRes, +1, prob);
1353  mapHisto_["hMassProbVsMu_fine"]->Fill(recMu1, bestRecRes, -1, prob);
1354  mapHisto_["hMassProbVsMu_fine"]->Fill(recMu2, bestRecRes, +1, prob);
1355  }
1356  }
1357  } // end if ResFound
1358 
1359  // Fill the pair
1360  // -------------
1361  if (loopCounter > 0) {
1362  if (debug_ > 0)
1363  std::cout << "[MuScleFit]: filling the pair" << std::endl;
1364  MuScleFitUtils::SavedPair[iev] = std::make_pair(recMu1, recMu2);
1365  }
1366 
1367  iev++;
1369 
1370  // return kContinue;
1371 }
size
Write out results.
static std::vector< std::pair< lorentzVector, lorentzVector > > simPair
static std::vector< int > doScaleFit
unsigned int loopCounter
Definition: MuScleFit.cc:277
static std::vector< double > parResol
static bool debugMassResol_
static bool speedup
Definition: weight.py:1
constexpr int pow(int x)
Definition: conifer.h:24
std::map< std::string, Histograms * > mapHisto_
The map of histograms.
Definition: MuScleFitBase.h:79
static bool ResFound
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:1388
static struct MuScleFitUtils::massResolComponentsStruct massResolComponents
static std::vector< std::vector< double > > parvalue
U second(std::pair< T, U > const &p)
static std::vector< std::pair< lorentzVector, lorentzVector > > genPair
static double massResolution(const lorentzVector &mu1, const lorentzVector &mu2)
reco::Particle::LorentzVector recMu2
Definition: MuScleFit.cc:285
reco::Particle::LorentzVector recMu1
Definition: MuScleFit.cc:285
static std::vector< double > parBgr
bool compareToSimTracks_
Definition: MuScleFit.cc:290
static double computeWeight(const double &mass, const int iev, const bool doUseBkgrWindow=false)
static std::vector< std::pair< lorentzVector, lorentzVector > > SavedPair
static lorentzVector applyScale(const lorentzVector &muon, const std::vector< double > &parval, const int charge)
static std::vector< double > parScale
static int iev_
static std::vector< double > parCrossSection
bool checkDeltaR(reco::Particle::LorentzVector &genMu, reco::Particle::LorentzVector &recMu)
Check if two lorentzVector are near in deltaR.
Definition: MuScleFit.cc:1373
static resolutionFunctionBase< std::vector< double > > * resolutionFunctionForVec
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
static CrossSectionHandler * crossSectionHandler
void addParameters(std::vector< double > &initpar)
Inputs the vars in a vector.

◆ duringLoop()

edm::EDLooper::Status MuScleFit::duringLoop ( const edm::Event ,
const edm::EventSetup  
)
overridevirtual

Called after all event modules have had a chance to process the edm::Event.

Implements edm::EDLooper.

Definition at line 804 of file MuScleFit.cc.

References gather_cfg::cout, MuScleFitBase::debug_, duringFastLoop(), relativeConstraints::empty, options_cfi::eventSetup, fastLoop, HltComparatorCreateWorkflow::hltConfig, mps_fire::i, inputRootTreeFileName_, edm::EDLooperBase::kContinue, loopCounter, negateTrigger_, selectMuons(), findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, totalEvents_, L1TEGammaOffline_cfi::triggerNames, triggerPath_, triggerResults, triggerResultsProcess_, and triggerResultsToken_.

804  {
806  bool isFired = false;
807 
808  if (triggerPath_[0].empty())
809  isFired = true;
810  else if (triggerPath_[0] == "All") {
811  isFired = triggerResults->accept();
812  if (debug_ > 0)
813  std::cout << "Trigger " << isFired << std::endl;
814  } else {
815  bool changed;
817  hltConfig.init(event.getRun(), eventSetup, triggerResultsProcess_, changed);
818 
819  const edm::TriggerNames& triggerNames = event.triggerNames(*triggerResults);
820 
821  for (unsigned i = 0; i < triggerNames.size(); i++) {
822  const std::string& hltName = triggerNames.triggerName(i);
823 
824  // match the path in the pset with the true name of the trigger
825  for (unsigned int ipath = 0; ipath < triggerPath_.size(); ipath++) {
826  if (hltName.find(triggerPath_[ipath]) != std::string::npos) {
827  unsigned int triggerIndex(hltConfig.triggerIndex(hltName));
828 
829  // triggerIndex must be less than the size of HLTR or you get a CMSException: _M_range_check
830  if (triggerIndex < triggerResults->size()) {
831  isFired = triggerResults->accept(triggerIndex);
832  if (debug_ > 0)
833  std::cout << triggerPath_[ipath] << " " << hltName << " " << isFired << std::endl;
834  }
835  } // end if (matching the path in the pset with the true trigger name
836  }
837  }
838  }
839 
840  if (negateTrigger_ && isFired)
841  return kContinue;
842  else if (!(negateTrigger_) && !isFired)
843  return kContinue;
844 
845 #ifdef USE_CALLGRIND
846  CALLGRIND_START_INSTRUMENTATION;
847 #endif
848 
849  if (debug_ > 0) {
850  std::cout << "[MuScleFit-duringLoop]: loopCounter = " << loopCounter << " Run: " << event.id().run()
851  << " Event: " << event.id().event() << std::endl;
852  }
853 
854  // On the first iteration we read the bank, otherwise we fetch the information from the muon tree
855  // ------------------------------------ Important Note --------------------------------------- //
856  // The fillMuonCollection method applies any smearing or bias to the muons, so we NEVER use
857  // unbiased muons.
858  // ----------------------------------------------------------------------------------------------
859  if (loopCounter == 0) {
860  if (!fastLoop || inputRootTreeFileName_.empty()) {
861  if (debug_ > 0)
862  std::cout << "Reading from edm event" << std::endl;
864  duringFastLoop();
865  ++totalEvents_;
866  }
867  }
868 
869  return kContinue;
870 
871 #ifdef USE_CALLGRIND
872  CALLGRIND_STOP_INSTRUMENTATION;
873  CALLGRIND_DUMP_STATS;
874 #endif
875 }
size
Write out results.
void selectMuons(const edm::Event &event)
Definition: MuScleFit.cc:877
unsigned int loopCounter
Definition: MuScleFit.cc:277
int totalEvents_
Definition: MuScleFit.cc:288
std::string triggerResultsProcess_
Definition: MuScleFit.cc:308
virtual void duringFastLoop()
Definition: MuScleFit.cc:1097
std::vector< std::string > triggerPath_
Definition: MuScleFit.cc:309
static std::string const triggerResults
Definition: EdmProvDump.cc:47
bool fastLoop
Definition: MuScleFit.cc:279
std::string inputRootTreeFileName_
Definition: MuScleFit.cc:296
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
Definition: MuScleFit.cc:302
bool negateTrigger_
Definition: MuScleFit.cc:310
Definition: event.py:1

◆ endOfFastLoop()

void MuScleFit::endOfFastLoop ( const unsigned int  iLoop)
virtual

Definition at line 769 of file MuScleFit.cc.

References MuScleFitBase::clearHistoMap(), gather_cfg::cout, loopCounter, MuScleFitUtils::minimizeLikelihood(), plotter, MuScleFitBase::theFiles_, and MuScleFitBase::writeHistoMap().

Referenced by endOfLoop().

769  {
770  // std::cout<< "Inside endOfFastLoop, iLoop = " << iLoop << " and loopCounter = " << loopCounter << std::endl;
771 
772  if (loopCounter == 0) {
773  // plotter->writeHistoMap();
774  // The destructor will call the writeHistoMap after the cd to the output file
775  delete plotter;
776  }
777 
778  std::cout << "Ending loop # " << iLoop << std::endl;
779 
780  // Write the histos to file
781  // ------------------------
782  // theFiles_[iLoop]->cd();
783  writeHistoMap(iLoop);
784 
785  // Likelihood minimization to compute corrections
786  // ----------------------------------------------
787  // theFiles_[iLoop]->cd();
788  TDirectory* likelihoodDir = theFiles_[iLoop]->mkdir("likelihood");
789  likelihoodDir->cd();
791 
792  // ATTENTION, this was put BEFORE the minimizeLikelihood. Check for problems.
793  theFiles_[iLoop]->Close();
794  // ATTENTION: Check that this delete does not give any problem
795  delete theFiles_[iLoop];
796 
797  // Clear the histos
798  // ----------------
799  clearHistoMap();
800 }
static void minimizeLikelihood()
unsigned int loopCounter
Definition: MuScleFit.cc:277
void clearHistoMap()
Clean the histograms map.
void writeHistoMap(const unsigned int iLoop)
Save the histograms map to file.
MuScleFitPlotter * plotter
Definition: MuScleFit.cc:281
std::vector< TFile * > theFiles_
The files were the histograms are saved.
Definition: MuScleFitBase.h:76

◆ endOfJob()

void MuScleFit::endOfJob ( )
overridevirtual

Reimplemented from edm::EDLooperBase.

Definition at line 691 of file MuScleFit.cc.

References gather_cfg::cout, and MuScleFitBase::debug_.

691  {
692  if (debug_ > 0)
693  std::cout << "[MuScleFit]: endOfJob" << std::endl;
694 }

◆ endOfLoop()

edm::EDLooper::Status MuScleFit::endOfLoop ( const edm::EventSetup ,
unsigned int  iCounter 
)
overridevirtual

Called after the system has finished one loop over the events. Thar argument is a count of how many loops have been processed before this loo. For the first time through the events the argument will be 0.

Implements edm::EDLooperBase.

Definition at line 725 of file MuScleFit.cc.

References gather_cfg::cout, duringFastLoop(), endOfFastLoop(), fastLoop, iev, inputRootTreeFileName_, edm::EDLooperBase::kContinue, edm::EDLooperBase::kStop, maxEventsFromRootTree_, maxLoopNumber, MuScleFitUtils::SavedPair, selectMuons(), startingNewLoop(), and totalEvents_.

725  {
726  unsigned int iFastLoop = 1;
727 
728  // Read the events from the root tree if requested
729  if (!(inputRootTreeFileName_.empty())) {
731  // When reading from local file all the loops are done here
733  iFastLoop = 0;
734  } else {
735  endOfFastLoop(iLoop);
736  }
737 
738  // If a fastLoop is required we do all the remaining iterations here
739  if (fastLoop == true) {
740  for (; iFastLoop < maxLoopNumber; ++iFastLoop) {
741  std::cout << "Starting fast loop number " << iFastLoop << std::endl;
742 
743  // In the first loop is called by the framework
744  // if( iFastLoop > 0 ) {
745  startingNewLoop(iFastLoop);
746  // }
747 
748  // std::vector<std::pair<lorentzVector,lorentzVector> >::const_iterator it = MuScleFitUtils::SavedPair.begin();
749  // for( ; it != SavedPair.end(); ++it ) {
750  while (iev < totalEvents_) {
751  if (iev % 50000 == 0) {
752  std::cout << "Fast looping on event number " << iev << std::endl;
753  }
754  // This reads muons from SavedPair using iev to keep track of the event
755  duringFastLoop();
756  }
757  std::cout << "End of fast loop number " << iFastLoop << ". Ran on " << iev << " events" << std::endl;
758  endOfFastLoop(iFastLoop);
759  }
760  }
761 
762  if (iFastLoop >= maxLoopNumber - 1) {
763  return kStop;
764  } else {
765  return kContinue;
766  }
767 }
void selectMuons(const edm::Event &event)
Definition: MuScleFit.cc:877
int totalEvents_
Definition: MuScleFit.cc:288
virtual void duringFastLoop()
Definition: MuScleFit.cc:1097
void startingNewLoop(unsigned int iLoop) override
Definition: MuScleFit.cc:698
unsigned int maxLoopNumber
Definition: MuScleFit.cc:276
static std::vector< std::pair< lorentzVector, lorentzVector > > SavedPair
bool fastLoop
Definition: MuScleFit.cc:279
std::string inputRootTreeFileName_
Definition: MuScleFit.cc:296
int maxEventsFromRootTree_
Definition: MuScleFit.cc:300
virtual void endOfFastLoop(const unsigned int iLoop)
Definition: MuScleFit.cc:769

◆ fillComparisonHistograms()

void MuScleFit::fillComparisonHistograms ( const reco::Particle::LorentzVector genMu,
const reco::Particle::LorentzVector recoMu,
const std::string &  inputName,
const int  charge 
)
protected

Fill the reco vs gen and reco vs sim comparison histograms.

Definition at line 1388 of file MuScleFit.cc.

References ALCARECOTkAlJpsiMuMu_cff::charge, funct::cos(), MuScleFitUtils::deltaPhiNoFabs(), MuScleFitBase::mapHisto_, Skims_PA_cff::name, funct::sin(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by duringFastLoop().

1391  {
1392  std::string name(inputName + "VSMu");
1393  mapHisto_["hResolPt" + name]->Fill(recMu, (-genMu.Pt() + recMu.Pt()) / genMu.Pt(), charge);
1394  mapHisto_["hResolTheta" + name]->Fill(recMu, (-genMu.Theta() + recMu.Theta()), charge);
1395  mapHisto_["hResolCotgTheta" + name]->Fill(
1396  recMu, (-cos(genMu.Theta()) / sin(genMu.Theta()) + cos(recMu.Theta()) / sin(recMu.Theta())), charge);
1397  mapHisto_["hResolEta" + name]->Fill(recMu, (-genMu.Eta() + recMu.Eta()), charge);
1398  mapHisto_["hResolPhi" + name]->Fill(recMu, MuScleFitUtils::deltaPhiNoFabs(recMu.Phi(), genMu.Phi()), charge);
1399 
1400  // Fill only if it was matched to a genMu and this muon is valid
1401  if ((genMu.Pt() != 0) && (recMu.Pt() != 0)) {
1402  mapHisto_["hPtRecoVsPt" + inputName]->Fill(genMu.Pt(), recMu.Pt());
1403  }
1404 }
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...
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::map< std::string, Histograms * > mapHisto_
The map of histograms.
Definition: MuScleFitBase.h:79
Cos< T >::type cos(const T &t)
Definition: Cos.h:22

◆ fillMuonCollection()

template<typename T >
std::vector< MuScleFitMuon > MuScleFit::fillMuonCollection ( const std::vector< T > &  tracks)

Definition at line 321 of file MuScleFit.cc.

References applyBias(), applySmearing(), gather_cfg::cout, MuScleFitBase::debug_, MuScleFitUtils::goodmuon, MuScleFitUtils::mMu2, amptDefaultParameters_cff::mu, HLT_2023v12_cff::muon, PDWG_BPHSkim_cff::muons, mathSSE::sqrt(), HLT_2023v12_cff::track, and pwdgSkimBPark_cfi::tracks.

321  {
322  std::vector<MuScleFitMuon> muons;
323  typename std::vector<T>::const_iterator track;
324  for (track = tracks.begin(); track != tracks.end(); ++track) {
327  track->px(), track->py(), track->pz(), sqrt(track->p() * track->p() + MuScleFitUtils::mMu2));
328  // Apply smearing if needed, and then bias
329  // ---------------------------------------
331  if (debug_ > 0)
332  std::cout << std::setprecision(9) << "Muon #" << MuScleFitUtils::goodmuon << ": initial value Pt = " << mu.Pt()
333  << std::endl;
334 
335  applySmearing(mu);
336  applyBias(mu, track->charge());
337  if (debug_ > 0)
338  std::cout << "track charge: " << track->charge() << std::endl;
339 
340  Double_t hitsTk = track->innerTrack()->hitPattern().numberOfValidTrackerHits();
341  Double_t hitsMuon = track->innerTrack()->hitPattern().numberOfValidMuonHits();
342  Double_t ptError = track->innerTrack()->ptError();
343  MuScleFitMuon muon(mu, track->charge(), ptError, hitsTk, hitsMuon, false);
344  if (debug_ > 0) {
345  std::cout << "[MuScleFit::fillMuonCollection]" << std::endl;
346  std::cout << " muon = " << muon << std::endl;
347  }
348 
349  // Store modified muon
350  // -------------------
351  muons.push_back(muon);
352  }
353  return muons;
354 }
T sqrt(T t)
Definition: SSEVec.h:19
void applySmearing(reco::Particle::LorentzVector &mu)
Apply the smearing if needed using the function in MuScleFitUtils.
Definition: MuScleFit.cc:1406
static int goodmuon
static const double mMu2
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
void applyBias(reco::Particle::LorentzVector &mu, const int charge)
Apply the bias if needed using the function in MuScleFitUtils.
Definition: MuScleFit.cc:1414

◆ selectMuons() [1/2]

void MuScleFit::selectMuons ( const edm::Event event)
protected

Selects the muon pairs and fills the SavedPair and (if needed) the genPair vector. This version reads the events from the edm root file and performs a selection of the muons according to the parameters in the cfg.

Definition at line 877 of file MuScleFit.cc.

References L1TStage2uGTEmulatorClient_cff::BX, gather_cfg::cout, MuScleFitBase::debug_, MuScleFitUtils::findBestRecoRes(), dqmdumpme::first, genEvtInfoToken_, MuScleFitBase::genMuonPairs_, MuScleFitUtils::genPair, edm::HandleBase::isValid(), MuScleFitBase::muonPairs_, PDWG_BPHSkim_cff::muons, muonSelector_, plotter, puInfoToken_, recMu1, recMu2, recMuScleMu1, recMuScleMu2, MuScleFitUtils::ResFound, MuScleFitUtils::SavedPair, MuScleFitUtils::SavedPairMuScleFitMuons, edm::second(), MuScleFitUtils::simPair, MuScleFitUtils::speedup, vertexToken_, AlignmentTracksFromVertexSelector_cfi::vertices, and GenEventInfoProduct::weight().

Referenced by duringLoop(), and endOfLoop().

877  {
880 
881  std::vector<MuScleFitMuon> muons;
883  // plotter->fillRec(muons); // @EM method already invoked inside MuScleFitMuonSelector::selectMuons()
884 
885  if (debug_ > 0) {
886  std::cout << "[MuScleFit::selectMuons] Debugging muons collections after call to muonSelector_->selectMuons"
887  << std::endl;
888  int iMu = 0;
889  for (std::vector<MuScleFitMuon>::const_iterator it = muons.begin(); it < muons.end(); ++it) {
890  std::cout << " - muon n. " << iMu << " = " << (*it) << std::endl;
891  ++iMu;
892  }
893  }
894 
895  // Find the two muons from the resonance, and set ResFound bool
896  // ------------------------------------------------------------
897  std::pair<MuScleFitMuon, MuScleFitMuon> recMuFromBestRes = MuScleFitUtils::findBestRecoRes(muons);
898 
900  if (debug_ > 0) {
901  std::cout << std::setprecision(9) << "Pt after findbestrecores: " << (recMuFromBestRes.first).Pt() << " "
902  << (recMuFromBestRes.second).Pt() << std::endl;
903  std::cout << "recMu1 = " << recMu1 << std::endl;
904  std::cout << "recMu2 = " << recMu2 << std::endl;
905  }
906  recMu1 = recMuFromBestRes.first.p4();
907  recMu2 = recMuFromBestRes.second.p4();
908  recMuScleMu1 = recMuFromBestRes.first;
909  recMuScleMu2 = recMuFromBestRes.second;
910 
911  if (debug_ > 0) {
912  std::cout << "after recMu1 = " << recMu1 << std::endl;
913  std::cout << "after recMu2 = " << recMu2 << std::endl;
914  std::cout << "mu1.pt = " << recMu1.Pt() << std::endl;
915  std::cout << "mu2.pt = " << recMu2.Pt() << std::endl;
916  std::cout << "after recMuScleMu1 = " << recMuScleMu1 << std::endl;
917  std::cout << "after recMuScleMu2 = " << recMuScleMu2 << std::endl;
918  }
919  MuScleFitUtils::SavedPair.push_back(std::make_pair(recMu1, recMu2));
921  } else {
922  MuScleFitUtils::SavedPair.push_back(std::make_pair(lorentzVector(0., 0., 0., 0.), lorentzVector(0., 0., 0., 0.)));
924  }
925  // Save the events also in the external tree so that it can be saved late
926 
927  // Fetch extra information (per event)
928  UInt_t the_NVtx(0);
929  Int_t the_numPUvtx(0);
930  Float_t the_TrueNumInteractions(0);
931 
932  // Fill pile-up related informations
933  // --------------------------------
934  edm::Handle<std::vector<PileupSummaryInfo> > puInfo = event.getHandle(puInfoToken_);
935  if (puInfo.isValid()) {
936  std::vector<PileupSummaryInfo>::const_iterator PVI;
937  for (PVI = puInfo->begin(); PVI != puInfo->end(); ++PVI) {
938  int BX = PVI->getBunchCrossing();
939  if (BX == 0) { // "0" is the in-time crossing, negative values are the early crossings, positive are late
940  the_TrueNumInteractions = PVI->getTrueNumInteractions();
941  the_numPUvtx = PVI->getPU_NumInteractions();
942  }
943  }
944  }
945 
947  if (vertices.isValid()) {
948  std::vector<reco::Vertex>::const_iterator itv;
949  // now, count vertices
950  for (itv = vertices->begin(); itv != vertices->end(); ++itv) {
951  // require that the vertex meets certain criteria
952  if (itv->ndof() < 5)
953  continue;
954  if (fabs(itv->z()) > 50.0)
955  continue;
956  if (fabs(itv->position().rho()) > 2.0)
957  continue;
958  ++the_NVtx;
959  }
960  }
961 
962  // get the MC event weight
963  edm::Handle<GenEventInfoProduct> genEvtInfo = event.getHandle(genEvtInfoToken_);
964  double the_genEvtweight = 1.;
965  if (genEvtInfo.isValid()) {
966  the_genEvtweight = genEvtInfo->weight();
967  }
968 
969  muonPairs_.push_back(MuonPair(
973  event.run(), event.id().event(), the_genEvtweight, the_numPUvtx, the_TrueNumInteractions, the_NVtx)));
974  // Fill the internal genPair tree from the external one
975  if (MuScleFitUtils::speedup == false) {
976  MuScleFitUtils::genPair.push_back(std::make_pair(genMuonPairs_.back().mu1.p4(), genMuonPairs_.back().mu2.p4()));
977  }
978 }
static std::vector< std::pair< lorentzVector, lorentzVector > > simPair
std::vector< GenMuonPair > genMuonPairs_
Stores the genMuon pairs and the motherId prior to the creation of the internal tree.
Definition: MuScleFitBase.h:84
static std::vector< std::pair< MuScleFitMuon, MuScleFitMuon > > SavedPairMuScleFitMuons
static bool speedup
static bool ResFound
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
Definition: MuScleFit.cc:303
MuScleFitMuon recMuScleMu1
Definition: MuScleFit.cc:286
reco::Particle::LorentzVector lorentzVector
Definition: GenMuonPair.h:9
U second(std::pair< T, U > const &p)
static std::pair< MuScleFitMuon, MuScleFitMuon > findBestRecoRes(const std::vector< MuScleFitMuon > &muons)
static std::vector< std::pair< lorentzVector, lorentzVector > > genPair
reco::Particle::LorentzVector recMu2
Definition: MuScleFit.cc:285
reco::Particle::LorentzVector recMu1
Definition: MuScleFit.cc:285
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > puInfoToken_
Definition: MuScleFit.cc:304
MuScleFitMuon recMuScleMu2
Definition: MuScleFit.cc:286
static std::vector< std::pair< lorentzVector, lorentzVector > > SavedPair
edm::EDGetTokenT< GenEventInfoProduct > genEvtInfoToken_
Definition: MuScleFit.cc:305
MuScleFitPlotter * plotter
Definition: MuScleFit.cc:281
bool isValid() const
Definition: HandleBase.h:70
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:82
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
std::unique_ptr< MuScleFitMuonSelector > muonSelector_
Definition: MuScleFit.cc:317
Definition: event.py:1

◆ selectMuons() [2/2]

void MuScleFit::selectMuons ( const int  maxEvents,
const TString &  treeFileName 
)
protected

Selects the muon pairs and fills the SavedPair and (if needed) the genPair vector. This version reads the events from a tree in the file specified in the cfg. The tree only contains one muon pair per event. This means that no selection is performed and we use preselected muons.

Definition at line 980 of file MuScleFit.cc.

References applyBias(), applySmearing(), MuScleFitUtils::BiasType, gather_cfg::cout, SiPixelRawToDigiRegional_cfi::deltaPhi, MuScleFitUtils::deltaPhi(), MuScleFitUtils::deltaPhiMaxCut_, MuScleFitUtils::deltaPhiMinCut_, HLT_2023v12_cff::eta1, HLT_2023v12_cff::eta2, MuScleFitPlotter::fillTreeGen(), MuScleFitPlotter::fillTreeRec(), MuScleFitBase::genMuonPairs_, MuScleFitUtils::genMuscleFitPair, MuScleFitUtils::genPair, inputRootTreeFileName_, Data_TkAlMinBias_Run2018C_PromptReco_v3_cff::maxEvents, MuScleFitUtils::maxMuonEtaFirstRange_, MuScleFitUtils::maxMuonEtaSecondRange_, MuScleFitUtils::maxMuonPt_, MuScleFitUtils::minMuonEtaFirstRange_, MuScleFitUtils::minMuonEtaSecondRange_, MuScleFitUtils::minMuonPt_, MuScleFitBase::muonPairs_, plotter, HLT_2023v12_cff::pt1, HLT_2023v12_cff::pt2, RootTreeHandler::readTree(), MuScleFitUtils::SavedPair, MuScleFitUtils::SavedPairMuScleFitMuons, MuScleFitUtils::separateRanges_, MuScleFitUtils::SmearType, MuScleFitUtils::speedup, and MuScleFitBase::theMuonType_.

980  {
981  std::cout << "Reading muon pairs from Root Tree in " << treeFileName << std::endl;
982  RootTreeHandler rootTreeHandler;
983  std::vector<std::pair<unsigned int, unsigned long long> > evtRun;
985  rootTreeHandler.readTree(
987  } else {
988  rootTreeHandler.readTree(maxEvents,
991  theMuonType_,
992  &evtRun,
994  }
995  // Now loop on all the pairs and apply any smearing and bias if needed
996  std::vector<std::pair<unsigned int, unsigned long long> >::iterator evtRunIt = evtRun.begin();
997  std::vector<std::pair<MuScleFitMuon, MuScleFitMuon> >::iterator it = MuScleFitUtils::SavedPairMuScleFitMuons.begin();
998  std::vector<std::pair<MuScleFitMuon, MuScleFitMuon> >::iterator genIt;
999  if (MuScleFitUtils::speedup == false)
1000  genIt = MuScleFitUtils::genMuscleFitPair.begin();
1001  for (; it != MuScleFitUtils::SavedPairMuScleFitMuons.end(); ++it, ++evtRunIt) {
1002  // Apply any cut if requested
1003  // Note that cuts here are only applied to already selected muons. They should not be used unless
1004  // you are sure that the difference is negligible (e.g. the number of events with > 2 muons is negligible).
1005  double pt1 = it->first.pt();
1006  //std::cout << "pt1 = " << pt1 << std::endl;
1007  double pt2 = it->second.pt();
1008  //std::cout << "pt2 = " << pt2 << std::endl;
1009  double eta1 = it->first.eta();
1010  //std::cout << "eta1 = " << eta1 << std::endl;
1011  double eta2 = it->second.eta();
1012  //std::cout << "eta2 = " << eta2 << std::endl;
1013  // If they don't pass the cuts set to null vectors
1014  bool dontPass = false;
1015  bool eta1InFirstRange;
1016  bool eta2InFirstRange;
1017  bool eta1InSecondRange;
1018  bool eta2InSecondRange;
1019 
1020  int ch1 = it->first.charge();
1021  int ch2 = it->second.charge();
1022 
1026  eta1InSecondRange =
1028  eta2InSecondRange =
1030 
1031  // This is my logic, which should be erroneous, but certainly simpler...
1034  ((eta1InFirstRange && eta2InSecondRange && ch1 >= ch2) ||
1035  (eta1InSecondRange && eta2InFirstRange && ch1 < ch2))))
1036  dontPass = true;
1037  } else {
1040  eta1InSecondRange =
1042  eta2InSecondRange =
1046  (((eta1InFirstRange && !eta2InFirstRange) && (eta2InSecondRange && !eta1InSecondRange) && ch1 >= ch2) ||
1047  ((eta2InFirstRange && !eta1InFirstRange) && (eta1InSecondRange && !eta2InSecondRange) && ch1 < ch2))))
1048  dontPass = true;
1049  }
1050 
1051  // Additional check on deltaPhi
1052  double deltaPhi = MuScleFitUtils::deltaPhi(it->first.phi(), it->second.phi());
1054  dontPass = true;
1055 
1056  lorentzVector vec1 = it->first.p4();
1057  lorentzVector vec2 = it->second.p4();
1058  if (ch1 >= ch2) {
1059  lorentzVector vectemp = vec1;
1060  vec1 = vec2;
1061  vec2 = vectemp;
1062  }
1063 
1064  if (!dontPass) {
1065  // First is always mu-, second mu+
1066  if ((MuScleFitUtils::SmearType != 0) || (MuScleFitUtils::BiasType != 0)) {
1068  applyBias(vec1, -1);
1070  applyBias(vec2, 1);
1071  }
1072 
1073  MuScleFitUtils::SavedPair.push_back(std::make_pair(vec1, vec2));
1074  }
1075 
1076  //FIXME: we loose the additional information besides the 4-momenta
1077  muonPairs_.push_back(MuonPair(
1078  MuScleFitMuon(vec1, -1),
1079  MuScleFitMuon(vec2, +1),
1081  (*evtRunIt).first, (*evtRunIt).second, 0, 0, 0, 0)) // FIXME: order of event and run number mixed up!
1082  );
1083 
1084  // Fill the internal genPair tree from the external one
1085  if (!MuScleFitUtils::speedup) {
1086  MuScleFitUtils::genPair.push_back(std::make_pair(genIt->first.p4(), genIt->second.p4()));
1087  genMuonPairs_.push_back(GenMuonPair(genIt->first.p4(), genIt->second.p4(), 0));
1088  ++genIt;
1089  }
1090  }
1092  if (!(MuScleFitUtils::speedup)) {
1094  }
1095 }
std::vector< GenMuonPair > genMuonPairs_
Stores the genMuon pairs and the motherId prior to the creation of the internal tree.
Definition: MuScleFitBase.h:84
static double maxMuonEtaSecondRange_
static double deltaPhiMaxCut_
static std::vector< std::pair< MuScleFitMuon, MuScleFitMuon > > SavedPairMuScleFitMuons
static std::vector< std::pair< MuScleFitMuon, MuScleFitMuon > > genMuscleFitPair
static bool speedup
void readTree(const int maxEvents, const TString &fileName, MuonPairVector *savedPair, const int muonType, std::vector< std::pair< unsigned int, unsigned long long > > *evtRun, MuonPairVector *genPair=nullptr)
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 double minMuonEtaFirstRange_
static int BiasType
reco::Particle::LorentzVector lorentzVector
Definition: GenMuonPair.h:9
static double maxMuonPt_
static std::vector< std::pair< lorentzVector, lorentzVector > > genPair
std::vector< double > vec1
Definition: HCALResponse.h:15
static int SmearType
static std::vector< std::pair< lorentzVector, lorentzVector > > SavedPair
void applySmearing(reco::Particle::LorentzVector &mu)
Apply the smearing if needed using the function in MuScleFitUtils.
Definition: MuScleFit.cc:1406
void fillTreeGen(const std::vector< std::pair< reco::Particle::LorentzVector, reco::Particle::LorentzVector > > &genPairs)
static double deltaPhiMinCut_
MuScleFitPlotter * plotter
Definition: MuScleFit.cc:281
static bool separateRanges_
static double minMuonEtaSecondRange_
std::string inputRootTreeFileName_
Definition: MuScleFit.cc:296
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:82
static double deltaPhi(const double &phi1, const double &phi2)
static double minMuonPt_
std::vector< vec1 > vec2
Definition: HCALResponse.h:16
static double maxMuonEtaFirstRange_
void applyBias(reco::Particle::LorentzVector &mu, const int charge)
Apply the bias if needed using the function in MuScleFitUtils.
Definition: MuScleFit.cc:1414

◆ selGlobalMuon()

bool MuScleFit::selGlobalMuon ( const pat::Muon aMuon)
protected

Function for onia selections.

Definition at line 1520 of file MuScleFit.cc.

References pat::Muon::globalTrack(), pat::Muon::innerTrack(), pat::Muon::muonID(), AlCaHLTBitMon_ParallelJobs::p, and submitPVResolutionJobs::q.

1520  {
1521  reco::TrackRef iTrack = aMuon->innerTrack();
1522  const reco::HitPattern& p = iTrack->hitPattern();
1523 
1524  reco::TrackRef gTrack = aMuon->globalTrack();
1525  const reco::HitPattern& q = gTrack->hitPattern();
1526 
1527  return ( //isMuonInAccept(aMuon) &&// no acceptance cuts!
1528  iTrack->found() > 11 && gTrack->chi2() / gTrack->ndof() < 20.0 && q.numberOfValidMuonHits() > 0 &&
1529  iTrack->chi2() / iTrack->ndof() < 4.0 && aMuon->muonID("TrackerMuonArbitrated") &&
1530  aMuon->muonID("TMLastStationAngTight") && p.pixelLayersWithMeasurement() > 1 &&
1531  fabs(iTrack->dxy()) < 3.0 && //should be done w.r.t. PV!
1532  fabs(iTrack->dz()) < 15.0); //should be done w.r.t. PV!
1533 }
reco::TrackRef globalTrack() const override
reference to Track reconstructed in both tracked and muon detector (reimplemented from reco::Muon) ...
Definition: Muon.h:80
reco::TrackRef innerTrack() const override
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.h:72
bool muonID(const std::string &name) const

◆ selTrackerMuon()

bool MuScleFit::selTrackerMuon ( const pat::Muon aMuon)
protected

Definition at line 1535 of file MuScleFit.cc.

References pat::Muon::innerTrack(), pat::Muon::muonID(), and AlCaHLTBitMon_ParallelJobs::p.

1535  {
1536  reco::TrackRef iTrack = aMuon->innerTrack();
1537  const reco::HitPattern& p = iTrack->hitPattern();
1538 
1539  return ( //isMuonInAccept(aMuon) // no acceptance cuts!
1540  iTrack->found() > 11 && iTrack->chi2() / iTrack->ndof() < 4.0 && aMuon->muonID("TrackerMuonArbitrated") &&
1541  aMuon->muonID("TMLastStationAngTight") && p.pixelLayersWithMeasurement() > 1 &&
1542  fabs(iTrack->dxy()) < 3.0 && //should be done w.r.t. PV!
1543  fabs(iTrack->dz()) < 15.0); //should be done w.r.t. PV!
1544 }
reco::TrackRef innerTrack() const override
reference to Track reconstructed in the tracker only (reimplemented from reco::Muon) ...
Definition: Muon.h:72
bool muonID(const std::string &name) const

◆ startingNewLoop()

void MuScleFit::startingNewLoop ( unsigned int  int)
overridevirtual

Called before system starts to loop over the events. The argument is a count of how many loops have been processed. For the first time through the events the argument will be 0.

Implements edm::EDLooperBase.

Definition at line 698 of file MuScleFit.cc.

References MuScleFitUtils::counter_resprob, gather_cfg::cout, MuScleFitBase::debug_, MuScleFitBase::fillHistoMap(), MuScleFitUtils::goodmuon, iev, MuScleFitUtils::iev_, MuScleFitUtils::loopCounter, loopCounter, MuScleFitUtils::oldNormalization_, and MuScleFitBase::theFiles_.

Referenced by endOfLoop().

698  {
699  if (debug_ > 0)
700  std::cout << "[MuScleFit]: Starting loop # " << iLoop << std::endl;
701 
702  // Number of muons used
703  // --------------------
705 
706  // Counters for problem std::cout-ing
707  // -----------------------------
709 
710  // Create the root file
711  // --------------------
712  fillHistoMap(theFiles_[iLoop], iLoop);
713 
714  loopCounter = iLoop;
716 
717  iev = 0;
719 
721 }
static unsigned int loopCounter
unsigned int loopCounter
Definition: MuScleFit.cc:277
static double oldNormalization_
void fillHistoMap(TFile *outputFile, unsigned int iLoop)
Create the histograms map.
Definition: MuScleFitBase.cc:9
std::vector< TFile * > theFiles_
The files were the histograms are saved.
Definition: MuScleFitBase.h:76
static int goodmuon
static int iev_
static int counter_resprob

◆ takeSelectedMuonType()

template<typename T >
void MuScleFit::takeSelectedMuonType ( const T muon,
std::vector< reco::Track > &  tracks 
)
protected

Template method used to fill the track collection starting from reco::muons or pat::muons.

Definition at line 357 of file MuScleFit.cc.

References MuScleFitBase::theMuonType_, and pwdgSkimBPark_cfi::tracks.

357  {
358  // std::cout<<"muon "<<muon->isGlobalMuon()<<muon->isStandAloneMuon()<<muon->isTrackerMuon()<<std::endl;
359  //NNBB: one muon can be of many kinds at once but with the theMuonType_ we are sure
360  // to avoid double counting of the same muon
361  if (muon->isGlobalMuon() && theMuonType_ == 1)
362  tracks.push_back(*(muon->globalTrack()));
363  else if (muon->isStandAloneMuon() && theMuonType_ == 2)
364  tracks.push_back(*(muon->outerTrack()));
365  else if (muon->isTrackerMuon() && theMuonType_ == 3)
366  tracks.push_back(*(muon->innerTrack()));
367 
368  else if (theMuonType_ == 10 && !(muon->isStandAloneMuon())) //particular case!!
369  tracks.push_back(*(muon->innerTrack()));
370  else if (theMuonType_ == 11 && muon->isGlobalMuon())
371  tracks.push_back(*(muon->innerTrack()));
372  else if (theMuonType_ == 13 && muon->isTrackerMuon())
373  tracks.push_back(*(muon->innerTrack()));
374 }

Member Data Documentation

◆ compareToSimTracks_

bool MuScleFit::compareToSimTracks_
protected

Definition at line 290 of file MuScleFit.cc.

Referenced by duringFastLoop(), and MuScleFit().

◆ fastLoop

bool MuScleFit::fastLoop
protected

Definition at line 279 of file MuScleFit.cc.

Referenced by duringLoop(), endOfLoop(), and MuScleFit().

◆ genEvtInfoToken_

edm::EDGetTokenT<GenEventInfoProduct> MuScleFit::genEvtInfoToken_
protected

Definition at line 305 of file MuScleFit.cc.

Referenced by MuScleFit(), and selectMuons().

◆ genParticlesName_

std::string MuScleFit::genParticlesName_
protected

Definition at line 293 of file MuScleFit.cc.

Referenced by MuScleFit().

◆ iev

int MuScleFit::iev
protected

Definition at line 287 of file MuScleFit.cc.

Referenced by duringFastLoop(), endOfLoop(), and startingNewLoop().

◆ ifGenPart

bool MuScleFit::ifGenPart
protected

Definition at line 267 of file MuScleFit.cc.

◆ ifHepMC

bool MuScleFit::ifHepMC
protected

Definition at line 266 of file MuScleFit.cc.

◆ inputRootTreeFileName_

std::string MuScleFit::inputRootTreeFileName_
protected

Definition at line 296 of file MuScleFit.cc.

Referenced by duringLoop(), endOfLoop(), MuScleFit(), selectMuons(), and ~MuScleFit().

◆ loopCounter

unsigned int MuScleFit::loopCounter
protected

Definition at line 277 of file MuScleFit.cc.

Referenced by duringFastLoop(), duringLoop(), endOfFastLoop(), MuScleFit(), and startingNewLoop().

◆ maxEventsFromRootTree_

int MuScleFit::maxEventsFromRootTree_
protected

Definition at line 300 of file MuScleFit.cc.

Referenced by endOfLoop(), and MuScleFit().

◆ maxLoopNumber

unsigned int MuScleFit::maxLoopNumber
protected

Definition at line 276 of file MuScleFit.cc.

Referenced by beginOfJobInConstructor(), checkParameters(), endOfLoop(), and MuScleFit().

◆ maxResMass_hwindow

double MuScleFit::maxResMass_hwindow[6]
protected

Definition at line 272 of file MuScleFit.cc.

Referenced by MuScleFit().

◆ minResMass_hwindow

double MuScleFit::minResMass_hwindow[6]
protected

Definition at line 271 of file MuScleFit.cc.

Referenced by MuScleFit().

◆ muonSelector_

std::unique_ptr<MuScleFitMuonSelector> MuScleFit::muonSelector_
protected

Definition at line 317 of file MuScleFit.cc.

Referenced by MuScleFit(), and selectMuons().

◆ negateTrigger_

bool MuScleFit::negateTrigger_
protected

Definition at line 310 of file MuScleFit.cc.

Referenced by duringLoop(), and MuScleFit().

◆ numberOfEwkZ

int MuScleFit::numberOfEwkZ
protected

Definition at line 264 of file MuScleFit.cc.

◆ numberOfSimMuons

int MuScleFit::numberOfSimMuons
protected

Definition at line 262 of file MuScleFit.cc.

◆ numberOfSimTracks

int MuScleFit::numberOfSimTracks
protected

Definition at line 261 of file MuScleFit.cc.

◆ numberOfSimVertices

int MuScleFit::numberOfSimVertices
protected

Definition at line 263 of file MuScleFit.cc.

◆ outputRootTreeFileName_

std::string MuScleFit::outputRootTreeFileName_
protected

Definition at line 298 of file MuScleFit.cc.

Referenced by MuScleFit(), and ~MuScleFit().

◆ PATmuons_

bool MuScleFit::PATmuons_
protected

Definition at line 292 of file MuScleFit.cc.

Referenced by MuScleFit().

◆ plotter

MuScleFitPlotter* MuScleFit::plotter
protected

Definition at line 281 of file MuScleFit.cc.

Referenced by beginOfJobInConstructor(), endOfFastLoop(), and selectMuons().

◆ puInfoSrc_

edm::InputTag MuScleFit::puInfoSrc_
protected

Definition at line 314 of file MuScleFit.cc.

Referenced by MuScleFit().

◆ puInfoToken_

edm::EDGetTokenT<std::vector<PileupSummaryInfo> > MuScleFit::puInfoToken_
protected

Definition at line 304 of file MuScleFit.cc.

Referenced by MuScleFit(), and selectMuons().

◆ recMu1

reco::Particle::LorentzVector MuScleFit::recMu1
protected

Definition at line 285 of file MuScleFit.cc.

Referenced by duringFastLoop(), and selectMuons().

◆ recMu2

reco::Particle::LorentzVector MuScleFit::recMu2
protected

Definition at line 285 of file MuScleFit.cc.

Referenced by duringFastLoop(), and selectMuons().

◆ recMuScleMu1

MuScleFitMuon MuScleFit::recMuScleMu1
protected

Definition at line 286 of file MuScleFit.cc.

Referenced by selectMuons().

◆ recMuScleMu2

MuScleFitMuon MuScleFit::recMuScleMu2
protected

Definition at line 286 of file MuScleFit.cc.

Referenced by selectMuons().

◆ saveAllToTree_

bool MuScleFit::saveAllToTree_
protected

Definition at line 311 of file MuScleFit.cc.

Referenced by MuScleFit(), and ~MuScleFit().

◆ simTracksCollection_

edm::InputTag MuScleFit::simTracksCollection_
protected

Definition at line 291 of file MuScleFit.cc.

Referenced by MuScleFit().

◆ theService

MuonServiceProxy* MuScleFit::theService
protected

Definition at line 257 of file MuScleFit.cc.

◆ totalEvents_

int MuScleFit::totalEvents_
protected

Definition at line 288 of file MuScleFit.cc.

Referenced by duringLoop(), endOfLoop(), and ~MuScleFit().

◆ triggerPath_

std::vector<std::string> MuScleFit::triggerPath_
protected

Definition at line 309 of file MuScleFit.cc.

Referenced by duringLoop(), and MuScleFit().

◆ triggerResultsLabel_

std::string MuScleFit::triggerResultsLabel_
protected

Definition at line 307 of file MuScleFit.cc.

Referenced by MuScleFit().

◆ triggerResultsProcess_

std::string MuScleFit::triggerResultsProcess_
protected

Definition at line 308 of file MuScleFit.cc.

Referenced by duringLoop(), and MuScleFit().

◆ triggerResultsToken_

edm::EDGetTokenT<edm::TriggerResults> MuScleFit::triggerResultsToken_
protected

Definition at line 302 of file MuScleFit.cc.

Referenced by duringLoop(), and MuScleFit().

◆ vertexSrc_

edm::InputTag MuScleFit::vertexSrc_
protected

Definition at line 315 of file MuScleFit.cc.

Referenced by MuScleFit().

◆ vertexToken_

edm::EDGetTokenT<reco::VertexCollection> MuScleFit::vertexToken_
protected

Definition at line 303 of file MuScleFit.cc.

Referenced by MuScleFit(), and selectMuons().