StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
makeEEmcDisplay.C
1 //-- switch should be commented out when analysing real data
2 //#define MONTE_CARLO
3 
4 class StChain;
5 class St_db_Maker;
6 class StEEmcDb;
7 class StMuDstMaker;
8 class StEEmcA2EMaker;
12 class StEEmcMixMaker;
13 class StEEmcMixQAMaker;
14 class StSpinDbMaker;
15 class StEEmcPi0Maker;
16 class StEEmcDisplayMaker;
17 
18 //--
19 //-- globals
20 //--
21 StChain *mChain = 0;
22 St_db_Maker *mStarDatabase = 0;
23 StEEmcDb *mEEmcDatabase = 0;
24 StMuDstMaker *mMuDstMaker = 0;
28 
29 StEEmcPi0Maker *mEEpi0s = 0;
30 StEEmcDisplayMaker *mEEdisplay=0;
31 
32 //StEEmcPointFitMaker *mEEpoints = 0;
33 
34 //StEEmcMixMaker *mEEmixer = 0;
35 //StEEmcMixQAMaker *mEEmixqa = 0;
36 
37 //StSpinDbMaker *mSpinDb = 0;
38 
39 Int_t count = 0;
40 Int_t stat = 0;
41 
42 Int_t prescale = 1;
43 
44 TFile *file = 0;
45 
46 void makeEEmcDisplay( Int_t nevents = -1,
47  Char_t *name="mc.list",
48  Char_t *ofile="mc.root",
49  Char_t *path = "",
50  Int_t trigID=96261,
51  Int_t nfiles = 100
52  )
53 {
54 
55 
56  TString pathname = path;
57  pathname += name;
58 
59  std::cout << "------------ blah ----------------" << std::endl;
60 
61  //--
62  //-- Load shared libraries
63  //--
64  LoadLibs();
65 
66  //--
67  //-- Create the analysis chain
68  //--
69  mChain = new StChain("eemcAnalysisChain");
70 
71  //--
72  //-- MuDst maker for reading input
73  //--
74  mMuDstMaker = new StMuDstMaker(0,0,path,name,"MuDst",nfiles);
75  //mMuDstMaker->SetStatus("*",0);
76  //mMuDstMaker->SetStatus("MuEvent",1);
77  //mMuDstMaker->SetStatus("EmcAll",1);
78 
79  //--
80  //-- Connect to the STAR databse
81  //--
82  mStarDatabase = new St_db_Maker("StarDb", "MySQL:StarDb");
83 
84 
85 #ifdef MONTE_CARLO
86  //--
87  //-- Setup ideal gains for processing MC data
88  //--
89  mStarDatabase->SetFlavor("sim","eemcPMTcal");
90  mStarDatabase->SetFlavor("sim","eemcPIXcal");
91  mStarDatabase->SetFlavor("sim","eemcPMTped");
92  mStarDatabase->SetFlavor("sim","eemcPMTstat");
93  mStarDatabase->SetFlavor("sim","eemcPMTname");
94  mStarDatabase->SetFlavor("sim","eemcADCconf");
95  mStarDatabase->SetDateTime(20050101,0);
96 #endif
97 
98 
99  //--
100  //-- Initialize EEMC database
101  //--
102  new StEEmcDbMaker("eemcDb");
103  // -> setSectors(1,7);
104 
105  gMessMgr -> SwitchOff("D");
106  gMessMgr -> SwitchOn("I");
107 
108 
109 
110  //--
111  //-- Initialize SPIN database
112  //--
113  mSpinDb = new StSpinDbMaker("mSpinDb");
114 
115 
116 
117 #ifdef MONTE_CARLO
118  //#ifdef BLAH
119  //--
120  //-- Initialize slow simulator
121  //--
122  StEEmcSlowMaker *slowSim = new StEEmcSlowMaker("slowSim");
123  slowSim->setDropBad(0); // 0=no action, 1=drop chn marked bad in db
124  slowSim->setAddPed(0); // 0=no action, 1=ped offset from db
125  slowSim->setSmearPed(0); // 0=no action, 1=gaussian ped, width from db
126  slowSim->setOverwrite(1); // 0=no action, 1=overwrite muDst values
127 #endif
128 
129 
130  //--
131  //-- Energy to ADC maker
132  //--
133  mEEanalysis=new StEEmcA2EMaker("AandE");
134  mEEanalysis->database("eemcDb"); // sets db connection
135  mEEanalysis->source("MuDst",1); // sets mudst as input
136  mEEanalysis->threshold(3.0,0); // tower threshold
137  mEEanalysis->threshold(3.0,1); // pre1 threshold
138  mEEanalysis->threshold(3.0,2); // pre2 threshold
139  mEEanalysis->threshold(3.0,3); // post threshold
140  mEEanalysis->threshold(3.0,4); // smdu threshold
141  mEEanalysis->threshold(3.0,5); // smdv threshold
142 #ifdef MONTE_CARLO
143  mEEanalysis->scale(1.2); // scale energies by x1.2
144 #endif
145 /*
146  mEEanalysis->scale(1./1.56,4); // smd-u
147  mEEanalysis->scale(1./1.56,5); // smd-v
148 */
149 
150 
151  //--
152  //-- Cluster maker.
153  //--
154  mEEclusters=new StMyClusterMaker("mEEclusters", mEEanalysis, mMuDstMaker );
155  ((StMyClusterMaker*)mEEclusters)->setSmdSeedEnergy( 5.0/1000.0 );
156  ((StMyClusterMaker*)mEEclusters)->setSmdMinimumEnergy(0.5/1000.0 );
157  ((StMyClusterMaker*)mEEclusters)->setSmdMaximumSize(5);
158 
159  // ((StMyClusterMaker*)mEEclusters)->setDoBreakTruncation(true);
160  // ((StMyClusterMaker*)mEEclusters)->setSmdTruncationRatio(1.20);
161 
162  ((StMyClusterMaker*)mEEclusters)->setSmdMinimumStrips(3);
163  ((StMyClusterMaker*)mEEclusters)->setSeedEnergy(3.0);
164  ((StMyClusterMaker*)mEEclusters)->setMinimumEnergy(0.5);
165  ((StMyClusterMaker*)mEEclusters)->setFloor(0.20,3.5);
166 
167  //((StMyClusterMaker*)mEEclusters)->setEtaCut(1);
168  //((StMyClusterMaker*)mEEclusters)->setPhiCut(1);
169 
170 
171  mEEpoints=new StMyPointMaker("mEEpoints",mEEanalysis,mEEclusters);
172  // ((StMyPointMaker*)mEEpoints)->setSplit();
173  // ((StMyPointMaker*)mEEpoints)->setSplitMinimumET(6.0);
174  ((StMyPointMaker*)mEEpoints)->setSmdMinFraction(0.00);
175 
176  /***
177  mEEpi0s = new StEEmcPi0Maker("mEEpi0s",mEEanalysis,mEEclusters,mEEpoints);
178  mEEpi0s->addTrigger(96261);
179  mEEpi0s->setCheckTrigger(true);
180 ****/
181 
182  mEEdisplay=new StEEmcDisplayMaker("mEEdisplay");
183  mEEdisplay->adc2energy(mEEanalysis);
184  mEEdisplay->clusters(mEEclusters);
185  mEEdisplay->points(mEEpoints);
186  mEEdisplay->addTrigger(96261);
187  mEEdisplay->setCheckTrigger(true);
188 
189 
190  // output file for histograms/ttrees
191  file=new TFile(ofile,"RECREATE");
192  //mEEpi0s->setFile(file);
193  mEEdisplay->setFile(file);
194 
195 
196 
197  mChain->ls(3);
198  mChain->Init();
199 
200 
201 
202 
203  //-----------------------------------------------------------------
204  //--
205  //-- This is where the business happens. We loop over all events.
206  //-- when mChain -> Make() is called, ::Make() will be called on
207  //-- all of the makers created above.
208  //--
209  //
210 
211 
212  Int_t stat = 0; // error flag
213  Int_t count = 0; // event count
214  while ( stat == 0 ) {
215 
216 
217  printf("event=%d\n",count);
218 
219  //--
220  //-- Terminate once we reach nevents --
221  //--
222  if ( count++ >= nevents ) if ( nevents > 0 ) break;
223 
224  //--
225  //-- Call clear on all makers
226  //--
227  mChain -> Clear();
228 
229 
230  //--
231  //-- Process the event through all makers
232  //--
233  stat = mChain -> Make();
234  //std::cout << "Number of pairs = " << mEEpi0s->numberOfPairs() << std::endl;
235 
236  //--
237  //-- Set to printout on every 10th event
238  //--
239  // if ( (count%prescale) ) continue;
240 
241  std::cout << "------------------------------------------------";
242  std::cout << "event=" << count << std::endl;
243 
244  //--
245  //-- Print the number of hits in the towers, pre/postshower layers
246  //--
247  Int_t nhits[]={0,0,0,0,0,0};
248  for ( int i = 0; i < 4; i++ ) {
249  // std::cout << " layer=" << i
250  // << " nhits=" << mEEanalysis->numberOfHitTowers(i) << std::endl;
251  nhits[i]+=mEEanalysis->numberOfHitTowers(i);
252  }
253 
254  //--
255  //-- Print the total number of smd strips which fired
256  //--
257  Int_t nu=0,nv=0;
258  for ( Int_t sec=0;sec<12;sec++ )
259  {
260  nu+=mEEanalysis->numberOfHitStrips(sec,0);
261  nv+=mEEanalysis->numberOfHitStrips(sec,1);
262  }
263  nhits[4]=nu;
264  nhits[5]=nv;
265 
266 
267  //--
268  //-- Print number of clusters in each layer
269  //--
270  Int_t ncl[6]={0,0,0,0,0,0};
271  ncl[0]+=mEEclusters->numberOfClusters(0);
272  ncl[1]+=mEEclusters->numberOfClusters(1);
273  ncl[2]+=mEEclusters->numberOfClusters(2);
274  ncl[3]+=mEEclusters->numberOfClusters(3);
275  ncl[4]+=mEEclusters->numberOfClusters(4);
276  ncl[5]+=mEEclusters->numberOfClusters(5);
277 
278  const Char_t *lay[]={"tower:","pre1: ", "pre2: ", "post: ", "smdu: ", "smdv: "};
279  for ( Int_t i=0;i<6;i++ )
280  {
281  std::cout << lay[i] << " " << nhits[i] << " " << ncl[i] << std::endl;
282  }
283 
284  std::cout << "number of points: " << mEEpoints -> numberOfPoints() << std::endl;
285  // std::cout << "number of pairs: " << mEEmixer -> numberOfCandidates() << std::endl;
286 
287 
288 
289 
290 
291 
292 
293 
294  }
295  //--
296  //-----------------------------------------------------------------
297 
298 
299  //--
300  //-- For debugging purposes, it's often useful to print out the
301  //-- database
302  //--
303  mEEmcDatabase = (StEEmcDb*)mChain->GetDataSet("StEEmcDb");
304  if (mEEmcDatabase) mEEmcDatabase->exportAscii("dbdump.dat");
305 
306  //--
307  //-- Calls the ::Finish() method on all makers
308  //--
309  mChain -> Finish();
310 
311 
312  //--
313  //-- Output the QA histograms to disk
314  //--
315  file->cd();
316  //mEEpi0s->GetHistList()->Write();
317  //mEEpi0s->GetHistList()->Print();
318  mEEdisplay->tree()->Write();
319  file->Close();
320  delete file;
321 
322 
323  return;
324 
325 }
326 
327 void LoadLibs()
328 {
329  //-- Load muDst shared libraries --
330  gROOT -> LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
331  loadSharedLibraries();
332 
333  gSystem->Load("StDbLib");
334  gSystem->Load("StDbBroker");
335  gSystem->Load("St_db_Maker");
336  gSystem->Load("StEEmcUtil");
337  gSystem->Load("StEEmcDbMaker");
338  gSystem->Load("StEEmcSimulatorMaker");
339 
340  gSystem->Load("StEEmcA2EMaker");
341  gSystem->Load("StEEmcClusterMaker");
342  gSystem->Load("StEEmcPointMaker");
343  gSystem->Load("StEEmcPi0Mixer");
344  gSystem->Load("StEEmcDisplayMaker");
345 
346  gSystem->Load("StSpinDbMaker");
347 }
348 
349 
TFile * setFile(TFile *file)
EEmc ADC –&gt; energy maker.
void adc2energy(StEEmcA2EMaker *a)
void scale(Float_t s)
void source(const Char_t *, Int_t=0)
StEEmcGenericPointMaker * mEEpoints
void setAddPed(Bool_t a=true)
Add pedestal offsets from DB.
void Clear(Option_t *opts="")
User defined functions.
A maker for creating pi0 histograms.
Int_t numberOfHitStrips(Int_t sector, Int_t plane) const
Int_t numberOfHitTowers(Int_t layer) const
StEEmcA2EMaker * mEEanalysis
Int_t numberOfClusters(Int_t sector, Int_t layer) const
void threshold(Float_t cut, Int_t layer)
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
StEEmcGenericClusterMaker * mEEclusters
void setOverwrite(Bool_t o=true)
Overwrite the muDst values.
void clusters(StEEmcGenericClusterMaker *c)
void setDropBad(Bool_t d=true)
Drop bad channels marked as &quot;fail&quot; in DB.
void points(StEEmcGenericPointMaker *p)
A class for finding EEMC points.
void setSmearPed(Bool_t s=true)
Smear the pedestal with sigma from DB.
virtual Int_t Finish()
Definition: StMaker.cxx:776
A class for mixing pi0 candidates.
Slow simulator for EEMC.
void database(const Char_t *)
Set the name of the EEMC database, init obtains pointer.
void setCheckTrigger(Bool_t c=true)
void addTrigger(Int_t t)