14 #include "StRHICfDbMaker.h"
15 #include "St_db_Maker/St_db_Maker.h"
16 #include "StMessMgr.h"
17 #include "tables/St_rhicfPedestal_Table.h"
18 #include "tables/St_rhicfPedestalF_Table.h"
19 #include "tables/St_rhicfGain_Table.h"
20 #include "tables/St_rhicfPlateRange_Table.h"
21 #include "tables/St_rhicfBarMap_Table.h"
22 #include "tables/St_rhicfBarPos_Table.h"
23 #include "tables/St_rhicfCrossTalk_Table.h"
25 #include "tables/St_rhicfNeutronLeakageOut_Table.h"
26 #include "tables/St_rhicfPhotonLeakageOut_Table.h"
27 #include "tables/St_rhicfPhotonLeakageIn_Table.h"
35 StRHICfDbMaker::~StRHICfDbMaker()
39 Int_t StRHICfDbMaker::Init()
41 return StMaker::Init();
49 void StRHICfDbMaker::Clear(
const Char_t*)
64 LOG_INFO <<
"StRHICfDbMaker::InitRun - Date&time from St_db_Maker="<<dbmaker->GetDate()<<
","<< dbmaker->GetTime() << endm;
69 DBgeometry = GetInputDB(
"Geometry/rhicf");
71 LOG_ERROR <<
"StRHICfDbMaker::InitRun - No Geometry/rhicf"<<endm;
77 St_rhicfBarMap *dbBarMap = 0;
78 dbBarMap = (St_rhicfBarMap*) DBgeometry->
Find(
"rhicfBarMap");
81 int mMaxBarMap = dbBarMap->GetNRows();
83 rhicfBarMap_st* barmap = (rhicfBarMap_st*) dbBarMap->GetTable();
84 mBarMap =
new rhicfBarMap_st;
85 memcpy(mBarMap, barmap,
sizeof(*barmap));
90 St_rhicfBarPos *dbBarPos = 0;
91 dbBarPos = (St_rhicfBarPos*) DBgeometry->
Find(
"rhicfBarPos");
94 int mMaxBarPos = dbBarPos->GetNRows();
96 rhicfBarPos_st* barpos = (rhicfBarPos_st*) dbBarPos->GetTable();
97 mBarPos =
new rhicfBarPos_st;
98 memcpy(mBarPos, barpos,
sizeof(*barpos));
104 DBcalibrations = GetInputDB(
"Calibrations/rhicf");
106 LOG_ERROR <<
"StRHICfDbMaker::InitRun - No Calibrations/rhicf"<<endm;
111 St_rhicfPlateRange * dbPlateRange = 0;
112 dbPlateRange = (St_rhicfPlateRange*) DBcalibrations ->
Find(
"rhicfPlateRange");
115 int mMaxPlateRange = dbPlateRange->GetNRows();
116 if(mMaxPlateRange==1){
117 rhicfPlateRange_st* platerange = (rhicfPlateRange_st*) dbPlateRange->GetTable();
118 mPlateRange =
new rhicfPlateRange_st;
119 memcpy(mPlateRange, platerange,
sizeof(*platerange));
124 St_rhicfPedestal* dbPedestal = 0;
125 dbPedestal = (St_rhicfPedestal*) DBcalibrations ->
Find(
"rhicfPedestal");
128 int mMaxPedestal = dbPedestal->GetNRows();
130 rhicfPedestal_st* pedestal = (rhicfPedestal_st*) dbPedestal->GetTable();
131 mPedestal =
new rhicfPedestal_st;
132 memcpy(mPedestal, pedestal,
sizeof(*pedestal));
137 St_rhicfPedestalF* dbPedestalF = 0;
138 dbPedestalF = (St_rhicfPedestalF*) DBcalibrations ->
Find(
"rhicfPedestalF");
141 int mMaxPedestal = dbPedestalF->GetNRows();
143 rhicfPedestalF_st* pedestalF = (rhicfPedestalF_st*) dbPedestalF->GetTable();
144 mPedestalF =
new rhicfPedestalF_st;
145 memcpy(mPedestalF, pedestalF,
sizeof(*pedestalF));
150 St_rhicfGain* dbGain = 0;
151 dbGain = (St_rhicfGain*) DBcalibrations ->
Find(
"rhicfGain");
154 int mMaxGain = dbGain->GetNRows();
156 rhicfGain_st* gain = (rhicfGain_st*) dbGain->GetTable();
157 mGain =
new rhicfGain_st;
158 memcpy(mGain, gain,
sizeof(*gain));
163 St_rhicfCrossTalk* dbCrossTalk = 0;
164 dbCrossTalk = (St_rhicfCrossTalk*) DBcalibrations ->
Find(
"rhicfCrossTalk");
167 int mMaxCrossTalk = dbCrossTalk->GetNRows();
168 if(mMaxCrossTalk==1){
169 rhicfCrossTalk_st* crosstalk = (rhicfCrossTalk_st*) dbCrossTalk->GetTable();
170 mCrossTalk =
new rhicfCrossTalk_st;
171 memcpy(mCrossTalk, crosstalk,
sizeof(*crosstalk));
176 h2_TSneuLeakOut =
new TH2D(
"h2_TSneuLeakOut",
"", 20, 0, 20, 20, 0, 20);
177 h2_TLneuLeakOut =
new TH2D(
"h2_TLneuLeakOut",
"", 40, 0, 40, 40, 0, 40);
179 for(
int i=0; i<15; i++){
180 h2_TSphoLeakOut[i] =
new TH2D(Form(
"h2_TSphoLeakOut_%d", i),
"", 20, 0, 20, 20, 0, 20);
181 h2_TLphoLeakOut[i] =
new TH2D(Form(
"h2_TLphoLeakOut_%d", i),
"", 40, 0, 40, 40, 0, 40);
182 h2_TSphoLeakIn[i] =
new TH2D(Form(
"h2_TSphoLeakIn_%d", i),
"", 20, 0, 20, 20, 0, 20);
183 h2_TLphoLeakIn[i] =
new TH2D(Form(
"h2_TLphoLeakIn_%d", i),
"", 40, 0, 40, 40, 0, 40);
186 St_rhicfNeutronLeakageOut* dbNeutronLeakageOut = 0;
187 dbNeutronLeakageOut = (St_rhicfNeutronLeakageOut*) DBcalibrations ->
Find(
"rhicfNeutronLeakageOut");
189 if(dbNeutronLeakageOut){
190 int mMaxNeutronLeakageOut = dbNeutronLeakageOut->GetNRows();
191 if(mMaxNeutronLeakageOut==1){
192 rhicfNeutronLeakageOut_st* neuleakout = (rhicfNeutronLeakageOut_st*) dbNeutronLeakageOut->GetTable();
193 mNeutronLeakageOut =
new rhicfNeutronLeakageOut_st;
194 memcpy(mNeutronLeakageOut, neuleakout,
sizeof(*neuleakout));
197 for(
int ix=0; ix<20; ix++){
198 for(
int iy=0; iy<20; iy++){
199 h2_TSneuLeakOut -> SetBinContent(ix+1, iy+1, mNeutronLeakageOut->smallplate[20*ix + iy]);
203 for(
int ix=0; ix<40; ix++){
204 for(
int iy=0; iy<40; iy++){
205 h2_TLneuLeakOut -> SetBinContent(ix+1, iy+1, mNeutronLeakageOut->largeplate[40*ix + iy]);
210 St_rhicfPhotonLeakageOut* dbPhotonLeakageOut = 0;
211 dbPhotonLeakageOut = (St_rhicfPhotonLeakageOut*) DBcalibrations ->
Find(
"rhicfPhotonLeakageOut");
213 if(dbPhotonLeakageOut){
214 int mMaxPhotonLeakageOut = dbPhotonLeakageOut->GetNRows();
215 if(mMaxPhotonLeakageOut==1){
216 rhicfPhotonLeakageOut_st* pholeakout = (rhicfPhotonLeakageOut_st*) dbPhotonLeakageOut->GetTable();
217 mPhotonLeakageOut =
new rhicfPhotonLeakageOut_st;
218 memcpy(mPhotonLeakageOut, pholeakout,
sizeof(*pholeakout));
221 for(
int il=0; il<15; il++){
222 for(
int ix=0; ix<20; ix++){
223 for(
int iy=0; iy<20; iy++){
224 h2_TSphoLeakOut[il] -> SetBinContent(ix+1, iy+1, mPhotonLeakageOut->smallplate[400*il + 20*ix + iy]);
228 for(
int ix=0; ix<40; ix++){
229 for(
int iy=0; iy<40; iy++){
230 h2_TLphoLeakOut[il] -> SetBinContent(ix+1, iy+1, mPhotonLeakageOut->largeplate[1600*il + 40*ix + iy]);
236 St_rhicfPhotonLeakageIn* dbPhotonLeakageIn = 0;
237 dbPhotonLeakageIn = (St_rhicfPhotonLeakageIn*) DBcalibrations ->
Find(
"rhicfPhotonLeakageIn");
239 if(dbPhotonLeakageIn){
240 int mMaxPhotonLeakageIn = dbPhotonLeakageIn->GetNRows();
241 if(mMaxPhotonLeakageIn==1){
242 rhicfPhotonLeakageIn_st* pholeakin = (rhicfPhotonLeakageIn_st*) dbPhotonLeakageIn->GetTable();
243 mPhotonLeakageIn =
new rhicfPhotonLeakageIn_st;
244 memcpy(mPhotonLeakageIn, pholeakin,
sizeof(*pholeakin));
247 for(
int il=0; il<15; il++){
248 for(
int ix=0; ix<20; ix++){
249 for(
int iy=0; iy<20; iy++){
250 h2_TSphoLeakIn[il] -> SetBinContent(ix+1, iy+1, mPhotonLeakageIn->smallplate[400*il + 20*ix + iy]);
254 for(
int ix=0; ix<40; ix++){
255 for(
int iy=0; iy<40; iy++){
256 h2_TLphoLeakIn[il] -> SetBinContent(ix+1, iy+1, mPhotonLeakageIn->largeplate[1600*il + 40*ix + iy]);
265 unsigned int StRHICfDbMaker::getRHICfRunNumberAddress()
const {
return 0;}
266 unsigned int StRHICfDbMaker::getRHICfEventNumberAddress()
const {
return 1;}
267 unsigned int StRHICfDbMaker::getRunTRGMAddress()
const {
return 4;}
268 unsigned int StRHICfDbMaker::getTriggerAddress()
const {
return 623;}
269 unsigned int StRHICfDbMaker::getBunchNumberAddress()
const {
return 649;}
270 unsigned int StRHICfDbMaker::getRunTimeAddress(
unsigned int idx)
const {
return 2+idx;}
271 unsigned int StRHICfDbMaker::getTDCAddress(
unsigned int idx)
const {
return 367+idx;}
272 unsigned int StRHICfDbMaker::getCAD0Address(
unsigned int idx)
const {
return 101+idx;}
273 unsigned int StRHICfDbMaker::getGPI0Address(
unsigned int idx)
const {
return 623+idx;}
274 unsigned int StRHICfDbMaker::getGPI1Address(
unsigned int idx)
const {
return 642+idx;}
276 unsigned int StRHICfDbMaker::getAdcAddress(
unsigned int tower,
unsigned int plate,
unsigned int range)
const
279 return 10+2*plate+(1-range);
282 return 74+2*plate+(1-range);
287 unsigned int StRHICfDbMaker::getAdcDAddress(
unsigned int tower,
unsigned int plate,
unsigned int range)
const
290 return 42+2*plate+(1-range);
293 return 106+2*plate+(1-range);
298 unsigned short StRHICfDbMaker::getScifiAddress(
unsigned int tower,
unsigned int layer,
unsigned xy,
unsigned pos)
const
301 if(tower==0)
return 222 + mBarMap->smallbar[40*layer + 20*xy + pos];
302 if(tower==1)
return 222 + mBarMap->largebar[80*layer + 40*xy + pos];
308 Float_t StRHICfDbMaker::getPlatePedestal(
unsigned int tower,
unsigned int plate)
const
310 if(mPedestal)
return mPedestal->plate[16*tower + plate];
314 Float_t StRHICfDbMaker::getBarPedestal(
unsigned int tower,
unsigned int layer,
unsigned int xy,
unsigned int pos)
const
317 if(tower==0)
return mPedestal->smallbar[40*layer + 20*xy + pos];
318 if(tower==1)
return mPedestal->largebar[80*layer + 40*xy + pos];
323 Float_t StRHICfDbMaker::getBarPedestalF(
unsigned int tower,
unsigned int layer,
unsigned int xy,
unsigned int pos)
const
326 if(tower==0)
return mPedestalF->smallbar[40*layer + 20*xy + pos];
327 if(tower==1)
return mPedestalF->largebar[80*layer + 40*xy + pos];
332 Float_t StRHICfDbMaker::getPlateGain(
unsigned int tower,
unsigned int plate)
const
334 if(mGain)
return mGain->plate[16*tower + plate];
338 Float_t StRHICfDbMaker::getBarGain(
unsigned int tower,
unsigned int layer,
unsigned int xy,
unsigned int pos)
const
341 if(tower==0)
return mGain->smallbar[40*layer + 20*xy + pos];
342 if(tower==1)
return mGain->largebar[80*layer + 40*xy + pos];
347 Float_t StRHICfDbMaker::getPlateRangePar(
unsigned int tower,
unsigned int plate,
unsigned int parnum)
const
349 if(mPlateRange)
return mPlateRange->plate[32*tower + 2*plate + parnum];
353 Float_t StRHICfDbMaker::getBarPos(
unsigned int tower,
unsigned int layer,
unsigned xy,
unsigned pos)
const
356 if(tower==0)
return mBarPos->smallbar[40*layer + 20*xy + pos];
357 if(tower==1)
return mBarPos->largebar[80*layer + 40*xy + pos];
362 Float_t StRHICfDbMaker::getCrossTalk(
unsigned int i,
unsigned int j)
const
365 if((i < 20 && j >= 20) || (i >= 20 && j < 20)){
return 0.;}
367 unsigned short tmpI = i;
368 unsigned short tmpJ = j;
376 unsigned short tmp = tmpI;
381 unsigned short index = 0;
382 for(
unsigned short sum=0; sum<=tmpI; sum++){index += sum;}
385 if(i < 20){
return mCrossTalk->crossTalk[index];}
386 if(i >= 20){
return mCrossTalk->crossTalk[210 + index];}
391 TH2D* StRHICfDbMaker::getLeakOutNeutron(
unsigned int tower)
393 if(tower==0){
return h2_TSneuLeakOut;}
394 if(tower==1){
return h2_TLneuLeakOut;}
398 TH2D* StRHICfDbMaker::getLeakOutPhoton(
unsigned int tower,
unsigned int plate)
400 if(plate==15){plate = 14;}
401 if(tower==0){
return h2_TSphoLeakOut[plate];}
402 if(tower==1){
return h2_TLphoLeakOut[plate];}
406 TH2D* StRHICfDbMaker::getLeakInPhoton(
unsigned int tower,
unsigned int plate)
408 if(plate==15){plate = 14;}
409 if(tower==0){
return h2_TSphoLeakIn[plate];}
410 if(tower==1){
return h2_TLphoLeakIn[plate];}
virtual void Clear(Option_t *option="")
User defined functions.
virtual Int_t InitRun(Int_t runNumber)
virtual TDataSet * Find(const char *path) const