BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
RootInterface Class Reference

#include <RootInterface.h>

Public Member Functions

 RootInterface (MsgStream log)
 
virtual ~RootInterface ()
 
virtual StatusCode finalize ()
 
virtual bool checkEndOfTree ()
 check if all the files is over 2005-11-28
 
virtual bool getENDFILE ()
 
virtual StatusCode addInput (const std::string &treename, const std::string &file)
 add input tree to the list
 
virtual StatusCode addOutput (const std::string &treename, const std::string &file, int splitx, int bufsize, int compression)
 add output tree to the list
 
virtual StatusCode createBranch (const std::string &tree, const std::string &branch, const char *classname, void *addr, int &branchnr)
 create a branch in this tree
 
virtual StatusCode setBranchAddress (const std::string treename, const std::string branchname, void *addr, int &nb)
 set branch address
 
virtual StatusCode getBranchEntry (int nr, int entry, int &nb)
 get entry from this branch
 
virtual StatusCode getBranchEntry (int nr, int entry, void *addr, int &nb)
 get entry from this branch with addr
 
virtual bool getEOF ()
 get EOF flag
 
virtual Int_t getEntries ()
 get nr of entries
 
virtual StatusCode fillTrees ()
 fill in all trees
 
virtual std::string getCurrentFileName ()
 
virtual std::vector< int > getTotEvtNo ()
 
virtual std::string getJobOptions ()
 
virtual std::string getDecayOptions ()
 
virtual void printJobInfo (TFile *file, int level)
 
virtual void setSelectFromTag (bool temp)
 
virtual bool getSelectFromTag ()
 
virtual int getCurrentFileNum ()
 
virtual int getTotalFileNum ()
 
virtual void setTagInputFile (std::vector< std::string > input)
 
virtual std::vector< std::string > getTagInputFile ()
 
virtual StatusCode f_addOutput (const std::string &treename, const std::string &file, int splitx=1, int bufsize=64000, int compression=1)
 
virtual StatusCode f_createTree (unsigned int treenr, const std::string treename)
 
virtual StatusCode f_createBranch (const std::string &treename, const std::string &branchname, const char *classname, void *addr, int &branchnr)
 
virtual StatusCode f_getTreeNr (const std::string treename, unsigned int &treenr, bool doAdd=false)
 
virtual StatusCode f_fillTrees ()
 
virtual StatusCode f_finalize ()
 

Static Public Member Functions

static RootInterfaceInstance (MsgStream log)
 singleton behaviour
 

Detailed Description

Definition at line 19 of file RootInterface.h.

Constructor & Destructor Documentation

◆ RootInterface()

RootInterface::RootInterface ( MsgStream  log)

Definition at line 31 of file RootInterface.cxx.

31 : log(str)
32{
33
34 m_branches= new TClonesArray("TBranch",1);
35 m_branchesRead= new TClonesArray("TBranch",1);
36 m_entries=-1;
37 m_EOF=false;
38 m_ENDFILE = false ;
39 m_fileNum = 0; //-1
40 }

◆ ~RootInterface()

RootInterface::~RootInterface ( )
virtual

Definition at line 43 of file RootInterface.cxx.

44{
45}

Member Function Documentation

◆ addInput()

StatusCode RootInterface::addInput ( const std::string &  treename,
const std::string &  file 
)
virtual

add input tree to the list

Definition at line 163 of file RootInterface.cxx.

163 {
164 log << MSG::DEBUG << "addInput for Tree "<<treename<<endreq;
165 StatusCode sc=StatusCode::SUCCESS;
166 m_fileNames.push_back(file); //input files 2005-11-28
167 m_otherTrees.push_back(NULL);
168 inputFiles.push_back(NULL);
169 unsigned int treenr;
170 sc=getTreeNr(treename,treenr,true);
171 m_inputFilenames[treenr]=file; // the last one file is setted
172 m_inputFiles[treenr]=NULL;
173 m_inputTrees[treenr]=NULL;
174 m_currentFileName = m_fileNames[treenr].c_str();
175 return sc;
176}
char * file
Definition: DQA_TO_DB.cxx:15

Referenced by RootEvtSelector::initialize().

◆ addOutput()

