CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ErrorsAnalyzer Class Reference

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

Inheritance diagram for ErrorsAnalyzer:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 ErrorsAnalyzer (const edm::ParameterSet &)
 
 ~ErrorsAnalyzer () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
void drawHistograms (const TProfile *histo, const TProfile *histoPlusErr, const TProfile *histoMinusErr, const TString &type)
 
void endJob () override
 
void fillHistograms ()
 
void fillValueError ()
 

Private Attributes

bool debug_
 
std::vector< int > errorFactors_
 
std::vector< double > errors_
 
int etaBins_
 
double etaMax_
 
double etaMin_
 
uint32_t maxEvents_
 
TString outputFileName_
 
std::vector< double > parameters_
 
int ptBins_
 
double ptMax_
 
double ptMin_
 
int resolFitType_
 
TProfile * sigmaMassVsEta_
 
TProfile * sigmaMassVsEtaMinusErr_
 
TProfile * sigmaMassVsEtaPlusErr_
 
TProfile * sigmaMassVsPt_
 
TProfile * sigmaMassVsPtMinusErr_
 
TProfile * sigmaMassVsPtPlusErr_
 
TProfile * sigmaPtVsEta_
 
TProfile * sigmaPtVsEtaMinusErr_
 
TProfile * sigmaPtVsEtaPlusErr_
 
TProfile * sigmaPtVsPt_
 
TProfile * sigmaPtVsPtMinusErr_
 
TProfile * sigmaPtVsPtPlusErr_
 
TString treeFileName_
 
std::vector< double > valueMinusError_
 
std::vector< double > valuePlusError_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 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 ()
 
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)
 

Detailed Description

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

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

Definition at line 45 of file ErrorsAnalyzer.cc.

Constructor & Destructor Documentation

◆ ErrorsAnalyzer()

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

Definition at line 97 of file ErrorsAnalyzer.cc.

References gather_cfg::cout, errorFactors_, errors_, etaBins_, etaMax_, etaMin_, beamvalidation::exit(), fillValueError(), edm::ParameterSet::getParameter(), parameters_, ptBins_, ptMax_, ptMin_, sigmaMassVsEta_, sigmaMassVsEtaMinusErr_, sigmaMassVsEtaPlusErr_, sigmaMassVsPt_, sigmaMassVsPtMinusErr_, sigmaMassVsPtPlusErr_, sigmaPtVsEta_, sigmaPtVsEtaMinusErr_, sigmaPtVsEtaPlusErr_, sigmaPtVsPt_, sigmaPtVsPtMinusErr_, and sigmaPtVsPtPlusErr_.

