CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
TestCorrection Class Reference

#include <MuonAnalysis/MomentumScaleCalibration/plugins/TestCorrection.cc>

Inheritance diagram for TestCorrection:
edm::EDAnalyzer MuScleFitBase edm::EDAnalyzer MuScleFitBase edm::EDConsumerBase edm::EDConsumerBase

Public Member Functions

 TestCorrection (const edm::ParameterSet &)
 
 TestCorrection (const edm::ParameterSet &)
 
 ~TestCorrection () override
 
 ~TestCorrection ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
lorentzVector correctMuon (const lorentzVector &muon)
 
lorentzVector correctMuon (const lorentzVector &muon)
 
void endJob () override
 
virtual void endJob ()
 
template<typename T >
std::vector< MuScleFitMuonfillMuonCollection (const std::vector< T > &tracks)
 
template<typename T >
std::vector< MuScleFitMuonfillMuonCollection (const std::vector< T > &tracks)
 
virtual void initialize (const edm::EventSetup &)
 
virtual void initialize (const edm::EventSetup &)
 
- 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

std::unique_ptr
< BackgroundFunction
background_
 
TH1F * correctedPt_
 
TProfile * correctedPtVsEta_
 
std::unique_ptr
< MomentumScaleCorrector
corrector_
 
int eventCounter_
 
edm::EDGetTokenT
< reco::MuonCollection
glbMuonsToken_
 
std::unique_ptr
< ResolutionFunction
resolution_
 
edm::EDGetTokenT
< reco::TrackCollection
saMuonsToken_
 
edm::EDGetTokenT
< reco::TrackCollection
tracksToken_
 
TH1F * uncorrectedPt_
 
TProfile * uncorrectedPtVsEta_
 
- 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_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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< B > consumes (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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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 () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
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)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 60 of file TestCorrection.cc.

Constructor & Destructor Documentation

TestCorrection::TestCorrection ( const edm::ParameterSet iConfig)
explicit

Definition at line 139 of file TestCorrection.cc.

References background_, correctedPt_, correctedPtVsEta_, corrector_, gather_cfg::cout, eventCounter_, MuScleFitBase::fillHistoMap(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), download_sqlite_cfg::outputFile, MuScleFitUtils::parResol, MuScleFitUtils::resfind, resolution_, MuScleFitUtils::resolutionFunction, MuScleFitUtils::resolutionFunctionForVec, resolutionFunctionVecService(), AlCaHLTBitMon_QueryRunRegistry::string, MuScleFitBase::theFiles_, MuScleFitBase::theRootFileName_, uncorrectedPt_, and uncorrectedPtVsEta_.

140  : MuScleFitBase(iConfig),
141  glbMuonsToken_(mayConsume<reco::MuonCollection>(theMuonLabel_)),
142  saMuonsToken_(mayConsume<reco::TrackCollection>(theMuonLabel_)),
143  tracksToken_(mayConsume<reco::TrackCollection>(theMuonLabel_)) {
144  //now do what ever initialization is needed
145  TFile* outputFile = new TFile(theRootFileName_.c_str(), "RECREATE");
146  theFiles_.push_back(outputFile);
147  // outputFile_ = new TFile(theRootFileName_.c_str(), "RECREATE");
148  // outputFile_->cd();
149  outputFile->cd();
150  MuScleFitUtils::resfind = iConfig.getParameter<std::vector<int> >("resfind");
151  fillHistoMap(outputFile, 0);
152  uncorrectedPt_ = new TH1F("uncorrectedPt", "uncorrected pt", 1000, 0, 100);
153  uncorrectedPtVsEta_ = new TProfile("uncorrectedPtVsEta", "uncorrected pt vs eta", 1000, 0, 100, -3., 3.);
154  correctedPt_ = new TH1F("correctedPt", "corrected pt", 1000, 0, 100);
155  correctedPtVsEta_ = new TProfile("correctedPtVsEta", "corrected pt vs eta", 1000, 0, 100, -3., 3.);
156  eventCounter_ = 0;
157  // Create the corrector and set the parameters
158  corrector_ =
159  std::make_unique<MomentumScaleCorrector>(iConfig.getUntrackedParameter<std::string>("CorrectionsIdentifier"));
160  std::cout << "corrector_ = " << &*corrector_ << std::endl;
161  resolution_ =
162  std::make_unique<ResolutionFunction>(iConfig.getUntrackedParameter<std::string>("ResolutionsIdentifier"));
163  std::cout << "resolution_ = " << &*resolution_ << std::endl;
164  background_ =
165  std::make_unique<BackgroundFunction>(iConfig.getUntrackedParameter<std::string>("BackgroundIdentifier"));
166 
167  // Initialize the parameters of MuScleFitUtils from those saved in the functions.
168  // MuScleFitUtils::parScale = corrector_.getFunction(0)->parameters();
171 
172  MuScleFitUtils::parResol = resolution_->parameters();
173 }
MuScleFitBase(const edm::ParameterSet &iConfig)
Definition: MuScleFitBase.h:20
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag theMuonLabel_
Definition: MuScleFitBase.h:48
TProfile * correctedPtVsEta_
static std::vector< double > parResol
edm::EDGetTokenT< reco::TrackCollection > saMuonsToken_
std::unique_ptr< BackgroundFunction > background_
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
std::unique_ptr< MomentumScaleCorrector > corrector_
TProfile * uncorrectedPtVsEta_
std::string theRootFileName_
Definition: MuScleFitBase.h:50
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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
edm::EDGetTokenT< reco::MuonCollection > glbMuonsToken_
tuple cout
Definition: gather_cfg.py:144
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
static std::vector< int > resfind
static resolutionFunctionBase< std::vector< double > > * resolutionFunctionForVec
static resolutionFunctionBase< double * > * resolutionFunction
std::unique_ptr< ResolutionFunction > resolution_
TestCorrection::~TestCorrection ( )
override

