CMS 3D CMS Logo

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

#include <MuonCaloCompatibility.h>

Public Member Functions

void configure (const edm::ParameterSet &)
 
double evaluate (const reco::Muon &)
 
 MuonCaloCompatibility ()
 

Private Member Functions

bool accessing_overflow (const TH2D &histo, double x, double y)
 

Private Attributes

bool isConfigured_
 
double muon_compatibility
 
std::shared_ptr< TH2D > muon_em_etaB
 
std::shared_ptr< TH2D > muon_em_etaEmi
 
std::shared_ptr< TH2D > muon_em_etaEpl
 
std::shared_ptr< TH2D > muon_em_etaTmi
 
std::shared_ptr< TH2D > muon_em_etaTpl
 
std::shared_ptr< TH2D > muon_had_etaB
 
std::shared_ptr< TH2D > muon_had_etaEmi
 
std::shared_ptr< TH2D > muon_had_etaEpl
 
std::shared_ptr< TH2D > muon_had_etaTmi
 
std::shared_ptr< TH2D > muon_had_etaTpl
 
std::shared_ptr< TH2D > muon_ho_etaB
 
std::shared_ptr< TH2D > muon_template_em
 
std::shared_ptr< TH2D > muon_template_had
 
std::shared_ptr< TH2D > muon_template_ho
 
double pbx
 
double pby
 
double pbz
 
std::shared_ptr< TH2D > pion_em_etaB
 
std::shared_ptr< TH2D > pion_em_etaEmi
 
std::shared_ptr< TH2D > pion_em_etaEpl
 
std::shared_ptr< TH2D > pion_em_etaTmi
 
std::shared_ptr< TH2D > pion_em_etaTpl
 
std::shared_ptr< TH2D > pion_had_etaB
 
std::shared_ptr< TH2D > pion_had_etaEmi
 
std::shared_ptr< TH2D > pion_had_etaEpl
 
std::shared_ptr< TH2D > pion_had_etaTmi
 
std::shared_ptr< TH2D > pion_had_etaTpl
 
std::shared_ptr< TH2D > pion_ho_etaB
 
std::shared_ptr< TH2D > pion_template_em
 
std::shared_ptr< TH2D > pion_template_had
 
std::shared_ptr< TH2D > pion_template_ho
 
double psx
 
double psy
 
double psz
 
bool use_corrected_hcal
 
bool use_em_special
 

Detailed Description

Definition at line 26 of file MuonCaloCompatibility.h.

Constructor & Destructor Documentation

◆ MuonCaloCompatibility()

MuonCaloCompatibility::MuonCaloCompatibility ( )
inline

Definition at line 28 of file MuonCaloCompatibility.h.

Member Function Documentation

◆ accessing_overflow()

bool MuonCaloCompatibility::accessing_overflow ( const TH2D &  histo,
double  x,
double  y 
)
private

Definition at line 142 of file MuonCaloCompatibility.cc.

References timingPdfMaker::histo, x, and y.

Referenced by evaluate().

142  {
143  bool access = false;
144 
145  if (histo.GetXaxis()->FindBin(x) == 0 || histo.GetXaxis()->FindBin(x) > histo.GetXaxis()->GetNbins()) {
146  access = true;
147  }
148  if (histo.GetYaxis()->FindBin(y) == 0 || histo.GetYaxis()->FindBin(y) > histo.GetYaxis()->GetNbins()) {
149  access = true;
150  }
151  return access;
152 }

◆ configure()

void MuonCaloCompatibility::configure ( const edm::ParameterSet iConfig)

Definition at line 21 of file MuonCaloCompatibility.cc.

References edm::ParameterSet::getParameter(), isConfigured_, muon_compatibility, muon_em_etaB, muon_em_etaEmi, muon_em_etaEpl, muon_em_etaTmi, muon_em_etaTpl, muon_had_etaB, muon_had_etaEmi, muon_had_etaEpl, muon_had_etaTmi, muon_had_etaTpl, muon_ho_etaB, pbx, pby, pbz, pion_em_etaB, pion_em_etaEmi, pion_em_etaEpl, pion_em_etaTmi, pion_em_etaTpl, pion_had_etaB, pion_had_etaEmi, pion_had_etaEpl, pion_had_etaTmi, pion_had_etaTpl, pion_ho_etaB, psx, psy, psz, AlCaHLTBitMon_QueryRunRegistry::string, use_corrected_hcal, and use_em_special.

Referenced by MuonIdProducer::MuonIdProducer().

