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 ( )
inline

Member Function Documentation

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

Definition at line 143 of file MuonCaloCompatibility.cc.

Referenced by evaluate(), and MuonCaloCompatibility().

143  {
144  bool access = false;
145 
146  if( histo.GetXaxis()->FindBin(x) == 0 ||
147  histo.GetXaxis()->FindBin(x) > histo.GetXaxis()->GetNbins() ) {
148  access = true;
149  }
150  if( histo.GetYaxis()->FindBin(y) == 0 ||
151  histo.GetYaxis()->FindBin(y) > histo.GetYaxis()->GetNbins() ) {
152  access = true;
153  }
154  return access;
155 }
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 MuonCaloCompatibility(), and MuonIdProducer::MuonIdProducer().

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

Definition at line 157 of file MuonCaloCompatibility.cc.

References accessing_overflow(), reco::Muon::calEnergy(), reco::MuonEnergy::em, stringResolutionProvider_cfi::eta, reco::TrackBase::eta(), Exception, edm::Ref< C, T, F >::get(), reco::MuonEnergy::had, photonIsolationHIProducer_cfi::ho, reco::MuonEnergy::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, NULL, AlCaHLTBitMon_ParallelJobs::p, reco::TrackBase::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::TrackBase::theta(), HiIsolationCommonParameters_cff::track, reco::Muon::track(), use_corrected_hcal, and use_em_special.

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

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

Member Data Documentation

bool MuonCaloCompatibility::isConfigured_
private

Definition at line 33 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

double MuonCaloCompatibility::muon_compatibility
private

Definition at line 75 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 61 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 65 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 56 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 63 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 58 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 60 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 64 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 55 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 62 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 57 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 59 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 39 of file MuonCaloCompatibility.h.

Referenced by evaluate().

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

Definition at line 40 of file MuonCaloCompatibility.h.

Referenced by evaluate().

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

Definition at line 41 of file MuonCaloCompatibility.h.

Referenced by evaluate().

double MuonCaloCompatibility::pbx
private

Definition at line 67 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

double MuonCaloCompatibility::pby
private

Definition at line 68 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

double MuonCaloCompatibility::pbz
private

Definition at line 69 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 49 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 53 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 44 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 51 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 46 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 48 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 52 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 43 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 50 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 45 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 47 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

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

Definition at line 36 of file MuonCaloCompatibility.h.

Referenced by evaluate().

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

Definition at line 37 of file MuonCaloCompatibility.h.

Referenced by evaluate().

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

Definition at line 38 of file MuonCaloCompatibility.h.

Referenced by evaluate().

double MuonCaloCompatibility::psx
private

Definition at line 71 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

double MuonCaloCompatibility::psy
private

Definition at line 72 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

double MuonCaloCompatibility::psz
private

Definition at line 73 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

bool MuonCaloCompatibility::use_corrected_hcal
private

Definition at line 77 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().

bool MuonCaloCompatibility::use_em_special
private

Definition at line 78 of file MuonCaloCompatibility.h.

Referenced by configure(), and evaluate().