]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliCaloCalibPedestal.cxx
- removing obsolote classes
[u/mrichter/AliRoot.git] / EMCAL / AliCaloCalibPedestal.cxx
CommitLineData
a235e2bc 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
59ed788d 15//* $Id$ */
a235e2bc 16
17//________________________________________________________________________
18//
19// A help class for monitoring and calibration tools: MOOD, AMORE etc.,
20// It can be created and used a la (ctor):
21/*
22 //Create the object for making the histograms
23 fPedestals = new AliCaloCalibPedestal( fDetType );
24 // AliCaloCalibPedestal knows how many modules we have for PHOS or EMCAL
25 fNumModules = fPedestals->GetModules();
26*/
27// fed an event:
28// fPedestals->ProcessEvent(fCaloRawStream);
29// asked to draw histograms:
30// fPedestals->GetDeadMap(i)->Draw("col");
31// or
32// fPedestals->GetPeakProfileHighGainRatio((i < fNumModules) ? i : fVisibleModule)->Draw("colz");
33// etc.
34// The pseudo-code examples above were from the first implementation in MOOD (summer 2007).
35//________________________________________________________________________
36
59ed788d 37//#include "TCanvas.h"
356c3e0c 38#include "TH1.h"
59ed788d 39#include "TF1.h"
356c3e0c 40#include "TFile.h"
356c3e0c 41#include <fstream>
b07ee441 42#include <sstream>
356c3e0c 43#include <iostream>
c490d8e5 44#include <stdexcept>
3dba9483 45#include <cmath>
356c3e0c 46
30aa89b0 47#include "AliRawReader.h"
32cd4c24 48#include "AliCaloRawStreamV3.h"
a235e2bc 49
356c3e0c 50//The include file
51#include "AliCaloCalibPedestal.h"
52
53ClassImp(AliCaloCalibPedestal)
54
55using namespace std;
56
57// ctor; initialize everything in order to avoid compiler warnings
58AliCaloCalibPedestal::AliCaloCalibPedestal(kDetType detectorType) :
59 TObject(),
60 fPedestalLowGain(),
61 fPedestalHighGain(),
29f94584 62 fPedestalLEDRefLowGain(),
63 fPedestalLEDRefHighGain(),
356c3e0c 64 fPeakMinusPedLowGain(),
65 fPeakMinusPedHighGain(),
59ed788d 66 fPeakMinusPedHighGainHisto(),
356c3e0c 67 fPedestalLowGainDiff(),
68 fPedestalHighGainDiff(),
29f94584 69 fPedestalLEDRefLowGainDiff(),
70 fPedestalLEDRefHighGainDiff(),
356c3e0c 71 fPeakMinusPedLowGainDiff(),
72 fPeakMinusPedHighGainDiff(),
73 fPedestalLowGainRatio(),
74 fPedestalHighGainRatio(),
29f94584 75 fPedestalLEDRefLowGainRatio(),
76 fPedestalLEDRefHighGainRatio(),
356c3e0c 77 fPeakMinusPedLowGainRatio(),
78 fPeakMinusPedHighGainRatio(),
79 fDeadMap(),
419341ea 80 fNEvents(0),
81 fNChanFills(0),
356c3e0c 82 fDeadTowers(0),
83 fNewDeadTowers(0),
84 fResurrectedTowers(0),
85 fReference(0),
86 fDetType(kNone),
87 fColumns(0),
88 fRows(0),
29f94584 89 fLEDRefs(0),
356c3e0c 90 fModules(0),
18db89b7 91 fRowMin(0),
92 fRowMax(0),
93 fRowMultiplier(0),
f4fc542c 94 fCaloString(),
95 fMapping(NULL),
3dba9483 96 fRunNumber(-1),
97 fSelectPedestalSamples(kTRUE),
98 fFirstPedestalSample(0),
59ed788d 99 fLastPedestalSample(15),
100 fDeadThreshold(5),
101 fWarningThreshold(50),
102 fWarningFraction(0.002),
103 fHotSigma(5)
356c3e0c 104{
105 //Default constructor. First we set the detector-type related constants.
106 if (detectorType == kPhos) {
107 fColumns = fgkPhosCols;
108 fRows = fgkPhosRows;
29f94584 109 fLEDRefs = fgkPhosLEDRefs;
356c3e0c 110 fModules = fgkPhosModules;
f4fc542c 111 fCaloString = "PHOS";
18db89b7 112 fRowMin = -1*fRows;
113 fRowMax = 0;
114 fRowMultiplier = -1;
356c3e0c 115 }
116 else {
117 //We'll just trust the enum to keep everything in line, so that if detectorType
118 //isn't kPhos then it is kEmCal. Note, however, that this is not necessarily the
119 //case, if someone intentionally gives another number
bd3cd9c2 120 fColumns = AliEMCALGeoParams::fgkEMCALCols;
121 fRows = AliEMCALGeoParams::fgkEMCALRows;
29f94584 122 fLEDRefs = AliEMCALGeoParams::fgkEMCALLEDRefs;
bd3cd9c2 123 fModules = AliEMCALGeoParams::fgkEMCALModules;
f4fc542c 124 fCaloString = "EMCAL";
18db89b7 125 fRowMin = 0;
126 fRowMax = fRows;
127 fRowMultiplier = 1;
356c3e0c 128 }
129 fDetType = detectorType;
130
131 //Then, loop for the requested number of modules
132 TString title, name;
133 for (int i = 0; i < fModules; i++) {
134 //Pedestals, low gain
135 name = "hPedlowgain";
136 name += i;
137 title = "Pedestals, low gain, module ";
138 title += i;
139 fPedestalLowGain.Add(new TProfile2D(name, title,
140 fColumns, 0.0, fColumns,
18db89b7 141 fRows, fRowMin, fRowMax,"s"));
356c3e0c 142
143 //Pedestals, high gain
144 name = "hPedhighgain";
145 name += i;
146 title = "Pedestals, high gain, module ";
147 title += i;
148 fPedestalHighGain.Add(new TProfile2D(name, title,
149 fColumns, 0.0, fColumns,
18db89b7 150 fRows, fRowMin, fRowMax,"s"));
29f94584 151
152 //LED Ref/Mon pedestals, low gain
153 name = "hPedestalLEDReflowgain";
18db89b7 154 name += i;
29f94584 155 title = "Pedestal LEDRef, low gain, module ";
18db89b7 156 title += i;
29f94584 157 fPedestalLEDRefLowGain.Add(new TProfile(name, title,
158 fLEDRefs, 0.0, fLEDRefs, "s"));
159
160 //LED Ref/Mon pedestals, high gain
161 name = "hPedestalLEDRefhighgain";
18db89b7 162 name += i;
29f94584 163 title = "Pedestal LEDRef, high gain, module ";
18db89b7 164 title += i;
29f94584 165 fPedestalLEDRefHighGain.Add(new TProfile(name, title,
166 fLEDRefs, 0.0, fLEDRefs, "s"));
356c3e0c 167
168 //Peak-Pedestals, low gain
169 name = "hPeakMinusPedlowgain";
170 name += i;
171 title = "Peak-Pedestal, low gain, module ";
172 title += i;
173 fPeakMinusPedLowGain.Add(new TProfile2D(name, title,
174 fColumns, 0.0, fColumns,
18db89b7 175 fRows, fRowMin, fRowMax,"s"));
356c3e0c 176
177 //Peak-Pedestals, high gain
178 name = "hPeakMinusPedhighgain";
179 name += i;
180 title = "Peak-Pedestal, high gain, module ";
181 title += i;
182 fPeakMinusPedHighGain.Add(new TProfile2D(name, title,
183 fColumns, 0.0, fColumns,
18db89b7 184 fRows, fRowMin, fRowMax,"s"));
59ed788d 185
186 //Peak-Pedestals, high gain - TH2F histo
187 name = "hPeakMinusPedhighgainHisto";
188 name += i;
189 title = "Peak-Pedestal, high gain, module ";
190 title += i;
191 fPeakMinusPedHighGainHisto.Add(new TH2F(name, title,
192 fColumns*fRows, 0.0, fColumns*fRows,
193 100, 0, 1000));
194
356c3e0c 195 name = "hDeadMap";
196 name += i;
197 title = "Dead map, module ";
198 title += i;
199 fDeadMap.Add(new TH2D(name, title, fColumns, 0.0, fColumns,
18db89b7 200 fRows, fRowMin, fRowMax));
356c3e0c 201
202 }//end for nModules create the histograms
203
204 //Compress the arrays, in order to remove the empty objects (a 16 slot array is created by default)
205 fPedestalLowGain.Compress();
206 fPedestalHighGain.Compress();
29f94584 207 fPedestalLEDRefLowGain.Compress();
208 fPedestalLEDRefHighGain.Compress();
356c3e0c 209 fPeakMinusPedLowGain.Compress();
210 fPeakMinusPedHighGain.Compress();
59ed788d 211 fPeakMinusPedHighGainHisto.Compress();
356c3e0c 212 fDeadMap.Compress();
29f94584 213
356c3e0c 214}
215
216// dtor
217//_____________________________________________________________________
218AliCaloCalibPedestal::~AliCaloCalibPedestal()
219{
220 if (fReference) delete fReference;//Delete the reference object, if it has been loaded
221 //TObjArray will delete the histos/profiles when it is deleted.
222}
223
224// copy ctor
225//_____________________________________________________________________
226AliCaloCalibPedestal::AliCaloCalibPedestal(const AliCaloCalibPedestal &ped) :
227 TObject(ped),
228 fPedestalLowGain(),
229 fPedestalHighGain(),
29f94584 230 fPedestalLEDRefLowGain(),
231 fPedestalLEDRefHighGain(),
356c3e0c 232 fPeakMinusPedLowGain(),
233 fPeakMinusPedHighGain(),
59ed788d 234 fPeakMinusPedHighGainHisto(),
356c3e0c 235 fPedestalLowGainDiff(),
236 fPedestalHighGainDiff(),
29f94584 237 fPedestalLEDRefLowGainDiff(),
238 fPedestalLEDRefHighGainDiff(),
356c3e0c 239 fPeakMinusPedLowGainDiff(),
240 fPeakMinusPedHighGainDiff(),
241 fPedestalLowGainRatio(),
242 fPedestalHighGainRatio(),
29f94584 243 fPedestalLEDRefLowGainRatio(),
244 fPedestalLEDRefHighGainRatio(),
356c3e0c 245 fPeakMinusPedLowGainRatio(),
246 fPeakMinusPedHighGainRatio(),
247 fDeadMap(),
419341ea 248 fNEvents(ped.GetNEvents()),
249 fNChanFills(ped.GetNChanFills()),
356c3e0c 250 fDeadTowers(ped.GetDeadTowerCount()),
251 fNewDeadTowers(ped.GetDeadTowerNew()),
252 fResurrectedTowers(ped.GetDeadTowerResurrected()),
253 fReference( 0 ), //! note that we do not try to copy the reference info here
254 fDetType(ped.GetDetectorType()),
255 fColumns(ped.GetColumns()),
256 fRows(ped.GetRows()),
29f94584 257 fLEDRefs(ped.GetLEDRefs()),
356c3e0c 258 fModules(ped.GetModules()),
18db89b7 259 fRowMin(ped.GetRowMin()),
260 fRowMax(ped.GetRowMax()),
261 fRowMultiplier(ped.GetRowMultiplier()),
f4fc542c 262 fCaloString(ped.GetCaloString()),
263 fMapping(NULL), //! note that we are not copying the map info
3dba9483 264 fRunNumber(ped.GetRunNumber()),
265 fSelectPedestalSamples(ped.GetSelectPedestalSamples()),
266 fFirstPedestalSample(ped.GetFirstPedestalSample()),
59ed788d 267 fLastPedestalSample(ped.GetLastPedestalSample()),
268 fDeadThreshold(ped.GetDeadThreshold()),
269 fWarningThreshold(ped.GetWarningThreshold()),
270 fWarningFraction(ped.GetWarningFraction()),
271 fHotSigma(ped.GetHotSigma())
356c3e0c 272{
273 // Then the ObjArray ones; we add the histograms rather than trying TObjArray = assignment
274 //DS: this has not really been tested yet..
275 for (int i = 0; i < fModules; i++) {
276 fPedestalLowGain.Add( ped.GetPedProfileLowGain(i) );
277 fPedestalHighGain.Add( ped.GetPedProfileHighGain(i) );
29f94584 278 fPedestalLEDRefLowGain.Add( ped.GetPedLEDRefProfileLowGain(i) );
279 fPedestalLEDRefHighGain.Add( ped.GetPedLEDRefProfileHighGain(i) );
356c3e0c 280 fPeakMinusPedLowGain.Add( ped.GetPeakProfileLowGain(i) );
281 fPeakMinusPedHighGain.Add( ped.GetPeakProfileHighGain(i) );
59ed788d 282 fPeakMinusPedHighGainHisto.Add( ped.GetPeakHighGainHisto(i) );
356c3e0c 283
284 fDeadMap.Add( ped.GetDeadMap(i) );
285 }//end for nModules
286
287 //Compress the arrays, in order to remove the empty objects (a 16 slot array is created by default)
288 fPedestalLowGain.Compress();
289 fPedestalHighGain.Compress();
29f94584 290 fPedestalLEDRefLowGain.Compress();
291 fPedestalLEDRefHighGain.Compress();
356c3e0c 292 fPeakMinusPedLowGain.Compress();
293 fPeakMinusPedHighGain.Compress();
59ed788d 294 fPeakMinusPedHighGainHisto.Compress();
295
356c3e0c 296 fDeadMap.Compress();
297}
298
299// assignment operator; use copy ctor to make life easy..
300//_____________________________________________________________________
301AliCaloCalibPedestal& AliCaloCalibPedestal::operator = (const AliCaloCalibPedestal &source)
302{
a235e2bc 303 // assignment operator; use copy ctor
356c3e0c 304 if (&source == this) return *this;
305
306 new (this) AliCaloCalibPedestal(source);
307 return *this;
308}
309
310//_____________________________________________________________________
311void AliCaloCalibPedestal::Reset()
312{
a235e2bc 313 // Reset all arrays/histograms
356c3e0c 314 for (int i = 0; i < fModules; i++) {
315 GetPedProfileLowGain(i)->Reset();
316 GetPedProfileHighGain(i)->Reset();
29f94584 317 GetPedLEDRefProfileLowGain(i)->Reset();
318 GetPedLEDRefProfileHighGain(i)->Reset();
356c3e0c 319 GetPeakProfileLowGain(i)->Reset();
320 GetPeakProfileHighGain(i)->Reset();
59ed788d 321 GetPeakHighGainHisto(i)->Reset();
356c3e0c 322 GetDeadMap(i)->Reset();
323
324 if (!fPedestalLowGainDiff.IsEmpty()) {
325 //This means that the comparison profiles have been created.
326
327 GetPedProfileLowGainDiff(i)->Reset();
328 GetPedProfileHighGainDiff(i)->Reset();
29f94584 329 GetPedLEDRefProfileLowGainDiff(i)->Reset();
330 GetPedLEDRefProfileHighGainDiff(i)->Reset();
356c3e0c 331 GetPeakProfileLowGainDiff(i)->Reset();
332 GetPeakProfileHighGainDiff(i)->Reset();
333
334 GetPedProfileLowGainRatio(i)->Reset();
335 GetPedProfileHighGainRatio(i)->Reset();
29f94584 336 GetPedLEDRefProfileLowGainRatio(i)->Reset();
337 GetPedLEDRefProfileHighGainRatio(i)->Reset();
356c3e0c 338 GetPeakProfileLowGainRatio(i)->Reset();
339 GetPeakProfileHighGainRatio(i)->Reset();
340 }
341 }
419341ea 342 fNEvents = 0;
343 fNChanFills = 0;
356c3e0c 344 fDeadTowers = 0;
345 fNewDeadTowers = 0;
346 fResurrectedTowers = 0;
347
348 //To think about: should fReference be deleted too?... let's not do it this time, at least...
349}
350
b07ee441 351// Parameter/cut handling
352//_____________________________________________________________________
353void AliCaloCalibPedestal::SetParametersFromFile(const char *parameterFile)
40164976 354{
355 // Note: this method is a bit more complicated than it really has to be
356 // - allowing for multiple entries per line, arbitrary order of the
357 // different variables etc. But I wanted to try and do this in as
358 // correct a C++ way as I could (as an exercise).
359
b07ee441 360 static const string delimitor("::");
361
362 // open, check input file
363 ifstream in( parameterFile );
364 if( !in ) {
365 printf("in AliCaloCalibPedestal::SetParametersFromFile - Using default/run_time parameters.\n");
366 return;
367 }
368
b07ee441 369
370 // read in
371 char readline[1024];
372 while ((in.rdstate() & ios::failbit) == 0 ) {
373
374 // Read into the raw char array and then construct a string
375 // to do the searching
376 in.getline(readline, 1024);
377 istringstream s(readline);
378
379 while ( ( s.rdstate() & ios::failbit ) == 0 ) {
380
ab962f7b 381 string keyValue;
382 s >> keyValue;
b07ee441 383
384 // check stream status
385 if( s.rdstate() & ios::failbit ) break;
386
387 // skip rest of line if comments found
ab962f7b 388 if( keyValue.substr( 0, 2 ) == "//" ) break;
b07ee441 389
ab962f7b 390 // look for "::" in keyValue pair
391 size_t position = keyValue.find( delimitor );
b07ee441 392 if( position == string::npos ) {
ab962f7b 393 printf("wrong format for key::value pair: %s\n", keyValue.c_str());
b07ee441 394 }
395
ab962f7b 396 // split keyValue pair
397 string key( keyValue.substr( 0, position ) );
398 string value( keyValue.substr( position+delimitor.size(),
399 keyValue.size()-delimitor.size() ) );
b07ee441 400
401 // check value does not contain a new delimitor
402 if( value.find( delimitor ) != string::npos ) {
ab962f7b 403 printf("wrong format for key::value pair: %s\n", keyValue.c_str());
b07ee441 404 }
405
406 // debug: check key value pair
407 // printf("AliCaloCalibPedestal::SetParametersFromFile - key %s value %s\n", key.c_str(), value.c_str());
408
409 // if the key matches with something we expect, we assign the new value
410 istringstream iss(value);
411 // the comparison strings defined at the beginning of this method
59ed788d 412 if ( (key == "fFirstPedestalSample") || (key == "fLastPedestalSample") || (key == "fDeadThreshold") || (key == "fWarningThreshold") || (key == "fWarningFraction") || (key == "fHotSigma") ) {
b07ee441 413 printf("AliCaloCalibPedestal::SetParametersFromFile - key %s value %s\n", key.c_str(), value.c_str());
414
415 if (key == "fFirstPedestalSample") {
416 iss >> fFirstPedestalSample;
417 }
418 else if (key == "fLastPedestalSample") {
419 iss >> fLastPedestalSample;
420 }
59ed788d 421 else if (key == "fDeadThreshold") {
422 iss >> fDeadThreshold;
423 }
424 else if (key == "fWarningThreshold") {
425 iss >> fWarningThreshold;
426 }
427 else if (key == "fWarningFraction") {
428 iss >> fWarningFraction;
429 }
430 else if (key == "fHotSigma") {
431 iss >> fHotSigma;
432 }
433
b07ee441 434 } // some match
435
436 }
437 }
438
439 in.close();
440 return;
441
442}
443
444//_____________________________________________________________________
445void AliCaloCalibPedestal::WriteParametersToFile(const char *parameterFile)
446{
40164976 447 //Write parameters in file.
448
b07ee441 449 static const string delimitor("::");
450 ofstream out( parameterFile );
451 out << "// " << parameterFile << endl;
452 out << "fFirstPedestalSample" << "::" << fFirstPedestalSample << endl;
453 out << "fLastPedestalSample" << "::" << fLastPedestalSample << endl;
59ed788d 454 out << "fDeadThreshold" << "::" << fDeadThreshold << endl;
455 out << "fWarningThreshold" << "::" << fWarningThreshold << endl;
456 out << "fWarningFraction" << "::" << fWarningFraction << endl;
457 out << "fHotSigma" << "::" << fHotSigma << endl;
b07ee441 458
459 out.close();
460 return;
461}
462
419341ea 463//_____________________________________________________________________
464Bool_t AliCaloCalibPedestal::AddInfo(const AliCaloCalibPedestal *ped)
465{
466 // just do this for the basic histograms/profiles that get filled in ProcessEvent
467 // may not have data for all modules, but let's just Add everything..
468 for (int i = 0; i < fModules; i++) {
2ce7ee7f 469 GetPedProfileLowGain(i)->Add( ped->GetPedProfileLowGain(i) );
470 GetPedProfileHighGain(i)->Add( ped->GetPedProfileHighGain(i) );
471 GetPeakProfileLowGain(i)->Add( ped->GetPeakProfileLowGain(i) );
472 GetPeakProfileHighGain(i)->Add( ped->GetPeakProfileHighGain(i) );
59ed788d 473 GetPeakHighGainHisto(i)->Add( ped->GetPeakHighGainHisto(i) );
474
419341ea 475 }//end for nModules
476
477 // DeadMap; Diff profiles etc would need to be redone after this operation
478
479 return kTRUE;//We succesfully added info from the supplied object
480}
481
f4fc542c 482//_____________________________________________________________________
483Bool_t AliCaloCalibPedestal::ProcessEvent(AliRawReader *rawReader)
484{
485 // if fMapping is NULL the rawstream will crate its own mapping
32cd4c24 486 AliCaloRawStreamV3 rawStream(rawReader, fCaloString, (AliAltroMapping**)fMapping);
30aa89b0 487 if (fDetType == kEmCal) {
488 rawReader->Select("EMCAL", 0, AliEMCALGeoParams::fgkLastAltroDDL) ; //select EMCAL DDL range
489 }
f4fc542c 490 return ProcessEvent(&rawStream);
491}
492
356c3e0c 493//_____________________________________________________________________
32cd4c24 494Bool_t AliCaloCalibPedestal::ProcessEvent(AliCaloRawStreamV3 *in)
356c3e0c 495{
a235e2bc 496 // Method to process=analyze one event in the data stream
356c3e0c 497 if (!in) return kFALSE; //Return right away if there's a null pointer
419341ea 498 fNEvents++; // one more event
3dba9483 499
500 // indices for the reading
501 int sample = 0;
3dba9483 502 int time = 0;
32cd4c24 503 int i = 0; // sample counter
504 int startBin = 0;
3dba9483 505
32cd4c24 506 // start loop over input stream
507 while (in->NextDDL()) {
508 while (in->NextChannel()) {
3dba9483 509
32cd4c24 510 // counters
bd3cd9c2 511 int max = AliEMCALGeoParams::fgkSampleMin, min = AliEMCALGeoParams::fgkSampleMax; // min and max sample values
56613d93 512 int nsamples = 0;
513
29f94584 514 // pedestal samples
515 int nPed = 0;
516 vector<int> pedSamples;
517
32cd4c24 518 while (in->NextBunch()) {
519 const UShort_t *sig = in->GetSignals();
520 startBin = in->GetStartTimeBin();
56613d93 521 nsamples += in->GetBunchLength();
32cd4c24 522 for (i = 0; i < in->GetBunchLength(); i++) {
523 sample = sig[i];
524 time = startBin--;
525
526 // check if it's a min or max value
527 if (sample < min) min = sample;
528 if (sample > max) max = sample;
529
530 // should we add it for the pedestal calculation?
531 if ( (fFirstPedestalSample<=time && time<=fLastPedestalSample) || // sample time in range
532 !fSelectPedestalSamples ) { // or we don't restrict the sample range.. - then we'll take all
29f94584 533 pedSamples.push_back( sig[i] );
534 nPed++;
32cd4c24 535 }
536
537 } // loop over samples in bunch
538 } // loop over bunches
3dba9483 539
56613d93 540 if (nsamples > 0) { // this check is needed for when we have zero-supp. on, but not sparse readout
541
32cd4c24 542 // it should be enough to check the SuperModule info for each DDL really, but let's keep it here for now
356c3e0c 543 int arrayPos = in->GetModule(); //The modules are numbered starting from 0
544 if (arrayPos >= fModules) {
545 //TODO: return an error message, if appopriate (perhaps if debug>0?)
546 return kFALSE;
32cd4c24 547 }
356c3e0c 548 //Debug
549 if (arrayPos < 0 || arrayPos >= fModules) {
550 printf("Oh no: arrayPos = %i.\n", arrayPos);
551 }
32cd4c24 552
419341ea 553 fNChanFills++; // one more channel found, and profile to be filled
356c3e0c 554 //NOTE: coordinates are (column, row) for the profiles
29f94584 555 if ( in->IsLowGain() ) {
356c3e0c 556 //fill the low gain histograms
18db89b7 557 ((TProfile2D*)fPeakMinusPedLowGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), max - min);
29f94584 558 if (nPed>0) { // only fill pedestal info in case it could be calculated
559 for ( i=0; i<nPed; i++) {
560 ((TProfile2D*)fPedestalLowGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), pedSamples[i]);
561 }
3dba9483 562 }
356c3e0c 563 }
29f94584 564 else if ( in->IsHighGain() ) {
3dba9483 565 //fill the high gain ones
18db89b7 566 ((TProfile2D*)fPeakMinusPedHighGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), max - min);
29f94584 567 if (nPed>0) { // only fill pedestal info in case it could be calculated
568 for ( i=0; i<nPed; i++) {
569 ((TProfile2D*)fPedestalHighGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), pedSamples[i]);
570 }
3dba9483 571 }
59ed788d 572 // for warning checks
573 int idx = in->GetRow() + fRows * in->GetColumn();
574 ((TH2F*)fPeakMinusPedHighGainHisto[arrayPos])->Fill(idx, max - min);
29f94584 575 }
576 else if ( in->IsLEDMonData() ) {
577 // for LED Mon data, the mapping class holds the gain info in the Row variable
578 // and the Strip number in the Column..
579 int gain = in->GetRow();
580 int stripId = in->GetColumn();
581 if (nPed>0 && stripId<fLEDRefs) {
582 if (gain == 0) {
583 for ( i=0; i<nPed; i++) {
584 ((TProfile*)fPedestalLEDRefLowGain[arrayPos])->Fill(stripId, pedSamples[i]);
585 }
586 }
587 else {
588 for ( i=0; i<nPed; i++) {
589 ((TProfile*)fPedestalLEDRefHighGain[arrayPos])->Fill(stripId, pedSamples[i]);
590 }
591 }
592 }
593 }
419341ea 594
56613d93 595 } // nsamples>0 check, some data found for this channel; not only trailer/header
32cd4c24 596 }// end while over channel
597 }//end while over DDL's, of input stream
598
599 in->Reset(); // just in case the next customer forgets to check if the stream was reset..
600
356c3e0c 601 return kTRUE;
602}
603
604//_____________________________________________________________________
605Bool_t AliCaloCalibPedestal::SaveHistograms(TString fileName, Bool_t saveEmptyHistos)
606{
607 //Saves all the histograms (or profiles, to be accurate) to the designated file
608
609 TFile destFile(fileName, "recreate");
610
611 if (destFile.IsZombie()) {
612 return kFALSE;
613 }
614
615 destFile.cd();
616
617 for (int i = 0; i < fModules; i++) {
618 if( ((TProfile2D *)fPeakMinusPedLowGain[i])->GetEntries() || saveEmptyHistos) {
619 fPeakMinusPedLowGain[i]->Write();
620 }
621 if( ((TProfile2D *)fPeakMinusPedHighGain[i])->GetEntries() || saveEmptyHistos) {
622 fPeakMinusPedHighGain[i]->Write();
623 }
624 if( ((TProfile2D *)fPedestalLowGain[i])->GetEntries() || saveEmptyHistos) {
625 fPedestalLowGain[i]->Write();
626 }
627 if( ((TProfile2D *)fPedestalHighGain[i])->GetEntries() || saveEmptyHistos) {
628 fPedestalHighGain[i]->Write();
629 }
29f94584 630 if( ((TProfile *)fPedestalLEDRefLowGain[i])->GetEntries() || saveEmptyHistos) {
631 fPedestalLEDRefLowGain[i]->Write();
18db89b7 632 }
29f94584 633 if( ((TProfile *)fPedestalLEDRefHighGain[i])->GetEntries() || saveEmptyHistos) {
634 fPedestalLEDRefHighGain[i]->Write();
18db89b7 635 }
59ed788d 636 if( ((TH2F *)fPeakMinusPedHighGainHisto[i])->GetEntries() || saveEmptyHistos) {
637 fPeakMinusPedHighGainHisto[i]->Write();
638 }
639
356c3e0c 640 }
641
642 destFile.Close();
643
644 return kTRUE;
645}
646
647//_____________________________________________________________________
648Bool_t AliCaloCalibPedestal::LoadReferenceCalib(TString fileName, TString objectName)
649{
650
651 //Make sure that the histograms created when loading the object are not destroyed as the file object is destroyed
652 TH1::AddDirectory(kFALSE);
653
654 TFile *sourceFile = new TFile(fileName);
655 if (sourceFile->IsZombie()) {
656 return kFALSE;//We couldn't load the reference
657 }
658
659 if (fReference) delete fReference;//Delete the reference object, if it already exists
660 fReference = 0;
661
662 fReference = (AliCaloCalibPedestal*)sourceFile->Get(objectName);
663
664 if (!fReference || !(fReference->InheritsFrom(AliCaloCalibPedestal::Class())) || (fReference->GetDetectorType() != fDetType)) {
665 if (fReference) delete fReference;//Delete the object, in case we had an object of the wrong type
666 fReference = 0;
667 return kFALSE;
668 }
669
670 delete sourceFile;
29f94584 671
356c3e0c 672 //Reset the histogram ownership behaviour. NOTE: a better workaround would be good, since this may accidentally set AddDirectory to true, even
673 //if we are called by someone who has set it to false...
674 TH1::AddDirectory(kTRUE);
675
676 return kTRUE;//We succesfully loaded the object
677}
678
679//_____________________________________________________________________
680void AliCaloCalibPedestal::ValidateComparisonProfiles()
681{
a235e2bc 682 //Make sure the comparison histos exist
356c3e0c 683 if (!fPedestalLowGainDiff.IsEmpty()) return; //The profiles already exist. We just check one, because they're all created at
684 //the same time
685
686
687 //Then, loop for the requested number of modules
688 TString title, name;
689 for (int i = 0; i < fModules; i++) {
690 //Pedestals, low gain
691 name = "hPedlowgainDiff";
692 name += i;
693 title = "Pedestals difference, low gain, module ";
694 title += i;
695 fPedestalLowGainDiff.Add(new TProfile2D(name, title,
696 fColumns, 0.0, fColumns,
18db89b7 697 fRows, fRowMin, fRowMax,"s"));
356c3e0c 698
699 //Pedestals, high gain
700 name = "hPedhighgainDiff";
701 name += i;
702 title = "Pedestals difference, high gain, module ";
703 title += i;
704 fPedestalHighGainDiff.Add(new TProfile2D(name, title,
705 fColumns, 0.0, fColumns,
18db89b7 706 fRows, fRowMin, fRowMax,"s"));
707
29f94584 708 //LED Ref/Mon pedestals, low gain
709 name = "hPedestalLEDReflowgainDiff";
710 name += i;
711 title = "Pedestal difference LEDRef, low gain, module ";
712 title += i;
713 fPedestalLEDRefLowGainDiff.Add(new TProfile(name, title,
714 fLEDRefs, 0.0, fLEDRefs, "s"));
715
716 //LED Ref/Mon pedestals, high gain
717 name = "hPedestalLEDRefhighgainDiff";
718 name += i;
719 title = "Pedestal difference LEDRef, high gain, module ";
720 title += i;
721 fPedestalLEDRefHighGainDiff.Add(new TProfile(name, title,
722 fLEDRefs, 0.0, fLEDRefs, "s"));
723
356c3e0c 724 //Peak-Pedestals, high gain
725 name = "hPeakMinusPedhighgainDiff";
726 name += i;
727 title = "Peak-Pedestal difference, high gain, module ";
728 title += i;
729 fPeakMinusPedHighGainDiff.Add(new TProfile2D(name, title,
730 fColumns, 0.0, fColumns,
18db89b7 731 fRows, fRowMin, fRowMax,"s"));
29f94584 732
733 //Peak-Pedestals, low gain
734 name = "hPeakMinusPedlowgainDiff";
735 name += i;
736 title = "Peak-Pedestal difference, low gain, module ";
737 title += i;
738 fPeakMinusPedLowGainDiff.Add(new TProfile2D(name, title,
739 fColumns, 0.0, fColumns,
740 fRows, fRowMin, fRowMax,"s"));
356c3e0c 741
742 //Pedestals, low gain
743 name = "hPedlowgainRatio";
744 name += i;
745 title = "Pedestals ratio, low gain, module ";
746 title += i;
747 fPedestalLowGainRatio.Add(new TProfile2D(name, title,
748 fColumns, 0.0, fColumns,
18db89b7 749 fRows, fRowMin, fRowMax,"s"));
356c3e0c 750
751 //Pedestals, high gain
752 name = "hPedhighgainRatio";
753 name += i;
754 title = "Pedestals ratio, high gain, module ";
755 title += i;
756 fPedestalHighGainRatio.Add(new TProfile2D(name, title,
757 fColumns, 0.0, fColumns,
18db89b7 758 fRows, fRowMin, fRowMax,"s"));
29f94584 759
760 //LED Ref/Mon pedestals, low gain
761 name = "hPedestalLEDReflowgain";
762 name += i;
763 title = "Pedestal ratio LEDRef, low gain, module ";
764 title += i;
765 fPedestalLEDRefLowGainRatio.Add(new TProfile(name, title,
766 fLEDRefs, 0.0, fLEDRefs, "s"));
767
768 //LED Ref/Mon pedestals, high gain
769 name = "hPedestalLEDRefhighgainRatio";
770 name += i;
771 title = "Pedestal ratio LEDRef, high gain, module ";
772 title += i;
773 fPedestalLEDRefHighGainRatio.Add(new TProfile(name, title,
774 fLEDRefs, 0.0, fLEDRefs, "s"));
356c3e0c 775
776 //Peak-Pedestals, low gain
777 name = "hPeakMinusPedlowgainRatio";
778 name += i;
779 title = "Peak-Pedestal ratio, low gain, module ";
780 title += i;
781 fPeakMinusPedLowGainRatio.Add(new TProfile2D(name, title,
782 fColumns, 0.0, fColumns,
18db89b7 783 fRows, fRowMin, fRowMax,"s"));
356c3e0c 784
785 //Peak-Pedestals, high gain
786 name = "hPeakMinusPedhighgainRatio";
787 name += i;
788 title = "Peak-Pedestal ratio, high gain, module ";
789 title += i;
790 fPeakMinusPedHighGainRatio.Add(new TProfile2D(name, title,
791 fColumns, 0.0, fColumns,
18db89b7 792 fRows, fRowMin, fRowMax,"s"));
356c3e0c 793
794 }//end for nModules create the histograms
795}
796
797//_____________________________________________________________________
798void AliCaloCalibPedestal::ComputeDiffAndRatio()
799{
a235e2bc 800 // calculate differences and ratios relative to a reference
356c3e0c 801 ValidateComparisonProfiles();//Make sure the comparison histos exist
802
803 if (!fReference) {
804 return;//Return if the reference object isn't loaded
805 }
806
29f94584 807 int bin = 0;
808 double diff = 0;
809 double ratio = 1;
356c3e0c 810 for (int i = 0; i < fModules; i++) {
356c3e0c 811 //For computing the difference, we cannot simply do TProfile2D->Add(), because that subtracts the sum of all entries,
812 //which means that the mean of the new profile will not be the difference of the means. So do it by hand:
29f94584 813 for (int j = 0; j < fColumns; j++) {
814 for (int k = 0; k < fRows; k++) {
815 bin = ((TProfile2D*)fPeakMinusPedHighGainDiff[i])->GetBin(j+1, k+1);//Note that we assume here that all histos have the same structure...
816
817 if (fReference->GetPeakProfileHighGain(i)->GetBinContent(bin) > 0) {
818 diff = GetPeakProfileHighGain(i)->GetBinContent(bin) - fReference->GetPeakProfileHighGain(i)->GetBinContent(bin);
819 ((TProfile2D*)fPeakMinusPedHighGainDiff[i])->SetBinContent(bin, diff);
820 ((TProfile2D*)fPeakMinusPedHighGainDiff[i])->SetBinEntries(bin, 1);
821 ratio = GetPeakProfileHighGain(i)->GetBinContent(bin) / fReference->GetPeakProfileHighGain(i)->GetBinContent(bin);
822 ((TProfile2D*)fPeakMinusPedHighGainRatio[i])->SetBinContent(bin, ratio);
823 ((TProfile2D*)fPeakMinusPedHighGainRatio[i])->SetBinEntries(bin, 1);
824 }
825
826 if (fReference->GetPeakProfileLowGain(i)->GetBinContent(bin) > 0) {
827 diff = GetPeakProfileLowGain(i)->GetBinContent(bin) - fReference->GetPeakProfileLowGain(i)->GetBinContent(bin);
828 ((TProfile2D*)fPeakMinusPedLowGainDiff[i])->SetBinContent(bin, diff);
829 ((TProfile2D*)fPeakMinusPedLowGainDiff[i])->SetBinEntries(bin, 1);
830 ratio = GetPeakProfileLowGain(i)->GetBinContent(bin) / fReference->GetPeakProfileLowGain(i)->GetBinContent(bin);
831 ((TProfile2D*)fPeakMinusPedLowGainRatio[i])->SetBinContent(bin, ratio);
832 ((TProfile2D*)fPeakMinusPedLowGainRatio[i])->SetBinEntries(bin, 1);
833 }
834
835 if (fReference->GetPedProfileHighGain(i)->GetBinContent(bin) > 0) {
836 diff = GetPedProfileHighGain(i)->GetBinContent(bin) - fReference->GetPedProfileHighGain(i)->GetBinContent(bin);
837 ((TProfile2D*)fPedestalHighGainDiff[i])->SetBinContent(bin, diff);
838 ((TProfile2D*)fPedestalHighGainDiff[i])->SetBinEntries(bin, 1);
839 ratio = GetPedProfileHighGain(i)->GetBinContent(bin) / fReference->GetPedProfileHighGain(i)->GetBinContent(bin);
840 ((TProfile2D*)fPedestalHighGainRatio[i])->SetBinContent(bin, ratio);
841 ((TProfile2D*)fPedestalHighGainRatio[i])->SetBinEntries(bin, 1);
842 }
843
844 if (fReference->GetPedProfileLowGain(i)->GetBinContent(bin) > 0) {
845 diff = GetPedProfileLowGain(i)->GetBinContent(bin) - fReference->GetPedProfileLowGain(i)->GetBinContent(bin);
846 ((TProfile2D*)fPedestalLowGainDiff[i])->SetBinContent(bin, diff);
847 ((TProfile2D*)fPedestalLowGainDiff[i])->SetBinEntries(bin, 1);
848 ratio = GetPedProfileLowGain(i)->GetBinContent(bin) / fReference->GetPedProfileLowGain(i)->GetBinContent(bin);
849 ((TProfile2D*)fPedestalLowGainRatio[i])->SetBinContent(bin, ratio);
850 ((TProfile2D*)fPedestalLowGainRatio[i])->SetBinEntries(bin, 1);
851 }
852
356c3e0c 853 } // rows
854 } // columns
29f94584 855
856 // same for LED Ref/Mon channels
857 for (int j = 0; j <= fLEDRefs; j++) {
858 bin = j+1;//Note that we assume here that all histos have the same structure...
859
860 if (fReference->GetPedLEDRefProfileHighGain(i)->GetBinContent(bin) > 0) {
861 diff = GetPedLEDRefProfileHighGain(i)->GetBinContent(bin) - fReference->GetPedLEDRefProfileHighGain(i)->GetBinContent(bin);
862 ((TProfile*)fPedestalLEDRefHighGainDiff[i])->SetBinContent(bin, diff);
863 ((TProfile*)fPedestalLEDRefHighGainDiff[i])->SetBinEntries(bin, 1);
864 ratio = GetPedLEDRefProfileHighGain(i)->GetBinContent(bin) / fReference->GetPedLEDRefProfileHighGain(i)->GetBinContent(bin);
865 ((TProfile*)fPedestalLEDRefHighGainRatio[i])->SetBinContent(bin, ratio);
866 ((TProfile*)fPedestalLEDRefHighGainRatio[i])->SetBinEntries(bin, 1);
867 }
868
869 if (fReference->GetPedLEDRefProfileLowGain(i)->GetBinContent(bin) > 0) {
870 diff = GetPedLEDRefProfileLowGain(i)->GetBinContent(bin) - fReference->GetPedLEDRefProfileLowGain(i)->GetBinContent(bin);
871 ((TProfile*)fPedestalLEDRefLowGainDiff[i])->SetBinContent(bin, diff);
872 ((TProfile*)fPedestalLEDRefLowGainDiff[i])->SetBinEntries(bin, 1);
873 ratio = GetPedLEDRefProfileLowGain(i)->GetBinContent(bin) / fReference->GetPedLEDRefProfileLowGain(i)->GetBinContent(bin);
874 ((TProfile*)fPedestalLEDRefLowGainRatio[i])->SetBinContent(bin, ratio);
875 ((TProfile*)fPedestalLEDRefLowGainRatio[i])->SetBinEntries(bin, 1);
876 }
877
878 }
879
356c3e0c 880 } // modules
881
882}
883
884//_____________________________________________________________________
59ed788d 885void AliCaloCalibPedestal::ComputeHotAndWarningTowers(const char * hotMapFile)
886{ // look for hot/noisy towers
887 ofstream * fout = 0;
888 char name[512];//Quite a long temp buffer, just in case the filename includes a path
889
890 if (hotMapFile) {
891 snprintf(name, 512, "%s.txt", hotMapFile);
892 fout = new ofstream(name);
893 if (!fout->is_open()) {
894 delete fout;
895 fout = 0;//Set the pointer to empty if the file was not opened
896 }
897 }
898
899 for(int i = 0; i < fModules; i++){
900
901 //first we compute the peak-pedestal distribution for each supermodule...
902 if( GetPeakHighGainHisto(i)->GetEntries() > 0 ) {
903 double min = GetPeakProfileHighGain(i)->GetBinContent(GetPeakProfileHighGain(i)->GetMinimumBin());
904 double max = GetPeakProfileHighGain(i)->GetBinContent(GetPeakProfileHighGain(i)->GetMaximumBin());
905 TH1D *hPeakFit = new TH1D(Form("hFit_%d", i), Form("hFit_%d", i), (int)((max-min)*10), min-1, max+1);
906
907 for (int j = 1; j <= fColumns; j++) {
908 for (int k = 1; k <= fRows; k++) {
909 hPeakFit->Fill(GetPeakProfileHighGain(i)->GetBinContent(j, k));
910 }
911 }
912
c490d8e5 913 //...and then we try to fit it
914 double mean = hPeakFit->GetMean();
915 double sigma = hPeakFit->GetRMS();
916 try {
917 hPeakFit->Fit("gaus", "OQ", "", mean - 3*sigma, mean + 3*sigma);
918 mean = hPeakFit->GetFunction("gaus")->GetParameter(1);
919 sigma = hPeakFit->GetFunction("gaus")->GetParameter(2);
920 }
921 catch (const std::exception & e) {
922 printf("AliCaloCalibPedestal: TH1D PeakFit exception %s", e.what());
923 }
59ed788d 924 //hPeakFit->Draw();
59ed788d 925
926 delete hPeakFit;
927
928 //Then we look for warm/hot towers
929 TH2F * hPeak2D = GetPeakHighGainHisto(i);
930 hPeak2D->GetYaxis()->SetRangeUser( fWarningThreshold, hPeak2D->GetYaxis()->GetBinUpEdge(hPeak2D->GetNbinsY()) );
931
932 int idx = 0 ;
933 int warnCounter = 0;
934 for (int j = 1; j <= fColumns; j++) {
935 for (int k = 1; k <= fRows; k++) {
936 //we start looking for warm/warning towers...
937 // histogram x-axis index
938 idx = k-1 + fRows*(j-1); // this is what is used in the Fill call
939 hPeak2D->GetXaxis()->SetRangeUser(idx, idx);
940 warnCounter = (int) hPeak2D->Integral();
941 if(warnCounter > fNEvents * fWarningFraction) {
942 ((TH2D*)fDeadMap[i])->SetBinContent(j, k, kWarning);
943 /* printf("mod %d col %d row %d warnCounter %d - status %d\n",
944 i, j-1, k-1, warnCounter, (int) (kWarning)); */
945 }
946 //...then we look for hot ones (towers whose values are greater than mean + X*sigma)
947 if(GetPeakProfileHighGain(i)->GetBinContent(j, k) > mean + fHotSigma*sigma ) {
948 ((TH2D*)fDeadMap[i])->SetBinContent(j, k, kHot);
949 /* printf("mod %d col %d row %d binc %d - status %d\n",
950 i, j-1, k-1, (int)(GetPeakProfileHighGain(i)->GetBinContent(j, k)), (int) (kHot)); */
951 }
952
953 //Write the status to the hot/warm map file, if the file is open.
954 // module - column - row - status (1=dead, 2= warm/warning , 3 = hot, see .h file enum)
955 if (fout && ((TH2D*)fDeadMap[i])->GetBinContent(j, k) > 1) {
956
957 (*fout) << i << " "
958 << (j - 1) << " "
959 << (k - 1) << " "
960 << ((TH2D*)fDeadMap[i])->GetBinContent(j, k) << endl; }
961
962 }
963 }
964
965 }
966 }
967 return;
968}
969
970//_____________________________________________________________________
971void AliCaloCalibPedestal::ComputeDeadTowers(const char * deadMapFile)
a235e2bc 972{
973 //Computes the number of dead towers etc etc into memory, after this you can call the GetDead... -functions
356c3e0c 974 int countTot = 0;
975 int countNew = 0;
976 int countRes = 0;
977 ofstream * fout = 0;
978 ofstream * diff = 0;
979 char name[512];//Quite a long temp buffer, just in case the filename includes a path
980
981 if (deadMapFile) {
982 snprintf(name, 512, "%s.txt", deadMapFile);
983 fout = new ofstream(name);
984 snprintf(name, 512, "%sdiff.txt", deadMapFile);
985 diff = new ofstream(name);
986 if (!fout->is_open()) {
987 delete fout;
988 fout = 0;//Set the pointer to empty if the file was not opened
989 }
990 if (!diff->is_open()) {
991 delete diff;
992 fout = 0;//Set the pointer to empty if the file was not opened
993 }
994 }
995
996 for (int i = 0; i < fModules; i++) {
997 if (GetPeakProfileHighGain(i)->GetEntries() > 0) { //don't care about empty histos
998 for (int j = 1; j <= fColumns; j++) {
999 for (int k = 1; k <= fRows; k++) {
1000
59ed788d 1001 if (GetPeakProfileHighGain(i)->GetBinContent(j, k) < fDeadThreshold) {//It's dead
356c3e0c 1002 countTot++;//One more dead total
1003 if (fout) {
1004 (*fout) << i << " "
59ed788d 1005 << (j - 1) << " "
1006 << (k - 1) << " "
356c3e0c 1007 << "1" << " "
1008 << "0" << endl;//Write the status to the deadmap file, if the file is open.
1009 }
1010
59ed788d 1011 if (fReference && fReference->GetPeakProfileHighGain(i)->GetBinContent(j, k) >= fDeadThreshold) {
356c3e0c 1012 ((TH2D*)fDeadMap[i])->SetBinContent(j, k, kRecentlyDeceased);
1013 countNew++;//This tower wasn't dead before!
1014 if (diff) {
1015 ( *diff) << i << " "
356c3e0c 1016 << (j - 1) << " "
59ed788d 1017 << (k - 1) << " "
356c3e0c 1018 << "1" << " "
1019 << "0" << endl;//Write the status to the deadmap difference file, if the file is open.
1020 }
1021 }
1022 else {
1023 ((TH2D*)fDeadMap[i])->SetBinContent(j, k, kDead);//This has been dead before. Nothing new
1024 }
1025 }
1026 else { //It's ALIVE!!
1027 //Don't bother with writing the live ones.
59ed788d 1028 if (fReference && fReference->GetPeakProfileHighGain(i)->GetBinContent(j, k) < fDeadThreshold) {
356c3e0c 1029 ((TH2D*)fDeadMap[i])->SetBinContent(j, k, kResurrected);
1030 countRes++; //This tower was dead before => it's a miracle! :P
1031 if (diff) {
1032 (*diff) << i << " "
356c3e0c 1033 << (j - 1) << " "
59ed788d 1034 << (k - 1) << " "
356c3e0c 1035 << "1" << " "
1036 << "1" << endl;//Write the status to the deadmap difference file, if the file is open.
1037 }
1038 }
1039 else {
1040 ((TH2D*)fDeadMap[i])->SetBinContent(j, k, kAlive);
1041 }
1042 }
1043
1044 }//end for k/rows
1045 }//end for j/columns
1046 }//end if GetEntries >= 0
1047
1048 }//end for modules
1049
1050 if (fout) {
1051 fout->close();
1052 delete fout;
1053 }
1054
1055 fDeadTowers = countTot;
1056 fNewDeadTowers = countNew;
1057 fResurrectedTowers = countRes;
1058}
1059
40164976 1060//_____________________________________________________________________
1061Bool_t AliCaloCalibPedestal::IsBadChannel(int imod, int icol, int irow) const
1062{
59ed788d 1063 //Check if channel is dead or hot.
1064 Int_t status = (Int_t) ( ((TH2D*)fDeadMap[imod])->GetBinContent(icol,irow) );
1065 if(status == kAlive)
1066 return kFALSE;
1067 else
1068 return kTRUE;
1069
40164976 1070}
1071
1072//_____________________________________________________________________
1073void AliCaloCalibPedestal::SetChannelStatus(int imod, int icol, int irow, int status)
1074{
59ed788d 1075 //Set status of channel dead, hot, alive ...
1076 ((TH2D*)fDeadMap[imod])->SetBinContent(icol, irow, status);
40164976 1077}