StatusCode RootInterface::addOutput ( const std::string &  treename,
const std::string &  file,
int  splitx,
int  bufsize,
int  compression 
)
virtual

add output tree to the list

Definition at line 189 of file RootInterface.cxx.

189 {
190 static int i =0;
191 i ++;
192 log << MSG::DEBUG << "addOutput for Tree "<<treename<<endreq;
193 StatusCode sc=StatusCode::SUCCESS;
194 unsigned int treenr;
195 sc=getTreeNr(treename,treenr,true);
196 m_outputFilenames[treenr]=file;
197 m_outputFiles[treenr]=NULL;
198 m_outputTrees[treenr]=NULL;
199 m_splitModes[treenr]=split;
200 m_bufSizes[treenr]=bufsize;
201 m_compressionLevels[treenr]=compression;
202
203 return sc;
204}

◆ checkEndOfTree()

bool RootInterface::checkEndOfTree ( )
virtual

check if all the files is over 2005-11-28

Definition at line 436 of file RootInterface.cxx.

436 {
437
438 if ( m_fileNum >= int(m_fileNames.size())-1 ){
439 if(m_inputFiles[0]){
440 delete m_inputFiles[0];
441 m_inputFiles[0] = NULL;
442 }
443 return true;
444 }
445
446 (*m_branchesRead).Clear();
447 unsigned int treenr;
448 getTreeNr("Event",treenr);
449 if(m_inputFiles[treenr]){
450 delete m_inputFiles[treenr];
451 m_inputFiles[treenr] = NULL;
452 }
453 if(m_inputTrees[treenr]){
454 //delete m_inputTrees[treenr];
455 m_inputTrees[treenr] = NULL;
456 }
457 if(m_otherTrees[m_fileNum]) delete m_otherTrees[m_fileNum];
458 if(inputFiles[m_fileNum]) delete inputFiles[m_fileNum];
459
460 m_ENDFILE = true;
461 m_fileNum++;
462 m_currentFileName = m_fileNames[m_fileNum].c_str();
463
464 m_entries=-1;
465 m_EOF = false;
466 return false;
467}

Referenced by RootEvtSelector::getEntryFromTag(), and RootEvtSelector::next().

◆ createBranch()

StatusCode RootInterface::createBranch ( const std::string &  tree,
const std::string &  branch,
const char *  classname,
void *  addr,
int &  branchnr 
)
virtual

create a branch in this tree

Definition at line 206 of file RootInterface.cxx.

206 {
207
208 log << MSG::DEBUG << "CreateBranch, Tree "<<treename<<" branch "<<branchname<<endreq;
209
210 TBranch *branch;
211 unsigned int treenr;
212 StatusCode sc=getTreeNr(treename,treenr);
213 if (!sc.isSuccess()) return sc;
214
215 if ( m_outputFilenames[treenr].empty() ) {
216 log << MSG::DEBUG << "No corresponding output file specified, ignore createBranch: "<<branchname<<endreq;
217 return StatusCode::SUCCESS;
218 }
219
220 if(!m_outputTrees[treenr]) sc=this->createTree(treenr,treename);
221 if (!sc.isSuccess()) return sc;
222 TTree * tree=m_outputTrees[treenr];
223 tree->SetUniqueID(treenr);
224
225 branch = tree->Branch(branchname.c_str(),classname,addr,m_bufSizes[treenr],m_splitModes[treenr]);
226 branch->SetUniqueID(treenr);
227 branchnr=m_branches->GetEntriesFast()+1;
228 m_branches->Expand(branchnr);
229 TClonesArray &a = *m_branches;
230 a[branchnr-1]=branch;
231 tree->SetBasketSize(branchname.c_str(),m_bufSizes[treenr]); //some problem with above method to set buffersize, so we set it here.
232 return StatusCode::SUCCESS;
233}

Referenced by DigiCnv::DataObjectToTObject(), DstCnv::DataObjectToTObject(), EvtHeaderCnv::DataObjectToTObject(), EvtNavigatorCnv::DataObjectToTObject(), EvtRecCnv::DataObjectToTObject(), HltCnv::DataObjectToTObject(), McCnv::DataObjectToTObject(), RecTrackCnv::DataObjectToTObject(), and TrigCnv::DataObjectToTObject().

