StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
runEEmcA2EMaker.C
1 //--
2 //-- runEEmcA2EMaker.C
3 //--
4 //-- example script for running the adc --> energy 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 
13 class StChain;
14 class St_db_Maker;
15 class StMuDstMaker;
16 class StEEmcDb;
17 class StEEmcA2EMaker;
18 
19 //--
20 //-- globals
21 //--
22 StChain *mChain = 0;
23 St_db_Maker *mStarDatabase = 0;
24 StEEmcDb *mEEmcDatabase = 0;
25 StMuDstMaker *mMuDstMaker = 0;
26 StEEmcA2EMaker *mEEanalysis = 0;
27 
28 Int_t count = 0;
29 Int_t stat = 0;
30 
31 void runEEmcA2EMaker( Int_t nevents = 50,
32  Char_t *name = "mcpi0_5000_06TC05_3.MuDst.root",
33  Char_t *ofile= "test.root",
34  Char_t *path = "./test/",
35  Int_t nfiles = 100
36  )
37 {
38 
39  TString pathname = path;
40  pathname += name;
41 
42  //--
43  //-- Load shared libraries
44  //--
45  LoadLibs();
46 
47 
48  //--
49  //-- Create the analysis chain
50  //--
51  mChain = new StChain("eemcAnalysisChain");
52 
53 
54  //--
55  //-- MuDst maker for reading input
56  //--
57  mMuDstMaker = new StMuDstMaker(0,0,path,name,"MuDst",nfiles);
58  mMuDstMaker->SetStatus("*",0);
59  mMuDstMaker->SetStatus("MuEvent",1);
60  mMuDstMaker->SetStatus("EmcAll",1);
61 
62 
63  //--
64  //-- Connect to the STAR databse
65  //--
66  mStarDatabase = new St_db_Maker("StarDb", "MySQL:StarDb");
67 
68 
69 #ifdef MONTE_CARLO
70  //--
71  //-- Setup ideal gains for processing MC data
72  //--
73  mStarDatabase->SetFlavor("sim","eemcPMTcal");
74  mStarDatabase->SetFlavor("sim","eemcPIXcal");
75  mStarDatabase->SetFlavor("sim","eemcPMTped");
76  mStarDatabase->SetFlavor("sim","eemcPMTstat");
77  mStarDatabase->SetFlavor("sim","eemcPMTname");
78  mStarDatabase->SetFlavor("sim","eemcADCconf");
79  mStarDatabase->SetDateTime(20050101,0);
80 #endif
81 
82  //--
83  //-- Initialize EEMC database
84  //--
85  new StEEmcDbMaker("eemcDb");
86  gMessMgr -> SwitchOff("D");
87  gMessMgr -> SwitchOn("I");
88 
89 
90 
91 #ifdef MONTE_CARLO
92  //--
93  //-- Initialize slow simulator
94  //--
95  StEEmcSlowMaker *slowSim = new StEEmcSlowMaker("slowSim");
96  slowSim->setDropBad(0); // 0=no action, 1=drop chn marked bad in db
97  slowSim->setAddPed(0); // 0=no action, 1=ped offset from db
98  slowSim->setSmearPed(0); // 0=no action, 1=gaussian ped, width from db
99  slowSim->setOverwrite(1); // 0=no action, 1=overwrite muDst values
100 #endif
101 
102 
103  //--
104  //-- Energy to ADC maker
105  //--
106  mEEanalysis=new StEEmcA2EMaker("AandE");
107  mEEanalysis->database("eemcDb"); // sets db connection
108  mEEanalysis->source("MuDst",1); // sets mudst as input
109 //mEEanalysis->source("StEvent",2); // sets StEvent as input
110 //mEEanalysis->threshold(3.0,0); // tower threshold, adc > 3.0*sigma + ped
111 //mEEanalysis->threshold(3.0,1); // pre1 threshold, adc > 3.0*sigma + ped
112 //mEEanalysis->threshold(3.0,2); // pre2 threshold, adc > 3.0*sigma + ped
113 //mEEanalysis->threshold(3.0,3); // post threshold, adc > 3.0*sigma + ped
114 //mEEanalysis->threshold(3.0,4); // smdu threshold, adc > 3.0*sigma + ped
115 //mEEanalysis->threshold(3.0,5); // smdv threshold, adc > 3.0*sigma + ped
116 #ifdef MONTE_CARLO
117  mEEanalysis->scale(1.2); // scale energies by x1.2
118 #endif
119 
120  mChain->ls(3);
121  mChain->Init();
122 
123  //-----------------------------------------------------------------
124  //--
125  //-- This is where the business happens. We loop over all events.
126  //-- when mChain -> Make() is called, ::Make() will be called on
127  //-- all of the makers created above.
128  //--
129 
130  Int_t stat = 0; // error flag
131  Int_t count = 0; // event count
132  while ( stat == 0 ) {
133 
134 
135  //--
136  //-- Terminate once we reach nevents --
137  //--
138  if ( count++ >= nevents ) if ( nevents > 0 ) break;
139 
140  //--
141  //-- Call clear on all makers
142  //--
143  mChain -> Clear();
144 
145 
146  //--
147  //-- Process the event through all makers
148  //--
149  stat = mChain -> Make();
150 
151  //--
152  //-- Set to printout on every 10th event
153  //--
154  if ( (count%10) ) continue;
155 
156  std::cout << "------------------------------------------------";
157  std::cout << "event=" << count << std::endl;
158 
159  //--
160  //-- Print the number of hits in the towers, pre/postshower layers
161  //--
162  for ( int i = 0; i < 4; i++ ) {
163  std::cout << " layer=" << i
164  << " nhits=" << mEEanalysis->numberOfHitTowers(i) << std::endl;
165  }
166 
167  //--
168  //-- Print the total number of smd strips which fired
169  //--
170  Int_t nu=0,nv=0;
171  for ( Int_t sec=0;sec<12;sec++ )
172  {
173  nu+=mEEanalysis->numberOfHitStrips(sec,0);
174  nv+=mEEanalysis->numberOfHitStrips(sec,1);
175  }
176  std::cout << " layer=u nhits=" << nu << std::endl;
177  std::cout << " layer=v nhits=" << nv << std::endl;
178 
179  }
180  //--
181  //-----------------------------------------------------------------
182 
183 
184  //--
185  //-- For debugging purposes, it's often useful to print out the
186  //-- database
187  //--
188  mEEmcDatabase = (StEEmcDb*)mChain->GetDataSet("StEEmcDb");
189  if (mEEmcDatabase) mEEmcDatabase->exportAscii("dbdump.dat");
190 
191  //--
192  //-- Calls the ::Finish() method on all makers
193  //--
194  mChain -> Finish();
195 
196 
197  //--
198  //-- Output the QA histograms to disk
199  //--
200  //TFile *file=new TFile(ofile,"RECREATE");
201  //file->mkdir("QA");
202  //file->cd("QA");
203  //eemcQA -> GetHistList() -> Write();
204  //file -> Close();
205  //delete file;
206 
207 
208  return;
209 
210 }
211 
212 void LoadLibs()
213 {
214  gSystem->Load("libMinuit");
215  //-- Load muDst shared libraries --
216  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
217  loadSharedLibraries();
218 
219  gSystem->Load("StDbLib");
220  gSystem->Load("StDbBroker");
221  gSystem->Load("St_db_Maker");
222  gSystem->Load("StEEmcUtil");
223  gSystem->Load("StEEmcDbMaker");
224  gSystem->Load("StEEmcSimulatorMaker");
225 
226  gSystem->Load("StEEmcA2EMaker");
227  gSystem->Load("StEEmcClusterMaker");
228  gSystem->Load("StEEmcPointMaker");
229 
230 }
231 
StEEmcA2EMaker(const Char_t *name="mEEanalysis")
EEmc ADC –&gt; energy maker.
void scale(Float_t s)
void source(const Char_t *, Int_t=0)
void setAddPed(Bool_t a=true)
Add pedestal offsets from DB.
Int_t numberOfHitStrips(Int_t sector, Int_t plane) const
Int_t numberOfHitTowers(Int_t layer) const
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 SetStatus(const char *arrType, int status)
void setSmearPed(Bool_t s=true)
Smear the pedestal with sigma from DB.
virtual void Clear(Option_t *opts="")
Clear the maker for next event.
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.
virtual Int_t Make()
Read and process one event.