Definition at line 175 of file TestCorrection.cc.

References svgfig::canvas(), correctedPt_, correctedPtVsEta_, gather_cfg::cout, eventCounter_, MuScleFitBase::theFiles_, uncorrectedPt_, uncorrectedPtVsEta_, and MuScleFitBase::writeHistoMap().

175  {
176  theFiles_[0]->cd();
177  TCanvas canvas("ptComparison", "pt comparison", 1000, 800);
178  canvas.cd();
179  uncorrectedPt_->GetXaxis()->SetTitle("Pt(GeV)");
180  correctedPt_->SetLineColor(kRed);
181  TLegend* legend = new TLegend(0.7, 0.71, 0.98, 1.);
182  legend->SetTextSize(0.02);
183  legend->SetFillColor(0); // Have a white background
184  legend->AddEntry(uncorrectedPt_, "original pt");
185  legend->AddEntry(correctedPt_, "corrected pt");
186  uncorrectedPt_->Draw();
187  correctedPt_->Draw("same");
188  legend->Draw("same");
189 
190  canvas.Write();
191  uncorrectedPt_->Write();
192  uncorrectedPtVsEta_->Write();
193  correctedPt_->Write();
194  correctedPtVsEta_->Write();
195 
196  writeHistoMap(0);
197  theFiles_[0]->Close();
198 
199  std::cout << "Total analyzed events = " << eventCounter_ << std::endl;
200 }
TProfile * correctedPtVsEta_
def canvas
Definition: svgfig.py:482
TProfile * uncorrectedPtVsEta_
void writeHistoMap(const unsigned int iLoop)
Save the histograms map to file.
std::vector< TFile * > theFiles_
The files were the histograms are saved.
Definition: MuScleFitBase.h:76
tuple cout
Definition: gather_cfg.py:144
TestCorrection::TestCorrection ( const edm::ParameterSet )
explicit
TestCorrection::~TestCorrection ( )

Member Function Documentation

void TestCorrection::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 207 of file TestCorrection.cc.

References funct::abs(), correctedPt_, correctedPtVsEta_, correctMuon(), gather_cfg::cout, eventCounter_, fillMuonCollection(), MuScleFitUtils::findBestRecoRes(), edm::Event::getByToken(), glbMuonsToken_, initialize(), MuScleFitBase::mapHisto_, patZpeak::muons, MuScleFitUtils::ResFound, saMuonsToken_, MuScleFitUtils::SavedPair, MuScleFitBase::theMuonType_, tracks, tracksToken_, uncorrectedPt_, and uncorrectedPtVsEta_.

