AAN_Atlfast.cxx

Go to the documentation of this file.
00001 #include "AtlfastAlgs/AAN_Atlfast.h"
00002 
00003 #include "AtlfastAlgs/StandardNtupleMaker.h"
00004 #include "AtlfastAlgs/JetRecalibrator.h"
00005 
00006 #include "AtlfastUtils/HeaderPrinter.h"
00007 #include "AtlfastUtils/HepMC_helper/IsStatusxx.h"
00008 #include "AtlfastUtils/HepMC_helper/All.h"
00009 
00010 #include "AtlfastEvent/ReconstructedParticle.h"
00011 #include "AtlfastEvent/CollectionDefs.h"
00012 #include "AtlfastEvent/Jet.h"
00013 #include "AtlfastEvent/EventHeader.h"
00014 #include "AtlfastEvent/MCweightContainerCollection.h"
00015 #include "AtlfastAlgs/GlobalEventData.h"
00016 
00017 // CLHEP,HepMC
00018 #include "GeneratorObjects/McEventCollection.h"
00019 #include "HepMC/GenEvent.h"
00020 
00021 #include <cmath> 
00022 
00023 #include "GaudiKernel/MsgStream.h"
00024 #include "GaudiKernel/ISvcLocator.h"
00025 #include "GaudiKernel/PropertyMgr.h"
00026 
00027 #include <string>
00028 
00029 namespace Atlfast{
00030 
00031   AAN_Atlfast::AAN_Atlfast(const std::string& name, 
00032                                  ISvcLocator* pSvcLocator):
00033     CBNT_AthenaAwareBase(name,pSvcLocator),
00034     m_tesIO(0)
00035   {
00036     m_atlfastEventLocation    = "/Event/Atlfast";
00037     m_jetLocation             = "/Event/AtlfastJets";
00038     m_jetCLocation            = "/Event/AtlfastCJets";
00039     m_electronLocation        = "/Event/AtlfastIsolatedElectrons";
00040     m_electronCLocation       = "/Event/AtlfastCElectrons";
00041     m_isolatedMuonLocation    = "/Event/AtlfastIsolatedMuons";
00042     m_nonIsolatedMuonLocation = "/Event/AtlfastNonIsolatedMuons";
00043     m_muonCLocation           = "/Event/AtlfastCMuons";
00044     m_photonLocation          = "/Event/AtlfastIsolatedPhotons";
00045     m_photonCLocation         = "/Event/AtlfastCPhotons";
00046     m_mcTruthLocation         = "/Event/McEventCollection";
00047     m_bPhysicsLocation        = "/Event/AtlfastBPhysics";
00048     m_eventHeaderLocation     = "/Event/AtlfastEventHeader";
00049 
00050     m_fillIsolatedElectrons = true;
00051     m_fillAtlfastCElectrons = true;
00052     m_fillIsolatedPhotons = true;
00053     m_fillAtlfastCPhotons = true;
00054     m_fillIsolatedMuons = true;
00055     m_fillNonIsolatedMuons = true;
00056     m_fillAtlfastCMuons = true;
00057     m_fillJets = true;
00058     m_fillJetsC = true;
00059     m_fillHistory = false;
00060     m_fillEventData = true;
00061 
00062     declareProperty("AtlfastEventLocation",    m_atlfastEventLocation );
00063     declareProperty("JetLocation",             m_jetLocation );
00064     declareProperty("JetCLocation",            m_jetCLocation );
00065     declareProperty("ElectronLocation",        m_electronLocation );
00066     declareProperty("ElectronCLocation",       m_electronCLocation );
00067     declareProperty("IsolatedMuonLocation",    m_isolatedMuonLocation );
00068     declareProperty("NonIsolatedMuonLocation", m_nonIsolatedMuonLocation );
00069     declareProperty("MuonCLocation",           m_muonCLocation );
00070     declareProperty("PhotonLocation",          m_photonLocation );
00071     declareProperty("PhotonCLocation",         m_photonCLocation );
00072     declareProperty("McTruthLocation",         m_mcTruthLocation );
00073     declareProperty("BPhysicsLocation",        m_bPhysicsLocation );
00074     declareProperty("EventHeaderLocation",     m_eventHeaderLocation );
00075     declareProperty("NtupleLocID",             m_NtupleLocID);
00076     declareProperty("FillIsolatedElectrons",   m_fillIsolatedElectrons);
00077     declareProperty("FillAtlfastCElectrons",   m_fillAtlfastCElectrons);
00078     declareProperty("FillIsolatedPhotons",     m_fillIsolatedPhotons);
00079     declareProperty("FillAtlfastCPhotons",     m_fillAtlfastCPhotons);
00080     declareProperty("FillIsolatedMuons",       m_fillIsolatedMuons);
00081     declareProperty("FillNonIsolatedMuons",    m_fillNonIsolatedMuons);
00082     declareProperty("FillAtlfastCMuons",       m_fillAtlfastCMuons);
00083     declareProperty("FillJets",                m_fillJets);
00084     declareProperty("FillJetsC",               m_fillJetsC);
00085     declareProperty("FillHistory",             m_fillHistory);
00086     declareProperty("FillEventData",           m_fillEventData);
00087 
00088   }
00089 
00090   StatusCode AAN_Atlfast::CBNT_initializeBeforeEventLoop(){
00091     
00092     MsgStream log(messageService(), name());
00093     log << MSG::DEBUG << "in CBNT_initializeBeforeEventLoop() ..." << endreq;
00094 
00095     //get the Global Event Data using singleton pattern
00096     GlobalEventData* ged = GlobalEventData::Instance();
00097     // load the location of the MC in StoreGate
00098     m_mcLocation       = ged -> mcLocation();
00099     m_tesIO = new TesIO(m_mcLocation, ged->justHardScatter());
00100     
00101     HeaderPrinter hp("Atlfast Athena-Aware NtupleMaker:", log);
00102     hp.add("MC location                 ", m_mcTruthLocation);
00103     hp.add("Electron Location           ", m_electronLocation);
00104     hp.add("AtlfastC Electron Location  ", m_electronCLocation);
00105     hp.add("Photon   Location           ", m_photonLocation);
00106     hp.add("AtlfastC Photon Location    ", m_photonCLocation);
00107     hp.add("Isolated Muon Location      ", m_isolatedMuonLocation);
00108     hp.add("Non-Isolated Muon Location  ", m_nonIsolatedMuonLocation);
00109     hp.add("AtlfastC Muon Location      ", m_muonCLocation);
00110     hp.add("Jet Location                ", m_jetLocation);
00111     hp.add("AtlfastC Jet Location       ", m_jetCLocation);
00112     hp.add("EventHeaderLocation         ", m_eventHeaderLocation );
00113     hp.print();
00114     
00115     return StatusCode::SUCCESS;
00116     
00117   }
00118   
00119   StatusCode AAN_Atlfast::CBNT_initialize(){
00120 
00121     MsgStream log(messageService(), name());
00122     log << MSG::DEBUG << "in CBNT_initialize() ..." << endreq;
00123 
00124     // Electrons
00125     if(m_fillIsolatedElectrons){
00126       addBranch ("Atlf_NEle",        m_nele,      "Atlf_NEle/I");
00127       addBranch ("Atlf_KfEle",       m_codeele);
00128       addBranch ("Atlf_PxEle",       m_pxele);
00129       addBranch ("Atlf_PyEle",       m_pyele);
00130       addBranch ("Atlf_PzEle",       m_pzele);
00131       addBranch ("Atlf_EEle",        m_eeele);
00132     }
00133     // AtlfastC Electrons
00134     if(m_fillAtlfastCElectrons){
00135       addBranch ("Atlf_NEleAFC",     m_neleAFC,    "Atlf_NEleAFC/I");
00136       addBranch ("Atlf_KfEleAFC",    m_codeeleAFC);
00137       addBranch ("Atlf_PxEleAFC",    m_pxeleAFC);
00138       addBranch ("Atlf_PyEleAFC",    m_pyeleAFC);
00139       addBranch ("Atlf_PzEleAFC",    m_pzeleAFC);
00140       addBranch ("Atlf_EEleAFC",     m_eeeleAFC);
00141     }
00142     // Photons
00143     if(m_fillIsolatedPhotons){
00144       addBranch ("Atlf_NPho",        m_npho,      "Atlf_NPho/I");
00145       addBranch ("Atlf_KfPho",       m_codepho);
00146       addBranch ("Atlf_PxPho",       m_pxpho);
00147       addBranch ("Atlf_PyPho",       m_pypho);
00148       addBranch ("Atlf_PzPho",       m_pzpho);
00149       addBranch ("Atlf_EPho",        m_eepho);
00150     }
00151     //AtlfastC Photons
00152     if(m_fillAtlfastCPhotons){
00153       addBranch ("Atlf_NPhoAFC",     m_nphoAFC,    "Atlf_NPhoAFC/I");
00154       addBranch ("Atlf_KfPhoAFC",    m_codephoAFC);
00155       addBranch ("Atlf_PxPhoAFC",    m_pxphoAFC);
00156       addBranch ("Atlf_PyPhoAFC",    m_pyphoAFC);
00157       addBranch ("Atlf_PzPhoAFC",    m_pzphoAFC);
00158       addBranch ("Atlf_EPhoAFC",     m_eephoAFC);
00159     }
00160     // Muons (isolated)
00161     if(m_fillIsolatedMuons){
00162       addBranch ("Atlf_NMu",         m_nmuo,      "Atlf_NMu/I");
00163       addBranch ("Atlf_KfMu",        m_codemuo);
00164       addBranch ("Atlf_PxMu",        m_pxmuo);
00165       addBranch ("Atlf_PyMu",        m_pymuo);
00166       addBranch ("Atlf_PzMu",        m_pzmuo);
00167       addBranch ("Atlf_EMu",         m_eemuo);
00168     }
00169      // MuonsX (non-isolated)
00170     if(m_fillNonIsolatedMuons){
00171       addBranch ("Atlf_NNonIsoMu",   m_nmux,      "Atlf_NNonIsoMu/I");
00172       addBranch ("Atlf_KfNonIsoMu",  m_codemux);
00173       addBranch ("Atlf_PxNonIsoMu",  m_pxmux);
00174       addBranch ("Atlf_PyNonIsoMu",  m_pymux);
00175       addBranch ("Atlf_PzNonIsoMu",  m_pzmux);
00176       addBranch ("Atlf_ENonIsoMu",   m_eemux);
00177     }
00178     // AtlfastC Muons
00179     if(m_fillAtlfastCMuons){
00180       addBranch ("Atlf_NMuAFC",     m_nmuoAFC,    "Atlf_NMuAFC/I");
00181       addBranch ("Atlf_KfMuAFC",    m_codemuoAFC);
00182       addBranch ("Atlf_PxMuAFC",    m_pxmuoAFC);
00183       addBranch ("Atlf_PyMuAFC",    m_pymuoAFC);
00184       addBranch ("Atlf_PzMuAFC",    m_pzmuoAFC);
00185       addBranch ("Atlf_EMuAFC",     m_eemuoAFC);
00186     }
00187     // Jets
00188     if(m_fillJets){
00189       addBranch ("Atlf_NJet",        m_njet,      "Atlf_NJet/I");
00190       addBranch ("Atlf_KfJet",       m_jetlabel);
00191       addBranch ("Atlf_PxJet",       m_pxjet);
00192       addBranch ("Atlf_PyJet",       m_pyjet);
00193       addBranch ("Atlf_PzJet",       m_pzjet);
00194       addBranch ("Atlf_EJet",        m_eejet);
00195       addBranch ("Atlf_BJetdR",      m_bjetdR);
00196       addBranch ("Atlf_CJetdR",      m_cjetdR);
00197       addBranch ("Atlf_TauJetdR",    m_taujetdR);
00198       addBranch ("Atlf_PtCalo",      m_ptcalo);
00199       addBranch ("Atlf_UCorr",       m_ucorr);
00200       addBranch ("Atlf_BTag",        m_btag);
00201       addBranch ("Atlf_BCorr",       m_bcorr);
00202       addBranch ("Atlf_TauTag",      m_tautag);
00203       addBranch ("Atlf_TauCorr",     m_taucorr);
00204       addBranch ("Atlf_Tau1PTag",    m_tau1ptag);
00205       addBranch ("Atlf_Tau3PTag",    m_tau3ptag);
00206       addBranch ("Atlf_Tau1P3PCorr", m_tau1p3pcorr);
00207     }
00208     // AtlfastC Jets
00209     if(m_fillJetsC){
00210       addBranch ("Atlf_NJetAFC",        m_njetAFC,      "Atlf_NJetAFC/I");
00211       addBranch ("Atlf_KfJetAFC",       m_jetlabelAFC);
00212       addBranch ("Atlf_PxJetAFC",       m_pxjetAFC);
00213       addBranch ("Atlf_PyJetAFC",       m_pyjetAFC);
00214       addBranch ("Atlf_PzJetAFC",       m_pzjetAFC);
00215       addBranch ("Atlf_EJetAFC",        m_eejetAFC);
00216       addBranch ("Atlf_BJetdRAFC",      m_bjetdRAFC);
00217       addBranch ("Atlf_CJetdRAFC",      m_cjetdRAFC);
00218       addBranch ("Atlf_TauJetdRAFC",    m_taujetdRAFC);
00219       addBranch ("Atlf_PtCaloAFC",      m_ptcaloAFC);
00220       addBranch ("Atlf_UCorrAFC",       m_ucorrAFC);
00221       addBranch ("Atlf_BTagAFC",        m_btagAFC);
00222       addBranch ("Atlf_BCorrAFC",       m_bcorrAFC);
00223       addBranch ("Atlf_TauTagAFC",      m_tautagAFC);
00224       addBranch ("Atlf_TauCorrAFC",     m_taucorrAFC);
00225       addBranch ("Atlf_Tau1PTagAFC",    m_tau1ptagAFC);
00226       addBranch ("Atlf_Tau3PTagAFC",    m_tau3ptagAFC);
00227       addBranch ("Atlf_Tau1P3PCorrAFC", m_tau1p3pcorrAFC);
00228     }
00229     // History
00230     if(m_fillHistory){
00231       addBranch ("Atlf_NPart",       m_npart,     "Atlf_NPart/I");
00232       addBranch ("Atlf_KpPart",      m_kppart);
00233       addBranch ("Atlf_KsPart",      m_kspart);
00234       addBranch ("Atlf_KfPart",      m_kfpart);
00235       addBranch ("Atlf_KpMoth",      m_kpmoth);
00236       addBranch ("Atlf_KfMoth",      m_kfmoth);
00237       addBranch ("Atlf_PxPart",      m_pxpart);
00238       addBranch ("Atlf_PyPart",      m_pypart);
00239       addBranch ("Atlf_PzPart",      m_pzpart);
00240       addBranch ("Atlf_EPart",       m_eepart);
00241     }
00242     // Event Info
00243     if(m_fillEventData){
00244       addBranch ("Atlf_Isub",        m_isub,      "Atlf_ISUB/I");
00245       addBranch ("Atlf_JetBLabel",   m_njetb,     "Atlf_JetB/I");
00246       addBranch ("Atlf_JetCLabel",   m_njetc,     "Atlf_JetC/I");
00247       addBranch ("Atlf_JetTauLabel", m_njettau,   "Atlf_JetTAU/I");
00248       addBranch ("Atlf_PxMiss",      m_pxmiss,    "Atlf_PxMiss/F");
00249       addBranch ("Atlf_PyMiss",      m_pymiss,    "Atlf_PyMiss/F");
00250       addBranch ("Atlf_PxInvis",     m_pxnue,     "Atlf_PxInvis/F");
00251       addBranch ("Atlf_PyInvis",     m_pynue,     "Atlf_PyInvis/F") ;
00252       addBranch ("Atlf_SumET",       m_sumET,     "Atlf_SUMET/F");
00253       addBranch ("Atlf_Weight0",     m_mcWeight0, "Atlf_WEIGHT0/F");
00254       addBranch ("Atlf_Weight1",     m_mcWeight1, "Atlf_WEIGHT1/F");
00255       addBranch ("Atlf_Weight2",     m_mcWeight2, "Atlf_WEIGHT2/F");
00256     }
00257 
00258     return StatusCode::SUCCESS;
00259 
00260   }
00261 
00262   StatusCode AAN_Atlfast::CBNT_clear(){
00263 
00264     MsgStream log(messageService(), name());
00265     log << MSG::DEBUG << "in CBNT_clear() ..." << endreq;
00266 
00268     if(m_fillIsolatedElectrons){ 
00269       m_nele=0;
00270       m_codeele->clear(); m_pxele->clear(); m_pyele->clear();
00271       m_pzele->clear(); m_eeele->clear();
00272     }
00274     if(m_fillAtlfastCElectrons){
00275       m_neleAFC=0;
00276       m_codeeleAFC->clear(); m_pxeleAFC->clear(); m_pyeleAFC->clear();
00277       m_pzeleAFC->clear(); m_eeeleAFC->clear();
00278     }
00280     if(m_fillIsolatedPhotons){
00281       m_npho=0;
00282       m_codepho->clear(); m_pxpho->clear(); m_pypho->clear();
00283       m_pzpho->clear(); m_eepho->clear();
00284     }
00286     if(m_fillAtlfastCPhotons){
00287       m_nphoAFC=0;
00288       m_codephoAFC->clear(); m_pxphoAFC->clear(); m_pyphoAFC->clear();
00289       m_pzphoAFC->clear(); m_eephoAFC->clear();
00290     }
00292     if(m_fillIsolatedMuons){
00293       m_nmuo=0;
00294       m_codemuo->clear(); m_pxmuo->clear(); m_pymuo->clear();
00295       m_pzmuo->clear(); m_eemuo->clear();
00296     }
00298     if(m_fillNonIsolatedMuons){
00299       m_nmux=0;
00300       m_codemux->clear(); m_pxmux->clear(); m_pymux->clear();
00301       m_pzmux->clear(); m_eemux->clear();
00302       }
00304     if(m_fillAtlfastCMuons){
00305       m_nmuoAFC=0;
00306       m_codemuoAFC->clear(); m_pxmuoAFC->clear(); m_pymuoAFC->clear();
00307       m_pzmuoAFC->clear(); m_eemuoAFC->clear();
00308     }
00310     if(m_fillJets){
00311       m_njet=0;
00312       m_jetlabel->clear(); m_bjetdR->clear(); m_cjetdR->clear();
00313       m_taujetdR->clear(); m_pxjet->clear(); m_pyjet->clear();
00314       m_pzjet->clear(); m_eejet->clear(); m_ptcalo->clear();
00315       m_ucorr->clear(); m_btag->clear(); m_bcorr->clear();
00316       m_tautag->clear(); m_taucorr->clear(); m_tau1ptag->clear();
00317       m_tau3ptag->clear(); m_tau1p3pcorr->clear();
00318     }
00320     if(m_fillJetsC){
00321       m_njetAFC=0;
00322       m_jetlabelAFC->clear(); m_bjetdRAFC->clear(); m_cjetdRAFC->clear();
00323       m_taujetdRAFC->clear(); m_pxjetAFC->clear(); m_pyjetAFC->clear();
00324       m_pzjetAFC->clear(); m_eejetAFC->clear(); m_ptcaloAFC->clear();
00325       m_ucorrAFC->clear(); m_btagAFC->clear(); m_bcorrAFC->clear();
00326       m_tautagAFC->clear(); m_taucorrAFC->clear(); m_tau1ptagAFC->clear();
00327       m_tau3ptagAFC->clear(); m_tau1p3pcorrAFC->clear();
00328     }
00330     if(m_fillHistory){
00331       m_npart=0;
00332       m_kppart->clear(); m_kspart->clear(); m_kfpart->clear();
00333       m_kpmoth->clear(); m_kfmoth->clear(); m_pxpart->clear();
00334       m_pypart->clear(); m_pzpart->clear(); m_eepart->clear(); 
00335     }
00337     if(m_fillEventData){
00338       m_isub=0; m_njetb=0; m_njetc=0; m_njettau=0;
00339       m_pxmiss=0; m_pymiss=0; m_pxnue=0; m_pynue=0;
00340       m_sumET=0; m_mcWeight0=0; m_mcWeight1=0; m_mcWeight2=0;
00341     }
00342     
00343     return StatusCode::SUCCESS;
00344   }
00345   
00346   StatusCode AAN_Atlfast::CBNT_execute(){
00347 
00348     MsgStream log(messageService(), name());
00349 
00350     log << MSG::DEBUG << "in CBNT_execute() ..." << endreq;
00351 
00352     log << MSG::DEBUG << " -> retrieving all Atlfast stuff"<< endreq;
00353 
00354     //-------------------
00355     // Retrieve Electrons 
00356     //-------------------
00357     std::vector<ReconstructedParticle*> rp;
00358     std::vector<ReconstructedParticle*>::const_iterator irp; 
00359     if(m_fillIsolatedElectrons){
00360       if(!m_tesIO->copy<ReconstructedParticleCollection>(rp,m_electronLocation)){
00361         log <<MSG::DEBUG << "Could not find Electrons"<<endreq;
00362       }
00363       log << MSG::DEBUG << "processing Electrons: " <<rp.size()<< endreq;
00364 
00365       irp = rp.begin();
00366 
00367       m_nele = rp.size();
00368       for (; irp != rp.end(); ++irp) {
00369         m_codeele->push_back((*irp)->pdg_id());
00370         m_pxele->push_back((*irp)->momentum().px());
00371         m_pyele->push_back((*irp)->momentum().py());
00372         m_pzele->push_back((*irp)->momentum().pz());
00373         m_eeele->push_back((*irp)->momentum().e());
00374       }
00375     }else{
00376       log << MSG::DEBUG << "Isolated-Electrons switched off!" << endreq;
00377     }
00378 
00379     //-------------------
00380     // Retrieve AtlfastC Electrons
00381     //-------------------
00382     rp.clear();
00383     if(m_fillAtlfastCElectrons){
00384       if(!m_tesIO->copy<ReconstructedParticleCollection>(rp,m_electronCLocation)){
00385         log <<MSG::DEBUG << "Could not find AtlfastC Electrons"<<endreq;
00386       }
00387       log << MSG::DEBUG << "processing AtlfastC Electrons: " <<rp.size()<< endreq;
00388                                                                                                                                                                    
00389       irp = rp.begin();
00390       
00391       m_neleAFC = rp.size();
00392       for (; irp != rp.end(); ++irp) {
00393         m_codeeleAFC->push_back((*irp)->pdg_id());
00394         m_pxeleAFC->push_back((*irp)->momentum().px());
00395         m_pyeleAFC->push_back((*irp)->momentum().py());
00396         m_pzeleAFC->push_back((*irp)->momentum().pz());
00397         m_eeeleAFC->push_back((*irp)->momentum().e());
00398       }
00399     }else{
00400       log << MSG::DEBUG << "AtlfastC Electrons switched off!" << endreq;
00401     }
00402     
00403     //-------------------
00404     // Retrieve Photons 
00405     //-------------------
00406     rp.clear();
00407     if(m_fillIsolatedPhotons){
00408       if(!m_tesIO->copy <ReconstructedParticleCollection>(rp, m_photonLocation)){
00409         log <<MSG::DEBUG << "Could not find Photons"<<endreq;
00410       }
00411       log << MSG::DEBUG << "processing Photons: " <<rp.size()<< endreq;
00412 
00413       irp  = rp.begin();
00414 
00415       m_npho = rp.size();
00416       for (; irp != rp.end(); ++irp) {
00417         m_codepho->push_back((*irp)->pdg_id());
00418         m_pxpho->push_back((*irp)->momentum().px());
00419         m_pypho->push_back((*irp)->momentum().py());
00420         m_pzpho->push_back((*irp)->momentum().pz());
00421         m_eepho->push_back((*irp)->momentum().e());
00422       }
00423     }else{
00424       log << MSG::DEBUG << "Isolated-Photons switched off!" << endreq;
00425     }
00426 
00427     //-------------------
00428     // Retrieve AtlfastC Photons
00429     //-------------------
00430     rp.clear();
00431     if(m_fillAtlfastCPhotons){
00432       if(!m_tesIO->copy <ReconstructedParticleCollection>(rp, m_photonCLocation)){
00433         log <<MSG::DEBUG << "Could not find AtlfastC Photons"<<endreq;
00434       }
00435       log << MSG::DEBUG << "processing AtlfastC Photons: " <<rp.size()<< endreq;
00436       
00437       irp  = rp.begin();
00438       
00439       m_nphoAFC = rp.size();
00440       for (; irp != rp.end(); ++irp) {
00441         m_codephoAFC->push_back((*irp)->pdg_id());
00442         m_pxphoAFC->push_back((*irp)->momentum().px());
00443         m_pyphoAFC->push_back((*irp)->momentum().py());
00444         m_pzphoAFC->push_back((*irp)->momentum().pz());
00445         m_eephoAFC->push_back((*irp)->momentum().e());
00446       }
00447     }else{
00448       log << MSG::DEBUG << "AtlfastC Photons switched off!" << endreq;
00449     }
00450     
00451     //-------------------
00452     // Retrieve Isolated Muons
00453     //-------------------
00454     rp.clear();
00455     if(m_fillIsolatedMuons){
00456       if(!m_tesIO->copy
00457          <ReconstructedParticleCollection>(rp, m_isolatedMuonLocation)){
00458         log <<MSG::DEBUG << "Could not find Isolated Muons"<<endreq;
00459       }
00460       log << MSG::DEBUG << "Isolated Muons: " <<rp.size()<< endreq;
00461 
00462       irp  = rp.begin();
00463 
00464       m_nmuo = rp.size();
00465       for (; irp != rp.end(); ++irp) {
00466         m_codemuo->push_back((*irp)->pdg_id());
00467         m_pxmuo->push_back((*irp)->momentum().px());
00468         m_pymuo->push_back((*irp)->momentum().py());
00469         m_pzmuo->push_back((*irp)->momentum().pz());
00470         m_eemuo->push_back((*irp)->momentum().e());
00471       }
00472     }else{
00473       log << MSG::DEBUG << "Isolated-Muons switched off!" << endreq;
00474     }
00475 
00476     //-------------------
00477     // Retrieve NonIsolated Muons
00478     //-------------------
00479     rp.clear();
00480     if(m_fillNonIsolatedMuons){
00481       if(!m_tesIO->copy
00482          <ReconstructedParticleCollection >(rp, m_nonIsolatedMuonLocation)){
00483         log <<MSG::DEBUG << "Could not find non Isolated muons"<<endreq;
00484       }
00485       log << MSG::DEBUG << "NonIsolated Muons: " <<rp.size()<< endreq;
00486       irp  = rp.begin();
00487 
00488       m_nmux = rp.size();
00489       for (; irp != rp.end(); ++irp) {
00490         m_codemux->push_back((*irp)->pdg_id());
00491         m_pxmux->push_back((*irp)->momentum().px());
00492         m_pymux->push_back((*irp)->momentum().py());
00493         m_pzmux->push_back((*irp)->momentum().pz());
00494         m_eemux->push_back((*irp)->momentum().e());
00495       }
00496     }else{
00497       log << MSG::DEBUG << "NonIsolated-Muons switched off!" << endreq;
00498     }
00499 
00500     //-------------------
00501     // Retrieve AtlfastC Muons
00502     //-------------------
00503     rp.clear();
00504     if(m_fillAtlfastCMuons){
00505       if(!m_tesIO->copy
00506          <ReconstructedParticleCollection>(rp, m_muonCLocation)){
00507         log <<MSG::DEBUG << "Could not find AtlfastC Muons"<<endreq;
00508       }
00509       log << MSG::DEBUG << "AtlfastC Muons: " <<rp.size()<< endreq;
00510       
00511       irp  = rp.begin();
00512       
00513       m_nmuoAFC = rp.size();
00514       for (; irp != rp.end(); ++irp) {
00515         m_codemuoAFC->push_back((*irp)->pdg_id());
00516         m_pxmuoAFC->push_back((*irp)->momentum().px());
00517         m_pymuoAFC->push_back((*irp)->momentum().py());
00518         m_pzmuoAFC->push_back((*irp)->momentum().pz());
00519         m_eemuoAFC->push_back((*irp)->momentum().e());
00520       }
00521     }else{
00522       log << MSG::DEBUG << "AtlfastC Muons switched off!" << endreq;
00523     }
00524     
00525     //-------------------
00526     // Retrieve Jets
00527     //-------------------
00528     std::vector<Jet*> jv;
00529     std::vector<Jet*>::const_iterator ijv; 
00530     if(m_fillJets){
00531       if(!m_tesIO->copy<JetCollection >(jv, m_jetLocation)){
00532         log <<MSG::DEBUG << "Could not find Jets"<<endreq;
00533       }
00534       log << MSG::DEBUG << "Processing Jets: " <<jv.size()<< endreq;
00535 
00536       ijv = jv.begin();
00537 
00538       m_njet = jv.size();
00539 
00540       for (; ijv != jv.end(); ++ijv) {
00541         m_jetlabel->push_back((*ijv)->pdg_id());
00542         m_pxjet->push_back((*ijv)->px());
00543         m_pyjet->push_back((*ijv)->py());
00544         m_pzjet->push_back((*ijv)->pz());
00545         m_eejet->push_back((*ijv)->e());
00546         m_bjetdR->push_back((*ijv)->getdRbquark());
00547         m_cjetdR->push_back((*ijv)->getdRcquark());
00548         m_taujetdR->push_back((*ijv)->getdRhadtau());
00549         m_ptcalo->push_back((*ijv)->pT());
00550         m_ucorr->push_back((*ijv)->lTagCorrFactor());
00551         m_btag->push_back((*ijv)->isBTagged() ? 1. : 0.);
00552         m_bcorr->push_back((*ijv)->bTagCorrFactor());
00553         m_tautag->push_back((*ijv)->isTauTagged("Standard") ? 1. : 0.);
00554         m_taucorr->push_back((*ijv)->tauTagCorrFactor("Tau"));
00555         m_tau1ptag->push_back((*ijv)->isTauTagged("Tau1P3P:1prong") ? 1. : 0.);
00556         m_tau3ptag->push_back((*ijv)->isTauTagged("Tau1P3P:3prong") ? 1. : 0.);
00557         m_tau1p3pcorr->push_back((*ijv)->tauTagCorrFactor("Tau1P3P"));
00558       }
00559       log << MSG::DEBUG << " Jets in ntuple" << endreq;
00560     }else{
00561       log << MSG::DEBUG << "Atlfast Jets switched off!" << endreq;
00562     }
00563     
00564     //-------------------
00565     // Retrieve AtlfastC Jets
00566     //-------------------
00567     std::vector<Jet*> cjv;
00568     std::vector<Jet*>::const_iterator icjv;
00569     if(m_fillJetsC){
00570       if(!m_tesIO->copy<JetCollection >(cjv, m_jetCLocation)){
00571         log <<MSG::DEBUG << "Could not find AtlfastC Jets"<<endreq;
00572       }
00573       log << MSG::DEBUG << "Processing AtlfastC Jets: " << cjv.size()<< endreq;
00574       
00575       icjv = cjv.begin();
00576       
00577       m_njetAFC = cjv.size();
00578       
00579       for (; icjv != cjv.end(); ++icjv) {
00580         m_jetlabelAFC->push_back(-777);
00581         m_pxjetAFC->push_back((*icjv)->px());
00582         m_pyjetAFC->push_back((*icjv)->py());
00583         m_pzjetAFC->push_back((*icjv)->pz());
00584         m_eejetAFC->push_back((*icjv)->e());
00585         //m_bjetdRAFC->push_back((*icjv)->getdRbquark());
00586         //m_cjetdRAFC->push_back((*icjv)->getdRcquark());
00587         //m_taujetdRAFC->push_back((*icjv)->getdRhadtau());
00588         //m_ptcaloAFC->push_back((*icjv)->pT());
00589         //m_ucorrAFC->push_back((*icjv)->lTagCorrFactor());
00590         //m_btagAFC->push_back((*icjv)->isBTagged() ? 1. : 0.);
00591         //m_bcorrAFC->push_back((*icjv)->bTagCorrFactor());
00592         //m_tautagAFC->push_back((*icjv)->isTauTagged() ? 1. : 0.);
00593         //m_taucorrAFC->push_back((*icjv)->tauTagCorrFactor());
00594         //m_tau1ptagAFC->push_back((*icjv)->isTauTagged("Tau1P3P:1prong") ? 1. : 0.);
00595         //m_tau3ptagAFC->push_back((*icjv)->isTauTagged("Tau1P3P:3prong") ? 1. : 0.);
00596         //m_tau1p3pcorrAFC->push_back((*icjv)->tauTagCorrFactor("Tau1P3P"));
00597       }
00598       log << MSG::DEBUG << " AtlfastC Jets in ntuple" << endreq;
00599     }else{
00600       log << MSG::DEBUG << "AtlfastC Jets switched off!" << endreq;
00601     }
00602 
00603 
00604 
00605     if(m_fillHistory){
00606       MCparticleCollection mc;
00607       
00608       HepMC_helper::All* all= new HepMC_helper::All;
00609       TesIoStat stat = m_tesIO->getMC(mc, all);
00610       delete all;
00611 
00612       if(stat){
00613         log << MSG::DEBUG << " found MC truth" << endreq;
00614       }else{
00615         log << MSG::ERROR << " MC truth not found in TES" << endreq;
00616       }
00617 
00618       MCparticleCollection::const_iterator imc = mc.begin();
00619       m_npart=0;
00620       
00621       HepMC_helper::IsStatusxx isf(3);
00622 
00623       for(;imc != mc.end(); ++imc){
00624         if(isf(*imc)){
00625           m_kppart->push_back((*imc)->barcode());
00626           m_kspart->push_back((*imc)->status()%100);
00627           m_kfpart->push_back((*imc)->pdg_id());
00628           std::pair<int, int> parentCodes = getParentCodes(imc);
00629           m_kfmoth->push_back(parentCodes.first);            
00630           m_kpmoth->push_back(parentCodes.second);
00631           m_pxpart->push_back((*imc)->momentum().x());
00632           m_pypart->push_back((*imc)->momentum().y());
00633           m_pzpart->push_back((*imc)->momentum().z());
00634           m_eepart->push_back((*imc)->momentum().e());
00635           ++m_npart;
00636         }
00637       }
00638       
00639       log << MSG::DEBUG << " Particles in ntuple" << endreq;      
00640     }else{
00641       log << MSG::DEBUG << "Atlfast History switched off!" << endreq;
00642     }
00643 
00644     if(m_fillEventData){
00645       const EventHeader* theEventHeader(0);
00646       if(!(m_tesIO->getDH(theEventHeader))){
00647         log << MSG::ERROR<<"Could not find the event header in the TES"<<endreq;
00648       }
00649 
00650       if(theEventHeader){
00651         m_isub    = 0;
00652         m_njetb   = theEventHeader->nBJets();
00653         m_njetc   = theEventHeader->nCJets();
00654         m_njettau = theEventHeader->nTauJets();
00655         m_pxmiss  = theEventHeader->pMiss().x();
00656         m_pymiss  = theEventHeader->pMiss().y();
00657         m_pxnue   = theEventHeader->pEscaped().x();
00658         m_pynue   = theEventHeader->pEscaped().y();
00659         m_sumET   = theEventHeader->sumET();
00660 
00661         MCweightContainer weights = theEventHeader->firstFewWeights(3);
00662         m_mcWeight0 = weights[0];
00663         m_mcWeight1 = weights[1];
00664         m_mcWeight2 = weights[2];
00665       } else {
00666         log << MSG::ERROR << " Invalid EventHeader data handle" << endreq;
00667       }
00668 
00669       log << MSG::DEBUG << " EventHeader quantities are in ntuple" << endreq;
00670     }else{
00671       log << MSG::DEBUG << "Atlfast History switched off!" << endreq;
00672     }
00673 
00674     return StatusCode::SUCCESS;
00675 
00676   }
00677 
00678   std::pair<int, int> 
00679   AAN_Atlfast::getParentCodes(MCparticleCollection::const_iterator&  imc){
00680 
00681     HepMC::GenVertex* gv = (*imc)->production_vertex();
00682     if ( gv == 0 ){ return std::pair<int, int>(0,0);}
00683 
00684     if ( gv->particles_in_size() == 0 ) { return std::pair<int, int>(0,0); }
00685 
00686     HepMC::GenVertex::particle_iterator 
00687       pi = gv->particles_begin(HepMC::parents);
00688     if( *pi == 0 ){ return std::pair<int, int>(0,0); }
00689 
00690 
00691     return std::pair<int, int>( (*pi)->pdg_id(), (*pi)->barcode() );
00692   }
00693 
00694   StatusCode AAN_Atlfast::CBNT_finalize() {
00695     MsgStream log(messageService(), name());
00696     log << MSG::DEBUG << "in CBNT_finalize() ..." << endreq;
00697     return StatusCode::SUCCESS;
00698   }
00699 
00700 }

Generated on Mon Sep 24 14:19:11 2007 for AtlfastAlgs by  doxygen 1.5.1