AtlfastDumper.cxx

Go to the documentation of this file.
00001 // ================================================
00002 //AtlfastDumper class Implementation
00003 // ================================================
00004 //
00005 // Namespace Atlfast::
00006 //
00007 #include "AtlfastAlgs/AtlfastDumper.h"
00008 #include "AtlfastEvent/CollectionDefs.h"
00009 #include "AtlfastEvent/EventHeader.h"
00010 #include "AtlfastAlgs/GlobalEventData.h"
00011 
00012 #include <cmath> 
00013 #include <algorithm>
00014 #include <iomanip>
00015 // Gaudi includes
00016 #include "GaudiKernel/DataSvc.h"
00017 #include "GaudiKernel/ISvcLocator.h"
00018 
00019 #include <assert.h>
00020 #include <cmath>
00021 //--------------------------------
00022 // Constructors and destructors
00023 //--------------------------------
00024 
00025 namespace Atlfast {
00026   using std::cout;
00027   using std::endl;
00028   using std::ios;
00029 
00030   AtlfastDumper::AtlfastDumper
00031   ( const std::string& name, ISvcLocator* pSvcLocator ) 
00032     : Algorithm( name, pSvcLocator ){
00033     
00034     
00035     // Default paths for entities in the TES
00036     m_clusterLocation         = "/Event/AtlfastClusters";
00037     m_jetLocation             = "/Event/AtlfastJets";
00038     m_jetBLocation            = "/Event/AtlfastBJets";
00039     m_cellLocation            = "/Event/AtlfastCells";
00040     m_imuonLocation           = "/Event/AtlfastIsolatedMuons";
00041     m_nimuonLocation          = "/Event/AtlfastNonIsolatedMuons";
00042     m_ielectronLocation       = "/Event/AtlfastIsolatedElectrons";
00043     m_nielectronLocation      = "/Event/AtlfastNonIsolatedElectrons";
00044     m_iphotonLocation         = "/Event/AtlfastIsolatedPhotons";
00045     m_niphotonLocation        = "/Event/AtlfastNonIsolatedPhotons";
00046     m_coordinates             = "PxPyPzE";
00047 
00048     declareProperty( "clusterLocation",     m_clusterLocation ) ;
00049     declareProperty( "jetLocation",         m_jetLocation ) ;
00050     declareProperty( "jetBLocation",        m_jetBLocation ) ;
00051     declareProperty( "cellLocation",        m_cellLocation ) ;
00052     declareProperty( "imuonLocation",       m_imuonLocation ) ;
00053     declareProperty( "nimuonLocation",      m_nimuonLocation ) ;
00054     declareProperty( "ielectronLocation",   m_ielectronLocation ) ;
00055     declareProperty( "nielectronLocation",  m_nielectronLocation ) ;    
00056     declareProperty( "iphotonLocation",     m_iphotonLocation ) ;
00057     declareProperty( "niphotonLocation",    m_niphotonLocation ) ;
00058     declareProperty( "coordinates",         m_coordinates ) ;
00059     
00060     m_eventNo = 0;
00061   }
00062   
00063   
00064   AtlfastDumper::~AtlfastDumper() {} 
00065   
00066 
00067 
00068 
00069   //---------------------------------
00070   // initialise() 
00071   //---------------------------------
00072   
00073   StatusCode AtlfastDumper::initialize()
00074   {
00075     //get the Global Event Data using singleton pattern
00076     GlobalEventData* ged = GlobalEventData::Instance();
00077     // load the location of the MC in StoreGate
00078     m_mcLocation       = ged -> mcLocation();
00079 
00080 
00081     MsgStream log( messageService(), name() ) ;
00082     log<<MSG::DEBUG<<"Initialising "<<endreq;
00083     //Helper class: IO from Transient store
00084     m_tesIO = new TesIO(m_mcLocation, ged->justHardScatter()); 
00085   
00086     return StatusCode::SUCCESS ;
00087   }
00088   
00089   //---------------------------------
00090   // finalise() 
00091   //---------------------------------
00092   
00093   StatusCode AtlfastDumper::finalize()
00094   {
00095     // .. put any finalisation in here...
00096     
00097     return StatusCode::SUCCESS ;
00098   }
00099   
00100   
00101   //----------------------------------------------
00102   // execute() method called once per event
00103   //----------------------------------------------
00104   //
00105   
00106   StatusCode AtlfastDumper::execute( )
00107   {
00108     //................................
00109     // make a message logging stream
00110     
00111     MsgStream log( messageService(), name() ) ;
00112     log<<MSG::DEBUG<<"Executing "<<endreq;
00113     
00114     ++m_eventNo;
00115 
00116 
00117     std::cout<<"------------ New Event "
00118              <<std::setw(8)<<m_eventNo<<" -----------"
00119              <<std::endl<<std::endl;
00120 
00121     //IsolatedPhotons: read from TES and dump
00122     std::vector<ReconstructedParticle*> iphotons;
00123     m_tesIO->copy<ReconstructedParticleCollection>(
00124                                                    iphotons, 
00125                                                    m_iphotonLocation
00126                                                    );
00127 
00128     this->sortAndDump(iphotons.begin(), iphotons.end(), m_iphotonLocation);
00130     //
00131     // NonIsolatedPhotons: read, sort and dump
00132     //
00134     std::vector<ReconstructedParticle*> niphotons;
00135     m_tesIO->copy<ReconstructedParticleCollection> (niphotons, 
00136                                                     m_niphotonLocation
00137                                                     );
00138     this->sortAndDump(niphotons.begin(), niphotons.end(), m_niphotonLocation);
00139     
00141     //
00142     // IsolatedElectrons: read, sort and dump
00143     //
00145 
00146     std::vector<ReconstructedParticle*> ielectrons;
00147     m_tesIO->copy<ReconstructedParticleCollection>(ielectrons, 
00148                                                    m_ielectronLocation
00149                                                    );
00150     this->sortAndDump(ielectrons.begin(), 
00151                       ielectrons.end(),
00152                       m_ielectronLocation 
00153                       );
00154 
00155     
00157     //
00158     // NonIsolatedElectrons: read, sort and dump
00159     //
00161 
00162     std::vector<ReconstructedParticle*> nielectrons;
00163     m_tesIO->copy<ReconstructedParticleCollection>(nielectrons, 
00164                                                    m_nielectronLocation
00165                                                    );
00166     this->sortAndDump(nielectrons.begin(), 
00167                       nielectrons.end(),
00168                       m_nielectronLocation );
00169 
00170     
00172     //
00173     // IsolatedMuons: read, sort and dump
00174     //
00176 
00177     std::vector<ReconstructedParticle*> imuons;
00178     m_tesIO->copy<ReconstructedParticleCollection>(imuons, 
00179                                                    m_imuonLocation
00180                                                    );
00181 
00182     this->sortAndDump(imuons.begin(), imuons.end(), m_imuonLocation );
00183 
00184     
00186     //
00187     // NonIsolatedMuons: read, sort and dump
00188     //
00190 
00191     std::vector<ReconstructedParticle*> nimuons;
00192     m_tesIO->copy<ReconstructedParticleCollection>(nimuons, 
00193                                                    m_nimuonLocation
00194                                                    );
00195     this->sortAndDump(nimuons.begin(), nimuons.end(), m_nimuonLocation );
00196     
00198     //
00199     // Clusters: read, sort and dump
00200     //
00202 
00203     std::vector<ICluster*> clusters;
00204     m_tesIO->copy<IClusterCollection>(clusters, m_clusterLocation);
00205     this->sortAndDump(clusters.begin(), clusters.end(), m_clusterLocation );
00206 
00208     //
00209     // Jets: read, sort and dump
00210     //
00212 
00213     std::vector<Jet*> jets;
00214     m_tesIO->copy<JetCollection>(jets, m_jetLocation);
00215     this->sortAndDump(jets.begin(), jets.end(), m_jetLocation );
00216 
00218     //
00219     // AtlfastB Jets: read, sort and dump
00220     //
00222 
00223     std::vector<Jet*> bjets;
00224     m_tesIO->copy<JetCollection>(bjets, m_jetBLocation);
00225     this->sortAndDump(bjets.begin(), bjets.end(), m_jetBLocation );
00226 
00228     //
00229     // ITwoCptCells: read, sort and dump
00230     //
00232 
00233     std::vector<ITwoCptCell*> cells;
00234     m_tesIO->copy<ITwoCptCellCollection>(cells, m_cellLocation);
00235     this->sortAndDump(cells.begin(), cells.end(), m_cellLocation );
00236 
00238     //
00239     // EventHeader: read  and dump
00240     //
00242 
00243     const EventHeader* eventHeader(0);
00244     m_tesIO->getDH(eventHeader);
00245     this->dumpEH(eventHeader);
00246   
00247     log<<MSG::INFO<<"End of execute "<<std::endl;    
00248 
00249     return StatusCode::SUCCESS;
00250 
00251   }
00252   void AtlfastDumper::dumpEH(const EventHeader* eventHeader)const{
00253     
00254     if(!eventHeader){
00255       std::cout<<"\n\n"<<std::string(73,' ')<<"EventHeader"<<std::endl;
00256     }else{
00257       std::cout<<"\n\n"
00258                <<"b, c tau Jets:     "  
00259                <<std::setw(6)<<eventHeader->nBJets()
00260                <<std::setw(6)<<eventHeader->nCJets()
00261                <<std::setw(6)<<eventHeader->nTauJets()
00262                <<std::string(36,' ')<<"EventHeader"<<std::endl;
00263 
00264       std::cout<<std::setprecision(3);
00265       std::cout
00266         <<"px, py Miss:       "  
00267         <<std::setw(12)<<eventHeader->pMiss().x()       
00268         <<std::setw(12)<<eventHeader->pMiss().y()
00269         <<std::string(30,' ')<<"EventHeader"<<std::endl;
00270 
00271       std::cout
00272         <<"px, py Escaped:    "  
00273         <<std::setw(12)<<eventHeader->pEscaped().x()    
00274         <<std::setw(12)<<eventHeader->pEscaped().y()
00275         <<std::string(30,' ')<<"EventHeader"<<std::endl;
00276 
00277 
00278       HepMC::WeightContainer weights = eventHeader->firstFewWeights(3);
00279       std::cout
00280         <<"weight1, 2, 3:     "  
00281         <<std::setw(12)<<weights[0]
00282         <<std::setw(12)<<weights[1]
00283         <<std::setw(12)<<weights[2]
00284         <<std::string(18,' ')<<"EventHeader"<<std::endl;
00285     }
00286   }
00287 }  // end of namespace bracket

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