21  {
22  const std::string muonfileName = (iConfig.getParameter<edm::FileInPath>("MuonTemplateFileName")).fullPath();
23  const std::string pionfileName = (iConfig.getParameter<edm::FileInPath>("PionTemplateFileName")).fullPath();
24  TFile muon_templates(muonfileName.c_str(), "READ");
25  TFile pion_templates(pionfileName.c_str(), "READ");
26 
27  pion_em_etaEmi.reset((TH2D*)pion_templates.Get("em_etaEmi"));
28  pion_had_etaEmi.reset((TH2D*)pion_templates.Get("had_etaEmi"));
29 
30  pion_em_etaTmi.reset((TH2D*)pion_templates.Get("em_etaTmi"));
31  pion_had_etaTmi.reset((TH2D*)pion_templates.Get("had_etaTmi"));
32 
33  pion_em_etaB.reset((TH2D*)pion_templates.Get("em_etaB"));
34  pion_had_etaB.reset((TH2D*)pion_templates.Get("had_etaB"));
35  pion_ho_etaB.reset((TH2D*)pion_templates.Get("ho_etaB"));
36 
37  pion_em_etaTpl.reset((TH2D*)pion_templates.Get("em_etaTpl"));
38  pion_had_etaTpl.reset((TH2D*)pion_templates.Get("had_etaTpl"));
39 
40  pion_em_etaEpl.reset((TH2D*)pion_templates.Get("em_etaEpl"));
41  pion_had_etaEpl.reset((TH2D*)pion_templates.Get("had_etaEpl"));
42 
43  muon_em_etaEmi.reset((TH2D*)muon_templates.Get("em_etaEmi"));
44  muon_had_etaEmi.reset((TH2D*)muon_templates.Get("had_etaEmi"));
45 
46  muon_em_etaTmi.reset((TH2D*)muon_templates.Get("em_etaTmi"));
47  muon_had_etaTmi.reset((TH2D*)muon_templates.Get("had_etaTmi"));
48 
49  muon_em_etaB.reset((TH2D*)muon_templates.Get("em_etaB"));
50  muon_had_etaB.reset((TH2D*)muon_templates.Get("had_etaB"));
51  muon_ho_etaB.reset((TH2D*)muon_templates.Get("ho_etaB"));
52 
53  muon_em_etaTpl.reset((TH2D*)muon_templates.Get("em_etaTpl"));
54  muon_had_etaTpl.reset((TH2D*)muon_templates.Get("had_etaTpl"));
55 
56  muon_em_etaEpl.reset((TH2D*)muon_templates.Get("em_etaEpl"));
57  muon_had_etaEpl.reset((TH2D*)muon_templates.Get("had_etaEpl"));
58 
59  // Release from the opened file
60  pion_em_etaEmi->SetDirectory(nullptr);
61  pion_had_etaEmi->SetDirectory(nullptr);
62 
63  pion_em_etaTmi->SetDirectory(nullptr);
64  pion_had_etaTmi->SetDirectory(nullptr);
65 
66  pion_em_etaB->SetDirectory(nullptr);
67  pion_had_etaB->SetDirectory(nullptr);
68  pion_ho_etaB->SetDirectory(nullptr);
69 
70  pion_em_etaTpl->SetDirectory(nullptr);
71  pion_had_etaTpl->SetDirectory(nullptr);
72 
73  pion_em_etaEpl->SetDirectory(nullptr);
74  pion_had_etaEpl->SetDirectory(nullptr);
75 
76  muon_em_etaEmi->SetDirectory(nullptr);
77  muon_had_etaEmi->SetDirectory(nullptr);
78 
79  muon_em_etaTmi->SetDirectory(nullptr);
80  muon_had_etaTmi->SetDirectory(nullptr);
81 
82  muon_em_etaB->SetDirectory(nullptr);
83  muon_had_etaB->SetDirectory(nullptr);
84  muon_ho_etaB->SetDirectory(nullptr);
85 
86  muon_em_etaTpl->SetDirectory(nullptr);
87  muon_had_etaTpl->SetDirectory(nullptr);
88 
89  muon_em_etaEpl->SetDirectory(nullptr);
90  muon_had_etaEpl->SetDirectory(nullptr);
91 
92  // change names
93  const std::string prefixPion = "MuonCaloCompatibility_pion_";
94  pion_em_etaEmi->SetName((prefixPion + pion_em_etaEmi->GetName()).c_str());
95  pion_had_etaEmi->SetName((prefixPion + pion_had_etaEmi->GetName()).c_str());
96 
97  pion_em_etaTmi->SetName((prefixPion + pion_em_etaTmi->GetName()).c_str());
98  pion_had_etaTmi->SetName((prefixPion + pion_had_etaTmi->GetName()).c_str());
99 
100  pion_em_etaB->SetName((prefixPion + pion_em_etaB->GetName()).c_str());
101  pion_had_etaB->SetName((prefixPion + pion_had_etaB->GetName()).c_str());
102  pion_ho_etaB->SetName((prefixPion + pion_ho_etaB->GetName()).c_str());
103 
104  pion_em_etaTpl->SetName((prefixPion + pion_em_etaTpl->GetName()).c_str());
105  pion_had_etaTpl->SetName((prefixPion + pion_had_etaTpl->GetName()).c_str());
106 
107  pion_em_etaEpl->SetName((prefixPion + pion_em_etaEpl->GetName()).c_str());
108  pion_had_etaEpl->SetName((prefixPion + pion_had_etaEpl->GetName()).c_str());
109 
110  const std::string prefixMuon = "MuonCaloCompatibility_muon_";
111  muon_em_etaEmi->SetName((prefixMuon + muon_em_etaEmi->GetName()).c_str());
112  muon_had_etaEmi->SetName((prefixMuon + muon_had_etaEmi->GetName()).c_str());
113 
114  muon_em_etaTmi->SetName((prefixMuon + muon_em_etaTmi->GetName()).c_str());
115  muon_had_etaTmi->SetName((prefixMuon + muon_had_etaTmi->GetName()).c_str());
116 
117  muon_em_etaB->SetName((prefixMuon + muon_em_etaB->GetName()).c_str());
118  muon_had_etaB->SetName((prefixMuon + muon_had_etaB->GetName()).c_str());
119  muon_ho_etaB->SetName((prefixMuon + muon_ho_etaB->GetName()).c_str());
120 
121  muon_em_etaTpl->SetName((prefixMuon + muon_em_etaTpl->GetName()).c_str());
122  muon_had_etaTpl->SetName((prefixMuon + muon_had_etaTpl->GetName()).c_str());
123 
124  muon_em_etaEpl->SetName((prefixMuon + muon_em_etaEpl->GetName()).c_str());
125  muon_had_etaEpl->SetName((prefixMuon + muon_had_etaEpl->GetName()).c_str());
126 
127  pbx = -1;
128  pby = -1;
129  pbz = -1;
130 
131  psx = -1;
132  psy = -1;
133  psz = -1;
134 
135  muon_compatibility = -1;
136 
137  use_corrected_hcal = true;
138  use_em_special = true;
139  isConfigured_ = true;
140 }
std::shared_ptr< TH2D > muon_em_etaTmi
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::shared_ptr< TH2D > muon_em_etaEmi
std::shared_ptr< TH2D > pion_ho_etaB
std::shared_ptr< TH2D > muon_ho_etaB
std::shared_ptr< TH2D > pion_had_etaEpl
std::shared_ptr< TH2D > pion_had_etaB
std::shared_ptr< TH2D > pion_em_etaEpl
std::shared_ptr< TH2D > muon_had_etaEpl
std::shared_ptr< TH2D > pion_had_etaTmi
std::shared_ptr< TH2D > pion_em_etaB
std::shared_ptr< TH2D > pion_em_etaTmi
std::shared_ptr< TH2D > muon_had_etaTpl
std::shared_ptr< TH2D > muon_em_etaB
std::shared_ptr< TH2D > pion_em_etaTpl
std::shared_ptr< TH2D > pion_had_etaEmi
std::shared_ptr< TH2D > muon_had_etaTmi
std::shared_ptr< TH2D > pion_em_etaEmi
std::shared_ptr< TH2D > muon_em_etaTpl
std::shared_ptr< TH2D > pion_had_etaTpl
std::shared_ptr< TH2D > muon_had_etaEmi
std::shared_ptr< TH2D > muon_had_etaB
std::shared_ptr< TH2D > muon_em_etaEpl