◆ f_addOutput()

StatusCode RootInterface::f_addOutput ( const std::string &  treename,
const std::string &  file,
int  splitx = 1,
int  bufsize = 64000,
int  compression = 1 
)
virtual

Definition at line 636 of file RootInterface.cxx.

638 {
639 log << MSG::INFO << "addOutput to single event" << endreq;
640 StatusCode status = StatusCode::FAILURE;
641 unsigned int treenr;
642
643 status = f_getTreeNr(treename, treenr, true);
644 m_single_compressionLevels[treenr] = compression;
645 m_single_outputFileNames[treenr] = file;
646 m_single_outputFiles[treenr] = NULL;
647 m_single_outputTrees[treenr] = NULL;
648 m_single_splitModes[treenr] = splitx;
649 m_single_bufSizes[treenr] = bufsize;
650
651 std::cout << "finish f_addOutput to single event" << std::endl;
652 return status;
653}
virtual StatusCode f_getTreeNr(const std::string treename, unsigned int &treenr, bool doAdd=false)

◆ f_createBranch()

StatusCode RootInterface::f_createBranch ( const std::string &  treename,
const std::string &  branchname,
const char *  classname,
void *  addr,
int &  branchnr 
)
virtual

Definition at line 683 of file RootInterface.cxx.

686 {
687 log << MSG::INFO << "f_craeteBranch() create branch, tree name:"
688 << treename << ", branch name:" << branchname << endreq;
689
690 TBranch *branch;
691 unsigned int treenr;
692 StatusCode status = f_getTreeNr(treename, treenr);
693 if ( !status.isSuccess()) return status;
694
695 if ( !m_single_outputTrees[treenr])
696 status = this->f_createTree(treenr, treename);
697 if ( !status.isSuccess()) return status;
698
699 TTree* tree = m_single_outputTrees[treenr];
700 tree->SetUniqueID(treenr);
701
702 branch = tree->Branch(branchname.c_str(),
703 classname,
704 addr,
705 m_single_bufSizes[treenr],
706 m_single_splitModes[treenr]);
707
708}
virtual StatusCode f_createTree(unsigned int treenr, const std::string treename)

◆ f_createTree()

StatusCode RootInterface::f_createTree ( unsigned int  treenr,
const std::string  treename 
)
virtual

Definition at line 655 of file RootInterface.cxx.

656 {
657 log << MSG::INFO << "f_createTree()" << endreq;
658
659 TDirectory *saveDir = gDirectory;
660
661 m_single_outputFiles[treenr] =
662 TFile::Open(m_single_outputFileNames[treenr].c_str(), "RECREATE");
663 if ( !m_single_outputFiles[treenr]->IsOpen()){
664 log << MSG::ERROR << "ROOT share file: "
665 << m_single_outputFileNames[treenr]
666 << " could not be opened for writing"
667 << endreq;
668 return StatusCode::FAILURE;
669 }
670 log << MSG::INFO << "f_createTree()::open share file for writing: "
671 << m_single_outputFileNames[treenr] << endreq;
672
673 m_single_outputFiles[treenr]->cd();
674 m_single_outputFiles[treenr]->SetCompressionLevel(m_single_compressionLevels[treenr]);
675
676 std::string title = treename + " for share";
677 m_single_outputTrees[treenr] = new TTree(treename.c_str(), title.c_str());
678 saveDir->cd();
679
680 return StatusCode::SUCCESS;
681}
titledef title[20]
char * c_str(Index i)
Definition: EvtCyclic3.cc:252

Referenced by f_createBranch().

◆ f_fillTrees()

StatusCode RootInterface::f_fillTrees ( )
virtual

Definition at line 740 of file RootInterface.cxx.

740 {
741 StatusCode status = StatusCode::FAILURE;
742 int byte;
743
744 std::vector<TTree *>::const_iterator tree;
745 for ( tree = m_single_outputTrees.begin(); tree < m_single_outputTrees.end(); tree++){
746 if ( (*tree) == NULL) continue;
747 byte = (*tree)->Fill();
748 (*tree)->Print();
749 log << MSG::INFO << "f_fillTrees() filled tree " << (*tree)->GetName()
750 << " with " << byte << " bytes!" << endreq;
751 status = StatusCode::SUCCESS;
752 }
753
754 return status;
755}

