| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

MixInputAlgorithm.cc

Go to the documentation of this file.
00001 #include "MixInputSvc/MixInputAlgorithm.h"
00002 
00003 #include "Event/GenHeader.h"
00004 #include "Event/SimHeader.h"
00005 #include "Event/RegistrationSequence.h"
00006 
00007 #include "RootIOSvc/IRootIOSvc.h"
00008 #include "RootIOSvc/RootIOAddress.h"
00009 #include "PerGenEvent/PerGenHeader.h"
00010 #include "PerSimEvent/PerSimHeader.h"
00011 
00012 #include "GaudiKernel/IDataManagerSvc.h"
00013 
00014 using namespace std;
00015 using namespace DayaBay;
00016 
00017 MixInputAlgorithm::MixInputAlgorithm(const string& name, ISvcLocator* pSvcLocator) 
00018                   :DybAlgorithm<SimHeader>(name,pSvcLocator)
00019 {
00020   info()<< "Construct:MixInputAlgorithm()!"<< endreq;
00021 }
00022 
00023 StatusCode MixInputAlgorithm::initialize()
00024 {
00025   StatusCode status= this->GaudiAlgorithm::initialize();
00026   if(status.isFailure()) 
00027   { 
00028     error()<< "Error when initializing  GaudiAlgorithm"<< endreq;
00029     return status;
00030   }
00031    
00032   info()<< "MixInputAlgorithm ininalize()"<< endreq; 
00033   IService* isvc = 0;
00034   StatusCode sc = serviceLocator()->service("RootIOCnvSvc", isvc, false);
00035   if(sc.isFailure()) 
00036   {
00037     error()<< "Conversion service RootIOCnvSvc"<< " could not be retrieved"<< endreq;
00038     return sc;
00039   }
00040   isvc->addRef();
00041   sc = isvc->queryInterface(IMixInputSvc::interfaceID(), (void**)&m_mixInputSvc);
00042   if(sc.isFailure()) 
00043   {
00044     error()<< "Conversion service RootIOCnvSvc"<< " does not implement IRootIOCnvSvc"<< endreq;
00045   }
00046   return sc;
00047 }
00048 
00049 StatusCode MixInputAlgorithm::execute() 
00050 {
00051   info()<< "Now into MixInputAlgorithm executation!"<< endreq;
00052 
00053   SimHeader* sh = new SimHeader();
00054   GenHeader* gh = new GenHeader();
00055   m_mixInputSvc->prepareStream();
00056   m_mixInputSvc->getSimHeader(gh, sh);
00057 
00058   const SimHitHeader* shh = sh->hits();
00059   info()<< "SimHitHeader's address: "<< shh<< endreq;
00060   map<short int, SimHitCollection*> shc = shh->hitCollection();
00061   for(map<short int, SimHitCollection*>::iterator mit = shc.begin(); mit != shc.end(); mit++)
00062   {
00063     vector<SimHit*> vsh = mit->second->collection();
00064     info()<< MSG::INFO<< "In Det"<< mit->first
00065           << " : SimHit's num = "<< vsh.size()<< endreq;
00066   }
00067 
00068   info()<< "GenHeader: "<< gh<< "--"<< "SimHeader: "<< sh<< endreq;
00069                               
00070   if(0 != sh && 0 != gh)
00071   {
00072     // Using some functions in RegistrationSequence
00073     RegistrationSequence* seq = get<RegistrationSequence>(evtSvc(), RegistrationSequenceLocation::Default);
00074     debug()<< "ATTENTION!===========> Size = "<< seq->size()<< endreq;
00075     seq->setEarliest(sh->earliest());
00076     seq->setLatest(sh->latest());
00077 
00078     //If the sample coming from MDC, the codes below needed
00079     /*IRegistrationSequence::Registrations& regs = const_cast<IRegistrationSequence::Registrations&>(seq->registrations());
00080     IRegistrationSequence::Registrations::iterator regit;
00081     for(regit = regs.begin(); regit != regs.end(); regit++)
00082     {
00083       info()<< regit->path()<< endreq;
00084       if(regit->path() == "/Event/Readout/ReadoutHeader")
00085       {
00086         DataObject*    child = const_cast<DataObject*>(regit->object());   
00087         ReadoutHeader* reoh  = dynamic_cast<ReadoutHeader*>(child);
00088         info()<< reoh->readout()->triggerTime().GetSeconds()<< endreq;
00089         regit->setStore(false);
00090         info()<< "Not Storing: "<< regit->path()<< endreq;
00091       }
00092       }*/
00093 
00094     // Put SimHeader(GenHeader) into TES
00095     put(evtSvc(), gh, GenHeaderLocation::Default);
00096     put(evtSvc(), sh, SimHeaderLocation::Default);
00097   }
00098 
00099   info()<< "MixInputAlgorithm execute() finalized!" << endreq;
00100   return StatusCode::SUCCESS;
00101 }
00102 
00103 StatusCode MixInputAlgorithm::finalize() 
00104 {
00105   info()<< "MixInputAlgorithm finalize()"<< endreq;
00106   return StatusCode::SUCCESS;
00107 }
00108 
00109 MixInputAlgorithm::~MixInputAlgorithm()
00110 {
00111   info()<< "Destruct:~MixInputAlgorithm()!"<< endreq;
00112 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:44:38 2011 for MixInputSvc by doxygen 1.4.7