10 #include "MuEzSmdCalMaker.h"
12 #include "StMuDSTMaker/COMMON/StMuEvent.h"
13 #include "StMuDSTMaker/COMMON/StMuDst.h"
14 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
16 #include "StMuDSTMaker/EZTREE/EztEventHeader.h"
17 #include "StMuDSTMaker/EZTREE/EztTrigBlob.h"
18 #include "StMuDSTMaker/EZTREE/EztEmcRawData.h"
19 #include "StMuDSTMaker/EZTREE/StTriggerDataMother.h"
21 #include "StTriggerData2005.h"
23 #include "StEEmcUtil/database/StEEmcDb.h"
24 #include "StEEmcUtil/database/EEmcDbItem.h"
35 nAcceptEve=nTrigEve=nCorrEve=0;
44 void MuEzSmdCalMaker::setSector(
int sec){
55 MuEzSmdCalMaker::~MuEzSmdCalMaker(){
62 MuEzSmdCalMaker::saveHisto(TString fname){
63 TString outName=fname+
".hist.root";
64 TFile f( outName,
"recreate");
66 printf(
"%d histos are written to '%s' ...\n",HList->GetEntries(),outName.Data());
76 MuEzSmdCalMaker::Init(){
79 eeDb = (
StEEmcDb*)this->GetDataSet(
"StEEmcDb");
83 gMessMgr->Message(
"",
"I") <<
GetName()<<
"::Init() filter trigID="<<trigID<<
" maxCtbSum="<<maxCtbSum<<endm;
84 return StMaker::Init();
90 MuEzSmdCalMaker::InitRun(
int runNo){
92 gMessMgr->Message(
"",
"W")<<
GetName()<<
"::InitRun("<<runNo<<
") ??? changed to 555, it s OK for M-C - perhaps, JB"<<endm;
106 gMessMgr->Message(
"",
"I") <<
GetName()<<
"::Finish()\n inputEve="<<nInpEve<<
" trigFilterEve="<<nTrigEve<<
" nCorrEve="<<nCorrEve<<
" nAcceptEve="<<nAcceptEve<<endm;
113 MuEzSmdCalMaker::Clear(
const Option_t*){
129 if(useEZtree)
return MakeEZtree();
131 return MakeRegular();
137 MuEzSmdCalMaker::MakeEZtree(){
141 gMessMgr->Message(
"",
"E") <<
GetName()<<
"::Make() no EztEventHeader, skip event "<<endm;
return kStOK;
144 if(nInpEve==1) eHead->print();
147 if (! mMuDstMaker->
muDst()->
event()->triggerIdCollection().nominal().isTrigger(trigID))
return kStOK;
155 if(!eETow || !eESmd || !eTrig)
return kStOK;
163 StMuEvent *muEve = mMuDstMaker -> muDst() -> event();
166 int runId=info.runId();
170 void *blob=eTrig->trgd->GetArray();
173 if(eETow->doTowerHeadCorruptionTest(trgAkio5.token())||
174 eESmd->doMapmtHeadCorruptionTest(trgAkio5.token())
180 int ctbSum=trgAkio5.ctbSum();
181 if(maxCtbSum>0 && (ctbSum>maxCtbSum || ctbSum<maxCtbSum/2.))
return kStOK;
199 MuEzSmdCalMaker::MakeRegular(){
200 gMessMgr->Message(
"",
"D") <<
GetName()<<
"::MakeRegular() is called , useEZtree="<<useEZtree<<endm;
203 vector<unsigned int> trgL=mMuDstMaker->
muDst()->
event()->triggerIdCollection().nominal().triggerIds();
204 printf(
"trigL len=%d\n",trgL.size());
206 for(ii=0;ii<trgL.size();ii++) printf(
"ii=%d trigID=%d\n",ii,trgL[ii]);
210 if (! mMuDstMaker->
muDst()->
event()->triggerIdCollection().nominal().isTrigger(trigID))
return kStOK;
215 memset(killT,
false,
sizeof(killT));
233 MuEzSmdCalMaker::tileReMap(
int &iT,
int &sec ,
char &sub ,
int &eta){
237 }
else if( iT==2 && sub==
'A' && eta==11 ) {
238 iT=2; sub=
'B'; eta=2;
239 }
else if( iT==2 && sub==
'B' && eta==2 ) {
240 iT=2; sub=
'A'; eta=11;
241 }
else if( iT==0 && sub==
'A' && eta==4 ) {
242 iT=0; sub=
'A'; eta=5;
243 }
else if( iT==0 && sub==
'A' && eta==5 ) {
244 iT=0; sub=
'A'; eta=4;
253 MuEzSmdCalMaker:: stripReMap(
const EEmcDbItem *x){
256 if(x->sec==8 && x->plane==
'V' ) {
259 case 209: str=216;
break;
260 case 210: str=215;
break;
261 case 211: str=214;
break;
262 case 212: str=213;
break;
263 case 213: str=212;
break;
264 case 214: str=211;
break;
265 case 215: str=210;
break;
266 case 216: str=280;
break;
267 case 280: str=209;
break;
270 case 265: str=272;
break;
271 case 266: str=271;
break;
272 case 267: str=270;
break;
273 case 268: str=269;
break;
274 case 269: str=268;
break;
275 case 270: str=267;
break;
276 case 271: str=266;
break;
277 case 272: str=265;
break;
292 for(icr=0;icr<eRaw->getNBlocks();icr++) {
293 if(eRaw->isCrateVoid(icr))
continue;
294 assert(!eRaw ->getCorruption(icr));
296 int crateID=eRaw->getCrateID(icr);
298 const UShort_t*
data=eRaw->data(icr);
299 for(chan=0;chan<eRaw->sizeData(icr);chan++) {
300 const EEmcDbItem *x=eeDb->getByCrate(crateID,chan);
302 if(x->sec!=
sectID && crateID>6 )
break;
303 if(x->fail )
continue;
306 float rawAdc=data[chan];
307 float adc=rawAdc-x->ped;
311 if(rawAdc>x->thr) n3++;
312 int iuv=x->plane-
'U';
313 int istr=x->strip -1;
317 assert(iuv>=0 && iuv<MaxSmdPlains);
318 assert(istr>=0 && istr<MaxSmdStrips);
320 if(x->gain<=0)
continue;
322 smdEne[iuv][istr]=adc/x->gain;
332 assert(iT>=0 && iT<mxTile);
333 bool aboveThr=rawAdc>x->thr;
335 if( adc<=thrMipPresAdc || adc>(thrMipPresAdc+100) ) aboveThr=
false;
337 if( adc<=(thrMipPresAdc/2.) || adc>(thrMipPresAdc/2.+100) ) aboveThr=
false;
347 int iphi=(sec-1)*MaxSubSec+(sub-
'A');
349 assert(iphi>=0 && iphi<MaxPhiBins);
350 assert(ieta>=0 && ieta<MaxEtaBins);
352 tileThr[iT][ieta][iphi]=aboveThr;
353 killT[iT][ieta][iphi]=
false;
361 if(x->gain<=0)
continue;
362 tileEne[iT][ieta][iphi]=adc/x->gain;
372 MuEzSmdCalMaker::unpackMuTails(){
377 gMessMgr->Warning() <<
"No EMC data for this event"<<endm;
return;
383 for (i=0; i< emc->getNEndcapTowerADC(); i++) {
384 int sec,eta,sub,rawAdc;
385 emc->getEndcapTowerADC(i,rawAdc,sec,sub,eta);
388 const EEmcDbItem *x=eeDb->getTile(sec,
'A'+sub-1,eta,
'T');
394 float adc=rawAdc-x->ped;
399 bool aboveThr=rawAdc>x->thr;
402 recordTail( x,adc,aboveThr,iT);
407 int pNh= emc->getNEndcapPrsHits();
408 for (i=0; i < pNh; i++) {
409 int pre, sec,eta,sub;
412 float rawAdc=hit->
getAdc();
414 const EEmcDbItem *x=eeDb-> getTile(sec,sub-1+
'A', eta, pre-1+
'P');
418 assert(iT>=0 && iT<mxTile);
424 float adc=rawAdc-x->ped;
426 bool aboveThr=rawAdc > x->thr;
428 if( adc<=thrMipPresAdc || adc>(thrMipPresAdc+100) ) aboveThr=
false;
430 if( adc<=(thrMipPresAdc/2.) || adc>(thrMipPresAdc/2.+100) ) aboveThr=
false;
433 recordTail( x,adc,aboveThr,iT);
442 MuEzSmdCalMaker::unpackMuSmd(){
447 gMessMgr->Warning() <<
"No EMC data for this event"<<endm;
return;
452 for(uv=
'U'; uv <=
'V'; uv++) {
454 int nh= emc->getNEndcapSmdHits(uv);
456 for (i=0; i < nh; i++) {
457 StMuEmcHit *hit=emc->getEndcapSmdHit(uv,i,sec,strip);
458 float rawAdc=hit->
getAdc();
459 const EEmcDbItem *x=eeDb->getByStrip(sec,uv,strip);
463 if(x->fail )
continue;
465 float adc=rawAdc-x->ped;
467 int iuv=x->plane-
'U';
468 int istr=x->strip -1;
470 assert(iuv>=0 && iuv<MaxSmdPlains);
471 assert(istr>=0 && istr<MaxSmdStrips);
473 if(x->gain<=0)
continue;
475 smdEne[iuv][istr]=adc/x->gain;
483 MuEzSmdCalMaker::recordTail(
const EEmcDbItem *x,
float adc,
bool aboveThr,
int iT) {
489 if(strstr(x->
name,
"C10")) {
490 printf(
"\nadc=%f iT=%d abTthr=%d \n",adc,iT,aboveThr); x->print();
496 int iphi=(sec-1)*MaxSubSec+(sub-
'A');
498 assert(iphi>=0 && iphi<MaxPhiBins);
499 assert(ieta>=0 && ieta<MaxEtaBins);
501 tileThr[iT][ieta][iphi]=aboveThr;
502 killT[iT][ieta][iphi]=
false;
504 if(x->gain<=0)
return;
505 tileEne[iT][ieta][iphi]=adc/x->gain;
512 MuEzSmdCalMaker::killTail(
const EEmcDbItem *x,
int iT) {
517 int iphi=(sec-1)*MaxSubSec+(sub-
'A');
519 assert(iphi>=0 && iphi<MaxPhiBins);
520 assert(ieta>=0 && ieta<MaxEtaBins);
521 killT[iT][ieta][iphi]=
true;
int sectID
no. of input events
char name[StEEmcNameLen]
ASCII name of the channel, see Readme.
static EztEmcRawData * eztESmd()
returns pointer to eztESmd +pre/post
static EztTrigBlob * eztTrig()
returns pointer to eztTrig
float smdAdc[MaxSmdPlains][MaxSmdStrips]
30 deg (only for this sector)
int getAdc() const
Return ADC value.
static EztEventHeader * eztHeader()
returns pointer to eztHeader
unsigned short killStat
DB access point.
static EztEmcRawData * eztETow()
returns pointer to ETOW
void setSector(int x)
the same info, counted from 0
static StMuEmcCollection * muEmcCollection()
returns pointer to current StMuEmcCollection
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
virtual const char * GetName() const
special overload
float tileAdc[mxTile][MaxEtaBins][MaxPhiBins]