Definition at line 89 of file MuonCaloCompatibility.cc.
References accessing_overflow(), reco::Muon::calEnergy(), em, eta, reco::TrackBase::eta(), Exception, isConfigured_, 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, reco::TrackBase::p(), 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(), reco::Muon::track(), track, use_corrected_hcal, and use_em_special.
Referenced by CaloMuonProducer::makeMuon(), and MuonIdProducer::produce().
00089 {
00090 if (! isConfigured_) {
00091 edm::LogWarning("MuonIdentification") << "MuonCaloCompatibility is not configured! Nothing is calculated.";
00092 return -9999;
00093 }
00094
00095 double eta = 0.;
00096 double p = 0.;
00097 double em = 0.;
00098 double had = 0.;
00099 double ho = 0.;
00100
00101
00102 pbx = 1.;
00103 pby = 1.;
00104 pbz = 1.;
00105
00106 psx = 1.;
00107 psy = 1.;
00108 psz = 1.;
00109
00110 muon_compatibility = -1.;
00111
00112 pion_template_em = NULL;
00113 muon_template_em = NULL;
00114
00115 pion_template_had = NULL;
00116 muon_template_had = NULL;
00117
00118 pion_template_ho = NULL;
00119 muon_template_ho = NULL;
00120
00121
00122
00123
00124
00125 const reco::Track* track = 0;
00126 if ( ! amuon.track().isNull() ) {
00127 track = amuon.track().get();
00128 }
00129 else {
00130 if ( ! amuon.standAloneMuon().isNull() ) {
00131 track = amuon.standAloneMuon().get();
00132 }
00133 else {
00134 throw cms::Exception("FatalError") << "Failed to fill muon id calo_compatibility information for a muon with undefined references to tracks";
00135 }
00136 }
00137
00138 if( !use_corrected_hcal ) {
00139 eta = track->eta();
00140 p = track->p();
00141
00142
00143
00144
00145
00146 if( p>=2000. ) p = 1999.9;
00147
00148
00149 if( use_em_special ) {
00150 if( amuon.calEnergy().em == 0. ) em = -5.;
00151 else em = amuon.calEnergy().em;
00152 }
00153 else {
00154 em = amuon.calEnergy().em;
00155 }
00156 had = amuon.calEnergy().had;
00157 ho = amuon.calEnergy().ho;
00158 }
00159 else {
00160 eta = track->eta();
00161 p = track->p();
00162
00163
00164
00165
00166
00167 if( p>=2000. ) p = 1999.9;
00168
00169
00170
00171
00172 if( use_em_special ) {
00173 if( amuon.calEnergy().em == 0. ) em = -5.;
00174 else em = amuon.calEnergy().em;
00175 }
00176 else {
00177 em = amuon.calEnergy().em;
00178 }
00179 ho = amuon.calEnergy().ho;
00180 }
00181
00182
00183
00184
00185 if( p < 0. ) return 0.5;
00186 if( fabs(eta) > 2.5 ) return 0.5;
00187
00188
00189
00190
00191
00192 if(42 != 42) {
00193 if(eta <= -1.4) {
00194
00195 pion_template_em = pion_em_etaEmi;
00196 pion_template_had = pion_had_etaEmi;
00197 muon_template_em = muon_em_etaEmi;
00198 muon_template_had = muon_had_etaEmi;
00199 }
00200 else if(eta > -1.4 && eta <= -1.31) {
00201
00202 pion_template_em = pion_em_etaTmi;
00203 pion_template_had = pion_had_etaTmi;
00204 muon_template_em = muon_em_etaTmi;
00205 muon_template_had = muon_had_etaTmi;
00206 }
00207 else if(eta > -1.31 && eta <= 1.31) {
00208
00209 pion_template_em = pion_em_etaB;
00210 pion_template_had = pion_had_etaB;
00211 pion_template_ho = pion_ho_etaB;
00212 muon_template_em = muon_em_etaB;
00213 muon_template_had = muon_had_etaB;
00214 muon_template_ho = muon_ho_etaB;
00215 }
00216 else if(eta > 1.31 && eta <= 1.4) {
00217
00218 pion_template_em = pion_em_etaTpl;
00219 pion_template_had = pion_had_etaTpl;
00220 muon_template_em = muon_em_etaTpl;
00221 muon_template_had = muon_had_etaTpl;
00222 }
00223 else if(eta > 1.4) {
00224
00225 pion_template_em = pion_em_etaEpl;
00226 pion_template_had = pion_had_etaEpl;
00227 muon_template_em = muon_em_etaEpl;
00228 muon_template_had = muon_had_etaEpl;
00229 }
00230 else {
00231 LogTrace("MuonIdentification")<<"Some very weird thing happened in MuonCaloCompatibility::evaluate - go figure ;) ";
00232 return -999;
00233 }
00234 }
00235 else if( 42 == 42 ) {
00236 if( track->eta() > 1.27 ) {
00237
00238 if(use_corrected_hcal) had = 1.8/2.2*amuon.calEnergy().had;
00239 else had = amuon.calEnergy().had;
00240 pion_template_had = pion_had_etaEpl;
00241 muon_template_had = muon_had_etaEpl;
00242 }
00243 if( track->eta() <= 1.27 && track->eta() > 1.1 ) {
00244
00245 if(use_corrected_hcal) had = (1.8/(-2.2*track->eta()+5.5))*amuon.calEnergy().had;
00246 else had = amuon.calEnergy().had;
00247 pion_template_had = pion_had_etaTpl;
00248 muon_template_had = muon_had_etaTpl;
00249 }
00250 if( track->eta() <= 1.1 && track->eta() > -1.1 ) {
00251
00252 if(use_corrected_hcal) had = sin(track->theta())*amuon.calEnergy().had;
00253 else had = amuon.calEnergy().had;
00254 pion_template_had = pion_had_etaB;
00255 muon_template_had = muon_had_etaB;
00256 }
00257 if( track->eta() <= -1.1 && track->eta() > -1.27 ) {
00258
00259 if(use_corrected_hcal) had = (1.8/(2.2*track->eta()+5.5))*amuon.calEnergy().had;
00260 else had = amuon.calEnergy().had;
00261 pion_template_had = pion_had_etaTmi;
00262 muon_template_had = muon_had_etaTmi;
00263 }
00264 if( track->eta() <= -1.27 ) {
00265
00266 if(use_corrected_hcal) had = 1.8/2.2*amuon.calEnergy().had;
00267 else had = amuon.calEnergy().had;
00268 pion_template_had = pion_had_etaEmi;
00269 muon_template_had = muon_had_etaEmi;
00270 }
00271
00272
00273
00274
00275
00276 if( track->eta() > 1.479 ) {
00277
00278
00280 pion_template_em = pion_em_etaEpl;
00281 muon_template_em = muon_em_etaEpl;
00282 }
00283 if( track->eta() <= 1.479 && track->eta() > -1.479 ) {
00284
00286 pion_template_em = pion_em_etaB;
00287 muon_template_em = muon_em_etaB;
00288 }
00289 if( track->eta() <= -1.479 ) {
00290
00291
00293 pion_template_em = pion_em_etaEmi;
00294 muon_template_em = muon_em_etaEmi;
00295 }
00296
00297
00298
00299 if( track->eta() < 1.28 && track->eta() > -1.28 ) {
00300
00302 pion_template_ho = pion_ho_etaB;
00303 muon_template_ho = muon_ho_etaB;
00304 }
00305
00306
00307 }
00308
00309
00310 if( 42 != 42 ) {
00311 pion_template_em ->ls();
00312 pion_template_had->ls();
00313 if(pion_template_ho) pion_template_ho ->ls();
00314 muon_template_em ->ls();
00315 muon_template_had->ls();
00316 if(muon_template_ho) muon_template_ho ->ls();
00317
00318 LogTrace("MuonIdentification")<<"Input variables: eta p em had ho "<<"\n"
00319 <<eta<<" "<<p<<" "<<em<<" "<<had<<" "<<ho<<" "<<"\n"
00320 <<"cal uncorr: em had ho "<<"\n"
00321 <<eta<<" "<<p<<" "<<amuon.calEnergy().em<<" "<<amuon.calEnergy().had<<" "<<amuon.calEnergy().ho;
00322 }
00323
00324
00325
00326
00327
00328
00329
00330 if( pion_template_em ) {
00331 if( accessing_overflow( pion_template_em, p, em ) ) {
00332 pbx = 1.;
00333 psx = 1.;
00334 LogTrace("MuonIdentification")<<" // Message: trying to access overflow bin in MuonCompatibility template for ecal - defaulting signal and background ";
00335 LogTrace("MuonIdentification")<<" // template value to 1. "<<pion_template_em->GetName()<<" e: "<<em<<" p: "<<p;
00336 }
00337 else pbx = pion_template_em->GetBinContent( pion_template_em->GetXaxis()->FindBin(p), pion_template_em->GetYaxis()->FindBin(em) );
00338 }
00339 if( pion_template_had ) {
00340 if( accessing_overflow( pion_template_had, p, had ) ) {
00341 pby = 1.;
00342 psy = 1.;
00343 LogTrace("MuonIdentification")<<" // Message: trying to access overflow bin in MuonCompatibility template for hcal - defaulting signal and background ";
00344 LogTrace("MuonIdentification")<<" // template value to 1. "<<pion_template_had->GetName()<<" e: "<<had<<" p: "<<p;
00345 }
00346 else pby = pion_template_had->GetBinContent( pion_template_had->GetXaxis()->FindBin(p), pion_template_had->GetYaxis()->FindBin(had) );
00347 }
00348 if(pion_template_ho) {
00349 if( accessing_overflow( pion_template_ho, p, ho ) ) {
00350 pbz = 1.;
00351 psz = 1.;
00352 LogTrace("MuonIdentification")<<" // Message: trying to access overflow bin in MuonCompatibility template for ho - defaulting signal and background ";
00353 LogTrace("MuonIdentification")<<" // template value to 1. "<<pion_template_ho->GetName()<<" e: "<<em<<" p: "<<p;
00354 }
00355 else pbz = pion_template_ho->GetBinContent( pion_template_ho->GetXaxis()->FindBin(p), pion_template_ho->GetYaxis()->FindBin(ho) );
00356 }
00357
00358
00359 if( muon_template_em ) {
00360 if( accessing_overflow( muon_template_em, p, em ) ) {
00361 psx = 1.;
00362 pbx = 1.;
00363 LogTrace("MuonIdentification")<<" // Message: trying to access overflow bin in MuonCompatibility template for ecal - defaulting signal and background ";
00364 LogTrace("MuonIdentification")<<" // template value to 1. "<<muon_template_em->GetName()<<" e: "<<em<<" p: "<<p;
00365 }
00366 else psx = muon_template_em->GetBinContent( muon_template_em->GetXaxis()->FindBin(p), muon_template_em->GetYaxis()->FindBin(em) );
00367 }
00368 if( muon_template_had ) {
00369 if( accessing_overflow( muon_template_had, p, had ) ) {
00370 psy = 1.;
00371 pby = 1.;
00372 LogTrace("MuonIdentification")<<" // Message: trying to access overflow bin in MuonCompatibility template for hcal - defaulting signal and background ";
00373 LogTrace("MuonIdentification")<<" // template value to 1. "<<muon_template_had->GetName()<<" e: "<<had<<" p: "<<p;
00374 }
00375 else psy = muon_template_had->GetBinContent( muon_template_had->GetXaxis()->FindBin(p), muon_template_had->GetYaxis()->FindBin(had) );
00376 }
00377 if(muon_template_ho) {
00378 if( accessing_overflow( muon_template_ho, p, ho ) ) {
00379 psz = 1.;
00380 pbz = 1.;
00381 LogTrace("MuonIdentification")<<" // Message: trying to access overflow bin in MuonCompatibility template for ho - defaulting signal and background ";
00382 LogTrace("MuonIdentification")<<" // template value to 1. "<<muon_template_ho->GetName()<<" e: "<<ho<<" p: "<<p;
00383 }
00384 else psz = muon_template_ho->GetBinContent( muon_template_ho->GetXaxis()->FindBin(p), muon_template_ho->GetYaxis()->FindBin(ho) );
00385 }
00386
00387
00388 if(psz <= 0.) psz = 1.;
00389 if(pbz <= 0.) pbz = 1.;
00390
00391
00392
00393 if (psx == 0. || pbx == 0.) {
00394 psx = 1.;
00395 pbx = 1.;
00396 }
00397 if (psy == 0. || pby == 0.) {
00398 psy = 1.;
00399 pby = 1.;
00400 }
00401 if (psz == 0. || pbz == 0.) {
00402 psz = 1.;
00403 pbz = 1.;
00404 }
00405
00406
00407
00408
00409
00410
00411
00412 if ( had == 0.0 ) {
00413 psy = 1.;
00414 pby = 1.;
00415 }
00416 if ( ho == 0.0 ) {
00417 psz = 1.;
00418 pbz = 1.;
00419 }
00420
00421
00422
00423
00424
00425 if( em <= 0. && !use_em_special ) {
00426 pbx = 1.;
00427 psx = 1.;
00428 }
00429
00430 if( (psx*psy*psz+pbx*pby*pbz) > 0. ) muon_compatibility = psx*psy*psz / (psx*psy*psz+pbx*pby*pbz);
00431 else {
00432 LogTrace("MuonIdentification")<<"Divide by 0 - defaulting consistency to 0.5 (neutral)!!";
00433 muon_compatibility = 0.5;
00434 LogTrace("MuonIdentification")<<"Input variables: eta p em had ho "<<"\n"
00435 <<eta<<" "<<p<<" "<<em<<" "<<had<<" "<<ho<<" "<<"\n"
00436 <<"cal uncorr: em had ho "<<"\n"
00437 <<eta<<" "<<p<<" "<<amuon.calEnergy().em<<" "<<amuon.calEnergy().had<<" "<<amuon.calEnergy().ho;
00438 }
00439 return muon_compatibility;
00440 }