98  : treeFileName_(iConfig.getParameter<std::string>("InputFileName")),
99  resolFitType_(iConfig.getParameter<int>("ResolFitType")),
100  maxEvents_(iConfig.getParameter<int>("MaxEvents")),
101  outputFileName_(iConfig.getParameter<std::string>("OutputFileName")),
102  ptBins_(iConfig.getParameter<int>("PtBins")),
103  ptMin_(iConfig.getParameter<double>("PtMin")),
104  ptMax_(iConfig.getParameter<double>("PtMax")),
105  etaBins_(iConfig.getParameter<int>("EtaBins")),
106  etaMin_(iConfig.getParameter<double>("EtaMin")),
107  etaMax_(iConfig.getParameter<double>("EtaMax")),
108  debug_(iConfig.getParameter<bool>("Debug")) {
109  parameters_ = iConfig.getParameter<std::vector<double> >("Parameters");
110  errors_ = iConfig.getParameter<std::vector<double> >("Errors");
111  errorFactors_ = iConfig.getParameter<std::vector<int> >("ErrorFactors");
112 
113  if ((parameters_.size() != errors_.size()) || (parameters_.size() != errorFactors_.size())) {
114  std::cout << "Error: parameters and errors have different number of values" << std::endl;
115  exit(1);
116  }
117 
118  fillValueError();
119 
120  sigmaPtVsPt_ = new TProfile("sigmaPtVsPtProfile", "sigmaPtVsPt", ptBins_, ptMin_, ptMax_);
121  sigmaPtVsPtPlusErr_ = new TProfile("sigmaPtVsPtPlusErrProfile", "sigmaPtVsPtPlusErr", ptBins_, ptMin_, ptMax_);
122  sigmaPtVsPtMinusErr_ = new TProfile("sigmaPtVsPtMinusErrProfile", "sigmaPtVsPtMinusErr", ptBins_, ptMin_, ptMax_);
123 
124  sigmaPtVsEta_ = new TProfile("sigmaPtVsEtaProfile", "sigmaPtVsEta", etaBins_, etaMin_, etaMax_);
125  sigmaPtVsEtaPlusErr_ = new TProfile("sigmaPtVsEtaPlusErrProfile", "sigmaPtVsEtaPlusErr", etaBins_, etaMin_, etaMax_);
127  new TProfile("sigmaPtVsEtaMinusErrProfile", "sigmaPtVsEtaMinusErr", etaBins_, etaMin_, etaMax_);
128 
129  sigmaMassVsPt_ = new TProfile("sigmaMassVsPtProfile", "sigmaMassVsPt", ptBins_, ptMin_, ptMax_);
130  sigmaMassVsPtPlusErr_ = new TProfile("sigmaMassVsPtPlusErrProfile", "sigmaMassVsPtPlusErr", ptBins_, ptMin_, ptMax_);
132  new TProfile("sigmaMassVsPtMinusErrProfile", "sigmaMassVsPtMinusErr", ptBins_, ptMin_, ptMax_);
133 
134  sigmaMassVsEta_ = new TProfile("sigmaMassVsEtaProfile", "sigmaMassVsEta", etaBins_, etaMin_, etaMax_);
136  new TProfile("sigmaMassVsEtaPlusErrProfile", "sigmaMassVsEtaPlusErr", etaBins_, etaMin_, etaMax_);
138  new TProfile("sigmaMassVsEtaMinusErrProfile", "sigmaMassVsEtaMinusErr", etaBins_, etaMin_, etaMax_);
139 }
TProfile * sigmaMassVsPtPlusErr_
TProfile * sigmaMassVsEta_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< double > errors_
TProfile * sigmaPtVsPtMinusErr_
TProfile * sigmaMassVsPtMinusErr_
TProfile * sigmaMassVsEtaPlusErr_
TString outputFileName_
TProfile * sigmaPtVsEtaMinusErr_
std::vector< int > errorFactors_
uint32_t maxEvents_
TProfile * sigmaPtVsPtPlusErr_
TProfile * sigmaPtVsPt_
TProfile * sigmaMassVsEtaMinusErr_
TProfile * sigmaMassVsPt_
std::vector< double > parameters_
TString treeFileName_
TProfile * sigmaPtVsEta_
TProfile * sigmaPtVsEtaPlusErr_
def exit(msg="")

◆ ~ErrorsAnalyzer()

ErrorsAnalyzer::~ErrorsAnalyzer ( )
override

Definition at line 155 of file ErrorsAnalyzer.cc.

References drawHistograms(), fillHistograms(), download_sqlite_cfg::outputFile, outputFileName_, sigmaMassVsEta_, sigmaMassVsEtaMinusErr_, sigmaMassVsEtaPlusErr_, sigmaMassVsPt_, sigmaMassVsPtMinusErr_, sigmaMassVsPtPlusErr_, sigmaPtVsEta_, sigmaPtVsEtaMinusErr_, sigmaPtVsEtaPlusErr_, sigmaPtVsPt_, sigmaPtVsPtMinusErr_, and sigmaPtVsPtPlusErr_.

155  {
156  gROOT->SetStyle("Plain");
157 
158  fillHistograms();
159 
160  TFile* outputFile = new TFile(outputFileName_, "RECREATE");
161 
164 
167 
168  outputFile->Write();
169  outputFile->Close();
170 }
TProfile * sigmaMassVsPtPlusErr_
TProfile * sigmaMassVsEta_
void drawHistograms(const TProfile *histo, const TProfile *histoPlusErr, const TProfile *histoMinusErr, const TString &type)
TProfile * sigmaPtVsPtMinusErr_
TProfile * sigmaMassVsPtMinusErr_
TProfile * sigmaMassVsEtaPlusErr_
TString outputFileName_
TProfile * sigmaPtVsEtaMinusErr_
TProfile * sigmaPtVsPtPlusErr_
TProfile * sigmaPtVsPt_
TProfile * sigmaMassVsEtaMinusErr_
TProfile * sigmaMassVsPt_
TProfile * sigmaPtVsEta_
TProfile * sigmaPtVsEtaPlusErr_

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 285 of file ErrorsAnalyzer.cc.

