1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 /* History of cvs commits:
20 * Revision 1.1 2006/12/07 16:32:16 gustavo
21 * First shuttle code, online calibration histograms producer, EMCAL preprocessor
25 ///////////////////////////////////////////////////////////////////////////////
26 // EMCAL Preprocessor class. It runs by Shuttle at the end of the run,
27 // calculates calibration coefficients and dead/bad channels
28 // to be posted in OCDB
30 // Author: Boris Polichtchouk, 4 October 2006
31 // Adapted for EMCAL by Gustavo Conesa Balbastre, October 2006
32 ///////////////////////////////////////////////////////////////////////////////
41 #include "Riostream.h"
43 #include "AliEMCALPreprocessor.h"
45 #include "AliCDBMetaData.h"
46 #include "AliEMCALCalibData.h"
48 ClassImp(AliEMCALPreprocessor)
50 //_______________________________________________________________________________________
51 AliEMCALPreprocessor::AliEMCALPreprocessor() :
52 AliPreprocessor("EMC",0)
57 //_______________________________________________________________________________________
58 AliEMCALPreprocessor::AliEMCALPreprocessor(AliShuttleInterface* shuttle):
59 AliPreprocessor("EMC",shuttle)
64 //_______________________________________________________________________________________
65 UInt_t AliEMCALPreprocessor::Process(TMap* /*valueSet*/)
67 // process data retrieved by the Shuttle
69 // The fileName with the histograms which have been produced by
70 // AliEMCALCalibHistoProducer.
71 // It is a responsibility of the SHUTTLE framework to form the fileName
73 const char* fileName = GetFile(kDAQ, "AMPLITUDES", "GDC");
74 AliInfo(Form("Got filename: %s",fileName));
79 AliInfo(Form("File %s is not opened, something goes wrong!",fileName));
83 const Int_t nMod=12; // 1:5 modules
84 const Int_t nCol=48; //1:56 columns in each module
85 Int_t nRow=24; //1:64 rows in each module
86 const Int_t nRowHalfSM = 12; //Supermodules 11 and 12 are half supermodules
93 //Get reference histogram
94 TList * keylist = f.GetListOfKeys();
95 Int_t nkeys = f.GetNkeys();
98 TString refHistoName= "";
103 //Check if the file contains any histogram
105 AliInfo(Form("Not enough histograms for calibration, nhist = %d",nkeys));
110 ikey = gRandom->Integer(nkeys);
111 key = (TKey*)keylist->At(ikey);
112 refHistoName = key->GetName();
113 hRef = (TH1F*)f.Get(refHistoName);
115 // Check if the reference has too little statistics and
116 // if the histogram has the correct name (2 kinds, mod#col#row for
117 // reference here, and mod#, see AliEMCALHistoProducer.
118 if(refHistoName.Contains("col") && hRef->GetEntries()>2 && hRef->GetMean()>0)
120 if(!ok && counter >= nMod*nCol*nRow+nMod){
121 AliInfo("No histogram with enough statistics for reference");
126 Double_t refMean=hRef->GetMean();
128 // Calculates relative calibration coefficients for all non-zero channels
129 AliEMCALCalibData calibData;
131 for(Int_t mod=0; mod<nMod; mod++) {
132 if(mod > 10) nRow = nRowHalfSM ;
133 for(Int_t col=0; col<nCol; col++) {
134 for(Int_t row=0; row<nRow; row++) {
135 sprintf(hnam,"mod%dcol%drow%d",mod,col,row);
136 histo = (TH1F*)f.Get(hnam);
137 //TODO: dead channels exclusion!
138 if(histo && histo->GetMean() > 0) {
139 coeff = histo->GetMean()/refMean;
140 calibData.SetADCchannel(mod+1,col+1,row+1,1./coeff);
141 AliInfo(Form("mod %d col %d row %d coeff %f\n",mod,col,row,coeff));
144 calibData.SetADCchannel(mod+1,col+1,row+1,-111);
149 AliCDBMetaData metaData;
150 Int_t result = Store("Calib", "Data", &calibData, &metaData);