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