285 {}

◆ drawHistograms()

void ErrorsAnalyzer::drawHistograms ( const TProfile *  histo,
const TProfile *  histoPlusErr,
const TProfile *  histoMinusErr,
const TString &  type 
)
private

Definition at line 172 of file ErrorsAnalyzer.cc.

References svgfig::canvas(), timingPdfMaker::histo, mps_fire::i, sigmaMassVsEta_, sigmaMassVsEtaMinusErr_, sigmaMassVsEtaPlusErr_, sigmaPtVsEta_, sigmaPtVsEtaMinusErr_, sigmaPtVsEtaPlusErr_, runGCPTkAlMap::title, and contentValuesCheck::values.

Referenced by ~ErrorsAnalyzer().

175  {
176  TH1D* sigmaPtVsEtaTH1D =
177  new TH1D(type, type, histo->GetNbinsX(), histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax());
178  TH1D* sigmaPtVsEtaPlusErrTH1D = new TH1D(type + "PlusErr",
179  type + "PlusErr",
180  histo->GetNbinsX(),
181  histo->GetXaxis()->GetXmin(),
182  histo->GetXaxis()->GetXmax());
183  TH1D* sigmaPtVsEtaMinusErrTH1D = new TH1D(type + "MinusErr",
184  type + "MinusErr",
185  histo->GetNbinsX(),
186  histo->GetXaxis()->GetXmin(),
187  histo->GetXaxis()->GetXmax());
188 
189  TH1D* sigmaMassVsEtaTH1D =
190  new TH1D(type, type, histo->GetNbinsX(), histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax());
191  TH1D* sigmaMassVsEtaPlusErrTH1D = new TH1D(type + "PlusErr",
192  type + "PlusErr",
193  histo->GetNbinsX(),
194  histo->GetXaxis()->GetXmin(),
195  histo->GetXaxis()->GetXmax());
196  TH1D* sigmaMassVsEtaMinusErrTH1D = new TH1D(type + "MinusErr",
197  type + "MinusErr",
198  histo->GetNbinsX(),
199  histo->GetXaxis()->GetXmin(),
200  histo->GetXaxis()->GetXmax());
201 
202  TCanvas* canvas = new TCanvas("canvas" + type, "canvas" + type, 1000, 800);
203  for (int iBin = 1; iBin <= histo->GetNbinsX(); ++iBin) {
204  sigmaPtVsEtaTH1D->SetBinContent(iBin, histo->GetBinContent(iBin));
205  sigmaPtVsEtaPlusErrTH1D->SetBinContent(iBin, histoPlusErr->GetBinContent(iBin));
206  sigmaPtVsEtaMinusErrTH1D->SetBinContent(iBin, histoMinusErr->GetBinContent(iBin));
207  }
208  int numBins = sigmaPtVsEtaTH1D->GetNbinsX();
209  // Draw TGraph with asymmetric errors
210  Double_t* values = sigmaPtVsEtaTH1D->GetArray();
211  Double_t* valuesPlus = sigmaPtVsEtaPlusErrTH1D->GetArray();
212  Double_t* valuesMinus = sigmaPtVsEtaMinusErrTH1D->GetArray();
213  double* posErrors = new double[numBins];
214  double* negErrors = new double[numBins];
215 
216  TGraphAsymmErrors* graphAsymmErrors = new TGraphAsymmErrors(sigmaPtVsEtaTH1D);
217  TGraph* graph = new TGraph(sigmaPtVsEtaTH1D);
218 
219  for (int i = 1; i <= numBins; ++i) {
220  // std::cout << "filling " << i << std::endl;
221  posErrors[i - 1] = valuesPlus[i] - values[i];
222  if (valuesMinus[i] < 0)
223  negErrors[i - 1] = values[i];
224  else
225  negErrors[i - 1] = values[i] - valuesMinus[i];
226 
227  graphAsymmErrors->SetPointEYlow(i - 1, negErrors[i - 1]);
228  graphAsymmErrors->SetPointEYhigh(i - 1, posErrors[i - 1]);
229  }
230 
231  canvas->Draw();
232 
233  delete[] posErrors;
234  delete[] negErrors;
235 
236  graphAsymmErrors->SetTitle("");
237  graphAsymmErrors->SetFillColor(kGray);
238  graphAsymmErrors->Draw("A2");
239  TString title(type);
240  if (type == "Eta")
241  title = "#eta";
242  graphAsymmErrors->GetXaxis()->SetTitle(title);
243  graphAsymmErrors->GetYaxis()->SetTitle("#sigmaPt/Pt");
244  graph->Draw();
245 
246  // graph->SetLineColor(kGray);
247  // graph->SetMarkerColor(kBlack);
248  // graph->Draw("AP");
249 
250  // if( debug_ ) {
251  // sigmaPtVsEtaPlusErrTH1D->SetLineColor(kRed);
252  // sigmaPtVsEtaMinusErrTH1D->SetLineColor(kBlue);
253  // }
254  // else {
255  // sigmaPtVsEtaPlusErrTH1D->SetFillColor(kGray);
256  // sigmaPtVsEtaPlusErrTH1D->SetLineColor(kWhite);
257  // sigmaPtVsEtaMinusErrTH1D->SetFillColor(kWhite);
258  // sigmaPtVsEtaMinusErrTH1D->SetLineColor(kWhite);
259  // }
260  // sigmaPtVsEtaPlusErrTH1D->Draw();
261  // sigmaPtVsEtaTH1D->Draw("SAME");
262  // sigmaPtVsEtaMinusErrTH1D->Draw("SAME");
263 
264  sigmaPtVsEtaPlusErrTH1D->Write();
265  sigmaPtVsEtaTH1D->Write();
266  sigmaPtVsEtaMinusErrTH1D->Write();
267 
268  sigmaPtVsEtaPlusErr_->Write();
269  sigmaPtVsEta_->Write();
270  sigmaPtVsEtaMinusErr_->Write();
271 
272  // Mass
273  sigmaMassVsEtaPlusErrTH1D->Write();
274  sigmaMassVsEtaTH1D->Write();
275  sigmaMassVsEtaMinusErrTH1D->Write();
276 
277  sigmaMassVsEtaPlusErr_->Write();
278  sigmaMassVsEta_->Write();
279  sigmaMassVsEtaMinusErr_->Write();
280 
281  canvas->Write();
282 }
TProfile * sigmaMassVsEta_
TProfile * sigmaMassVsEtaPlusErr_
TProfile * sigmaPtVsEtaMinusErr_
TProfile * sigmaMassVsEtaMinusErr_
def canvas(sub, attr)
Definition: svgfig.py:482
TProfile * sigmaPtVsEta_
TProfile * sigmaPtVsEtaPlusErr_

