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"
27 /*************************************************************************
28 * Class AliHLTPHOSRcuHistogramProducer accumulating histograms *
29 * with amplitudes per PHOS channel *
30 * It is intended to run at the HLT farm *
31 * and it fills the histograms with amplitudes per channel. *
32 * Usage example see in PHOS/macros/Shuttle/AliPHOSCalibHistoProducer.C *
33 **************************************************************************/
36 AliHLTPHOSRcuHistogramProducer:: AliHLTPHOSRcuHistogramProducer(): fModuleID(0), fRcuX(0), fRcuZ(0)
40 cout << "WARNING: You cannot invoke the AliHLTPHOSRcuHistogramProducer without arguments" << endl;
41 cout << "Usage AliHLTPHOSRcuHistogramProducer(ModuleID, X. Z)" << endl;
44 //AliHLTPHOSRcuHistogramProducer::AliHLTPHOSRcuHistogramProducer(AliHLTUInt8_t moduleID, AliHLTUInt8_t rcuX, AliHLTUInt8_t rcuZ)
45 AliHLTPHOSRcuHistogramProducer::AliHLTPHOSRcuHistogramProducer(AliHLTUInt8_t moduleID, AliHLTUInt8_t rcuX, AliHLTUInt8_t rcuZ)
47 //Se header file for documentation
48 SetModuleID(moduleID);
54 AliHLTPHOSRcuHistogramProducer::~ AliHLTPHOSRcuHistogramProducer()
61 AliHLTPHOSRcuHistogramProducer::Init()
63 //See header file for documentation
64 char tmpHistoName[256];
69 for(int x = 0; x < N_XCOLUMNS_RCU; x ++)
71 for(int z = 0; z < N_ZROWS_RCU; z ++)
73 for(int gain = 0; gain < N_GAINS; gain ++)
75 geomx = x + N_XCOLUMNS_RCU*fRcuX;
76 geomz = z + N_ZROWS_RCU*fRcuZ;
78 fEnergyAverageValues[x][z][gain] = 0;
79 fAccumulatedValues[x][z][gain] = 0;
80 fTimingAverageValues[x][z][gain] = 0;
81 fHits[x][z][gain] = 0;
82 sprintf(tmpHistoName, "Edistribution_%d_%d_%d_%d",(int)fModuleID, geomx, geomz, gain);
83 fEnergyHistogramPtrs[x][z][gain] = 0;
85 fEnergyHistogramPtrs[x][z][gain] = new TH1F( tmpHistoName, tmpHistoName, N_BINS, XBIN_LOW, XBIN_UP);
87 sprintf(tmpHistoName, "TOFdistribution_%d_%d_%d_%d",(int)fModuleID, geomx, geomz, gain);
89 fTimingHistogramPtrs[x][z][gain] = 0;
91 fTimingHistogramPtrs[x][z][gain] = new TH1F(tmpHistoName , tmpHistoName, N_BINS, XBIN_LOW, XBIN_UP);
93 fCellAccEnergy.fAccumulatedEnergies[x][z][gain] = 0;
94 fCellAccEnergy.fHits[x][z][gain] = 0;
95 fCellAccEnergy.fModuleID = 0;
96 fCellAccEnergy.fRcuX = 0;
97 fCellAccEnergy.fRcuZ = 0;
105 AliHLTPHOSRcuHistogramProducer::SetRcuX(AliHLTUInt8_t X)
107 //See header file for documentation
109 fCellAccEnergy.fRcuX = X;
115 AliHLTPHOSRcuHistogramProducer::SetRcuZ(AliHLTUInt8_t Z)
117 //See header file for documentation
119 fCellAccEnergy.fRcuZ = Z;
126 AliHLTPHOSRcuHistogramProducer::SetModuleID(AliHLTUInt8_t moduleID)
128 //See header file for documentation
129 fModuleID = moduleID;
134 AliHLTPHOSRcuHistogramProducer::FillEnergy(AliHLTUInt8_t x, AliHLTUInt8_t z, AliHLTUInt8_t gain, float energy)
136 //See header file for documentation
137 fCellAccEnergy.fAccumulatedEnergies[x][z][gain] += energy;
138 fCellAccEnergy.fHits[x][z][gain] ++;
139 fEnergyHistogramPtrs[x][z][gain]->Fill(energy);
144 AliHLTPHOSRcuHistogramProducer::FillTime(AliHLTUInt8_t x, AliHLTUInt8_t z, AliHLTUInt8_t gain, float time)
146 //See header file for documentation
147 fTimingHistogramPtrs[x][z][gain]->Fill(time);
150 const AliHLTPHOSRcuCellAccumulatedEnergyDataStruct&
151 AliHLTPHOSRcuHistogramProducer::GetCellAccumulatedEnergies()
153 // return &fCellAccEnergy ;
154 return fCellAccEnergy ;
159 AliHLTPHOSRcuHistogramProducer::Reset()
161 //See header file for documentation
162 for(int x = 0; x < N_XCOLUMNS_RCU; x ++)
164 for(int z = 0; z < N_ZROWS_RCU; z ++)
166 for(int gain = 0; gain < N_GAINS; gain ++)
168 fEnergyAverageValues[x][z][gain] = 0;
169 fAccumulatedValues[x][z][gain] = 0;
170 fTimingAverageValues[x][z][gain] = 0;
171 fHits[x][z][gain] = 0;
176 for(int i = 0; i <ALTRO_MAX_SAMPLES; i++)
178 fTmpChannelData[i] = 0;
184 AliHLTPHOSRcuHistogramProducer::WriteEnergyHistograms()
186 //See header file for documentation
187 char tmpFileName[256];
188 sprintf(tmpFileName,"/home/aliphoshlt/rundir/outdata/calibHisto_%d_%d_%d.root", (int)fModuleID, (int)fRcuX, (int)fRcuZ);
189 TFile *histoFile = new TFile(tmpFileName,"update");
191 if(!histoFile) return;
192 if(!histoFile->IsOpen()) return;
194 cout <<"printing histograms"<< endl;
195 cout <<"histofile-Getname() =" << histoFile->GetName() << endl;
197 for(int x = 0; x < N_XCOLUMNS_RCU; x ++)
199 for(int z = 0; z < N_ZROWS_RCU; z ++)
201 for(int gain = 0; gain < N_GAINS; gain ++)
203 fEnergyHistogramPtrs[x][z][gain]->Write();
208 cout << "printing histograms, finished"<< endl;