13 #include "StSvtOnlineSeqAdjSimMaker.h"
14 #include "StSvtClassLibrary/StSvtHybridPixelsC.hh"
15 #include "StSvtClassLibrary/StSvtHybridPixelsD.hh"
16 #include "StSvtClassLibrary/StSvtHybridCollection.hh"
17 #include "StSvtClassLibrary/StSvtData.hh"
18 #include "StSvtClassLibrary/StSvtHybridBadAnodes.hh"
19 #include "StSvtClassLibrary/StSvtHybridData.hh"
20 #include "StSvtClassLibrary/StSvtConfig.hh"
21 #include "StSvtClassLibrary/StSvtDaq.hh"
22 #include "StSequence.hh"
23 #include "StMCTruth.h"
24 #include "StMessMgr.h"
25 #include "StSvtConversionTable.h"
36 mCurrentPixelData=NULL;
37 mCurrent8bitPixelData=NULL;
38 mPedOffsetAdjustment=2;
46 StSvtOnlineSeqAdjSimMaker::~StSvtOnlineSeqAdjSimMaker()
51 Int_t StSvtOnlineSeqAdjSimMaker::GetConfig()
55 dataSet = GetDataSet(
"StSvtConfig");
58 gMessMgr->Warning() <<
" No SvtConfig data set" << endm;
65 gMessMgr->Warning() <<
"SvtConfig data set is empty- seting default full configuration" << endm;
67 mConfig->setConfiguration(
"FULL");
68 mConfig->setNumberOfAnodes(240);
69 mConfig->setNumberOfTimeBins(128);
77 Int_t StSvtOnlineSeqAdjSimMaker::GetDaqParams()
82 dataSet = GetDataSet(
"StSvtDaq");
84 gMessMgr->Error()<<
"BIG TROUBLE:No DAQ parameters from database!!!!"<<endm;
90 gMessMgr->Error()<<
"BIG TROUBLE:No DAQ parameters are empty!!!!"<<endm;
94 SetNumberTBinsToClear(mDaq->getClearedTimeBins());
95 SetExtraPixelsBefore(mDaq->getPixelsBefore());
96 SetExtraPixelsAfter(mDaq->getPixelsAfter());
97 SetPedOffset(mDaq->getPedOffset());
98 Set_n_seq_lo(mDaq->getSeqLo());
99 Set_n_seq_hi(mDaq->getSeqHi());
100 Set_thresh_lo(mDaq->getThreshLo());
101 Set_thresh_hi(mDaq->getThreshHi());
108 Int_t StSvtOnlineSeqAdjSimMaker::GetPixelData()
111 dataSet = GetDataSet(
"StSvtPixelData");
113 gMessMgr->Error()<<
"no StSvtPixelData dataset"<<endm;
119 gMessMgr->Error()<<
"StSvtPixelData is empty"<<endm;
125 dataSet = GetDataSet(
"StSvt8bitPixelData");
127 gMessMgr->Error()<<
"no StSvt8bitPixelData dataset"<<endm;
131 if (!m8bitPixelColl){
132 gMessMgr->Error()<<
"StSvt8bitPixelData is empty"<<endm;
141 void StSvtOnlineSeqAdjSimMaker::GetBadAnodes()
145 dataSet = GetDataSet(
"StSvtBadAnodes");
147 gMessMgr->Warning() <<
"StSvtOnlineSeqAdjSimMaker: No Svt Bad Anodes data set" << endm;
152 if( !mSvtBadAnodes) {
153 gMessMgr->Warning() <<
"StSvtOnlineSeqAdjSimMaker: No Svt Bad Anodes data " << endm;
157 gMessMgr->Info()<<
"StSvtOnlineSeqAdjSimMaker:Svt Bad Anode list found"<<endm;
162 void StSvtOnlineSeqAdjSimMaker::SetRawData()
171 mRawData =
new StSvtData(mConfig->getConfiguration());
178 return StMaker::Init();
185 if (Debug()) gMessMgr->Info()<<
"StSvtOnlineSeqAdjSimMaker::InitRun"<<endm;
189 if ((res=GetDaqParams())!=
kStOk)
return res;
191 gMessMgr->Info()<<
" DAQ parameters used for simulation:"<<endm;
192 gMessMgr->Info() <<
" PedOffSet = "<<mPedOffset<<endm;
193 gMessMgr->Info() <<
" thresh_lo = "<<m_thresh_lo <<endm;
194 gMessMgr->Info() <<
" thresh_hi = "<<m_thresh_hi <<endm;
195 gMessMgr->Info() <<
" n_seq_lo = "<<m_n_seq_lo <<endm;
196 gMessMgr->Info() <<
" n_seq_hi = "<< m_n_seq_hi <<endm;
199 if (Debug()) gMessMgr->Info()<<
"StSvtOnlineSeqAdjSimMaker::InitRun...END"<<endm;
200 return StMaker::InitRun(runumber);
210 void StSvtOnlineSeqAdjSimMaker::Clear(
const char*)
217 void StSvtOnlineSeqAdjSimMaker::SetAdjParams(
int thresh_lo,
int n_seq_lo,
int thresh_hi,
int n_seq_hi)
219 m_thresh_lo =thresh_lo;
220 m_n_seq_lo =n_seq_lo;
221 m_thresh_hi =thresh_hi;
222 m_n_seq_hi =n_seq_hi;
229 if (Debug()) gMessMgr->Info()<<
"StSvtOnlineSeqAdjSimMaker::Make"<<endm;
232 if ((res=GetPixelData())!=
kStOk)
return res;
234 for(
int Barrel = 1;Barrel <= mPixelColl->getNumberOfBarrels();Barrel++) {
235 for (
int Ladder = 1;Ladder <= mPixelColl->getNumberOfLadders(Barrel);Ladder++) {
236 for (
int Wafer = 1;Wafer <= mPixelColl->getNumberOfWafers(Barrel);Wafer++) {
237 for(
int Hybrid = 1;Hybrid <= mPixelColl->getNumberOfHybrids();Hybrid++){
239 mCurrentIndex = mPixelColl->getHybridIndex(Barrel,Ladder,Wafer,Hybrid);
240 if( mCurrentIndex < 0)
continue;
246 if(!mCurrent8bitPixelData) {
248 m8bitPixelColl->put_at(mCurrent8bitPixelData,mCurrentIndex);
251 if(!mCurrentPixelData) {
252 mCurrent8bitPixelData->Reset();
258 Conversion10to8bit();
260 if (mKillBadAnodes) KillBadAnodes();
261 if (mNumberTBinsToClear>0) ClearFirstTbins();
272 if (Debug()) gMessMgr->Info()<<
"StSvtOnlineSeqAdjSimMaker::Make...END"<<endm;
277 void StSvtOnlineSeqAdjSimMaker::Conversion10to8bit()
279 double *fromArray=mCurrentPixelData->GetArray();
280 Char_t *toArray=mCurrent8bitPixelData->GetArray();
282 for (
int i=0;i<mCurrentPixelData->getTotalNumberOfPixels();i++)
284 double adc=fromArray[i];
286 if (adc>=1023) adc=1023.;
287 unsigned int adc1=(
unsigned int)adc;
288 toArray[i]=(Char_t)StSvt10to8ConversionTable[adc1];
293 void StSvtOnlineSeqAdjSimMaker::FillRawData()
296 hybridData =
new StSvtHybridData(mCurrentPixelData->getBarrelID(), mCurrentPixelData->getLadderID(), mCurrentPixelData->getWaferID(),mCurrentPixelData->getHybridID());
297 mRawData->put_at(hybridData,mCurrentIndex);
303 if (mKillBadAnodes && mSvtBadAnodes) badAnode = (
StSvtHybridBadAnodes*)mSvtBadAnodes->at(mCurrentIndex);
305 Char_t *mAdcArray=mCurrent8bitPixelData->GetArray();
309 for (
int ianode=0;ianode<240;ianode++)
315 if ((an==mDaq->getSavedBlackAnodes(0))||(an==mDaq->getSavedBlackAnodes(1))||(an==mDaq->getSavedBlackAnodes(2))||(an==mDaq->getSavedBlackAnodes(3)))
317 if (badAnode->isBadAnode(an))
continue;
318 tmpSeq[0].startTimeBin =0;
319 tmpSeq[0].firstAdc=(
unsigned char*)(mAdcArray+ianode*128);
320 tmpSeq[0].length = 128;
323 hybridData->setListSequences(anodes, an, seqCount, tmpSeq);
330 for(
int tim = 0; tim <= 128; tim++)
334 else adc= (
unsigned char)mAdcArray[ianode*128 + tim];
338 StMCTruth tru =mCurrentPixelData->getTrackId(ianode*128 + tim);
341 tmpSeq[seqCount].startTimeBin = tim;
342 tmpSeq[seqCount].firstAdc=(
unsigned char*)(mAdcArray+ianode*128 + tim);
344 if(
int(tru)) pivo.Add(tru,adc);
350 tmpSeq[seqCount].length = pixCount;
351 tmpTru[seqCount] = pivo.Get();
362 hybridData->setListSequences(anodes,ianode+1, seqCount, tmpSeq);
363 hybridData->setListTruth (anodes,ianode+1, seqCount, tmpTru);
370 hybridData->setAnodeList();
374 void StSvtOnlineSeqAdjSimMaker::WriteSequence(
int anode,
int begins,
int ends,
int NumOfHigh)
379 if (NumOfHigh<=m_n_seq_hi)
return;
380 if ((ends-begins+1)<=m_n_seq_lo)
return;
383 begins= begins-mExtraBefore;
384 if (begins<0) begins=0;
386 ends=ends+mExtraAfter;
387 if (ends>127) ends=127;
389 for (
int i=begins;i<=ends;i++) mMask[anode*128 + i]=kTRUE;
393 void StSvtOnlineSeqAdjSimMaker::SequenceSearch()
400 int HiTresh=mPedOffset+m_thresh_hi+mPedOffsetAdjustment;
401 int LoTresh=mPedOffset+m_thresh_lo+mPedOffsetAdjustment;
404 Char_t *mAdcArray=mCurrent8bitPixelData->GetArray();
406 for(
int an = 0; an < 240; an++){
410 for(
int tim = 0; tim <= 128; tim++)
414 else adc=(
unsigned char)mAdcArray[an*128 + tim];
416 if (adc>HiTresh) hiCount++;
420 if (loCount==0) SeqBegins=tim;
427 WriteSequence(an,SeqBegins,tim-1,hiCount);
441 void StSvtOnlineSeqAdjSimMaker::KillBadAnodes()
445 cout<<
"Warning: cannot simulate bad anodes in online sequence adjusting - no anode list"<<endl;
449 if (!BadAnode)
return;
451 Char_t *mAdcArray=mCurrent8bitPixelData->GetArray();
453 for (
int an=0;an<240;an++)
454 if (BadAnode->isBadAnode(an+1))
456 for(
int tim = 0; tim < 128; tim++) mAdcArray[an*128 + tim]=0;
463 void StSvtOnlineSeqAdjSimMaker::RawAnodes()
466 for (
int i=0 ; i<4 ; i++)
468 int an=mDaq->getSavedBlackAnodes(i);
469 if ((an<=0)||(an>240))
continue;
470 for(
int tb = 0; tb < 128; tb++) mMask[an*128 + tb]=kTRUE;
476 void StSvtOnlineSeqAdjSimMaker::ClearMask()
478 memset(mMask,0,128*240*
sizeof(mMask[0]));
482 void StSvtOnlineSeqAdjSimMaker::ClearFirstTbins()
484 Char_t *mAdcArray=mCurrent8bitPixelData->GetArray();
486 for(
int tim = 0; tim < mNumberTBinsToClear; tim++){
487 for(
int an = 0; an < 240; an++){
488 mAdcArray[an*128 + tim]=0;
495 void StSvtOnlineSeqAdjSimMaker::WriteMask()
497 Char_t *mAdcArray=mCurrent8bitPixelData->GetArray();
499 for(
int tim = 0; tim < 128; tim++){
500 for(
int an = 0; an < 240; an++){
501 if (mMask[an*128 + tim]==kFALSE) mAdcArray[an*128 + tim]=0;
virtual Int_t InitRun(int runumber)
Reads run dependent data from the database.
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
virtual void Clear(Option_t *option="")
User defined functions.
virtual void SetObject(TObject *obj)
The depricated method (left here for the sake of the backward compatibility)
Simulates proceses in the DAQ for SVT Slow Simulator: 10 to 8 bit conversion, killing of bad anodes...
virtual Int_t Init()
inherited maker routines
virtual void SetObject(TObject *obj)
The depricated method (left here for the sake of the backward compatibility)
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
virtual Int_t Make()
Does all data adjusting. At the end creates data in the raw format - the same format as the real data...