StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
runDaq2Root.C
1 /***************************************************************************
2  *
3  * $Id: runDaq2Root.C,v 1.2 2012/06/20 20:21:35 sgliske Exp $
4  * Author: S. Gliske, Jan 2012
5  *
6  ***************************************************************************
7  *
8  * Description: runs StFgtDaq2Root on cosmic data.
9  *
10  ***************************************************************************
11  *
12  * $Log: runDaq2Root.C,v $
13  * Revision 1.2 2012/06/20 20:21:35 sgliske
14  * update
15  *
16  * Revision 1.1 2012/01/28 09:29:26 sgliske
17  * creation
18  *
19  *
20  **************************************************************************/
21 
22 // forward declarations
23 class StChain;
24 class StFgtRawDaqReader;
25 class StFgtDaq2RootMaker;
26 
27 StChain *analysisChain = 0;
28 StFgtRawDaqReader *daqRdr = 0;
29 StFgtDaq2RootMaker *rootMkr = 0;
30 
31 int runDaq2Root( const Char_t *filenameIn = "testfile.sfs",
32  const Char_t *filenameOut = "testfile.root",
33  Int_t nevents = -1,
34  Int_t date = 20120125,
35  Int_t time = 80350 // run 13025001 2012-01-25 08:03:34 GMT
36  ){
37 
38  LoadLibs();
39  Int_t ierr = 0;
40 
41  cerr << "Constructing the chain" << endl;
42  analysisChain = new StChain("eemcAnalysisChain");
43 
44  //
45  // Set up the date base
46  //
47  TString dir0 = "MySQL:StarDb";
48  TString dir1 = "$STAR/StarDb";
49  St_db_Maker *dbMkr = new St_db_Maker( "dbMkr", dir0, dir1 );
50 
51  dbMkr->SetDateTime(date,time);
52 
53  cout << "Loading StFgtDbMaker" << endl;
54  gSystem->Load("StFgtDbMaker");
55 
56  cout << "Constructing StFgtDbMaker" << endl;
57  fgtDbMkr = new StFgtDbMaker( "fgtDbMkr" );
58 
59  //
60  // Raw DAQ reader
61  //
62  cout << "Constructing the daq reader" << endl;
63  daqRdr = new StFgtRawDaqReader( "daqReader", filenameIn, "fgtDbMkr" );
64  daqRdr->setIsCosmic( 0 );
65  daqRdr->cutShortEvents( 1 );
66 
67  cerr << "Constructing the root makers" << endl;
68  rootMkr = new StFgtDaq2RootMaker( "daq2root", filenameOut );
69 
70  cerr << "Initializing" << endl;
71  ierr = analysisChain->Init();
72 
73  if( ierr ){
74  cerr << "Error initializing" << endl;
75  return;
76  };
77 
78  if( nevents < 0 )
79  nevents = 1<<29; // a big number
80 
81  for( int i=0; i<nevents && !ierr; ++i ){
82  analysisChain->Clear();
83  ierr = analysisChain->Make();
84  };
85 
86  //
87  // Calls the ::Finish() method on all makers
88  //
89  cerr << "finish" << endl;
90  analysisChain->Finish();
91 
92  cerr << "all done" << endl;
93  return;
94 };
95 
96 // load the shared libraries
97 void LoadLibs() {
98  // commong shared libraries
99  gROOT->Macro("loadMuDst.C");
100  //gROOT->Macro("LoadLogger.C");
101 
102  // and a few others
103  gSystem->Load("libStDb_Tables.so");
104  gSystem->Load("StDbLib");
105  gSystem->Load("StDbBroker");
106  gSystem->Load("St_db_Maker");
107  gSystem->Load("StStarLogger");
108  gSystem->Load("StFgtDbMaker");
109 
110  gSystem->Load("RTS");
111 
112  gSystem->Load("StFgtUtil");
113  gSystem->Load("StFgtRawDaqReader");
114  gSystem->Load("StFgtDaq2Root");
115 };
116 
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Finish()
Definition: StChain.cxx:85
virtual Int_t Make()
Definition: StChain.cxx:110