IKinematicDumper.cxx

Go to the documentation of this file.
00001 // ================================================
00002 //IKinematicDumper class Implementation
00003 // ================================================
00004 //
00005 // THIS TEXT TO BE REPLACED BY ATLAS STANDARD FORMAT
00006 //
00007 // Namespace Atlfast::
00008 //
00009 #include "AtlfastAlgs/IKinematicDumper.h"
00010 #include "AtlfastEvent/ICluster.h"
00011 #include "AtlfastEvent/Jet.h"
00012 #include "AtlfastEvent/ITwoCptCell.h"
00013 #include "AtlfastEvent/CollectionDefs.h"
00014 #include "AtlfastEvent/ReconstructedParticle.h"
00015 #include "AtlfastUtils/FunctionObjects.h"
00016 #include "EventKernel/I4Momentum.h"
00017 #include "AtlfastAlgs/GlobalEventData.h"
00018 
00019 #include <cmath> 
00020 #include <algorithm>
00021 #include <iomanip>
00022 // Gaudi includes
00023 #include "GaudiKernel/DataSvc.h"
00024 #include <assert.h>
00025 #include <cmath>
00026 //--------------------------------
00027 // Constructors and destructors
00028 //--------------------------------
00029 
00030 namespace Atlfast {
00031   using std::cout;
00032   using std::endl;
00033   using std::ios;
00034 
00035   IKinematicDumper::IKinematicDumper
00036   ( const std::string& name, ISvcLocator* pSvcLocator ) 
00037     : Algorithm( name, pSvcLocator ){
00038     
00039     
00040     // Default paths for entities in the TES
00041     m_clusterLocation         = "/Event/AtlfastClusters";
00042     m_jetLocation             = "/Event/AtlfastJets";
00043     m_cellLocation            = "/Event/AtlfastCells";
00044     m_imuonLocation           = "/Event/AtlfastIsolatedMuons";
00045     m_nimuonLocation          = "/Event/AtlfastNonIsolatedMuons";
00046     m_ielectronLocation       = "/Event/AtlfastIsolatedElectrons";
00047     m_nielectronLocation      = "/Event/AtlfastNonIsolatedElectrons";
00048     m_iphotonLocation         = "/Event/AtlfastIsolatedPhotons";
00049     m_niphotonLocation        = "/Event/AtlfastNonIsolatedPhotons";
00050 
00051     declareProperty( "clusterLocation",     m_clusterLocation ) ;
00052     declareProperty( "jetLocation",         m_jetLocation ) ;
00053     declareProperty( "cellLocation",        m_cellLocation ) ;
00054     declareProperty( "imuonLocation",       m_imuonLocation ) ;
00055     declareProperty( "nimuonLocation",      m_nimuonLocation ) ;
00056     declareProperty( "ielectronLocation",   m_ielectronLocation ) ;
00057     declareProperty( "nielectronLocation",  m_nielectronLocation ) ;    
00058     declareProperty( "iphotonLocation",     m_iphotonLocation ) ;
00059     declareProperty( "niphotonLocation",    m_niphotonLocation ) ;
00060     
00061   }
00062   
00063   
00064   IKinematicDumper::~IKinematicDumper() {} 
00065   
00066   
00067   //---------------------------------
00068   // initialise() 
00069   //---------------------------------
00070   
00071   StatusCode IKinematicDumper::initialize()
00072   {
00073     MsgStream log( messageService(), name() ) ;
00074     log<<MSG::DEBUG<<"Initialising "<<endreq;
00075 
00076     //get the Global Event Data using singleton pattern
00077     GlobalEventData* ged = GlobalEventData::Instance();
00078     // load the location of the MC in StoreGate
00079     m_mcLocation       = ged -> mcLocation();
00080 
00081     //set up TesIO
00082     //    m_tesIO = new TesIO(eventDataService());
00083     m_tesIO = new TesIO(m_mcLocation, ged->justHardScatter());
00084     
00085     return StatusCode::SUCCESS ;
00086   }
00087   
00088   //---------------------------------
00089   // finalise() 
00090   //---------------------------------
00091   
00092   StatusCode IKinematicDumper::finalize()
00093   {
00094     // .. put any finalisation in here...
00095     
00096     return StatusCode::SUCCESS ;
00097   }
00098   
00099   
00100   //----------------------------------------------
00101   // execute() method called once per event
00102   //----------------------------------------------
00103   //
00104   
00105   StatusCode IKinematicDumper::execute( )
00106   {
00107     //................................
00108     // make a message logging stream
00109     
00110     MsgStream log( messageService(), name() ) ;
00111     log<<MSG::DEBUG<<"Executing "<<endreq;
00112     
00113 
00114     std::vector<ReconstructedParticle*>::const_iterator rp_iter;
00115 
00116     //IsolatedPhotons: read from TES and dump
00117     std::vector<ReconstructedParticle*> iphotons;
00118     m_tesIO->copy<ReconstructedParticleCollection>(iphotons, m_iphotonLocation);
00119     std::sort(iphotons.begin(), iphotons.end(), SortAttribute::AscendingEta());
00120     std::cout<<"Dumping  Isolated Photons "<<iphotons.size()<<std::endl;
00121     std::cout<<"--------------------------- "<<std::endl;    
00122     rp_iter = iphotons.begin();
00123     this->header();
00124     for(;rp_iter!=iphotons.end();++rp_iter) this->dump(*rp_iter);
00125 
00126     //NonIsolatedPhotons: read from TES and dump
00127     std::vector<ReconstructedParticle*> niphotons;
00128     m_tesIO->copy<ReconstructedParticleCollection> (niphotons, m_niphotonLocation);
00129     std::sort(niphotons.begin(), niphotons.end(), SortAttribute::AscendingEta());
00130     std::cout<<"Dumping  NonIsolated Photons "<<niphotons.size()<<std::endl;
00131     std::cout<<"------------------------------ "<<std::endl;    
00132     rp_iter = niphotons.begin();
00133     this->header();
00134     for(;rp_iter!=niphotons.end();++rp_iter) this->dump(*rp_iter);
00135     
00136     //IsolatedElectrons: read from TES and dump
00137     std::vector<ReconstructedParticle*> ielectrons;
00138     m_tesIO->copy<ReconstructedParticleCollection>(ielectrons, m_ielectronLocation);
00139     std::sort(ielectrons.begin(), ielectrons.end(), SortAttribute::AscendingEta());
00140     std::cout<<"Dumping  Isolated Electrons "<<ielectrons.size()<<std::endl;
00141     std::cout<<"--------------------------- "<<std::endl;    
00142     rp_iter = ielectrons.begin();
00143     this->header();
00144     for(;rp_iter!=ielectrons.end();++rp_iter) this->dump(*rp_iter);
00145 
00146     //NonIsolatedElectrons: read from TES and dump
00147     std::vector<ReconstructedParticle*> nielectrons;
00148     m_tesIO->copy<ReconstructedParticleCollection> (nielectrons, m_nielectronLocation);
00149     std::sort(nielectrons.begin(), nielectrons.end(), SortAttribute::AscendingEta());
00150     std::cout<<"Dumping  NonIsolated Electrons "<<nielectrons.size()<<std::endl;
00151     std::cout<<"------------------------------ "<<std::endl;    
00152     rp_iter = nielectrons.begin();
00153     this->header();
00154     for(;rp_iter!=nielectrons.end();++rp_iter) this->dump(*rp_iter);
00155     
00156 
00157 
00158     //IsolatedMuons: read from TES and dump
00159     std::vector<ReconstructedParticle*> imuons;
00160     m_tesIO->copy<ReconstructedParticleCollection>(imuons, m_imuonLocation);
00161     std::sort(imuons.begin(), imuons.end(), SortAttribute::AscendingEta());
00162     std::cout<<"Dumping  Isolated Muons "<<imuons.size()<<std::endl;
00163     std::cout<<"----------------------- "<<std::endl;    
00164     rp_iter = imuons.begin();
00165     this->header();
00166     for(;rp_iter!=imuons.end();++rp_iter) this->dump(*rp_iter);
00167 
00168 
00169     //    std::cout<<"Interface comparison "<<imuons.size()<<std::endl;
00170     //    std::cout<<"------------------- "<<std::endl;        
00171     //    for(rp_iter = imuons.begin(); rp_iter!=imuons.end(); ++rp_iter) {
00172     //      this->iki4comp(*rp_iter);
00173     //    }
00174 
00175 
00176     //NonIsolatedMuons: read from TES and dump
00177     std::vector<ReconstructedParticle*> nimuons;
00178     m_tesIO->copy<ReconstructedParticleCollection> (nimuons, m_nimuonLocation);
00179     std::sort(nimuons.begin(), nimuons.end(), SortAttribute::AscendingEta());
00180     std::cout<<"Dumping  NonIsolated Muons "<<nimuons.size()<<std::endl;
00181     std::cout<<"-------------------------- "<<std::endl;    
00182     rp_iter = nimuons.begin();
00183     this->header();
00184     for(;rp_iter!=nimuons.end();++rp_iter) this->dump(*rp_iter);
00185 
00186     //    std::cout<<"Interface comparison "<<nimuons.size()<<std::endl;
00187     //    std::cout<<"------------------- "<<std::endl;        
00188     //    for(rp_iter = nimuons.begin(); rp_iter!=nimuons.end(); ++rp_iter) {
00189     //      this->iki4comp(*rp_iter);
00190     //    }
00191 
00192     //Clusters: read from TES and dump
00193     std::vector<ICluster*> clusters;
00194     m_tesIO->copy<IClusterCollection> (clusters, m_clusterLocation);
00195     std::sort(clusters.begin(), clusters.end(), SortAttribute::AscendingEta());
00196     std::cout<<"Dumping  Clusters "<<clusters.size()<<std::endl;
00197     std::cout<<"------------------- "<<std::endl;    
00198     std::vector<ICluster*>::const_iterator cl_iter = clusters.begin();
00199     this->header();
00200     for(;cl_iter!=clusters.end();++cl_iter) this->dump(*cl_iter);
00201 
00202 
00203     //    std::cout<<"Interface comparison "<<clusters.size()<<std::endl;
00204     //    std::cout<<"------------------- "<<std::endl;        
00205     //    for(cl_iter = clusters.begin(); cl_iter!=clusters.end(); ++cl_iter) {
00206     //      this->iki4comp(*cl_iter);
00207     //    }
00208 
00209 
00210 
00211     //Jets: read from TES and dump
00212     std::vector<Jet*> jets;
00213     m_tesIO->copy<JetCollection>(jets, m_jetLocation);
00214     std::sort(jets.begin(), jets.end(), SortAttribute::AscendingEta());
00215     std::cout<<"Dumping  Jets "<<jets.size()<<std::endl;
00216     std::cout<<"------------------- "<<std::endl;    
00217     std::vector<Jet*>::const_iterator jet_iter = jets.begin();
00218     this->header();
00219     for(;jet_iter!=jets.end();++jet_iter) this->dump(*jet_iter);
00220 
00221     //    std::cout<<"Interface comparison "<<jets.size()<<std::endl;
00222     //    std::cout<<"------------------- "<<std::endl;        
00223     //    for(jet_iter = jets.begin(); jet_iter!=jets.end(); ++jet_iter) {
00224     //      this->iki4comp(*jet_iter);
00225     //    }
00226 
00227     //Cells: read from TES and dump
00228     std::vector<ITwoCptCell*> cells;
00229     m_tesIO->copy<ITwoCptCellCollection>(cells, m_cellLocation);
00230     std::sort(cells.begin(), cells.end(), SortAttribute::AscendingEta());
00231     std::cout<<"Dumping  Cells "<<cells.size()<<std::endl;
00232     std::cout<<"------------------- "<<std::endl;    
00233     std::vector<ITwoCptCell*>::const_iterator cell_iter = cells.begin();
00234     this->header();
00235     for(;cell_iter!=cells.end();++cell_iter) this->dump(*cell_iter);
00236 
00237     //    std::cout<<"Interface comparison "<<cells.size()<<std::endl;
00238     //    std::cout<<"------------------- "<<std::endl;        
00239     //    for(cell_iter = cells.begin(); cell_iter!=cells.end(); ++cell_iter) {
00240     //      this->iki4comp(*cell_iter);
00241     //    }
00242 
00243     log<<MSG::INFO<<"End of execute "<<std::endl;    
00244     return StatusCode::SUCCESS;
00245   }
00246   
00247   void IKinematicDumper::header()const{
00248     cout<<"     eta      phi       pt        e"<<endl;
00249     cout<<"-----------------------------------"<<endl;
00250   }
00251   void IKinematicDumper::dump(const IKinematic* p)const{
00252     cout<<setiosflags(ios::fixed);
00253     cout<<std::setprecision(3);
00254     cout
00255         <<std::setw(8)<<std::setprecision(3)<<p->momentum().pseudoRapidity()<<" "
00256         <<std::setw(8)<<std::setprecision(3)<<p->momentum().phi()<<" "
00257         <<std::setw(8)<<std::setprecision(3)<<p->momentum().perp()<<" "
00258         <<std::setw(8)<<std::setprecision(3)<<p->momentum().e()<<" "
00259         <<endl;
00260   }
00261 }  // end of namespace bracket

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