StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fgtSingleEvents.C
1 /***************************************************************************
2  *
3  * $Id: fgtSingleEvents.C,v 1.2 2012/07/31 20:33:13 sgliske Exp $
4  * Author: S. Gliske, Jan 2011
5  *
6  ***************************************************************************
7  *
8  * Description: Make histograms of single events.
9  *
10  ***************************************************************************
11  *
12  * $Log: fgtSingleEvents.C,v $
13  * Revision 1.2 2012/07/31 20:33:13 sgliske
14  * updated to execute without errors with latest other CVS FGT software
15  *
16  * Revision 1.1 2012/01/31 09:26:18 sgliske
17  * StFgtQaMakers moved to StFgtPool
18  *
19  * Revision 1.4 2012/01/28 11:25:59 sgliske
20  * changed StFgtA2CMaker::setDb to setFgtDb
21  *
22  * Revision 1.3 2012/01/24 08:11:12 sgliske
23  * Bug fixes
24  *
25  * Revision 1.2 2012/01/24 06:27:35 sgliske
26  * debugged a bit more
27  *
28  * Revision 1.1 2012/01/24 03:32:19 sgliske
29  * creation
30  *
31  *
32  **************************************************************************/
33 
34 // forward declarations
35 class StChain;
36 class StFgtDbMaker;
37 class StFgtRawDaqReader;
38 class St_db_Maker;
39 class StDbConfigNode;
40 class StDbManager;
41 class StFgtA2CMaker;
42 class StFgtSingleEventQA;
43 
44 StChain *analysisChain = 0;
45 St_db_Maker *dbMkr = 0;
46 StFgtDbMaker *fgtDbMkr = 0;
47 StFgtRawDaqReader *daqRdr = 0;
48 StFgtSingleEventQA *qaMkr = 0;
49 StFgtA2CMaker *a2cMkr = 0;
50 
51 int fgtSingleEvents( const Char_t *filenameIn = "testfile.daq",
52  const Char_t *filenameOut = "testfile.root",
53  Int_t nevents = 200,
54  Bool_t isCosmic = 0,
55  Bool_t cutShortEvents = 0 ){
56 
57  LoadLibs();
58  Int_t ierr = 0;
59 
60  if( isCosmic )
61  cout << "Is Cosmic" << endl;
62  else
63  cout << "Is not cosmic" << endl;
64 
65  //
66  // START CONSTRUCTING THE CHAIN
67  //
68 
69  cout << "Constructing the chain" << endl;
70  analysisChain = new StChain("eemcAnalysisChain");
71 
72  std::string fgtDbMkrName = "";
73 
74  if( !isCosmic ){
75  // always cut short events if it is cosmic data
76  cutShortEvents = 1;
77 
78  cout << "Loading St_db_Maker" << endl;
79  gSystem->Load("libStDb_Tables.so");
80  gSystem->Load("StDbLib.so");
81  gSystem->Load("St_db_Maker");
82  gSystem->Load("StDbBroker");
83 
84  TString dir0 = "MySQL:StarDb";
85  TString dir1 = "$STAR/StarDb";
86  St_db_Maker *dbMkr = new St_db_Maker( "dbMkr", dir0, dir1 );
87  dbMkr->SetDateTime(20120115,1);
88 
89  cout << "Loading StFgtDbMaker" << endl;
90  gSystem->Load("StFgtDbMaker");
91 
92  cout << "Constructing StFgtDbMaker" << endl;
93  fgtDbMkr = new StFgtDbMaker( "fgtDbMkr" );
94  //fgtDbMkr->SetFlavor("ideal",""); // mapping is wrong, but at least the code runs...
95 
96  fgtDbMkrName = fgtDbMkr->GetName();
97  };
98 
99  //
100  // NOW THE OTHER READERS AND MAKERS
101  //
102 
103  cout << "Constructing the daq reader" << endl;
104  daqRdr = new StFgtRawDaqReader( "daqReader", filenameIn, fgtDbMkrName.data() );
105  daqRdr->setIsCosmic( isCosmic );
106  daqRdr->cutShortEvents( cutShortEvents );
107 
108  cout << "Constructing the A2C converter" << endl;
109  a2cMkr = new StFgtA2CMaker( "a2cMaker" );
110  //a2cMkr->setTimeBinMask( 0xFF );
111  a2cMkr->setAbsThres( 100 ); // set to below -4096 to skip cut
112  a2cMkr->setRelThres( 0 ); // set to zero to skip cut
113  if( !isCosmic )
114  a2cMkr->setFgtDb( fgtDbMkr->getDbTables() );
115  //a2cMkr->doRemoveOtherTimeBins( 0 );
116  //a2cMkr->doCutBadStatus( 0 );
117 
118  cout << "Constructing the QA Maker" << endl;
119  qaMkr = new StFgtSingleEventQA( "fgtSingleEventQA" );
120  qaMkr->setFilename( filenameOut );
121 
122  // debug
123  // analysisChain->ls(4);
124 
125  cout << "Initializing" << endl;
126  ierr = analysisChain->Init();
127 
128  if( ierr ){
129  cout << "Error initializing" << endl;
130  return;
131  };
132 
133  if( nevents < 0 )
134  nevents = 1<<30; // a big number
135 
136  cout << "max nevents = " << nevents << endl;
137  for( int i=0; i<nevents && !ierr; ++i ){
138 
139  if( i+1 % 100 == 0 )
140  cout << "\ton event number " << i << endl;
141 
142  //cout << "clear" << endl;
143  analysisChain->Clear();
144 
145  //cout << "make" << endl;
146  ierr = analysisChain->Make();
147 
148  };
149 
150  //
151  // Calls the ::Finish() method on all makers
152  //
153  cout << "finish" << endl;
154  analysisChain->Finish();
155 
156  cerr << "\tall done" << endl;
157  return;
158 };
159 
160 
161 // load the shared libraries
162 void LoadLibs() {
163  // common shared libraries
164 
165  gSystem->Load("libPhysics");
166  gSystem->Load("St_base");
167  gSystem->Load("StChain");
168  gSystem->Load("StFgtUtil");
169  gSystem->Load("StUtilities");
170  gSystem->Load("StEvent");
171  cout << "loaded StEvent library" << endl;
172 
173  gSystem->Load("RTS");
174  gSystem->Load("StFgtUtil");
175  gSystem->Load("StFgtDbMaker");
176  gSystem->Load("StFgtRawDaqReader");
177 // gSystem->Load("StFgtPedMaker");
178 // gSystem->Load("StFgtStatusMaker");
179  gSystem->Load("StFgtA2CMaker");
180  gSystem->Load("StFgtQaMakers");
181 };
void setRelThres(Float_t thres)
set to below -kFgtMaxAdc (-4096) to skip cut
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Finish()
Definition: StChain.cxx:85
void setFgtDb(StFgtDb *fgtDb)
set to zero to skip cut
virtual Int_t Make()
Definition: StChain.cxx:110
virtual const char * GetName() const
special overload
Definition: StMaker.cxx:237