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

CreateEvent.cpp

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/GlastSvc/src/test/CreateEvent.cpp,v 1.17 2001/04/19 01:32:31 igable Exp $
00002 #define GlastApps_CreateEvent_CPP 
00003 
00004 
00005 //#define GlastApps_CreateEvent_CPP 
00006 
00007 
00008 // Include files
00009 #include "CreateEvent.h"
00010 
00011 #include "GaudiKernel/MsgStream.h"
00012 #include "GaudiKernel/AlgFactory.h"
00013 #include "GaudiKernel/IDataProviderSvc.h"
00014 #include "GaudiKernel/SmartDataPtr.h"
00015 
00016 #include "GlastSvc/GlastDetSvc/IGlastDetSvc.h"
00017 #include "GlastEvent/TopLevel/EventModel.h"
00018 #include "GlastEvent/TopLevel/Event.h"
00019 #include "GaudiKernel/ObjectVector.h"
00020 
00021 
00022 #include "GlastEvent/TopLevel/IrfEvent.h"
00023 #include "GlastEvent/Irf/IrfAcdHit.h"
00024 #include "GlastEvent/Irf/IrfCalHit.h"
00025 #include "GlastEvent/Irf/IrfTkrLayer.h"
00026 
00027 #include "GlastEvent/MonteCarlo/McIntegratingHit.h"
00028                                 
00029 static const AlgFactory<CreateEvent>  Factory;
00030 const IAlgFactory& CreateEventFactory = Factory;
00031 
00032 //extern void GlastSvc_load();
00033 
00034 //------------------------------------------------------------------------------
00037 CreateEvent::CreateEvent(const std::string& name, ISvcLocator* pSvcLocator) :
00038 Algorithm(name, pSvcLocator), m_detSvc(0), m_irfLoadSvc(0) {
00039     //GlastSvc_load();
00040 }
00041 
00042 
00043 //------------------------------------------------------------------------------
00050 StatusCode CreateEvent::initialize() {
00051     
00052     MsgStream log(msgSvc(), name());
00053     log << MSG::INFO << "initialize" << endreq;
00054     
00055     // Use the Job options service to set the Algorithm's parameters
00056     setProperties();
00057     
00058     // now try to find the GlastDevSvc service
00059     IGlastDetSvc* detSvc = 0;
00060     const IID&  IID_IGlastDetSvc  =  401; // wired it for now!
00061 
00062     StatusCode sc = serviceLocator()->getService ("GlastDetSvc",
00063         IID_IGlastDetSvc, reinterpret_cast<IInterface*&>( detSvc ));
00064     
00065     if (sc.isSuccess ())
00066         log << MSG::INFO << "Succeeded in accessing the GlastDetSvc!" << endreq;
00067     else {
00068         log << MSG::ERROR << "Couldn't find the GlastDetSvc!" << endreq;
00069         return StatusCode::FAILURE;
00070     }
00071     m_detSvc = detSvc;
00072 
00073 
00074     return StatusCode::SUCCESS;
00075 }
00076 
00077 
00078 //------------------------------------------------------------------------------
00079 StatusCode CreateEvent::execute() {
00080     
00081     StatusCode  sc = StatusCode::SUCCESS;
00082     MsgStream   log( msgSvc(), name() );
00083     log << MSG::INFO << "execute" << endreq;
00084 
00085     DataObject* pObject;
00086 
00090     sc = eventSvc()->retrieveObject("/Event/Irf/IrfAcdHits", pObject);
00091 
00092     if( sc.isFailure() ){
00093         log << MSG::INFO << "Failed to get IrfAcdHits from TDS!" << endreq;
00094         return sc; 
00095     }
00096     
00097         log << MSG::INFO << "Successfully retrieved ACD Container!!!" << endreq;
00098 
00099     ObjectVector<IrfAcdHit>* acdList;
00100     try {
00101         acdList  = dynamic_cast<ObjectVector<IrfAcdHit>*>(pObject);
00102     } catch(...) {
00103         log << MSG::INFO << "Failed to convert object to IrfAcdHitVector" << endreq;
00104         return StatusCode::FAILURE;
00105     }
00106 
00107     
00108         // Decrease the amount of output
00109 #if 0
00110 
00111     for (ObjectVector<IrfAcdHit>::const_iterator it = acdList->begin(); it != acdList->end(); it++) {
00112         log << MSG::INFO << " ACD Tile Hit " 
00113             << (*it)->id() << " "
00114             << (*it)->energy() << endreq;
00115     }
00116 #endif
00117 
00120     sc = eventSvc()->retrieveObject("/Event/Irf/IrfCalHits", pObject);
00121     if( sc.isFailure() ) {
00122         log << MSG::INFO << "Failed to get IrfCalHits" << endreq;
00123         return sc;                                                             
00124     } 
00125     
00126     log << MSG::INFO << "Retrieved IrfCalHit Vector!" << endreq;
00127 
00128     ObjectVector<IrfCalHit>* calList;
00129     try {
00130         calList  = dynamic_cast<ObjectVector<IrfCalHit>*>(pObject);
00131     } catch(...) {
00132         log << MSG::INFO << "Failed to convert object to IrfCalHitVector" << endreq;
00133         return StatusCode::FAILURE;
00134     }
00135 
00136         // Decrease amount of output
00137 #if 0
00138 
00139     for (ObjectVector<IrfCalHit>::const_iterator xtal = calList->begin(); xtal != calList->end(); xtal++) {
00140         log << MSG::INFO << "Csi Log Hit: " << endreq;
00141         log <<MSG::INFO << "       " 
00142                         << (*xtal)->minusResponse() << " " 
00143                         << (*xtal)->plusResponse() << " "
00144                         << (*xtal)->energy() << " " << endreq;
00145     }
00146 #endif
00147 
00150     sc = eventSvc()->retrieveObject("/Event/Irf/IrfTkrHits", pObject);
00151     if( sc.isFailure() ) return sc;                                                             
00152     
00153         log << MSG::INFO << "Successfully retrieved TKR Container!!!" << endreq;
00154 
00155     ObjectVector<IrfTkrLayer>* tkrList;
00156     try {
00157         tkrList  = dynamic_cast<ObjectVector<IrfTkrLayer>*>(pObject);
00158     } catch(...) {
00159         log << MSG::INFO << "Failed to convert object to IrfTkrLayerVector" << endreq;
00160         return StatusCode::FAILURE;
00161     }
00162     
00163         // Decrease amount of output
00164 #if 0
00165 
00166     for (ObjectVector<IrfTkrLayer>::const_iterator silayer = tkrList->begin(); silayer != tkrList->end(); silayer++) {
00167         log << MSG::INFO << "TkrLayer " << (*silayer)->id() << " "
00168             << (*silayer)->MaxEnergy() << endreq;
00169 
00170         for (ObjectVector<IrfTkrHit>::const_iterator hit = ((*silayer)->getHits())->begin(); hit != ((*silayer)->getHits())->end(); hit++) {
00171             log << MSG::INFO << "Hit SSD Strip " 
00172                 << (*hit)->id() << " "
00173                 << (*hit)->energy() << " "
00174                 << (*hit)->noise() << endreq;
00175         }
00176       }
00177 #endif // End of decreased output comment.
00178 
00179 
00180 
00181     return sc;
00182 
00183 
00184     //
00185 }
00186 
00187 
00188 //------------------------------------------------------------------------------
00189 StatusCode CreateEvent::finalize() {
00190     
00191     MsgStream log(msgSvc(), name());
00192     log << MSG::INFO << "finalize" << endreq;
00193     
00194     return StatusCode::SUCCESS;
00195 }
00196 ;
00197 
00198 StatusCode CreateEvent::testMcClass(){
00199     McIntegratingHit* integratingHit = new McIntegratingHit();
00200     McParticle* mcParticle =  new McParticle();
00201 
00202     
00203     return StatusCode::SUCCESS;
00204 }
00205 
00206 
00207 

Generated at Wed Nov 21 12:21:12 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000