7 #include <TClonesArray.h>
14 #include "EEsmdPlain.h"
15 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
16 #include "StEEmcUtil/StEEmcSmd/EEmcSmdGeom.h"
17 #include "StEEmcUtil/EEmcSmdMap/EEmcSmdMap.h"
18 #include "StEEmcUtil/database/cstructs/eemcConstDB.hh"
19 #include "StEEmcUtil/database/EEmcDbItem.h"
22 #include "EEmcDb/EEmcDb.h"
24 #include "StEEmcUtil/database/StEEmcDb.h"
37 memset(hT,0,
sizeof(hT));
38 memset(hSs,0,
sizeof(hSs));
42 memset(dbT,0,
sizeof(dbT));
43 memset(dbS,0,
sizeof(dbS));
48 geoSmd= EEmcSmdGeom::instance();
49 mapSmd= EEmcSmdMap::instance();
51 thrMipSmdE=-1; emptyStripCount=-2;
52 twMipRelEneLow=-3; twMipRelEneHigh=-4;
53 offCenter=0.7; thrMipPresAdc=-5;
58 killStat=EEMCSTAT_ONLPED | EEMCSTAT_HOTSTR ;
60 printf(
"EEsmdCal() constructed\n");
65 EEsmdCal::~EEsmdCal() {}
70 void EEsmdCal::init( ){
71 printf(
"EEsmdCal() init , calibrate sector=%d\n",
sectID);
75 initTileHistoAdc(
'a',
"inclusive ADC ",kBlack);
76 initTileHistoAdc(
'd',
"ADC, tag: UxV 2*thr",kBlack);
77 initTileHistoAdc(
'e',
"ADC, tag: mipT UxV 2*thr",kBlue);
79 initTileHistoEne(
'f',
"energy, tag: UxV 2*thr",kBlack);
80 initTileHistoEne(
'g',
"energy, tag: mipT UxV 2*thr",kBlue);
82 initSmdHist(
'a',
"inclusive ADC");
83 initSmdHist(
'b',
"ADC, tag: best MIP",kBlue);
84 initSmdEneHist(
'e',
"Energy (K)+(K+1)*tgh(eta): best MIP",kBlack);
88 for(i=0;i<MaxSmdPlains;i++) {
89 smdHitPl[i].set(thrMipSmdE,emptyStripCount,i+
'U');
92 printf(
"use thrMipSmdE/MeV=%.2f emptyStripCount=%d twMipRelEne/high=%.2f/%.2f offCenter=%.2f maxStripAdc=%.1f thrMipPresAdc=%d\n", thrMipSmdE*1000.,emptyStripCount,twMipRelEneLow, twMipRelEneHigh,offCenter,maxStripAdc,thrMipPresAdc);
96 assert(twMipRelEneLow< twMipRelEneHigh);
98 for(
int i=0;i<MaxEtaBins;i++){
100 float tghEta=TMath::TanH(etaValue);
102 towerMipE[i]= 1./(2.89*tghEta);
103 presMipE[i]=0.0009/tghEta;
108 #if 0 //smdMap - histos for finding mapping
110 for( ij=0;ij<12;ij++) {
112 sprintf(t1,
"hM%c",
'a'+ij);
113 hM[ij]=
new TH1F(t1,t1,600,0.5,600.5);
123 void EEsmdCal::initRun(
int runID){
124 printf(
" EEsmdCal::initRun(%d)\n",runID);
126 #if 1 //smdMap verification
128 printf(
" EEsmdCal::initRun(%d) N-th time, Ignore\n",runID);
138 addTwMipEbarsToHisto(kGreen,
'g');
140 addPresMipEbarsToHisto(kGreen,
'P');
141 addPresMipEbarsToHisto(kGreen,
'Q');
142 addPresMipEbarsToHisto(kGreen,
'R');
144 addSmdMipEbarsToHisto(kGreen,
'U');
145 addSmdMipEbarsToHisto(kGreen,
'V');
151 void EEsmdCal:: mapTileDb(){
152 printf(
"EEsmdCal:: mapTileDb()\n");
155 char cT[mxTile]={
'T',
'P',
'Q',
'R'};
157 for(iT=0;iT<mxTile;iT++) {
158 for(
char iSub=0; iSub<MaxSubSec; iSub++){
159 for(
int iEta=0; iEta<MaxEtaBins; iEta++){
160 int iPhi=
iSect*MaxSubSec+iSub;
161 dbT[iT][iEta][iPhi]=eeDb->getTile(
sectID,iSub+
'A',iEta+1,cT[iT]);
169 for(iu=0;iu<MaxSmdPlains;iu++) {
171 for(istr=0;istr<MaxSmdStrips;istr++) {
173 dbS[iu][istr]=eeDb->getByStrip(
sectID,iu+
'U',istr+1);
182 void EEsmdCal::clear(){
184 memset(tileEne,0,
sizeof(tileEne));
185 memset(tileThr,0,
sizeof(tileThr));
187 memset(smdEne,0,
sizeof(smdEne));
189 memset(killT,
true,
sizeof(killT));
192 for(i=0;i<MaxSmdPlains;i++) {
199 void EEsmdCal::findSectorMip( ){
208 for(
char iSub=0; iSub<MaxSubSec; iSub++){
209 for(
int iEta=0; iEta<MaxEtaBins; iEta++){
210 int iPhi=
iSect*MaxSubSec+iSub;
211 fillOneTailHisto(
'a', iEta,iPhi);
218 if(ret>1) hA[9]->Fill(2);
219 if(ret==1) hA[9]->Fill(3);
226 #if 0 //smdMap verification
231 for(ist=0;ist<12;ist++)
232 scanSpike(
smdAdc[1][30+ist-1],hM[ist]);
237 for(nU=0;nU<plU->nMatch;nU++){
238 for(nV=0;nV<plV->nMatch;nV++){
240 calibAllwithMip(plU->iStrip[nU],plV->iStrip[nV]);
250 void EEsmdCal::calibAllwithMip(
int iStrU,
int iStrV){
259 int iSecX, iSubX, iEtaX;
261 int ret=geoTw->
getTower(r, iSecX, iSubX, iEtaX,dphi, deta);
264 if(ret==0 || iSecX!=
iSect)
return;
268 hA[10]->Fill(iStrU+1);
269 hA[11]->Fill(iStrV+1);
272 int inCenter=(fabs(dphi)<offCenter && fabs(deta)<offCenter);
273 ((TH2F*) hA[21])->Fill( r.x(),r.y());
275 if(!inCenter)
return;
279 int iPhiX=
iSect*MaxSubSec+iSubX;
280 hA[24]->Fill(iPhiX+iEtaX*MaxPhiBins);
284 float adcT=
tileAdc[kT][iEtaX][iPhiX];
285 float adcP=
tileAdc[kP][iEtaX][iPhiX];
286 float adcQ=
tileAdc[kQ][iEtaX][iPhiX];
287 float adcR=
tileAdc[kR][iEtaX][iPhiX];
290 float eneT=tileEne[kT][iEtaX][iPhiX];
291 float eneP=tileEne[kP][iEtaX][iPhiX]*1000;
292 float eneQ=tileEne[kQ][iEtaX][iPhiX]*1000;
293 float eneR=tileEne[kR][iEtaX][iPhiX]*1000;
297 bool thrP=
false, thrQ=
false, thrR=
false, thrDum=
false;
298 bool *thr_p[mxTile]={&thrDum,&thrP,&thrQ,&thrR};
301 for (iT=kP; iT<=kR;iT++) {
302 bool thr=tileThr[iT][iEtaX][iPhiX] ;
303 thr= thr || killT[iT][iEtaX][iPhiX];
304 #if 0 //.... after pre/post calibration is avaliable
305 float preMipRelEneLow=0.6, preMipRelEneHigh=3.0;
306 float ene2Mip=tileEne[iT][iEtaX][iPhiX]/presMipE[iEtaX];
307 thr= thr && ene2Mip>preMipRelEneLow && ene2Mip<preMipRelEneHigh;
320 float RelTwEne=tileEne[kT][iEtaX][iPhiX]/towerMipE[iEtaX];
321 bool mipT= RelTwEne>twMipRelEneLow && RelTwEne<twMipRelEneHigh;
322 mipT= mipT || killT[kT][iEtaX][iPhiX];
326 if(thrR) hA[9]->Fill(7);
328 if(mipT )hA[9]->Fill(8);
332 if( thrP && thrQ && thrR ) hT[iCut][kT][iEtaX][iPhiX]->Fill(adcT);
333 if( mipT && thrQ && thrR ) hT[iCut][kP][iEtaX][iPhiX]->Fill(adcP);
334 if( mipT && thrP && thrR ) hT[iCut][kQ][iEtaX][iPhiX]->Fill(adcQ);
335 if( mipT && thrP && thrQ ) hT[iCut][kR][iEtaX][iPhiX]->Fill(adcR);
339 if( mipT && thrP && thrQ && thrR ){
340 hT[iCut][kT][iEtaX][iPhiX]->Fill(adcT);
341 hT[iCut][kP][iEtaX][iPhiX]->Fill(adcP);
342 hT[iCut][kQ][iEtaX][iPhiX]->Fill(adcQ);
343 hT[iCut][kR][iEtaX][iPhiX]->Fill(adcR);
348 if( thrP && thrQ && thrR ) hT[iCut][kT][iEtaX][iPhiX]->Fill(eneT);
349 if( mipT && thrQ && thrR ) hT[iCut][kP][iEtaX][iPhiX]->Fill(eneP);
350 if( mipT && thrP && thrR ) hT[iCut][kQ][iEtaX][iPhiX]->Fill(eneQ);
351 if( mipT && thrP && thrQ ) hT[iCut][kR][iEtaX][iPhiX]->Fill(eneR);
354 if( mipT && thrP && thrQ && thrR ){
355 hT[iCut][kT][iEtaX][iPhiX]->Fill(eneT);
356 hT[iCut][kP][iEtaX][iPhiX]->Fill(eneP);
357 hT[iCut][kQ][iEtaX][iPhiX]->Fill(eneQ);
358 hT[iCut][kR][iEtaX][iPhiX]->Fill(eneR);
359 ((TH2F*) hA[22])->Fill( r.x(),r.y());
363 if( mipT && thrP && thrQ && thrR ) {
367 int iStr[MaxSmdPlains];
371 for(iuv=0;iuv<MaxSmdPlains;iuv++) {
373 for(i2=0;i2<mx;i2++) {
374 int istrip=iStr[iuv]+i2;
375 float adc=
smdAdc[iuv][istrip];
376 float ene=smdEne[iuv][istrip]*twTghEta[iEtaX]*1000;
380 hSs[
'b'-
'a'][iuv][istrip]->Fill(adc);
384 int istrip1=iStr[iuv];
385 ((TH2F*) hA[20])->Fill(istrip1+1,e12);
386 hSs[
'e'-
'a'][iuv][istrip1]->Fill(e12);
387 hA[14+iuv]->Fill(istrip1+1);
390 ((TH2F*) hA[23])->Fill(iEtaX+1,eUV);
398 TVector3 r1=bar->end1;
399 TVector3 r2=bar->end2;
401 if(r1.Eta()<r2.Eta()) {
408 float dist=sqrt(dx*dx+dy*dy);
409 int iG=istrip/stripGang;
410 assert(iG>=0 && iG <MaxAt);
411 hSc[iuv][iSubX][iG]->Fill(ene);
412 hSeta[iuv][iSubX][iG]->Fill(r.Eta());
413 hSdist[iuv][iSubX][iG]->Fill(dist);
418 int EEsmdCal::getUxVmip(){
422 for(iuv=0;iuv<MaxSmdPlains;iuv++) {
424 pl->scanAdc(smdEne[iuv], thrMipSmdE);
426 pl->findMipPattern();
427 hA[12+iuv]->Fill(pl->nMatch);
432 int ret=smdHitPl[0].nMatch*smdHitPl[1].nMatch;
445 void EEsmdCal::finish(
int k){
446 printf(
"\n EEsmdCal::finish(sec=%d) nInpEve=%d \n",
sectID,nInpEve);
450 printf(
"drawing ...\n");
454 TString tt=
"sec"; tt+=
sectID;
455 TCanvas *c=
new TCanvas(tt,tt,400,400);
458 TH2F * h=(TH2F *)hA[22];
460 for(iuv=0;iuv<2;iuv++) {
470 TVector3 r1=bar->end1;
471 TVector3 r2=bar->end2;
473 TLine *ln=
new TLine(r1.x(),r1.y(),r2.x(),r2.y());
475 ln->SetLineColor(kRed);
477 if(strip==161 ||strip==201 ||strip==241 )
continue;
478 TString strT=uv; strT+=strip;
481 tx=
new TText(r2.x()+1,r2.y()-5,strT);
484 tx=
new TText(r2.x()-10,r2.y()-8,strT);
486 tx=
new TText(r2.x()-20,r2.y(),strT);
491 for(sub=
'A'; sub<=
'E';sub++) {
496 TText *tx=
new TText(x,y,strT);
506 #if 0 //smdMap verification
509 void EEsmdCal:: scanSpike(
float adc1, TH1F *h){
511 if(adc1<adcTh)
return;
513 for(istrip=0+3;istrip<MaxSmdStrips-3;istrip++) {
515 for(iuv=0;iuv<2;iuv++) {
517 if(
smdAdc[iuv][istrip-3]>=adcTh)
continue;
518 if(
smdAdc[iuv][istrip-2]>=adcTh)
continue;
519 if(
smdAdc[iuv][istrip+2]>=adcTh)
continue;
520 if(
smdAdc[iuv][istrip+3]>=adcTh)
continue;
522 if(
smdAdc[iuv][istrip-1]>=adcTh)
continue;
523 if(
smdAdc[iuv][istrip+1]>=adcTh)
continue;
525 if(
smdAdc[iuv][istrip ]< adcTh)
continue;
526 h->Fill(1+300*iuv+istrip);
int iSect
calibrate only one sector
int sectID
no. of input events
float smdAdc[MaxSmdPlains][MaxSmdStrips]
30 deg (only for this sector)
float tileAdc[mxTile][MaxEtaBins][MaxPhiBins]
TVector3 getIntersection(Int_t iSec, Int_t iUStrip, Int_t iVStrip, const TVector3 &vertex) const
StructEEmcStrip * getStripPtr(const Int_t iStrip, const Int_t iUV, const Int_t iSec)
return a strip pointer from indices
bool getTower(const TVector3 &r, int &sec, int &sub, int &etabin, Float_t &dphi, Float_t &deta) const
Float_t getEtaMean(UInt_t eta) const