X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=EMCAL%2FAliEMCALBiasAPD.cxx;h=760f63b490183f84127164a6954aec66fb8a1ee8;hb=f11b2cf8c07de079c60800e52cba070baa4aed0e;hp=c11782d2c6592a7ffbc66fa01133279e6797ce9c;hpb=61917ab3778617578e8c13231f4cc2d98d9c2e86;p=u%2Fmrichter%2FAliRoot.git diff --git a/EMCAL/AliEMCALBiasAPD.cxx b/EMCAL/AliEMCALBiasAPD.cxx index c11782d2c65..760f63b4901 100644 --- a/EMCAL/AliEMCALBiasAPD.cxx +++ b/EMCAL/AliEMCALBiasAPD.cxx @@ -30,11 +30,16 @@ using namespace std; ClassImp(AliEMCALBiasAPD) //____________________________________________________________________________ -AliEMCALBiasAPD::AliEMCALBiasAPD() : - fNSuperModule(0), - fSuperModuleData(0) +AliEMCALBiasAPD::AliEMCALBiasAPD(const int nSM) : + fNSuperModule(nSM), // make space for everyone + fSuperModuleData() { //Default constructor. + for (int i=0; i> iSM; - t.fSuperModuleNum = iSM; + t->SetSuperModuleNum(iSM); for (Int_t j=0; j> iCol >> iRow >> iElecId >> iDAC >> voltage; + // check that input values are not out bounds + if (iCol<0 || iCol>(AliEMCALGeoParams::fgkEMCALCols-1) || + iRow<0 || iRow>(AliEMCALGeoParams::fgkEMCALRows-1) ) { + printf("AliEMCALBiasAPD::ReadBiasAPDInfo - Error while reading input file; j %d iCol %d iRow %d\n", j, iCol, iRow); + return; + } + // assume that this info is already swapped and done for this basis? if (swapSides) { // C side, oriented differently than A side: swap is requested @@ -81,9 +92,9 @@ void AliEMCALBiasAPD::ReadTextBiasAPDInfo(Int_t nSM, const TString &txtFileName, iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow; } - t.fElecId[iCol][iRow] = iElecId; - t.fDAC[iCol][iRow] = iDAC; - t.fVoltage[iCol][iRow] = voltage; + t->SetElecId(iCol, iRow, iElecId); + t->SetDAC(iCol, iRow, iDAC); + t->SetVoltage(iCol, iRow, voltage); } } // i, SuperModule @@ -114,16 +125,16 @@ void AliEMCALBiasAPD::WriteTextBiasAPDInfo(const TString &txtFileName, Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows; for (Int_t i = 0; i < fNSuperModule; i++) { - AliEMCALSuperModuleBiasAPD &t = fSuperModuleData[i]; - outputFile << t.fSuperModuleNum << endl; + AliEMCALSuperModuleBiasAPD * t = (AliEMCALSuperModuleBiasAPD*) fSuperModuleData[i]; + outputFile << t->GetSuperModuleNum() << endl; for (Int_t j=0; jGetElecId(iCol, iRow); + iDAC = t->GetDAC(iCol, iRow); + voltage = t->GetVoltage(iCol, iRow); if (swapSides) { // C side, oriented differently than A side: swap is requested @@ -167,9 +178,6 @@ void AliEMCALBiasAPD::ReadTreeBiasAPDInfo(TTree *tree, Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows; fNSuperModule = tree->GetEntries() / nAPDPerSM; - if (fSuperModuleData) delete [] fSuperModuleData; - fSuperModuleData = new AliEMCALSuperModuleBiasAPD[fNSuperModule]; - Int_t iSM = 0; // SuperModule index Int_t iCol = 0; Int_t iRow = 0; @@ -191,8 +199,8 @@ void AliEMCALBiasAPD::ReadTreeBiasAPDInfo(TTree *tree, tree->GetEntry(ient); // assume the index SuperModules come in order: i=iSM - AliEMCALSuperModuleBiasAPD &t = fSuperModuleData[iSM]; - t.fSuperModuleNum = iSM; + AliEMCALSuperModuleBiasAPD * t = (AliEMCALSuperModuleBiasAPD*) fSuperModuleData[iSM]; + t->SetSuperModuleNum(iSM); // assume that this info is already swapped and done for this basis? if (swapSides) { @@ -201,9 +209,9 @@ void AliEMCALBiasAPD::ReadTreeBiasAPDInfo(TTree *tree, iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow; } - t.fElecId[iCol][iRow] = iElecId; - t.fDAC[iCol][iRow] = iDAC; - t.fVoltage[iCol][iRow] = voltage; + t->SetElecId(iCol, iRow, iElecId); + t->SetDAC(iCol, iRow, iDAC); + t->SetVoltage(iCol, iRow, voltage); } // @@ -241,15 +249,15 @@ void AliEMCALBiasAPD::WriteRootBiasAPDInfo(const TString &rootFileName, Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows; for (iSM = 0; iSM < fNSuperModule; iSM++) { - AliEMCALSuperModuleBiasAPD &t = fSuperModuleData[iSM]; + AliEMCALSuperModuleBiasAPD * t = (AliEMCALSuperModuleBiasAPD*) fSuperModuleData[iSM]; for (Int_t j=0; jGetElecId(iCol, iRow); + iDAC = t->GetDAC(iCol, iRow); + voltage = t->GetVoltage(iCol, iRow); if (swapSides) { // C side, oriented differently than A side: swap is requested @@ -271,32 +279,20 @@ void AliEMCALBiasAPD::WriteRootBiasAPDInfo(const TString &rootFileName, //____________________________________________________________________________ AliEMCALBiasAPD::~AliEMCALBiasAPD() { - delete [] fSuperModuleData; + fSuperModuleData.Delete(); } //____________________________________________________________________________ -AliEMCALSuperModuleBiasAPD AliEMCALBiasAPD::GetSuperModuleBiasAPDId(Int_t supModIndex)const -{ - AliEMCALSuperModuleBiasAPD t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really.. - if (!fSuperModuleData) - return t; - - return fSuperModuleData[supModIndex]; -} - -//____________________________________________________________________________ -AliEMCALSuperModuleBiasAPD AliEMCALBiasAPD::GetSuperModuleBiasAPDNum(Int_t supModIndex)const -{ - AliEMCALSuperModuleBiasAPD t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really.. - if (!fSuperModuleData) - return t; - +AliEMCALSuperModuleBiasAPD * AliEMCALBiasAPD::GetSuperModuleBiasAPDNum(Int_t supModIndex)const +{ // getter via index for (int i=0; iGetSuperModuleNum() == supModIndex) { + return t; } } - return t; + // if we arrived here, then nothing was found.. just return a NULL pointer + return NULL; }