TagWriterAlg Class Reference

#include <TagWriterAlg.h>

List of all members.

Public Member Functions

 TagWriterAlg (const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize ()
StatusCode execute ()
StatusCode finalize ()
StatusCode getTagInfo ()
void openOutputTagFile (std::string file)

Private Attributes

RootInterfacem_rootInterface
int m_fileNum
TFile * m_oFile
TTree * m_oTree
TTree * m_oFileTree
vector< stringm_outputTagFile
string m_dstFile
int m_entry
int m_runNo
int m_eventId
int m_totalCharged
int m_totalNeutral
int m_totalTrks
string m_dstOutput
int m_entry_in_alg


Detailed Description

Definition at line 14 of file TagWriterAlg.h.


Constructor & Destructor Documentation

TagWriterAlg::TagWriterAlg ( const std::string name,
ISvcLocator *  pSvcLocator 
)

Definition at line 38 of file TagWriterAlg.cxx.

References m_outputTagFile.

00038                                                                           :
00039   Algorithm(name, pSvcLocator) {
00040   
00041   //declareProperty("InputTagFile", m_inputTagFile);
00042   declareProperty("OutputTagFile", m_outputTagFile);
00043   //declareProperty("FilterTotalCharged", m_filterTotalCharged=2);
00044 }


Member Function Documentation

StatusCode TagWriterAlg::execute (  ) 

Definition at line 100 of file TagWriterAlg.cxx.

References RootInterface::getCurrentFileName(), getTagInfo(), Bes_Common::INFO, m_dstFile, m_dstOutput, m_entry, m_entry_in_alg, m_fileNum, m_oFile, m_oFileTree, m_oTree, m_outputTagFile, m_rootInterface, msgSvc(), and openOutputTagFile().

00100                                  {
00101 
00102   MsgStream log(msgSvc(), name());
00103   log << MSG::INFO << "in execute()" << endreq;
00104 
00105   //Write Tag during reconstruction
00106   if(m_dstOutput!="")
00107   {
00108     if(m_entry==-1)
00109     {
00110       std::cout << "TagWriterAlg: write tag during reconstruction" << std::endl;
00111       m_dstFile = m_dstOutput;
00112       std::cout<< "dst file: "<< m_dstFile << std::endl;
00113       openOutputTagFile(m_outputTagFile[0]);
00114       m_oFileTree->Fill();
00115     }
00116   }
00117   else  //Write Tag after reconstruction
00118   {
00119     if( m_dstFile != m_rootInterface->getCurrentFileName() )
00120     {
00121       std::cout<<"TagWriterAlg, current file: "<<m_rootInterface->getCurrentFileName()<<std::endl;
00122       m_fileNum++;
00123       m_dstFile = m_rootInterface->getCurrentFileName();
00124 
00125       m_entry=-1;
00126       if(m_fileNum>0)
00127       {
00128         m_oFile->Write();
00129         delete m_oTree;
00130         delete m_oFileTree;
00131         delete m_oFile;
00132       }
00133     
00134       log << MSG::INFO << "open ROOT output TAG file: "<<m_outputTagFile[m_fileNum]<<endreq;
00135       openOutputTagFile(m_outputTagFile[m_fileNum]);
00136       m_oFileTree->Fill();
00137     }
00138   }
00139 
00140   m_entry++;
00141   getTagInfo();  
00142   log << MSG::INFO << "writing TAG information to ROOT TAG file"<<endreq;
00143   m_oTree->Fill();
00144 
00145   m_entry_in_alg++;
00146   return StatusCode::SUCCESS;
00147 }

StatusCode TagWriterAlg::finalize (  ) 

Definition at line 184 of file TagWriterAlg.cxx.

References Bes_Common::INFO, m_oFile, and msgSvc().

00184                                   {
00185 
00186   MsgStream log(msgSvc(), name());
00187 
00188   m_oFile->Write();
00189 
00190   log << MSG::INFO << "in finalize()" << endmsg;
00191   return StatusCode::SUCCESS;
00192 }

StatusCode TagWriterAlg::getTagInfo (  ) 

Definition at line 151 of file TagWriterAlg.cxx.

References Bes_Common::DEBUG, EventModel::EvtRec::EvtRecEvent, Bes_Common::FATAL, Bes_Common::INFO, m_eventId, m_runNo, m_totalCharged, m_totalNeutral, m_totalTrks, and msgSvc().

Referenced by execute().

00152 {
00153   MsgStream log(msgSvc(), name());
00154   log << MSG::INFO << "reading event data from DST"<<endreq;
00155   
00156   SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
00157   if(!eventHeader)
00158   {
00159     log << MSG::FATAL << "Could not find EventHeader." << endreq;
00160     return StatusCode::FAILURE;
00161   }
00162 
00163   m_runNo=eventHeader->runNumber();
00164   m_eventId=eventHeader->eventNumber();
00165   log << MSG::DEBUG <<"run, evtnum = " << m_runNo << " , "<< m_eventId <<endreq;
00166 
00167   SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc(), EventModel::EvtRec::EvtRecEvent);
00168   if(!evtRecEvent)
00169   {
00170     log << MSG::FATAL << "Could not find EvtRecEvent." << endreq;
00171     return StatusCode::FAILURE;
00172   }
00173   log << MSG::DEBUG <<"ncharg, nneu, tottks = " 
00174       << evtRecEvent->totalCharged() << " , "
00175       << evtRecEvent->totalNeutral() << " , "
00176       << evtRecEvent->totalTracks() <<endreq;
00177   m_totalCharged = evtRecEvent->totalCharged();
00178   m_totalNeutral = evtRecEvent->totalNeutral();
00179   m_totalTrks = evtRecEvent->totalTracks();
00180   return StatusCode::SUCCESS;
00181 }

