StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
runEEmcPi0Analysis.C
1 //--
2 //-- runEEmcPointMaker.C
3 //--
4 //-- example script for running the point maker. The macro
5 //-- will process the first nevents of the MuDst (or list of MuDst's).
6 //-- if nevents is negative, the macro will process all events in the
7 //-- mudst.
8 //--
9 
10 //-- switch should be commented out when analysing real data
11 //#define MONTE_CARLO
12 #define NEW
13 
14 class StChain;
15 class St_db_Maker;
16 class StEEmcDb;
17 class StMuDstMaker;
18 class StEEmcA2EMaker;
19 class StEEmcClusterMaker;
20 class StEEmcPointMaker;
22 class StEEmcMixMaker;
23 class StEEmcMixQAMaker;
24 class StSpinDbMaker;
25 
26 //--
27 //-- globals
28 //--
29 StChain *mChain = 0;
30 St_db_Maker *mStarDatabase = 0;
31 StEEmcDb *mEEmcDatabase = 0;
32 StMuDstMaker *mMuDstMaker = 0;
33 StEEmcA2EMaker *mEEanalysis = 0;
34 StEEmcClusterMaker *mEEclusters = 0;
35 StEEmcPointMaker *mEEpoints = 0;
36 //StEEmcPointFitMaker *mEEpoints = 0;
37 
38 StEEmcMixMaker *mEEmixer = 0;
39 StEEmcMixQAMaker *mEEmixqa = 0;
40 
41 StSpinDbMaker *mSpinDb = 0;
42 
43 Int_t count = 0;
44 Int_t stat = 0;
45 
46 Int_t prescale = 100;
47 
48 void runEEmcPi0Analysis( Int_t nevents = -1,
49  Char_t *name = "test.lis",
50  Char_t *ofile= "test.root",
51  Char_t *path = "./",
52  Int_t nfiles = 100
53  )
54 {
55 
56  TString pathname = path;
57  pathname += name;
58 
59  //--
60  //-- Load shared libraries
61  //--
62  LoadLibs();
63 
64 
65  //--
66  //-- Create the analysis chain
67  //--
68  mChain = new StChain("eemcAnalysisChain");
69 
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  //--
81  //-- Connect to the STAR databse
82  //--
83  mStarDatabase = new St_db_Maker("StarDb", "MySQL:StarDb");
84 
85 
86 #ifdef MONTE_CARLO
87  //--
88  //-- Setup ideal gains for processing MC data
89  //--
90  mStarDatabase->SetFlavor("sim","eemcPMTcal");
91  mStarDatabase->SetFlavor("sim","eemcPIXcal");
92  mStarDatabase->SetFlavor("sim","eemcPMTped");
93  mStarDatabase->SetFlavor("sim","eemcPMTstat");
94  mStarDatabase->SetFlavor("sim","eemcPMTname");
95  mStarDatabase->SetFlavor("sim","eemcADCconf");
96  mStarDatabase->SetDateTime(20050101,0);
97 #endif
98 
99  //--
100  //-- Initialize EEMC database
101  //--
102  new StEEmcDbMaker("eemcDb");
103  // -> setSectors(1,7);
104  gMessMgr -> SwitchOff("D");
105  gMessMgr -> SwitchOn("I");
106 
107 
108  //--
109  //-- Initialize SPIN database
110  //--
111  mSpinDb = new StSpinDbMaker("mSpinDb");
112 
113 
114 #ifdef MONTE_CARLO
115  //--
116  //-- Initialize slow simulator
117  //--
118  StEEmcSlowMaker *slowSim = new StEEmcSlowMaker("slowSim");
119  slowSim->setDropBad(0); // 0=no action, 1=drop chn marked bad in db
120  slowSim->setAddPed(0); // 0=no action, 1=ped offset from db
121  slowSim->setSmearPed(0); // 0=no action, 1=gaussian ped, width from db
122  slowSim->setOverwrite(1); // 0=no action, 1=overwrite muDst values
123 #endif
124 
125 
126  //--
127  //-- Energy to ADC maker
128  //--
129  mEEanalysis=new StEEmcA2EMaker("AandE");
130  mEEanalysis->database("eemcDb"); // sets db connection
131  mEEanalysis->source("MuDst",1); // sets mudst as input
132  mEEanalysis->threshold(3.0,0); // tower threshold
133  mEEanalysis->threshold(3.0,1); // pre1 threshold
134  mEEanalysis->threshold(3.0,2); // pre2 threshold
135  mEEanalysis->threshold(3.0,3); // post threshold
136  mEEanalysis->threshold(3.0,4); // smdu threshold
137  mEEanalysis->threshold(3.0,5); // smdv threshold
138 //mEEanalysis->scale(1.2); // scale energies by x1.2
139 /*
140  mEEanalysis->scale(1./1.56,4); // smd-u
141  mEEanalysis->scale(1./1.56,5); // smd-v
142 */
143 
144 
145  //--
146  //-- Some simple QA histograms
147  //--
148  StEEmcQAMaker *eemcQA=new StEEmcQAMaker("eeqa");
149  eemcQA->analysis("AandE");
150  eemcQA->mudst("MuDst");
151  eemcQA->nVertexMin=0; // cut on min number of verticies
152  eemcQA->nVertexMax=999; // cut on max number of verticies
153  eemcQA->trigger(96261); // HT2 slow
154  eemcQA->softTrigger(3.36);
155 
156 
157  //--
158  //-- Cluster maker. Generates tower, preshower, postshower clusters
159  //-- (using Minesweeper algo) and smd clusters (seed strip w/ truncation).
160  //--
161  mEEclusters=new StEEmcClusterMaker("mEEclusters");
162  mEEclusters->analysis("AandE");
163  mEEclusters->seedEnergy(0.8,0); // tower seed energy
164  mEEclusters->seedEnergy(5./1000.,4); // 2 MeV smd-u strip
165  mEEclusters->seedEnergy(5./1000.,5); // 2 MeV smd-v strip
166  mEEclusters->setSeedFloor(2.0); // floating seed threshold near clusters
167  mEEclusters->setMaxExtent(5); // maximum distance from seed strip
168  mEEclusters->suppress(0); // disallows seeds in two strips adjacent to any cluster
169 
170 
171  //--
172  //-- Point maker. Matches pairs of smd clusters to active towers.
173  //-- Energy is divided between points using a tower energy-sharing
174  //-- vs position function.
175  //--
176  mEEpoints=new StEEmcPointMaker("mEEpoints");
177  mEEpoints->analysis("AandE");
178  mEEpoints->clusters("mEEclusters");
179  mEEpoints->setEnergyMode(0);
180 
181  //--
182  //-- Pi0 mixer, takes the points identified above and mixes pi0 pairs.
183  //--
184  mEEmixer = new StEEmcMixMaker("mEEmixer");
185  mEEmixer -> mudst("MuDst");
186  mEEmixer -> analysis("AandE");
187  mEEmixer -> points("mEEpoints");
188  for ( Int_t i=0;i<12;i++ ) // activate all 12 sectors
189  mEEmixer->sector(i);
190  mEEmixer->trigger(96261); // EHT2
191 
192  mEEpi0analysis=new StEEmcPi0Analysis("pi0analy");
193  mEEpi0analysis->trigger(96261);
194  mEEpi0analysis->minbias(96011);
195  mEEpi0analysis->mudst("MuDst");
196  mEEpi0analysis->points("mEEpoints");
197  mEEpi0analysis->mixer("mEEmixer");
198  mEEpi0analysis->analysis("AandE");
199  mEEpi0analysis->spin("mSpinDb");
200 
201  mEEmixer2 = new StEEmcMixMaker("mEEmixer2");
202  mEEmixer2 -> mudst("MuDst");
203  mEEmixer2 -> analysis("AandE");
204  mEEmixer2 -> points("mEEpoints");
205  for ( Int_t i=0;i<12;i++ ) // activate all 12 sectors
206  mEEmixer2->sector(i);
207  mEEmixer2->trigger(96251); // EHT2
208 
209  mEEpi0analysis2=new StEEmcPi0Analysis("pi0analy2");
210  mEEpi0analysis2->trigger(96251);
211  mEEpi0analysis2->minbias(96011);
212  mEEpi0analysis2->mudst("MuDst");
213  mEEpi0analysis2->points("mEEpoints");
214  mEEpi0analysis2->mixer("mEEmixer");
215  mEEpi0analysis2->analysis("AandE");
216  mEEpi0analysis2->spin("mSpinDb");
217 
218 
219  mEEmixer3 = new StEEmcMixMaker("mEEmixer3");
220  mEEmixer3 -> mudst("MuDst");
221  mEEmixer3 -> analysis("AandE");
222  mEEmixer3 -> points("mEEpoints");
223  for ( Int_t i=0;i<12;i++ ) // activate all 12 sectors
224  mEEmixer3->sector(i);
225  mEEmixer3->trigger(96282); // jet patch 2
226 
227  mEEpi0analysis3=new StEEmcPi0Analysis("pi0analy3");
228  mEEpi0analysis3->trigger(96282); // jet patch 2
229  mEEpi0analysis3->minbias(96011);
230  mEEpi0analysis3->mudst("MuDst");
231  mEEpi0analysis3->points("mEEpoints");
232  mEEpi0analysis3->mixer("mEEmixer");
233  mEEpi0analysis3->analysis("AandE");
234  mEEpi0analysis3->spin("mSpinDb");
235  mEEpi0analysis3->cuts()->setTowerCut(0.0);
236 
237  mEEmixer4 = new StEEmcMixMaker("mEEmixer4");
238  mEEmixer4 -> mudst("MuDst");
239  mEEmixer4 -> analysis("AandE");
240  mEEmixer4 -> points("mEEpoints");
241  for ( Int_t i=0;i<12;i++ ) // activate all 12 sectors
242  mEEmixer4->sector(i);
243  mEEmixer4->trigger(96272); // jet patch 2
244 
245  mEEpi0analysis4=new StEEmcPi0Analysis("pi0analy4");
246  mEEpi0analysis4->trigger(96272); // jet patch 2
247  mEEpi0analysis4->minbias(96011);
248  mEEpi0analysis4->mudst("MuDst");
249  mEEpi0analysis4->points("mEEpoints");
250  mEEpi0analysis4->mixer("mEEmixer");
251  mEEpi0analysis4->analysis("AandE");
252  mEEpi0analysis4->spin("mSpinDb");
253  mEEpi0analysis4->cuts()->setTowerCut(0.0);
254 
255  mChain->ls(3);
256  mChain->Init();
257 
258  //-----------------------------------------------------------------
259  //--
260  //-- This is where the business happens. We loop over all events.
261  //-- when mChain -> Make() is called, ::Make() will be called on
262  //-- all of the makers created above.
263  //--
264 
265  Int_t stat = 0; // error flag
266  Int_t count = 0; // event count
267  while ( stat == 0 ) {
268 
269 
270  //--
271  //-- Terminate once we reach nevents --
272  //--
273  if ( count++ >= nevents ) if ( nevents > 0 ) break;
274 
275  //--
276  //-- Call clear on all makers
277  //--
278  mChain -> Clear();
279 
280 
281  //--
282  //-- Process the event through all makers
283  //--
284  stat = mChain -> Make();
285 
286  //--
287  //-- Set to printout on every 10th event
288  //--
289  if ( (count%prescale) ) continue;
290 
291  std::cout << "------------------------------------------------";
292  std::cout << "event=" << count << std::endl;
293 
294  //--
295  //-- Print the number of hits in the towers, pre/postshower layers
296  //--
297  Int_t nhits[]={0,0,0,0,0,0};
298  for ( int i = 0; i < 4; i++ ) {
299  // std::cout << " layer=" << i
300  // << " nhits=" << mEEanalysis->numberOfHitTowers(i) << std::endl;
301  nhits[i]+=mEEanalysis->numberOfHitTowers(i);
302  }
303 
304  //--
305  //-- Print the total number of smd strips which fired
306  //--
307  Int_t nu=0,nv=0;
308  for ( Int_t sec=0;sec<12;sec++ )
309  {
310  nu+=mEEanalysis->numberOfHitStrips(sec,0);
311  nv+=mEEanalysis->numberOfHitStrips(sec,1);
312  }
313  nhits[4]=nu;
314  nhits[5]=nv;
315 
316 
317  //--
318  //-- Print number of clusters in each layer
319  //--
320  Int_t ncl[6]={0,0,0,0,0,0};
321  for ( Int_t i=0;i<12;i++ )
322  {
323  ncl[0]+=mEEclusters->numberOfClusters(i,0);
324  ncl[1]+=mEEclusters->numberOfClusters(i,1);
325  ncl[2]+=mEEclusters->numberOfClusters(i,2);
326  ncl[3]+=mEEclusters->numberOfClusters(i,3);
327  ncl[4]+=mEEclusters->numberOfSmdClusters(i,0);
328  ncl[5]+=mEEclusters->numberOfSmdClusters(i,1);
329  }
330 
331  const Char_t *lay[]={"tower:","pre1: ", "pre2: ", "post: ", "smdu: ", "smdv: "};
332  for ( Int_t i=0;i<6;i++ )
333  {
334  std::cout << lay[i] << " " << nhits[i] << " " << ncl[i] << std::endl;
335  }
336 
337  // std::cout << "number of points: " << mEEpoints -> numberOfPoints() << std::endl;
338  std::cout << "number of pairs: " << mEEmixer -> numberOfCandidates() << std::endl;
339 
340 
341 
342  }
343  //--
344  //-----------------------------------------------------------------
345 
346 
347  //--
348  //-- For debugging purposes, it's often useful to print out the
349  //-- database
350  //--
351  mEEmcDatabase = (StEEmcDb*)mChain->GetDataSet("StEEmcDb");
352  if (mEEmcDatabase) mEEmcDatabase->exportAscii("dbdump.dat");
353 
354  //--
355  //-- Calls the ::Finish() method on all makers
356  //--
357  mChain -> Finish();
358 
359 
360  //--
361  //-- Output the QA histograms to disk
362  //--
363  TFile *file=new TFile(ofile,"RECREATE");
364  file->mkdir("QA");
365  file->cd("QA");
366  eemcQA -> GetHistList() -> Write();
367  file->mkdir("eht2");
368  file->cd("eht2");
369  mEEpi0analysis->GetHistList()->Write();
370  file->cd();
371  file->mkdir("eht1");
372  file->cd("eht1");
373  mEEpi0analysis2->GetHistList()->Write();
374  file->cd();
375  file->mkdir("ejp2");
376  file->cd("ejp2");
377  mEEpi0analysis3->GetHistList()->Write();
378  file->cd();
379  file->mkdir("ejp1");
380  file->cd("ejp1");
381  mEEpi0analysis4->GetHistList()->Write();
382  file->Close();
383 
384 
385  delete file;
386 
387 
388  return;
389 
390 }
391 
392 void LoadLibs()
393 {
394  //-- Load muDst shared libraries --
395  gROOT -> LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
396  loadSharedLibraries();
397 
398  gSystem->Load("StDbLib");
399  gSystem->Load("StDbBroker");
400  gSystem->Load("St_db_Maker");
401  gSystem->Load("StEEmcUtil");
402  gSystem->Load("StEEmcDbMaker");
403  gSystem->Load("StEEmcSimulatorMaker");
404 
405 #ifdef NEW
406  gSystem->Load("StEEmcA2EMaker");
407  gSystem->Load("StEEmcClusterMaker");
408  gSystem->Load("StEEmcPointMaker");
409  gSystem->Load("StEEmcPi0Mixer");
410 #else
411  gSystem->Load("StMaxStripPi0");
412 #endif
413 
414  gSystem->Load("StSpinDbMaker");
415 }
416 
void analysis(const Char_t *name)
Set the name of the ADC–&gt;E maker.
EEmc ADC –&gt; energy maker.
void setSeedFloor(Float_t f=2.0)
Int_t numberOfClusters(Int_t sec, Int_t layer) const
Return number of clusters for a given sector, layer.
void mudst(const Char_t *name)
sets pointer to the muDst maker
Int_t numberOfSmdClusters(Int_t sec, Int_t plane) const
Return number of smd clusters for a given sector, plane.
A maker for creating pi0 histograms.
void source(const Char_t *, Int_t=0)
void trigger(Int_t t)
add a trigger to the trigger list
Definition: StEEmcQAMaker.h:28
void setAddPed(Bool_t a=true)
Add pedestal offsets from DB.
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StMaker.cxx:634
void trigger(Int_t trigger)
void setMaxExtent(Int_t m)
Maximum distance around seed strip to cluster smd strips.
void analysis(const Char_t *name)
sets pointer to adc–&gt;energy maker
void analysis(const Char_t *name)
Set adc to energy maker.
A maker for creating pi0 histograms.
Int_t numberOfHitStrips(Int_t sector, Int_t plane) const
void sector(Int_t sector)
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Definition: TDataSet.cxx:893
Class for building points from smd clusters.
Int_t numberOfHitTowers(Int_t layer) const
void threshold(Float_t cut, Int_t layer)
void setEnergyMode(Int_t mode)
void suppress(Int_t n=2)
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
virtual Int_t Make()
void setOverwrite(Bool_t o=true)
Overwrite the muDst values.
void setDropBad(Bool_t d=true)
Drop bad channels marked as &quot;fail&quot; in DB.
StSpinDbMaker(const char *name="SpinDbMaker")
experts only
void clusters(const Char_t *name)
Set cluster maker.
Example of QA histograming using the StEEmcA2EMaker.
Definition: StEEmcQAMaker.h:12
A class for finding EEMC points.
void SetStatus(const char *arrType, int status)
void setSmearPed(Bool_t s=true)
Smear the pedestal with sigma from DB.
void seedEnergy(Float_t energy, Int_t layer=0)
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.
Int_t nVertexMax
Cuts on primary vertex (see constructor for defaults)
Definition: StEEmcQAMaker.h:30
A cluster maker for the EEMC.