207  {
208  using namespace edm;
209 
210  initialize(iSetup);
211 
212  ++eventCounter_;
213  if (eventCounter_ % 100 == 0) {
214  std::cout << "Event number " << eventCounter_ << std::endl;
215  }
216 
217  // Take the reco-muons, depending on the type selected in the cfg
218  // --------------------------------------------------------------
219 
220  std::vector<MuScleFitMuon> muons;
221 
222  if (theMuonType_ == 1) { // GlobalMuons
224  iEvent.getByToken(glbMuonsToken_, glbMuons);
225  muons = fillMuonCollection(*glbMuons);
226  } else if (theMuonType_ == 2) { // StandaloneMuons
228  iEvent.getByToken(saMuonsToken_, saMuons);
229  muons = fillMuonCollection(*saMuons);
230  } else if (theMuonType_ == 3) { // Tracker tracks
232  iEvent.getByToken(tracksToken_, tracks);
233  muons = fillMuonCollection(*tracks);
234  }
235 
236  // Find the two muons from the resonance, and set ResFound bool
237  // ------------------------------------------------------------
238  std::pair<MuScleFitMuon, MuScleFitMuon> recMuFromBestRes = MuScleFitUtils::findBestRecoRes(muons);
240  MuScleFitUtils::SavedPair.push_back(std::make_pair(recMuFromBestRes.first.p4(), recMuFromBestRes.second.p4()));
241  } else {
242  MuScleFitUtils::SavedPair.push_back(std::make_pair(lorentzVector(0., 0., 0., 0.), lorentzVector(0., 0., 0., 0.)));
243  }
244 
245  // If resonance found, do the hard work
246  // ------------------------------------
248  // Find weight and reference mass for this muon pair
249  // -------------------------------------------------
250  // double weight = MuScleFitUtils::computeWeight ((recMu1+recMu2).mass());
251 
252  // Use the correction function to correct the pt scale of the muons. Note that this takes into
253  // account the corrections from all iterations.
254  lorentzVector recMu1;
255  recMu1 = correctMuon(recMu1);
256  lorentzVector recMu2;
257  recMu2 = correctMuon(recMu2);
258 
259  reco::Particle::LorentzVector bestRecRes(recMu1 + recMu2);
260 
261  //Fill histograms
262  //------------------
263  mapHisto_["hRecBestMu"]->Fill(recMu1);
264  if ((std::abs(recMu1.eta()) < 2.5) && (recMu1.pt() > 2.5)) {
265  mapHisto_["hRecBestMu_Acc"]->Fill(recMu1);
266  }
267  mapHisto_["hRecBestMu"]->Fill(recMu2);
268  if ((std::abs(recMu2.eta()) < 2.5) && (recMu2.pt() > 2.5)) {
269  mapHisto_["hRecBestMu_Acc"]->Fill(recMu2);
270  }
271  mapHisto_["hDeltaRecBestMu"]->Fill(recMu1, recMu2);
272 
273  mapHisto_["hRecBestRes"]->Fill(bestRecRes);
274  if ((std::abs(recMu1.eta()) < 2.5) && (recMu1.pt() > 2.5) && (std::abs(recMu2.eta()) < 2.5) &&
275  (recMu2.pt() > 2.5)) {
276  mapHisto_["hRecBestRes_Acc"]->Fill(bestRecRes);
277  // Fill histogram of Res mass vs muon variable
278  mapHisto_["hRecBestResVSMu"]->Fill(recMu1, bestRecRes, -1);
279  mapHisto_["hRecBestResVSMu"]->Fill(recMu2, bestRecRes, +1);
280  }
281  }
282 
283  // Loop on the recMuons
284  std::vector<MuScleFitMuon>::const_iterator recMuon = muons.begin();
285  int muonCount = 0;
286  for (; recMuon != muons.end(); ++recMuon, ++muonCount) {
287  // Fill the histogram with uncorrected pt values
288  uncorrectedPt_->Fill(recMuon->pt());
289  uncorrectedPtVsEta_->Fill(recMuon->pt(), recMuon->eta());
290 
291  // Fill the histogram with corrected pt values
292  std::cout << "correcting muon[" << muonCount << "] with pt = " << recMuon->pt() << std::endl;
293  double corrPt = (*corrector_)(*recMuon);
294  std::cout << "to pt = " << corrPt << std::endl;
295  correctedPt_->Fill(corrPt);
296  correctedPtVsEta_->Fill(corrPt, recMuon->eta());
297  // correctedPt_->Fill(recMuon->pt());
298  }
299 }
lorentzVector correctMuon(const lorentzVector &muon)
TProfile * correctedPtVsEta_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
virtual void initialize(const edm::EventSetup &)
edm::EDGetTokenT< reco::TrackCollection > saMuonsToken_
std::map< std::string, Histograms * > mapHisto_
The map of histograms.
Definition: MuScleFitBase.h:79
auto const & tracks
cannot be loose
static bool ResFound
reco::Particle::LorentzVector lorentzVector
Definition: GenMuonPair.h:9
static std::pair< MuScleFitMuon, MuScleFitMuon > findBestRecoRes(const std::vector< MuScleFitMuon > &muons)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static std::vector< std::pair< lorentzVector, lorentzVector > > SavedPair
TProfile * uncorrectedPtVsEta_
std::vector< MuScleFitMuon > fillMuonCollection(const std::vector< T > &tracks)
edm::EDGetTokenT< reco::MuonCollection > glbMuonsToken_
tuple muons
Definition: patZpeak.py:39
tuple cout
Definition: gather_cfg.py:144
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
virtual void TestCorrection::analyze ( const edm::Event ,
const edm::EventSetup  
)
privatevirtual

