1 /**************************************************************************
2 * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
4 * Authors: Boris Polichtchouk & Per Thomas Hille for the ALICE *
5 * offline/HLT Project. Contributors are mentioned in the code where *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
17 #include "AliHLTPHOSRcuHistogramProducer.h"
21 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
24 /*************************************************************************
25 * Class AliHLTPHOSRcuHistogramProducer accumulating histograms *
26 * with amplitudes per PHOS channel *
27 * It is intended to run at the HLT farm *
28 * and it fills the histograms with amplitudes per channel. *
29 * Usage example see in PHOS/macros/Shuttle/AliPHOSCalibHistoProducer.C *
30 **************************************************************************/
31 AliHLTPHOSRcuHistogramProducer:: AliHLTPHOSRcuHistogramProducer(): fEventCount(0), fEquippmentID(0), fModuleID(0), fRcuX(0), fRcuZ(0)
33 cout << "WARNING: You cannot invoke the AliHLTPHOSRcuHistogramProducer without arguments" << endl;
34 cout << "Usage AliHLTPHOSRcuHistogramProducer(ModuleID, X. Z)" << endl;
39 AliHLTPHOSRcuHistogramProducer::AliHLTPHOSRcuHistogramProducer(AliHLTUInt8_t moduleID, AliHLTUInt8_t rcuX, AliHLTUInt8_t rcuZ)
41 SetModuleID(moduleID);
47 AliHLTPHOSRcuHistogramProducer::~ AliHLTPHOSRcuHistogramProducer()
54 AliHLTPHOSRcuHistogramProducer::Init()
56 char tmpHistoName[256];
61 for(int x = 0; x < N_XCOLUMNS_RCU; x ++)
63 for(int z = 0; z < N_ZROWS_RCU; z ++)
65 for(int gain = 0; gain < N_GAINS; gain ++)
67 geomx = x + N_XCOLUMNS_RCU*fRcuX;
68 geomz = z + N_ZROWS_RCU*fRcuZ;
70 fEnergyAverageValues[x][z][gain] = 0;
71 fAccumulatedValues[x][z][gain] = 0;
72 fTimingAverageValues[x][z][gain] = 0;
73 fHits[x][z][gain] = 0;
74 sprintf(tmpHistoName, "Edistribution_%d_%d_%d_%d",(int)fModuleID, geomx, geomz, gain);
75 fEnergyHistogramPtrs[x][z][gain] = 0;
77 fEnergyHistogramPtrs[x][z][gain] = new TH1F( tmpHistoName, tmpHistoName, N_BINS, XBIN_LOW, XBIN_UP);
79 sprintf(tmpHistoName, "TOFdistribution_%d_%d_%d_%d",(int)fModuleID, geomx, geomz, gain);
81 fTimingHistogramPtrs[x][z][gain] = 0;
83 fTimingHistogramPtrs[x][z][gain] = new TH1F(tmpHistoName , tmpHistoName, N_BINS, XBIN_LOW, XBIN_UP);
85 fCellAccEnergy.fAccumulatedEnergies[x][z][gain] = 0;
86 fCellAccEnergy.fHits[x][z][gain] = 0;
87 fCellAccEnergy.fModuleID = 0;
88 fCellAccEnergy.fRcuX = 0;
89 fCellAccEnergy.fRcuZ = 0;
96 AliHLTPHOSRcuHistogramProducer::GetEquippmentId()
103 AliHLTPHOSRcuHistogramProducer::SetRcuX(AliHLTUInt8_t X)
106 fCellAccEnergy.fRcuX = X;
111 AliHLTPHOSRcuHistogramProducer::SetRcuZ(AliHLTUInt8_t Z)
114 fCellAccEnergy.fRcuZ = Z;
119 AliHLTPHOSRcuHistogramProducer::SetModuleID(AliHLTUInt8_t moduleID)
121 fModuleID = moduleID;
126 AliHLTPHOSRcuHistogramProducer::SetEquippmentId(int id)
133 AliHLTPHOSRcuHistogramProducer::FillEnergy(AliHLTUInt8_t x, AliHLTUInt8_t z, AliHLTUInt8_t gain, float energy)
135 fCellAccEnergy.fAccumulatedEnergies[x][z][gain] += energy;
136 fCellAccEnergy.fHits[x][z][gain] ++;
137 fEnergyHistogramPtrs[x][z][gain]->Fill(energy);
142 AliHLTPHOSRcuHistogramProducer::FillTime(AliHLTUInt8_t x, AliHLTUInt8_t z, AliHLTUInt8_t gain, float time)
144 fTimingHistogramPtrs[x][z][gain]->Fill(time);
147 const AliHLTPHOSRcuCellAccumulatedEnergyDataStruct&
148 AliHLTPHOSRcuHistogramProducer::GetCellAccumulatedEnergies()
150 // return &fCellAccEnergy ;
151 return fCellAccEnergy ;
155 AliHLTPHOSRcuHistogramProducer::IncrementEventCounter()
163 AliHLTPHOSRcuHistogramProducer::Reset()
165 for(int x = 0; x < N_XCOLUMNS_RCU; x ++)
167 for(int z = 0; z < N_ZROWS_RCU; z ++)
169 for(int gain = 0; gain < N_GAINS; gain ++)
171 fEnergyAverageValues[x][z][gain] = 0;
172 fAccumulatedValues[x][z][gain] = 0;
173 fTimingAverageValues[x][z][gain] = 0;
174 fHits[x][z][gain] = 0;
179 for(int i = 0; i <ALTRO_MAX_SAMPLES; i++)
181 fTmpChannelData[i] = 0;
186 AliHLTPHOSRcuHistogramProducer::WriteEnergyHistograms()
188 char tmpFileName[256];
189 sprintf(tmpFileName,"/home/aliphoshlt/rundir/outdata/calibHisto_%d_%d_%d.root", (int)fModuleID, (int)fRcuX, (int)fRcuZ);
190 TFile *histoFile = new TFile(tmpFileName,"update");
192 if(!histoFile) return;
193 if(!histoFile->IsOpen()) return;
195 cout <<"printing histograms"<< endl;
196 cout <<"histofile-Getname() =" << histoFile->GetName() << endl;
198 for(int x = 0; x < N_XCOLUMNS_RCU; x ++)
200 for(int z = 0; z < N_ZROWS_RCU; z ++)
202 for(int gain = 0; gain < N_GAINS; gain ++)
204 fEnergyHistogramPtrs[x][z][gain]->Write();
209 cout << "printing histograms, finished"<< endl;