// File: hrichpedcalnew.cc // // Author: Angelika Elhardt // Last update by Angelika Elhardt: 00/11/18 16:16:41 // last modified by W.Schoen: 2000/11/08 #include #include "hrichpedcalnew.h" #include "hevent.h" #include "hspectrometer.h" #include "hrichdetector.h" #include "hcategory.h" #include "hmatrixcatiter.h" #include "hrichcal.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(HRichPedCalNew) HRichPedCalNew::HRichPedCalNew(Text_t *name, Text_t *title,char * path ,char * pString): HReconstructor(name,title) { pedPathName = path; strcpy(sectorList,pString); numSec = strlen(sectorList); pRichCal = 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 "<padsy; //int x = (int) (*vec5)(hardwarenumber); //return x; return ((HRichMappingPar*)fMappingPar)->getCol(hardwarenumber); } int HRichPedCalNew::getRow(int hardwarenumber){ fMappingPar=gHades->getRuntimeDb()->getContainer("RichMappingParameters"); //WRONG! This should have been removed long since (T.C. 16.03.03) //vec6 = ((HRichMappingPar*)fMappingPar)->uiplog; //int y = (int) (*vec6)(hardwarenumber); //return y; return ((HRichMappingPar*)fMappingPar)->getRow(hardwarenumber); } void HRichPedCalNew::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 upifile" << endl; } void HRichPedCalNew::bookCanvases(){ } void HRichPedCalNew::calculate(){ HRichCal *pCal=NULL; Bool_t kData = kFALSE; pIter->Reset(); while( (pCal = (HRichCal *)pIter->Next()) ){ kData = kTRUE; Int_t sec = pCal->getSector(); Float_t fCharge = pCal->getCharge(); Int_t iRow = pCal->getRow(); Int_t iCol = pCal->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 HRichPedCalNew::bookCounterHisto(){ count = new TH1F("count","count",3,0,3); } void HRichPedCalNew::fillCounterHisto(){ count->Fill(1,nCounter+1); } void HRichPedCalNew::outputFile(){ char fileName[128]; char * extRoot = ".root"; strcpy(fileName,pedPathName); strcat(fileName,extRoot); dataFile = new TFile(fileName, "RECREATE"); count->Write(); 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"); pRichCal=gHades->getCurrentEvent()->getCategory(catRichCal); if (!pRichCal) { pRichCal=pRichDet->buildCategory(catRichCal); if (!pRichCal) return kFALSE; else gHades->getCurrentEvent() ->addCategory(catRichCal, pRichCal, "Rich"); } pIter = (HMatrixCatIter*)pRichCal->MakeIterator(); //uipFile(); initMappingPar(); nCounter = 0; } return kTRUE; } void HRichPedCalNew::initMappingPar() { HRuntimeDb* rtdb=gHades->getRuntimeDb(); fMappingPar = rtdb->getContainer("RichMappingParameters"); } Int_t HRichPedCalNew::execute() { if (checkInput){ calculate(); } return kTRUE; } Bool_t HRichPedCalNew::finalize(void) { if (checkInput){ cout<<"We are in finalize!"<