BOSS 6.6.4.p03
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 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
175 return sc;
176}

◆ 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 178 of file RootInterface.cxx.

178 {
179 static int i =0;
180 i ++;
181 log << MSG::DEBUG << "addOutput for Tree "<<treename<<endreq;
182 StatusCode sc=StatusCode::SUCCESS;
183 unsigned int treenr;
184 sc=getTreeNr(treename,treenr,true);
185 m_outputFilenames[treenr]=file;
186 m_outputFiles[treenr]=NULL;
187 m_outputTrees[treenr]=NULL;
188 m_splitModes[treenr]=split;
189 m_bufSizes[treenr]=bufsize;
190 m_compressionLevels[treenr]=compression;
191
192 return sc;
193}

◆ checkEndOfTree()

bool RootInterface::checkEndOfTree ( )
virtual

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

Definition at line 425 of file RootInterface.cxx.

425 {
426
427 if ( m_fileNum >= int(m_fileNames.size())-1 ){
428 if(m_inputFiles[0]){
429 delete m_inputFiles[0];
430 m_inputFiles[0] = NULL;
431 }
432 return true;
433 }
434
435 (*m_branchesRead).Clear();
436 unsigned int treenr;
437 getTreeNr("Event",treenr);
438 if(m_inputFiles[treenr]){
439 delete m_inputFiles[treenr];
440 m_inputFiles[treenr] = NULL;
441 }
442 if(m_inputTrees[treenr]){
443 //delete m_inputTrees[treenr];
444 m_inputTrees[treenr] = NULL;
445 }
446 if(m_otherTrees[m_fileNum]) delete m_otherTrees[m_fileNum];
447 if(inputFiles[m_fileNum]) delete inputFiles[m_fileNum];
448
449 m_ENDFILE = true;
450 m_fileNum++;
451
452 m_entries=-1;
453 m_EOF = false;
454 return false;
455}

Referenced by 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 195 of file RootInterface.cxx.

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

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 624 of file RootInterface.cxx.

626 {
627 log << MSG::INFO << "addOutput to single event" << endreq;
628 StatusCode status = StatusCode::FAILURE;
629 unsigned int treenr;
630
631 status = f_getTreeNr(treename, treenr, true);
632 m_single_compressionLevels[treenr] = compression;
633 m_single_outputFileNames[treenr] = file;
634 m_single_outputFiles[treenr] = NULL;
635 m_single_outputTrees[treenr] = NULL;
636 m_single_splitModes[treenr] = splitx;
637 m_single_bufSizes[treenr] = bufsize;
638
639 std::cout << "finish f_addOutput to single event" << std::endl;
640 return status;
641}
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 671 of file RootInterface.cxx.

674 {
675 log << MSG::INFO << "f_craeteBranch() create branch, tree name:"
676 << treename << ", branch name:" << branchname << endreq;
677
678 TBranch *branch;
679 unsigned int treenr;
680 StatusCode status = f_getTreeNr(treename, treenr);
681 if ( !status.isSuccess()) return status;
682
683 if ( !m_single_outputTrees[treenr])
684 status = this->f_createTree(treenr, treename);
685 if ( !status.isSuccess()) return status;
686
687 TTree* tree = m_single_outputTrees[treenr];
688 tree->SetUniqueID(treenr);
689
690 branch = tree->Branch(branchname.c_str(),
691 classname,
692 addr,
693 m_single_bufSizes[treenr],
694 m_single_splitModes[treenr]);
695
696}
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 643 of file RootInterface.cxx.

644 {
645 log << MSG::INFO << "f_createTree()" << endreq;
646
647 TDirectory *saveDir = gDirectory;
648
649 m_single_outputFiles[treenr] =
650 new TFile(m_single_outputFileNames[treenr].c_str(), "RECREATE");
651 if ( !m_single_outputFiles[treenr]->IsOpen()){
652 log << MSG::ERROR << "ROOT share file: "
653 << m_single_outputFileNames[treenr]
654 << " could not be opened for writing"
655 << endreq;
656 return StatusCode::FAILURE;
657 }
658 log << MSG::INFO << "f_createTree()::open share file for writing: "
659 << m_single_outputFileNames[treenr] << endreq;
660
661 m_single_outputFiles[treenr]->cd();
662 m_single_outputFiles[treenr]->SetCompressionLevel(m_single_compressionLevels[treenr]);
663
664 std::string title = treename + " for share";
665 m_single_outputTrees[treenr] = new TTree(treename.c_str(), title.c_str());
666 saveDir->cd();
667
668 return StatusCode::SUCCESS;
669}
char * c_str(Index i)
Definition: EvtCyclic3.cc:252