Implements edm::EDAnalyzer.

lorentzVector TestCorrection::correctMuon ( const lorentzVector muon)
private

Definition at line 301 of file TestCorrection.cc.

References corrector_, and MuScleFitUtils::fromPtEtaPhiToPxPyPz().

Referenced by analyze().

301  {
302  double corrPt = corrector_->correct(muon);
303  double ptEtaPhiE[4] = {corrPt, muon.Eta(), muon.Phi(), muon.E()};
304  return MuScleFitUtils::fromPtEtaPhiToPxPyPz(ptEtaPhiE);
305 }
std::unique_ptr< MomentumScaleCorrector > corrector_
static lorentzVector fromPtEtaPhiToPxPyPz(const double *ptEtaPhiE)
lorentzVector TestCorrection::correctMuon ( const lorentzVector muon)
private
void TestCorrection::endJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 68 of file TestCorrection.cc.

68 {};
virtual void TestCorrection::endJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 69 of file TestCorrection.h.

69 {};
template<typename T >
std::vector<MuScleFitMuon> TestCorrection::fillMuonCollection ( const std::vector< T > &  tracks)
inlineprivate

Definition at line 70 of file TestCorrection.cc.

References gather_cfg::cout, MuScleFitBase::debug_, RPCpg::mu, HLT_FULL_cff::muon, patZpeak::muons, mathSSE::sqrt(), and HLT_FULL_cff::track.

Referenced by analyze().

70  {
71  std::vector<MuScleFitMuon> muons;
72  typename std::vector<T>::const_iterator track;
73  for (track = tracks.begin(); track != tracks.end(); ++track) {
76  track->px(), track->py(), track->pz(), sqrt(track->p() * track->p() + +0.011163612));
77 
78  Double_t hitsTk(0), hitsMuon(0), ptError(0);
79  if (const reco::Muon* myMu = dynamic_cast<const reco::Muon*>(&(*track))) {
80  hitsTk = myMu->innerTrack()->hitPattern().numberOfValidTrackerHits();
81  hitsMuon = myMu->innerTrack()->hitPattern().numberOfValidMuonHits();
82  ptError = myMu->innerTrack()->ptError();
83  } else if (const pat::Muon* myMu = dynamic_cast<const pat::Muon*>(&(*track))) {
84  hitsTk = myMu->innerTrack()->hitPattern().numberOfValidTrackerHits();
85  hitsMuon = myMu->innerTrack()->hitPattern().numberOfValidMuonHits();
86  ptError = myMu->innerTrack()->ptError();
87  } else if (const reco::Track* myMu = dynamic_cast<const reco::Track*>(&(*track))) {
88  hitsTk = myMu->hitPattern().numberOfValidTrackerHits();
89  hitsMuon = myMu->hitPattern().numberOfValidMuonHits();
90  ptError = myMu->ptError();
91  }
92 
93  MuScleFitMuon muon(mu, track->charge(), ptError, hitsTk, hitsMuon);
94 
95  if (debug_ > 0) {
96  std::cout << "[TestCorrection::fillMuonCollection] after MuScleFitMuon initialization" << std::endl;
97  std::cout << " muon = " << muon << std::endl;
98  }
99 
100  muons.push_back(muon);
101  }
102  return muons;
103  }
auto const & tracks
cannot be loose
T sqrt(T t)
Definition: SSEVec.h:19
const int mu
Definition: Constants.h:22
tuple muons
Definition: patZpeak.py:39
tuple cout
Definition: gather_cfg.py:144
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
Analysis-level muon class.
Definition: Muon.h:51
template<typename T >
std::vector<MuScleFitMuon> TestCorrection::fillMuonCollection ( const std::vector< T > &  tracks)
inlineprivate

Definition at line 71 of file TestCorrection.h.

References gather_cfg::cout, MuScleFitBase::debug_, RPCpg::mu, HLT_FULL_cff::muon, patZpeak::muons, mathSSE::sqrt(), and HLT_FULL_cff::track.