◆ endJob()

void ErrorsAnalyzer::endJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 58 of file ErrorsAnalyzer.cc.

58 {};

◆ fillHistograms()

void ErrorsAnalyzer::fillHistograms ( )
private

Definition at line 287 of file ErrorsAnalyzer.cc.

References gather_cfg::cout, MuScleFitUtils::debug, debug_, MuScleFitUtils::debugMassResol_, HLT_2022v15_cff::eta1, HLT_2022v15_cff::eta2, mps_fire::i, MuScleFitUtils::massResolution(), maxEvents_, parameters_, HLT_2022v15_cff::pt1, HLT_2022v15_cff::pt2, RootTreeHandler::readTree(), MuScleFitUtils::resfind, resolFitType_, MuScleFitUtils::resolutionFunction, resolutionFunctionService(), resolutionFunctionVecService(), sigmaMassVsEta_, sigmaMassVsEtaMinusErr_, sigmaMassVsEtaPlusErr_, sigmaMassVsPt_, sigmaMassVsPtMinusErr_, sigmaMassVsPtPlusErr_, resolutionFunctionBase< T >::sigmaPt(), sigmaPtVsEta_, sigmaPtVsEtaMinusErr_, sigmaPtVsEtaPlusErr_, sigmaPtVsPt_, sigmaPtVsPtMinusErr_, sigmaPtVsPtPlusErr_, treeFileName_, valueMinusError_, and valuePlusError_.