Referenced by f_createBranch().

◆ f_fillTrees()

StatusCode RootInterface::f_fillTrees ( )
virtual

Definition at line 728 of file RootInterface.cxx.

728 {
729 StatusCode status = StatusCode::FAILURE;
730 int byte;
731
732 std::vector<TTree *>::const_iterator tree;
733 for ( tree = m_single_outputTrees.begin(); tree < m_single_outputTrees.end(); tree++){
734 if ( (*tree) == NULL) continue;
735 byte = (*tree)->Fill();
736 (*tree)->Print();
737 log << MSG::INFO << "f_fillTrees() filled tree " << (*tree)->GetName()
738 << " with " << byte << " bytes!" << endreq;
739 status = StatusCode::SUCCESS;
740 }
741
742 return status;
743}

◆ f_finalize()

StatusCode RootInterface::f_finalize ( )
virtual

Definition at line 745 of file RootInterface.cxx.

745 {
746 log << MSG::INFO << "f_finalize() in RootInterface" << endreq;
747
748 std::vector<TTree *>::const_iterator tree;
749 for ( tree = m_single_outputTrees.begin(); tree < m_single_outputTrees.end(); tree++){
750 if ( *tree){
751 unsigned int treenr = (*tree)->GetUniqueID();
752 log << MSG::INFO << "tree id: " << treenr << endreq;
753 if ( m_single_outputFiles[treenr] ){
754 if ( !m_single_outputFiles[treenr]->IsOpen()){
755 log << MSG::ERROR << "f_finalize could not open share file for writing"
756 << endreq;
757 return StatusCode::FAILURE;
758 }
759 else {
760 log << MSG::INFO << "Closing file:" << treenr
761 << ", tree:" << (*tree)->GetName() << endreq;
762
763 TDirectory *saveDir = gDirectory;
764 m_single_outputFiles[treenr]->cd();
765 log <<MSG::INFO << "WREITE TO FILE BYTES: "
766 << m_single_outputFiles[treenr]->Write()
767 << endreq;
768 m_single_outputFiles[treenr]->Close();
769 saveDir->cd();
770 }
771 }
772 }
773 }
774 return StatusCode::SUCCESS;
775}

◆ f_getTreeNr()

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

Definition at line 698 of file RootInterface.cxx.

699 {
700
701 std::vector<std::string>::iterator where =
702 std::find(m_single_treenames.begin(), m_single_treenames.end(), treename);
703
704 if ( where == m_single_treenames.end()){
705 if ( doAdd){
706 treenr = m_single_treenames.size();
707 m_single_treenames.push_back(treename);
708
709 m_single_outputFileNames.push_back("");
710 m_single_outputFiles.push_back(NULL);
711 m_single_outputTrees.push_back(NULL);
712 m_single_splitModes.push_back(0);
713 m_single_bufSizes.push_back(0);
714 m_single_compressionLevels.push_back(0);
715
716 return StatusCode::SUCCESS;
717 }
718 else {
719 log << MSG::ERROR << "Invalid share tree name: "
720 << treename << endreq;
721 return StatusCode::FAILURE;
722 }
723 }
724 treenr = where - m_single_treenames.begin();
725 return StatusCode::SUCCESS;
726}

Referenced by f_addOutput(), and f_createBranch().

◆ fillTrees()

StatusCode RootInterface::fillTrees ( )
virtual

fill in all trees

Definition at line 596 of file RootInterface.cxx.

