// File: hrichpedestalupdate.cc // // Author: Tassilo Christ // Last update by Tassilo Christ: 15.05.02 #include #include #include "hrichpedestalraw.h" #include "hrichpedestalupdate.h" #include "hevent.h" #include "hspectrometer.h" #include "hrichdetector.h" #include "hcategory.h" #include "hmatrixcatiter.h" #include "hrichraw.h" #include "richdef.h" #include "hrichgeometrypar.h" #include "hdetgeompar.h" #include "hruntimedb.h" #include "hrichcalparcell.h" #include "hlocation.h" #include "hrichcalpar.h" #include "hrichthresholdpar.h" #include "hrichmappingpar.h" #include #include ClassImp(HRichPedestalUpdate) HRichPedestalUpdate::HRichPedestalUpdate(Text_t *name, Text_t *title, char * path ,char * pString): HReconstructor(name,title) { pedPathName = path; strcpy(sectorList,pString); numSec = strlen(sectorList); for (int i=0;i sectorMax) { cout<<"!!!!!!!!!!!!!!!!!!!!!!!"<47 && b<55)){ cout<<"Attention!!! "<getSlot(loc); mean1dHisto[i]->Fill(j,pCell->getOffset()); sigma1dHisto[i]->Fill(j,pCell->getSigma()); } } } } void HRichPedestalUpdate::fill2DHistos(){ if (nCounter <=0){ cout<<"No Data found in any of the requested sectors !! Aborting !!"<Fill(j,k,pStat[sIx][j][k]); loc[0]=i; loc[1]=k; loc[2]=j; pCell = (HRichCalParCell*) ((HRichCalPar*)getCalPar())->getSlot(loc); meanHisto[i]->Fill(j,k,pCell->getOffset()); sigmaHisto[i]->Fill(j,k,pCell->getSigma()); } } } } normalizedSums = true; } //NO CHANGE int HRichPedestalUpdate::getCol(int hardwarenumber){ fMappingPar = gHades->getRuntimeDb()->getContainer("RichMappingParameters"); vec5 = ((HRichMappingPar*)fMappingPar)->padsx; int x = (int) (*vec5)(hardwarenumber); return x; } //NO CHANGE int HRichPedestalUpdate::getRow(int hardwarenumber){ fMappingPar=gHades->getRuntimeDb()->getContainer("RichMappingParameters"); vec6 = ((HRichMappingPar*)fMappingPar)->padsy; int y = (int) (*vec6)(hardwarenumber); return y; } void HRichPedestalUpdate::calculateShifts(){ // Int_t wait; // unused HLocation loc; HRichCalParCell *pCell=0; loc.setNIndex(3); float countedFraction, newCoordinate; cout << "Calculating shift of mean values!" << endl; for(Int_t k =0; kgetMultiply_sigma(k); //gamma Float_t multiply_mean_orig = ( (HRichThresholdPar*)fThresholdPar )->getMultiply_offset(k); //beta Float_t additional_offset_orig = ( (HRichThresholdPar*)fThresholdPar )->getShift(k); //alpha for (Int_t i = 0; igetSlot(loc); if (pCell) { //pCell = new(pCell) HRichCalParCell; pCell->setSector(k); pCell->setRow(j); pCell->setCol(i); pCell->setSlope(1); if(pCell->getSigma()>0.0){ countedFraction=pFrac[sIx][i][j]; //handle extreme shifts outside the erftable loop if(countedFraction>=0.999997) { cout << "Number of detected noise events is " <getSigma() << endl; //cin >> wait; //THIS IS WRONG!!! //newCoordinate=sqrt(2.0) * erfc(2.0*countedFraction-1.0); } pShift[sIx][i][j]= (multiply_sigma_orig-newCoordinate) * pCell->getSigma() + pCell->getOffset() * (multiply_mean_orig - 1. ) + additional_offset_orig; cout << "Calculated absoulte shift is: " << pShift[sIx][i][j] << endl; if(pShift[sIx][i][j]>0) { //cout << "positive shift: " << pShift[sIx][i][j] << endl; //cout << "sector: " << sIx << endl; //cout << "col: " << i << endl; //cout << "row: " << j << endl; //cin >> wait; } if(pShift[sIx][i][j]<-1) { cout << "huge negative shift: " << pShift[sIx][i][j] << endl; cout << "sector: " << sIx << endl; cout << "col: " << i << endl; cout << "row: " << j << endl; cout << "original sigma: " <getSigma() << endl; cout << "original mean: " <getOffset() << endl; cout << "number of firings" <> wait; } if(pShift[sIx][i][j]<-1) pShift[sIx][i][j]=-1; //limit the down shift artificially! } // if getsigma > 0 } //if pCell }// if mask }// row }// col }// sector } void HRichPedestalUpdate::calculate(){ int npads=0; HRichRaw *pRaw=NULL; Bool_t kData = kFALSE; pRichRaw=gHades->getCurrentEvent()->getCategory(catRichRaw); //cout << "number of entries : " << pRichRaw->getEntries() << endl; pIter->Reset(); while( (pRaw = (HRichRaw *)pIter->Next()) ){ kData = kTRUE; npads++; Int_t sec = pRaw->getSector(); Float_t fCharge = pRaw->getCharge(); Int_t iRow = pRaw->getRow(); Int_t iCol = pRaw->getCol(); if(mask[sec][0]==1){ if(iRow < rowMax && iCol < colMax){ int sIx = mask[sec][1]; pStat[sIx][iCol][iRow] = pStat[sIx][iCol][iRow]+1; }else{ cout<<"Warning: impossible Pad numbers: row: " <Write(); mean1dHisto[i]->Write(); sigmaHisto[i]->Write(); sigma1dHisto[i]->Write(); statHisto[i]->Write(); driftHisto[i]->Write(); } } dataFile->Close(); cout<<"Histos are written to: "<getSetup()->getDetector("Rich"); pRichRaw=gHades->getCurrentEvent()->getCategory(catRichRaw); if (!pRichRaw) { pRichRaw=pRichDet->buildCategory(catRichRaw); if (!pRichRaw) return kFALSE; else gHades->getCurrentEvent() ->addCategory(catRichRaw, pRichRaw, "Rich"); } pIter = (HMatrixCatIter*)pRichRaw->MakeIterator(); initMappingPar(); cout << "calling init calpar during init function"<getRuntimeDb(); fCalPar = rtdb->getContainer("RichCalPar"); cout << "calpar container made" << endl; } void HRichPedestalUpdate::initThresholdPar() { HRuntimeDb* rtdb=gHades->getRuntimeDb(); fThresholdPar = rtdb->getContainer("RichThresholdPar"); cout << "threshold parameter container made!" << endl; } //NO CHANGE void HRichPedestalUpdate::initMappingPar() { HRuntimeDb* rtdb=gHades->getRuntimeDb(); fMappingPar = rtdb->getContainer("RichMappingParameters"); } //CHANGE!!!!!!!!!!!!!!!!!!!! Bool_t HRichPedestalUpdate::fillCalParCntr(){ HLocation loc; HRichCalParCell *pCell=0; loc.setNIndex(3); Int_t n=0; for(Int_t k =0; kgetSlot(loc); if (pCell) { //pCell = new(pCell) HRichCalParCell; pCell->setSector(k); pCell->setRow(j); pCell->setCol(i); pCell->setSlope(1); if(pCell->getSigma()>0.0){ if(pCell->getOffset()+pShift[sIx][i][j]<0.0) { driftHisto[k]->Fill(i,j, -pCell->getOffset()); cout <<"Warning, mean is set to 0 in sector: " << k << " row: " << j << " col: " << i << endl; cout <<"Original offset was: " <getOffset() <setOffset(0.0); } if(pCell->getOffset()+pShift[sIx][i][j]>1023){ driftHisto[k]->Fill(i,j, 1023-pCell->getOffset()); pCell->setOffset(1023); cout << "Mean is set to 1023 in sector: " << k << " row: " << j << " col: " << i << endl; } if(pCell->getOffset()+pShift[sIx][i][j]>0.0 && pCell->getOffset()+pShift[sIx][i][j]<1023){ driftHisto[k]->Fill(i,j, pShift[sIx][i][j]); pCell->setOffset( pCell->getOffset() + pShift[sIx][i][j]); } pCell->setSigma(pCell->getSigma()); n++; }else{ //if getSigma!>0 pCell->setOffset( pCell->getOffset()); pCell->setSigma(pCell->getSigma()); } }else{ cerr<<"Error in HRichPedestalUpdate::fillCalParCntr"<getObject(loc); cout<<"Location: "<getSlope()<<" : "<getOffset()<<" : "<getSigma()<getRuntimeDb(); fMappingPar = rtdb->getContainer("RichMappingParameters"); TVector *pUncVec = ((HRichMappingPar*)fMappingPar)->uncuip; vec3 = ((HRichMappingPar*)fMappingPar)->uiplog; HLocation loc; HRichCalParCell *calparcell = NULL; loc.setNIndex(3); for (Int_t i = 0; igetObject(loc); pedestalOut<getOffset() <<" "<getSigma()<getSlot(loc); calOut<getOffset()<<" "<< calparcell->getSigma() <