StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
testSimulatorMaker.C
1 TH1 *btow_adc, *bprs_adc, *smde_adc, *smdp_adc;
2 TH1 *btow_energy, *bprs_energy, *smde_energy, *smdp_energy;
3 TCanvas *c;
4 
5 void testSimulatorMaker(int nEvents=1000, const char *geantFile = "/star/institutions/mit/common/simu/photon_5_7_09.geant.root") {
6  gROOT->Macro("LoadLogger.C");
7  gROOT->Macro("loadMuDst.C");
8  gSystem->Load("StDetectorDbMaker");
9  gSystem->Load("StDbUtilities");
10  gSystem->Load("StEEmcUtil");
11  gSystem->Load("StMcEvent");
12  gSystem->Load("StMcEventMaker");
13  gSystem->Load("StDbBroker");
14  gSystem->Load("St_db_Maker");
15  gSystem->Load("StDaqLib");
16  gSystem->Load("StEmcSimulatorMaker");
17 
18  StChain *chain = new StChain("StChain");
19 
20  StIOMaker* ioMaker = new StIOMaker();
21  ioMaker->SetFile(geantFile);
22  ioMaker->SetIOMode("r");
23  ioMaker->SetBranch("*",0,"0"); //deactivate all branches
24  ioMaker->SetBranch("geantBranch",0,"r"); //activate geant Branch
25 
26  StMcEventMaker* mcEventMaker = new StMcEventMaker();
27 
28  St_db_Maker* dbMaker = new St_db_Maker("StarDb","MySQL:StarDb","$STAR/StarDb");
29 
30  //pick up average status table in 2005
31  dbMaker->SetDateTime(20050506,214129);
32 
33  //if you want to use ideal DB values for some detector
34  dbMaker->SetFlavor("sim","bprsCalib");
35 
37 
38  //emcSim->setCheckStatus(kBarrelEmcTowerId, false);
39 
40  //emcSim->setSimulatorMode(kBarrelEmcTowerId, StEmcVirtualSimulator::kTestMode);
41  //emcSim->setSimulatorMode(kBarrelEmcPreShowerId, StEmcVirtualSimulator::kTestMode);
42  //emcSim->setSimulatorMode(kBarrelSmdEtaStripId, StEmcVirtualSimulator::kTestMode);
43  //emcSim->setSimulatorMode(kBarrelSmdPhiStripId, StEmcVirtualSimulator::kTestMode);
44 
45  emcSim->setMaximumAdc(kBarrelSmdEtaStripId, 850.0);
46  emcSim->setMaximumAdcSpread(kBarrelSmdEtaStripId, 15.0);
47 
48  emcSim->setMaximumAdc(kBarrelSmdPhiStripId, 850.0);
49  emcSim->setMaximumAdcSpread(kBarrelSmdPhiStripId, 15.0);
50 
51  chain->Init();
52 
53  btow_adc = new TH1F("btow_adc","",200,0.,2000.);
54  btow_energy = new TH1F("btow_energy","",200,0.,60.);
55 
56  bprs_adc = new TH1F("bprs_adc","",200,0.,1200.);
57  bprs_energy = new TH1F("bprs_energy","",200,0.,30.);
58 
59  smde_adc = new TH1F("smde_adc","",200,0.,1200.);
60  smde_energy = new TH1F("smde_energy","",200,0.,30.);
61 
62  smdp_adc = new TH1F("smdp_adc","",200,0.,1200.);
63  smdp_energy = new TH1F("smdp_energy","",200,0.,30.);
64 
65  int i=0;
66  while(i<nEvents && chain->Make() == kStOk) {
67  StEmcCollection *coll = emcSim->getEmcCollection();
68 
69  StEmcDetector *btow = coll->detector(kBarrelEmcTowerId);
70  StEmcDetector *bprs = coll->detector(kBarrelEmcPreShowerId);
71  StEmcDetector *smde = coll->detector(kBarrelSmdEtaStripId);
72  StEmcDetector *smdp = coll->detector(kBarrelSmdPhiStripId);
73 
74  for(int m=1; m<=120; m++) {
75  StSPtrVecEmcRawHit btow_hits = btow->module(m)->hits();
76  StSPtrVecEmcRawHit bprs_hits = bprs->module(m)->hits();
77  StSPtrVecEmcRawHit smde_hits = smde->module(m)->hits();
78  StSPtrVecEmcRawHit smdp_hits = smdp->module(m)->hits();
79 
80  for(int j=0; j<btow_hits.size(); j++) {
81  btow_adc->Fill( (btow_hits[j])->adc() );
82  btow_energy->Fill( (btow_hits[j])->energy() );
83  }
84 
85  for(int j=0; j<bprs_hits.size(); j++) {
86  bprs_adc->Fill( (bprs_hits[j])->adc() );
87  bprs_energy->Fill( (bprs_hits[j])->energy() );
88  }
89 
90  for(int j=0; j<smde_hits.size(); j++) {
91  smde_adc->Fill( (smde_hits[j])->adc() );
92  smde_energy->Fill( (smde_hits[j])->energy() );
93  }
94 
95  for(int j=0; j<smdp_hits.size(); j++) {
96  smdp_adc->Fill( (smdp_hits[j])->adc() );
97  smdp_energy->Fill( (smdp_hits[j])->energy() );
98  }
99  }
100 
101  i++; chain->Clear();
102  }
103 
104  chain->ls(3);
105  chain->Finish();
106 
107  c = new TCanvas("c","",600,800);
108  c->Divide(2,4);
109 
110  TVirtualPad *pad = c->cd(1);
111  pad->SetLogy();
112  btow_adc->Draw();
113 
114  pad = c->cd(2);
115  pad->SetLogy();
116  btow_energy->Draw();
117 
118  pad = c->cd(3);
119  pad->SetLogy();
120  bprs_adc->Draw();
121 
122  pad = c->cd(4);
123  pad->SetLogy();
124  bprs_energy->Draw();
125 
126  pad = c->cd(5);
127  pad->SetLogy();
128  smde_adc->Draw();
129 
130  pad = c->cd(6);
131  pad->SetLogy();
132  smde_energy->Draw();
133 
134  pad = c->cd(7);
135  pad->SetLogy();
136  smdp_adc->Draw();
137 
138  pad = c->cd(8);
139  pad->SetLogy();
140  smdp_energy->Draw();
141 }
void setMaximumAdc(StDetectorId det, float adc)
maximum possible ADC for a channel. Defaults are 4095 (TOW), 1023 (PRS), 1023 (SMDs) ...
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
Definition: StIOInterFace.h:35
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
StEmcCollection * getEmcCollection()
virtual Int_t Finish()
Definition: StChain.cxx:85
Filling of all StMcEvent classes from g2t tables Transform all the data in the g2t tables into the co...
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
void setMaximumAdcSpread(StDetectorId det, float spread)
maximum possible ADC will be calculated by sampling Gaussian with this spread. Default is 0 for all d...
Definition: Stypes.h:41