Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

StandardHistogramMaker.cxx

Go to the documentation of this file.
00001 // ================================================
00002 // StandardHistogramMaker class Implementation
00003 // ================================================
00004 //
00005 // THIS TEXT TO BE REPLACED BY ATLAS STANDARD FORMAT
00006 //
00007 // Namespace ATLF::
00008 //
00009 
00010 
00011 #include "AtlfastAlgs/StandardHistogramMaker.h"
00012 #include "AtlfastEvent/ReconstructedParticle.h"
00013 #include "AtlfastEvent/CollectionDefs.h"
00014 
00015 // standard library includes
00016 #include <math.h> 
00017 
00018 // Gaudi includes
00019 #include "GaudiKernel/DataSvc.h"
00020 #include "AIDA/IHistogram1D.h"
00021 #include "GaudiKernel/IHistogramSvc.h"
00022 //htp killed for Gaudi v4
00023 //include "GaudiKernel/H1D.h"
00024 
00025 namespace Atlfast {
00026 
00027 //--------------------------------
00028 // Constructors and destructors
00029 //-------------------------------
00030 
00031 StandardHistogramMaker::StandardHistogramMaker 
00032   ( const std::string& name, ISvcLocator* pSvcLocator ) 
00033     : Algorithm( name, pSvcLocator )
00034 {
00035 
00036 
00037 
00038 
00039   // Default paths for entities in the TES
00040   m_electronLocation         = "/Event/Electrons";
00041   m_photonLocation           = "/Event/Photons";
00042   m_isolatedElectronLocation = "/Event/IsolatedElectrons";
00043   m_isolatedPhotonLocation   = "/Event/IsolatedPhotons";
00044   m_cellLocation             = "/Event/AtlfastCells";
00045   m_clusterLocation          = "/Event/Clusters";
00046   m_mcTruthLocation          = "/Event/McEventCollection";
00047 
00048 
00049   // Defaults for which sets of histograms to do
00050   m_doElectronHistograms         = true;
00051   m_doPhotonHistograms           = true;
00052   m_doIsolatedElectronHistograms = true;
00053   m_doIsolatedPhotonHistograms   = true;
00054   m_doCellHistograms             = true;
00055   m_doClusterHistograms          = true;
00056 
00057 
00058   // Default number at which to start the histograms
00059   m_histStart                    = 0;
00060 
00061   declareProperty( "ElectronLocation", m_electronLocation ) ;
00062   declareProperty( "PhotonLocation",   m_photonLocation );
00063   declareProperty( "IsolatedElectronLocation", m_isolatedElectronLocation );
00064   declareProperty( "IsolatedPhotonLocation", m_isolatedPhotonLocation );
00065   declareProperty( "CellLocation", m_cellLocation );
00066   declareProperty( "ClusterLocation", m_clusterLocation );
00067   declareProperty( "McTruthLocation", m_mcTruthLocation );
00068 
00069   declareProperty( "DoElectronHistograms",m_doElectronHistograms );
00070   declareProperty( "DoPhotonHistograms", m_doPhotonHistograms );
00071   declareProperty( "DoIsolatedElectronHistograms",m_doIsolatedElectronHistograms );
00072   declareProperty( "DoIsolatedPhotonHistograms",m_doIsolatedPhotonHistograms );
00073   declareProperty( "DoCellHistograms",m_doCellHistograms );
00074   declareProperty( "DoClusterHistograms",m_doClusterHistograms );
00075 
00076   declareProperty( "HistogramStart", m_histStart );
00077 
00078 
00079 }
00080 StandardHistogramMaker::~StandardHistogramMaker(){}
00081 
00082 //---------------------------------
00083 // initialise() 
00084 //---------------------------------
00085 
00086 StatusCode StandardHistogramMaker::initialize()
00087 {
00088   // .. put any initialisation in here...
00089   MsgStream log(messageService(), name());
00090   log << MSG::DEBUG << "in initialize()" << endreq;
00091   
00092   m_nHist = m_histStart;
00093   if ( m_doElectronHistograms ) bookElectronHistograms();
00094   if ( m_doPhotonHistograms ) bookPhotonHistograms();
00095   if ( m_doIsolatedElectronHistograms ) bookIsolatedElectronHistograms();
00096   if ( m_doIsolatedPhotonHistograms ) bookIsolatedPhotonHistograms();
00097   if ( m_doCellHistograms ) bookCellHistograms();
00098   if ( m_doClusterHistograms ) bookClusterHistograms();
00099 
00100   log << MSG::DEBUG << "Booked histograms OK" << endreq;
00101   //  m_tesIO = new TesIO(eventDataService());
00102   m_tesIO = new TesIO();
00103   return StatusCode::SUCCESS ;
00104 }
00105 
00106 
00107 
00108 //---------------------------------
00109 // finalise() 
00110 //---------------------------------
00111 
00112 StatusCode StandardHistogramMaker::finalize()
00113 {
00114   // .. put any finalisation in here...
00115   return StatusCode::SUCCESS ;
00116 }
00117 
00118 
00119 
00120 
00121 //----------------------------------------------
00122 // execute() method called once per event
00123 //----------------------------------------------
00124 
00125 StatusCode StandardHistogramMaker::execute( )
00126 {
00127 
00128   //................................
00129   // make a message logging stream
00130 
00131   MsgStream log( messageService(), name() ) ;
00132   log << MSG::DEBUG << "Executing " << endreq;
00133 
00134   if ( m_doElectronHistograms ) fillElectronHistograms();
00135   if ( m_doPhotonHistograms ) fillPhotonHistograms();
00136   if ( m_doIsolatedElectronHistograms ) fillIsolatedElectronHistograms();
00137   if ( m_doIsolatedPhotonHistograms ) fillIsolatedPhotonHistograms();
00138   if ( m_doCellHistograms ) fillCellHistograms();
00139   if ( m_doClusterHistograms ) fillClusterHistograms();
00140     
00141   return StatusCode::SUCCESS ;
00142 }
00143 
00144 
00145 
00146 
00147 void StandardHistogramMaker::bookElectronHistograms () {
00148   MsgStream log( messageService(), name() );
00149   log << MSG::DEBUG << "Booking electron histograms" << endreq;
00150 
00151   // first increment the histogram count
00152   m_nHist++;
00153   // then book the histogram
00154   m_h_electronMultiplicity = 
00155     histoSvc()->book("/stat/simple/",m_nHist,"Electron Multiplicity",20,0.0,20.0);
00156   // or be a C++ guru and do both at once
00157   m_h_electronPt = 
00158     histoSvc()->book("/stat/simple/",++m_nHist,"Electron Pt",100,0.0,1000.0);
00159 
00160   //MC truth electrons
00161   
00162 
00163   return;
00164 }
00165 
00166 
00167 
00168 void StandardHistogramMaker::bookPhotonHistograms () {
00169   MsgStream log( messageService(), name() );
00170   log << MSG::DEBUG << "Booking photon histograms" << endreq;
00171 
00172   m_h_photonMultiplicity = 
00173     histoSvc()->book("/stat/simple/",++m_nHist,"Photon Multiplicity",100,0.0,100.0);
00174   // or be a C++ guru and do both at once
00175   m_h_photonPt = 
00176     histoSvc()->book("/stat/simple/",++m_nHist,"Photon Pt",100,0.0,1000.0);
00177   return;
00178 }
00179 
00180 
00181 
00182 void StandardHistogramMaker::bookIsolatedElectronHistograms () {
00183   MsgStream log( messageService(), name() );
00184   log << MSG::DEBUG << "Booking isolated electron histograms" << endreq;
00185 
00186   m_h_isolatedElectronMultiplicity = 
00187     histoSvc()->book("/stat/simple/",++m_nHist,"Isolated Electron Multiplicity",10,0.0,10.0);
00188   // or be a C++ guru and do both at once
00189   m_h_isolatedElectronPt = 
00190     histoSvc()->book("/stat/simple/",++m_nHist,"Isolated Electron Pt",100,0.0,1000.0);
00191   return;
00192 }
00193 
00194 
00195 
00196 void StandardHistogramMaker::bookIsolatedPhotonHistograms () {
00197   MsgStream log( messageService(), name() );
00198   log << MSG::DEBUG << "Booking isolated photon histograms" << endreq;
00199 
00200   m_h_isolatedPhotonMultiplicity = 
00201     histoSvc()->book("/stat/simple/",++m_nHist,"Isolated Photon Multiplicity",20,0.0,20.0);
00202   // or be a C++ guru and do both at once
00203   m_h_isolatedPhotonPt = 
00204     histoSvc()->book("/stat/simple/",++m_nHist,"Isolated Photon Pt",100,0.0,1000.0);
00205   return;
00206 }
00207 
00208 
00209 
00210 void StandardHistogramMaker::bookCellHistograms () {
00211   MsgStream log( messageService(), name() );
00212   log << MSG::DEBUG << "Booking Cell histograms" << endreq;
00213 
00214   m_h_cellMultiplicity = 
00215     histoSvc()->book("/stat/simple/",++m_nHist,"Cell Multiplicity",200,0.0,4000.0);
00216   // or be a C++ guru and do both at once
00217   m_h_cellPt = 
00218     histoSvc()->book("/stat/simple/",++m_nHist,"Cell Pt",100,0.0,1000.0);
00219   return;
00220 }
00221 
00222 
00223 
00224 void StandardHistogramMaker::bookClusterHistograms () {
00225   MsgStream log( messageService(), name() );
00226   log << MSG::DEBUG << "Booking Cluster histograms" << endreq;
00227 
00228   m_h_clusterMultiplicity = 
00229     histoSvc()->book("/stat/simple/",++m_nHist,"Cluster Multiplicity",10,0.0,10.0);
00230   // or be a C++ guru and do both at once
00231   m_h_clusterPt = 
00232     histoSvc()->book("/stat/simple/",++m_nHist,"Cluster Pt",100,0.0,1000.0);
00233   return;
00234 }
00235 
00236 
00237 
00238 
00239 
00240 void StandardHistogramMaker::fillElectronHistograms() {
00241 
00242   MsgStream log( messageService(), name() ) ;
00243   log << MSG::DEBUG << "Fillin Electron Histograms " << endreq;
00244   std::vector<ReconstructedParticle*> amyElectrons;
00245   if(!m_tesIO->
00246      copy<ReconstructedParticleCollection >(amyElectrons, m_electronLocation)){
00247     log << MSG::DEBUG << "no electrons found in the TES. This is probably normal" << endreq; 
00248     // fill any histograms that have meaning in the absence of electrons
00249     m_h_electronMultiplicity->fill(0.0,1.0);
00250   } else {
00251     // fill all electron histograms
00252     m_h_electronMultiplicity->fill(float(amyElectrons.size()),1.0);
00253     std::vector<ReconstructedParticle*>::const_iterator iter  = amyElectrons.begin();
00254     for (; iter != amyElectrons.end(); ++iter) {
00255       m_h_electronPt->fill(float( (*iter)->pT()), 1.0);
00256     }
00257   }
00258   return;
00259 }
00260 
00261 
00262 
00263 
00264 void StandardHistogramMaker::fillPhotonHistograms() {
00265 
00266   MsgStream log( messageService(), name() ) ;
00267   log << MSG::DEBUG << "Fillins Photon Histograms " << endreq;
00268   std::vector<ReconstructedParticle*> amyPhotons;
00269   if(!m_tesIO->copy<ReconstructedParticleCollection >
00270      (amyPhotons, m_photonLocation)){
00271     log << MSG::DEBUG << "no photons found in the TES. This is probably normal" << endreq; 
00272     // fill any histograms that have meaning in the absence of photons
00273     m_h_photonMultiplicity->fill(0.0,1.0);
00274   } else {
00275     // fill all photon histograms
00276     m_h_photonMultiplicity->fill(float(amyPhotons.size()),1.0);
00277     std::vector<ReconstructedParticle*>::const_iterator iter  = amyPhotons.begin();
00278     for (; iter != amyPhotons.end(); ++iter) {
00279       m_h_photonPt->fill(float( (*iter)->pT()), 1.0);
00280     }
00281   }
00282   return;
00283 }
00284 
00285 void StandardHistogramMaker::fillIsolatedElectronHistograms() {
00286 
00287   MsgStream log( messageService(), name() ) ;
00288   log << MSG::DEBUG << "Filling Isolated Electron Histograms " << endreq;
00289   std::vector<ReconstructedParticle*> amyElectrons;
00290   if(!m_tesIO->copy<ReconstructedParticleCollection >
00291      (amyElectrons, m_isolatedElectronLocation)){
00292     log << MSG::DEBUG << "no electrons found in the TES. This is probably normal" << endreq; 
00293     // fill any histograms that have meaning in the absence of electrons
00294     m_h_isolatedElectronMultiplicity->fill(0.0,1.0);
00295   } else {
00296     // fill all electron histograms
00297     m_h_isolatedElectronMultiplicity->fill(float(amyElectrons.size()),1.0);
00298     std::vector<ReconstructedParticle*>::const_iterator iter  = amyElectrons.begin();
00299     for (; iter != amyElectrons.end(); ++iter) {
00300       m_h_isolatedElectronPt->fill(float( (*iter)->pT()), 1.0);
00301     }
00302   }
00303   return;
00304 }
00305 
00306 
00307 
00308 void StandardHistogramMaker::fillIsolatedPhotonHistograms() {
00309 
00310   MsgStream log( messageService(), name() ) ;
00311   log << MSG::DEBUG << "Filling isolated Photon Histograms " << endreq;
00312   std::vector<ReconstructedParticle*> amyPhotons;
00313   if(!m_tesIO->copy<ReconstructedParticleCollection >
00314      (amyPhotons, m_isolatedPhotonLocation)){
00315     log << MSG::DEBUG << "no photons found in the TES. This is probably normal" << endreq; 
00316     // fill any histograms that have meaning in the absence of photons
00317     m_h_isolatedPhotonMultiplicity->fill(0.0,1.0);
00318   } else {
00319     // fill all photon histograms
00320     m_h_isolatedPhotonMultiplicity->fill(float(amyPhotons.size()),1.0);
00321     std::vector<ReconstructedParticle*>::const_iterator iter  = amyPhotons.begin();
00322     for (; iter != amyPhotons.end(); ++iter) {
00323       m_h_isolatedPhotonPt->fill(float( (*iter)->pT()), 1.0);
00324     }
00325   }
00326   return;
00327 }
00328 
00329 
00330 
00331 void StandardHistogramMaker::fillCellHistograms() {
00332 
00333   MsgStream log( messageService(), name() ) ;
00334   log << MSG::DEBUG << "Filling Cell Histograms, currently empty " << endreq;
00335 
00336   return;
00337 }
00338  
00339 
00340 void StandardHistogramMaker::fillClusterHistograms() {
00341 
00342   MsgStream log( messageService(), name() ) ;
00343   log << MSG::DEBUG << "Filling Cluster Histograms, currently empty " << endreq;
00344 
00345   return;
00346 }
00347 
00348 
00349 
00350 
00351 } // end of namespace bracket
00352 
00353 
00354 
00355 
00356 
00357 
00358 
00359 
00360 
00361 
00362 
00363 
00364 
00365 
00366 
00367 
00368 
00369 

Generated on Tue Mar 18 11:18:24 2003 for AtlfastAlgs by doxygen1.3-rc1