Referenced by ~ErrorsAnalyzer().

287  {
288  std::cout << "Reading muon pairs from Root Tree in " << treeFileName_ << std::endl;
289  RootTreeHandler rootTreeHandler;
290 
291  typedef std::vector<std::pair<lorentzVector, lorentzVector> > MuonPairVector;
292  MuonPairVector savedPair;
293  std::vector<std::pair<unsigned int, unsigned long long> > evtRun;
294  rootTreeHandler.readTree(maxEvents_, treeFileName_, &savedPair, 0, &evtRun);
295  // rootTreeHandler.readTree(maxEvents, inputRootTreeFileName_, &savedPair, &(MuScleFitUtils::genPair));
296 
301  MuScleFitUtils::resfind = std::vector<int>(6, 0);
302 
303  // Loop on all the pairs
304  unsigned int i = 0;
305  MuonPairVector::iterator it = savedPair.begin();
306  std::cout << "Starting loop on " << savedPair.size() << " muons" << std::endl;
307  for (; it != savedPair.end(); ++it, ++i) {
308  double pt1 = it->first.pt();
309  double eta1 = it->first.eta();
310  double pt2 = it->second.pt();
311  double eta2 = it->second.eta();
312 
313  if (debug_) {
314  std::cout << "pt1 = " << pt1 << ", eta1 = " << eta1 << ", pt2 = " << pt2 << ", eta2 = " << eta2 << std::endl;
315  }
316 
317  if (pt1 == 0 && pt2 == 0 && eta1 == 0 && eta2 == 0)
318  continue;
319 
320  double sigmaPt1 = resolutionFunctionForVec->sigmaPt(pt1, eta1, parameters_);
321  double sigmaPt2 = resolutionFunctionForVec->sigmaPt(pt2, eta2, parameters_);
322  double sigmaPtPlusErr1 = resolutionFunctionForVec->sigmaPt(pt1, eta1, valuePlusError_);
323  double sigmaPtPlusErr2 = resolutionFunctionForVec->sigmaPt(pt2, eta2, valuePlusError_);
324  double sigmaPtMinusErr1 = resolutionFunctionForVec->sigmaPt(pt1, eta1, valueMinusError_);
325  double sigmaPtMinusErr2 = resolutionFunctionForVec->sigmaPt(pt2, eta2, valueMinusError_);
326 
327  double sigmaMass = MuScleFitUtils::massResolution(it->first, it->second, parameters_);
328  double sigmaMassPlusErr = MuScleFitUtils::massResolution(it->first, it->second, valuePlusError_);
329  double sigmaMassMinusErr = MuScleFitUtils::massResolution(it->first, it->second, valueMinusError_);
330 
331  if (debug_) {
332  std::cout << "sigmaPt1 = " << sigmaPt1 << " + " << sigmaPtPlusErr1 << " - " << sigmaPtMinusErr1 << std::endl;
333  std::cout << "sigmaPt2 = " << sigmaPt2 << " + " << sigmaPtPlusErr2 << " - " << sigmaPtMinusErr2 << std::endl;
334  std::cout << "sigmaMass = " << sigmaMass << " + " << sigmaMassPlusErr << " - " << sigmaMassMinusErr << std::endl;
335  }
336 
337  // Protections from nans
338  if (pt1 != pt1)
339  continue;
340  if (pt2 != pt2)
341  continue;
342  if (eta1 != eta1)
343  continue;
344  if (eta2 != eta2)
345  continue;
346  if (sigmaPt1 != sigmaPt1)
347  continue;
348  if (sigmaPt2 != sigmaPt2)
349  continue;
350  if (sigmaPtPlusErr1 != sigmaPtPlusErr1)
351  continue;
352  if (sigmaPtPlusErr2 != sigmaPtPlusErr2)
353  continue;
354  if (sigmaPtMinusErr1 != sigmaPtMinusErr1)
355  continue;
356  if (sigmaPtMinusErr2 != sigmaPtMinusErr2)
357  continue;
358  if (sigmaMass != sigmaMass)
359  continue;
360  if (sigmaMassPlusErr != sigmaMassPlusErr)
361  continue;
362  if (sigmaMassMinusErr != sigmaMassMinusErr)
363  continue;
364 
365  std::cout << "Muon pair number " << i << std::endl;
366 
367  // std::cout << "sigmaPt1 = " << sigmaPt1 << ", sigmaPt2 = " << sigmaPt2 << std::endl;
368  // std::cout << "sigmaPtPlusErr1 = " << sigmaPtPlusErr1 << ", sigmaPtMinusErr2 = " << sigmaPtMinusErr2 << std::endl;
369  // std::cout << "sigmaPtMinusErr1 = " << sigmaPtPlusErr1 << ", sigmaPtMinusErr2 = " << sigmaPtMinusErr2 << std::endl;
370 
371  sigmaPtVsPt_->Fill(pt1, sigmaPt1);
372  sigmaPtVsPt_->Fill(pt2, sigmaPt2);
373  sigmaPtVsPtPlusErr_->Fill(pt1, sigmaPtPlusErr1);
374  sigmaPtVsPtPlusErr_->Fill(pt2, sigmaPtPlusErr2);
375  sigmaPtVsPtMinusErr_->Fill(pt1, sigmaPtMinusErr1);
376  sigmaPtVsPtMinusErr_->Fill(pt2, sigmaPtMinusErr2);
377 
378  sigmaPtVsEta_->Fill(eta1, sigmaPt1);
379  sigmaPtVsEta_->Fill(eta2, sigmaPt2);
380  sigmaPtVsEtaPlusErr_->Fill(eta1, sigmaPtPlusErr1);
381  sigmaPtVsEtaPlusErr_->Fill(eta2, sigmaPtPlusErr2);
382  sigmaPtVsEtaMinusErr_->Fill(eta1, sigmaPtMinusErr1);
383  sigmaPtVsEtaMinusErr_->Fill(eta2, sigmaPtMinusErr2);
384 
385  sigmaMassVsPt_->Fill(pt1, sigmaMass);
386  sigmaMassVsPt_->Fill(pt2, sigmaMass);
387  sigmaMassVsPtPlusErr_->Fill(pt1, sigmaMassPlusErr);
388  sigmaMassVsPtPlusErr_->Fill(pt2, sigmaMassPlusErr);
389  sigmaMassVsPtMinusErr_->Fill(pt1, sigmaMassMinusErr);
390  sigmaMassVsPtMinusErr_->Fill(pt2, sigmaMassMinusErr);
391 
392  sigmaMassVsEta_->Fill(eta1, sigmaMass);
393  sigmaMassVsEta_->Fill(eta2, sigmaMass);
394  sigmaMassVsEtaPlusErr_->Fill(eta1, sigmaMassPlusErr);
395  sigmaMassVsEtaPlusErr_->Fill(eta2, sigmaMassPlusErr);
396  sigmaMassVsEtaMinusErr_->Fill(eta1, sigmaMassMinusErr);
397  sigmaMassVsEtaMinusErr_->Fill(eta2, sigmaMassMinusErr);
398  }
399 }
TProfile * sigmaMassVsPtPlusErr_
TProfile * sigmaMassVsEta_
std::vector< double > valueMinusError_
TProfile * sigmaPtVsPtMinusErr_
TProfile * sigmaMassVsPtMinusErr_
static bool debugMassResol_
TProfile * sigmaMassVsEtaPlusErr_
static int debug
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)
TProfile * sigmaPtVsEtaMinusErr_
resolutionFunctionBase< double * > * resolutionFunctionService(const int identifier)
Service to build the resolution functor corresponding to the passed identifier.
Definition: Functions.cc:70
virtual double sigmaPt(const double &pt, const double &eta, const T &parval)=0
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
static double massResolution(const lorentzVector &mu1, const lorentzVector &mu2)
uint32_t maxEvents_
std::vector< double > valuePlusError_
TProfile * sigmaPtVsPtPlusErr_
TProfile * sigmaPtVsPt_
std::vector< std::pair< lorentzVector, lorentzVector > > MuonPairVector
TProfile * sigmaMassVsEtaMinusErr_
TProfile * sigmaMassVsPt_
std::vector< double > parameters_
static std::vector< int > resfind
TString treeFileName_
TProfile * sigmaPtVsEta_
TProfile * sigmaPtVsEtaPlusErr_
static resolutionFunctionBase< double * > * resolutionFunction