◆ f_finalize()

StatusCode RootInterface::f_finalize ( )
virtual

Definition at line 757 of file RootInterface.cxx.

757 {
758 log << MSG::INFO << "f_finalize() in RootInterface" << endreq;
759
760 std::vector<TTree *>::const_iterator tree;
761 for ( tree = m_single_outputTrees.begin(); tree < m_single_outputTrees.end(); tree++){
762 if ( *tree){
763 unsigned int treenr = (*tree)->GetUniqueID();
764 log << MSG::INFO << "tree id: " << treenr << endreq;
765 if ( m_single_outputFiles[treenr] ){
766 if ( !m_single_outputFiles[treenr]->IsOpen()){
767 log << MSG::ERROR << "f_finalize could not open share file for writing"
768 << endreq;
769 return StatusCode::FAILURE;
770 }
771 else {
772 log << MSG::INFO << "Closing file:" << treenr
773 << ", tree:" << (*tree)->GetName() << endreq;
774
775 TDirectory *saveDir = gDirectory;
776 m_single_outputFiles[treenr]->cd();
777 log <<MSG::INFO << "WREITE TO FILE BYTES: "
778 << m_single_outputFiles[treenr]->Write()
779 << endreq;
780 m_single_outputFiles[treenr]->Close();
781 saveDir->cd();
782 }
783 }
784 }
785 }
786 return StatusCode::SUCCESS;
787}

◆ f_getTreeNr()

StatusCode RootInterface::f_getTreeNr ( const std::string  treename,
unsigned int &  treenr,
bool  doAdd = false 
)
virtual

Definition at line 710 of file RootInterface.cxx.

711 {
712
713 std::vector<std::string>::iterator where =
714 std::find(m_single_treenames.begin(), m_single_treenames.end(), treename);
715
716 if ( where == m_single_treenames.end()){
717 if ( doAdd){
718 treenr = m_single_treenames.size();
719 m_single_treenames.push_back(treename);
720
721 m_single_outputFileNames.push_back("");
722 m_single_outputFiles.push_back(NULL);
723 m_single_outputTrees.push_back(NULL);
724 m_single_splitModes.push_back(0);
725 m_single_bufSizes.push_back(0);
726 m_single_compressionLevels.push_back(0);
727
728 return StatusCode::SUCCESS;
729 }
730 else {
731 log << MSG::ERROR << "Invalid share tree name: "
732 << treename << endreq;
733 return StatusCode::FAILURE;
734 }
735 }
736 treenr = where - m_single_treenames.begin();
737 return StatusCode::SUCCESS;
738}

Referenced by f_addOutput(), and f_createBranch().

◆ fillTrees()

StatusCode RootInterface::fillTrees ( )
virtual

fill in all trees

Definition at line 608 of file RootInterface.cxx.

608 {
609 // loop over all trees and fill them
610 StatusCode sc=StatusCode::FAILURE;
611 int nb;
612 std::vector<TTree *>::const_iterator trees;
613 for (trees=m_outputTrees.begin();trees<m_outputTrees.end();trees++) {
614 if ((*trees)==NULL) continue;
615 int treenr=(*trees)->GetUniqueID();
616 if(m_outputFiles[treenr]->IsZombie()||(!m_outputFiles[treenr]->IsOpen())){
617 std::cout<<"RootInterface ERROR::The ROOT File:"<<m_outputFilenames[treenr].c_str()<<"status is false"<<std::endl;
618 exit(1);
619 }
620 nb=(*trees)->Fill();
621 m_outputFiles[treenr] = (*trees)->GetCurrentFile();
622 log << MSG::DEBUG << "filled tree "<<(* trees)->GetName() <<" with "<<nb<<" bytes"<< endreq;
623 if(nb==-1){
624 log << MSG::FATAL << "Error in filling tree "<<(* trees)->GetName() <<" with "<<nb<<" bytes"<< endreq;
625 exit(1);
626 }
627 sc=StatusCode::SUCCESS;
628 }
629 return sc;
630}

Referenced by RootCnvSvc::commitOutput().

