StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
runEEmcPi0Maker.C
1 //#define MONTE_CARLO
2 
3 class StChain;
5 
6 class St_db_Maker;
7 class StEEmcDb;
8 class StMuDstMaker;
9 
10 StChain *mChain = 0;
11 St_db_Maker *mStarDatabase = 0;
12 StEEmcDb *mEEmcDatabase = 0;
13 StMuDstMaker *mMuDstMaker = 0;
14 
15 class StEEmcA2EMaker;
16 StEEmcA2EMaker *mEEmcA2E = 0;
17 
18 class StEEmcClusterMaker;
19 StEEmcClusterMaker *mEEclusters=0;
20 
21 
22 
23 Bool_t useSlow=1;
24 
25 void runEEmcPi0Maker( Int_t nevents = 5000,
26  Char_t *name = "mcpi0_5000_06TC05_10.MuDst.root",
27  Char_t *ofile= "mcpi0_5000_06TC05_10.pi0tree.root",
28  Char_t *path = "/star/data04/sim/jwebb/MonteCarlo/single_gamma/",
29  Int_t nfiles = 100
30  )
31 {
32 
33 
34 
35  TString pathname = path;
36  pathname += name;
37 
38  gROOT->LoadMacro("StRoot/StEEmcPool/StMaxStripPi0/macros/loadlibs.C");
39  loadlibs();
40 
43 
44 
45  //-- Create the analysis chain --
46  mChain = new StChain("eemcAnalysisChain");
47 
48  //-- Create micro-dst maker and load in MuDsts --
49  mMuDstMaker = new StMuDstMaker(0,0,path,name,"MuDst",nfiles);
50  mMuDstMaker->SetStatus("*",0);
51  mMuDstMaker->SetStatus("MuEvent",1);
52  mMuDstMaker->SetStatus("EmcAll",1);
53 
54  //-- Initialize database connection --
55  mStarDatabase = new St_db_Maker("StarDb", "MySQL:StarDb");
56 
57  //-- DATE TIME FOR MONTE CARLO --
58 #ifdef MONTE_CARLO // flags for M-C events
59  TDatime *time = new TDatime();
60  mStarDatabase -> SetDateTime( time -> GetDate(), time -> GetTime() );
61  mStarDatabase->SetDateTime(20031120,0);
62  mStarDatabase->SetFlavor("sim","eemcPMTcal");
63  mStarDatabase->SetFlavor("sim","eemcPIXcal");
64  mStarDatabase->SetFlavor("sim","eemcPMTped");
65  mStarDatabase->SetFlavor("sim","eemcPMTstat");
66  mStarDatabase->SetFlavor("sim","eemcPMTname");
67  mStarDatabase->SetFlavor("sim","eemcADCconf");
68 #endif
69 
70  //-- Initialize EEMC database --
71  new StEEmcDbMaker("eemcDb");
72  gMessMgr -> SwitchOff("D");
73  gMessMgr -> SwitchOn("I");
74 
75 #ifdef MONTE_CARLO
76  //-- Create the slow simulator for the endcap
77  if ( useSlow ) {
78  StEEmcSlowMaker *slowSim = new StEEmcSlowMaker("slowSim");
79  slowSim->setDropBad(0); // 0=no action, 1=drop chn marked bad in db
80  slowSim->setAddPed(0); // 0=no action, 1=ped offset from db
81  slowSim->setSmearPed(0); // 0=no action, 1=gaussian ped, width from db
82  slowSim->setOverwrite(1); // 0=no action, 1=overwrite muDst values
83  }
84 #endif
85 
86 
87 
88  mEEmcA2E=new StEEmcA2EMaker("AandE");
89  mEEmcA2E->database("eemcDb");
90  mEEmcA2E->source("MuDst",1);
91  mEEmcA2E->threshold(0,3.0);
92  mEEmcA2E->threshold(1,3.0);
93  mEEmcA2E->threshold(2,3.0);
94  mEEmcA2E->threshold(3,3.0);
95 #ifdef MONTE_CARLO
96  mEEmcA2E->scale(1.2);
97 #endif
98 
99 
100  mEEclusters=new StEEmcClusterMaker("mEEclusters");
101  mEEclusters->analysis("AandE");
102  mEEclusters->seedEnergy(0.8,0); // tower seed energy
103  mEEclusters->seedEnergy(2.0/1000.,4); // 2 MeV smd-u strip
104  mEEclusters->seedEnergy(2.0/1000.,5); // 2 MeV smd-v strip
105  mEEclusters->setSeedFloor(3.0);
106  // mEEclusters->setFillStEvent();
107 
108  mEEclusters->setMaxExtent(3);
109 
110 
111 
112 
113  mEEpoints=new StEEmcPointMaker("mEEpoints");
114  mEEpoints->analysis("AandE");
115  mEEpoints->clusters("mEEclusters");
116 
117 
118 
119  //mEEmixer=new StEEmcMixMaker("mEEmixer");
120  mEEmixer=new StEEmcMixTreeMaker("mEEmixer");
121  mEEmixer->setFilename( ofile );
122  mEEmixer->mudst("MuDst");
123  mEEmixer->analysis("AandE");
124  mEEmixer->points("mEEpoints");
125  mEEmixer->sector(4);
126  mEEmixer->sector(5);
127  mEEmixer->sector(6);
128  mEEmixer->sector(7);
129  mEEmixer->trigger(45203);
130 
131 
132  mEEmixer2 = new StEEmcMixHistMaker("mEEmixer2");
133  mEEmixer2->mudst("MuDst");
134  mEEmixer2->analysis("AandE");
135  mEEmixer2->points("mEEpoints");
136  mEEmixer2->sector(4);
137  mEEmixer2->sector(5);
138  mEEmixer2->sector(6);
139  mEEmixer2->sector(7);
140  mEEmixer2->trigger(45203);
141 
142 
143 
144  // TFile *f=new TFile("test.root","recreate");
145  // TH1F *hNpoints=new TH1F("hNpoints","Number of points",10,0.,10.);
146 
147 
148  mChain->ls(3);
149  mChain->Init();
150 
151  //-- Loop over all events in the muDst --
152  Int_t stat = 0;
153  Int_t count = 0;
154  while ( stat == 0 ) {
155 
156  //-- Terminate once we reach nevents --
157  if ( count++ >= nevents )
158  if ( nevents > 0 ) break;
159 
160  //-- Call clear on all makers --
161  mChain -> Clear();
162 
163 
164  //-- Process the event through all makers --
165  stat = mChain -> Make();
166 
167  if ( (count%100) ) continue;
168 
169  std::cout << "------------------------------------------------";
170  std::cout << "event=" << count << std::endl;
171  for ( int i = 0; i < 4; i++ ) {
172  std::cout << " layer=" << i << " nhits=" << mEEmcA2E->numberOfHitTowers(i) << std::endl;
173  }
174 
175 
176  }// loop over all events
177 
178  //-- Finish up --
179  mChain -> Finish();
180  // f->Write();
181 
182  TString oo=ofile;
183  oo.ReplaceAll("pi0tree","pi0hist");
184  TFile *f=new TFile(oo,"recreate");
185  f->cd();
186  mEEmixer2->GetHistList()->Write();
187  f->Write();
188  f->Close();
189  delete f;
190 
191 
192 
193  return;
194 
195 }
196 
197 void LoadLibs()
198 {
199  gSystem->Load("StDbLib");
200  gSystem->Load("StDbBroker");
201  gSystem->Load("St_db_Maker");
202  gSystem->Load("StEEmcUtil");
203  gSystem->Load("StEEmcDbMaker");
204 
205  gSystem->Load("StEEmcBFC2005");
206 
207  gSystem->Load("StEEmcSimulatorMaker");
208 
209 }
210 
211 
212 
213 void testNeighborhood()
214 {
215 
216  for ( Int_t i = 0; i < 720; i++ ) {
217 
218  mEEmcA2E->tower(i).print();
219 
220  Int_t num= mEEmcA2E->tower(i).numberOfNeighbors();
221  std::cout << "+ number of neighbors=" << num << std::endl;
222 
223  for ( Int_t j = 0; j < num; j++ ) {
224 
225  std::cout << "+ ";
226  Int_t nn =mEEmcA2E->tower(i).neighborIndex(j);
227  mEEmcA2E->tower(nn).print();
228 
229  }
230 
231  }
232 
233 }
virtual void Clear(Option_t *opts="")
Clear clusters for next event.
void analysis(const Char_t *name)
Set the name of the ADC–&gt;E maker.
Int_t numberOfNeighbors() const
get the number of neighboring towers
Definition: StEEmcTower.h:54
EEmc ADC –&gt; energy maker.
void setSeedFloor(Float_t f=2.0)
StEEmcClusterMaker(const Char_t *name="mEEclusters")
void scale(Float_t s)
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.
Class for building points from smd clusters.
Int_t numberOfHitTowers(Int_t layer) const
void threshold(Float_t cut, Int_t layer)
void print() const
Print a summary of this tower.
Definition: StEEmcTower.cxx:58
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
void trigger(Int_t trigger)
void setOverwrite(Bool_t o=true)
Overwrite the muDst values.
void mudst(const Char_t *name)
sets the name of the muDst maker
void setDropBad(Bool_t d=true)
Drop bad channels marked as &quot;fail&quot; in DB.
void analysis(const Char_t *name)
sets the name of the adc–&gt;energy maker
EEMC simple geometry.
virtual Int_t Make()
Make clusters for this event.
void points(const Char_t *name)
sets the name of the point 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)
StEEmcTower & tower(Int_t index, 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.
A cluster maker for the EEMC.