9 #include "StJanBarrelDbMaker.h"
11 #include "StEmcRawMaker/defines.h"
12 #include "StEmcUtil/database/StBemcTables.h"
13 #include "StEmcUtil/geometry/StEmcGeom.h"
14 #include "StEmcUtil/database/StEmcDecoder.h"
22 setDbType(kStarDb); setHList(0);
29 StJanBarrelDbMaker::~StJanBarrelDbMaker(){
37 Int_t StJanBarrelDbMaker::Init(){
38 LOG_INFO<<Form(
"::Init() ")<<endm;
41 mBtowGeom = StEmcGeom::instance(
"bemc");
42 mBprsGeom = StEmcGeom::instance(
"bprs");
43 mSmdEGeom = StEmcGeom::instance(
"bsmde");
44 mSmdPGeom = StEmcGeom::instance(
"bsmdp");
52 return StMaker::Init();
58 Int_t StJanBarrelDbMaker::InitRun (
int runNo){
59 LOG_INFO<<Form(
"::InitRun(%d) algo params:dbType=%d",
66 mMappB =
new StEmcDecoder(GetDateTime().GetDate(),GetDateTime().GetTime());
70 janDb_bprsReMap=janDb_btowReMap=0;
72 if(par_dbType==kJanDb ) {
73 assert(par_dbType==kJanDb);
77 LOG_INFO<<
"upload local peds from run"<<pedRun<<endm;
80 const char *pedPath=
"/star/institutions/mit/balewski/2008-janDb-BprsPeds-v3.1";
81 sprintf(txt,
"%s/pedBprsR%d-allCap.hist.root",pedPath,pedRun);
82 TFile* fd=
new TFile(txt); assert(fd->IsOpen());
84 janDb_bprsPed2D=(TH2S *)fd->Get(
"pedBPRScap"); assert(janDb_bprsPed2D);
85 janDb_bprsSigPed2D=(TH2S *)fd->Get(
"rmsPedBPRScap"); assert(janDb_bprsSigPed2D);
86 janDb_bprsStat=(TH1S *)fd->Get(
"statBPRSallCap"); assert( janDb_bprsStat);
88 const char *path=
"calib-jan3.1/";
90 sprintf(txt,
"%s/mipGainBprs+Btow_v2.hist.root",path);
91 TFile* fd5=
new TFile(txt); assert(fd5->IsOpen());
93 const char *core[mxBTile]={
"btow",
"bprs"};
94 for(
int ibp=0;ibp<mxBTile;ibp++) {
95 TString tit=core[ibp]; tit+=
"MipGain";
96 janDb_mipMean[ibp]=(TH1F *)fd5->Get(tit); assert( janDb_mipMean[ibp]);
97 tit=core[ibp]; tit+=
"MipSig";
98 janDb_mipSig[ibp]=(TH1F *)fd5->Get(tit); assert( janDb_mipSig[ibp]);
99 tit=core[ibp]; tit+=
"MipStat";
100 janDb_mipStat[ibp]=(TH1F *)fd5->Get(tit); assert( janDb_mipStat[ibp]);
105 sprintf(txt,
"%s/bprsReMap-ver3.hist.root",path);
106 TFile* fd3=
new TFile(txt); assert(fd3->IsOpen());
107 janDb_bprsReMap=(TH1I *)fd3->Get(
"bprsReMap"); assert(janDb_bprsReMap);
108 printf(
"use BPRS softID corection: %s\n",txt);
112 sprintf(txt,
"%s/btowReMap-ver3.hist.root",path);
113 TFile* fd4=
new TFile(txt); assert(fd4->IsOpen());
114 janDb_btowReMap=(TH1I *)fd4->Get(
"btowReMap"); assert(janDb_btowReMap);
115 printf(
"use BTOW softID corection: %s\n",txt);
120 for(
int ibp=0;ibp<mxBTile;ibp++) {
121 for(
int id=1;
id<=mxBtow;
id++) {
122 float adcL=5., adcH=40.;
123 if(ibp==kBPrs) adcL=3.5;
124 int statGain=(int)mipStat(ibp)->GetBinContent(
id);
126 float mean=mipMean(ibp)->GetBinContent(
id);
127 float sig=mipSig(ibp)->GetBinContent(
id);
130 if(ibp==kBTow && adcL<5) adcL=5;
131 if(ibp==kBPrs && adcL<3.5) adcL=3.5;
132 if(adcH>2*mean) adcH=2*mean;
134 printf(
"%s id=%4d MIP mean=%.1f sig=%.1f adcL=%.1f H=%.1f\n",core[ibp],
id,mean,sig,adcL,adcH);
137 cut_mipAdcL[ibp][
id-1]=adcL;
138 cut_mipAdcH[ibp][
id-1]=adcH;
142 LOG_INFO<<Form(
"::InitRun() Load private DB, nBad BPRS=%.0f",janDb_bprsStat->GetEntries())<<endm;
144 printf(
"WARN: tmp disable 2 BPRS & 1 tiles\n");
147 janDb_bprsStat->SetBinContent(2821,99);
148 janDb_bprsStat->SetBinContent(3781,99);
163 for(softId=650; softId<750;softId++) {
165 mMappB->
GetPsdRDO(softId, RDO, posInFiber);
166 mMappB->
GetPsdId( RDO, posInFiber, newId,PMTbox,wire, A_value,
true);
167 assert(newId==softId);
172 printf(
"JJJBprs softID rdo posInFib \n");
174 for(softId=1; softId<=4800;softId++) {
175 mMappB->
GetPsdRDO(softId, RDO, posInFiber);
176 int newId=(int)bprsReMap()->GetBinContent(softId);
178 if(newId==4525) { RDO=2; posInFiber=487; }
179 if(newId==4526) { RDO=2; posInFiber=507; }
180 printf(
"JJJBprs %4d %2d %4d \n", newId,RDO,posInFiber);
181 janDb_bprsSoft2Hard->SetBinContent(softId, RDO*5000 + posInFiber);
185 printf(
"JJJBtow softID rdo posInFib \n");
186 for(
int softId=1; softId<=4800;softId++) {
191 printf(
"JJJBtow %4d %2d %4d \n", newId,RDO,posInFiber);
195 LOG_INFO<<Form(
"::InitRun() done")<<endm;
196 return StMaker::Init();
204 LOG_INFO<<Form(
"::Make() ")<<endm;
213 int StJanBarrelDbMaker::bprsCrate(
int softID) {
215 assert(softID<=mxBtow);
216 if(softID<=340 )
return 0;
217 else if(softID<=1540 )
return 1;
218 else if(softID<=2400 )
return 0;
219 else if(softID<=2900 )
return 2;
220 else if(softID<=4100 )
return 3;
228 float StJanBarrelDbMaker::pedTile(
int ibp,
int softID,
int capID){
229 assert(softID>0 && softID<=mxBtow);
230 assert(capID>=0 && capID<mxBcap);
234 if(ibp==kBPrs)jBP=BPRS;
236 float pedOfl,sigPedOfl;
237 mTables->
getPedestal(jBP,softID,capID,pedOfl,sigPedOfl);
242 if(ibp==kBPrs && par_dbType==kJanDb)
243 ped=0.1*janDb_bprsPed2D->GetBinContent(softID,capID+1);
252 float StJanBarrelDbMaker::sigPedTile(
int ibp,
int softID,
int capID){
254 assert(softID>0 && softID<=mxBtow);
255 assert(capID>=0 && capID<mxBcap);
259 if(ibp==kBPrs)jBP=BPRS;
261 float pedOfl,sigPedOfl;
262 mTables->
getPedestal(jBP,softID,capID,pedOfl,sigPedOfl);
267 if(ibp==kBPrs && par_dbType==kJanDb)
268 sigPed=0.1*janDb_bprsSigPed2D->GetBinContent(softID,capID+1);
279 int StJanBarrelDbMaker::statTile(
int ibp,
int softID){
281 assert(softID>0 && softID<=mxBtow);
284 if(ibp==kBPrs)jBP=BPRS;
286 mTables->
getStatus(jBP, softID, statOflPed,
"pedestal");
288 if(statOflPed!=1) stat=1;
292 if( softID==1075) stat=1;
293 if( softID==2969) stat=1;
294 if( softID==3289) stat=1;
298 if(ibp==kBPrs && par_dbType==kJanDb)
299 stat=(int)janDb_bprsStat->GetBinContent(softID);
309 void StJanBarrelDbMaker::initBprsGeometry(){
310 printf(
"\nggg BPRS geometry initialization\n");
313 for(
int id0=0; id0< mxBTetaBin; id0++) {
316 assert(mBprsGeom->getEta(
id,eta)==0);
318 assert(mBtowGeom->getEta(
id,eta2)==0);
319 printf(
"id=%d, BPRS eta=%f BTOW eta=%f\n",
id,eta,eta2);
345 int GetPsdId(
int RDO,
int posInFiber,
int &softId,
int &PMTbox,
int &wire,
int &A_value,
bool print=
false)
const;
348 int GetPsdRDO(
int softId,
int &RDO,
int &posInFiber)
const;
void getPedestal(Int_t det, Int_t softId, Int_t cap, Float_t &ped, Float_t &rms) const
Return pedestal mean and rms.
void loadTables(StMaker *anyMaker)
load tables.
int GetPsdRDO(int softId, int &RDO, int &posInFiber) const
Get PSD fiber and position from id.
int GetCrateFromTowerId(int softId, int &crate, int &sequence) const
Get crate number and position in crate for Software Id.
void getStatus(Int_t det, Int_t softId, Int_t &status, const char *option="") const
Return status.
int GetPsdId(int RDO, int posInFiber, int &softId, bool print=false) const
Get PSD id.