// File: hrichpedrawnew.cc // // Author: Angelika Elhardt // Last update by Angelika Elhardt: 01/01/09 18:37:00 // last modified by W.Schoen: 2000/11/08 #include #include "hrichpedrawnew.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 #include #include #include "hrichcalparcell.h" #include "hlocation.h" #include "hrichcalpar.h" #include "hrichmappingpar.h" ClassImp(HRichPedRawNew) HRichPedRawNew::HRichPedRawNew(Text_t *name, Text_t *title,char * path ,char * pString): HReconstructor(name,title) { pedPathName = path; strcpy(sectorList,pString); numSec = strlen(sectorList); pRichRaw = 0; pIter = 0; sectorMax = 6; rowMax = 90; colMax = 92; hardwareMax = 17464; size = 6.; // for finding runaways in meanAndSigma! epsilon = 0.001; channels = 2; sigmaTransformation = false; for (int i=0;i sectorMax) { cout<<"!!!!!!!!!!!!!!!!!!!!!!!"<47 && b<55)){ cout<<"Attention!!! "<Fill(j,k,pStat[sIx][j][k]); runAwayHisto[i]->Fill(j,k,pRunAway[sIx][j][k]); meanHisto[i]->Fill(j,k,pMean[sIx][j][k]); float radikand = pSigma[sIx][j][k]*countArray[sIx][j][k]; if(radikand < 0.){ sigmaHisto[i]->Fill(j,k,20000.); cout<<" !2D! numerical problem occured "<padsx; //int x = (int) (*vec5)(hardwarenumber); //return x; return ((HRichMappingPar*)fMappingPar)->getCol(hardwarenumber); } int HRichPedRawNew::getRow(int hardwarenumber){ fMappingPar=gHades->getRuntimeDb()->getContainer("RichMappingParameters"); //vec6 = ((HRichMappingPar*)fMappingPar)->padsy; //int y = (int) (*vec6)(hardwarenumber); //return y; return ((HRichMappingPar*)fMappingPar)->getRow(hardwarenumber); } void HRichPedRawNew::uipFile(){ TFile *pFile = new TFile("uipfile_new.root","read","Testfile",1); if(pFile){ vec3 = (TVector*) pFile->Get("uip"); //retrieve object from file vec5 = (TVector*) pFile->Get("pads_x"); //and keyname vec6 = (TVector*) pFile->Get("pads_y"); } else cout << "problems opening uipfile" << endl; } void HRichPedRawNew::bookCanvases(){ } void HRichPedRawNew::calculate(){ HRichRaw *pRaw=NULL; Bool_t kData = kFALSE; pIter->Reset(); while( (pRaw = (HRichRaw *)pIter->Next()) ){ kData = kTRUE; 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]; meanAndSigma(sIx,iCol,iRow,fCharge); countArray[sIx][iCol][iRow]++; pStat[sIx][iCol][iRow]= pStat[sIx][iCol][iRow]+1; }else{ cout<<"Warning: impossible Pad numbers: row: " <5. && fabs(pMean[sIx][col][row] - charge) >= size * sigma + epsilon && fabs(pMean[sIx][col][row] - charge) > channels ){ // "nEv>5." to avoid numerical problems pRunAway[sIx][col][row]++; countArray[sIx][col][row]--; } else{ pDiff[sIx][col][row] = ((double)charge - pMean[sIx][col][row]) / (nEv+1.); pMean[sIx][col][row] = pMean[sIx][col][row] + pDiff[sIx][col][row]; pSigma[sIx][col][row] = (nEv==0.)?0.:((nEv-1.)/(nEv+1.))*pSigma[sIx][col][row]+pDiff[sIx][col][row]*pDiff[sIx][col][row]; } } void HRichPedRawNew::outputFile(){ char fileName[128]; char * extPed = "ped"; char * extRoot = ".root"; strcpy(fileName,pedPathName); strcat(fileName,"_"); strcat(fileName,extPed); strcat(fileName,extRoot); dataFile = new TFile(fileName, "RECREATE"); for (int i = 0; iWrite(); mean1dHisto[i]->Write(); sigmaHisto[i]->Write(); sigma1dHisto[i]->Write(); statHisto[i]->Write(); runAwayHisto[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(); //uipFile(); initMappingPar(); initCalPar(); nCounter = 0; } return kTRUE; } Int_t HRichPedRawNew::execute() { if (checkInput){ calculate(); } return kTRUE; } Bool_t HRichPedRawNew::finalize(void) { if (checkInput){ cout<<"We are in finalize!"<getRuntimeDb(); fMappingPar = rtdb->getContainer("RichMappingParameters"); } void HRichPedRawNew::initCalPar() { // HRichDetector *pRichDet = (HRichDetector*)gHades->getSetup() // ->getDetector("Rich"); HRuntimeDb* rtdb=gHades->getRuntimeDb(); fCalPar = rtdb->getContainer("RichCalPar"); // if (fCalPar) { // ((HRichCalPar*)fCalPar)-> // setSetup(pRichDet->getSectors(), // pRichDet->getRows(), // pRichDet->getColumns()); // } } Bool_t HRichPedRawNew::fillCalParCntr(){ initCalPar(); 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); pCell->setOffset(pMean[sIx][i][j]); pCell->setSigma(pSigma[sIx][i][j]); n++; }else{ cerr<<"Error in HRichPedRawNew::fillCalParCntr"<getObject(loc); cout<<"Location: "<getSlope()<<" : "<getOffset()<<" : "<getSigma()<Get("uip unconnected"); HRuntimeDb* rtdb=gHades->getRuntimeDb(); fMappingPar = rtdb->getContainer("RichMappingParameters"); //TVector *pUncVec = ((HRichMappingPar*)fMappingPar)->uncuip; //vec3 = ((HRichMappingPar*)fMappingPar)->uiplog; for (Int_t i = 0; iisValidUpi(hardware)){ pedestalOut<isUnConnCh(hardware)){ pedestalOut<Close(); } void HRichPedRawNew::createCalibration(){ char * extPed = ".txt"; char calFile[128]; // filename and path! strcpy(calFile,pedPathName); strcat(calFile,"_cal"); strcat(calFile,extPed); cout<<"--------------------------------------------"<