◆ evaluate()

double MuonCaloCompatibility::evaluate ( const reco::Muon amuon)

Definition at line 154 of file MuonCaloCompatibility.cc.

References accessing_overflow(), reco::Muon::calEnergy(), reco::MuonEnergy::em, PVValHelper::eta, Exception, edm::Ref< C, T, F >::get(), reco::MuonEnergy::had, reco::MuonEnergy::ho, Hcal_Conditions_forGlobalTag_cff::ho, isConfigured_, edm::Ref< C, T, F >::isNull(), LogTrace, muon_compatibility, muon_em_etaB, muon_em_etaEmi, muon_em_etaEpl, muon_em_etaTmi, muon_em_etaTpl, muon_had_etaB, muon_had_etaEmi, muon_had_etaEpl, muon_had_etaTmi, muon_had_etaTpl, muon_ho_etaB, muon_template_em, muon_template_had, muon_template_ho, AlCaHLTBitMon_ParallelJobs::p, pbx, pby, pbz, pion_em_etaB, pion_em_etaEmi, pion_em_etaEpl, pion_em_etaTmi, pion_em_etaTpl, pion_had_etaB, pion_had_etaEmi, pion_had_etaEpl, pion_had_etaTmi, pion_had_etaTpl, pion_ho_etaB, pion_template_em, pion_template_had, pion_template_ho, psx, psy, psz, funct::sin(), reco::Muon::standAloneMuon(), reco::Muon::track(), HLT_2024v14_cff::track, use_corrected_hcal, and use_em_special.

