41 #include "StFcsFastSimulatorMaker/StFcsFastSimulatorMaker.h"
43 #include "St_base/StMessMgr.h"
44 #include "StEvent/StEvent.h"
45 #include "StEvent/StFcsCollection.h"
46 #include "StEvent/StFcsHit.h"
47 #include "tables/St_g2t_emc_hit_Table.h"
48 #include "tables/St_g2t_hca_hit_Table.h"
49 #include "tables/St_g2t_epd_hit_Table.h"
50 #include "StFcsDbMaker/StFcsDb.h"
53 static const char name[kFcsEHP][4]={
"wca",
"hca",
"pre"};
56 StFcsFastSimulatorMaker::StFcsFastSimulatorMaker(
const char* name) :
StMaker(name) {
61 int StFcsFastSimulatorMaker::Init() {
62 mFcsDb =
static_cast<StFcsDb*
>(GetDataSet(
"fcsDb"));
64 LOG_ERROR <<
"StFcsFastSimulatorMaker initializing failed due to no StFcsDb" << endm;
68 memset(mEcalMap,0,
sizeof(mEcalMap));
69 memset(mHcalMap,0,
sizeof(mHcalMap));
70 memset(mPresMap,0,
sizeof(mPresMap));
75 memset(mEcalMap,0,
sizeof(mEcalMap));
76 memset(mHcalMap,0,
sizeof(mHcalMap));
77 memset(mPresMap,0,
sizeof(mPresMap));
83 LOG_DEBUG <<
"StFcsFastSimulatorMaker::Make" << endm;
90 LOG_DEBUG <<
"Creating StEvent" << endm;
94 if (!event->fcsCollection()) {
96 LOG_DEBUG <<
"Creating StFcsCollection" << endm;
104 void StFcsFastSimulatorMaker::fillStEvent(
StEvent* event) {
107 int ng2thit[kFcsEHP]={};
109 int leakyHcal = IAttr(
"FcsLeakyHcal");
110 int hcalZdepEff = IAttr(
"FcsHcalZdepEff");
114 St_g2t_emc_hit* hitTable =
static_cast<St_g2t_emc_hit*
>(GetDataSet(Form(
"g2t_%3s_hit",name[ehp])));
116 LOG_INFO << Form(
"g2t_%3s_hit table is empty",name[ehp]) << endm;
118 const int nHits = hitTable->GetNRows();
120 LOG_INFO << Form(
"g2t_%s_hit table has %d hit",name[ehp],nHits) << endm;
122 const g2t_emc_hit_st*
hit = hitTable->GetTable();
124 LOG_INFO << Form(
"g2t_%3s_hit GetTable failed",name[ehp]) << endm;
126 for (
int i=0; i < nHits; ++i) {
127 if (!hit) {hit++;
continue;}
128 const int ns = hit->volume_id / 1000 - 1;
129 const int id = hit->volume_id % 1000 - 1;
131 if(det<0 || det>=kFcsNDet || id<0 || id>=kFcsEcalMaxId){
132 LOG_WARN << Form(
"ECAL det=%1d id=%3d volid=%5d e=%f out of range (%d)",
133 det,
id,hit->volume_id,hit->de,kFcsMaxId) << endm;
136 }
else if(GetDebug()){
137 LOG_INFO << Form(
"ECAL det=%1d id=%3d volid=%4d e=%f",
138 det,
id,hit->volume_id,hit->de) << endm;
142 if(mEcalMap[ns][
id]==0){
143 int ehp=0, rns=0, crt=0, sub=0, dep=0, ch=0;
144 mFcsDb->
getDepfromId(det,
id, ehp, rns, crt, sub, dep, ch);
145 fcshit =
new StFcsHit(1, det,
id, rns, ehp, dep, ch, de);
146 hits.push_back(fcshit);
147 mEcalMap[ns][id]=fcshit;
149 fcshit = mEcalMap[ns][id];
150 fcshit->setEnergy(fcshit->energy() + de);
152 fcshit->addGeantTrack(hit->track_p,de);
161 St_g2t_hca_hit* hitTable_h =
static_cast<St_g2t_hca_hit*
>(GetDataSet(Form(
"g2t_%3s_hit",name[ehp])));
163 LOG_INFO << Form(
"g2t_%3s_hit table is empty",name[ehp]) << endm;
165 const int nHits = hitTable_h->GetNRows();
167 LOG_INFO << Form(
"g2t_%s_hit table has %d hit",name[ehp],nHits) << endm;
169 const g2t_hca_hit_st* hit = hitTable_h->GetTable();
171 LOG_INFO << Form(
"g2t_%3s_hit GetTable failed",name[ehp]) << endm;
173 for (
int i=0; i < nHits; i++) {
174 if (!hit) {hit++;
continue;}
175 const int ns = hit->volume_id / 1000 - 1;
176 const int id = hit->volume_id % 1000 - 1;
178 if(det<0 || det>=kFcsNDet || id<0 || id>=kFcsHcalMaxId){
179 LOG_WARN << Form(
"HCAL det=%d id=%d volid=%5d e=%f out of range (%d)",
180 det,
id,hit->volume_id,hit->de,kFcsMaxId) << endm;
183 }
else if(GetDebug()){
184 LOG_INFO << Form(
"HCAL det=%d id=%d volid=%5d e=%f",
185 det,
id,hit->volume_id,hit->de) << endm;
188 int ehp=0, rns=0, crt=0, sub=0, dep=0, ch=0;
189 mFcsDb->
getDepfromId(det,
id, ehp, rns, crt, sub, dep, ch);
190 if(leakyHcal==0 || leakyHcal==2){
194 if(hcalZdepEff==1) de = hit->deA;
195 if(hcalZdepEff==2) de = hit->deB;
196 if(mHcalMap[ns][
id]==0){
197 fcshit =
new StFcsHit(1, det,
id, rns, ehp, dep, ch, de);
198 hits.push_back(fcshit);
199 mHcalMap[ns][id]=fcshit;
201 fcshit = mHcalMap[ns][id];
202 fcshit->setEnergy(fcshit->energy() + de);
204 fcshit->addGeantTrack(hit->track_p,de);
220 int ncol= mFcsDb->
nColumn(det);
221 for(
int j=0; j<4; j++){
224 if(col==1 && jj<0) {id2=id;}
225 else if(col==2 && jj==-2) {id2=
id-1;}
226 else if(col==ncol && jj==1) {id2=id;}
228 mFcsDb-> getDepfromId(det, id2, ehp, rns, crt, sub, dep, ch);
229 if(mHcalMap[ns][id2]==0){
230 int ehp=0, rns=0, crt=0, sub=0, dep=0, ch=0;
231 mFcsDb-> getDepfromId(det, id2, ehp, rns, crt, sub, dep, ch);
232 fcshit =
new StFcsHit(1, det, id2, rns, ehp, dep, ch, de[j]);
233 hits.push_back(fcshit);
234 mHcalMap[ns][id2]=fcshit;
236 fcshit = mHcalMap[ns][id2];
237 fcshit->setEnergy(fcshit->energy() + de[j]);
239 fcshit->addGeantTrack(hit->track_p,de[j]);
250 St_g2t_epd_hit* hitTable_p =
static_cast<St_g2t_epd_hit*
>(GetDataSet(
"g2t_epd_hit"));
252 LOG_INFO << Form(
"g2t_epd_hit table is empty") << endm;
254 const int nHits = hitTable_p->GetNRows();
256 LOG_INFO << Form(
"g2t_epd_hit table has %d hit",nHits) << endm;
258 const g2t_epd_hit_st* hit = hitTable_p->GetTable();
260 LOG_INFO << Form(
"g2t_epd_hit GetTable failed") << endm;
262 for (
int i=0; i < nHits; ++i) {
263 if (!hit) {hit++;
continue;}
264 const int volume_id = hit->volume_id;
265 const int ew = volume_id/100000;
266 const int pp = (volume_id%100000)/1000;
267 int tt = (volume_id%1000)/10;
268 const float de = hit->de * 1000.0;
269 if(ew==1) {hit++;
continue;}
275 int det,id,ehp,ns,crt,slt,dep,ch;
278 if(det<0 || det>=kFcsNDet || id<0 || id>=kFcsPresMaxId){
279 LOG_WARN << Form(
"Pres det=%1d id=%3d volid=%4d e=%f10.6 id out of range (%d)",
280 det,
id,hit->volume_id,1000*hit->de,kFcsPresId) << endm;
283 }
else if(GetDebug()){
284 LOG_INFO << Form(
"Pres det=%1d id=%3d volid=%4d e=%10.6f",
285 det,
id,hit->volume_id,1000*hit->de) << endm;
288 if(mPresMap[ns][
id]==0){
289 fcshit =
new StFcsHit(1, det,
id, ns, ehp, dep, ch, de);
290 hits.push_back(fcshit);
291 mPresMap[ns][id]=fcshit;
293 fcshit = mPresMap[ns][id];
294 fcshit->setEnergy(fcshit->energy() + de);
297 fcshit->addGeantTrack(hit->track_p,de);
303 int nhittot=hits.size();
305 int nhit[kFcsEHP]={};
306 float etot[kFcsEHP]={};
308 for(
int i=0; i<nhittot; i++){
309 const int det = hits[i]->detectorId();
310 const int id = hits[i]->id();
311 float de = hits[i]->energy();
313 float gain= mFcsDb->
getGain(det,
id);
315 int adc =
static_cast<int>(de / (sf * gain * corr));
316 adc = std::min(adc, 4095*8);
318 if(GetDebug()) LOG_INFO << Form(
"Det=%1d id=%3d dE=%8.3f SF=%6.3f gain=%6.3f corr=%6.3f ADC=%4d ZS=%2d digiE=%8.3f",
319 det,
id,de,sf,gain,corr,adc,zs,adc*gain*corr) << endm;
321 float digi_energy = adc * gain * corr;
323 hits[i]->setAdc(0,adc);
324 hits[i]->setEnergy(digi_energy);
325 fcscollection->addHit(det,hits[i]);
326 etot[ehp] += digi_energy;
334 for(
int ehp=0; ehp<kFcsEHP; ehp++){
335 LOG_INFO << Form(
"%s Found %d g2t hits in %d cells, created %d hits with ADC>ZS(%d) and Etot=%8.3f",
336 name[ehp],ng2thit[ehp],nhit[ehp],
337 fcscollection->numberOfHits(ehp*2) + fcscollection->numberOfHits(ehp*2+1),
341 if(GetDebug()>1) fcscollection->print();
int getColumnNumber(int det, int id) const
get the row number for the channel
void getIdfromEPD(int pp, int tt, int &det, int &id)
Map header.
int getZeroSuppression(int det) const
fcsGain/GainCorrection related
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
float getGainCorrection(int det, int id) const
get the gain for the channel for 8 timebin sum
virtual void Clear(Option_t *option="")
User defined functions.
int detectorId(int eh, int ns) const
6
float getSamplingFraction(int det) const
get zero suppression threshold
int ecalHcalPres(int det) const
Ecal North=0, Ecal South=1, Hcal North=2, Hcal South=3, Pres=4/5.
float getGain(int det, int id) const
get sampling fraction
void Clear(Option_t *option="")
User defined functions.
int nColumn(int det) const
number of rows
void getDepfromId(int detectorId, int id, int &ehp, int &ns, int &crt, int &slt, int &dep, int &ch) const
print ET gain