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 #include "AtlfastAlgs/StandardHistogramMaker.h"
00011 #include "AtlfastAlgs/GlobalEventData.h"
00012 #include "AtlfastEvent/ReconstructedParticle.h"
00013 #include "AtlfastEvent/CollectionDefs.h"
00014 #include "AtlfastEvent/EventHeader.h"
00015 // standard library includes
00016 #include <math.h> 
00017 
00018 // Gaudi includes
00019 #include "GaudiKernel/DataSvc.h"
00020 #include "GaudiKernel/IHistogramSvc.h"
00021 
00022 namespace Atlfast {
00023 
00024 //--------------------------------
00025 // Constructors and destructors
00026 //-------------------------------
00027 
00028 StandardHistogramMaker::StandardHistogramMaker 
00029   ( const std::string& name, ISvcLocator* pSvcLocator ) 
00030     : Algorithm( name, pSvcLocator )
00031 {
00032 
00033 
00034 
00035 
00036   // Default paths for entities in the TES
00037   m_electronLocation         = "/Event/AtlfastElectrons";
00038   m_photonLocation           = "/Event/AtlfastPhotons";
00039   m_muonLocation             = "/Event/AtlfastNonIsolatedMuons";
00040   m_isolatedElectronLocation = "/Event/AtlfastIsolatedElectrons";
00041   m_isolatedPhotonLocation   = "/Event/AtlfastIsolatedPhotons";
00042   m_isolatedMuonLocation     = "/Event/AtlfastIsolatedMuons";
00043   m_cellLocation             = "/Event/AtlfastCells";
00044   m_clusterLocation          = "/Event/AtlfastClusters";
00045   m_jetLocation              = "/Event/AtlfastJets";
00046   m_eventHeaderLocation      = "/Event/AtlfastEventHeader";
00047   m_mcTruthLocation          = "/Event/McEventCollection";
00048 
00049 
00050   // Default number at which to start the histograms
00051   m_histStart                    = 0;
00052 
00053   declareProperty( "ElectronLocation",         m_electronLocation ) ;
00054   declareProperty( "PhotonLocation",           m_photonLocation );
00055   declareProperty( "MuonLocation",             m_muonLocation );
00056   declareProperty( "IsolatedElectronLocation", m_isolatedElectronLocation );
00057   declareProperty( "IsolatedPhotonLocation",   m_isolatedPhotonLocation );
00058   declareProperty( "IsolatedMuonLocation",     m_isolatedMuonLocation );
00059   declareProperty( "CellLocation",             m_cellLocation );
00060   declareProperty( "ClusterLocation",          m_clusterLocation );
00061   declareProperty( "JetLocation",              m_jetLocation );
00062   declareProperty( "EventHeaderLocation",      m_eventHeaderLocation );  
00063   declareProperty( "McTruthLocation",          m_mcTruthLocation );
00064 
00065   declareProperty( "HistogramStart", m_histStart );
00066 
00067 
00068 }
00069 StandardHistogramMaker::~StandardHistogramMaker(){}
00070 
00071 //---------------------------------
00072 // initialise() 
00073 //---------------------------------
00074 
00075 StatusCode StandardHistogramMaker::initialize()
00076 {
00077   // .. put any initialisation in here...
00078   MsgStream log(messageService(), name());
00079   log << MSG::DEBUG << "in initialize()" << endreq;
00080   
00081   m_nHist = m_histStart;
00082   this->bookNonIsolatedElectronHistograms();
00083   this->bookIsolatedElectronHistograms();
00084   this->bookNonIsolatedPhotonHistograms();
00085   this->bookIsolatedPhotonHistograms();
00086   this->bookNonIsolatedMuonHistograms();
00087   this->bookIsolatedMuonHistograms();
00088   this->bookCellHistograms();
00089   this->bookClusterHistograms();
00090   this->bookJetHistograms();
00091   this->bookEventHeaderHistograms();
00092 
00093   log << MSG::DEBUG << "Booked histograms OK" << endreq;
00094 
00095   GlobalEventData* ged = GlobalEventData::Instance();
00096   // load the location of the MC in StoreGate
00097   m_mcLocation       = ged -> mcLocation();
00098 
00099 
00100   //  m_tesIO = new TesIO(eventDataService());
00101   m_tesIO = new TesIO(m_mcLocation, ged->justHardScatter());
00102   return StatusCode::SUCCESS ;
00103 }
00104 
00105 
00106 
00107 //---------------------------------
00108 // finalise() 
00109 //---------------------------------
00110 
00111 StatusCode StandardHistogramMaker::finalize()
00112 {
00113   // .. put any finalisation in here...
00114   delete m_tesIO;
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 
00135 
00136   this->kinHistogramFiller<
00137     ReconstructedParticleCollection>(
00138                                      m_electronLocation,
00139                                      m_h_electronMultiplicity,
00140                                      m_h_electronPx,
00141                                      m_h_electronPy,
00142                                      m_h_electronPz,
00143                                      m_h_electronE,
00144                                      m_h_electronPt
00145                                      );
00146 
00147   this->kinHistogramFiller<
00148     ReconstructedParticleCollection>(
00149                                      m_isolatedElectronLocation,
00150                                      m_h_isolatedElectronMultiplicity,
00151                                      m_h_isolatedElectronPx,
00152                                      m_h_isolatedElectronPy,
00153                                      m_h_isolatedElectronPz,
00154                                      m_h_isolatedElectronE,
00155                                      m_h_isolatedElectronPt
00156                                      );
00157 
00158   this->kinHistogramFiller<
00159     ReconstructedParticleCollection>(
00160                                      m_photonLocation,
00161                                      m_h_photonMultiplicity,
00162                                      m_h_photonPx,
00163                                      m_h_photonPy,
00164                                      m_h_photonPz,
00165                                      m_h_photonE,
00166                                      m_h_photonPt
00167                                      );
00168 
00169 
00170   
00171   this->kinHistogramFiller<
00172     ReconstructedParticleCollection>(
00173                                      m_isolatedPhotonLocation,
00174                                      m_h_isolatedPhotonMultiplicity,
00175                                      m_h_isolatedPhotonPx,
00176                                      m_h_isolatedPhotonPy,
00177                                      m_h_isolatedPhotonPz,
00178                                      m_h_isolatedPhotonE,
00179                                      m_h_isolatedPhotonPt
00180                                      );
00181 
00182   
00183   this->kinHistogramFiller<
00184     ReconstructedParticleCollection>(
00185                                      m_muonLocation,
00186                                      m_h_muonMultiplicity,
00187                                      m_h_muonPx,
00188                                      m_h_muonPy,
00189                                      m_h_muonPz,
00190                                      m_h_muonE,
00191                                      m_h_muonPt
00192                                      );
00193 
00194     
00195    this->kinHistogramFiller<
00196      ReconstructedParticleCollection>(
00197                                       m_isolatedMuonLocation,
00198                                       m_h_isolatedMuonMultiplicity,
00199                                       m_h_isolatedMuonPx,
00200                                       m_h_isolatedMuonPy,
00201                                       m_h_isolatedMuonPz,
00202                                       m_h_isolatedMuonE,
00203                                       m_h_isolatedMuonPt
00204                                       );
00205 
00206 
00207 
00208   this->kinHistogramFiller<ITwoCptCellCollection>(m_cellLocation,
00209                                                   m_h_cellMultiplicity,
00210                                                   m_h_cellPx,
00211                                                   m_h_cellPy,
00212                                                   m_h_cellPz,
00213                                                   m_h_cellE,
00214                                                   m_h_cellPt
00215                                                   );
00216   
00217   this->kinHistogramFiller<IClusterCollection>(m_clusterLocation,
00218                                                m_h_clusterMultiplicity,
00219                                                m_h_clusterPx,
00220                                                m_h_clusterPy,
00221                                                m_h_clusterPz,
00222                                                m_h_clusterE,
00223                                                m_h_clusterPt
00224                                                );
00225   
00226   this->kinHistogramFiller<JetCollection>(m_jetLocation,
00227                                           m_h_jetMultiplicity,
00228                                           m_h_jetPx,
00229                                           m_h_jetPy,
00230                                           m_h_jetPz,
00231                                           m_h_jetE,
00232                                           m_h_jetPt
00233                                           );
00234   
00235 
00236 
00237   /*    
00238   const EventHeader* eventHeader(0);
00239   if(!(m_tesIO->getDH(eventHeader))){
00240     log << MSG::ERROR<<"Could not find the event header in the TES"<<endreq;
00241     }
00242   
00243   if(eventHeader){
00244     m_h_njetb->fill(float(eventHeader->nBJets()), 1.0);
00245     m_h_njetc->fill(float(eventHeader->nCJets()), 1.0);
00246     m_h_njettau->fill(float(eventHeader->nTauJets()), 1.0);
00247     m_h_pxmiss->fill(float(eventHeader->pMiss().x()), 1.0);
00248     m_h_pymiss->fill(float(eventHeader->pMiss().y()), 1.0);
00249     m_h_pxnue->fill(float(eventHeader->pEscaped().x()), 1.0);
00250     m_h_pynue->fill(float(eventHeader->pEscaped().y()), 1.0);
00251     
00252     
00253     HepMC::WeightContainer weights = eventHeader->firstFewWeights(3);
00254     m_h_mcWeight0->fill(float(weights[0]), 1.0);
00255     m_h_mcWeight1->fill(float(weights[1]), 1.0);
00256     m_h_mcWeight2->fill(float(weights[2]), 1.0);
00257   } else {
00258     log << MSG::ERROR << " Invalid EventHeader data handle" << endreq;
00259   }
00260   
00261   */
00262   return StatusCode::SUCCESS ;
00263 }
00264 
00265 void StandardHistogramMaker::bookNonIsolatedElectronHistograms () {
00266   MsgStream log( messageService(), name() );
00267   log << MSG::DEBUG << "Booking electron histograms" << endreq;
00268 
00269   m_h_electronMultiplicity = 
00270     histoSvc()->book("/stat/simple/",
00271                      ++m_nHist,"Electron Multiplicity",10,0.0,10.0);
00272 
00273   m_h_electronPx = 
00274     histoSvc()->book("/stat/simple/",
00275                      ++m_nHist,"Electron Px",10,0.0,100000.0);
00276   m_h_electronPy = 
00277     histoSvc()->book("/stat/simple/",
00278                      ++m_nHist,"Electron Py",10,0.0,100000.0);
00279   m_h_electronPz = 
00280     histoSvc()->book("/stat/simple/",
00281                      ++m_nHist,"Electron Pz",10,0.0,100000.0);
00282   m_h_electronE = 
00283     histoSvc()->book("/stat/simple/",
00284                      ++m_nHist,"Electron  E",10,0.0,100000.0);
00285   m_h_electronPt = 
00286     histoSvc()->book("/stat/simple/",
00287                      ++m_nHist,"Electron Pt",10,0.0,100000.0);
00288 
00289   //MC truth electrons
00290   
00291 
00292   return;
00293 }
00294 
00295 
00296 void StandardHistogramMaker::bookIsolatedElectronHistograms () {
00297   MsgStream log( messageService(), name() );
00298   log << MSG::DEBUG << "Booking isolated electron histograms" << endreq;
00299 
00300   m_h_isolatedElectronMultiplicity = 
00301     histoSvc()->book("/stat/simple/",
00302                      ++m_nHist,"Isolated Electron Multiplicity",10,0.0,10.0);
00303 
00304   m_h_isolatedElectronPx = 
00305     histoSvc()->book("/stat/simple/",
00306                      ++m_nHist,"Isolated Electron Px",10,0.0,100000.0);
00307 
00308   m_h_isolatedElectronPy = 
00309     histoSvc()->book("/stat/simple/",
00310                      ++m_nHist,"Isolated Electron Py",10,0.0,100000.0);
00311 
00312   m_h_isolatedElectronPz = 
00313     histoSvc()->book("/stat/simple/",
00314                      ++m_nHist,"Isolated Electron Pz",10,0.0,100000.0);
00315 
00316   m_h_isolatedElectronE = 
00317     histoSvc()->book("/stat/simple/",
00318                      ++m_nHist,"Isolated Electron  E",10,0.0,100000.0);
00319 
00320   m_h_isolatedElectronPt = 
00321     histoSvc()->book("/stat/simple/",
00322                      ++m_nHist,"Isolated Electron Pt",10,0.0,100000.0);
00323   return;
00324 }
00325 
00326 
00327 void StandardHistogramMaker::bookNonIsolatedPhotonHistograms () {
00328   MsgStream log( messageService(), name() );
00329   log << MSG::DEBUG << "Booking photon histograms" << endreq;
00330 
00331   m_h_photonMultiplicity = 
00332     histoSvc()->book("/stat/simple/",
00333                      ++m_nHist,"Photon Multiplicity",20,0.0,20.0);
00334 
00335   m_h_photonPx = 
00336     histoSvc()->book("/stat/simple/",
00337                      ++m_nHist,"Photon Px",10,0.0,100000.0);
00338 
00339   m_h_photonPy = 
00340     histoSvc()->book("/stat/simple/",
00341                      ++m_nHist,"Photon Py",10,0.0,100000.0);
00342 
00343   m_h_photonPz = 
00344     histoSvc()->book("/stat/simple/",
00345                      ++m_nHist,"Photon Pz",10,0.0,100000.0);
00346 
00347   m_h_photonE = 
00348     histoSvc()->book("/stat/simple/",
00349                      ++m_nHist,"Photon  E",10,0.0,100000.0);
00350 
00351   m_h_photonPt = 
00352     histoSvc()->book("/stat/simple/",
00353                      ++m_nHist,"Photon Pt",10,0.0,100000.0);
00354   return;
00355 }
00356 
00357 
00358 void StandardHistogramMaker::bookIsolatedPhotonHistograms () {
00359   MsgStream log( messageService(), name() );
00360   log << MSG::DEBUG << "Booking isolated photon histograms" << endreq;
00361 
00362   m_h_isolatedPhotonMultiplicity = 
00363     histoSvc()->book("/stat/simple/",
00364                      ++m_nHist,"Isolated Photon Multiplicity",20,0.0,20.0);
00365 
00366 
00367   m_h_isolatedPhotonPx = 
00368     histoSvc()->book("/stat/simple/",
00369                      ++m_nHist,"Isolated Photon Px",10,0.0,100000.0);
00370 
00371   m_h_isolatedPhotonPy = 
00372     histoSvc()->book("/stat/simple/",
00373                      ++m_nHist,"Isolated Photon Py",10,0.0,100000.0);
00374 
00375   m_h_isolatedPhotonPz = 
00376     histoSvc()->book("/stat/simple/",
00377                      ++m_nHist,"Isolated Photon Pz",10,0.0,100000.0);
00378 
00379   m_h_isolatedPhotonE = 
00380     histoSvc()->book("/stat/simple/",
00381                      ++m_nHist,"Isolated Photon E",10,0.0,100000.0);
00382 
00383   m_h_isolatedPhotonPt = 
00384     histoSvc()->book("/stat/simple/",
00385                      ++m_nHist,"Isolated Photon Pt",10,0.0,100000.0);
00386   return;
00387 }
00388 
00389 
00390 void StandardHistogramMaker::bookNonIsolatedMuonHistograms () {
00391   MsgStream log( messageService(), name() );
00392   log << MSG::DEBUG << "Booking muon histograms" << endreq;
00393 
00394   m_h_muonMultiplicity = 
00395     histoSvc()->book("/stat/simple/",
00396                      ++m_nHist,"Muon Multiplicity",20,0.0,20.0);
00397 
00398   m_h_muonPx = 
00399     histoSvc()->book("/stat/simple/",
00400                      ++m_nHist,"Muon Px",10,0.0,100000.0);
00401 
00402   m_h_muonPy = 
00403     histoSvc()->book("/stat/simple/",
00404                      ++m_nHist,"Muon Py",10,0.0,100000.0);
00405 
00406   m_h_muonPz = 
00407     histoSvc()->book("/stat/simple/",
00408                      ++m_nHist,"Muon Pz",10,0.0,100000.0);
00409 
00410   m_h_muonE = 
00411     histoSvc()->book("/stat/simple/",
00412                      ++m_nHist,"Muon  E",10,0.0,100000.0);
00413 
00414   m_h_muonPt = 
00415     histoSvc()->book("/stat/simple/",
00416                      ++m_nHist,"Muon Pt",10,0.0,100000.0);
00417   return;
00418 }
00419 
00420 
00421 void StandardHistogramMaker::bookIsolatedMuonHistograms () {
00422   MsgStream log( messageService(), name() );
00423   log << MSG::DEBUG << "Booking isolated isolated muon histograms" << endreq;
00424 
00425   m_h_isolatedMuonMultiplicity = 
00426     histoSvc()->book("/stat/simple/",
00427                      ++m_nHist,"Isolated Muon Multiplicity",20,0.0,20.0);
00428 
00429 
00430   m_h_isolatedMuonPx = 
00431     histoSvc()->book("/stat/simple/",
00432                      ++m_nHist,"Isolated Muon Px",10,0.0,100000.0);
00433 
00434   m_h_isolatedMuonPy = 
00435     histoSvc()->book("/stat/simple/",
00436                      ++m_nHist,"Isolated Muon Py",10,0.0,100000.0);
00437 
00438   m_h_isolatedMuonPz = 
00439     histoSvc()->book("/stat/simple/",
00440                      ++m_nHist,"Isolated Muon Pz",10,0.0,100000.0);
00441 
00442   m_h_isolatedMuonE = 
00443     histoSvc()->book("/stat/simple/",
00444                      ++m_nHist,"Isolated Muon E",10,0.0,100000.0);
00445 
00446   m_h_isolatedMuonPt = 
00447     histoSvc()->book("/stat/simple/",
00448                      ++m_nHist,"Isolated Muon Pt",10,0.0,100000.0);
00449   return;
00450 }
00451 
00452 void StandardHistogramMaker::bookCellHistograms () {
00453   MsgStream log( messageService(), name() );
00454   log << MSG::DEBUG << "Booking Cell histograms" << endreq;
00455 
00456   m_h_cellMultiplicity = 
00457     histoSvc()->book("/stat/simple/",
00458                      ++m_nHist,"Cell Multiplicity",50,0.0,1000.0);
00459 
00460   m_h_cellPx = 
00461     histoSvc()->book("/stat/simple/",
00462                      ++m_nHist,"Cell Px",10,0.0,20000.0);
00463 
00464   m_h_cellPy = 
00465     histoSvc()->book("/stat/simple/",
00466                      ++m_nHist,"Cell Py",10,0.0,20000.0);
00467 
00468   m_h_cellPz = 
00469     histoSvc()->book("/stat/simple/",
00470                      ++m_nHist,"Cell Pz",10,0.0,100000.0);
00471 
00472   m_h_cellE = 
00473     histoSvc()->book("/stat/simple/",
00474                      ++m_nHist,"Cell E",10,0.0,100000.0);
00475 
00476   m_h_cellPt = 
00477     histoSvc()->book("/stat/simple/",
00478                      ++m_nHist,"Cell Pt",10,0.0,50000.0);
00479 
00480   return;
00481 }
00482 
00483 void StandardHistogramMaker::bookClusterHistograms () {
00484   MsgStream log( messageService(), name() );
00485   log << MSG::DEBUG << "Booking Cluster histograms" << endreq;
00486 
00487   m_h_clusterMultiplicity = 
00488     histoSvc()->book("/stat/simple/",
00489                      ++m_nHist,"Cluster Multiplicity",20,0.0,20.0);
00490 
00491   m_h_clusterPx = 
00492     histoSvc()->book("/stat/simple/",
00493                      ++m_nHist,"Cluster Px",10,0.0,100000.0);
00494 
00495   m_h_clusterPy = 
00496     histoSvc()->book("/stat/simple/",
00497                      ++m_nHist,"Cluster Py",10,0.0,100000.0);
00498 
00499   m_h_clusterPz = 
00500     histoSvc()->book("/stat/simple/",
00501                      ++m_nHist,"Cluster Pz",10,0.0,100000.0);
00502 
00503   m_h_clusterE = 
00504     histoSvc()->book("/stat/simple/",
00505                      ++m_nHist,"Cluster E",10,0.0,100000.0);
00506 
00507   m_h_clusterPt = 
00508     histoSvc()->book("/stat/simple/",
00509                      ++m_nHist,"Cluster Pt",10,0.0,100000.0);
00510 
00511   return;
00512 }
00513 
00514 void StandardHistogramMaker::bookJetHistograms () {
00515   MsgStream log( messageService(), name() );
00516   log << MSG::DEBUG << "Booking Jet histograms" << endreq;
00517 
00518   m_h_jetMultiplicity = 
00519     histoSvc()->book("/stat/simple/",
00520                      ++m_nHist,"Jet Multiplicity",20,0.0,20.0);
00521 
00522   m_h_jetPx = 
00523     histoSvc()->book("/stat/simple/",
00524                      ++m_nHist,"Jet Px",10,0.0,100000.0);
00525 
00526   m_h_jetPy = 
00527     histoSvc()->book("/stat/simple/",
00528                      ++m_nHist,"Jet Py",10,0.0,100000.0);
00529 
00530   m_h_jetPz = 
00531     histoSvc()->book("/stat/simple/",
00532                      ++m_nHist,"Jet Pz",10,0.0,100000.0);
00533 
00534   m_h_jetE = 
00535     histoSvc()->book("/stat/simple/",
00536                      ++m_nHist,"Jet E",50,0.0,500000.0);
00537 
00538   m_h_jetPt = 
00539     histoSvc()->book("/stat/simple/",
00540                      ++m_nHist,"Jet Pt",20,0.0,200000.0);
00541 
00542   return;
00543 }
00544 
00545 void StandardHistogramMaker::bookEventHeaderHistograms () {
00546   MsgStream log( messageService(), name() );
00547   log << MSG::DEBUG << "Booking Event Header histograms" << endreq;
00548 
00549   m_h_njetb = 
00550     histoSvc()->book("/stat/simple/",
00551                      ++m_nHist,"Event Header njetb",20,0.0,20.0);
00552 
00553   m_h_njetc = 
00554     histoSvc()->book("/stat/simple/",
00555                      ++m_nHist,"Event Header njetc",20,0.0,20.0);
00556 
00557   m_h_njettau = 
00558     histoSvc()->book("/stat/simple/",
00559                      ++m_nHist,"Event Header njettau",20,0.0,20.0);
00560 
00561   m_h_pxmiss = 
00562     histoSvc()->book("/stat/simple/",
00563                      ++m_nHist,"Event Header pxmiss",20,0.0,100000.);
00564 
00565   m_h_pymiss = 
00566     histoSvc()->book("/stat/simple/",
00567                      ++m_nHist,"Event Header pymiss",20,0.0,100000.);
00568 
00569 
00570   m_h_pxnue = 
00571     histoSvc()->book("/stat/simple/",
00572                      ++m_nHist,"Event Header pxnue",20,0.0,100000.);
00573 
00574   m_h_mcWeight0 = 
00575     histoSvc()->book("/stat/simple/",
00576                      ++m_nHist,"Event Header mcWeight0",10,0.0,1.);
00577 
00578   m_h_mcWeight1 = 
00579     histoSvc()->book("/stat/simple/",
00580                      ++m_nHist,"Event Header mcWeight1",10,0.0,1.);
00581 
00582   m_h_mcWeight2 = 
00583     histoSvc()->book("/stat/simple/",
00584                      ++m_nHist,"Event Header mcWeight2",10,0.0,1.);
00585 
00586   return;
00587 }
00588 
00589 
00590 
00591 
00592 
00593 
00594 } // end of namespace bracket
00595 
00596 
00597 
00598 
00599 
00600 
00601 
00602 
00603 
00604 
00605 
00606 
00607 
00608 
00609 
00610 
00611 
00612 

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