StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
runEEmcMcPi0.C
1 //--
2 //-- runEEmcMcPi0.C
3 //-- used by Monte-Carlo and pythia sample.
4 //-- example script for running the EEMC pi0 finder. 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 //-- author: Weihong He
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 StMcOutputMaker;
19 class StEEmcA2EMaker;
21 class StEEmcIUPointMaker;
22 //class StEEmcPointFitMaker;
23 class StEEmcIUMixMaker;
24 //class StEEmcMixQAMaker;
25 class StSpinDbMaker;
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 StMcOutputMaker *mySputMk = 0;
35 StEEmcIUClusterMaker *mEEclusters = 0;
36 StEEmcIUPointMaker *mEEpoints = 0;
37 //StEEmcPointFitMaker *mEEpoints = 0;
38 
39 StEEmcIUMixMaker *mEEmixer = 0;
40 //StEEmcMixQAMaker *mEEmixqa = 0;
41 StSpinDbMaker *mSpinDb = 0;
42 
43 Int_t count = 0;
44 Int_t stat = 0;
45 
46 Int_t prescale = 100;
47 
48 void runEEmcMcPi0( Int_t nevents = 1000,
49  Char_t *name = "dipi0_10000evts.MuDst.root",
50  //Char_t *name = "/star/data05/scratch/hew/JanSample/pi0_set2.MuDst.root",
51  Char_t *ofile= "test.root",
52  Char_t *path = "/star/u/hew/pi0finder/ezGames/backyard/multiphoton/",
53  //Char_t *path = "",///star/data13/reco/pp200/pythia6_205/25_35gev/cdf_a/y2004y/gheisha_on/p05ih/",
54  Int_t nfiles = 100)
55 
56 {
57 
58  TString pathname = path;
59  pathname += name;
60  TString fileG=name;
61  fileG.ReplaceAll("MuDst","geant");
62 
63  fileG=path+fileG;
64 
65  //--
66  //-- Load shared libraries
67  //--
68  LoadLibs();
69  gSystem->Load("StMcEvent");
70  gSystem->Load("StMcEventMaker");
71 
72  //assert(!gSystem->Load("StEEmcMcReadMaker"));
73 
74  //--
75  //-- Create the analysis chain
76  //--
77  mChain = new StChain("eemcAnalysisChain");
78 
79  StIOMaker* ioMaker = new StIOMaker();
80 
81  printf("%s\n",fileG.Data());
82  ioMaker->SetFile(fileG);
83 
84  ioMaker->SetIOMode("r");
85  ioMaker->SetBranch("*",0,"1"); //deactivate all branches
86  ioMaker->SetBranch("geantBranch",0,"r"); //activate geant Branch
87  ioMaker->SetBranch("minimcBranch",0,"r"); //activate geant Branch
88 
89 
90  //--
91  //-- MuDst maker for reading input
92  //--
93  mMuDstMaker = new StMuDstMaker(0,0,path,name,"MuDst",nfiles);
94  mMuDstMaker->SetStatus("*",0);
95  mMuDstMaker->SetStatus("MuEvent",1);
96  mMuDstMaker->SetStatus("EmcAll",1);
97 
98  StMcEventMaker *mcEventMaker = new StMcEventMaker();
99  mcEventMaker->doPrintEventInfo = false;
100  mcEventMaker->doPrintMemoryInfo = false;
101 
102  //--
103  //-- Connect to the STAR databse
104  //--
105  mStarDatabase = new St_db_Maker("StarDb", "MySQL:StarDb");
106 
107 
108 #ifdef MONTE_CARLO
109  //--
110  //-- Setup ideal gains for processing MC data
111  //--
112 
113  mStarDatabase->SetFlavor("sim","eemcPMTcal");
114  mStarDatabase->SetFlavor("sim","eemcPIXcal");
115  mStarDatabase->SetFlavor("sim","eemcPMTped");
116  mStarDatabase->SetFlavor("sim","eemcPMTstat");
117  mStarDatabase->SetFlavor("sim","eemcPMTname");
118  mStarDatabase->SetFlavor("sim","eemcADCconf");
119  mStarDatabase->SetDateTime(20050101,0);
120 
121 #endif
122 
123  //--
124  //-- Initialize EEMC database
125  //--
126  new StEEmcDbMaker("eemcDb");
127  gMessMgr -> SwitchOff("D");
128  gMessMgr -> SwitchOn("I");
129 
130  mSpinDb = new StSpinDbMaker("mSpinDb");
131 
132 #ifdef MONTE_CARLO
133  //--
134  //-- Initialize slow simulator
135  //--
136  StEEmcSlowMaker *slowSim = new StEEmcSlowMaker("slowSim");
137  slowSim->setDropBad(0); // 0=no action, 1=drop chn marked bad in db
138  slowSim->setAddPed(0); // 0=no action, 1=ped offset from db
139  slowSim->setSmearPed(0); // 0=no action, 1=gaussian ped, width from db
140  slowSim->setOverwrite(1); // 0=no action, 1=overwrite muDst values
141  slowSim->setNpePerMipSmd(1.0);
142 
143 #endif
144 
145 
146  //--
147  //-- Energy to ADC maker
148  //--
149  mEEanalysis=new StEEmcA2EMaker("AandE");
150  mEEanalysis->database("eemcDb"); // sets db connection
151  mEEanalysis->source("MuDst",1); // sets mudst as input
152  mEEanalysis->threshold(3.0,0); // tower threshold
153  mEEanalysis->threshold(3.0,1); // pre1 threshold
154  mEEanalysis->threshold(3.0,2); // pre2 threshold
155  mEEanalysis->threshold(3.0,3); // post threshold
156 //mEEanalysis->threshold(4,5.0); // smdu threshold
157 //mEEanalysis->threshold(5,5.0); // smdv threshold
158  mEEanalysis->scale(1.3); // scale energies by x1.2
159 
160 
161  //--
162  //-- Some simple QA histograms
163  //--
164  StEEmcQAMaker *eemcQA=new StEEmcQAMaker("eeqa");
165  eemcQA->analysis("AandE");
166  eemcQA->mudst("MuDst");
167 //eemcQA->trigger(96261); // add specified trigger to list
168  eemcQA->nVertexMin=0; // cut on min number of verticies
169  eemcQA->nVertexMax=999; // cut on max number of verticies
170 
171 
172  //--
173  //-- Cluster maker. Generates tower, preshower, postshower clusters
174  //-- (using Minesweeper algo) and smd clusters (seed strip w/ truncation).
175  //--
176  mEEclusters=new StEEmcIUClusterMaker("mEEclusters");
177  mEEclusters->analysis("AandE");
178  mEEclusters->seedEnergy(0.8,0); // tower seed energy
179  mEEclusters->seedEnergy(1.5/1000.,4); // 2 MeV smd-u strip
180  mEEclusters->seedEnergy(1.5/1000.,5); // 2 MeV smd-v strip
181  mEEclusters->setSeedFloor(1.0); // floating seed threshold near clusters
182  mEEclusters->setMaxExtent(3); // maximum distance from seed strip
183 //mEEclusters->suppress(); // disallows seeds in two strips adjacent to any cluster
184 
185  //--
186  //-- Point maker. Matches pairs of smd clusters to active towers.
187  //-- Energy is divided between points using a tower energy-sharing
188  //-- vs position function.
189  //--
190  mEEpoints=new StEEmcIUPointMaker("mEEpoints");
191  //mEEpoints=new StEEmcPointFitMaker("mEEpoints");
192  mEEpoints->analysis("AandE");
193  mEEpoints->clusters("mEEclusters");
194  mEEpoints->setEnergyMode(0);
195  mEEpoints->setLimit(10);
196  // mEEpoints -> doPermutations(false);
197 
198  // output maker tracker
199  HList=new TObjArray;
200  StMcOutputMaker *mySputMk=new StMcOutputMaker("mcRead");
201  mySputMk->SetHList(HList);
202 
203 
204  //--
205  //-- Pi0 mixer, takes the points identified above and mixes pi0 pairs.
206  //--
207  mEEmixer = new StEEmcIUMixMaker("mEEmixer");
208  mEEmixer -> mudst("MuDst");
209  mEEmixer -> analysis("AandE");
210  mEEmixer -> points("mEEpoints");
211  for ( Int_t i=0;i<12;i++ ) // activate all 12 sectors
212  mEEmixer->sector(i);
213 //mEEmixer->trigger(96251); // specify trigger id(s) to process
214 //for Monte-Carlo sample, fix vertex to zero. Otherwise, comment it out.
215  mEEmixer->fixedVertex(0.,0.,0.); // fixes the vertex positiion
216 
217 
218  //pi0 analysis
219  mEEpi0analysis=new StEEmcIUPi0Analysis("pi0analy");
220  // mEEpi0analysis->trigger(96261);
221  //mEEpi0analysis->minbias(96011);
222  mEEpi0analysis->mudst("MuDst");
223  mEEpi0analysis->points("mEEpoints");
224  mEEpi0analysis->mixer("mEEmixer");
225  mEEpi0analysis->analysis("AandE");
226  mEEpi0analysis->spin("mSpinDb");
227 
228 
229  //--
230  //-- QA/analysis histograms for pi0's
231  //--
232  //mEEmixqa = new StEEmcMixQAMaker("mEEmixqa");
233  //mEEmixqa -> mixer( "mEEmixer", 0.08, 0.18 ); // specify mixer and mass range for gated histograms
234  //mEEmixqa -> points( "mEEpoints" );
235  //mEEmixqa -> maxPerCluster = 1; // max number of pairs matched to a cluster of towers
236  //mEEmixqa -> maxPerSector = 100; // max number of pairs allowed per sector
237  //mEEmixqa -> maxPerEvent = 100; // max number of pairs allowed per event
238 
239  mChain->ls(3);
240  mChain->Init();
241 
242  //-----------------------------------------------------------------
243  //--
244  //-- This is where the business happens. We loop over all events.
245  //-- when mChain -> Make() is called, ::Make() will be called on
246  //-- all of the makers created above.
247 
248  Int_t stat = 0; // error flag
249  Int_t count = 0; // event count
250  int TTnumsmdu=0,TTnumsmdv=0,Tnumsmdu=0,Tnumsmdv=0,Tnumpoints=0,Tnumpairs=0,Tnumfp=0,n2clusteru=0,n2clusterv=0,n2point=0,j=0;
251  //FILE *fout=fopen("lowratio.txt","w");assert(fout);
252  while ( stat == 0 ) {
253 
254 
255  //--
256  //-- Terminate once we reach nevents --
257  //--
258  if ( count++ >= nevents && nevents>0 ) break;
259 
260  //--
261  //-- Call clear on all makers
262  //--
263  mChain -> Clear();
264 
265 
266  //--
267  //-- Process the event through all makers
268  //--
269  stat = mChain -> Make();
270 
271  //--
272  //-- Set to printout on every 10th event
273  //--
274  if ( (count%prescale)==0 ) //continue;
275  {
276  std::cout << "------------------------------------------------";
277  std::cout << "event=" << count << std::endl;
278  }
279  //--
280  //-- Print the number of hits in the towers, pre/postshower layers
281  //--
282  Int_t nhits[]={0,0,0,0,0,0};
283  float umeandiff=0,vmeandiff;
284  for ( int i = 0; i < 4; i++ ) {
285  // std::cout << " layer=" << i
286  // << " nhits=" << mEEanalysis->numberOfHitTowers(i) << std::endl;
287  nhits[i]+=mEEanalysis->numberOfHitTowers(i);
288  }
289 
290  //--
291  //-- Print the total number of smd strips which fired
292  //--
293  Int_t nu=0,nv=0;
294  for ( Int_t sec=0;sec<12;sec++ )
295  {
296  nu+=mEEanalysis->numberOfHitStrips(sec,0);
297  nv+=mEEanalysis->numberOfHitStrips(sec,1);
298  }
299  nhits[4]=nu;
300  nhits[5]=nv;
301 
302 
303  //--
304  //-- Print number of clusters in each layer
305  //--
306  Int_t ncl[8]={0,0,0,0,0,0,0,0};
307  for ( Int_t i=0;i<12;i++ )
308  {
309  ncl[0]+=mEEclusters->numberOfClusters(i,0);
310  ncl[1]+=mEEclusters->numberOfClusters(i,1);
311  ncl[2]+=mEEclusters->numberOfClusters(i,2);
312  ncl[3]+=mEEclusters->numberOfClusters(i,3);
313  ncl[4]+=mEEclusters->numberOfSmdClusters(i,0);
314  ncl[5]+=mEEclusters->numberOfSmdClusters(i,1);
315  ncl[6]+=mEEclusters->TnumberOfSmdClusters(i,0);
316  ncl[7]+=mEEclusters->TnumberOfSmdClusters(i,1);
317 
318  }
319 
320  // h0->Fill(ncl[4]);
321  //h1->Fill(ncl[5]);
322  //h3->Fill(mEEpoints -> numberOfPoints());
323  if(ncl[4]==2) n2clusteru+=1;
324  if(ncl[5]==2) n2clusterv+=1;
325  if(mEEpoints->numberOfPoints()==2) n2point+=1;
326 
327 
328  Tnumsmdu+=ncl[4];
329  Tnumsmdv+=ncl[5];
330  TTnumsmdu+=ncl[6];
331  TTnumsmdv+=ncl[7];
332  Tnumpoints+=mEEpoints->numberOfPoints();
333  Tnumpairs+=mEEmixer -> numberOfCandidates();
334 
335  }
336  std::cout << "total number of cluster in smdu=" << Tnumsmdu << std::endl;
337  std::cout << "total number of cluster in smdv=" << Tnumsmdv << std::endl;
338  std::cout << "temp total number of cluster in smdu=" << TTnumsmdu << std::endl;
339  std::cout << "temp total number of cluster in smdv=" << TTnumsmdv << std::endl;
340  std::cout << "total number of points =" << Tnumpoints << std::endl;
341  std::cout << "number of 2cluster/event in Vplane" << n2clusterv << std::endl;
342  std::cout << "total number of pairs =" << Tnumpairs << std::endl;
343  std::cout << "number of 2cluster/event in Uplane" << n2clusteru << std::endl;
344  std::cout << "number of 2point /event " << n2point << std::endl;
345 
346  //-----------------------------------------------------------------
347 
348 
349  //--
350  //-- For debugging purposes, it's often useful to print out the
351  //-- database
352  //--
353  mEEmcDatabase = (StEEmcDb*)mChain->GetDataSet("StEEmcDb");
354  if (mEEmcDatabase) mEEmcDatabase->exportAscii("dbdump.dat");
355 
356  //--
357  //-- Calls the ::Finish() method on all makers
358  //--
359  mChain -> Finish();
360 
361 
362  //--
363  //-- Output the QA histograms to disk
364  //--
365  TFile *file=new TFile(ofile,"RECREATE");
366 
367  mEEclusters -> GetHistList() -> Write();
368  mEEpoints -> GetHistList() -> Write();
369  mEEanalysis->GetHistList()->Write();
370  mEEpi0analysis->GetHistList()->Write();
371  mySputMk->GetHistList()->Write();
372  mEEmixer->GetHistList()->Write();
373 
374  file->Close();
375 
376 
377 
378  delete file;
379 
380 
381  return;
382 
383 }
384 
385 void LoadLibs()
386 {
387  //-- Load muDst shared libraries --
388  gROOT -> LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
389  loadSharedLibraries();
390 
391  gSystem->Load("StDbLib");
392  gSystem->Load("StDbBroker");
393  gSystem->Load("St_db_Maker");
394  gSystem->Load("StEEmcUtil");
395  gSystem->Load("StEEmcDbMaker");
396  gSystem->Load("StEEmcSimulatorMaker");
397  gSystem->Load("StEEmcA2EMaker");
398 #ifdef NEW
399  gSystem->Load("StEEmcIUPi0");
400 #else
401  gSystem->Load("StMaxStripPi0");
402 #endif
403  gSystem->Load("StSpinDbMaker");
404 
405 }
EEmc ADC –&gt; energy maker.
void setMaxExtent(Int_t m)
Maximum distance around seed strip to cluster smd strips.
A class for mixing pi0 candidates.
void mudst(const Char_t *name)
sets pointer to the muDst maker
void fixedVertex(Float_t x, Float_t y, Float_t z)
Fix vertex for simple MC.
void scale(Float_t s)
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
Definition: StIOInterFace.h:35
void source(const Char_t *, Int_t=0)
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 analysis(const Char_t *name)
sets pointer to adc–&gt;energy maker
A maker for creating pi0 histograms \Weihong He The StEEmcIUPi0Analysis takes as input the list of pi...
Int_t numberOfSmdClusters(Int_t sec, Int_t plane)
Return number of smd clusters for a given sector, plane.
Int_t numberOfHitStrips(Int_t sector, Int_t plane) const
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 numberOfPoints()
Return number of points.
A cluster maker for the EEMC.
void SetHList(TObjArray *x)
output histo access point
void analysis(const Char_t *name)
Set the name of the ADC–&gt;E maker.
Int_t numberOfHitTowers(Int_t layer) const
void setNpePerMipSmd(Int_t strip, Float_t npe)
void threshold(Float_t cut, Int_t layer)
Filling of all StMcEvent classes from g2t tables Transform all the data in the g2t tables into the co...
void analysis(const Char_t *name)
Set adc to energy maker.
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
Bool_t doPrintMemoryInfo
lots of screen output
virtual Int_t Make()
void setOverwrite(Bool_t o=true)
Overwrite the muDst values.
Int_t numberOfClusters(Int_t sec, Int_t layer)
Return number of clusters for a given sector, layer.
void setDropBad(Bool_t d=true)
Drop bad channels marked as &quot;fail&quot; in DB.
StSpinDbMaker(const char *name="SpinDbMaker")
experts only
void setEnergyMode(Int_t mode)
void setSeedFloor(Float_t f=2.0)
void clusters(const Char_t *name)
Set cluster maker.
Example of QA histograming using the StEEmcA2EMaker.
Definition: StEEmcQAMaker.h:12
void sector(Int_t sector)
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
Slow simulator for EEMC.
void database(const Char_t *)
Set the name of the EEMC database, init obtains pointer.
void setLimit(Int_t l)
Number of iterations for tower-shape mode.
Int_t nVertexMax
Cuts on primary vertex (see constructor for defaults)
Definition: StEEmcQAMaker.h:30