StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
runEEmcMcPi0Mixer.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 
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 StEEmcClusterMaker *mEEclusters = 0;
35 //StEEmcPointFitMaker *mEEpoints = 0;
36 
38 StEEmcMixQAMaker *mEEmixqa = 0;
39 
40 Int_t count = 0;
41 Int_t stat = 0;
42 
43 Int_t prescale = 10;
44 
45 void runEEmcMcPi0Mixer( Int_t nevents = 50,
46  Char_t *name = "mcpi0_5000_06TC05_15.MuDst.root",
47  Char_t *ofile= "mcpi0_5000_06TC05_15.root",
48  Char_t *path = "/star/data04/sim/jwebb/MonteCarlo/single_gamma/",
49  Int_t nfiles = 100
50  )
51 {
52 
53  TString pathname = path;
54  pathname += name;
55 
56  //--
57  //-- Load shared libraries
58  //--
59  LoadLibs();
60 
61 
62  //--
63  //-- Create the analysis chain
64  //--
65  mChain = new StChain("eemcAnalysisChain");
66 
67 
68  //--
69  //-- MuDst maker for reading input
70  //--
71  mMuDstMaker = new StMuDstMaker(0,0,path,name,"MuDst",nfiles);
72  mMuDstMaker->SetStatus("*",0);
73  mMuDstMaker->SetStatus("MuEvent",1);
74  mMuDstMaker->SetStatus("EmcAll",1);
75 
76 
77  //--
78  //-- Connect to the STAR databse
79  //--
80  mStarDatabase = new St_db_Maker("StarDb", "MySQL:StarDb");
81 
82 
83 #ifdef MONTE_CARLO
84  //--
85  //-- Setup ideal gains for processing MC data
86  //--
87  mStarDatabase->SetFlavor("sim","eemcPMTcal");
88  mStarDatabase->SetFlavor("sim","eemcPIXcal");
89  mStarDatabase->SetFlavor("sim","eemcPMTped");
90  mStarDatabase->SetFlavor("sim","eemcPMTstat");
91  mStarDatabase->SetFlavor("sim","eemcPMTname");
92  mStarDatabase->SetFlavor("sim","eemcADCconf");
93  mStarDatabase->SetDateTime(20050101,0);
94 #endif
95 
96  //--
97  //-- Initialize EEMC database
98  //--
99  new StEEmcDbMaker("eemcDb");
100  gMessMgr -> SwitchOff("D");
101  gMessMgr -> SwitchOn("I");
102 
103 
104 
105 #ifdef MONTE_CARLO
106  //--
107  //-- Initialize slow simulator
108  //--
109  StEEmcSlowMaker *slowSim = new StEEmcSlowMaker("slowSim");
110  slowSim->setDropBad(0); // 0=no action, 1=drop chn marked bad in db
111  slowSim->setAddPed(0); // 0=no action, 1=ped offset from db
112  slowSim->setSmearPed(0); // 0=no action, 1=gaussian ped, width from db
113  slowSim->setOverwrite(1); // 0=no action, 1=overwrite muDst values
114 #endif
115 
116 
117  //--
118  //-- Energy to ADC maker
119  //--
120  mEEanalysis=new StEEmcA2EMaker("AandE");
121  mEEanalysis->database("eemcDb"); // sets db connection
122  mEEanalysis->source("MuDst",1); // sets mudst as input
123  mEEanalysis->threshold(0,3.0); // tower threshold
124  mEEanalysis->threshold(1,3.0); // pre1 threshold
125  mEEanalysis->threshold(2,3.0); // pre2 threshold
126  mEEanalysis->threshold(3,3.0); // post threshold
127 //mEEanalysis->threshold(4,5.0); // smdu threshold
128 //mEEanalysis->threshold(5,5.0); // smdv threshold
129  mEEanalysis->scale(1.2); // scale energies by x1.2
130 
131 
132  //--
133  //-- Some simple QA histograms
134  //--
135  StEEmcQAMaker *eemcQA=new StEEmcQAMaker("eeqa");
136  eemcQA->analysis("AandE");
137  eemcQA->mudst("MuDst");
138 //eemcQA->trigger(96261); // add specified trigger to list
139  eemcQA->nVertexMin=0; // cut on min number of verticies
140  eemcQA->nVertexMax=999; // cut on max number of verticies
141 
142 
143  //--
144  //-- Cluster maker. Generates tower, preshower, postshower clusters
145  //-- (using Minesweeper algo) and smd clusters (seed strip w/ truncation).
146  //--
147  mEEclusters=new StEEmcClusterMaker("mEEclusters");
148  mEEclusters->analysis("AandE");
149  mEEclusters->seedEnergy(0.8,0); // tower seed energy
150  mEEclusters->seedEnergy(2.0/1000.,4); // 2 MeV smd-u strip
151  mEEclusters->seedEnergy(2.0/1000.,5); // 2 MeV smd-v strip
152  mEEclusters->setSeedFloor(3.0); // floating seed threshold near clusters
153  mEEclusters->setMaxExtent(3); // maximum distance from seed strip
154 //mEEclusters->suppress(); // disallows seeds in two strips adjacent to any cluster
155 
156 
157  //--
158  //-- Point maker. Matches pairs of smd clusters to active towers.
159  //-- Energy is divided between points using a tower energy-sharing
160  //-- vs position function.
161  //--
162  mEEpoints=new StEEmcPointMaker("mEEpoints");
163  //mEEpoints=new StEEmcPointFitMaker("mEEpoints");
164  mEEpoints->analysis("AandE");
165  mEEpoints->clusters("mEEclusters");
166  mEEpoints->setEnergyMode(0);
167  //mEEpoints->setLimit(10);
168  // mEEpoints -> doPermutations(false);
169 
170 
171  //--
172  //-- Pi0 mixer, takes the points identified above and mixes pi0 pairs.
173  //--
174  mEEmixer = new StEEmcMixMaker("mEEmixer");
175  mEEmixer -> mudst("MuDst");
176  mEEmixer -> analysis("AandE");
177  mEEmixer -> points("mEEpoints");
178  for ( Int_t i=0;i<12;i++ ) // activate all 12 sectors
179  mEEmixer->sector(i);
180 //mEEmixer->trigger(96251); // specify trigger id(s) to process
181  mEEmixer->fixedVertex(0.,0.,0.); // fixes the vertex positiion
182 
183  //--
184  //-- QA/analysis histograms for pi0's
185  //--
186  mEEmixqa = new StEEmcMixQAMaker("mEEmixqa");
187  mEEmixqa -> mixer( "mEEmixer", 0.1, 0.18 ); // specify mixer and mass range for gated histograms
188  mEEmixqa -> points( "mEEpoints" );
189  mEEmixqa -> maxPerCluster = 1; // max number of pairs matched to a cluster of towers
190  mEEmixqa -> maxPerSector = 1; // max number of pairs allowed per sector
191  mEEmixqa -> maxPerEvent = 100; // max number of pairs allowed per event
192 
193  mChain->ls(3);
194  mChain->Init();
195 
196  //-----------------------------------------------------------------
197  //--
198  //-- This is where the business happens. We loop over all events.
199  //-- when mChain -> Make() is called, ::Make() will be called on
200  //-- all of the makers created above.
201  //--
202 
203  Int_t stat = 0; // error flag
204  Int_t count = 0; // event count
205  while ( stat == 0 ) {
206 
207 
208  //--
209  //-- Terminate once we reach nevents --
210  //--
211  if ( count++ >= nevents ) if ( nevents > 0 ) break;
212 
213  //--
214  //-- Call clear on all makers
215  //--
216  mChain -> Clear();
217 
218 
219  //--
220  //-- Process the event through all makers
221  //--
222  stat = mChain -> Make();
223 
224  //--
225  //-- Set to printout on every 10th event
226  //--
227  if ( (count%prescale) ) continue;
228 
229  std::cout << "------------------------------------------------";
230  std::cout << "event=" << count << std::endl;
231 
232  //--
233  //-- Print the number of hits in the towers, pre/postshower layers
234  //--
235  Int_t nhits[]={0,0,0,0,0,0};
236  for ( int i = 0; i < 4; i++ ) {
237  // std::cout << " layer=" << i
238  // << " nhits=" << mEEanalysis->numberOfHitTowers(i) << std::endl;
239  nhits[i]+=mEEanalysis->numberOfHitTowers(i);
240  }
241 
242  //--
243  //-- Print the total number of smd strips which fired
244  //--
245  Int_t nu=0,nv=0;
246  for ( Int_t sec=0;sec<12;sec++ )
247  {
248  nu+=mEEanalysis->numberOfHitStrips(sec,0);
249  nv+=mEEanalysis->numberOfHitStrips(sec,1);
250  }
251  nhits[4]=nu;
252  nhits[5]=nv;
253 
254 
255  //--
256  //-- Print number of clusters in each layer
257  //--
258  Int_t ncl[6]={0,0,0,0,0,0};
259  for ( Int_t i=0;i<12;i++ )
260  {
261  ncl[0]+=mEEclusters->numberOfClusters(i,0);
262  ncl[1]+=mEEclusters->numberOfClusters(i,1);
263  ncl[2]+=mEEclusters->numberOfClusters(i,2);
264  ncl[3]+=mEEclusters->numberOfClusters(i,3);
265  ncl[4]+=mEEclusters->numberOfSmdClusters(i,0);
266  ncl[5]+=mEEclusters->numberOfSmdClusters(i,1);
267  }
268 
269  const Char_t *lay[]={"tower:","pre1: ", "pre2: ", "post: ", "smdu: ", "smdv: "};
270  for ( Int_t i=0;i<6;i++ )
271  {
272  std::cout << lay[i] << " " << nhits[i] << " " << ncl[i] << std::endl;
273  }
274 
275  std::cout << "number of points: " << mEEpoints -> numberOfPoints() << std::endl;
276  std::cout << "number of pairs: " << mEEmixer -> numberOfCandidates() << std::endl;
277 
278 
279 
280  }
281  //--
282  //-----------------------------------------------------------------
283 
284 
285  //--
286  //-- For debugging purposes, it's often useful to print out the
287  //-- database
288  //--
289  mEEmcDatabase = (StEEmcDb*)mChain->GetDataSet("StEEmcDb");
290  if (mEEmcDatabase) mEEmcDatabase->exportAscii("dbdump.dat");
291 
292  //--
293  //-- Calls the ::Finish() method on all makers
294  //--
295  mChain -> Finish();
296 
297 
298  //--
299  //-- Output the QA histograms to disk
300  //--
301  TFile *file=new TFile(ofile,"RECREATE");
302  file->mkdir("QA");
303  file->cd("QA");
304  eemcQA -> GetHistList() -> Write();
305  file->cd();
306  file->mkdir("pions");
307  file->cd("pions");
308  mEEmixqa -> GetHistList() -> Write();
309  file->Close();
310 
311  delete file;
312 
313 
314  return;
315 
316 }
317 
318 void LoadLibs()
319 {
320  //-- Load muDst shared libraries --
321  gROOT -> LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
322  loadSharedLibraries();
323 
324  gSystem->Load("StDbLib");
325  gSystem->Load("StDbBroker");
326  gSystem->Load("St_db_Maker");
327  gSystem->Load("StEEmcUtil");
328  gSystem->Load("StEEmcDbMaker");
329  gSystem->Load("StEEmcSimulatorMaker");
330 
331 #ifdef NEW
332  gSystem->Load("StEEmcA2EMaker");
333  gSystem->Load("StEEmcClusterMaker");
334  gSystem->Load("StEEmcPointMaker");
335  gSystem->Load("StEEmcPi0Mixer");
336 #else
337  gSystem->Load("StMaxStripPi0");
338 #endif
339 }
340 
void analysis(const Char_t *name)
Set the name of the ADC–&gt;E maker.
EEmc ADC –&gt; energy maker.
StEEmcMixMaker * mEEmixer
Pointer to the pi0 mixer.
void fixedVertex(Float_t x, Float_t y, Float_t z)
Fix vertex for simple MC.
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
void mixer(const Char_t *name, Float_t min=0., Float_t max=999.)
void scale(Float_t s)
Int_t numberOfSmdClusters(Int_t sec, Int_t plane) const
Return number of smd clusters for a given sector, plane.
void source(const Char_t *, Int_t=0)
void setAddPed(Bool_t a=true)
Add pedestal offsets from DB.
void setMaxExtent(Int_t m)
Maximum distance around seed strip to cluster smd strips.
Int_t Make()
processes a single event
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.
StEEmcPointMaker * mEEpoints
pointer to the point maker
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
void Clear(Option_t *opts="")
clears the maker
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)
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
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.
void points(const Char_t *name)
specifies the name of the point maker
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.
StEEmcMixQAMaker(const Char_t *name)
constructor
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.