◆ finalize()

StatusCode RootInterface::finalize ( )
virtual

Definition at line 107 of file RootInterface.cxx.

107 {
108
109 // Get the messaging service, print where you are
110 log << MSG::INFO << "finalize() in RootInterface" << endreq;
111
112 // close file (FIXME for several output files)
113 std::vector<TTree *>::const_iterator trees;
114 for (trees=m_outputTrees.begin();trees<m_outputTrees.end();trees++)
115 if (*trees) {
116 int treenr=(*trees)->GetUniqueID();
117 if (m_outputFiles[treenr]) {
118 if (!m_outputFiles[treenr]->IsOpen()) {
119 log << MSG::ERROR << "Could not open file for writing" << endreq;
120 return StatusCode::FAILURE;
121 } else {
122 log << MSG::DEBUG<<" Closing file "<<treenr<<", tree "<<(*trees)->GetName()<<endreq;
123 TDirectory *saveDir = gDirectory;
124 m_outputFiles[treenr]->cd();
125
126 TJobInfo* jobInfo = new TJobInfo;
127 TTree* m_jobInfoTree = new TTree("JobInfoTree","Job info");
128 m_jobInfoTree->Branch("JobInfo",&jobInfo);
129
130 m_bossVer = getenv("BES_RELEASE");
131 log << MSG::INFO << "fill boss version: "<<m_bossVer << endreq;
132
133 string tmpJobOptions = getJobOptions();
134 m_jobOptions.push_back( tmpJobOptions );
135
136 if(m_decayOptions.size()==0)
137 m_decayOptions = getDecayOptions();
138
139 m_totEvtNo = getTotEvtNo();
140 jobInfo->setBossVer(m_bossVer);
141 jobInfo->setJobOptions(m_jobOptions);
142 jobInfo->setDecayOptions(m_decayOptions);
143 jobInfo->setTotEvtNo(m_totEvtNo);
144 m_jobInfoTree->Fill();
145
146 //? m_mcFile->Write(0, TObject::kOverwrite);
147 int st =1;
148 st = m_outputFiles[treenr]->Write();
149 if(st==0){
150 log << MSG::FATAL<<" can not write the file "<< m_outputFilenames[treenr].c_str()<<endreq;
151 exit(1);
152 }
153
154 m_outputFiles[treenr]->Close();
155 saveDir->cd();
156 }
157 }
158 }
159 if(m_outputTrees.size()>0) m_outputTrees.clear();
160 return StatusCode::SUCCESS;
161}
virtual std::vector< int > getTotEvtNo()
virtual std::string getJobOptions()
virtual std::string getDecayOptions()
void setBossVer(string ver)
Definition: TJobInfo.h:21
void setTotEvtNo(std::vector< int > i)
Definition: TJobInfo.h:25
void setDecayOptions(string opt)
Definition: TJobInfo.h:24
void setJobOptions(vector< string > opt)
Definition: TJobInfo.h:23

Referenced by RootCnvSvc::finalize().

◆ getBranchEntry() [1/2]

StatusCode RootInterface::getBranchEntry ( int  nr,
int  entry,
int &  nb 
)
virtual

get entry from this branch

Definition at line 561 of file RootInterface.cxx.

562{
563 log << MSG::DEBUG <<"RootInterface::getBranchEntry: "<<", branch nr "<<nr <<", entry "<<entry <<endreq;
564
565 if (nr <0) return StatusCode::FAILURE;
566 TBranch *branch=(TBranch *)m_branchesRead->At(nr);
567 if (!branch) {
568 log << MSG::ERROR << "Could not find branch " << nr <<endreq;
569 return StatusCode::FAILURE;
570 }
571 nb=branch->GetEntry(entry);
572
573 if (nb<=0){
574 m_EOF=true;
575
576 }
577
578 return StatusCode::SUCCESS;
579}

Referenced by RootEventBaseCnv::createObj().

◆ getBranchEntry() [2/2]

StatusCode RootInterface::getBranchEntry ( int  nr,
int  entry,
void *  addr,
int &  nb 
)
virtual

get entry from this branch with addr

Definition at line 539 of file RootInterface.cxx.

