BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
JobInputRoot.cxx
Go to the documentation of this file.
1#include "TFile.h"
2#include "TTree.h"
3#include "GaudiKernel/SmartIF.h"
4#include "GaudiKernel/Property.h"
5#include "GaudiKernel/IJobOptionsSvc.h"
6#include "GaudiKernel/ISvcLocator.h"
7#include <cstdlib>
8
9namespace DetVerSvcPack {
10
11 int getRunFromFileList(const std::string& flist)
12 {
13 std::string::size_type p1 = flist.find('"') + 1;
14 std::string::size_type p2 = flist.find('"', p1);
15 std::string fn = flist.substr(p1, p2-p1);
16
17 TFile* file = TFile::Open(fn.c_str(), "READ");
18 TTree* tree = (TTree*)file->Get("Event");
19 tree->SetMakeClass(1);
20 int run;
21 tree->SetBranchAddress("m_runId", &run);
22 tree->GetEntry(0);
23
24 return abs(run);
25 }
26
27 int funcInputRoot(ISvcLocator* svcLct)
28 {
29 SmartIF<IJobOptionsSvc> iSvc(svcLct->service("JobOptionsSvc"));
30 if ( iSvc.isValid() ) {
31 const std::vector<const Property*>* ps = iSvc->getProperties("EventCnvSvc");
32 std::vector<const Property*>::const_iterator it, end = ps->end();
33 for ( it = ps->begin(); it != end; ++it ) {
34 if ( (*it)->name() == "digiRootInputFile" ) {
35 return getRunFromFileList( (*it)->toString() );
36 }
37 }
38 }
39 return -1;
40 }
41
42 extern int (*pf_helper)(ISvcLocator*);
43
44 //initialize function pointer: pf_helper
48 }
49 };
50
51 InputRootInit init;
52}
char * file
Definition: DQA_TO_DB.cxx:15
int funcInputRoot(ISvcLocator *svcLct)
int getRunFromFileList(const std::string &flist)
int(* pf_helper)(ISvcLocator *)
Definition: DetVerSvc.cxx:9
InputRawInit init
Definition: JobInputRaw.cxx:29