◆ fillValueError()

void ErrorsAnalyzer::fillValueError ( )
private

Definition at line 141 of file ErrorsAnalyzer.cc.

References errorFactors_, errors_, mps_fire::i, parameters_, valueMinusError_, and valuePlusError_.

Referenced by ErrorsAnalyzer().

141  {
142  valuePlusError_.resize(parameters_.size());
143  valueMinusError_.resize(parameters_.size());
144 
145  std::vector<double>::const_iterator parIt = parameters_.begin();
146  std::vector<double>::const_iterator errIt = errors_.begin();
147  std::vector<int>::const_iterator errFactorIt = errorFactors_.begin();
148  int i = 0;
149  for (; parIt != parameters_.end(); ++parIt, ++errIt, ++errFactorIt, ++i) {
150  valuePlusError_[i] = *parIt + (*errIt) * (*errFactorIt);
151  valueMinusError_[i] = *parIt - (*errIt) * (*errFactorIt);
152  }
153 }
std::vector< double > valueMinusError_
std::vector< double > errors_
std::vector< int > errorFactors_
std::vector< double > valuePlusError_
std::vector< double > parameters_

Member Data Documentation

◆ debug_

bool ErrorsAnalyzer::debug_
private

Definition at line 70 of file ErrorsAnalyzer.cc.

