6 #include <TClonesArray.h>
14 #include "StEEmcUtil/database/EEmcDbItem.h"
17 #include "EEmcDb/EEmcDb.h"
19 #include "StEEmcUtil/database/StEEmcDb.h"
24 void EEsmdCal::initTileHistoAdc(
char cut,
const char *title,
int col) {
26 assert(iCut>=0 && iCut<kCut);
27 char tt1[100], tt2[500];
29 const char *cTile[mxTile]={
"Tower",
"Pres1",
"Pres2",
"Post"};
30 const char cT[mxTile]={
'T',
'P',
'Q',
'R'};
33 for(iT=0;iT<mxTile;iT++) {
34 for(
char iSub=0; iSub<MaxSubSec; iSub++){
35 for(
int iEta=0; iEta<MaxEtaBins; iEta++){
38 int iPhi=
iSect*MaxSubSec+iSub;
40 sprintf(core,
"%02d%c%c%02d",
sectID,cT[iT],sub,eta);
41 sprintf(tt1,
"%c%s",cut,core);
42 sprintf(tt2,
"%s(%c) %s , %s; ADC-ped",cTile[iT],cut,core,title);
46 h=
new TH1F(tt1,tt2,220,-20,200.);
48 h=
new TH1F(tt1,tt2,400,-50,350.);
51 hT[iCut][iT][iEta][iPhi]=h;
62 void EEsmdCal::initTileHistoEne(
char cut,
const char *title,
int col) {
64 assert(iCut>=0 && iCut<kCut);
65 char tt1[100], tt2[500];
67 const char *cTile[mxTile]={
"Tower",
"Pres1",
"Pres2",
"Post"};
68 const char cT[mxTile]={
'T',
'P',
'Q',
'R'};
69 const char *cUnits[mxTile]={
"(GeV)_EM",
"(MEV)_MIP",
"(MEV)_MIP",
"(MEV)_MIP"};
72 for(iT=0;iT<mxTile;iT++) {
73 for(
char iSub=0; iSub<MaxSubSec; iSub++){
74 for(
int iEta=0; iEta<MaxEtaBins; iEta++){
77 int iPhi=
iSect*MaxSubSec+iSub;
79 sprintf(core,
"%02d%c%c%02d",
sectID,cT[iT],sub,eta);
80 sprintf(tt1,
"%c%s",cut,core);
81 sprintf(tt2,
"%s(%c) %s , %s; ADC-ped/gain %s",cTile[iT],cut,core,title,cUnits[iT]);
83 TH1F *h=
new TH1F(tt1,tt2,200,-0.5,9.5);
86 hT[iCut][iT][iEta][iPhi]=h;
96 void EEsmdCal::addTwMipEbarsToHisto (
int col,
char mxC) {
103 sprintf(core,
"%02dT",
sectID);
105 TIterator *it=HList->MakeIterator();
107 while( (h=(TH1*) it->Next())) {
108 const char *name=h->GetName();
109 if(strstr(name,core)==0)
continue;
110 if(name[0]>mxC)
continue;
112 int iSub=name[4]-
'A';
113 int iEta=atoi(name+5)-1;
114 int iPhi=
iSect*MaxSubSec+iSub;
117 if(x->gain<=0)
continue;
118 TList *L=h->GetListOfFunctions();
120 float adcC=towerMipE[iEta]*x->gain;
121 if(name[0]>
'e') adcC=towerMipE[iEta];
123 TLine *ln=
new TLine(adcC,0,adcC,yMax);
124 ln->SetLineColor(kRed); ln->SetLineStyle(2);
127 float adc=adcC*twMipRelEneLow;
128 ln=
new TLine(adc,0,adc,yMax);
129 ln->SetLineColor(col);
132 adc=adcC*twMipRelEneHigh;
133 ln=
new TLine(adc,0,adc,yMax);
134 ln->SetLineColor(col);
141 void EEsmdCal::addPresMipEbarsToHisto (
int col,
char cT) {
146 assert(iT>kT && iT<mxTile);
150 sprintf(core,
"%02d%c",
sectID,cT);
152 TIterator *it=HList->MakeIterator();
154 while( (h=(TH1*) it->Next())) {
155 const char *name=h->GetName();
156 if(strstr(name,core)==0)
continue;
158 int iSub=name[4]-
'A';
159 int iEta=atoi(name+5)-1;
160 int iPhi=
iSect*MaxSubSec+iSub;
163 if(x->gain<=0)
continue;
165 float adcC=presMipE[iEta]*x->gain;
166 if(name[0]>
'e') adcC=presMipE[iEta]*1000;
168 TLine *ln=
new TLine(adcC,0,adcC,yMax);
169 ln->SetLineColor(col); ln->SetLineStyle(2);
170 TList *L=h->GetListOfFunctions();
178 void EEsmdCal::initSmdHist(
char cut,
const char *title,
int col) {
180 assert(iCut>=0 && iCut<kCut);
181 char tt1[100], tt2[500];
184 for(iuv=0;iuv<MaxSmdPlains;iuv++) {
185 for(istrip=0;istrip<MaxSmdStrips;istrip++) {
188 sprintf(core,
"%02d%c%03d",
sectID,iuv+
'U',istrip+1);
189 sprintf(tt1,
"%c%s",cut,core);
190 sprintf(tt2,
"SMD(%c) %s , %s; ADC-ped",cut,core,title);
192 TH1F *h=
new TH1F(tt1,tt2,400,-50,350);
194 h->SetLineColor(col);
197 hSs[iCut][iuv][istrip]=h;
205 void EEsmdCal::initSmdEneHist(
char cut,
const char *title,
int col) {
207 assert(iCut>=0 && iCut<kCut);
208 char tt1[100], tt2[500];
211 for(iuv=0;iuv<MaxSmdPlains;iuv++) {
212 for(istrip=0;istrip<MaxSmdStrips;istrip++) {
214 sprintf(core,
"%02d%c%03d",
sectID,iuv+
'U',istrip+1);
215 sprintf(tt1,
"%c%s",cut,core);
216 sprintf(tt2,
"SMD(%c) %s , %s; normal incident MIP energy (MeV)",cut,core,title);
218 TH1F *h=
new TH1F(tt1,tt2,200,-0.1,9.9);
219 h->SetLineColor(col);
222 hSs[iCut][iuv][istrip]=h;
230 void EEsmdCal::addSmdMipEbarsToHisto (
int col,
char cU) {
234 assert(cU==
'U' || cU==
'V');
238 sprintf(core,
"%02d%c",
sectID,cU);
240 TIterator *it=HList->MakeIterator();
242 while( (h=(TH1*) it->Next())) {
243 const char *name=h->GetName();
244 if(strstr(name,core)!=name+1)
continue;
248 int iStr=atoi(name+4)-1;
249 assert(iU>=0 && iU<MaxSmdPlains);
250 assert(iStr>=0 && iStr<MaxSmdStrips);
255 if((h->GetName()[0])==
'a') {
257 sprintf(tt3,
"%s, tube=%s",h->GetTitle(),x->
tube);
262 if(x->gain<=0)
continue;
263 TList *L=h->GetListOfFunctions();
264 float adcC=smdAvrMipE*x->gain;
265 if((h->GetName()[0])>
'b') adcC=smdAvrMipE*1000.;
267 TLine *ln=
new TLine(adcC,0,adcC,yMax);
268 ln->SetLineColor(col); ln->SetLineStyle(2);
279 void EEsmdCal::histoGains(){
283 for(iuv=0;iuv<MaxSmdPlains;iuv++) {
284 for(istrip=0;istrip<MaxSmdStrips;istrip++) {
288 if(x->gain<=0)
continue;
289 hA[16+iuv]->Fill(x->strip,x->gain);
291 const char *tube=x->
tube+2;
292 assert(tube[0]==
'S');
293 int box=atoi(tube+1);
294 int pmt=atoi(tube+3);
295 int pix=atoi(tube+6);
296 int xx=(pmt-1)*16+pix;
297 hA[5+box-1]->Fill(xx,x->gain);
305 for(iT=kP;iT<=kR;iT++)
306 for(iEta=0;iEta<MaxEtaBins;iEta++)
307 for(iPhi=0;iPhi<MaxPhiBins;iPhi++){
311 if(x->gain<=0)
continue;
314 const char *tube=x->
tube+2;
315 assert(tube[0]==
'P');
316 int pmt=atoi(tube+3);
317 int pix=atoi(tube+6);
318 int xx=(pmt-1)*16+pix;
319 hA[5+3]->Fill(xx,x->gain);
325 for(iEta=0;iEta<MaxEtaBins;iEta++)
326 for(iPhi=0;iPhi<MaxPhiBins;iPhi++){
329 if(x->gain<=0)
continue;
331 int ispir=(x->eta-1)*MaxSubSec + x->sub-
'A';
332 hA[4]->Fill(ispir,x->gain);
340 void EEsmdCal::initAuxHisto(){
343 memset(hA,0,
sizeof(hA));
345 char tt1[100], tt2[500], tt0[100];
350 sprintf(tt1,
"ug%02dT",
sectID);
351 sprintf(tt2,
"used tower gains sec=%d ; x=spiral=(eta-1)*5+subs-A; gain [ch/GeV]",
sectID);
352 h=
new TH1F(tt1,tt2, 60,-0.5,59.5);
358 sprintf(tt0,
"%02d_S%d",
sectID,i+1);
360 sprintf(tt0,
"%02d_P1",
sectID);
362 sprintf(tt1,
"ug%s",tt0);
363 sprintf(tt2,
"used gains MAPMT box %s ; chann=(pmt ID-1)*16+pix ; gain [ch/GeV]",tt0);
365 h=
new TH1F(tt1,tt2, MaxMapmtCrateCh,0.5, MaxMapmtCrateCh+0.5);
369 sprintf(tt1,
"my%02dStat",
sectID);
370 hA[9]=
new TH1F (tt1,
"type of events ",30,.5,30.5);
372 for(i=0;i<MaxSmdPlains;i++) {
373 sprintf(tt1,
"fr%02d%c",
sectID,i+
'U');
374 sprintf(tt2,
"freq. of MIP, UxV only, plane %02d%c; strip ID",
sectID,i+
'U');
375 h=
new TH1F(tt1,tt2,MaxSmdStrips,-0.5,MaxSmdStrips-0.5);
378 sprintf(tt1,
"mm%02d%c",
sectID,i+
'U');
379 sprintf(tt2,
"freq of 00xx00 pattern per plane %02d%c",
sectID,i+
'U');
380 h=
new TH1F(tt1,tt2,20,-0.5,19.5);
383 sprintf(tt1,
"fr%02d%cm",
sectID,i+
'U');
384 sprintf(tt2,
"freq. of best MIP, plane %02d%c; strip ID",
sectID,i+
'U');
385 h=
new TH1F(tt1,tt2,MaxSmdStrips,-0.5,MaxSmdStrips-0.5);
388 sprintf(tt1,
"ug%02d%c",
sectID,i+
'U');
389 sprintf(tt2,
"used gains for plane %02d%c; strip ID; gain [ch/GeV]",
sectID,i+
'U');
390 h=
new TH1F(tt1,tt2,MaxSmdStrips,0.5,MaxSmdStrips+0.5);
395 sprintf(tt1,
"ep%02dUorV",
sectID);
396 sprintf(tt2,
"#Sigma E of 2-strips, normal angle, best MIP , SMD %02dUorV; strip ID; MIP #Sigma E (MeV) ",
sectID);
397 h2=
new TH2F(tt1,tt2,30,0,300,100,-.1,10.);
401 sprintf(tt1,
"xy%02d",
sectID);
402 sprintf(tt2,
"MIP position , UxV only, sect=%02d; X(cm); Y(cm) ",
sectID);
403 h2=
new TH2F(tt1,tt2,500,-250,250,500,-250,250);
406 sprintf(tt1,
"xy%02dm",
sectID);
407 sprintf(tt2,
"MIP position, best MIP, sect=%02d; X(cm); Y(cm) ",
sectID);
408 h2=
new TH2F(tt1,tt2,250,-250,250,250,-250,250);
412 sprintf(tt1,
"eq%02dUV",
sectID);
413 sprintf(tt2,
"#Sigma from 4-strips, best MIP, plane %02dU+V; eta bin; #DeltaE MeV",
sectID);
414 h2=
new TH2F(tt1,tt2,12,.5,12.5,50,-.1,7.5);
418 sprintf(tt1,
"ca%02d",
sectID);
419 sprintf(tt2,
"# UxV candidates per tower, sector=%d; x=spiral=iPhi+60*iEta",
sectID);
420 int mxTw=MaxEtaBins*MaxPhiBins;
421 hA[24]=
new TH1F(tt1,tt2,mxTw,-0.5,mxTw-0.5);
427 if(hA[i]==0)
continue;
437 void EEsmdCal::fillOneTailHisto(
char cut,
int iEta,
int iPhi){
440 assert(iCut>=0 && iCut<kCut);
443 for(iT=0;iT<mxTile;iT++) {
444 TH1F *h=hT[iCut][iT][iEta][iPhi];
445 h->Fill(
tileAdc[iT][iEta][iPhi]);
451 void EEsmdCal::fillSmdHisto_a(){
456 for(iuv=0;iuv<MaxSmdPlains;iuv++) {
458 TH1F **hs=hSs[iCut][iuv];
460 for(istrip=0;istrip<MaxSmdStrips;istrip++) {
461 hs[istrip]->Fill(adc[istrip]);
469 void EEsmdCal::saveHisto(TString fname){
470 TString outName=fname+
".hist.root";
471 TFile f( outName,
"recreate");
473 printf(
"%d histos are written to '%s' ...\n",HList->GetEntries(),outName.Data());
int iSect
calibrate only one sector
int sectID
no. of input events
float smdAdc[MaxSmdPlains][MaxSmdStrips]
30 deg (only for this sector)
char tube[StEEmcNameLen]
name of PMT or MAPMT pixel
float tileAdc[mxTile][MaxEtaBins][MaxPhiBins]