StatusCode TagWriterAlg::initialize (  ) 

Definition at line 47 of file TagWriterAlg.cxx.

References RootInterface::getTotalFileNum(), genRecEmupikp::i, Bes_Common::INFO, RootInterface::Instance(), m_dstFile, m_dstOutput, m_entry, m_entry_in_alg, m_fileNum, m_outputTagFile, m_rootInterface, msgSvc(), and deljobs::string.

00047                                    {
00048   MsgStream log(msgSvc(), name());
00049 
00050   log << MSG::INFO << "in initialize()" << endmsg;
00051 
00052   SmartIF<IJobOptionsSvc> iSvc(serviceLocator()->service("JobOptionsSvc"));
00053   if ( iSvc.isValid() ) {
00054     std::string  dll;  //sub so name
00055     const std::vector<const Property*>* ps = 0;
00056     if ( iSvc->getProperties("RootCnvSvc") != 0 ) 
00057       ps = iSvc->getProperties("RootCnvSvc");
00058     if ( iSvc->getProperties("EventCnvSvc") != 0 )
00059       ps = iSvc->getProperties("EventCnvSvc");
00060     if ( iSvc->getProperties("WriteDst") != 0 )
00061       ps = iSvc->getProperties("WriteDst");
00062 
00063     if( ps !=0 )
00064     {
00065       for(int i=0;i<ps->size();i++)
00066       {
00067         if( (*ps)[i]->name() == "digiRootOutputFile" )
00068          
00069         { 
00070           m_dstOutput = (*ps)[i]->toString();
00071           std::cout<<"read from JobOptionSvc, dstOutput: "<< m_dstOutput<<std::endl;
00072         }
00073       }
00074     }
00075   }
00076 
00077 
00078 
00079   m_rootInterface=RootInterface::Instance(log);
00080   log << MSG::INFO <<"RootInteface TotalFileNum: "<<m_rootInterface->getTotalFileNum()<<endreq;
00081   std::cout<<"getTotalFileNum: "<<m_rootInterface->getTotalFileNum()<<std::endl;
00082 
00083   if(m_rootInterface->getTotalFileNum()>0)
00084   {
00085     if(m_rootInterface->getTotalFileNum() != m_outputTagFile.size() )
00086     {
00087       std::cout<<"the input file num != output file number, please check your jobOptions"<<std::endl;
00088       exit(-1);
00089     }
00090   }
00091   
00092   m_entry = -1;
00093   m_entry_in_alg = -1;
00094   m_dstFile = "";
00095   m_fileNum=-1; 
00096   return StatusCode::SUCCESS;
00097 }

