//*-- created : 011/03/2000 by R.Schicker using namespace std; #include "htboxchan.h" #include "htboxchansum.h" #include "htboxsum.h" #include "hdebug.h" #include "hades.h" #include "hiterator.h" #include "hruntimedb.h" #include "hspectrometer.h" #include "hdetector.h" #include "hevent.h" #include "hcategory.h" #include "hlinearcategory.h" #include "heventheader.h" #include #include //_HADES_CLASS_DESCRIPTION //////////////////////////////////////////////////////////////// // // HTBoxSum: sums TBox data over many events // //////////////////////////////////////////////////////////////// HTBoxSum::HTBoxSum(void) { tboxCat=0; tboxsCat=0; iter=0; iters=0; evsum=0; } HTBoxSum::HTBoxSum(const Text_t *name,const Text_t *title) : HReconstructor(name,title) { tboxCat=0; tboxsCat=0; iter=0; iters=0; evsum=0; } HTBoxSum::~HTBoxSum(void) { if (iter) delete iter; if (iters) delete iters; iter=0; iters=0; } Bool_t HTBoxSum::init(void) { tboxCat=gHades->getCurrentEvent()->getCategory(catTBoxChan); if (!tboxCat) { tboxCat=gHades->getSetup()->getDetector("TBox") ->buildCategory(catTBoxChan); if (!tboxCat) return kFALSE; else gHades->getCurrentEvent()->addCategory(catTBoxChan,tboxCat,"TBox"); } tboxsCat=gHades->getCurrentEvent()->getCategory(catTBoxChanSum); if (!tboxsCat) { tboxsCat=gHades->getSetup()->getDetector("TBox") ->buildCategory(catTBoxChanSum); if (!tboxsCat) return kFALSE; else gHades->getCurrentEvent()->addCategory(catTBoxChanSum,tboxsCat,"TBox"); } nChan = ((HLinearCategory*)tboxCat)->getCollection()->GetSize(); for (Int_t i=0;igetCurrentEvent()->getHeader()->SetBit(0x10000,spill); iter = (TIterator*)tboxCat->MakeIterator("native"); iters = (TIterator*)tboxsCat->MakeIterator("native"); fActive=kTRUE; return kTRUE; } Int_t HTBoxSum::execute(void) { evsum+=1; HTBoxChan *tboxchan; HTBoxChanSum *tboxchans; Float_t raw[SCALER_MAX_WORDS]; Int_t save; Int_t chNl=0; Int_t scal1=0; iter->Reset(); save = 0; while ((tboxchan=(HTBoxChan*)iter->Next())!=0) { tboxchan->getScalerData(chNl,scal1); loc.set(1,chNl); tboxchans = (HTBoxChanSum*) tboxsCat->getNewSlot(loc); if (tboxchans) tboxchans = new(tboxchans) HTBoxChanSum(chNl); scaler1sum[chNl]+=scal1; raw[chNl]=scal1; tboxchans->set(chNl,scaler1sum[chNl]); tboxchans->get(chNl,scal1); } // if (gHades->getCurrentEvent()->getHeader()->getTBit() & 0x100) { // scaler ev // spill = (raw[1]/raw[5] > 10.); // spill on or off? // if (spill && !gHades->getCurrentEvent()->getHeader()->TestBit(0x10000) ) { // timeInSpill = save; // if spill comes on, reset counter // } // } // gHades->getCurrentEvent()->getHeader()->setTimeInSpill(timeInSpill); // gHades->getCurrentEvent()->getHeader()->SetBit(0x10000,spill); return 0; } Bool_t HTBoxSum::finalize(void) { printf("\n----------------------------------------------------------------\n"); printf("TBox scaler values for %i events: \n",evsum); printf(" scaler1 \n"); for(Int_t i=0;i