StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
runEEmcTiming.C
1 /******************************************************************************
2  **
3  ** runEEmcTiming.C
4  **
5  ** Arguements:
6  **
7  ** nevents - number of events to process
8  ** name - filename, format = <run>.list, eg 8081048.list, containing
9  ** a list of MuDst's from a single run
10  ** ofile - output histogram filename, suggested <run>.root. Output
11  ** will be saved in subdirectory timing_files/
12  **
13  ** tower_delay - the TCD phase delay (towers) for this run
14  ** mapmt_delay - the TCD phase delay (mapmt) for this run
15  **
16  **/
17 
18 class StChain;
19 class St_db_Maker;
20 class StEEmcDb;
21 class StMuDstMaker;
22 class StEEmcA2EMaker;
23 class StEEmcTimingMaker;
24 
25 //--
26 //-- globals
27 //--
28 StChain *mChain = 0;
29 St_db_Maker *mStarDatabase = 0;
30 StEEmcDb *mEEmcDatabase = 0;
31 StMuDstMaker *mMuDstMaker = 0;
32 StEEmcA2EMaker *mEEanalysis = 0;
33 
34 Int_t count = 0;
35 Int_t stat = 0;
36 
37 Int_t nzeros = 0;
38 Int_t max_zero_count = 100;
39 
40 
41 void runEEmcTiming( Int_t nevents = 30000,
42  Char_t *name = "8095104.list",
43  Char_t *ofile= "8095104.root",
44  Float_t tower_delay=19.,
45  Float_t mapmt_delay=65.,
46  Int_t nfiles = 1000
47  )
48 {
49 
50  Char_t *path = "./";
51  TString pathname = path;
52  pathname += name;
53 
54  //--
55  //-- Load shared libraries
56  //--
57  LoadLibs();
58 
59 
60  //--
61  //-- Create the analysis chain
62  //--
63  mChain = new StChain("eemcAnalysisChain");
64 
65 
66  //--
67  //-- MuDst maker for reading input
68  //--
69  mMuDstMaker = new StMuDstMaker(0,0,path,name,"MuDst",nfiles);
70  mMuDstMaker->SetStatus("*",0);
71  mMuDstMaker->SetStatus("MuEvent",1);
72  mMuDstMaker->SetStatus("EmcAll",1);
73 
74 
75  //--
76  //-- Connect to the STAR databse
77  //--
78  mStarDatabase = new St_db_Maker("StarDb", "MySQL:StarDb");
79 
80 
81 
82  //--
83  //-- Initialize EEMC database
84  //--
85  new StEEmcDbMaker("eemcdb");
86  gMessMgr -> SwitchOff("D");
87  gMessMgr -> SwitchOn("I");
88 
89 
90 
91 
92  //--
93  //-- Energy to ADC maker
94  //--
95  mEEanalysis=new StEEmcA2EMaker("AandE");
96  mEEanalysis->database("eemcdb"); // sets db connection
97  mEEanalysis->source("MuDst",1); // sets mudst as input
98  // set a negative threshold for each channel
99  for ( int ii=0;ii<6;ii++ ) mEEanalysis->threshold(-300.0,ii);
100 
101 
102 
103  StEEmcTimingMaker *timing=new StEEmcTimingMaker("timing");
104  timing->setRunNumber( atoi( name ) );
105  timing->setTiming( tower_delay, mapmt_delay );
106  timing->setTowerCuts( 25, 75 );
107  timing->setMapmtCuts( 50, 150 );
108 
109  mChain->ls(3);
110  mChain->Init();
111 
112  //-----------------------------------------------------------------
113  //--
114  //-- This is where the business happens. We loop over all events.
115  //-- when mChain -> Make() is called, ::Make() will be called on
116  //-- all of the makers created above.
117  //--
118 
119  Int_t stat = 0; // error flag
120  Int_t count = 0; // event count
121  while ( stat == 0 ) {
122 
123 
124  //--
125  //-- Terminate once we reach nevents --
126  //--
127  if ( count++ >= nevents ) if ( nevents > 0 ) break;
128 
129  //--
130  //-- Call clear on all makers
131  //--
132  mChain -> Clear();
133 
134 
135  //--
136  //-- Process the event through all makers
137  //--
138  stat = mChain -> Make();
139 
140 
141  //--
142  //-- Check that EEMC data are valid and terminate if not
143  //--
144  Int_t sum=0;
145  for ( Int_t i=0;i<720;i++ )
146  {
147  StEEmcTower t=mEEanalysis->tower(i,0);
148  sum+=t.raw();
149  }
150  if (sum==0)nzeros++;
151  if ( nzeros > max_zero_count ) {
152  std::cout << "ADC sum for EEMC zero for > max events" << std::endl;
153  break;
154  }
155 
156  //--
157  //-- Set to printout on every 10th event
158  //--
159  if ( (count%100) ) continue;
160 
161 
162  std::cout << "------------------------------------------------";
163  std::cout << "event=" << count << std::endl;
164 
165  //--
166  //-- Print the number of hits in the towers, pre/postshower layers
167  //--
168 
169  for ( Int_t i=0;i<720;i++ )
170  {
171  StEEmcTower t=mEEanalysis->tower(i,0);
172  std::cout << t.raw() << " ";
173  if ( !((i+1)%24) ) std::cout << std::endl;
174  }
175  std::cout << std::endl;
176 
177 
178 
179  }
180  //--
181  //-----------------------------------------------------------------
182 
183 
184  //--
185  //-- For debugging purposes, it's often useful to print out the
186  //-- database
187  //--
188  mEEmcDatabase = (StEEmcDb*)mChain->GetDataSet("StEEmcDb");
189  if (mEEmcDatabase) mEEmcDatabase->exportAscii("dbdump.dat");
190 
191  //--
192  //-- Calls the ::Finish() method on all makers
193  //--
194  mChain -> Finish();
195 
196  TString psfile=ofile;psfile.ReplaceAll("root","ps");
197  TString dtfile=ofile;dtfile.ReplaceAll("root","dat");
198 
199 // timing->dumpPDF( psfile );
200  timing->dumpAsciiFile(dtfile);
201 
202  //--
203  //-- Output the QA histograms to disk
204  //--
205  gSystem->mkdir("timing_files/");
206  TString myofile="timing_files/";
207  TFile *file=new TFile(myofile+ofile,"RECREATE");
208  timing->GetHistList()->Write();
209  file -> Close();
210  delete file;
211 
212 
213  return;
214 
215 }
216 
217 void LoadLibs()
218 {
219  //-- Load muDst shared libraries --
220  gROOT -> LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
221  loadSharedLibraries();
222 
223  gSystem->Load("StDbLib");
224  gSystem->Load("StDbBroker");
225  gSystem->Load("St_db_Maker");
226  gSystem->Load("StEEmcUtil");
227  gSystem->Load("StEEmcDbMaker");
228  gSystem->Load("StEEmcSimulatorMaker");
229 
230  gSystem->Load("StEEmcA2EMaker");
231  gSystem->Load("StEEmcTimingMaker");
232 
233 }
234 
EEmc ADC –&gt; energy maker.
void source(const Char_t *, Int_t=0)
void raw(Float_t r)
Set the raw ADC for this element.
Definition: StEEmcElement.h:17
void threshold(Float_t cut, Int_t layer)
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
Base class for representing tower, preshower and postshower elements.
Definition: StEEmcTower.h:11
void SetStatus(const char *arrType, int status)
StEEmcTower & tower(Int_t index, Int_t layer=0)
void Clear(Option_t *opts="")
User defined functions.
void database(const Char_t *)
Set the name of the EEMC database, init obtains pointer.