12 #include "TPostScript.h"
19 #include "CalibrationHelperFunctions.h"
20 #include "CalibrationHelperFunctions.cxx"
23 double fit_function(
double *x,
double *par);
24 double fit_function2(
double *x,
double *par);
25 double background_only_fit(
double *x,
double *par);
26 int lookup_crate(
float,
float);
29 void electron_master(
const char* file_list=
"checkP11id/electrons.list",
const char* output=
"checkP11id/electroncalib2.root",
const char* dbDate=
"2009-04-10 00:11:00",
const char* gfname=
"checkP11id/mip.gains",
const char* ngname=
"checkP11id/electron2.gains",
const char* ffname=
"checkP11id/electron2.fits"){
33 gROOT->Macro(
"LoadLogger.C");
34 gROOT->Macro(
"loadMuDst.C");
35 gSystem->Load(
"StTpcDb");
36 gSystem->Load(
"StDaqLib");
37 gSystem->Load(
"StDetectorDbMaker");
38 gSystem->Load(
"St_db_Maker");
39 gSystem->Load(
"StDbUtilities");
40 gSystem->Load(
"StEmcRawMaker");
41 gSystem->Load(
"StMcEvent");
42 gSystem->Load(
"StMcEventMaker");
43 gSystem->Load(
"StEmcSimulatorMaker");
44 gSystem->Load(
"StEmcADCtoEMaker");
45 gSystem->Load(
"StEpcMaker");
46 gSystem->Load(
"StDbBroker");
47 gSystem->Load(
"StEEmcUtil");
48 gSystem->Load(
"StAssociationMaker");
49 gSystem->Load(
"StEmcTriggerMaker");
50 gSystem->Load(
"StTriggerUtilities");
51 gSystem->Load(
"StEmcOfflineCalibrationMaker");
53 cout<<
"input filelist: "<<file_list<<endl;
54 cout<<
"output: "<<output<<endl;
55 cout<<
"db Date: "<<dbDate<<endl;
71 TChain* tree =
new TChain(
"skimTree");
72 ifstream filelist(file_list);
75 if(!filelist.good())
break;
80 const int ntowers = 4800;
81 const int nrings = 40;
82 const int ncrates = 30;
86 float peakerr[ntowers];
87 float gainerr[ntowers];
89 ifstream gainfile(gfname);
92 float peak,err,gain,eta,theta;
93 gainfile >>
id >> peak >> err >> stat;
94 if(!gainfile.good())
break;
95 eta = helper->getEta(
id);
96 theta = helper->getTheta(
id);
97 gain = 0.264*(1+0.056*eta*eta)/(sin(theta)*peak);
100 if(status[
id-1] != 1 || stat != 1) status[
id-1] = stat;
106 TFile* geant_file =
new TFile(
"geant_fits.root",
"READ");
108 for(
int i = 0; i < 20; i++){
109 TString fname =
"fit_";
111 geant_fits[i] = (TF1*)geant_file->Get(fname);
115 TFile outfile(output,
"RECREATE");
117 TH1 *crate_histo[ncrates];
118 TF1 *crate_fit[ncrates];
119 TH1 *electron_histo[ntowers];
121 TH1 *prs_histo[ntowers];
122 TH1 *ring_histo[nrings];
123 TH1 *ring2_histo[nrings/2];
124 TF1 *ring2fit[nrings/2];
126 TH1 *etacrate_histo[ncrates*20];
127 TH1 *etacrate_histo_p[ncrates*20];
128 TH1 *etacrate_histo_n[ncrates*20];
131 TH2F* drvsep =
new TH2F(
"drvsep",
"drvsep",60,0,3.0,100,0.0,0.03);
133 TF1 *ringfit[nrings];
134 TH2F* ring_pve[nrings];
138 TH1F* ringprec =
new TH1F(
"ringprec",
"",40,-1.0,1.0);
139 TH1F* ringprec2 =
new TH1F(
"ringprec2",
"",40,-1.0,1.0);
140 ringprec->SetYTitle(
"E/p");
141 ringprec->SetXTitle(
"#eta");
142 ringprec2->SetYTitle(
"E/p");
143 ringprec2->SetXTitle(
"#eta");
144 TH1F* ring2prec =
new TH1F(
"ring2prec",
"",nrings/2,-1.0,1.0);
145 TH1F* ring2prec2 =
new TH1F(
"ring2prec2",
"",nrings/2,-1.0,1.0);
146 ring2prec->SetYTitle(
"E/p");
147 ring2prec->SetXTitle(
"#eta");
148 ring2prec2->SetYTitle(
"E/p");
149 ring2prec2->SetXTitle(
"#eta");
152 TH2F* trgcheck =
new TH2F(
"trgcheck",
"trgcheck",2,-0.5,1.5,3,-0.5,2.5);
154 TH1F* crateprec =
new TH1F(
"crateprec",
"",30,0.5,30.5);
155 crateprec->SetXTitle(
"Crate");
156 crateprec->SetYTitle(
"E/p");
158 TH2F *energyleak =
new TH2F(
"energyleak",
"",20,0.0,0.03,20,0.0,1.0);
159 TH2F *findbg =
new TH2F(
"findbg",
"",20,0.0,0.03,30,0.0,5.0);
160 TH1F *energymean =
new TH1F(
"energymean",
"",20,0.0,0.03);
161 TH1F *leakmean =
new TH1F(
"leakmean",
"",20,0.0,0.03);
162 energyleak->SetXTitle(
"#DeltaR");
163 energyleak->SetYTitle(
"leaked energy / total energy");
164 findbg->SetXTitle(
"#DeltaR");
165 findbg->SetYTitle(
"Total energy / track momentum");
166 TH2F *tevsp =
new TH2F(
"tevsp",
"",50,0.0,20.0,50,0.0,30.0);
167 TH1F *pmean =
new TH1F(
"pmean",
"",20,0.0,15.0);
168 tevsp->SetXTitle(
"track momentum (GeV)");
169 tevsp->SetYTitle(
"Total Energy (GeV)");
170 TH2F *tevspcent =
new TH2F(
"tevspcent",
"",20,0.0,15.0,20,0.0,15.0);
171 tevspcent->SetXTitle(
"track momentum (GeV)");
172 tevspcent->SetYTitle(
"Energy in central tower (GeV)");
173 TH1F *cmean =
new TH1F(
"cmain",
"",20,0.0,15.0);
174 TH2F *sistertracks =
new TH2F(
"sistertracks",
"",20,0.0,8.0,20,0.0,8.0);
175 sistertracks->SetXTitle(
"Track momentum (GeV)");
176 sistertracks->SetYTitle(
"Neighbor momentum (GeV)");
177 TH2F* dEdxvsp =
new TH2F(
"dEdxvsp",
"",100,0.15,1.3,100,-5.7,-5.);
178 dEdxvsp->SetXTitle(
"Log(p)");
179 dEdxvsp->SetYTitle(
"Log(dE/dx)");
180 TH2F* dEdxvsp_east =
new TH2F(
"dEdxvsp_east",
"",100,0.15,1.3,100,-5.7,-5.0);
181 dEdxvsp_east->SetXTitle(
"Log(p)");
182 dEdxvsp_east->SetYTitle(
"Log(dE/dx)");
183 TH2F* dEdxvsp_west =
new TH2F(
"dEdxvsp_west",
"",100,0.15,1.3,100,-5.7,-5.0);
184 dEdxvsp_west->SetXTitle(
"Log(p)");
185 dEdxvsp_west->SetYTitle(
"Log(dE/dx)");
186 TH2F* energyleak2 =
new TH2F(
"energyleak2",
"",20,0.0,0.03,20,0.0,1.0);
187 TH1F* energymean2 =
new TH1F(
"energymean2",
"",20,0.0,0.03);
188 TH1F* towermult =
new TH1F(
"towermult",
"",9,0.0,9.0);
189 energyleak2->SetXTitle(
"#DeltaR");
190 energyleak2->SetYTitle(
"leaked energy/total energy");
191 towermult->SetXTitle(
"Neighbors with energy");
192 TH2F* multvsp =
new TH2F(
"multvsp",
"",20,0.0,20.0,9,0.0,9.0);
193 multvsp->SetXTitle(
"Track momentum (GeV)");
194 multvsp->SetYTitle(
"Neighbors with energy");
195 TH1F* multmean =
new TH1F(
"multmean",
"",20,0.0,20.0);
196 TH2F* tep3 =
new TH2F(
"tep3",
"2 < p < 3",20,0.0,0.03,20,0.0,4.0);
197 TH2F* tep5 =
new TH2F(
"tep5",
"3 < p < 5",20,0.0,0.03,20,0.0,4.0);
198 TH2F* tep10 =
new TH2F(
"tep10",
"5 < p < 10",20,0.0,0.03,20,0.0,4.0);
199 tep3->SetXTitle(
"DeltaR");
200 tep3->SetYTitle(
"Total energy / track momentum");
201 tep5->SetXTitle(
"DeltaR");
202 tep5->SetYTitle(
"Total energy / track momentum");
203 tep10->SetXTitle(
"DeltaR");
204 tep10->SetYTitle(
"Total energy / track momentum");
205 TH1F* tep3mean =
new TH1F(
"tep3mean",
"",20,0,0.03);
206 TH1F* tep5mean =
new TH1F(
"tep5mean",
"",20,0,0.03);
207 TH1F* tep10mean =
new TH1F(
"tep10mean",
"",20,0,0.03);
208 TH1F* multen =
new TH1F(
"multen",
"",40,0.0,1.0);
209 multen->SetXTitle(
"Energy in neighbor towers (GeV)");
210 TH1F* east_histo =
new TH1F(
"east_histo",
"Electron E/p in East",40,0.0,2.0);
211 TH1F* west_histo =
new TH1F(
"west_histo",
"Electron E/p in West",40,0.0,2.0);
212 TH1F* all_histo =
new TH1F(
"all_histo",
"Electron E/p",40,0.0,2.0);
213 TH1F* notrg =
new TH1F(
"notrg",
"Electron E/p",40,0.0,2.0);
214 TH2F* pvsep =
new TH2F(
"pvsep",
"Electron p vs E/p",120,0,3.0,20,0,20.0);
215 pvsep->SetYTitle(
"p (Gev)");
216 pvsep->SetXTitle(
"E/p");
217 TH2F* pvsep0 =
new TH2F(
"pvsep0",
"Electron p vs E/p",120,0,3.0,20,0,20.0);
218 pvsep0->SetYTitle(
"p (Gev)");
219 pvsep0->SetXTitle(
"E/p");
220 TH2F* evsep =
new TH2F(
"evsep",
"Electron E vs E/p",120,0,3.0,20,0,20.0);
221 evsep->SetYTitle(
"E (GeV)");
222 evsep->SetXTitle(
"E/p");
224 TH1F* bsmde =
new TH1F(
"bsmde",
"BSMDE ADC TOT",1500,0,1500);
225 TH1F* bsmdp =
new TH1F(
"bsmdp",
"BSMDP ADC TOT",1500,0,1500);
227 TH1F* bsmde_central =
new TH1F(
"bsmde_central",
"BSMDE ADC TOT",100,0,1500);
228 TH1F* bsmde_mid =
new TH1F(
"bsmde_mid",
"BSMDE ADC TOT",100,0,1500);
229 TH1F* bsmde_outer =
new TH1F(
"bsmde_outer",
"BSMDE ADC TOT",100,0,1500);
231 TH2F* bsmdep =
new TH2F(
"bsmdep",
"BSMDE v BSMDP",100,0,1500,100,0,1500);
233 TH2F* bsmdevp =
new TH2F(
"bsmdevp",
"BSMDE v p",100,1.0,15.0,100,0,1500);
234 TH2F* bsmdpvp =
new TH2F(
"bsmdpvp",
"BSMDP v p",100,1.0,15.0,100,0,1500);
235 TH2F* bsmdevep =
new TH2F(
"bsmdevep",
"BSMDE v E/p",100,0.0,2.0,100,0,1500);
236 TH2F* bsmdpvep =
new TH2F(
"bsmdpvep",
"BSMDP v E/p",100,0.0,2.0,100,0,1500);
238 TH2F* bsmdeve =
new TH2F(
"bsmdeve",
"BSMDE v E",100,1.0,30.0,100,0,1500);
239 TH2F* bsmdpve =
new TH2F(
"bsmdpve",
"BSMDP v E",100,1.0,30.0,100,0,1500);
241 TH1F* httrig =
new TH1F(
"httrig",
"HT Trigger",5,-0.5,4.5);
243 TH1F* pplus =
new TH1F(
"pplus",
"e+ p",100,0,20);
244 TH1F* pminus =
new TH1F(
"pminus",
"e- p",100,0,20);
246 TH1F* posep =
new TH1F(
"posep",
"e+ E/p",60,0,3.0);
247 TH1F* negep =
new TH1F(
"negep",
"e- E/p",60,0,3.0);
253 for(
int i = 0; i < ncrates; i++){
254 for(
int j = 0; j < 20; j++){
255 TString ecname,ecnamep,ecnamen;
256 ecname +=
"etacrate_";
264 ecnamep.ReplaceAll(
"te_",
"te_p_");
265 ecnamen.ReplaceAll(
"te_",
"te_n_");
266 etacrate_histo[i*20+j] =
new TH1F(ecname.Data(),ecname.Data(),60,0.0,3.0);
267 etacrate_histo_p[i*20+j] =
new TH1F(ecnamep.Data(),ecnamep.Data(),60,0.0,3.0);
268 etacrate_histo_n[i*20+j] =
new TH1F(ecnamen.Data(),ecnamen.Data(),60,0.0,3.0);
273 for(
int i=0; i<ntowers; i++){
275 sprintf(nameeh,
"electron_histo_%i",i+1);
276 electron_histo[i] =
new TH1D(nameeh,
"",60,0.,3.0);
277 electron_histo[i]->SetXTitle(
"E/p");
283 for(
int i = 0; i < 21; i++){
287 bghisto[i] =
new TH1F(namebg.Data(),namebg.Data(),60,0,3.0);
290 for(
int i = 0; i < ncrates; i++){
293 sprintf(name,
"crate_%i",i+1);
294 sprintf(title,
"E/p for Crate %i",i+1);
295 crate_histo[i] =
new TH1F(name,title,60,0.,3.0);
296 crate_histo[i]->SetXTitle(
"E/p");
299 for(
int i = 0; i < nrings/2; i++){
301 sprintf(name,
"ring2_histo_%i",i);
302 ring2_histo[i] =
new TH1F(name,
"",60,0.,3.0);
303 ring2_histo[i]->SetXTitle(
"E/p");
307 for(
int i=0; i<nrings;i++)
309 sprintf(name2,
"ring_histo_%i",i);
312 ring_histo[i] =
new TH1D(name2,
"",60,0.,3.0);
313 ring_histo[i]->SetXTitle(
"E/p");
315 sprintf(namerpve,
"ring_pve_%i",i);
316 ring_pve[i] =
new TH2F(namerpve,
"",20,0,20.0,20,0,20.0);
317 ring_pve[i]->SetXTitle(
"E (GeV)");
318 ring_pve[i]->SetYTitle(
"p (GeV)");
321 for(
int i = 0; i < 6; i++){
323 sprintf(jname,
"jan_pve_%i",i);
324 jan_pve[i] =
new TH2F(jname,
"",120,0,3.0,20,0,20.0);
325 jan_pve[i]->SetXTitle(
"E/p");
326 jan_pve[i]->SetYTitle(
"p (GeV)");
329 gStyle->SetOptStat(
"oue");
330 gStyle->SetOptFit(111);
331 gStyle->SetCanvasColor(10);
332 gStyle->SetCanvasBorderMode(0);
333 gStyle->SetOptTitle(0);
334 gStyle->SetPalette(1);
335 gStyle->SetStatColor(0);
339 tree->SetBranchAddress(
"clusters",&cluster);
345 int nentries = tree->GetEntries();
346 cout<<nentries<<endl;
355 for(
int j=0; j<nentries; j++){
357 track = &(cluster->centralTrack);
358 TClonesArray *tracks = cluster->tracks;
359 if(j % 500000 == 0) cout<<
"reading "<<j<<
" of "<<nentries<<endl;
361 httrig->Fill((
float)track->htTrig);
363 if(track->charge > 0)pplus->Fill(track->p);
364 if(track->charge < 0)pminus->Fill(track->p);
368 for(
int i = 0; i < 11; i++){
369 if(track->smde_adc[i] > track->smde_pedestal[i])bsmdeadctot += track->smde_adc[i] - track->smde_pedestal[i];
370 if(track->smdp_adc[i] > track->smdp_pedestal[i])bsmdpadctot += track->smdp_adc[i] - track->smdp_pedestal[i];
373 double dR = TMath::Sqrt(track->deta*track->deta + track->dphi*track->dphi);
376 double scaled_adc = (track->tower_adc[0] - track->tower_pedestal[0]) / track->p;
378 int index = track->tower_id[0];
381 eta = helper->getEta(index);
382 if(TMath::Abs(eta) > 0.968) eta += 0.005 * TMath::Abs(eta)/eta;
383 etaindex = ((TMath::Nint(eta * 1000.0) + 25)/50 + 19);
384 int geantetaindex = ((TMath::Nint(fabs(eta) * 1000.0) + 25)/50 - 1);
386 double geant_scale = geant_fits[geantetaindex]->Eval(dR);
387 scaled_adc /= geant_scale;
393 if(geantetaindex == 19)dR *= 0.025/0.017;
396 double tgain = gains[index-1];
399 if((track->tower_adc[0] - track->tower_pedestal[0]) < 2.5 * track->tower_pedestal_rms[0])
continue;
401 dEdxvsp->Fill(TMath::Log10(track->p),TMath::Log10(track->dEdx));
402 if(track->tower_id[0] <= 2400)dEdxvsp_west->Fill(TMath::Log10(track->p),TMath::Log10(track->dEdx));
403 if(track->tower_id[0] > 2400)dEdxvsp_east->Fill(TMath::Log10(track->p),TMath::Log10(track->dEdx));
405 trgcheck->Fill(track->nonhtTrig,track->htTrig);
407 if(track->tower_id[0] != track->tower_id_exit)
continue;
410 if(status[index-1]!=1)
continue;
412 pvsep0->Fill(scaled_adc*tgain,track->p);
413 if(track->p > 10)
continue;
418 if(track->htTrig == 2 && track->nonhtTrig == 0)
continue;
421 float squarefid = 0.02;
426 int numsis = tracks->GetEntries();
430 for(
int i = 0; i < 9; i++){
431 if(track->tower_adc[i] - track->tower_pedestal[i] < 0)
continue;
432 float theta = helper->getTheta(track->tower_id[i]);
433 float nextEt = (track->tower_adc[i] - track->tower_pedestal[i]) * bemctables->calib(1,track->tower_id[i])*sin(theta);
441 if(track->dEdx > 3.5e-6 && track->dEdx <5.0e-6 && numsis ==0 &&maxId == 0)drvsep->Fill(scaled_adc*tgain,dR);
442 if(dR > 0.02)
continue;
453 for(
int i = 0; i < 21; i++){
456 if(track->dEdx*1e7 > 25 + i && track->dEdx*1e7 < 26+i)bghisto[i]->Fill(scaled_adc*tgain);
460 if(track->dEdx < 3.5e-6 || track->dEdx > 4.5e-6)
continue;
470 if(numsis > 0)
continue;
473 if(maxId != 0)
continue;
477 if(track->htTrig!=2)notrg->Fill(scaled_adc*tgain);
486 float phi = helper->getPhi(index);
489 etacrate_histo[(crate-1)*20+geantetaindex]->Fill(scaled_adc*tgain);
490 if(track->charge > 0)etacrate_histo_p[(crate-1)*20+geantetaindex]->Fill(scaled_adc*tgain);
491 if(track->charge < 0)etacrate_histo_n[(crate-1)*20+geantetaindex]->Fill(scaled_adc*tgain);
493 electron_histo[index-1]->Fill(scaled_adc*tgain);
494 ring_histo[etaindex]->Fill(scaled_adc*tgain);
495 if(etaindex == 0 || etaindex == 39){
499 ring_pve[etaindex]->Fill(scaled_adc*tgain*track->p,track->p);
501 dEdxvsp->Fill(TMath::Log10(track->p),TMath::Log10(track->dEdx));
503 float abseta = TMath::Abs(eta);
505 jan_pve[5]->Fill(scaled_adc*tgain,track->p);
506 }
else if(abseta > 0.9){
507 jan_pve[4]->Fill(scaled_adc*tgain,track->p);
508 }
else if(abseta > 0.6){
509 jan_pve[3]->Fill(scaled_adc*tgain,track->p);
510 }
else if(abseta > 0.3){
511 jan_pve[2]->Fill(scaled_adc*tgain,track->p);
512 }
else if(abseta > 0.05){
513 jan_pve[1]->Fill(scaled_adc*tgain,track->p);
515 jan_pve[0]->Fill(scaled_adc*tgain,track->p);
518 all_histo->Fill(scaled_adc*tgain);
519 pvsep->Fill(scaled_adc*tgain,track->p);
520 evsep->Fill(scaled_adc*tgain,track->p*scaled_adc*tgain);
521 tevsp->Fill(track->p,scaled_adc*tgain*track->p);
523 if(track->charge > 0)posep->Fill(scaled_adc*tgain);
524 if(track->charge < 0)negep->Fill(scaled_adc*tgain);
527 bsmde->Fill(bsmdeadctot);
528 bsmdp->Fill(bsmdpadctot);
529 bsmdep->Fill(bsmdeadctot,bsmdpadctot);
532 bsmde_outer->Fill(bsmdeadctot);
533 }
else if(abseta > 0.3){
534 bsmde_mid->Fill(bsmdeadctot);
536 bsmde_central->Fill(bsmdeadctot);
539 bsmdevp->Fill(track->p,bsmdeadctot);
540 bsmdpvp->Fill(track->p,bsmdpadctot);
541 bsmdevep->Fill(scaled_adc*tgain,bsmdeadctot);
542 bsmdpvep->Fill(scaled_adc*tgain,bsmdpadctot);
544 bsmdeve->Fill(scaled_adc*tgain*track->p,bsmdeadctot);
545 bsmdpve->Fill(scaled_adc*tgain*track->p,bsmdpadctot);
547 if(dR > 0.015)
continue;
548 if(track->tower_id[0] <= 2400){
549 west_histo->Fill(scaled_adc*tgain);
551 if(track->tower_id[0] > 2400){
552 east_histo->Fill(scaled_adc*tgain);
556 cout<<
"processed electron tree"<<endl;
557 cout<<
"ngoodhit: "<<ngoodhit<<endl;
558 cout<<
"nenterexit: "<<nenterexit<<endl;
559 cout<<
"n not trig: "<<nnottrig<<endl;
560 cout<<
"n p < 10: "<<nplt10<<endl;
561 cout<<
"n in fidu: "<<nfidu<<endl;
562 cout<<
"nbsmdhit: "<<nbsmdgood<<endl;
563 cout<<
"n no sis: "<<nnosis<<endl;
564 cout<<
"n final: "<<nfinal<<endl;
567 for(
int h=0;h<21;h++){
568 TH1D* projection = energyleak->ProjectionY(
"projection",h,h);
569 float mean = projection->GetMean();
570 energymean->SetBinContent(h,mean);
571 TH1D* projection1 = findbg->ProjectionY(
"projection1",h,h);
572 float mean1 = projection1->GetMean();
573 leakmean->SetBinContent(h,mean1);
574 TH1D* projection2 = tevsp->ProjectionY(
"projection2",h,h);
575 float mean2 = projection2->GetMean();
576 pmean->SetBinContent(h,mean2);
578 TH1D* projection3 = tevspcent->ProjectionY(
"projection3",h,h);
579 float mean3 = projection3->GetMean();
580 cmean->SetBinContent(h,mean3);
581 TH1D* projection4 = energyleak2->ProjectionY(
"projection4",h,h);
582 float mean4 = projection4->GetMean();
583 energymean2->SetBinContent(h,mean4);
584 TH1D* projection5 = multvsp->ProjectionY(
"projection5",h,h);
585 float mean5 = projection5->GetMean();
586 multmean->SetBinContent(h,mean5);
587 TH1D* projection6 = tep3->ProjectionY(
"projection6",h,h);
588 float mean6 = projection6->GetMean();
589 tep3mean->SetBinContent(h,mean6);
590 TH1D* projection7 = tep3->ProjectionY(
"projection7",h,h);
591 float mean7 = projection7->GetMean();
592 tep5mean->SetBinContent(h,mean7);
593 TH1D* projection8 = tep3->ProjectionY(
"projection8",h,h);
594 float mean8 = projection8->GetMean();
595 tep10mean->SetBinContent(h,mean8);
598 TF1* fitleak =
new TF1(
"fitleak",
"[0]",0,0.03);
599 fitleak->SetLineWidth(0.1);
600 leakmean->Fit(fitleak,
"rq");
632 for(
int i=0; i<nrings; i++){
636 sprintf(name,
"ring_fit_%i",i);
648 ring_histo[i]->Sumw2();
651 ringfit[i] =
new TF1(name,
"pol1(0) + gaus(2)");
652 ringfit[i]->SetParLimits(0,0,10.0*ring_histo[i]->GetBinContent(1));
653 ringfit[i]->SetParLimits(1,-10000,0);
654 ringfit[i]->SetParLimits(2,0,10.0*ring_histo[i]->GetMaximum());
655 ringfit[i]->SetParLimits(3,0,10);
656 ringfit[i]->SetParameter(0,ring_histo[i]->GetBinContent(1));
657 ringfit[i]->SetParameter(1,-ring_histo[i]->GetBinContent(1)/6.0);
658 ringfit[i]->SetParameter(2,ring_histo[i]->GetMaximum());
659 ringfit[i]->SetParameter(3,0.95);
660 ringfit[i]->SetParameter(4,0.15);
661 ringfit[i]->SetParNames(
"constant1",
"Slope",
"constant2",
"Mean",
"Sigma");
673 ringfit[i]->SetLineColor(kBlue);
674 ringfit[i]->SetLineWidth(0.6);
676 ring_histo[i]->Fit(ringfit[i],
"rql",
"",0.2,1.7);
678 ringprec->SetBinContent(i+1,(ringfit[i]->GetParameter(3)));
679 ringprec->SetBinError(i+1,ringfit[i]->GetParameter(4));
680 ringprec2->SetBinContent(i+1,(ringfit[i]->GetParameter(3)));
681 ringprec2->SetBinError(i+1,ringfit[i]->GetParError(3));
684 float mean = ringfit[i]->GetParameter(3);
685 float merr = ringfit[i]->GetParError(3);
686 cout<<
"ring "<<i<<
" "<<mean<<
" "<<merr/mean<<
" "<<ring_histo[i]->GetEntries()<<endl;
689 for(
int i = 0; i < nrings/2; i++){
690 ring2_histo[i]->Add(ring_histo[2*i]);
691 ring2_histo[i]->Add(ring_histo[2*i+1]);
692 sprintf(name,
"ring2_fit_%i",i);
693 ring2fit[i] =
new TF1(name,
"pol1(0) + gaus(2)",0.3,1.7);
695 ring2_histo[i]->Rebin(3);
697 ring2fit[i]->SetParLimits(0,0,10.0*ring2_histo[i]->GetBinContent(1));
698 ring2fit[i]->SetParLimits(1,-10000,0);
699 ring2fit[i]->SetParLimits(2,0,10.0*ring2_histo[i]->GetMaximum());
700 ring2fit[i]->SetParLimits(3,0,10);
701 ring2fit[i]->SetParLimits(4,0.17,0.175);
702 ring2fit[i]->SetParameter(0,ring2_histo[i]->GetBinContent(1));
703 ring2fit[i]->SetParameter(1,-ring2_histo[i]->GetBinContent(1)/6.0);
704 ring2fit[i]->SetParameter(2,ring2_histo[i]->GetMaximum());
705 ring2fit[i]->SetParameter(3,0.95);
706 ring2fit[i]->SetParameter(4,0.11245);
707 ring2fit[i]->SetParNames(
"constant1",
"Slope",
"constant2",
"Mean",
"Sigma");
709 ring2_histo[i]->Fit(ring2fit[i],
"rql",
"",0.3,1.7);
711 ring2prec->SetBinContent(i+1,(ring2fit[i]->GetParameter(3)));
712 ring2prec->SetBinError(i+1,ring2fit[i]->GetParameter(4));
713 ring2prec2->SetBinContent(i+1,(ring2fit[i]->GetParameter(3)));
714 ring2prec2->SetBinError(i+1,ring2fit[i]->GetParError(3));
716 cout<<
"ring2 "<<i<<
" "<<ring2fit[i]->GetParameter(3)<<
" "<<ring2fit[i]->GetParError(3)<<endl;
719 for(
int i = 0; i < ntowers; i++){
721 sprintf(name,
"electron_fit_%i",i+1);
735 fit[i] =
new TF1(name,
"pol0(0)+gaus(1)");
736 fit[i]->SetParLimits(0,0,10.0*electron_histo[i]->GetBinContent(1));
737 fit[i]->SetParLimits(1,0,10.0*electron_histo[i]->GetMaximum());
738 fit[i]->SetParLimits(2,0,10);
739 fit[i]->SetParameter(0,electron_histo[i]->GetBinContent(1));
740 fit[i]->SetParameter(1,electron_histo[i]->GetMaximum());
741 fit[i]->SetParameter(2,0.95);
742 fit[i]->SetParameter(3,0.15);
743 fit[i]->SetParNames(
"constant1",
"constant2",
"Mean",
"Sigma");
745 electron_histo[i]->Fit(fit[i],
"rql",
"",0.3,1.7);
748 ofstream fitfile(ffname);
750 TF1* etacrate_fit[ncrates*20];
751 for(
int ii = 0; ii < ncrates; ii++){
752 for(
int j = 0; j < 20; j++){
761 etacrate_fit[i] =
new TF1(ecname.Data(),
"pol1(0) + gaus(2)",0.25,1.6);
763 etacrate_histo[i]->Rebin();
764 etacrate_fit[i]->SetParLimits(1,-10000,0);
765 etacrate_fit[i]->SetParLimits(2,0,10.0*etacrate_histo[i]->GetMaximum());
766 etacrate_fit[i]->SetParLimits(3,0,10);
767 etacrate_fit[i]->SetParameter(0,etacrate_histo[i]->GetBinContent(2));
768 etacrate_fit[i]->SetParameter(1,-etacrate_histo[i]->GetBinContent(2)/3.0);
769 etacrate_fit[i]->SetParameter(2,etacrate_histo[i]->GetMaximum());
770 etacrate_fit[i]->SetParameter(3,0.96134);
771 etacrate_fit[i]->SetParameter(4,0.141123);
772 etacrate_fit[i]->SetParNames(
"constant1",
"Slope",
"constant2",
"Mean",
"Sigma");
774 etacrate_histo[i]->Fit(etacrate_fit[i],
"rql",
"",0.25,1.5);
775 etacrate_histo_p[i]->Fit(etacrate_fit[i],
"rql",
"",0.25,1.5);
776 etacrate_histo_n[i]->Fit(etacrate_fit[i],
"rql",
"",0.25,1.5);
777 fitfile << i <<
" " << etacrate_histo[i]->GetFunction(
"fit")->GetParameter(3) <<
" " << etacrate_histo_p[i]->GetFunction(
"fit")->GetParameter(3) <<
" " << etacrate_histo_n[i]->GetFunction(
"fit")->GetParameter(3) << endl;
782 ofstream newgain(ngname);
785 float gains2[ntowers];
786 float gerr2[ntowers];
787 for(
int i = 0; i < ntowers; i++){
788 float eta = helper->getEta(i+1);
791 int geantetaindex = ((TMath::Nint(fabs(eta) * 1000.0) + 25)/50 - 1);
800 if(TMath::Abs(eta) > 0.968) eta += 0.005 * TMath::Abs(eta)/eta;
801 int etaindex = ((TMath::Nint(eta * 1000.0) + 25)/50 + 19);
811 float adjust = etacrate_histo[(crate-1)*20+geantetaindex]->GetFunction(
"fit")->GetParameter(3);
812 float aerr = etacrate_histo[(crate-1)*20+geantetaindex]->GetFunction(
"fit")->GetParError(3);
813 if(geantetaindex == 19){
814 adjust = ringfit[etaindex]->GetParameter(3);
815 aerr = ringfit[etaindex]->GetParError(3);
818 float gerr = peakerr[i]*gains[i]/peaks[i];
819 ne = sqrt(pow(og*aerr/(adjust*adjust),2) + pow(gerr/adjust,2));
821 newgain << i+1 <<
" " << ng <<
" " << ne <<
" " << status[i] << endl;
960 double background_only_fit(
double *x,
double *par){
961 double par3 = par[0]/1.5;
962 double par4 = par[1] + 10.;
963 double par5 = par[2] * 6.5;
967 double arg1 = (x[0]-par[1])/par[2];
968 double arg2 = (x[0]-par4)/par5;
969 fitval = par[0]*TMath::Exp(-0.5*arg1*arg1) + par3*TMath::Exp(-0.5*arg2*arg2);
975 double fit_function(
double *x,
double *par){
983 if(par[3] != 0)par3 = par[0] / par[3];
984 double par6 = par3/1.5;
985 double par7 = par[4] + 10.;
986 double par8 = par[5] * 6.5;
989 if(par[2] != 0 && par[5] != 0){
990 double arg1 = (x[0]-par[1])/par[2];
991 double arg2 = (x[0]-par[4])/par[5];
992 double arg3 = (x[0]-par7)/par8;
993 fitval = par[0]*TMath::Exp(-0.5*arg1*arg1) + par3*TMath::Exp(-0.5*arg2*arg2) + par6*TMath::Exp(-0.5*arg3*arg3);
999 double fit_function2(
double *x,
double *par){
1007 if(par[3] != 0)par3 = par[0] / par[3];
1008 double par6 = par[6];
1009 double par7 = par[4] + 10.;
1010 double par8 = par[7];
1013 if(par[2] != 0 && par[5] != 0 && par8 != 0){
1014 double arg1 = (x[0]-par[1])/par[2];
1015 double arg2 = (x[0]-par[4])/par[5];
1016 double arg3 = (x[0])/par8;
1017 fitval = par[0]*TMath::Exp(-0.5*arg1*arg1) + par3*TMath::Exp(-0.5*arg2*arg2) + par6*TMath::Exp(-arg3);
1022 int lookup_crate(
float eta,
float phi)
1025 if (phi < -2.72)
return 5;
1026 else if (phi < -2.30)
return 6;
1027 else if (phi < -1.88)
return 7;
1028 else if (phi < -1.46)
return 8;
1029 else if( phi < -1.04)
return 9;
1030 else if( phi < -0.62)
return 10;
1031 else if( phi < -0.20)
return 11;
1032 else if( phi < 0.22)
return 12;
1033 else if( phi < 0.64)
return 13;
1034 else if( phi < 1.06)
return 14;
1035 else if( phi < 1.48)
return 15;
1036 else if( phi < 1.90)
return 1;
1037 else if( phi < 2.32)
return 2;
1038 else if( phi < 2.74)
return 3;
1041 if (phi < -2.72)
return 20;
1042 else if( phi < -2.30)
return 21;
1043 else if( phi < -1.88)
return 22;
1044 else if( phi < -1.46)
return 23;
1045 else if( phi < -1.04)
return 24;
1046 else if( phi < -0.62)
return 25;
1047 else if( phi < -0.20)
return 26;
1048 else if( phi < 0.22)
return 27;
1049 else if( phi < 0.64)
return 28;
1050 else if( phi < 1.06)
return 29;
1051 else if( phi < 1.48)
return 30;
1052 else if( phi < 1.90)
return 16;
1053 else if( phi < 2.32)
return 17;
1054 else if( phi < 2.74)
return 18;
void loadTables(const char *sqlTime, const char *flavor="ofl")
load directly from DB, no Maker needed
int GetCrateFromTowerId(int softId, int &crate, int &sequence) const
Get crate number and position in crate for Software Id.
StEmcDecoder * getDecoder()
Return pointer to decoder.