/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/RootRawEvtReader/RootRawEvtReader-00-00-01/src/RootRawEvtReader.cxx

Go to the documentation of this file.
00001 #include "RootRawEvtReader/RootRawEvtReader.h"
00002 
00003 #include "GaudiKernel/MsgStream.h"
00004 #include "GaudiKernel/AlgFactory.h"
00005 #include "GaudiKernel/Bootstrap.h"
00006 #include "GaudiKernel/ISvcLocator.h"
00007 #include "GaudiKernel/SmartDataPtr.h"
00008 #include "GaudiKernel/IDataProviderSvc.h"
00009 #include "GaudiKernel/PropertyMgr.h"
00010 #include "GaudiKernel/DataObject.h"
00011 #include "GaudiKernel/GenericAddress.h"
00012 #include "GaudiKernel/ClassID.h"
00013 
00014 #include "RawEvent/DigiEvent.h"   //TDS object
00015 #include "EventModel/EventModel.h"
00016 #include "EventModel/EventHeader.h"
00017 
00018 //Digi
00019 #include "MdcRawEvent/MdcDigi.h"
00020 #include "EmcRawEvent/EmcDigi.h"
00021 #include "TofRawEvent/TofDigi.h"
00022 #include "MucRawEvent/MucDigi.h"
00023 
00024 #include "RootEventData/TMdcDigi.h"
00025 #include "RootEventData/TTofDigi.h"
00026 #include "RootEventData/TEmcDigi.h"
00027 #include "RootEventData/TMucDigi.h"
00028 
00029 
00030 #include "TFile.h"
00031 #include "TTree.h"
00032 #include "TBranch.h"
00033 #include "TObjArray.h"
00034 
00036 
00037 RootRawEvtReader::RootRawEvtReader(const std::string& name, ISvcLocator* pSvcLocator) :
00038   Algorithm(name, pSvcLocator)
00039 {
00040   
00041   declareProperty("MdcDigi",m_mdcDigi=1);
00042   declareProperty("TofDigi",m_tofDigi=1);
00043   declareProperty("EmcDigi",m_emcDigi=1);
00044   declareProperty("MucDigi",m_mucDigi=1);
00045   declareProperty("InputFiles",m_inputFiles);
00046   
00047   m_totalEvents=0;
00048   m_fileNumber=0;
00049   m_tempNumber=-1;
00050   m_currentEntries=-1;
00051   m_currentEntry=-1;
00052 }
00053 
00054 RootRawEvtReader::~RootRawEvtReader()
00055 {
00056 }
00057 
00058 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
00059 StatusCode RootRawEvtReader::initialize(){
00060 
00061   MsgStream log(msgSvc(), name());
00062   log << MSG::INFO << "in initialize()" << endreq;
00063 
00064   ISvcLocator* svcLocator = Gaudi::svcLocator();
00065   StatusCode sc=svcLocator->service("EventDataSvc", m_evtSvc);
00066   if (sc.isFailure())
00067     std::cout<<"Could not accesss EventDataSvc!"<<std::endl;
00068 
00069   return StatusCode::SUCCESS;
00070 }
00071 
00072 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
00073 StatusCode RootRawEvtReader::execute() {
00074 
00075   MsgStream log(msgSvc(), name());
00076   log << MSG::INFO << "in execute()" << endreq;
00077 
00078   DigiEvent* aDigiEvent = new DigiEvent;
00079   StatusCode sc = m_evtSvc->registerObject("/Event/Digi",aDigiEvent);
00080   if(sc!=StatusCode::SUCCESS) {
00081     std::cout<< "Could not register DigiEvent" <<std::endl;
00082   }
00083 
00084   
00085   if(m_tempNumber != m_fileNumber)
00086   {
00087     m_currentEntry = 0;  
00088     TFile* m_input = TFile::Open(m_inputFiles[m_fileNumber].c_str(), "READ");
00089     std::cout<<"input file: "<<m_inputFiles[m_fileNumber].c_str()<<std::endl;
00090     m_tree= (TTree *)m_input->Get("Event");
00091     m_tree->SetMakeClass(1);
00092     m_currentEntries=(Int_t)m_tree->GetEntries();
00093     std::cout<<"m_currentEntries: "<<m_currentEntries<<std::endl;
00094 
00095     m_tempNumber = m_fileNumber;
00096   } 
00097  
00098   if(m_mdcDigi)
00099     readMdc(m_currentEntry);
00100 
00101   if(m_tofDigi)
00102     readTof(m_currentEntry);
00103 
00104   if(m_emcDigi)
00105     readEmc(m_currentEntry);
00106 
00107   if(m_mucDigi)
00108     readMuc(m_currentEntry); 
00109 
00110   log << MSG::INFO << "current Entry: "<< m_currentEntry << endreq;
00111   //std::cout << "current Entry: "<< m_currentEntry << std::endl;
00112   m_currentEntry++;
00113 
00114   if(m_currentEntry==m_currentEntries)
00115   {
00116     m_fileNumber++;
00117   }
00118 
00119   m_totalEvents++;
00120   log << MSG::INFO << "total events: "<< m_totalEvents << endreq;
00121   //std::cout << "total events: "<< m_totalEvents << std::endl;
00122 
00123   return StatusCode::SUCCESS;
00124 }
00125 
00126 
00127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00128 StatusCode RootRawEvtReader::readMdc(int entry)
00129 {
00130   TBranch *branch = m_tree->GetBranch("m_mdcDigiCol");
00131 
00132   TObjArray* mdcDigiCol;
00133   branch->SetAddress(&mdcDigiCol);
00134   mdcDigiCol=0;
00135 
00136   branch->GetEntry(entry);
00137 
00138   //commonData m_common;
00139 
00140   TIter mdcDigiIter(mdcDigiCol);
00141   MdcDigiCol* mdcDigiTdsCol = new MdcDigiCol;
00142   TMdcDigi *mdcDigiRoot = 0;
00143 
00144   while ((mdcDigiRoot = (TMdcDigi*)mdcDigiIter.Next())) {
00145     unsigned int  id  = mdcDigiRoot->getIntId();
00146           unsigned int  time = mdcDigiRoot->getTimeChannel();
00147           unsigned int  charge = mdcDigiRoot->getChargeChannel();
00148           unsigned int  overflow = mdcDigiRoot->getOverflow();
00149           int trackIndex = mdcDigiRoot->getTrackIndex();
00150 
00151     MdcDigi *mdcDigiTds = new MdcDigi(id);
00152     //m_common.m_rootMdcDigiMap[mdcDigiRoot] = mdcDigiTds;
00153           mdcDigiTds->setTimeChannel(time);
00154           mdcDigiTds->setChargeChannel(charge);
00155           mdcDigiTds->setOverflow(overflow);
00156     mdcDigiTds->setTrackIndex(trackIndex);
00157     mdcDigiTdsCol->push_back(mdcDigiTds);
00158     /*std::cout<<"trackID: "<<trackIndex;
00159     std::cout<<"  charge: "<<charge;
00160     std::cout<<"  time: "<<time<<std::endl;*/
00161   }
00162 
00163   //register MDC digits collection to TDS
00164   StatusCode scMdc = m_evtSvc->registerObject("/Event/Digi/MdcDigiCol", mdcDigiTdsCol);
00165   if(scMdc!=StatusCode::SUCCESS) 
00166     std::cout<< "Could not register MDC digi collection" <<std::endl;
00167   
00168 
00169   return StatusCode::SUCCESS;
00170 }
00171 
00172 StatusCode RootRawEvtReader::readTof(int entry)
00173 {
00174   TBranch *branch = m_tree->GetBranch("m_tofDigiCol");
00175 
00176   TObjArray* tofDigiCol;
00177   branch->SetAddress(&tofDigiCol);
00178   tofDigiCol=0;
00179 
00180   branch->GetEntry(entry);
00181 
00182   //commonData m_common;
00183 
00184   TIter tofDigiIter(tofDigiCol);
00185   TofDigiCol* tofDigiTdsCol = new TofDigiCol;
00186   TTofDigi *tofDigiRoot = 0;
00187 
00188   while ((tofDigiRoot = (TTofDigi*)tofDigiIter.Next())) {
00189     unsigned int  id  = tofDigiRoot->getIntId();
00190           unsigned int  time = tofDigiRoot->getTimeChannel();
00191           unsigned int  charge = tofDigiRoot->getChargeChannel();
00192           unsigned int  overflow = tofDigiRoot->getOverflow();
00193           int trackIndex = tofDigiRoot->getTrackIndex();
00194 
00195     TofDigi *tofDigiTds = new TofDigi(id);
00196     //m_common.m_rootTofDigiMap[tofDigiRoot] = tofDigiTds;
00197           tofDigiTds->setTimeChannel(time);
00198           tofDigiTds->setChargeChannel(charge);
00199           tofDigiTds->setOverflow(overflow);
00200     tofDigiTds->setTrackIndex(trackIndex);
00201     tofDigiTdsCol->push_back(tofDigiTds);
00202   }
00203 
00204   //register TOF digits collection to TDS
00205   StatusCode scTof = m_evtSvc->registerObject("/Event/Digi/TofDigiCol", tofDigiTdsCol);
00206   if(scTof!=StatusCode::SUCCESS) 
00207     std::cout<< "Could not register TOF digi collection" <<std::endl;
00208   
00209 
00210   return StatusCode::SUCCESS;
00211 }
00212 
00213 StatusCode RootRawEvtReader::readEmc(int entry)
00214 {
00215   TBranch *branch = m_tree->GetBranch("m_emcDigiCol");
00216 
00217   TObjArray* emcDigiCol;
00218   branch->SetAddress(&emcDigiCol);
00219   emcDigiCol=0;
00220 
00221   branch->GetEntry(entry);
00222 
00223   //commonData m_common;
00224 
00225   TIter emcDigiIter(emcDigiCol);
00226   EmcDigiCol* emcDigiTdsCol = new EmcDigiCol;
00227   TEmcDigi *emcDigiRoot = 0;
00228 
00229   while ((emcDigiRoot = (TEmcDigi*)emcDigiIter.Next())) {
00230     unsigned int  id  = emcDigiRoot->getIntId();
00231           unsigned int  time = emcDigiRoot->getTimeChannel();
00232           unsigned int  charge = emcDigiRoot->getChargeChannel();
00233           unsigned int  measure = emcDigiRoot->getMeasure();
00234           int trackIndex = emcDigiRoot->getTrackIndex();
00235 
00236     EmcDigi *emcDigiTds = new EmcDigi(id);
00237     //m_common.m_rootEmcDigiMap[emcDigiRoot] = emcDigiTds;
00238           emcDigiTds->setTimeChannel(time);
00239           emcDigiTds->setChargeChannel(charge);
00240           emcDigiTds->setMeasure(measure);
00241     emcDigiTds->setTrackIndex(trackIndex);
00242     emcDigiTdsCol->push_back(emcDigiTds);
00243   }
00244 
00245   //register EMC digits collection to TDS
00246   StatusCode scEmc = m_evtSvc->registerObject("/Event/Digi/EmcDigiCol", emcDigiTdsCol);
00247   if(scEmc!=StatusCode::SUCCESS) 
00248     std::cout<< "Could not register EMC digi collection" <<std::endl;
00249   
00250 
00251   return StatusCode::SUCCESS;
00252 }
00253 
00254 StatusCode RootRawEvtReader::readMuc(int entry)
00255 {
00256   TBranch *branch = m_tree->GetBranch("m_mucDigiCol");
00257 
00258   TObjArray* mucDigiCol;
00259   branch->SetAddress(&mucDigiCol);
00260   mucDigiCol=0;
00261 
00262   branch->GetEntry(entry);
00263 
00264   //commonData m_common;
00265 
00266   TIter mucDigiIter(mucDigiCol);
00267   MucDigiCol* mucDigiTdsCol = new MucDigiCol;
00268   TMucDigi *mucDigiRoot = 0;
00269 
00270   while ((mucDigiRoot = (TMucDigi*)mucDigiIter.Next())) {
00271     unsigned int  id  = mucDigiRoot->getIntId();
00272           unsigned int  time = mucDigiRoot->getTimeChannel();
00273           unsigned int  charge = mucDigiRoot->getChargeChannel();
00274           int trackIndex = mucDigiRoot->getTrackIndex();
00275 
00276     MucDigi *mucDigiTds = new MucDigi(id);
00277     //m_common.m_rootMucDigiMap[mucDigiRoot] = mucDigiTds;
00278           mucDigiTds->setTimeChannel(time);
00279           mucDigiTds->setChargeChannel(charge);
00280     mucDigiTds->setTrackIndex(trackIndex);
00281     mucDigiTdsCol->push_back(mucDigiTds);
00282   }
00283 
00284   //register MUC digits collection to TDS
00285   StatusCode scMuc = m_evtSvc->registerObject("/Event/Digi/MucDigiCol", mucDigiTdsCol);
00286   if(scMuc!=StatusCode::SUCCESS) 
00287     std::cout<< "Could not register MUC digi collection" <<std::endl;
00288   
00289 
00290   return StatusCode::SUCCESS;
00291 }
00292 
00293 
00294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
00295 StatusCode RootRawEvtReader::finalize() {
00296 
00297   MsgStream log(msgSvc(), name());
00298   log << MSG::INFO << "in finalize()" << endreq;
00299 
00300   return StatusCode::SUCCESS;
00301 }

Generated on Tue Nov 29 23:11:43 2016 for BOSS_7.0.2 by  doxygen 1.4.7