// File: hrichunpackercal99.cc // // Author: Walter Schoen // Last update by Walter Schoen: 99/12/17 17:29:47 // Last update by Thomas Eberl: 02/10/25 14:57:34 // #include "hrichunpackercal99.h" #include "hrichutilfunc.h" #include "hcategory.h" #include "hlocation.h" #include "hrichraw.h" #include "hevent.h" #include "hspectrometer.h" #include "hdetector.h" #include "hcategory.h" #include "hldsubevt.h" #include "hdebug.h" #include "hruntimedb.h" #include "richdef.h" #include "hrichdetector.h" #include "hrichcalpar.h" #include "hrichcal.h" #include #include HRichUnpackerCal99::HRichUnpackerCal99(int rId,int strtEvt=0,Bool_t isPed=kFALSE,Bool_t verbose=kFALSE,Int_t iSloppyL=0) { richId = rId; startEvt=strtEvt; isPedestal=isPed; kverbose=verbose; iSloppyLevel=iSloppyL; nSubEvtCntr = 0; nSecMisMatchCntr = 0; pRawCat=NULL; fEventNr = -1; if (startEvt !=0) cout<<"For SubEvtId "<getSetup() ->getDetector("Rich"); pCalCat=gHades->getCurrentEvent()->getCategory(catRichCal); if (!pCalCat) { pCalCat=pRichDet->buildCategory(catRichCal); if (!pCalCat) return kFALSE; else gHades->getCurrentEvent() ->addCategory(catRichCal, pCalCat, "Rich"); } initCalPar(); initMappingPar(); return kTRUE; } void HRichUnpackerCal99::initMappingPar(void){ HRuntimeDb* rtdb=gHades->getRuntimeDb(); pMapPar = rtdb->getContainer("RichMappingParameters"); } int HRichUnpackerCal99::getSubEvtId(void) const { return richId; } void HRichUnpackerCal99::printDataWord(DataWord &addr,int ch){ cout<<"*****************************************************************************"<getCol(getUpi(addr))<getRow(getUpi(addr))<isValidUpi(getUpi(addr))<getCol(getUpi(addr))); loc.setIndex(1,getMappingPar()->getRow(getUpi(addr))); loc.setIndex(0,addr.sector); printCalParCell(loc); cout<<"*****************************************************************************"<=0 && ch<1024){ if (addr.channel>=0 && addr.channel<64){ if (addr.modul>=0 && addr.modul<5){ if (addr.port>=0 && addr.port<8){ if (addr.controler >=0 && addr.controler<2){ if (addr.sector>=0 && addr.sector<6){ if (upi>=0 && upi<17464){//redundant if (getMappingPar()->isValidUpi(upi)){// if (getMappingPar()->getCol(upi)>0 && getMappingPar()->getCol(upi)<92){//redundant //cout<<"col: "<getCol(upi)<getRow(upi)>0 && getMappingPar()->getRow(upi)<90){//redundant //cout<<"row: "<getRow(upi)<getRow(upi) <<" is out of bounds [0;89]"<getCol(upi) <<" is out of bounds [0;91]"<isUnConnCh(upi))){ //TRUE //cout<<"not a valid upi"< FALSE nSubEvtCntr--; decision=kFALSE; }else{ //FALSE TRUE -> FALSE if (iSloppyLevel < 2){ cout<<"SubEvtId "< FALSE if (iSloppyLevel < 2){ cout<<"SubEvtId "<=startEvt){ if (pSubEvt) { for (UInt_t i = 0; i < pSubEvt->getDataLen(); i++) { charge = pSubEvt->getData()[i] & 0x3FF; dataword.channel = (pSubEvt->getData()[i] >> 10) & 0x3F; dataword.modul = (pSubEvt->getData()[i] >> 16) & 0x7; dataword.port = (pSubEvt->getData()[i] >> 19) & 0x7; dataword.controler = (pSubEvt->getData()[i] >>22) & 0x1 ; dataword.sector = (pSubEvt->getData()[i] >>23) & 0x7; if (dataword.sector == SubEvtIdSec){ //check sector consistency if (testSubEvt(dataword,charge)){ //check if pad is valid loc.setOffset(getMappingPar()->getCol(getUpi(dataword))); loc.setIndex(1,getMappingPar()->getRow(getUpi(dataword))); loc.setIndex(0,dataword.sector); if (getMappingPar()->isReadOut(loc[2],loc[1])){ if (loc.getIndex(1) >= 0 && loc.getOffset() >= 0) { HRichCalParCell *calparcell = NULL; HRichCal *pCalCell = NULL; calparcell = (HRichCalParCell*) ((HRichCalPar*)getCalPar()) ->getObject(loc); // subtract measured mean value and add a random nb // [0;1] to account for the cut-off in the ADC Float_t fCharge = charge * calparcell->getSlope() - calparcell->getOffset() + rand()/(double)RAND_MAX ; if (fCharge > 0.0) { pCalCell = (HRichCal *)pCalCat->getSlot(loc); if (pCalCell != NULL) { pCalCell = new(pCalCell) HRichCal; pCalCell->setCharge(fCharge); pCalCell->setSector(loc[0]); pCalCell->setRow(loc[1]); pCalCell->setCol(loc[2]); pCalCell->setEventNr(fEventNr); } } } }else{ cout<<"SubEvtId "<getObject(loc); cout<<"SEC: "<getOffset()<<" SIGMA : "<< calparcell->getSigma()<<" SLOPE : "<getSlope()<< endl; } void HRichUnpackerCal99::initCalPar() { HRuntimeDb* rtdb=gHades->getRuntimeDb(); fCalPar = rtdb->getContainer("RichCalPar"); } ClassImp(HRichUnpackerCal99)