StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
runEEmcPi0.C
1 //--
2 //-- runEEmcPi0.C
3 //-- used by real data
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 //--
9 //-- author: Weihong He
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;
20 class StEEmcIUPointMaker;
21 //class StEEmcPointFitMaker;
22 class StEEmcIUMixMaker;
23 //class StEEmcMixQAMaker;
24 class StSpinDbMaker;
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 StEEmcIUClusterMaker *mEEclusters = 0;
34 StEEmcIUPointMaker *mEEpoints = 0;
35 //StEEmcPointFitMaker *mEEpoints = 0;
36 
37 StEEmcIUMixMaker *mEEmixer = 0;
38 //StEEmcMixQAMaker *mEEmixqa = 0;
39 StSpinDbMaker *mSpinDb = 0;
40 
41 Int_t count = 0;
42 Int_t stat = 0;
43 
44 Int_t prescale = 100;
45 
46 void runEEmcPi0( Int_t nevents =-1,
47  Char_t *name = "st_physics_adc_7136033_raw_1060001.MuDst.root",
48  Char_t *ofile= "test.root ",
49  Char_t *path = "/star/institutions/iucf/hew/2006ppLongRuns/7136033/",
50  Int_t trigID=137641,
51  Int_t nfiles = 100,)
52 
53 {
54 
55  TString pathname = path;
56  pathname += name;
57 
58  //--
59  //-- Load shared libraries
60  //--
61  LoadLibs();
62 
63 
64  //--
65  //-- Create the analysis chain
66  //--
67  mChain = new StChain("eemcAnalysisChain");
68 
69 
70  //--
71  //-- MuDst maker for reading input
72  //--
73  mMuDstMaker = new StMuDstMaker(0,0,path,name,"MuDst",nfiles);
74  mMuDstMaker->SetStatus("*",0);
75  mMuDstMaker->SetStatus("MuEvent",1);
76  mMuDstMaker->SetStatus("EmcAll",1);
77 
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  //-- Initialize EEMC database
100  //--
101  new StEEmcDbMaker("eemcDb");
102  gMessMgr -> SwitchOff("D");
103  gMessMgr -> SwitchOn("I");
104 
105  mSpinDb = new StSpinDbMaker("mSpinDb");
106 
107 #ifdef MONTE_CARLO
108  //--
109  //-- Initialize slow simulator
110  //--
111  StEEmcSlowMaker *slowSim = new StEEmcSlowMaker("slowSim");
112  slowSim->setDropBad(0); // 0=no action, 1=drop chn marked bad in db
113  slowSim->setAddPed(0); // 0=no action, 1=ped offset from db
114  slowSim->setSmearPed(0); // 0=no action, 1=gaussian ped, width from db
115  slowSim->setOverwrite(1); // 0=no action, 1=overwrite muDst values
116 #endif
117 
118 
119  //--
120  //-- Energy to ADC maker
121  //--
122  mEEanalysis=new StEEmcA2EMaker("AandE");
123  mEEanalysis->database("eemcDb"); // sets db connection
124  mEEanalysis->source("MuDst",1); // sets mudst as input
125  mEEanalysis->threshold(3.0,0); // tower threshold
126  mEEanalysis->threshold(3.0,1); // pre1 threshold
127  mEEanalysis->threshold(3.0,2); // pre2 threshold
128  mEEanalysis->threshold(3.0,3); // post threshold
129  mEEanalysis->threshold(3.0,4); // smdu threshold
130  mEEanalysis->threshold(3.0,5); // smdv threshold
131  //mEEanalysis->scale(1.3); // scale energies by x1.2
132  //mEEanalysis->FUNC(1.,0.);
133 
134 
135  //--
136  //-- Cluster maker. Generates tower, preshower, postshower clusters
137  //-- (using Minesweeper algo) and smd clusters (seed strip w/ truncation).
138  //--
139  mEEclusters=new StEEmcIUClusterMaker("mEEclusters");
140  mEEclusters->analysis("AandE");
141  mEEclusters->seedEnergy(0.8,0); // tower seed energy
142  mEEclusters->seedEnergy(3.0/1000.,4); // 2 MeV smd-u strip
143  mEEclusters->seedEnergy(3.0/1000.,5); // 2 MeV smd-v strip
144  mEEclusters->setSeedFloor(1.0); // floating seed threshold near clusters
145  mEEclusters->setMaxExtent(3); // maximum distance from seed strip
146  mEEclusters->suppress(0); // disallows seeds in two strips adjacent to any cluster
147 
148 
149  //--
150  //-- Point maker. Matches pairs of smd clusters to active towers.
151  //-- Energy is divided between points using a tower energy-sharing
152  //-- vs position function.
153  //--
154  mEEpoints=new StEEmcIUPointMaker("mEEpoints");
155  //mEEpoints=new StEEmcPointFitMaker("mEEpoints");
156  mEEpoints->analysis("AandE");
157  mEEpoints->clusters("mEEclusters");
158  mEEpoints->setEnergyMode(0);
159  //mEEpoints->setLimit(10);
160  // mEEpoints -> doPermutations(false);
161 
162 
163 
164  //--
165  //-- Pi0 mixer, takes the points identified above and mixes pi0 pairs.
166  //--
167  mEEmixer = new StEEmcIUMixMaker("mEEmixer");
168  mEEmixer -> mudst("MuDst");
169  mEEmixer -> analysis("AandE");
170  mEEmixer -> points("mEEpoints");
171  for ( Int_t i=0;i<12;i++ ) // activate all 12 sectors
172  mEEmixer->sector(i);
173  mEEmixer->trigger(trigID); // specify trigger id(s) to process
174 
175 
176  //pi0 analysis starts
177  mEEpi0analysis=new StEEmcIUPi0Analysis("pi0analy");
178  mEEpi0analysis->trigger(trigID);
179  mEEpi0analysis->minbias(117001);
180  mEEpi0analysis->mudst("MuDst");
181  mEEpi0analysis->points("mEEpoints");
182  mEEpi0analysis->mixer("mEEmixer");
183  mEEpi0analysis->analysis("AandE");
184  mEEpi0analysis->spin("mSpinDb");
185  //--
186  //-- QA/analysis histograms for pi0's
187  //--
188  //mEEmixqa = new StEEmcMixQAMaker("mEEmixqa");
189  //mEEmixqa -> mixer( "mEEmixer", 0.1, 0.18 ); // specify mixer and mass range for gated histograms
190  //mEEmixqa -> points( "mEEpoints" );
191  //mEEmixqa -> maxPerCluster = 1; // max number of pairs matched to a cluster of towers
192  //mEEmixqa -> maxPerSector = 100; // max number of pairs allowed per sector
193  //mEEmixqa -> maxPerEvent = 100; // max number of pairs allowed per event
194 
195  mChain->ls(3);
196  mChain->Init();
197 
198  //-----------------------------------------------------------------
199  //--
200  //-- This is where the business happens. We loop over all events.
201  //-- when mChain -> Make() is called, ::Make() will be called on
202  //-- all of the makers created above.
203  //--
204 
205  Int_t stat = 0; // error flag
206  Int_t count = 0; // event count
207  int Tnumsmdu=0,Tnumsmdv=0,Tnumpoints=0,Tnumpairs=0,Tnumfp=0,n2clusteru=0,n2clusterv=0,n2point=0,j=0;
208  //FILE *fout=fopen("lowratio.txt","w");assert(fout);
209  while ( stat == 0 ) {
210 
211 
212  //--
213  //-- Terminate once we reach nevents --
214  //--
215  if ( count++ >= nevents && nevents>0 ) break;
216 
217  //--
218  //-- Call clear on all makers
219  //--
220  mChain -> Clear();
221 
222 
223  //--
224  //-- Process the event through all makers
225  //--
226  stat = mChain -> Make();
227 
228  //--
229  //-- Set to printout on every 10th event
230  //--
231  if ( (count%prescale)==0 ) //continue;
232  {
233  std::cout << "------------------------------------------------";
234  std::cout << "event=" << count << std::endl;
235  }
236  //--
237  //-- Print the number of hits in the towers, pre/postshower layers
238  //--
239  Int_t nhits[]={0,0,0,0,0,0};
240  float umeandiff=0,vmeandiff;
241  for ( int i = 0; i < 4; i++ ) {
242  // std::cout << " layer=" << i
243  // << " nhits=" << mEEanalysis->numberOfHitTowers(i) << std::endl;
244  nhits[i]+=mEEanalysis->numberOfHitTowers(i);
245  }
246 
247  //--
248  //-- Print the total number of smd strips which fired
249  //--
250  Int_t nu=0,nv=0;
251  for ( Int_t sec=0;sec<12;sec++ )
252  {
253  nu+=mEEanalysis->numberOfHitStrips(sec,0);
254  nv+=mEEanalysis->numberOfHitStrips(sec,1);
255  }
256  nhits[4]=nu;
257  nhits[5]=nv;
258 
259 
260  //--
261  //-- Print number of clusters in each layer
262  //--
263  Int_t ncl[6]={0,0,0,0,0,0};
264  for ( Int_t i=0;i<12;i++ )
265  {
266  ncl[0]+=mEEclusters->numberOfClusters(i,0);
267  ncl[1]+=mEEclusters->numberOfClusters(i,1);
268  ncl[2]+=mEEclusters->numberOfClusters(i,2);
269  ncl[3]+=mEEclusters->numberOfClusters(i,3);
270  ncl[4]+=mEEclusters->numberOfSmdClusters(i,0);
271  ncl[5]+=mEEclusters->numberOfSmdClusters(i,1);
272  }
273 
274 
275  }
276 
277  //-----------------------------------------------------------------
278 
279 
280  //--
281  //-- For debugging purposes, it's often useful to print out the
282  //-- database
283  //--
284  mEEmcDatabase = (StEEmcDb*)mChain->GetDataSet("StEEmcDb");
285  if (mEEmcDatabase) mEEmcDatabase->exportAscii("dbdump.dat");
286 
287  //--
288  //-- Calls the ::Finish() method on all makers
289  //--
290  mChain -> Finish();
291 
292 
293  //--
294  //-- Output the QA histograms to disk
295  //--
296  TFile *file=new TFile(ofile,"RECREATE");
297 
298  //file->mkdir("pions");
299  //file->cd("pions");
300  //mEEmixqa -> GetHistList() -> Write();
301  mEEclusters -> GetHistList() -> Write();
302  mEEpoints -> GetHistList() -> Write();
303  mEEpi0analysis->GetHistList()->Write();
304 
305  file->Close();
306 
307 
308 
309  delete file;
310 
311 
312  return;
313 
314 }
315 
316 void LoadLibs()
317 {
318  //-- Load muDst shared libraries --
319  gROOT -> LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
320  loadSharedLibraries();
321 
322  gSystem->Load("StDbLib");
323  gSystem->Load("StDbBroker");
324  gSystem->Load("St_db_Maker");
325  gSystem->Load("StEEmcUtil");
326  gSystem->Load("StEEmcDbMaker");
327  gSystem->Load("StEEmcSimulatorMaker");
328  gSystem->Load("StEEmcA2EMaker");
329 #ifdef NEW
330  gSystem->Load("StEEmcIUPi0");
331 #else
332  gSystem->Load("StMaxStripPi0");
333 #endif
334  gSystem->Load("StSpinDbMaker");
335 
336 }
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 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
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.
A cluster maker for the EEMC.
void analysis(const Char_t *name)
Set the name of the ADC–&gt;E maker.
Int_t numberOfHitTowers(Int_t layer) const
void threshold(Float_t cut, Int_t layer)
void analysis(const Char_t *name)
Set adc to energy maker.
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
void trigger(Int_t trigger)
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.
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.