Referenced by MuonIdProducer::makeCaloMuon(), and MuonIdProducer::produce().

154  {
155  if (!isConfigured_) {
156  edm::LogWarning("MuonIdentification") << "MuonCaloCompatibility is not configured! Nothing is calculated.";
157  return -9999;
158  }
159 
160  double eta = 0.;
161  double p = 0.;
162  double em = 0.;
163  double had = 0.;
164  double ho = 0.;
165 
166  // had forgotten this reset in previous versions 070409
167  pbx = 1.;
168  pby = 1.;
169  pbz = 1.;
170 
171  psx = 1.;
172  psy = 1.;
173  psz = 1.;
174 
175  muon_compatibility = -1.;
176 
177  pion_template_em = nullptr;
178  muon_template_em = nullptr;
179 
180  pion_template_had = nullptr;
181  muon_template_had = nullptr;
182 
183  pion_template_ho = nullptr;
184  muon_template_ho = nullptr;
185 
186  // 071002: Get either tracker track, or SAmuon track.
187  // CaloCompatibility templates may have to be specialized for
188  // the use with SAmuons, currently just using the ones produced
189  // using tracker tracks.
190  const reco::Track* track = nullptr;
191  if (!amuon.track().isNull()) {
192  track = amuon.track().get();
193  } else {
194  if (!amuon.standAloneMuon().isNull()) {
195  track = amuon.standAloneMuon().get();
196  } else {
197  throw cms::Exception("FatalError")
198  << "Failed to fill muon id calo_compatibility information for a muon with undefined references to tracks";
199  }
200  }
201 
202  if (!use_corrected_hcal) { // old eta regions, uncorrected energy
203  eta = track->eta();
204  p = track->p();
205 
206  // new 070904: Set lookup momentum to 1999.9 if larger than 2 TeV.
207  // Though the templates were produced with p<2TeV, we believe that
208  // this approximation should be roughly valid. A special treatment
209  // for >1 TeV muons is advisable anyway :)
210  if (p >= 2000.)
211  p = 1999.9;
212 
213  // p = 10./sin(track->theta()); // use this for templates < 1_5
214  if (use_em_special) {
215  if (amuon.calEnergy().em == 0.)
216  em = -5.;
217  else
218  em = amuon.calEnergy().em;
219  } else {
220  em = amuon.calEnergy().em;
221  }
222  had = amuon.calEnergy().had;
223  ho = amuon.calEnergy().ho;
224  } else {
225  eta = track->eta();
226  p = track->p();
227 
228  // new 070904: Set lookup momentum to 1999.9 if larger than 2 TeV.
229  // Though the templates were produced with p<2TeV, we believe that
230  // this approximation should be roughly valid. A special treatment
231  // for >1 TeV muons is advisable anyway :)
232  if (p >= 2000.)
233  p = 1999.9;
234 
235  // p = 10./sin(track->theta()); // use this for templates < 1_5
236  // hcal energy is now done where we get the template histograms (to use corrected cal energy)!
237  // had = amuon.calEnergy().had;
238  if (use_em_special) {
239  if (amuon.calEnergy().em == 0.)
240  em = -5.;
241  else
242  em = amuon.calEnergy().em;
243  } else {
244  em = amuon.calEnergy().em;
245  }
246  ho = amuon.calEnergy().ho;
247  }
248 
249  // Skip everyting and return "I don't know" (i.e. 0.5) for uncovered regions:
250  // if( p < 0. || p > 500.) return 0.5; // removed 500 GeV cutoff 070817 after updating the tempates (v2_0) to have valid entried beyond 500 GeV
251  if (p < 0.)
252  return 0.5; // return "unknown" for unphysical momentum input.
253  if (fabs(eta) > 2.5)
254  return 0.5;
255  // temporary fix for low association efficiency:
256  // set caloCompatibility to 0.12345 for tracks
257  // which have 0 energy in BOTH ecal and hcal
258  if (amuon.calEnergy().had == 0.0 && amuon.calEnergy().em == 0.0)
259  return 0.12345;
260 
261  // std::cout<<std::endl<<"Input values are: "<<eta <<" "<< p <<" "<< em <<" "<< had <<" "<< ho;
262 
263  // depending on the eta, choose correct histogram: (now all for barrel):
264  // bad! eta range has to be syncronised with choice for histogram... should be read out from the histo file somehow... 070322
265  if (42 != 42) { // old eta ranges and uncorrected hcal energy
266  if (eta <= -1.4) {
267  // std::cout<<"Emi"<<std::endl;
272  } else if (eta > -1.4 && eta <= -1.31) {
273  // std::cout<<"Tmi"<<std::endl;
278  } else if (eta > -1.31 && eta <= 1.31) {
279  // std::cout<<"B"<<std::endl;
286  } else if (eta > 1.31 && eta <= 1.4) {
287  // std::cout<<"Tpl"<<std::endl;
292  } else if (eta > 1.4) {
293  // std::cout<<"Epl"<<std::endl;
298  } else {
299  LogTrace("MuonIdentification")
300  << "Some very weird thing happened in MuonCaloCompatibility::evaluate - go figure ;) ";
301  return -999;
302  }
303  } else if (42 == 42) { // new eta bins, corrected hcal energy
304  if (track->eta() > 1.27) {
305  // had_etaEpl ->Fill(muon->track().get()->p(),1.8/2.2*muon->calEnergy().had );
306  if (use_corrected_hcal)
307  had = 1.8 / 2.2 * amuon.calEnergy().had;
308  else
309  had = amuon.calEnergy().had;
312  }
313  if (track->eta() <= 1.27 && track->eta() > 1.1) {
314  // had_etaTpl ->Fill(muon->track().get()->p(),(1.8/(-2.2*muon->track().get()->eta()+5.5))*muon->calEnergy().had );
315  if (use_corrected_hcal)
316  had = (1.8 / (-2.2 * track->eta() + 5.5)) * amuon.calEnergy().had;
317  else
318  had = amuon.calEnergy().had;
321  }
322  if (track->eta() <= 1.1 && track->eta() > -1.1) {
323  // had_etaB ->Fill(muon->track().get()->p(),sin(muon->track().get()->theta())*muon->calEnergy().had );
324  if (use_corrected_hcal)
325  had = sin(track->theta()) * amuon.calEnergy().had;
326  else
327  had = amuon.calEnergy().had;
330  }
331  if (track->eta() <= -1.1 && track->eta() > -1.27) {
332  // had_etaTmi ->Fill(muon->track().get()->p(),(1.8/(-2.2*muon->track().get()->eta()+5.5))*muon->calEnergy().had );
333  if (use_corrected_hcal)
334  had = (1.8 / (2.2 * track->eta() + 5.5)) * amuon.calEnergy().had;
335  else
336  had = amuon.calEnergy().had;
339  }
340  if (track->eta() <= -1.27) {
341  // had_etaEmi ->Fill(muon->track().get()->p(),1.8/2.2*muon->calEnergy().had );
342  if (use_corrected_hcal)
343  had = 1.8 / 2.2 * amuon.calEnergy().had;
344  else
345  had = amuon.calEnergy().had;
348  }
349 
350  // just two eta regions for Ecal (+- 1.479 for barrel, else for rest), no correction:
351 
352  // std::cout<<"We have a muon with an eta of: "<<track->eta()<<std::endl;
353 
354  if (track->eta() > 1.479) {
355  // em_etaEpl ->Fill(muon->track().get()->p(),muon->calEnergy().em );
356  // // em_etaTpl ->Fill(muon->track().get()->p(),muon->calEnergy().em );
360  }
361  if (track->eta() <= 1.479 && track->eta() > -1.479) {
362  // em_etaB ->Fill(muon->track().get()->p(),muon->calEnergy().em );
366  }
367  if (track->eta() <= -1.479) {
368  // // em_etaTmi ->Fill(muon->track().get()->p(),muon->calEnergy().em );
369  // em_etaEmi ->Fill(muon->track().get()->p(),muon->calEnergy().em );
373  }
374 
375  // just one barrel eta region for the HO, no correction
376  // if( track->eta() < 1.4 && track->eta() > -1.4 ) { // experimenting now...
377  if (track->eta() < 1.28 && track->eta() > -1.28) {
378  // ho_etaB ->Fill(muon->track().get()->p(),muon->calEnergy().ho );
382  }
383  }
384 
385  if (42 != 42) { // check validity of input template histos and input variables"
386  pion_template_em->ls();
387  pion_template_had->ls();
388  if (pion_template_ho)
389  pion_template_ho->ls();
390  muon_template_em->ls();
391  muon_template_had->ls();
392  if (muon_template_ho)
393  muon_template_ho->ls();
394 
395  LogTrace("MuonIdentification") << "Input variables: eta p em had ho "
396  << "\n"
397  << eta << " " << p << " " << em << " " << had << " " << ho << " "
398  << "\n"
399  << "cal uncorr: em had ho "
400  << "\n"
401  << eta << " " << p << " " << amuon.calEnergy().em << " " << amuon.calEnergy().had
402  << " " << amuon.calEnergy().ho;
403  }
404 
405  // Look up Compatibility by, where x is p and y the energy.
406  // We have a set of different histograms for different regions of eta.
407 
408  // need error meassage in case the template histos are missing / the template file is not present!!! 070412
409 
410  if (pion_template_em) { // access ecal background template
412  pbx = 1.;
413  psx = 1.;
414  LogTrace("MuonIdentification") << " // Message: trying to access overflow bin in MuonCompatibility "
415  "template for ecal - defaulting signal and background ";
416  LogTrace("MuonIdentification") << " // template value to 1. " << pion_template_em->GetName()
417  << " e: " << em << " p: " << p;
418  } else
419  pbx = pion_template_em->GetBinContent(pion_template_em->GetXaxis()->FindBin(p),
420  pion_template_em->GetYaxis()->FindBin(em));
421  }
422  if (pion_template_had) { // access hcal background template
423  if (accessing_overflow(*pion_template_had, p, had)) {
424  pby = 1.;
425  psy = 1.;
426  LogTrace("MuonIdentification") << " // Message: trying to access overflow bin in MuonCompatibility "
427  "template for hcal - defaulting signal and background ";
428  LogTrace("MuonIdentification") << " // template value to 1. " << pion_template_had->GetName()
429  << " e: " << had << " p: " << p;
430  } else
431  pby = pion_template_had->GetBinContent(pion_template_had->GetXaxis()->FindBin(p),
432  pion_template_had->GetYaxis()->FindBin(had));
433  }
434  if (pion_template_ho) { // access ho background template
436  pbz = 1.;
437  psz = 1.;
438  LogTrace("MuonIdentification") << " // Message: trying to access overflow bin in MuonCompatibility "
439  "template for ho - defaulting signal and background ";
440  LogTrace("MuonIdentification") << " // template value to 1. " << pion_template_ho->GetName()
441  << " e: " << em << " p: " << p;
442  } else
443  pbz = pion_template_ho->GetBinContent(pion_template_ho->GetXaxis()->FindBin(p),
444  pion_template_ho->GetYaxis()->FindBin(ho));
445  }
446 
447  if (muon_template_em) { // access ecal background template
449  psx = 1.;
450  pbx = 1.;
451  LogTrace("MuonIdentification") << " // Message: trying to access overflow bin in MuonCompatibility "
452  "template for ecal - defaulting signal and background ";
453  LogTrace("MuonIdentification") << " // template value to 1. " << muon_template_em->GetName()
454  << " e: " << em << " p: " << p;
455  } else
456  psx = muon_template_em->GetBinContent(muon_template_em->GetXaxis()->FindBin(p),
457  muon_template_em->GetYaxis()->FindBin(em));
458  }
459  if (muon_template_had) { // access hcal background template
460  if (accessing_overflow(*muon_template_had, p, had)) {
461  psy = 1.;
462  pby = 1.;
463  LogTrace("MuonIdentification") << " // Message: trying to access overflow bin in MuonCompatibility "
464  "template for hcal - defaulting signal and background ";
465  LogTrace("MuonIdentification") << " // template value to 1. " << muon_template_had->GetName()
466  << " e: " << had << " p: " << p;
467  } else
468  psy = muon_template_had->GetBinContent(muon_template_had->GetXaxis()->FindBin(p),
469  muon_template_had->GetYaxis()->FindBin(had));
470  }
471  if (muon_template_ho) { // access ho background template
473  psz = 1.;
474  pbz = 1.;
475  LogTrace("MuonIdentification") << " // Message: trying to access overflow bin in MuonCompatibility "
476  "template for ho - defaulting signal and background ";
477  LogTrace("MuonIdentification") << " // template value to 1. " << muon_template_ho->GetName()
478  << " e: " << ho << " p: " << p;
479  } else
480  psz = muon_template_ho->GetBinContent(muon_template_ho->GetXaxis()->FindBin(p),
481  muon_template_ho->GetYaxis()->FindBin(ho));
482  }
483 
484  // erm - what is this?!?! How could the HO probability be less than 0????? Do we want this line!?!?
485  if (psz <= 0.)
486  psz = 1.;
487  if (pbz <= 0.)
488  pbz = 1.;
489 
490  // Protection agains empty bins - set cal part to neutral if the bin of the template is empty
491  // (temporary fix, a proper extrapolation would be better)
492  if (psx == 0. || pbx == 0.) {
493  psx = 1.;
494  pbx = 1.;
495  }
496  if (psy == 0. || pby == 0.) {
497  psy = 1.;
498  pby = 1.;
499  }
500  if (psz == 0. || pbz == 0.) {
501  psz = 1.;
502  pbz = 1.;
503  }
504 
505  // There are two classes of events that deliver 0 for the hcal or ho energy:
506  // 1) the track momentum is so low that the extrapolation tells us it should not have reached the cal
507  // 2) the crossed cell had an reading below the readout cuts.
508  // The 2nd case discriminates between muons and hadrons, the 1st not. Thus for the time being,
509  // we set the returned ps and pb to 0 for these cases.
510  // We need to have a return value different from 0 for the 1st case in the long run.
511  if (had == 0.0) {
512  psy = 1.;
513  pby = 1.;
514  }
515  if (ho == 0.0) {
516  psz = 1.;
517  pbz = 1.;
518  }
519 
520  // Set em to neutral if no energy in em or negative energy measured.
521  // (These cases might indicate problems in the ecal association or readout?! The only
522  // hint so far: for critical eta region (eta in [1.52, 1.64]) have negative em values.)
523  if (em <= 0. && !use_em_special) {
524  pbx = 1.;
525  psx = 1.;
526  }
527 
528  if ((psx * psy * psz + pbx * pby * pbz) > 0.)
529  muon_compatibility = psx * psy * psz / (psx * psy * psz + pbx * pby * pbz);
530  else {
531  LogTrace("MuonIdentification") << "Divide by 0 - defaulting consistency to 0.5 (neutral)!!";
532  muon_compatibility = 0.5;
533  LogTrace("MuonIdentification") << "Input variables: eta p em had ho "
534  << "\n"
535  << eta << " " << p << " " << em << " " << had << " " << ho << " "
536  << "\n"
537  << "cal uncorr: em had ho "
538  << "\n"
539  << eta << " " << p << " " << amuon.calEnergy().em << " " << amuon.calEnergy().had
540  << " " << amuon.calEnergy().ho;
541  }
542  return muon_compatibility;
543 }
std::shared_ptr< TH2D > muon_em_etaTmi
std::shared_ptr< TH2D > muon_template_em
std::shared_ptr< TH2D > muon_em_etaEmi
std::shared_ptr< TH2D > pion_ho_etaB
std::shared_ptr< TH2D > pion_had_etaEpl
std::shared_ptr< TH2D > muon_ho_etaB
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::shared_ptr< TH2D > pion_had_etaB
std::shared_ptr< TH2D > pion_em_etaEpl
TrackRef track() const override
reference to a Track
Definition: Muon.h:46
std::shared_ptr< TH2D > muon_had_etaEpl
std::shared_ptr< TH2D > muon_template_ho
std::shared_ptr< TH2D > pion_template_em
std::shared_ptr< TH2D > pion_had_etaTmi
#define LogTrace(id)
float ho
energy deposited in crossed HO towers
Definition: MuonEnergy.h:42
std::shared_ptr< TH2D > muon_template_had
std::shared_ptr< TH2D > pion_em_etaB
std::shared_ptr< TH2D > pion_em_etaTmi
std::shared_ptr< TH2D > muon_had_etaTpl
MuonEnergy calEnergy() const
get energy deposition information
Definition: Muon.h:106
TrackRef standAloneMuon() const override
reference to a stand-alone muon Track
Definition: Muon.h:49
bool isNull() const
Checks for null.
Definition: Ref.h:229
bool accessing_overflow(const TH2D &histo, double x, double y)
std::shared_ptr< TH2D > pion_template_had
std::shared_ptr< TH2D > pion_template_ho
std::shared_ptr< TH2D > muon_em_etaB
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:226
std::shared_ptr< TH2D > pion_em_etaTpl
std::shared_ptr< TH2D > pion_had_etaEmi
Log< level::Warning, false > LogWarning
std::shared_ptr< TH2D > muon_had_etaTmi
std::shared_ptr< TH2D > pion_em_etaEmi
std::shared_ptr< TH2D > muon_em_etaTpl
std::shared_ptr< TH2D > pion_had_etaTpl
std::shared_ptr< TH2D > muon_had_etaEmi
std::shared_ptr< TH2D > muon_had_etaB
std::shared_ptr< TH2D > muon_em_etaEpl

