X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=EMCAL%2FAliCaloCalibPedestal.cxx;h=fc1609c999d57e38472cbbc7cf2bc3b911f092f4;hb=a27423bf0cdff6ebb12c81be41c681d9a7fbbb6e;hp=c3ec750367404ad74baaa53a2d674858b3610aa2;hpb=61e4e2e3b32a85094ce9bd4d107fe426c5d02c36;p=u%2Fmrichter%2FAliRoot.git diff --git a/EMCAL/AliCaloCalibPedestal.cxx b/EMCAL/AliCaloCalibPedestal.cxx index c3ec7503674..fc1609c999d 100644 --- a/EMCAL/AliCaloCalibPedestal.cxx +++ b/EMCAL/AliCaloCalibPedestal.cxx @@ -127,7 +127,17 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(kDetType detectorType) : fRowMultiplier = 1; } fDetType = detectorType; - + + // ValidateProfiles(); // not to be done in ctor; info from Axel N. +} + +//_____________________________________________________________________ +void AliCaloCalibPedestal::ValidateProfiles() +{ + //Make sure the basic histos exist + if (!fPedestalLowGain.IsEmpty()) return; //The profiles already exist. We just check one, because they're all created at + //the same time + //Then, loop for the requested number of modules TString title, name; for (int i = 0; i < fModules; i++) { @@ -200,7 +210,13 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(kDetType detectorType) : fRows, fRowMin, fRowMax)); }//end for nModules create the histograms - + + CompressAndSetOwner(); +} + +//_____________________________________________________________________ +void AliCaloCalibPedestal::CompressAndSetOwner() +{ //Compress the arrays, in order to remove the empty objects (a 16 slot array is created by default) fPedestalLowGain.Compress(); fPedestalHighGain.Compress(); @@ -232,17 +248,18 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(kDetType detectorType) : fPeakMinusPedLowGainRatio.SetOwner(kTRUE); fPeakMinusPedHighGainRatio.SetOwner(kTRUE); fDeadMap.SetOwner(kTRUE); - } // dtor //_____________________________________________________________________ AliCaloCalibPedestal::~AliCaloCalibPedestal() { + //dtor + if (fReference) delete fReference;//Delete the reference object, if it has been loaded - + // delete also TObjArray's - fPedestalLowGain.Delete(); + fPedestalLowGain.Delete(); fPedestalHighGain.Delete(); fPedestalLEDRefLowGain.Delete(); fPedestalLEDRefHighGain.Delete(); @@ -262,12 +279,12 @@ AliCaloCalibPedestal::~AliCaloCalibPedestal() fPeakMinusPedLowGainRatio.Delete(); fPeakMinusPedHighGainRatio.Delete(); fDeadMap.Delete(); - + } // copy ctor //_____________________________________________________________________ -AliCaloCalibPedestal::AliCaloCalibPedestal(const AliCaloCalibPedestal &ped) : +AliCaloCalibPedestal::AliCaloCalibPedestal(AliCaloCalibPedestal &ped) : TObject(ped), fPedestalLowGain(), fPedestalHighGain(), @@ -328,43 +345,12 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(const AliCaloCalibPedestal &ped) : fDeadMap.Add( ped.GetDeadMap(i) ); }//end for nModules - //Compress the arrays, in order to remove the empty objects (a 16 slot array is created by default) - fPedestalLowGain.Compress(); - fPedestalHighGain.Compress(); - fPedestalLEDRefLowGain.Compress(); - fPedestalLEDRefHighGain.Compress(); - fPeakMinusPedLowGain.Compress(); - fPeakMinusPedHighGain.Compress(); - fPeakMinusPedHighGainHisto.Compress(); - fDeadMap.Compress(); - - // set owner ship for everyone - fPedestalLowGain.SetOwner(kTRUE); - fPedestalHighGain.SetOwner(kTRUE); - fPedestalLEDRefLowGain.SetOwner(kTRUE); - fPedestalLEDRefHighGain.SetOwner(kTRUE); - fPeakMinusPedLowGain.SetOwner(kTRUE); - fPeakMinusPedHighGain.SetOwner(kTRUE); - fPeakMinusPedHighGainHisto.SetOwner(kTRUE); - fPedestalLowGainDiff.SetOwner(kTRUE); - fPedestalHighGainDiff.SetOwner(kTRUE); - fPedestalLEDRefLowGainDiff.SetOwner(kTRUE); - fPedestalLEDRefHighGainDiff.SetOwner(kTRUE); - fPeakMinusPedLowGainDiff.SetOwner(kTRUE); - fPeakMinusPedHighGainDiff.SetOwner(kTRUE); - fPedestalLowGainRatio.SetOwner(kTRUE); - fPedestalHighGainRatio.SetOwner(kTRUE); - fPedestalLEDRefLowGainRatio.SetOwner(kTRUE); - fPedestalLEDRefHighGainRatio.SetOwner(kTRUE); - fPeakMinusPedLowGainRatio.SetOwner(kTRUE); - fPeakMinusPedHighGainRatio.SetOwner(kTRUE); - fDeadMap.SetOwner(kTRUE); - + CompressAndSetOwner(); } // assignment operator; use copy ctor to make life easy.. //_____________________________________________________________________ -AliCaloCalibPedestal& AliCaloCalibPedestal::operator = (const AliCaloCalibPedestal &source) +AliCaloCalibPedestal& AliCaloCalibPedestal::operator = (AliCaloCalibPedestal &source) { // assignment operator; use copy ctor if (&source == this) return *this; @@ -375,8 +361,8 @@ AliCaloCalibPedestal& AliCaloCalibPedestal::operator = (const AliCaloCalibPedest //_____________________________________________________________________ void AliCaloCalibPedestal::Reset() -{ - // Reset all arrays/histograms +{ // Reset all arrays/histograms + ValidateProfiles(); // make sure histos/profiles exist for (int i = 0; i < fModules; i++) { GetPedProfileLowGain(i)->Reset(); GetPedProfileHighGain(i)->Reset(); @@ -448,7 +434,7 @@ void AliCaloCalibPedestal::SetParametersFromFile(const char *parameterFile) s >> keyValue; // check stream status - if( s.rdstate() & ios::failbit ) break; + if( ( s.rdstate() & ios::failbit ) == ios::failbit) break; // skip rest of line if comments found if( keyValue.substr( 0, 2 ) == "//" ) break; @@ -527,19 +513,40 @@ void AliCaloCalibPedestal::WriteParametersToFile(const char *parameterFile) } //_____________________________________________________________________ -Bool_t AliCaloCalibPedestal::AddInfo(const AliCaloCalibPedestal *ped) +Bool_t AliCaloCalibPedestal::AddInfo(AliCaloCalibPedestal *ped) { // just do this for the basic histograms/profiles that get filled in ProcessEvent // may not have data for all modules, but let's just Add everything.. + ValidateProfiles(); // make sure histos/profiles exist + for (int i = 0; i < fModules; i++) { GetPedProfileLowGain(i)->Add( ped->GetPedProfileLowGain(i) ); GetPedProfileHighGain(i)->Add( ped->GetPedProfileHighGain(i) ); + GetPedLEDRefProfileLowGain(i)->Add( ped->GetPedLEDRefProfileLowGain(i) ); + GetPedLEDRefProfileHighGain(i)->Add( ped->GetPedLEDRefProfileHighGain(i) ); GetPeakProfileLowGain(i)->Add( ped->GetPeakProfileLowGain(i) ); GetPeakProfileHighGain(i)->Add( ped->GetPeakProfileHighGain(i) ); GetPeakHighGainHisto(i)->Add( ped->GetPeakHighGainHisto(i) ); - }//end for nModules + // We should also copy other pieces of info: counters and parameters + // (not number of columns and rows etc which should be the same) + // note that I just assign them here rather than Add them, but we + // normally just Add (e.g. in Preprocessor) one object so this should be fine. + fNEvents = ped->GetNEvents(); + fNChanFills = ped->GetNChanFills(); + fDeadTowers = ped->GetDeadTowerCount(); + fNewDeadTowers = ped->GetDeadTowerNew(); + fResurrectedTowers = ped->GetDeadTowerResurrected(); + fRunNumber = ped->GetRunNumber(); + fSelectPedestalSamples = ped->GetSelectPedestalSamples(); + fFirstPedestalSample = ped->GetFirstPedestalSample(); + fLastPedestalSample = ped->GetLastPedestalSample(); + fDeadThreshold = ped->GetDeadThreshold(); + fWarningThreshold = ped->GetWarningThreshold(); + fWarningFraction = ped->GetWarningFraction(); + fHotSigma = ped->GetHotSigma(); + // DeadMap; Diff profiles etc would need to be redone after this operation return kTRUE;//We succesfully added info from the supplied object @@ -561,7 +568,11 @@ Bool_t AliCaloCalibPedestal::ProcessEvent(AliCaloRawStreamV3 *in) { // Method to process=analyze one event in the data stream if (!in) return kFALSE; //Return right away if there's a null pointer + in->Reset(); // just in case the next customer forgets to check if the stream was reset.. + fNEvents++; // one more event + + if (fNEvents==1) ValidateProfiles(); // 1st event, make sure histos/profiles exist // indices for the reading int sample = 0; @@ -662,7 +673,6 @@ Bool_t AliCaloCalibPedestal::ProcessEvent(AliCaloRawStreamV3 *in) }// end while over channel }//end while over DDL's, of input stream - in->Reset(); // just in case the next customer forgets to check if the stream was reset.. return kTRUE; } @@ -671,7 +681,7 @@ Bool_t AliCaloCalibPedestal::ProcessEvent(AliCaloRawStreamV3 *in) Bool_t AliCaloCalibPedestal::SaveHistograms(TString fileName, Bool_t saveEmptyHistos) { //Saves all the histograms (or profiles, to be accurate) to the designated file - + ValidateProfiles(); // make sure histos/profiles exist TFile destFile(fileName, "recreate"); if (destFile.IsZombie()) { @@ -745,7 +755,7 @@ Bool_t AliCaloCalibPedestal::LoadReferenceCalib(TString fileName, TString object //_____________________________________________________________________ Bool_t AliCaloCalibPedestal::SetReference(AliCaloCalibPedestal *ref) -{ +{ // set reference object if (fReference) delete fReference;//Delete the reference object, if it already exists fReference = 0; @@ -880,8 +890,8 @@ void AliCaloCalibPedestal::ValidateComparisonProfiles() //_____________________________________________________________________ void AliCaloCalibPedestal::ComputeDiffAndRatio() -{ - // calculate differences and ratios relative to a reference +{ // calculate differences and ratios relative to a reference + ValidateProfiles(); // make sure histos/profiles exist ValidateComparisonProfiles();//Make sure the comparison histos exist if (!fReference) { @@ -968,6 +978,7 @@ void AliCaloCalibPedestal::ComputeDiffAndRatio() //_____________________________________________________________________ void AliCaloCalibPedestal::ComputeHotAndWarningTowers(const char * hotMapFile) { // look for hot/noisy towers + ValidateProfiles(); // make sure histos/profiles exist ofstream * fout = 0; char name[512];//Quite a long temp buffer, just in case the filename includes a path @@ -1054,6 +1065,7 @@ void AliCaloCalibPedestal::ComputeHotAndWarningTowers(const char * hotMapFile) //_____________________________________________________________________ void AliCaloCalibPedestal::ComputeDeadTowers(const char * deadMapFile) { + ValidateProfiles(); // make sure histos/profiles exist //Computes the number of dead towers etc etc into memory, after this you can call the GetDead... -functions int countTot = 0; int countNew = 0; @@ -1073,7 +1085,7 @@ void AliCaloCalibPedestal::ComputeDeadTowers(const char * deadMapFile) } if (!diff->is_open()) { delete diff; - fout = 0;//Set the pointer to empty if the file was not opened + diff = 0;//Set the pointer to empty if the file was not opened } } @@ -1144,6 +1156,11 @@ void AliCaloCalibPedestal::ComputeDeadTowers(const char * deadMapFile) //_____________________________________________________________________ Bool_t AliCaloCalibPedestal::IsBadChannel(int imod, int icol, int irow) const { + // Check if status info histo exists + if (!fDeadMap[imod]) { + return kFALSE; + } + //Check if channel is dead or hot. Int_t status = (Int_t) ( ((TH2D*)fDeadMap[imod])->GetBinContent(icol,irow) ); if(status == kAlive) @@ -1156,6 +1173,7 @@ Bool_t AliCaloCalibPedestal::IsBadChannel(int imod, int icol, int irow) const //_____________________________________________________________________ void AliCaloCalibPedestal::SetChannelStatus(int imod, int icol, int irow, int status) { + ValidateProfiles(); // make sure histos/profiles exist //Set status of channel dead, hot, alive ... ((TH2D*)fDeadMap[imod])->SetBinContent(icol, irow, status); }