72  {
73  std::vector<MuScleFitMuon> muons;
74  typename std::vector<T>::const_iterator track;
75  for( track = tracks.begin(); track != tracks.end(); ++track ) {
77  mu = reco::Particle::LorentzVector(track->px(),track->py(),track->pz(),
78  sqrt(track->p()*track->p() + + 0.011163612));
79 
80  Double_t hitsTk(0), hitsMuon(0), ptError(0);
81  if ( const reco::Muon* myMu = dynamic_cast<const reco::Muon*>(&(*track)) ){
82  hitsTk = myMu->innerTrack()->hitPattern().numberOfValidTrackerHits();
83  hitsMuon = myMu->innerTrack()->hitPattern().numberOfValidMuonHits();
84  ptError = myMu->innerTrack()->ptError();
85  }
86  else if ( const pat::Muon* myMu = dynamic_cast<const pat::Muon*>(&(*track)) ) {
87  hitsTk = myMu->innerTrack()->hitPattern().numberOfValidTrackerHits();
88  hitsMuon = myMu->innerTrack()->hitPattern().numberOfValidMuonHits();
89  ptError = myMu->innerTrack()->ptError();
90  }
91  else if (const reco::Track* myMu = dynamic_cast<const reco::Track*>(&(*track))){
92  hitsTk = myMu->hitPattern().numberOfValidTrackerHits();
93  hitsMuon = myMu->hitPattern().numberOfValidMuonHits();
94  ptError = myMu->ptError();
95  }
96 
97  MuScleFitMuon muon(mu,track->charge(),ptError,hitsTk,hitsMuon,false);
98 
99  if (debug_>0) {
100  std::cout<<"[TestCorrection::fillMuonCollection] after MuScleFitMuon initialization"<<std::endl;
101  std::cout<<" muon = "<<muon<<std::endl;
102  }
103 
104  muons.push_back(muon);
105  }
106  return muons;
107  }
auto const & tracks
cannot be loose
T sqrt(T t)
Definition: SSEVec.h:19
const int mu
Definition: Constants.h:22
tuple muons
Definition: patZpeak.py:39
tuple cout
Definition: gather_cfg.py:144
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
Analysis-level muon class.
Definition: Muon.h:51
void TestCorrection::initialize ( const edm::EventSetup )
privatevirtual

Definition at line 308 of file TestCorrection.cc.

References MuScleFitBase::readProbabilityDistributionsFromFile().

Referenced by analyze().

308  {
309  // Read the pdf from root file. They are used by massProb when finding the muon pair, needed
310  // for the mass histograms.
312 }
void readProbabilityDistributionsFromFile()
Read probability distributions from a local root file.
virtual void TestCorrection::initialize ( const edm::EventSetup )
privatevirtual

Member Data Documentation

std::unique_ptr< BackgroundFunction > TestCorrection::background_
private

Definition at line 120 of file TestCorrection.cc.

Referenced by TestCorrection().

TH1F * TestCorrection::correctedPt_
private

Definition at line 113 of file TestCorrection.cc.

Referenced by analyze(), TestCorrection(), and ~TestCorrection().

TProfile * TestCorrection::correctedPtVsEta_
private

Definition at line 114 of file TestCorrection.cc.

Referenced by analyze(), TestCorrection(), and ~TestCorrection().

std::unique_ptr< MomentumScaleCorrector > TestCorrection::corrector_
private

Definition at line 118 of file TestCorrection.cc.

Referenced by correctMuon(), and TestCorrection().

int TestCorrection::eventCounter_
private

Definition at line 116 of file TestCorrection.cc.

Referenced by analyze(), TestCorrection(), and ~TestCorrection().

edm::EDGetTokenT<reco::MuonCollection> TestCorrection::glbMuonsToken_
private

Definition at line 122 of file TestCorrection.cc.

Referenced by analyze().

std::unique_ptr< ResolutionFunction > TestCorrection::resolution_
private

Definition at line 119 of file TestCorrection.cc.

Referenced by TestCorrection().

edm::EDGetTokenT<reco::TrackCollection> TestCorrection::saMuonsToken_
private

Definition at line 123 of file TestCorrection.cc.

Referenced by analyze().

edm::EDGetTokenT<reco::TrackCollection> TestCorrection::tracksToken_
private

Definition at line 124 of file TestCorrection.cc.

Referenced by analyze().

TH1F * TestCorrection::uncorrectedPt_
private

Definition at line 111 of file TestCorrection.cc.

Referenced by analyze(), TestCorrection(), and ~TestCorrection().

TProfile * TestCorrection::uncorrectedPtVsEta_
private

Definition at line 112 of file TestCorrection.cc.

Referenced by analyze(), TestCorrection(), and ~TestCorrection().