Member Data Documentation

◆ isConfigured_

bool MuonCaloCompatibility::isConfigured_
private

Definition at line 34 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ muon_compatibility

double MuonCaloCompatibility::muon_compatibility
private

Definition at line 76 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ muon_em_etaB

std::shared_ptr<TH2D> MuonCaloCompatibility::muon_em_etaB
private

Definition at line 62 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ muon_em_etaEmi

std::shared_ptr<TH2D> MuonCaloCompatibility::muon_em_etaEmi
private

Definition at line 66 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ muon_em_etaEpl

std::shared_ptr<TH2D> MuonCaloCompatibility::muon_em_etaEpl
private

Definition at line 57 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ muon_em_etaTmi

std::shared_ptr<TH2D> MuonCaloCompatibility::muon_em_etaTmi
private

Definition at line 64 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ muon_em_etaTpl

std::shared_ptr<TH2D> MuonCaloCompatibility::muon_em_etaTpl
private

Definition at line 59 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ muon_had_etaB

std::shared_ptr<TH2D> MuonCaloCompatibility::muon_had_etaB
private

Definition at line 61 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ muon_had_etaEmi

std::shared_ptr<TH2D> MuonCaloCompatibility::muon_had_etaEmi
private

Definition at line 65 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ muon_had_etaEpl

