]>
Commit | Line | Data |
---|---|---|
7bc140a5 | 1 | /************************************************************************** |
2 | * Copyright(c) 2007, 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 | //This class produces PHOS digits of one event | |
19 | //using AliPHOSRawDecoder. | |
20 | // | |
21 | // For example: | |
22 | // TClonesArray *digits = new TClonesArray("AliPHOSDigit",100); | |
23 | // AliRawReader* rawReader = new AliRawReaderDate("2006run2211.raw"); | |
24 | // AliPHOSRawDecoder dc(rawReader); | |
25 | // while (rawReader->NextEvent()) { | |
26 | // AliPHOSRawDigiProducer producer; | |
27 | // producer.MakeDigits(digits,&dc); | |
28 | // } | |
29 | ||
30 | // Author: Boris Polichtchouk | |
31 | ||
32 | // --- ROOT system --- | |
88fb5e50 | 33 | #include "TClonesArray.h" |
34 | ||
7bc140a5 | 35 | // --- AliRoot header files --- |
88fb5e50 | 36 | #include "AliPHOSRawDigiProducer.h" |
37 | #include "AliPHOSRawDecoder.h" | |
38 | #include "AliPHOSGeometry.h" | |
39 | #include "AliPHOSDigit.h" | |
c0394bfb | 40 | #include "AliPHOSRecoParam.h" |
41 | #include "AliPHOSCalibData.h" | |
42 | #include "AliLog.h" | |
88fb5e50 | 43 | |
44 | ClassImp(AliPHOSRawDigiProducer) | |
45 | ||
c0394bfb | 46 | AliPHOSCalibData * AliPHOSRawDigiProducer::fgCalibData = 0 ; |
47 | ||
48 | //-------------------------------------------------------------------------------------- | |
49 | AliPHOSRawDigiProducer::AliPHOSRawDigiProducer():TObject(), | |
70d93620 | 50 | fEmcMinE(0.),fCpvMinE(0.),fSampleQualityCut(1.),fEmcCrystals(0),fGeom(0){ |
c0394bfb | 51 | |
52 | } | |
53 | //-------------------------------------------------------------------------------------- | |
54 | AliPHOSRawDigiProducer::AliPHOSRawDigiProducer(const AliPHOSRecoParam* parEmc, const AliPHOSRecoParam* parCpv):TObject(), | |
70d93620 | 55 | fEmcMinE(0.),fCpvMinE(0.),fSampleQualityCut(1.),fEmcCrystals(0),fGeom(0){ |
c0394bfb | 56 | |
57 | if(!parEmc) AliFatal("Reconstruction parameters for EMC not set!"); | |
58 | if(!parCpv) AliFatal("Reconstruction parameters for CPV not set!"); | |
59 | ||
60 | fEmcMinE = parEmc->GetMinE(); | |
61 | fCpvMinE = parCpv->GetMinE(); | |
62 | ||
70d93620 | 63 | fSampleQualityCut = parEmc->GetSampleQualityCut() ; |
64 | ||
c0394bfb | 65 | fGeom=AliPHOSGeometry::GetInstance() ; |
66 | if(!fGeom) fGeom = AliPHOSGeometry::GetInstance("IHEP"); | |
67 | ||
68 | fEmcCrystals=fGeom->GetNCristalsInModule()*fGeom->GetNModules() ; | |
69 | ||
70 | GetCalibrationParameters() ; | |
71 | } | |
72 | //-------------------------------------------------------------------------------------- | |
73 | AliPHOSRawDigiProducer::AliPHOSRawDigiProducer(const AliPHOSRawDigiProducer &dp):TObject(), | |
70d93620 | 74 | fEmcMinE(0.),fCpvMinE(0.),fSampleQualityCut(1.),fEmcCrystals(0),fGeom(0){ |
c0394bfb | 75 | |
76 | fEmcMinE = dp.fEmcMinE ; | |
77 | fCpvMinE = dp.fCpvMinE ; | |
78 | fEmcCrystals = dp.fEmcCrystals ; | |
79 | fGeom = dp.fGeom ; | |
80 | } | |
81 | //-------------------------------------------------------------------------------------- | |
82 | AliPHOSRawDigiProducer& AliPHOSRawDigiProducer::operator= (const AliPHOSRawDigiProducer &dp){ | |
83 | if(&dp == this) return *this; | |
84 | ||
85 | fEmcMinE = dp.fEmcMinE ; | |
86 | fCpvMinE = dp.fCpvMinE ; | |
70d93620 | 87 | fSampleQualityCut = dp.fSampleQualityCut ; |
c0394bfb | 88 | fEmcCrystals = dp.fEmcCrystals ; |
89 | fGeom = dp.fGeom ; | |
90 | return *this; | |
91 | } | |
92 | ||
7bc140a5 | 93 | //-------------------------------------------------------------------------------------- |
88fb5e50 | 94 | void AliPHOSRawDigiProducer::MakeDigits(TClonesArray *digits, AliPHOSRawDecoder* decoder) |
95 | { | |
7bc140a5 | 96 | //Makes the job. |
97 | //TClonesArray *digits and raw data decoder should be provided by calling function. | |
98 | ||
88fb5e50 | 99 | digits->Clear(); |
100 | ||
88fb5e50 | 101 | Int_t iDigit = 0 ; |
88fb5e50 | 102 | Int_t relId[4], absId =0; |
103 | ||
c0394bfb | 104 | const Double_t baseLine=1. ; //Minimal energy of digit in ADC ch. |
105 | const Double_t highLowDiff=2. ; //Maximal difference between High and Low channels in LG adc channels | |
88fb5e50 | 106 | |
c0394bfb | 107 | //Temporary array for LowGain digits |
108 | TClonesArray tmpLG("AliPHOSDigit",10000) ; | |
109 | Int_t ilgDigit=0 ; | |
110 | ||
111 | while (decoder->NextDigit()) { | |
34827459 | 112 | |
c0394bfb | 113 | Double_t energy=decoder->GetEnergy() ; |
114 | if(energy<=baseLine) //in ADC channels | |
115 | continue ; | |
1267d56d | 116 | |
70d93620 | 117 | //remove digits with bas shape. Decoder should calculate quality so that |
118 | //in default case quality [0,1], while larger values of quality mean somehow | |
119 | //corrupted samples, 999 means obviously corrupted sample. | |
120 | if(decoder->GetSampleQuality() > fSampleQualityCut ) | |
121 | continue ; | |
122 | ||
c0394bfb | 123 | Bool_t lowGainFlag = decoder->IsLowGain(); |
88fb5e50 | 124 | |
125 | relId[0] = decoder->GetModule(); | |
126 | relId[1] = 0; | |
127 | relId[2] = decoder->GetRow(); | |
128 | relId[3] = decoder->GetColumn(); | |
c0394bfb | 129 | fGeom->RelToAbsNumbering(relId, absId); |
130 | ||
131 | Double_t time = decoder->GetTime() ; | |
132 | time = CalibrateT(time,relId,lowGainFlag) ; | |
133 | ||
134 | energy = CalibrateE(energy,relId,lowGainFlag) ; | |
135 | ||
136 | if(energy <= 0.) | |
137 | continue; | |
138 | ||
139 | if(lowGainFlag){ | |
7899109f | 140 | new(tmpLG[ilgDigit]) AliPHOSDigit(-1,absId,(Float_t)energy,(Float_t)time); |
c0394bfb | 141 | ilgDigit++ ; |
142 | } | |
143 | else{ | |
144 | if(decoder->IsOverflow()) //Keep this digit to replace it by Low Gain later. | |
145 | //If there is no LogGain it wil be removed by cut on Min E | |
7899109f | 146 | new((*digits)[iDigit]) AliPHOSDigit(-1,absId,-1.f,(Float_t)time); |
c0394bfb | 147 | else |
7899109f | 148 | new((*digits)[iDigit]) AliPHOSDigit(-1,absId,(Float_t)energy,(Float_t)time); |
149 | iDigit++; | |
c0394bfb | 150 | } |
151 | } | |
152 | ||
153 | //Now scan created LG and HG digits and keep only those which appeared in both lists | |
154 | //replace energy of HighGain digits only if there is overflow | |
155 | //negative energy (overflow) | |
156 | digits->Sort() ; | |
157 | tmpLG.Sort() ; | |
158 | Int_t iLG = 0; | |
159 | Int_t nLG1 = tmpLG.GetEntriesFast()-1 ; | |
160 | for(Int_t iDig=0 ; iDig < digits->GetEntriesFast() ; iDig++) { | |
161 | AliPHOSDigit * digHG = dynamic_cast<AliPHOSDigit*>(digits->At(iDig)) ; | |
7899109f | 162 | if (!digHG) continue; |
c0394bfb | 163 | AliPHOSDigit * digLG = dynamic_cast<AliPHOSDigit*>(tmpLG.At(iLG)) ; |
164 | while(iLG<nLG1 && digHG->GetId()> digLG->GetId()){ | |
165 | iLG++ ; | |
166 | digLG = dynamic_cast<AliPHOSDigit*>(tmpLG.At(iLG)) ; | |
167 | } | |
7899109f | 168 | if(digLG && digHG->GetId() == digLG->GetId()){ //we found pair |
c0394bfb | 169 | if(digHG->GetEnergy()<0.){ //This is overflow in HG |
7899109f | 170 | digHG->SetTime(digLG->GetTime()) ; |
171 | digHG->SetEnergy(digLG->GetEnergy()) ; | |
c0394bfb | 172 | } |
173 | else{ //Make approximate comparison of HG and LG energies | |
174 | Double_t de = (digHG->GetEnergy()-digLG->GetEnergy())/16./0.005 ; //aproximate difference in LG ADC ch. | |
175 | if(TMath::Abs(de)>highLowDiff){ //too strong difference, remove digit | |
176 | digits->RemoveAt(iDig) ; | |
88fb5e50 | 177 | } |
178 | } | |
88fb5e50 | 179 | } |
c0394bfb | 180 | else{ //no pair - remove |
181 | // temporary fix for dead LG channels | |
182 | Int_t absId=digHG->GetId() ; | |
183 | Int_t relId[4] ; | |
184 | fGeom->AbsToRelNumbering(absId,relId) ; | |
185 | if(relId[2]%2==1 && relId[3]%16==4) | |
186 | continue ; | |
187 | digits->RemoveAt(iDig) ; | |
188 | } | |
189 | } | |
190 | ||
191 | CleanDigits(digits) ; | |
192 | ||
193 | } | |
194 | //____________________________________________________________________________ | |
195 | Double_t AliPHOSRawDigiProducer::CalibrateE(Double_t amp, Int_t* relId, Bool_t isLowGain) | |
196 | { | |
197 | // Convert EMC measured amplitude into real energy. | |
198 | // Calibration parameters are taken from calibration data base for raw data, | |
199 | // or from digitizer parameters for simulated data. | |
200 | if(fgCalibData){ | |
201 | Int_t module = relId[0]; | |
202 | Int_t column = relId[3]; | |
203 | Int_t row = relId[2]; | |
204 | if(relId[1]==0) { // this is EMC | |
205 | if(isLowGain){ | |
206 | amp*= fgCalibData->GetHighLowRatioEmc(module,column,row); | |
88fb5e50 | 207 | } |
c0394bfb | 208 | amp *= fgCalibData->GetADCchannelEmc(module,column,row); |
209 | return amp ; | |
210 | } | |
211 | } | |
212 | return 0; | |
213 | } | |
214 | //____________________________________________________________________________ | |
215 | Double_t AliPHOSRawDigiProducer::CalibrateT(Double_t time, Int_t * relId, Bool_t /* isLowGain */) | |
216 | { | |
217 | //Calibrate time | |
218 | if(fgCalibData){ | |
219 | Int_t module = relId[0]; | |
220 | Int_t column = relId[3]; | |
221 | Int_t row = relId[2]; | |
222 | if(relId[1]==0) { // this is EMC | |
223 | time += fgCalibData->GetTimeShiftEmc(module,column,row); | |
224 | return time ; | |
225 | } | |
226 | } | |
227 | ||
228 | return -999.; | |
229 | } | |
230 | //____________________________________________________________________________ | |
231 | void AliPHOSRawDigiProducer::CleanDigits(TClonesArray * digits) | |
232 | { | |
233 | // remove digits with amplitudes below threshold. | |
234 | // remove digits in bad channels | |
235 | // sort digits with icreasing AbsId | |
236 | ||
237 | //remove digits in bad map and below threshold | |
238 | Bool_t isBadMap = 0 ; | |
239 | if(fgCalibData->GetNumOfEmcBadChannels()){ | |
240 | isBadMap=1 ; | |
241 | } | |
242 | ||
243 | for(Int_t i=0; i<digits->GetEntriesFast(); i++){ | |
244 | AliPHOSDigit * digit = static_cast<AliPHOSDigit*>(digits->At(i)) ; | |
245 | if(!digit) | |
246 | continue ; | |
247 | if ( (IsInEMC(digit) && digit->GetEnergy() < fEmcMinE) || | |
248 | (IsInCPV(digit) && digit->GetEnergy() < fCpvMinE) ){ | |
249 | digits->RemoveAt(i) ; | |
250 | continue ; | |
251 | } | |
252 | if(isBadMap){ //check bad map now | |
253 | Int_t relid[4] ; | |
254 | fGeom->AbsToRelNumbering(digit->GetId(), relid) ; | |
255 | if(fgCalibData->IsBadChannelEmc(relid[0],relid[2],relid[3])){ | |
256 | digits->RemoveAt(i) ; | |
88fb5e50 | 257 | } |
258 | } | |
88fb5e50 | 259 | } |
260 | ||
c0394bfb | 261 | //Compress, sort and set indexes |
262 | digits->Compress() ; | |
263 | // digits->Sort(); already sorted earlier | |
264 | for (Int_t i = 0 ; i < digits->GetEntriesFast() ; i++) { | |
265 | AliPHOSDigit *digit = static_cast<AliPHOSDigit*>( digits->At(i) ) ; | |
266 | digit->SetIndexInList(i) ; | |
267 | } | |
268 | } | |
269 | //____________________________________________________________________________ | |
270 | Bool_t AliPHOSRawDigiProducer::IsInEMC(AliPHOSDigit * digit) const | |
271 | { | |
272 | // Tells if (true) or not (false) the digit is in a PHOS-EMC module | |
273 | return digit->GetId() <= fEmcCrystals ; | |
274 | ||
275 | } | |
276 | ||
277 | //____________________________________________________________________________ | |
278 | Bool_t AliPHOSRawDigiProducer::IsInCPV(AliPHOSDigit * digit) const | |
279 | { | |
280 | // Tells if (true) or not (false) the digit is in a PHOS-CPV module | |
281 | return digit->GetId() > fEmcCrystals ; | |
282 | } | |
283 | //____________________________________________________________________________ | |
284 | void AliPHOSRawDigiProducer::GetCalibrationParameters() | |
285 | { | |
286 | // Set calibration parameters: | |
287 | // if calibration database exists, they are read from database, | |
288 | // otherwise, reconstruction stops in the constructor of AliPHOSCalibData | |
289 | // | |
290 | // It is a user responsilibity to open CDB before reconstruction, for example: | |
291 | // AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage("local://CalibDB"); | |
292 | ||
293 | if (!fgCalibData){ | |
294 | fgCalibData = new AliPHOSCalibData(-1); //use AliCDBManager's run number | |
295 | } | |
296 | if (fgCalibData->GetCalibDataEmc() == 0) | |
297 | AliFatal("Calibration parameters for PHOS EMC not found. Stop reconstruction.\n"); | |
298 | if (fgCalibData->GetCalibDataCpv() == 0) | |
299 | AliFatal("Calibration parameters for PHOS CPV not found. Stop reconstruction.\n"); | |
88fb5e50 | 300 | } |