540{
541 log << MSG::DEBUG <<"RootInterface::getBranchEntry: "<<", branch nr "<<nr <<", entry "<<entry <<endreq;
542
543 if (nr <0) return StatusCode::FAILURE;
544 TBranch *branch=(TBranch *)m_branchesRead->At(nr);
545 if (!branch) {
546 log << MSG::ERROR << "Could not find branch " << nr <<endreq;
547 return StatusCode::FAILURE;
548 }
549
550 branch->SetAddress(addr);
551 nb=branch->GetEntry(entry);
552
553 if (nb<=0){
554 m_EOF=true;
555
556 }
557 return StatusCode::SUCCESS;
558}

◆ getCurrentFileName()

virtual std::string RootInterface::getCurrentFileName ( )
inlinevirtual

◆ getCurrentFileNum()

virtual int RootInterface::getCurrentFileNum ( )
inlinevirtual

Definition at line 65 of file RootInterface.h.

65{return m_fileNum;}

Referenced by RootEvtSelector::getEntryFromTag().

◆ getDecayOptions()

std::string RootInterface::getDecayOptions ( )
virtual

Definition at line 70 of file RootInterface.cxx.

71{
72 ISvcLocator* svcLocator = Gaudi::svcLocator();
73 IDataInfoSvc *tmpInfoSvc;
74 DataInfoSvc* jobInfoSvc;
75 string decayOptions;
76 StatusCode status = svcLocator->service("DataInfoSvc",tmpInfoSvc);
77 if (status.isSuccess()) {
78 log << MSG::INFO << "get the DataInfoSvc" << endreq;
79 jobInfoSvc=dynamic_cast<DataInfoSvc *>(tmpInfoSvc);
80 decayOptions = jobInfoSvc->getDecayOptions();
81 log << MSG::INFO << "get decay options" << endreq
82 << decayOptions << endreq;
83 }else {
84 log << MSG::WARNING << "could not get the DataInfoSvc. Ignore it." << endreq;
85 }
86 return decayOptions;
87}
string getDecayOptions()
Definition: DataInfoSvc.h:25

Referenced by finalize().

◆ getENDFILE()

virtual bool RootInterface::getENDFILE ( )
inlinevirtual

Definition at line 31 of file RootInterface.h.

31{ return m_ENDFILE;}

Referenced by RootEventBaseCnv::createObj().

◆ getEntries()

virtual Int_t RootInterface::getEntries ( )
inlinevirtual

get nr of entries

Definition at line 51 of file RootInterface.h.

51{ return m_entries;}

Referenced by RootEventBaseCnv::createObj(), and RootEvtSelector::next().

◆ getEOF()

virtual bool RootInterface::getEOF ( )
inlinevirtual

get EOF flag

Definition at line 49 of file RootInterface.h.

49{ return m_EOF;}

Referenced by RootEvtSelector::next().

◆ getJobOptions()

std::string RootInterface::getJobOptions ( )
virtual

Definition at line 47 of file RootInterface.cxx.

48{
49 IInterface* iface = Gaudi::createApplicationMgr();
50 SmartIF<IProperty> propMgr (iface );
51 std::string path;
52 propMgr->getProperty( "JobOptionsPath", path);
53 log << MSG::INFO << "JobOptions file for current job: " <<path << endreq;
54 ifstream fin(path.c_str());
55 string jobOptions;
56 string tempString;
57 while(getline(fin,tempString))
58 {
59 if( tempString.size()>0 && tempString.find("//")>tempString.size() )
60 {
61 jobOptions += tempString;
62 jobOptions += "\n";
63 }
64 }
65 log << MSG::INFO << "JobOptions: " << endreq
66 << jobOptions << endreq;
67 return jobOptions;
68}
std::ifstream ifstream
Definition: bpkt_streams.h:44

Referenced by finalize().

◆ getSelectFromTag()

virtual bool RootInterface::getSelectFromTag ( )
inlinevirtual

Definition at line 63 of file RootInterface.h.

63{ return m_selectFromTag;}

Referenced by RootEventBaseCnv::createObj(), and RootEvtSelector::next().

◆ getTagInputFile()

virtual std::vector< std::string > RootInterface::getTagInputFile ( )
inlinevirtual

Definition at line 69 of file RootInterface.h.