std::shared_ptr<TH2D> MuonCaloCompatibility::muon_had_etaEpl
private

Definition at line 56 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ muon_had_etaTmi

std::shared_ptr<TH2D> MuonCaloCompatibility::muon_had_etaTmi
private

Definition at line 63 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ muon_had_etaTpl

std::shared_ptr<TH2D> MuonCaloCompatibility::muon_had_etaTpl
private

Definition at line 58 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ muon_ho_etaB

std::shared_ptr<TH2D> MuonCaloCompatibility::muon_ho_etaB
private

Definition at line 60 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ muon_template_em

std::shared_ptr<TH2D> MuonCaloCompatibility::muon_template_em
private

Definition at line 40 of file MuonCaloCompatibility.h.

Referenced by evaluate().

◆ muon_template_had

std::shared_ptr<TH2D> MuonCaloCompatibility::muon_template_had
private

Definition at line 41 of file MuonCaloCompatibility.h.

Referenced by evaluate().

◆ muon_template_ho

std::shared_ptr<TH2D> MuonCaloCompatibility::muon_template_ho
private

Definition at line 42 of file MuonCaloCompatibility.h.

Referenced by evaluate().

◆ pbx

double MuonCaloCompatibility::pbx
private

Definition at line 68 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ pby

double MuonCaloCompatibility::pby
private

