49 #include "StSvtPedMaker.h"
50 #include "St_DataSetIter.h"
51 #include "TObjectSet.h"
52 #include "StMessMgr.h"
53 #include "StarClassLibrary/StSequence.hh"
54 #include "StSvtClassLibrary/StSvtHybridData.hh"
55 #include "StSvtClassLibrary/StSvtHybridCollection.hh"
56 #include "StSvtClassLibrary/StSvtData.hh"
57 #include "StSvtClassLibrary/StSvtHybridPed.hh"
58 #include "StSvtClassLibrary/StSvtHybridPixels2.hh"
59 #include "StSvtClassLibrary/StSvtHybridStat.hh"
60 #include "StSvtClassLibrary/StSvtHybridStat2.hh"
61 #include "StSvtClassLibrary/StSvtConfig.hh"
62 #include "StSvtDaqMaker/StSvtHybridDaqPed.hh"
85 StSvtPedMaker::~StSvtPedMaker()
100 Int_t StSvtPedMaker::Init()
111 return StMaker::Init();
115 Int_t StSvtPedMaker::getConfig()
119 dataSet = GetDataSet(
"StSvtConfig");
123 gMessMgr->Warning() <<
" No SvtConfig data set" << endm;
132 gMessMgr->Warning() <<
"SvtConfig data set is empty- using raw data"<< endm;
137 gMessMgr->Warning() <<
"no raw data -seting default full configuration" << endm;
138 mConfig->setConfiguration(
"FULL");
139 }
else mConfig->setConfiguration(fSvtData->getConfiguration());
151 Int_t StSvtPedMaker::SetType(pedestalType option)
162 Int_t StSvtPedMaker::SetSvtData()
166 dataSet = GetDataSet(
"StSvtRawData");
175 Int_t StSvtPedMaker::SetSvtPed()
180 dataSet = (
TObjectSet*)GetDataSet(
"StSvtPedestal");
199 Int_t StSvtPedMaker::SetSvtPed2ndOrd()
203 fPedSet2 =
new TObjectSet(
"StSvtPedestal2ndOrd");
207 fPedSet2->SetObject((TObject*)fSvtPed2);
213 Int_t StSvtPedMaker::SetSvtRMSPed()
216 dataSet = (
TObjectSet*)GetDataSet(
"StSvtRMSPedestal");
219 fPedRmsSet =
new TObjectSet(
"StSvtRMSPedestal");
220 AddConst(fPedRmsSet);
223 fPedRmsSet->
SetObject((TObject*)fSvtPedRms);
237 if (Debug()) gMessMgr->Debug() <<
"StSvtPedMaker::Make" << endm;
243 Int_t StSvtPedMaker::AddStat()
245 if (Debug()) gMessMgr->Debug() <<
"StSvtPedMaker::AddStat" << endm;
247 int anodeID, nAnodes, nSeq, iseq, time, timeSeq, status;
248 int capacitor, nSCAZero;
251 int previousBin, nextBin, timeCap0th;
253 for (
int barrel = 1;barrel <= fSvtData->getNumberOfBarrels();barrel++) {
254 for (
int ladder = 1;ladder <= fSvtData->getNumberOfLadders(barrel);ladder++) {
255 for (
int wafer = 1;wafer <= fSvtData->getNumberOfWafers(barrel);wafer++) {
256 for (
int hybrid = 1;hybrid <= fSvtData->getNumberOfHybrids();hybrid++) {
259 if (fSvtData->getHybridIndex(barrel, ladder, wafer, hybrid) < 0)
continue;
261 fData = (
StSvtHybridData*)fSvtData->at(fSvtData->getHybridIndex(barrel, ladder, wafer, hybrid));
263 if (!fData)
continue;
265 nSCAZero = fData->getSCAZero();
268 timeCap0th = 128 - nSCAZero;
269 if (timeCap0th == 128)
276 previousBin = timeCap0th - 1;
279 if (timeCap0th == 127)
282 nextBin = timeCap0th + 1;
294 int idx = fSvtStat->getHybridIndex(barrel, ladder, wafer, hybrid);
298 fSvtStat->put_at(fStat,idx);
302 nAnodes = fData->getAnodeList(anodeList);
304 for (
int ianode=0;ianode<nAnodes;ianode++) {
306 anodeID = anodeList[ianode];
310 status = fData->getSequences(anodeID,nSeq,Seq);
312 for (iseq=0;iseq<nSeq;iseq++) {
313 for (timeSeq=0; timeSeq<Seq[iseq].length; timeSeq++) {
315 time = Seq[iseq].startTimeBin + timeSeq;
317 if ( fType == kCapacitor ) {
319 if ((time == 0) || (time == 1))
continue;
321 capacitor = time + nSCAZero;
325 fStat->fillMom((
int)Seq[iseq].firstAdc[timeSeq],anodeID,capacitor);
328 else if ( fType == kTime ) {
330 if ((time == previousBin) || (time == timeCap0th) || (time == nextBin))
continue;
332 fStat->fillMom((
int)Seq[iseq].firstAdc[timeSeq],anodeID,time);
346 Int_t StSvtPedMaker::AddStat2ndOrd()
348 int anodeID, nAnodes, nSeq, iseq, time, timeSeq, status;
349 int capacitor, nSCAZero;
352 int previousBin, nextBin, timeCap0th;
354 for (
int barrel = 1;barrel <= fSvtData->getNumberOfBarrels();barrel++) {
355 for (
int ladder = 1;ladder <= fSvtData->getNumberOfLadders(barrel);ladder++) {
356 for (
int wafer = 1;wafer <= fSvtData->getNumberOfWafers(barrel);wafer++) {
357 for (
int hybrid = 1;hybrid <= fSvtData->getNumberOfHybrids();hybrid++) {
360 if (fSvtData->getHybridIndex(barrel, ladder, wafer, hybrid) < 0)
continue;
362 fData = (
StSvtHybridData*)fSvtData->at(fSvtData->getHybridIndex(barrel, ladder, wafer, hybrid));
364 if (!fData)
continue;
366 nSCAZero = fData->getSCAZero();
369 timeCap0th = 128 - nSCAZero;
370 if (timeCap0th == 128)
377 previousBin = timeCap0th - 1;
380 if (timeCap0th == 127)
383 nextBin = timeCap0th + 1;
397 int idx = fSvtStat2->getHybridIndex(barrel, ladder, wafer, hybrid);
401 fSvtStat2->put_at(fStat2,idx);
405 nAnodes = fData->getAnodeList(anodeList);
407 for (
int ianode=0;ianode<nAnodes;ianode++) {
409 anodeID = anodeList[ianode];
413 status = fData->getSequences(anodeID,nSeq,Seq);
415 for (iseq=0;iseq<nSeq;iseq++) {
416 for (timeSeq=0; timeSeq<Seq[iseq].length; timeSeq++) {
418 time = Seq[iseq].startTimeBin + timeSeq;
420 capacitor = time + nSCAZero;
426 if ((time == 0) || (time == 1) ||
427 (time == previousBin) || (time == timeCap0th) || (time == nextBin))
continue;
428 fStat2->fillMom((
int)Seq[iseq].firstAdc[timeSeq],anodeID,time,capacitor);
441 Int_t StSvtPedMaker::CalcPed()
443 if (Debug()) gMessMgr->Debug() <<
"StSvtPedMaker::CalcPed" << endm;
447 for (
int barrel = 1;barrel <= fSvtData->getNumberOfBarrels();barrel++) {
448 for (
int ladder = 1;ladder <= fSvtData->getNumberOfLadders(barrel);ladder++) {
449 for (
int wafer = 1;wafer <= fSvtData->getNumberOfWafers(barrel);wafer++) {
450 for (
int hybrid = 1;hybrid <= fSvtData->getNumberOfHybrids();hybrid++) {
452 if (fSvtData->getHybridIndex(barrel, ladder, wafer, hybrid) < 0)
continue;
453 fStat = (
StSvtHybridStat*)fSvtStat->at(fSvtStat->getHybridIndex(barrel, ladder, wafer, hybrid));
454 if (!fStat)
continue;
456 int idxPed = fSvtPed->getHybridIndex(barrel, ladder, wafer, hybrid);
461 fPed->setType(fType);
462 fSvtPed->put_at(fPed,idxPed);
467 idxRms = fSvtPedRms->getHybridIndex(barrel, ladder, wafer, hybrid);
471 fSvtPedRms->put_at(fPedRms,idxRms);
476 for (
int anode=1; anode<=fPed->getNumberOfAnodes();anode++) {
477 for (
int time=0; time<fPed->getNumberOfTimeBins();time++) {
479 fPed->AddAt(fStat->getMean(anode,time),fPed->getPixelIndex(anode,time));
482 rms += fStat->getRMS(anode,time);
485 fPedRms->AddAt(fStat->getRMS(anode,time),fPedRms->getPixelIndex(anode,time));
489 rms /= fPed->getNumberOfAnodes()*fPed->getNumberOfTimeBins();
503 Int_t StSvtPedMaker::CalcPed2ndOrd()
505 for (
int barrel = 1;barrel <= fSvtData->getNumberOfBarrels();barrel++) {
506 for (
int ladder = 1;ladder <= fSvtData->getNumberOfLadders(barrel);ladder++) {
507 for (
int wafer = 1;wafer <= fSvtData->getNumberOfWafers(barrel);wafer++) {
508 for (
int hybrid = 1;hybrid <= fSvtData->getNumberOfHybrids();hybrid++) {
510 if (fSvtData->getHybridIndex(barrel, ladder, wafer, hybrid) < 0)
continue;
512 fPed2 = (
StSvtHybridPixels2*)fSvtPed2->at(fSvtPed2->getHybridIndex(barrel, ladder, wafer, hybrid));
516 fStat2 = (
StSvtHybridStat2*)fSvtStat2->at(fSvtStat2->getHybridIndex(barrel, ladder, wafer, hybrid));
518 if (!fStat2)
continue;
520 for (
int time2=0; time2<fPed2->getNumberOfCapacitors();time2++) {
525 fPed->setType(fType);
527 for (
int anode=1; anode<=fPed->getNumberOfAnodes();anode++) {
528 for (
int time=0; time<fPed->getNumberOfTimeBins();time++) {
530 fPed->AddAt( fStat2->getMean(anode,time,time2),fPed->getPixelIndex(anode,time));
535 fPed2->setSvtHybridPixels(fPed,time2);
539 fSvtPed2->at(fSvtPed2->getHybridIndex(barrel, ladder, wafer, hybrid))
550 Int_t StSvtPedMaker::WriteToFile(
const char* fileName)
552 if (Debug()) gMessMgr->Debug() <<
"StSvtPedMaker::WriteToFile" << endm;
554 TFile *file =
new TFile(fileName,
"RECREATE");
557 for (
int barrel = 1;barrel <= fSvtData->getNumberOfBarrels();barrel++) {
558 for (
int ladder = 1;ladder <= fSvtData->getNumberOfLadders(barrel);ladder++) {
559 for (
int wafer = 1;wafer <= fSvtData->getNumberOfWafers(barrel);wafer++) {
560 for (
int hybrid = 1;hybrid <= fSvtData->getNumberOfHybrids();hybrid++) {
562 if (fSvtData->getHybridIndex(barrel, ladder, wafer, hybrid) < 0)
continue;
564 fPed = (
StSvtHybridPed*)fSvtPed->at(fSvtPed->getHybridIndex(barrel, ladder, wafer, hybrid));
567 sprintf(name,
"Ped_%d_%d_%d_%d",barrel, ladder, wafer, hybrid);
581 Int_t StSvtPedMaker::WriteRMSToFile(
const char* fileName)
583 if (Debug()) gMessMgr->Debug() <<
"StSvtPedMaker::WriteToFile" << endm;
585 TFile *file =
new TFile(fileName,
"RECREATE");
588 for (
int barrel = 1;barrel <= fSvtData->getNumberOfBarrels();barrel++) {
589 for (
int ladder = 1;ladder <= fSvtData->getNumberOfLadders(barrel);ladder++) {
590 for (
int wafer = 1;wafer <= fSvtData->getNumberOfWafers(barrel);wafer++) {
591 for (
int hybrid = 1;hybrid <= fSvtData->getNumberOfHybrids();hybrid++) {
593 if (fSvtData->getHybridIndex(barrel, ladder, wafer, hybrid) < 0)
continue;
595 fPedRms = (
StSvtHybridPixels*)fSvtPedRms->at(fSvtPed->getHybridIndex(barrel, ladder, wafer, hybrid));
598 sprintf(name,
"Ped_%d_%d_%d_%d",barrel, ladder, wafer, hybrid);
599 fPedRms->Write(name);
612 Int_t StSvtPedMaker::ReadFromFile(
const char* fileName)
614 if (Debug()) gMessMgr->Debug() <<
"StSvtPedMaker::ReadFromFile" << endm;
616 TFile *file =
new TFile(fileName);
617 if (file->IsZombie()){
618 gMessMgr->Info() <<
"Error reading file:" <<fileName<< endm;
623 for (
int barrel = 1;barrel <= mConfig->getNumberOfBarrels();barrel++) {
624 for (
int ladder = 1;ladder <= mConfig->getNumberOfLadders(barrel);ladder++) {
625 for (
int wafer = 1;wafer <= mConfig->getNumberOfWafers(barrel);wafer++) {
626 for (
int hybrid = 1;hybrid <= mConfig->getNumberOfHybrids();hybrid++) {
628 if (mConfig->getHybridIndex(barrel, ladder, wafer, hybrid) < 0)
continue;
630 sprintf(name,
"Ped_%d_%d_%d_%d",barrel, ladder, wafer, hybrid);
634 int idx = fSvtPed->getHybridIndex(barrel, ladder, wafer, hybrid);
635 delete fSvtPed->at(idx); fSvtPed->at(idx)=0;
636 fSvtPed->put_at(fPed,idx);
649 Int_t StSvtPedMaker::ReadRMSFromFile(
const char* fileName)
651 if (Debug()) gMessMgr->Debug() <<
"StSvtPedMaker::ReadRMSFromFile" << endm;
653 TFile *file =
new TFile(fileName);
654 if (file->IsZombie()){
655 gMessMgr->Info() <<
"Error reading file:" <<fileName<< endm;
660 for (
int barrel = 1;barrel <= mConfig->getNumberOfBarrels();barrel++) {
661 for (
int ladder = 1;ladder <= mConfig->getNumberOfLadders(barrel);ladder++) {
662 for (
int wafer = 1;wafer <= mConfig->getNumberOfWafers(barrel);wafer++) {
663 for (
int hybrid = 1;hybrid <= mConfig->getNumberOfHybrids();hybrid++) {
665 if (mConfig->getHybridIndex(barrel, ladder, wafer, hybrid) < 0)
continue;
667 sprintf(name,
"Ped_%d_%d_%d_%d",barrel, ladder, wafer, hybrid);
671 int idx = fSvtPedRms->getHybridIndex(barrel, ladder, wafer, hybrid);
672 delete fSvtPedRms->at(idx); fSvtPedRms->at(idx)=0;
673 fSvtPedRms->put_at(fPedRms,idx);
687 Int_t StSvtPedMaker::ResetStat()
689 if (Debug()) gMessMgr->Debug() <<
"StSvtPedMaker::ResetStat" << endm;
691 for (
int i=0; i<fSvtStat->getTotalNumberOfHybrids();i++) {
701 Int_t StSvtPedMaker::ResetPed()
703 if (Debug()) gMessMgr->Debug() <<
"StSvtPedMaker::ResetPed" << endm;
705 for (
int i=0; i<fSvtPed->getTotalNumberOfHybrids();i++) {
717 if (Debug()) gMessMgr->Debug() <<
"StSvtPedMaker::Finish" << endm;
723 void StSvtPedMaker::PrintInfo()
726 if (Debug()) StMaker::PrintInfo();
virtual void SetObject(TObject *obj)
The depricated method (left here for the sake of the backward compatibility)
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)