void TagWriterAlg::openOutputTagFile ( std::string  file  ) 

Definition at line 196 of file TagWriterAlg.cxx.

References m_dstFile, m_entry, m_eventId, m_oFile, m_oFileTree, m_oTree, m_runNo, m_totalCharged, m_totalNeutral, and m_totalTrks.

Referenced by execute().

00197 {
00198   m_oFile = new TFile(ofile.c_str(),"RECREATE","ROOT file for TAG");
00199   m_oTree = new TTree("Tag","Tags for DST file");
00200   m_oTree->Branch("entry",&m_entry, "entry/I");
00201   m_oTree->Branch("runNo",&m_runNo, "runNo/I");
00202   m_oTree->Branch("eventId",&m_eventId, "eventId/I");
00203   m_oTree->Branch("totalCharged",&m_totalCharged, "totalCharged/I");
00204   m_oTree->Branch("totalNeutral",&m_totalNeutral, "totalNeutral/I");
00205   m_oTree->Branch("totalTrks",&m_totalTrks, "totalTrks/I");
00206   m_oFileTree = new TTree("File", "DST file names");
00207   m_oFileTree->Branch("fileName", &m_dstFile);
00208 
00209 }


Member Data Documentation

string TagWriterAlg::m_dstFile [private]

Definition at line 54 of file TagWriterAlg.h.

Referenced by execute(), initialize(), and openOutputTagFile().

string TagWriterAlg::m_dstOutput [private]

Definition at line 62 of file TagWriterAlg.h.

Referenced by execute(), and initialize().

int TagWriterAlg::m_entry [private]

Definition at line 55 of file TagWriterAlg.h.

Referenced by execute(), initialize(), and openOutputTagFile().

int TagWriterAlg::m_entry_in_alg [private]

Definition at line 63 of file TagWriterAlg.h.

Referenced by execute(), and initialize().

int TagWriterAlg::m_eventId [private]

Definition at line 57 of file TagWriterAlg.h.

Referenced by getTagInfo(), and openOutputTagFile().

int TagWriterAlg::m_fileNum [private]

Definition at line 30 of file TagWriterAlg.h.

Referenced by execute(), and initialize().

TFile* TagWriterAlg::m_oFile [private]

Definition at line 33 of file TagWriterAlg.h.

Referenced by execute(), finalize(), and openOutputTagFile().

TTree* TagWriterAlg::m_oFileTree [private]

Definition at line 36 of file TagWriterAlg.h.

Referenced by execute(), and openOutputTagFile().

TTree* TagWriterAlg::m_oTree [private]

Definition at line 35 of file TagWriterAlg.h.

Referenced by execute(), and openOutputTagFile().

vector<string> TagWriterAlg::m_outputTagFile [private]

Definition at line 42 of file TagWriterAlg.h.

Referenced by execute(), initialize(), and TagWriterAlg().

RootInterface* TagWriterAlg::m_rootInterface [private]

Definition at line 28 of file TagWriterAlg.h.

Referenced by execute(), and initialize().

int TagWriterAlg::m_runNo [private]

Definition at line 56 of file TagWriterAlg.h.

Referenced by getTagInfo(), and openOutputTagFile().

int TagWriterAlg::m_totalCharged [private]

Definition at line 58 of file TagWriterAlg.h.

Referenced by getTagInfo(), and openOutputTagFile().

int TagWriterAlg::m_totalNeutral [private]

Definition at line 59 of file TagWriterAlg.h.

Referenced by getTagInfo(), and openOutputTagFile().

int TagWriterAlg::m_totalTrks [private]

Definition at line 60 of file TagWriterAlg.h.

Referenced by getTagInfo(), and openOutputTagFile().


Generated on Tue Nov 29 23:35:57 2016 for BOSS_7.0.2 by  doxygen 1.4.7