+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
+
+ if (hotMapFile) {
+ snprintf(name, 512, "%s.txt", hotMapFile);
+ fout = new ofstream(name);
+ if (!fout->is_open()) {
+ delete fout;
+ fout = 0;//Set the pointer to empty if the file was not opened
+ }
+ }
+
+ for(int i = 0; i < fModules; i++){
+
+ //first we compute the peak-pedestal distribution for each supermodule...
+ if( GetPeakHighGainHisto(i)->GetEntries() > 0 ) {
+ double min = GetPeakProfileHighGain(i)->GetBinContent(GetPeakProfileHighGain(i)->GetMinimumBin());
+ double max = GetPeakProfileHighGain(i)->GetBinContent(GetPeakProfileHighGain(i)->GetMaximumBin());
+ TH1D *hPeakFit = new TH1D(Form("hFit_%d", i), Form("hFit_%d", i), (int)((max-min)*10), min-1, max+1);
+
+ for (int j = 1; j <= fColumns; j++) {
+ for (int k = 1; k <= fRows; k++) {
+ hPeakFit->Fill(GetPeakProfileHighGain(i)->GetBinContent(j, k));
+ }
+ }
+
+ //...and then we try to fit it
+ double mean = hPeakFit->GetMean();
+ double sigma = hPeakFit->GetRMS();
+ try {
+ hPeakFit->Fit("gaus", "OQ", "", mean - 3*sigma, mean + 3*sigma);
+ mean = hPeakFit->GetFunction("gaus")->GetParameter(1);
+ sigma = hPeakFit->GetFunction("gaus")->GetParameter(2);
+ }
+ catch (const std::exception & e) {
+ printf("AliCaloCalibPedestal: TH1D PeakFit exception %s", e.what());
+ }
+ //hPeakFit->Draw();
+
+ delete hPeakFit;
+
+ //Then we look for warm/hot towers
+ TH2F * hPeak2D = GetPeakHighGainHisto(i);
+ hPeak2D->GetYaxis()->SetRangeUser( fWarningThreshold, hPeak2D->GetYaxis()->GetBinUpEdge(hPeak2D->GetNbinsY()) );
+
+ int idx = 0 ;
+ int warnCounter = 0;
+ for (int j = 1; j <= fColumns; j++) {
+ for (int k = 1; k <= fRows; k++) {
+ //we start looking for warm/warning towers...
+ // histogram x-axis index
+ idx = k-1 + fRows*(j-1); // this is what is used in the Fill call
+ hPeak2D->GetXaxis()->SetRangeUser(idx, idx);
+ warnCounter = (int) hPeak2D->Integral();
+ if(warnCounter > fNEvents * fWarningFraction) {
+ ((TH2D*)fDeadMap[i])->SetBinContent(j, k, kWarning);
+ /* printf("mod %d col %d row %d warnCounter %d - status %d\n",
+ i, j-1, k-1, warnCounter, (int) (kWarning)); */
+ }
+ //...then we look for hot ones (towers whose values are greater than mean + X*sigma)
+ if(GetPeakProfileHighGain(i)->GetBinContent(j, k) > mean + fHotSigma*sigma ) {
+ ((TH2D*)fDeadMap[i])->SetBinContent(j, k, kHot);
+ /* printf("mod %d col %d row %d binc %d - status %d\n",
+ i, j-1, k-1, (int)(GetPeakProfileHighGain(i)->GetBinContent(j, k)), (int) (kHot)); */
+ }
+
+ //Write the status to the hot/warm map file, if the file is open.
+ // module - column - row - status (1=dead, 2= warm/warning , 3 = hot, see .h file enum)
+ if (fout && ((TH2D*)fDeadMap[i])->GetBinContent(j, k) > 1) {
+
+ (*fout) << i << " "
+ << (j - 1) << " "
+ << (k - 1) << " "
+ << ((TH2D*)fDeadMap[i])->GetBinContent(j, k) << endl; }
+
+ }
+ }
+
+ }
+ }
+ return;
+}
+
+//_____________________________________________________________________
+void AliCaloCalibPedestal::ComputeDeadTowers(const char * deadMapFile)