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.2 2006/12/12 17:16:09 gustavo
21 * Detector name hardcoded in Preprocesor with new detector name notation (3 letters). New way to take reference histogram to avoid problems in case of low number of entries or no existing histogram. Change return 0 by return 1
23 * Revision 1.1 2006/12/07 16:32:16 gustavo
24 * First shuttle code, online calibration histograms producer, EMCAL preprocessor
28 ///////////////////////////////////////////////////////////////////////////////
29 // EMCAL Preprocessor class. It runs by Shuttle at the end of the run,
30 // calculates calibration coefficients and dead/bad channels
31 // to be posted in OCDB
33 // Author: Boris Polichtchouk, 4 October 2006
34 // Adapted for EMCAL by Gustavo Conesa Balbastre, October 2006
35 ///////////////////////////////////////////////////////////////////////////////
47 #include "AliEMCALPreprocessor.h"
49 #include "AliCDBMetaData.h"
50 #include "AliEMCALCalibData.h"
52 ClassImp(AliEMCALPreprocessor)
54 //_______________________________________________________________________________________
55 AliEMCALPreprocessor::AliEMCALPreprocessor() :
56 AliPreprocessor("EMC",0)
61 //_______________________________________________________________________________________
62 AliEMCALPreprocessor::AliEMCALPreprocessor(AliShuttleInterface* shuttle):
63 AliPreprocessor("EMC",shuttle)
68 //_______________________________________________________________________________________
69 UInt_t AliEMCALPreprocessor::Process(TMap* /*valueSet*/)
71 // process data retrieved by the Shuttle
73 // The fileName with the histograms which have been produced by
74 // AliEMCALCalibHistoProducer.
75 // It is a responsibility of the SHUTTLE framework to form the fileName
77 TString fileName = GetFile(kDAQ, "AMPLITUDES", "GDC");
78 Log(Form("Got filename: %s",fileName.Data()));
83 Log(Form("File %s is not opened, something goes wrong!",fileName.Data()));
87 const Int_t nMod=12; // 1:5 modules
88 const Int_t nCol=48; //1:56 columns in each module
89 Int_t nRow=24; //1:64 rows in each module
90 const Int_t nRowHalfSM = 12; //Supermodules 11 and 12 are half supermodules
97 //Get reference histogram
98 TList * keylist = f.GetListOfKeys();
99 Int_t nkeys = f.GetNkeys();
102 TString refHistoName= "";
105 TH1F* hRef = new TH1F();
107 //Check if the file contains any histogram
109 Log(Form("Not enough histograms for calibration, nhist = %d",nkeys));
114 ikey = gRandom->Integer(nkeys);
115 key = (TKey*)keylist->At(ikey);
116 refHistoName = key->GetName();
117 hRef = (TH1F*)f.Get(refHistoName);
119 // Check if the reference has too little statistics and
120 // if the histogram has the correct name (2 kinds, mod#col#row for
121 // reference here, and mod#, see AliEMCALHistoProducer.
122 if(refHistoName.Contains("col") && hRef->GetEntries()>2 && hRef->GetMean()>0)
124 if(!ok && counter >= nMod*nCol*nRow+nMod){
125 Log("No histogram with enough statistics for reference");
130 Double_t refMean=hRef->GetMean();
132 // Calculates relative calibration coefficients for all non-zero channels
133 AliEMCALCalibData calibData;
135 for(Int_t mod=0; mod<nMod; mod++) {
136 if(mod > 10) nRow = nRowHalfSM ;
137 for(Int_t col=0; col<nCol; col++) {
138 for(Int_t row=0; row<nRow; row++) {
139 sprintf(hnam,"mod%dcol%drow%d",mod,col,row);
140 histo = (TH1F*)f.Get(hnam);
141 //TODO: dead channels exclusion!
142 if(histo && histo->GetMean() > 0) {
143 coeff = histo->GetMean()/refMean;
144 calibData.SetADCchannel(mod+1,col+1,row+1,1./coeff);
145 AliDebug(1,Form("mod %d col %d row %d coeff %f\n",mod,col,row,coeff));
148 calibData.SetADCchannel(mod+1,col+1,row+1,-111);
153 AliCDBMetaData metaData;
154 Int_t result = Store("Calib", "Data", &calibData, &metaData);