Referenced by fillHistograms().

◆ errorFactors_

std::vector<int> ErrorsAnalyzer::errorFactors_
private

Definition at line 74 of file ErrorsAnalyzer.cc.

Referenced by ErrorsAnalyzer(), and fillValueError().

◆ errors_

std::vector<double> ErrorsAnalyzer::errors_
private

Definition at line 73 of file ErrorsAnalyzer.cc.

Referenced by ErrorsAnalyzer(), and fillValueError().

◆ etaBins_

int ErrorsAnalyzer::etaBins_
private

Definition at line 67 of file ErrorsAnalyzer.cc.

Referenced by ErrorsAnalyzer().

◆ etaMax_

double ErrorsAnalyzer::etaMax_
private

Definition at line 69 of file ErrorsAnalyzer.cc.

Referenced by ErrorsAnalyzer().

◆ etaMin_

double ErrorsAnalyzer::etaMin_
private

Definition at line 68 of file ErrorsAnalyzer.cc.

Referenced by ErrorsAnalyzer().

◆ maxEvents_

uint32_t ErrorsAnalyzer::maxEvents_
private

Definition at line 62 of file ErrorsAnalyzer.cc.

Referenced by fillHistograms().

◆ outputFileName_

TString ErrorsAnalyzer::outputFileName_
private

Definition at line 63 of file ErrorsAnalyzer.cc.

Referenced by ~ErrorsAnalyzer().

◆ parameters_

std::vector<double> ErrorsAnalyzer::parameters_
private

◆ ptBins_

int ErrorsAnalyzer::ptBins_
private

Definition at line 64 of file ErrorsAnalyzer.cc.

Referenced by ErrorsAnalyzer().

◆ ptMax_

double ErrorsAnalyzer::ptMax_
private

Definition at line 66 of file ErrorsAnalyzer.cc.

Referenced by ErrorsAnalyzer().

◆ ptMin_

double ErrorsAnalyzer::ptMin_
private

Definition at line 65 of file ErrorsAnalyzer.cc.

Referenced by ErrorsAnalyzer().

◆ resolFitType_

int ErrorsAnalyzer::resolFitType_
private

Definition at line 61 of file ErrorsAnalyzer.cc.

Referenced by fillHistograms().

◆ sigmaMassVsEta_

TProfile* ErrorsAnalyzer::sigmaMassVsEta_
private

Definition at line 88 of file ErrorsAnalyzer.cc.

