00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <fstream>
00011 #include <cmath>
00012 #include <string>
00013
00014 #include "AtlfastAlgs/AtlfastC.h"
00015 #include "AtlfastAlgs/GlobalEventData.h"
00016
00017
00018 #include "AtlfastEvent/Jet.h"
00019 #include "AtlfastEvent/ReconstructedParticle.h"
00020 #include "AtlfastEvent/IKinematic.h"
00021 #include "AtlfastEvent/CollectionDefs.h"
00022 #include "AtlfastEvent/Interpolator.h"
00023
00024 #include "AtlfastUtils/TesIO.h"
00025 #include "AtlfastUtils/HeaderPrinter.h"
00026
00027
00028 #include "GaudiKernel/DataSvc.h"
00029 #include "GaudiKernel/ISvcLocator.h"
00030 #include "GaudiKernel/MsgStream.h"
00031
00032
00033
00034
00035 #include "CLHEP/Random/Ranlux64Engine.h"
00036 #include "CLHEP/Random/RandFlat.h"
00037 #include "CLHEP/Units/SystemOfUnits.h"
00038
00039 #include "PathResolver/PathResolver.h"
00040
00041
00042
00043
00044
00045
00046
00047 namespace Atlfast {
00048
00049 using std::abs;
00050 AtlfastC::AtlfastC( const std::string& name, ISvcLocator* pSvcLocator )
00051 : Algorithm( name, pSvcLocator )
00052 , m_tesIO( 0 )
00053 , m_pRandomEngine( 0 )
00054 , m_pRandFlatGenerator( 0 )
00055 , m_AtlfastCJets( 0 )
00056 , m_electron_interpolator( 0 )
00057 , m_photon_interpolator( 0 )
00058 , m_muon_interpolator( 0 )
00059 , m_jet_interpolator( 0 )
00060 , m_elecphot_interpolator( 0 )
00061 , m_elecmuon_interpolator( 0 )
00062 , m_elecjet_interpolator( 0 )
00063 , m_photelec_interpolator( 0 )
00064 , m_photmuon_interpolator( 0 )
00065 , m_photjet_interpolator( 0 )
00066 , m_muonelec_interpolator( 0 )
00067 , m_muonphot_interpolator( 0 )
00068 , m_muonjet_interpolator( 0 )
00069 , m_jetelec_interpolator( 0 )
00070 , m_jetphot_interpolator( 0 )
00071 , m_jetmuon_interpolator( 0 )
00072 {
00073
00074
00075 m_ApplyElecElecEff = true;
00076 m_ApplyElecPhotEff = true;
00077 m_ApplyElecMuonEff = true;
00078 m_ApplyPhotPhotEff = true;
00079 m_ApplyPhotElecEff = true;
00080 m_ApplyPhotMuonEff = true;
00081 m_ApplyMuonPhotEff = true;
00082 m_ApplyMuonElecEff = true;
00083 m_ApplyMuonMuonEff = true;
00084 m_ApplyJetJetEff = true;
00085 m_ApplyJetPhotEff = true;
00086 m_ApplyJetElecEff = true;
00087 m_ApplyJetMuonEff = true;
00088 m_ApplyPhotJetEff = false;
00089 m_ApplyElecJetEff = false;
00090 m_ApplyMuonJetEff = false;
00091
00092
00093
00094
00095
00096
00097 m_inputeLocation = "/Event/AtlfastIsolatedElectrons";
00098 m_inputphotonLocation = "/Event/AtlfastIsolatedPhotons";
00099 m_inputmuonLocation = "/Event/AtlfastIsolatedMuons" ;
00100 m_inputjetLocation = "/Event/AtlfastJets" ;
00101
00102
00103
00104 m_outputeLocation = "/Event/AtlfastCElectrons";
00105 m_outputphotonLocation = "/Event/AtlfastCPhotons";
00106 m_outputmuonLocation = "/Event/AtlfastCMuons" ;
00107 m_outputjetLocation = "/Event/AtlfastCJets" ;
00108
00109
00110 m_elecelecEfile = "atlfastDatafiles/electron_electronEff.dat";
00111 m_elecphotEfile = "atlfastDatafiles/electron_photonEff.dat";
00112 m_elecmuonEfile = "atlfastDatafiles/electron_muid_muonEff.dat";
00113 m_elecjetEfile = "atlfastDatafiles/electron_ktjetEff.dat";
00114
00115 m_photelecEfile = "atlfastDatafiles/photon_electronEff.dat";
00116 m_photphotEfile = "atlfastDatafiles/photon_photonEff.dat";
00117 m_photmuonEfile = "atlfastDatafiles/photon_muid_muonEff.dat";
00118 m_photjetEfile = "atlfastDatafiles/photon_ktjetEff.dat";
00119
00120 m_muonelecEfile = "atlfastDatafiles/muon_electronEff.dat";
00121 m_muonphotEfile = "atlfastDatafiles/muon_photonEff.dat";
00122 m_muonmuonEfile = "atlfastDatafiles/muon_muid_muonEff.dat";
00123 m_muonjetEfile = "atlfastDatafiles/muon_ktjetEff.dat";
00124
00125 m_jetelecEfile = "atlfastDatafiles/ktjet_electronEff.dat";
00126 m_jetphotEfile = "atlfastDatafiles/ktjet_photonEff.dat";
00127 m_jetmuonEfile = "atlfastDatafiles/ktjet_muid_muonEff.dat";
00128 m_jetjetEfile = "atlfastDatafiles/ktjet_ktjetEff.dat";
00129
00130
00131
00132
00133
00134
00135 declareProperty( "InputeLocation", m_inputeLocation ) ;
00136 declareProperty( "InputphotonLocation", m_inputphotonLocation ) ;
00137 declareProperty( "InputmuonLocation", m_inputmuonLocation ) ;
00138 declareProperty( "InputjetLocation", m_inputjetLocation ) ;
00139
00140 declareProperty( "OutputeLocation", m_outputeLocation ) ;
00141 declareProperty( "OutputphotonLocation", m_outputphotonLocation ) ;
00142 declareProperty( "OutputmuonLocation", m_outputmuonLocation ) ;
00143 declareProperty( "OutputjetLocation", m_outputjetLocation ) ;
00144
00145 declareProperty( "ApplyElecElecEff", m_ApplyElecElecEff);
00146 declareProperty( "ApplyElecPhotEff", m_ApplyElecPhotEff);
00147 declareProperty( "ApplyElecMuonEff", m_ApplyElecMuonEff);
00148 declareProperty( "ApplyPhotPhotEff", m_ApplyPhotPhotEff);
00149 declareProperty( "ApplyPhotElecEff", m_ApplyPhotElecEff);
00150 declareProperty( "ApplyPhotMuonEff", m_ApplyPhotMuonEff);
00151 declareProperty( "ApplyMuonElecEff", m_ApplyMuonElecEff);
00152 declareProperty( "ApplyMuonPhotEff", m_ApplyMuonPhotEff);
00153 declareProperty( "ApplyMuonMuonEff", m_ApplyMuonMuonEff);
00154 declareProperty( "ApplyJetElecEff", m_ApplyJetElecEff);
00155 declareProperty( "ApplyJetPhotEff", m_ApplyJetPhotEff);
00156 declareProperty( "ApplyJetMuonEff", m_ApplyJetMuonEff);
00157 declareProperty( "ApplyJetJetEff", m_ApplyJetJetEff);
00158 declareProperty( "ApplyElecJetEff", m_ApplyElecJetEff);
00159 declareProperty( "ApplyPhotJetEff", m_ApplyPhotJetEff);
00160 declareProperty( "ApplyMuonJetEff", m_ApplyMuonJetEff);
00161
00162
00163
00164 declareProperty( "ElecElecFile", m_elecelecEfile);
00165 declareProperty( "ElecPhotFile", m_elecphotEfile);
00166 declareProperty( "ElecMuonFile", m_elecmuonEfile);
00167 declareProperty( "PhotElecFile", m_photelecEfile);
00168 declareProperty( "PhotPhotFile", m_photphotEfile);
00169 declareProperty( "PhotMuonFile", m_photmuonEfile);
00170 declareProperty( "MuonElecFile", m_muonelecEfile);
00171 declareProperty( "MuonPhotFile", m_muonphotEfile);
00172 declareProperty( "MuonMuonFile", m_muonmuonEfile);
00173 declareProperty( "JetElecFile", m_jetelecEfile);
00174 declareProperty( "JetPhotFile", m_jetphotEfile);
00175 declareProperty( "JetMuonFile", m_jetmuonEfile);
00176 declareProperty( "JetJetFile", m_jetjetEfile);
00177 declareProperty( "ElecJetFile", m_elecjetEfile);
00178 declareProperty( "PhotJetFile", m_photjetEfile);
00179 declareProperty( "MuonJetFile", m_muonjetEfile);
00180
00181 }
00182
00183 AtlfastC::~AtlfastC() {
00184
00185 MsgStream log( messageService(), name() ) ;
00186 log << MSG::DEBUG << "Destructor" << endreq;
00187 if( m_tesIO) {
00188 delete m_tesIO;
00189 }
00190 if( m_pRandomEngine) {
00191 delete m_pRandomEngine;
00192 }
00193 if( m_pRandFlatGenerator) {
00194 delete m_pRandFlatGenerator;
00195 }
00196
00197
00198
00199 }
00200
00201
00202
00203
00204
00205
00206
00207 StatusCode AtlfastC::initialize(){
00208 MsgStream log( messageService(), name() ) ;
00209 log << MSG::DEBUG << "instantiating an AtlfastC" << endreq;
00210
00211
00212 m_elecelecEfile = PathResolver::find_file (m_elecelecEfile, "DATAPATH");
00213 m_elecphotEfile = PathResolver::find_file (m_elecphotEfile, "DATAPATH");
00214 m_elecmuonEfile = PathResolver::find_file (m_elecmuonEfile, "DATAPATH");
00215 m_photelecEfile = PathResolver::find_file (m_photelecEfile, "DATAPATH");
00216 m_photphotEfile = PathResolver::find_file (m_photphotEfile, "DATAPATH");
00217 m_photmuonEfile = PathResolver::find_file (m_photmuonEfile, "DATAPATH");
00218 m_muonelecEfile = PathResolver::find_file (m_muonelecEfile, "DATAPATH");
00219 m_muonphotEfile = PathResolver::find_file (m_muonphotEfile, "DATAPATH");
00220 m_muonmuonEfile = PathResolver::find_file (m_muonmuonEfile, "DATAPATH");
00221 m_jetelecEfile = PathResolver::find_file (m_jetelecEfile, "DATAPATH");
00222 m_jetphotEfile = PathResolver::find_file (m_jetphotEfile, "DATAPATH");
00223 m_jetmuonEfile = PathResolver::find_file (m_jetmuonEfile, "DATAPATH");
00224 m_jetjetEfile = PathResolver::find_file (m_jetjetEfile, "DATAPATH");
00225 m_elecjetEfile = PathResolver::find_file (m_elecjetEfile, "DATAPATH");
00226 m_photjetEfile = PathResolver::find_file (m_photjetEfile, "DATAPATH");
00227 m_muonjetEfile = PathResolver::find_file (m_muonjetEfile, "DATAPATH");
00228
00229 log << MSG::DEBUG << " m_elecelecEfile after PathResolver" << m_elecelecEfile << endreq;
00230 log << MSG::DEBUG << " m_elecphotEfile after PathResolver" << m_elecphotEfile << endreq;
00231 log << MSG::DEBUG << " m_photelecEfile after PathResolver" << m_photelecEfile << endreq;
00232 log << MSG::DEBUG << " m_photphotEfile after PathResolver" << m_photphotEfile << endreq;
00233
00234 m_electron_interpolator = new Interpolator(m_elecelecEfile);
00235 m_photon_interpolator = new Interpolator(m_photphotEfile);
00236 m_muon_interpolator = new Interpolator(m_muonmuonEfile);
00237 m_jet_interpolator = new Interpolator(m_jetjetEfile);
00238 m_elecphot_interpolator = new Interpolator(m_elecphotEfile);
00239 m_elecmuon_interpolator = new Interpolator(m_elecmuonEfile);
00240 m_elecjet_interpolator = new Interpolator(m_elecjetEfile);
00241 m_photelec_interpolator = new Interpolator(m_photelecEfile);
00242 m_photmuon_interpolator = new Interpolator(m_photmuonEfile);
00243 m_photjet_interpolator = new Interpolator(m_photjetEfile);
00244 m_muonelec_interpolator = new Interpolator(m_muonelecEfile);
00245 m_muonphot_interpolator = new Interpolator(m_muonphotEfile);
00246 m_muonjet_interpolator = new Interpolator(m_muonjetEfile);
00247 m_jetelec_interpolator = new Interpolator(m_jetelecEfile);
00248 m_jetphot_interpolator = new Interpolator(m_jetphotEfile);
00249 m_jetmuon_interpolator = new Interpolator(m_jetmuonEfile);
00250
00251
00252
00253
00254 GlobalEventData* ged = GlobalEventData::Instance();
00255 int randSeed = ged->randSeed() ;
00256
00257 m_mcLocation = ged -> mcLocation();
00258
00259 m_tesIO= new TesIO(m_mcLocation, ged->justHardScatter());
00260
00261 m_pRandomEngine = new Ranlux64Engine(randSeed);
00262 m_pRandFlatGenerator=new RandFlat(*m_pRandomEngine);
00263
00264
00265 HeaderPrinter hp("AtlfastC:", log);
00266
00267 hp.add("TES Locations: ");
00268 hp.add( "Electrons from ",m_inputeLocation ) ;
00269 hp.add( "Photons from ",m_inputphotonLocation ) ;
00270 hp.add( "Muons from ",m_inputmuonLocation ) ;
00271 hp.add( "Jets from ",m_inputjetLocation ) ;
00272
00273 hp.add( "Electrons after efficiency & mis-id ",m_outputeLocation ) ;
00274 hp.add( "Photons after efficiency & mis-id ",m_outputphotonLocation ) ;
00275 hp.add( "Muons after efficiency & mis-id ",m_outputmuonLocation ) ;
00276 hp.add( "Jets after efficiency & mis-id ",m_outputjetLocation ) ;
00277
00278 hp.add( "Apply ElecElec Efficiency ", m_ApplyElecElecEff);
00279 hp.add( "Apply ElecPhot Mis id ", m_ApplyElecPhotEff);
00280 hp.add( "Apply ElecMuon Mis id ", m_ApplyElecMuonEff);
00281 hp.add( "Apply PhotPhot Efficiency ", m_ApplyPhotPhotEff);
00282 hp.add( "Apply PhotElec Mis id ", m_ApplyPhotElecEff);
00283 hp.add( "Apply PhotMuon Mis id ", m_ApplyPhotMuonEff);
00284 hp.add( "Apply MuonPhot Efficiency ", m_ApplyMuonPhotEff);
00285 hp.add( "Apply MuonElec Mis id ", m_ApplyMuonElecEff);
00286 hp.add( "Apply MuonMuon Mis id ", m_ApplyMuonMuonEff);
00287 hp.add( "Apply JetJet Efficiency ", m_ApplyJetJetEff);
00288 hp.add( "Apply JetPhot Mis id ", m_ApplyJetPhotEff);
00289 hp.add( "Apply JetElec Mis id ", m_ApplyJetElecEff);
00290 hp.add( "Apply JetMuon Mis id ", m_ApplyJetMuonEff);
00291 hp.add( "Apply PhotJet Mis id ", m_ApplyPhotJetEff);
00292 hp.add( "Apply ElecJet Mis id ", m_ApplyElecJetEff);
00293 hp.add( "Apply MuonJet Mis id ", m_ApplyMuonJetEff);
00294
00295 hp.print();
00296
00297 return StatusCode::SUCCESS ;
00298 }
00299
00300
00301
00302
00303
00304
00305 StatusCode AtlfastC::finalize(){
00306
00307 MsgStream log( messageService(), name() ) ;
00308 log << MSG::INFO << "finalizing" << endreq;
00309 return StatusCode::SUCCESS ;
00310 }
00311
00312
00313
00314
00315
00316
00317 StatusCode AtlfastC::execute(){
00318
00319
00320 StatusCode sc;
00321 MsgStream log( messageService(), name() ) ;
00322
00323 log << MSG::DEBUG<<"In execute"<<endreq;
00324 originalElectrons.clear();
00325 originalPhotons.clear();
00326 originalJets.clear();
00327 originalMuons.clear();
00328
00329 if( ! m_tesIO->copy<ReconstructedParticleCollection>( originalElectrons, m_inputeLocation ) ) {
00330 log << MSG::INFO << "No Electrons in TES " << endreq;
00331 }
00332
00333 if( ! m_tesIO->copy<ReconstructedParticleCollection>( originalPhotons, m_inputphotonLocation ) ) {
00334 log << MSG::INFO << "No Photons in TES " << endreq;
00335
00336 }
00337
00338 if( ! m_tesIO->copy<JetCollection>( originalJets, m_inputjetLocation ) ) {
00339 log << MSG::INFO << "No Jets in TES " << endreq;
00340 }
00341
00342 if( ! m_tesIO->copy<ReconstructedParticleCollection>( originalMuons, m_inputmuonLocation ) ) {
00343 log << MSG::INFO << "No Muons in TES " << endreq;
00344
00345 }
00346
00347 m_AtlfastCElectrons = new ReconstructedParticleCollection;
00348 m_AtlfastCPhotons = new ReconstructedParticleCollection;
00349 m_AtlfastCMuons = new ReconstructedParticleCollection;
00350 m_AtlfastCJets = new JetCollection;
00351
00352
00353 if(m_ApplyElecElecEff && originalElectrons.size()!=0 ){
00354 sc=ApplyEfficiency(originalElectrons,m_AtlfastCElectrons,m_electron_interpolator,11) ;
00355 if(!sc){
00356 log << MSG::ERROR<<"Error in Electron Electron Element"<<endreq;
00357 return StatusCode::FAILURE;
00358 }
00359 }
00360
00361 if(m_ApplyElecPhotEff && originalElectrons.size()!=0 ){
00362 sc=ApplyEfficiency(originalElectrons,m_AtlfastCPhotons,m_elecphot_interpolator,22) ;
00363 if(!sc){
00364 log << MSG::ERROR<<"Error in Electron Photon Element"<<endreq;
00365 return StatusCode::FAILURE;
00366 }
00367 }
00368
00369 if(m_ApplyElecMuonEff && originalElectrons.size()!=0 ){
00370 sc=ApplyEfficiency(originalElectrons,m_AtlfastCMuons,m_elecmuon_interpolator,13) ;
00371 if(!sc){
00372 log << MSG::ERROR<<"Error in Electron Muon Element"<<endreq;
00373 return StatusCode::FAILURE;
00374 }
00375 }
00376
00377 if(m_ApplyElecJetEff && originalElectrons.size()!=0 ){
00378 sc=ApplyEfficiency(originalElectrons,m_AtlfastCJets,m_elecjet_interpolator) ;
00379 if(!sc){
00380 log << MSG::ERROR<<"Error in Electron Jet Element"<<endreq;
00381 return StatusCode::FAILURE;
00382 }
00383 }
00384
00385 if(m_ApplyPhotElecEff && originalPhotons.size()!=0 ){
00386 sc=ApplyEfficiency(originalPhotons,m_AtlfastCElectrons,m_photelec_interpolator,11) ;
00387 if(!sc){
00388 log << MSG::ERROR<<"Error in Photon Electron Element"<<endreq;
00389 return StatusCode::FAILURE;
00390 }
00391 }
00392
00393 if(m_ApplyPhotPhotEff && originalPhotons.size()!=0 ){
00394 sc=ApplyEfficiency(originalPhotons,m_AtlfastCPhotons,m_photon_interpolator,22) ;
00395 if(!sc){
00396 log << MSG::ERROR<<"Error in Photon Photon Element"<<endreq;
00397 return StatusCode::FAILURE;
00398 }
00399 }
00400
00401 if(m_ApplyPhotMuonEff && originalPhotons.size()!=0 ){
00402 sc=ApplyEfficiency(originalPhotons,m_AtlfastCMuons,m_photmuon_interpolator,13) ;
00403 if(!sc){
00404 log << MSG::ERROR<<"Error in Photon Muon Element"<<endreq;
00405 return StatusCode::FAILURE;
00406 }
00407 }
00408
00409 if(m_ApplyPhotJetEff && originalPhotons.size()!=0 ){
00410 sc=ApplyEfficiency(originalPhotons,m_AtlfastCJets,m_photjet_interpolator) ;
00411 if(!sc){
00412 log << MSG::ERROR<<"Error in Photon Jet Element"<<endreq;
00413 return StatusCode::FAILURE;
00414 }
00415 }
00416
00417 if(m_ApplyMuonElecEff && originalMuons.size()!=0 ){
00418 sc=ApplyEfficiency(originalMuons,m_AtlfastCElectrons,m_muonelec_interpolator,11) ;
00419 if(!sc){
00420 log << MSG::ERROR<<"Error in Muon Electron Element"<<endreq;
00421 return StatusCode::FAILURE;
00422 }
00423 }
00424
00425 if(m_ApplyMuonPhotEff && originalMuons.size()!=0 ){
00426 sc=ApplyEfficiency(originalMuons,m_AtlfastCPhotons,m_muonphot_interpolator,22) ;
00427 if(!sc){
00428 log << MSG::ERROR<<"Error in Muon Photon Element"<<endreq;
00429 return StatusCode::FAILURE;
00430 }
00431 }
00432
00433 if(m_ApplyMuonMuonEff && originalMuons.size()!=0 ){
00434 sc=ApplyEfficiency(originalMuons,m_AtlfastCMuons,m_muon_interpolator,13) ;
00435 if(!sc){
00436 log << MSG::ERROR<<"Error in Muon Muon Element"<<endreq;
00437 return StatusCode::FAILURE;
00438 }
00439 }
00440
00441 if(m_ApplyMuonJetEff && originalMuons.size()!=0 ){
00442 sc=ApplyEfficiency(originalMuons,m_AtlfastCJets,m_muonjet_interpolator) ;
00443 if(!sc){
00444 log << MSG::ERROR<<"Error in Muon Jet Element"<<endreq;
00445 return StatusCode::FAILURE;
00446 }
00447 }
00448
00449 if(m_ApplyJetElecEff && originalJets.size()!=0 ){
00450 sc=ApplyEfficiency(originalJets,m_AtlfastCElectrons,m_jetelec_interpolator,11) ;
00451 if(!sc){
00452 log << MSG::ERROR<<"Error in Jet Electron Element"<<endreq;
00453 return StatusCode::FAILURE;
00454 }
00455 }
00456
00457 if(m_ApplyJetPhotEff && originalJets.size()!=0 ){
00458 sc=ApplyEfficiency(originalJets,m_AtlfastCPhotons,m_jetphot_interpolator,22) ;
00459 if(!sc){
00460 log << MSG::ERROR<<"Error in Jet Photon Element"<<endreq;
00461 return StatusCode::FAILURE;
00462 }
00463 }
00464
00465 if(m_ApplyJetMuonEff && originalJets.size()!=0 ){
00466 sc=ApplyEfficiency(originalJets,m_AtlfastCMuons,m_elecmuon_interpolator,13) ;
00467 if(!sc){
00468 log << MSG::ERROR<<"Error in Jet Muon Element"<<endreq;
00469 return StatusCode::FAILURE;
00470 }
00471 }
00472
00473 if(m_ApplyJetJetEff && originalJets.size()!=0 ){
00474 sc=ApplyEfficiency(originalJets,m_AtlfastCJets,m_jet_interpolator) ;
00475 if(!sc){
00476 log << MSG::ERROR<<"Error in Jet Jet Element"<<endreq;
00477 return StatusCode::FAILURE;
00478 }
00479 }
00480
00481
00482
00483 TesIoStat stat;
00484 stat = m_tesIO->store( m_AtlfastCElectrons, m_outputeLocation);
00485 if(!stat){
00486 log << MSG::ERROR << "Could not store AtlfastC electrons"<< endreq;
00487 return stat;
00488 }
00489
00490 stat = m_tesIO->store( m_AtlfastCPhotons, m_outputphotonLocation);
00491 if(!stat){
00492 log << MSG::ERROR << "Could not store AtlfastC photons"<< endreq;
00493 return stat;
00494 }
00495 stat = m_tesIO->store( m_AtlfastCMuons, m_outputmuonLocation);
00496 if(!stat){
00497 log << MSG::ERROR << "Could not store AtlfastC muons"<< endreq;
00498 return stat;
00499 }
00500 stat = m_tesIO->store( m_AtlfastCJets, m_outputjetLocation);
00501 if(!stat){
00502 log << MSG::ERROR << "Could not store AtlfastC jets"<< endreq;
00503 return stat;
00504 }
00505
00506
00507
00508 return StatusCode::SUCCESS;
00509 }
00510
00511
00512
00513
00514 StatusCode AtlfastC::ApplyEfficiency(std::vector<ReconstructedParticle*> OriginalList, ReconstructedParticleCollection* NewList, Interpolator* InterpolatorName ,int pdgidnew){
00515
00516 MsgStream log( messageService(), name() ) ;
00517
00518 log<<MSG::DEBUG<<"Applying randomized efficiency...."<<endreq;
00519
00520 for(m_it=OriginalList.begin(); m_it<OriginalList.end();++m_it){
00521
00522 log<<MSG::DEBUG<<"In the particle particle loop...."<<endreq;
00523
00524 double recopt=(*m_it)->pT();
00525 double recoeta=(*m_it)->eta();
00526
00527
00528 double randnum=m_pRandFlatGenerator->shoot(m_pRandomEngine);
00529
00530
00531 double epsilon_ij = getEfficiencyMatrixElement(recopt, recoeta, InterpolatorName );
00532
00533 if(randnum < epsilon_ij){
00534 log<<MSG::DEBUG<<"in-out: " << **m_it << endreq;
00535
00536 ReconstructedParticle* candidate = new ReconstructedParticle ( pdgidnew , (*m_it)->momentum(), (*m_it)->truth() );
00537 NewList->push_back(candidate);
00538 log<<MSG::DEBUG<<"particle put in new collection"<<endreq;
00539 }
00540 }
00541 return StatusCode::SUCCESS;
00542
00543 }
00544
00545 StatusCode AtlfastC::ApplyEfficiency(std::vector<Jet*> OriginalList, ReconstructedParticleCollection* NewList, Interpolator* InterpolatorName ,int pdgidnew){
00546
00547 MsgStream log( messageService(), name() ) ;
00548
00549 log<<MSG::DEBUG<<"Applying randomized efficiency...."<<endreq;
00550
00551 for(j_it=OriginalList.begin(); j_it<OriginalList.end();++j_it){
00552
00553 log<<MSG::DEBUG<<"In the jet particle loop...."<<endreq;
00554
00555 double recopt=(*j_it)->pT();
00556 double recoeta=(*j_it)->eta();
00557
00558
00559 double randnum=m_pRandFlatGenerator->shoot(m_pRandomEngine);
00560
00561
00562 double epsilon_ij = getEfficiencyMatrixElement(recopt, recoeta, InterpolatorName );
00563
00564 if(randnum < epsilon_ij){
00565 log<<MSG::DEBUG<<"in-out: " << **j_it << endreq;
00566
00567 HepMC::GenParticle* dummy_truth(0) ;
00568 ReconstructedParticle* candidate = new ReconstructedParticle ( pdgidnew , (*j_it)->momentum() , dummy_truth);
00569 NewList->push_back(candidate);
00570 log<<MSG::DEBUG<<"particle put in new collection"<<endreq;
00571 }
00572 }
00573 return StatusCode::SUCCESS;
00574
00575 }
00576
00577 StatusCode AtlfastC::ApplyEfficiency(std::vector<ReconstructedParticle*> OriginalList, JetCollection* NewList, Interpolator* InterpolatorName ){
00578
00579 MsgStream log( messageService(), name() ) ;
00580
00581 log<<MSG::DEBUG<<"Applying randomized efficiency...."<<endreq;
00582
00583 for(m_it=OriginalList.begin(); m_it<OriginalList.end();++m_it){
00584
00585 log<<MSG::DEBUG<<"In the particle jet loop...."<<endreq;
00586
00587 double recopt=(*m_it)->pT();
00588 double recoeta=(*m_it)->eta();
00589
00590
00591 double randnum=m_pRandFlatGenerator->shoot(m_pRandomEngine);
00592
00593
00594 double epsilon_ij = getEfficiencyMatrixElement(recopt, recoeta, InterpolatorName );
00595
00596 if(randnum < epsilon_ij){
00597 log<<MSG::DEBUG<<"in-out: " << **m_it << endreq;
00598
00599 Jet* candidate = this->createJet(*m_it);
00600 NewList->push_back(candidate);
00601
00602 log<<MSG::DEBUG<<"particle put in new collection"<<endreq;
00603 }
00604 }
00605 return StatusCode::SUCCESS;
00606
00607 }
00608
00609 StatusCode AtlfastC::ApplyEfficiency(std::vector<Jet*> OriginalList, JetCollection* NewList, Interpolator* InterpolatorName){
00610
00611 MsgStream log( messageService(), name() ) ;
00612
00613 log<<MSG::DEBUG<<"Applying randomized efficiency...."<<endreq;
00614
00615 for(j_it=OriginalList.begin(); j_it<OriginalList.end();++j_it){
00616
00617 log<<MSG::DEBUG<<"In the jet jet loop...."<<endreq;
00618
00619 double recopt=(*j_it)->pT();
00620 double recoeta=(*j_it)->eta();
00621
00622
00623 double randnum=m_pRandFlatGenerator->shoot(m_pRandomEngine);
00624
00625
00626 double epsilon_ij = getEfficiencyMatrixElement(recopt, recoeta, InterpolatorName );
00627
00628 if(randnum < epsilon_ij){
00629 log<<MSG::DEBUG<<"in-out: " << **j_it << endreq;
00630
00631
00632
00633 Jet* candidate = new Jet ( **j_it );
00634 NewList->push_back(candidate);
00635 log<<MSG::DEBUG<<"particle put in new collection"<<endreq;
00636 }
00637 }
00638 return StatusCode::SUCCESS;
00639
00640 }
00641
00642 double AtlfastC::getEfficiencyMatrixElement(double pt, double eta, Interpolator* InterpolatorName){
00643 MsgStream log( messageService(), name() ) ;
00644
00645 double Efficiency = 0;
00646
00647 deque<double> input_values;
00648 input_values.push_back(pt/GeV);
00649 input_values.push_back(fabs(eta));
00650
00651
00652 Efficiency = InterpolatorName->interpolate(input_values);
00653
00654
00655
00656 return Efficiency;
00657 }
00658
00659
00660
00661 Jet* AtlfastC::createJet(const ReconstructedParticle* rp){
00662
00663 Jet* jet = 0;
00664 MsgStream log( messageService(), name() );
00665 HepLorentzVector vec = rp->momentum();
00666
00667
00668
00669
00670 const IAOO* iaooRP = rp;
00671 TypeVisitor tv =
00672 ContainerDispatcher( iaooRP->begin(), iaooRP->end(), TypeVisitor() );
00673
00674
00675 std::vector<const Cluster*> cv = tv.typeVector(Cluster());
00676 log << MSG::INFO << "TypeVisitor found " << cv.size()
00677 << " Clusters in this ReconstructedParticle" << endreq;
00678
00679 if ( cv.size() == 1 ){
00680 Cluster* ic = const_cast<Cluster*>(cv[0]);
00681 jet = new Jet(vec, *ic);
00682 log << MSG::INFO << "Unsmeared Cluster: " << *ic << endreq;
00683 log << MSG::INFO << "Smeared Jet : " << jet << endreq ;
00684 }
00685
00686 return jet;
00687
00688 }
00689
00690
00691
00692 }
00693