69{return m_tagInputFile;}

Referenced by RootEvtSelector::getEntryFromTag().

◆ getTotalFileNum()

virtual int RootInterface::getTotalFileNum ( )
inlinevirtual

Definition at line 66 of file RootInterface.h.

66{return m_fileNames.size();}

Referenced by RootEvtSelector::getEntryFromTag(), and TagWriterAlg::initialize().

◆ getTotEvtNo()

std::vector< int > RootInterface::getTotEvtNo ( )
virtual

Definition at line 89 of file RootInterface.cxx.

90{
91 ISvcLocator* svcLocator = Gaudi::svcLocator();
92 IDataInfoSvc *tmpInfoSvc;
93 DataInfoSvc* jobInfoSvc;
94 std::vector<int> totEvtNo;
95 StatusCode status = svcLocator->service("DataInfoSvc",tmpInfoSvc);
96 if (status.isSuccess()) {
97 log << MSG::INFO << "get the DataInfoSvc" << endreq;
98 jobInfoSvc=dynamic_cast<DataInfoSvc *>(tmpInfoSvc);
99 totEvtNo = jobInfoSvc->getTotEvtNo();
100 log << MSG::INFO << "get total event number for each run" << endreq;
101 }else {
102 log << MSG::WARNING << "could not get the DataInfoSvc. Ignore it." << endreq;
103 }
104 return totEvtNo;
105}
std::vector< int > getTotEvtNo()
Definition: DataInfoSvc.h:26

Referenced by finalize().

◆ Instance()

RootInterface * RootInterface::Instance ( MsgStream  log)
static

singleton behaviour

Definition at line 25 of file RootInterface.cxx.

25 {
26 if (m_rootInterface) return m_rootInterface;
27 m_rootInterface=new RootInterface(log);
28 return m_rootInterface;
29}

Referenced by MixerAlg::execute(), RootEvtSelector::initialize(), TagWriterAlg::initialize(), RootCnvSvc::RootCnvSvc(), and RootEventBaseCnv::RootEventBaseCnv().

◆ printJobInfo()

void RootInterface::printJobInfo ( TFile *  file,
int  level 
)
virtual

Definition at line 311 of file RootInterface.cxx.

312{
313 TTree* tree2 = (TTree *)file->Get("JobInfoTree");
314 if(!tree2)
315 {
316 std::cout<<"no JobInfoTree for file "<<file->GetName()<<std::endl;
317 exit(1);
318 }
319 else
320 {
321 log << MSG::INFO << "get JobInfoTree" << endreq;
322 TBranch* branch = tree2->GetBranch("JobInfo");
323 if(!branch)
324 {
325 std::cout<<"ERROR! No branch in JobInfoTree"<<std::endl;
326 exit(1);
327 }
328 else
329 {
330 TJobInfo* jobInfo= new TJobInfo;
331 branch->SetAddress(&jobInfo);
332 branch->GetEntry(0);
333 m_bossVer = jobInfo->getBossVer() ;
334 std::cout<<std::endl
335 << "**************************************************" << std::endl
336 <<"Print JobInfo for data file: "<< file->GetName()<<std::endl
337 << " BOSS version: "<< m_bossVer << std::endl
338 << "**************************************************" << std::endl
339 << std::endl;
340
341 m_decayOptions = jobInfo->getDecayOptions();
342 if(m_decayOptions.size()>0)
343 {
344 std::cout<< std::endl
345 <<"**************************************************" << std::endl
346 <<" Decay Options: "<<std::endl
347 <<m_decayOptions << std::endl
348 <<"**************************************************" << std::endl
349 << std::endl;
350 }
351
352 ISvcLocator* svcLocator = Gaudi::svcLocator();
353 IDataInfoSvc *tmpInfoSvc;
354 DataInfoSvc* jobInfoSvc;
355 StatusCode status = svcLocator->service("DataInfoSvc",tmpInfoSvc);
356 if (status.isSuccess()) {
357 log << MSG::INFO << "get the DataInfoSvc" << endreq;
358 jobInfoSvc=dynamic_cast<DataInfoSvc *>(tmpInfoSvc);
359 }else {
360 log << MSG::WARNING << "could not get the DataInfoSvc." << endreq;
361 }
362
363 m_totEvtNo = jobInfo->getTotEvtNo();
364 jobInfoSvc->setTotEvtNo(m_totEvtNo);
365
366 if(level>0)
367 {
368 std::cout<<std::endl
369 <<"**************************************************" << std::endl
370 <<" JobOptions for this data file: " << std::endl
371 << std::endl;
372
373
374 m_jobOptions = jobInfo->getJobOptions();
375 vector<std::string> vs = m_jobOptions;
376 int nv = vs.size();
377 if(nv>0)
378 {
379 for(int i=0;i<nv;i++)
380 {
381 std::cout<<vs[i]<<std::endl;
382 std::cout<<" end of the jobOptions file " << std::endl;
383 std::cout<<"**************************************************" << std::endl
384 <<std::endl;
385 }
386 }
387 }
388 }
389 }
390}
void setTotEvtNo(std::vector< int > i)
Definition: DataInfoSvc.h:29
string getDecayOptions() const
Definition: TJobInfo.h:18
vector< string > getJobOptions() const
Definition: TJobInfo.h:17
std::vector< int > getTotEvtNo() const
Definition: TJobInfo.h:19
string getBossVer() const
Definition: TJobInfo.h:16