Definition at line 69 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ pbz

double MuonCaloCompatibility::pbz
private

Definition at line 70 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ pion_em_etaB

std::shared_ptr<TH2D> MuonCaloCompatibility::pion_em_etaB
private

Definition at line 50 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ pion_em_etaEmi

std::shared_ptr<TH2D> MuonCaloCompatibility::pion_em_etaEmi
private

Definition at line 54 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ pion_em_etaEpl

std::shared_ptr<TH2D> MuonCaloCompatibility::pion_em_etaEpl
private

Definition at line 45 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ pion_em_etaTmi

std::shared_ptr<TH2D> MuonCaloCompatibility::pion_em_etaTmi
private

Definition at line 52 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ pion_em_etaTpl

std::shared_ptr<TH2D> MuonCaloCompatibility::pion_em_etaTpl
private

Definition at line 47 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ pion_had_etaB

std::shared_ptr<TH2D> MuonCaloCompatibility::pion_had_etaB
private

Definition at line 49 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ pion_had_etaEmi

std::shared_ptr<TH2D> MuonCaloCompatibility::pion_had_etaEmi
private

Definition at line 53 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ pion_had_etaEpl

std::shared_ptr<TH2D> MuonCaloCompatibility::pion_had_etaEpl
private

Definition at line 44 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ pion_had_etaTmi

