Detector name hardcoded in Preprocesor with new detector name notation (3 letters...
[u/mrichter/AliRoot.git] / PHOS / AliPHOSPreprocessor.cxx
CommitLineData
1ab07e55 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 **************************************************************************/
15
16/* $Id$ */
17
18///////////////////////////////////////////////////////////////////////////////
19// PHOS Preprocessor class. It runs by Shuttle at the end of the run,
20// calculates calibration coefficients and dead/bad channels
21// to be posted in OCDB
22//
23// Author: Boris Polichtchouk, 4 October 2006
24///////////////////////////////////////////////////////////////////////////////
25
26#include "AliPHOSPreprocessor.h"
27#include "AliLog.h"
28#include "AliCDBMetaData.h"
29#include "AliPHOSEmcCalibData.h"
30#include "TFile.h"
31#include "TH1.h"
32#include "TMap.h"
33#include "TRandom.h"
34
35ClassImp(AliPHOSPreprocessor)
36
37//_______________________________________________________________________________________
38AliPHOSPreprocessor::AliPHOSPreprocessor() :
81587b1e 39AliPreprocessor("PHS",0)
1ab07e55 40{
41 //default constructor
42}
43
44//_______________________________________________________________________________________
81587b1e 45AliPHOSPreprocessor::AliPHOSPreprocessor(AliShuttleInterface* shuttle):
46AliPreprocessor("PHS",shuttle)
1ab07e55 47{
48 // Constructor
49}
50
51//_______________________________________________________________________________________
52UInt_t AliPHOSPreprocessor::Process(TMap* /*valueSet*/)
53{
54 // process data retrieved by the Shuttle
55
56 // The fileName with the histograms which have been produced by
57 // AliPHOSCalibHistoProducer.
58 // It is a responsibility of the SHUTTLE framework to form the fileName
59
60 const char* fileName = GetFile(kDAQ, "AMPLITUDES", "GDC");
61 AliInfo(Form("Got filename: %s",fileName));
62
63 TFile f(fileName);
64
65 if(!f.IsOpen()) {
66 AliInfo(Form("File %s is not opened, something goes wrong!",fileName));
67 return 0;
68 }
69
70 const Int_t nMod=5; // 1:5 modules
71 const Int_t nCol=56; //1:56 columns in each module
72 const Int_t nRow=64; //1:64 rows in each module
73
74 Double_t coeff;
75 char hnam[80];
76 TH1F* histo=0;
77
78 // Generate name of the reference histogram
79 TString refHistoName = "mod";
80 refHistoName += gRandom->Integer(nMod)+1;
81 refHistoName += "col";
82 refHistoName += gRandom->Integer(nCol)+1;
83 refHistoName += "row";
84 refHistoName += gRandom->Integer(nRow)+1;
85 TH1F* hRef = (TH1F*)f.Get(refHistoName);
86
87 // If the reference histogram does not exist or has too little statistics,
88 // it is better to give up preprocessing
89 if(!hRef || hRef->GetEntries()<2) {
90 AliInfo(Form("Cannot get reference histogram %s",refHistoName.Data()));
91 return 0;
92 }
93
94 AliPHOSEmcCalibData calibData;
95 Double_t refMean=hRef->GetMean();
96
97 // Calculates relative calibration coefficients for all non-zero channels
98
99 for(Int_t mod=0; mod<nMod; mod++) {
100 for(Int_t col=0; col<nCol; col++) {
101 for(Int_t row=0; row<nRow; row++) {
102 sprintf(hnam,"mod%dcol%drow%d",mod,col,row);
103 histo = (TH1F*)f.Get(hnam);
104 //TODO: dead channels exclusion!
105 if(histo) {
106 coeff = histo->GetMean()/refMean;
107 calibData.SetADCchannelEmc(mod+1,col+1,row+1,0.001/coeff);
108 AliInfo(Form("mod %d col %d row %d coeff %f\n",mod,col,row,coeff));
109 }
110 else
111 calibData.SetADCchannelEmc(mod+1,col+1,row+1,-111);
112 }
113 }
114 }
115
116 AliCDBMetaData metaData;
81587b1e 117 Int_t result = Store("Calib", "EmcData", &calibData, &metaData);
1ab07e55 118
119 f.Close();
120 return result;
121
122}