Referenced by drawHistograms(), ErrorsAnalyzer(), fillHistograms(), and ~ErrorsAnalyzer().

◆ sigmaMassVsEtaMinusErr_

TProfile* ErrorsAnalyzer::sigmaMassVsEtaMinusErr_
private

Definition at line 90 of file ErrorsAnalyzer.cc.

Referenced by drawHistograms(), ErrorsAnalyzer(), fillHistograms(), and ~ErrorsAnalyzer().

◆ sigmaMassVsEtaPlusErr_

TProfile* ErrorsAnalyzer::sigmaMassVsEtaPlusErr_
private

Definition at line 89 of file ErrorsAnalyzer.cc.

Referenced by drawHistograms(), ErrorsAnalyzer(), fillHistograms(), and ~ErrorsAnalyzer().

◆ sigmaMassVsPt_

TProfile* ErrorsAnalyzer::sigmaMassVsPt_
private

Definition at line 92 of file ErrorsAnalyzer.cc.

Referenced by ErrorsAnalyzer(), fillHistograms(), and ~ErrorsAnalyzer().

◆ sigmaMassVsPtMinusErr_

TProfile* ErrorsAnalyzer::sigmaMassVsPtMinusErr_
private

Definition at line 94 of file ErrorsAnalyzer.cc.

Referenced by ErrorsAnalyzer(), fillHistograms(), and ~ErrorsAnalyzer().

◆ sigmaMassVsPtPlusErr_

TProfile* ErrorsAnalyzer::sigmaMassVsPtPlusErr_
private

Definition at line 93 of file ErrorsAnalyzer.cc.

Referenced by ErrorsAnalyzer(), fillHistograms(), and ~ErrorsAnalyzer().

◆ sigmaPtVsEta_

TProfile* ErrorsAnalyzer::sigmaPtVsEta_
private

Definition at line 79 of file ErrorsAnalyzer.cc.

Referenced by drawHistograms(), ErrorsAnalyzer(), fillHistograms(), and ~ErrorsAnalyzer().

◆ sigmaPtVsEtaMinusErr_

TProfile* ErrorsAnalyzer::sigmaPtVsEtaMinusErr_
private

Definition at line 81 of file ErrorsAnalyzer.cc.

Referenced by drawHistograms(), ErrorsAnalyzer(), fillHistograms(), and ~ErrorsAnalyzer().

◆ sigmaPtVsEtaPlusErr_

TProfile* ErrorsAnalyzer::sigmaPtVsEtaPlusErr_
private

Definition at line 80 of file ErrorsAnalyzer.cc.

Referenced by drawHistograms(), ErrorsAnalyzer(), fillHistograms(), and ~ErrorsAnalyzer().

◆ sigmaPtVsPt_

TProfile* ErrorsAnalyzer::sigmaPtVsPt_
private

Definition at line 83 of file ErrorsAnalyzer.cc.

Referenced by ErrorsAnalyzer(), fillHistograms(), and ~ErrorsAnalyzer().

◆ sigmaPtVsPtMinusErr_

TProfile* ErrorsAnalyzer::sigmaPtVsPtMinusErr_
private

Definition at line 85 of file ErrorsAnalyzer.cc.

Referenced by ErrorsAnalyzer(), fillHistograms(), and ~ErrorsAnalyzer().

◆ sigmaPtVsPtPlusErr_

TProfile* ErrorsAnalyzer::sigmaPtVsPtPlusErr_
private

Definition at line 84 of file ErrorsAnalyzer.cc.

Referenced by ErrorsAnalyzer(), fillHistograms(), and ~ErrorsAnalyzer().

◆ treeFileName_

TString ErrorsAnalyzer::treeFileName_
private

Definition at line 58 of file ErrorsAnalyzer.cc.

Referenced by fillHistograms().

◆ valueMinusError_

std::vector<double> ErrorsAnalyzer::valueMinusError_
private

Definition at line 77 of file ErrorsAnalyzer.cc.

Referenced by fillHistograms(), and fillValueError().

◆ valuePlusError_

std::vector<double> ErrorsAnalyzer::valuePlusError_
private

Definition at line 76 of file ErrorsAnalyzer.cc.

Referenced by fillHistograms(), and fillValueError().