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