std::shared_ptr<TH2D> MuonCaloCompatibility::pion_had_etaTmi
private

Definition at line 51 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ pion_had_etaTpl

std::shared_ptr<TH2D> MuonCaloCompatibility::pion_had_etaTpl
private

Definition at line 46 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ pion_ho_etaB

std::shared_ptr<TH2D> MuonCaloCompatibility::pion_ho_etaB
private

Definition at line 48 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ pion_template_em

std::shared_ptr<TH2D> MuonCaloCompatibility::pion_template_em
private

Definition at line 37 of file MuonCaloCompatibility.h.

Referenced by evaluate().

◆ pion_template_had

std::shared_ptr<TH2D> MuonCaloCompatibility::pion_template_had
private

Definition at line 38 of file MuonCaloCompatibility.h.

Referenced by evaluate().

◆ pion_template_ho

std::shared_ptr<TH2D> MuonCaloCompatibility::pion_template_ho
private

Definition at line 39 of file MuonCaloCompatibility.h.

Referenced by evaluate().

◆ psx

double MuonCaloCompatibility::psx
private

Definition at line 72 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ psy

double MuonCaloCompatibility::psy
private

Definition at line 73 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ psz

double MuonCaloCompatibility::psz
private

Definition at line 74 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ use_corrected_hcal

bool MuonCaloCompatibility::use_corrected_hcal
private

Definition at line 78 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

◆ use_em_special

bool MuonCaloCompatibility::use_em_special
private

Definition at line 79 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().