596 {
597 // loop over all trees and fill them
598 StatusCode sc=StatusCode::FAILURE;
599 int nb;
600 std::vector<TTree *>::const_iterator trees;
601 for (trees=m_outputTrees.begin();trees<m_outputTrees.end();trees++) {
602 if ((*trees)==NULL) continue;
603 int treenr=(*trees)->GetUniqueID();
604 if(m_outputFiles[treenr]->IsZombie()||(!m_outputFiles[treenr]->IsOpen())){
605 std::cout<<"RootInterface ERROR::The ROOT File:"<<m_outputFilenames[treenr].c_str()<<"status is false"<<std::endl;
606 exit(1);
607 }
608 nb=(*trees)->Fill();
609 m_outputFiles[treenr] = (*trees)->GetCurrentFile();
610 log << MSG::DEBUG << "filled tree "<<(* trees)->GetName() <<" with "<<nb<<" bytes"<< endreq;
611 if(nb==-1){
612 log << MSG::FATAL << "Error in filling tree "<<(* trees)->GetName() <<" with "<<nb<<" bytes"<< endreq;
613 exit(1);
614 }
615 sc=StatusCode::SUCCESS;
616 }
617 return sc;
618}

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 549 of file RootInterface.cxx.

550{
551 log << MSG::DEBUG <<"RootInterface::getBranchEntry: "<<", branch nr "<<nr <<", entry "<<entry <<endreq;
552
553 if (nr <0) return StatusCode::FAILURE;
554 TBranch *branch=(TBranch *)m_branchesRead->At(nr);
555 if (!branch) {
556 log << MSG::ERROR << "Could not find branch " << nr <<endreq;
557 return StatusCode::FAILURE;
558 }
559 nb=branch->GetEntry(entry);
560
561 if (nb<=0){
562 m_EOF=true;
563
564 }
565
566 return StatusCode::SUCCESS;
567}

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 527 of file RootInterface.cxx.

528{
529 log << MSG::DEBUG <<"RootInterface::getBranchEntry: "<<", branch nr "<<nr <<", entry "<<entry <<endreq;
530
531 if (nr <0) return StatusCode::FAILURE;
532 TBranch *branch=(TBranch *)m_branchesRead->At(nr);
533 if (!branch) {
534 log << MSG::ERROR << "Could not find branch " << nr <<endreq;
535 return StatusCode::FAILURE;
536 }
537
538 branch->SetAddress(addr);
539 nb=branch->GetEntry(entry);
540
541 if (nb<=0){
542 m_EOF=true;
543
544 }
545 return StatusCode::SUCCESS;
546}

◆ getCurrentFileName()

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

Definition at line 55 of file RootInterface.h.

55{ return m_currentFileName;}

Referenced by RootEventBaseCnv::createObj(), and MixerAlg::execute().

◆ 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().

◆ 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(), RootCnvSvc::RootCnvSvc(), and RootEventBaseCnv::RootEventBaseCnv().

◆ printJobInfo()

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

Definition at line 300 of file RootInterface.cxx.

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

485{
486 log << MSG::DEBUG <<"RootInterface::setbranch address, treename: "<<treename <<", branch "<<branchname <<endreq;
487
488 branchnr=-1;
489
490 TTree * tree;
491
492 if(m_fileNum != 0){
493
494 tree = getOtherTree(treename);
495 }else{
496 tree = getTree(treename);
497 }
498
499 //TTree * tree = getTree("Dst");
500 if (!tree) {
501 log << MSG::ERROR << "Could not find tree " << treename <<endreq;
502 log << MSG::ERROR << "terminate the process handly"<<endreq;
503 exit(1);
504 return StatusCode::FAILURE;
505 }
506 tree->SetMakeClass(1); // necessary for separate branch reading (segv otherwise)!
507
508 // log << MSG::INFO <<"ok!!!!!!!!!!!!!11"<<endreq;
509 TBranch *b = tree->GetBranch(branchname.c_str());
510 if (!b) {
511 //tree->Print();
512 log << MSG::DEBUG << "Could not find branch xx" << branchname <<"xx"<<endreq;
513 return StatusCode::FAILURE;
514 }
515 // log << MSG::INFO <<"ok!!!!!!!!!!!!!22"<<endreq;
516 // log << MSG::INFO <<"ok!!!!!!!!!!!!!22"<<(*addr)<<endreq;
517 b->SetAddress(addr);
518 // log << MSG::INFO <<"ok!!!!!!!!!!!!!33"<<endreq;
519 branchnr=m_branchesRead->GetEntries();
520 // log << MSG::INFO <<"ok!!!!!!!!!!!!!44"<<endreq;
521 TClonesArray &a = *m_branchesRead;
522 m_branchesRead->Expand(branchnr+1);
523 a[branchnr]=b;
524 return StatusCode::SUCCESS;
525}

Referenced by RootEventBaseCnv::createObj().


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