◆ setBranchAddress()

StatusCode RootInterface::setBranchAddress ( const std::string  treename,
const std::string  branchname,
void *  addr,
int &  nb 
)
virtual

set branch address

Definition at line 496 of file RootInterface.cxx.

497{
498 log << MSG::DEBUG <<"RootInterface::setbranch address, treename: "<<treename <<", branch "<<branchname <<endreq;
499
500 branchnr=-1;
501
502 TTree * tree;
503
504 if(m_fileNum != 0){
505
506 tree = getOtherTree(treename);
507 }else{
508 tree = getTree(treename);
509 }
510
511 //TTree * tree = getTree("Dst");
512 if (!tree) {
513 log << MSG::ERROR << "Could not find tree " << treename <<endreq;
514 log << MSG::ERROR << "terminate the process handly"<<endreq;
515 exit(1);
516 return StatusCode::FAILURE;
517 }
518 tree->SetMakeClass(1); // necessary for separate branch reading (segv otherwise)!
519
520 // log << MSG::INFO <<"ok!!!!!!!!!!!!!11"<<endreq;
521 TBranch *b = tree->GetBranch(branchname.c_str());
522 if (!b) {
523 //tree->Print();
524 log << MSG::DEBUG << "Could not find branch xx" << branchname <<"xx"<<endreq;
525 return StatusCode::FAILURE;
526 }
527 // log << MSG::INFO <<"ok!!!!!!!!!!!!!22"<<endreq;
528 // log << MSG::INFO <<"ok!!!!!!!!!!!!!22"<<(*addr)<<endreq;
529 b->SetAddress(addr);
530 // log << MSG::INFO <<"ok!!!!!!!!!!!!!33"<<endreq;
531 branchnr=m_branchesRead->GetEntries();
532 // log << MSG::INFO <<"ok!!!!!!!!!!!!!44"<<endreq;
533 TClonesArray &a = *m_branchesRead;
534 m_branchesRead->Expand(branchnr+1);
535 a[branchnr]=b;
536 return StatusCode::SUCCESS;
537}
const double b
Definition: slope.cxx:9

Referenced by RootEventBaseCnv::createObj().

◆ setSelectFromTag()

virtual void RootInterface::setSelectFromTag ( bool  temp)
inlinevirtual

Definition at line 62 of file RootInterface.h.

62{m_selectFromTag = temp;}

Referenced by RootCnvSvc::initialize().

◆ setTagInputFile()

void RootInterface::setTagInputFile ( std::vector< std::string >  input)
virtual

Definition at line 179 of file RootInterface.cxx.

180{
181
182 for(int i=0; i<input.size(); i++)
183 {
184 log << MSG::DEBUG <<"input tag file: "<<i<<" "<<input[i]<<endreq;
185 m_tagInputFile.push_back(input[i]);
186 }
187}

Referenced by RootCnvSvc::initialize(), and RootEvtSelector::initialize().


The documentation for this class was generated from the following files: