]>
Commit | Line | Data |
---|---|---|
0ffacf98 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | ||
7d855b04 | 16 | /// \class AliTPCdataQA |
17 | /// | |
18 | /// July 2011: | |
19 | /// | |
20 | /// Changes to accomodate updates of general DQM/QA changes to have per trigger | |
21 | /// histograms (for a given event specie). | |
22 | /// | |
23 | /// AliTPCdataQA has a new flag for only keeping DQM info event by | |
24 | /// event! | |
25 | /// The expert/DA functionality has been kept exactly the same! | |
26 | /// | |
27 | /// | |
28 | /// June 2010 | |
29 | /// | |
30 | /// This update should solve two problems mainly: | |
31 | /// * The vs event histograms have been limited to a fixed size for the | |
32 | /// DQM. The 500k seemed to be a big size but is no longer so, so we | |
33 | /// need to dynamically expand the range. The non-trivial point is that | |
34 | /// we also have to do it for the copy owned by AliTPCQADataMakerRec. | |
35 | /// * The amoreGui now remembers the x-range of the first visualization so | |
36 | /// the trick of setting the relevant event range as the histogram is | |
37 | /// filled no longer works. | |
38 | /// | |
39 | /// The fix is a bit crude but avoids creating a new histogram. Instead | |
40 | /// the range is expanded (max events and events per bin is doubled) but | |
41 | /// the number of bins is kept constant! In this way we can change just | |
42 | /// double the max of the X-axis of the hist and rebin the data. The | |
43 | /// same can easily be done for the copy owned by AliTPCQADataMakerRec. | |
44 | /// | |
45 | /// CAUTION: | |
46 | /// If we change the number of bins we could crash the whole system | |
47 | /// because ROOT does not create space for extra bins! (but we do not do | |
48 | /// this). In that way it is a crude solution. | |
49 | /// The rebinning in the code only works for an even number of bins. | |
50 | /// | |
51 | /// In addition to the above a bug in the reading of the config file was | |
52 | /// also found and corrected. fAdcMax was set instead of fEventsPerBin. | |
53 | /// | |
54 | /// Finally cout was changes to AliInfo. | |
55 | /// | |
56 | /// February 2008 | |
57 | /// | |
58 | /// The code has been heavily modified so that now the RAW data is | |
59 | /// "expanded" for each sector and stored in a big signal array. Then a | |
60 | /// simple version of the code in AliTPCclusterer is used to identify | |
61 | /// the local maxima and these are then used for QA. This gives a better | |
62 | /// estimate of the charge (both max and total) and also limits the | |
63 | /// effect of noise. | |
64 | /// | |
65 | /// Implementation: | |
66 | /// | |
67 | /// In Update the RAW signals >= 3 ADC channels are stored in the arrays. | |
68 | /// There are 3 arrays: | |
69 | /// | |
70 | /// ~~~{.cpp} | |
71 | /// Float_t** fAllBins 2d array [row][bin(pad, time)] ADC signal | |
72 | /// Int_t** fAllSigBins 2d array [row][signal#] bin(with signal) | |
73 | /// Int_t* fAllNSigBins; 1d array [row] Nsignals | |
74 | /// ~~~ | |
75 | /// | |
76 | /// This is done sector by sector. | |
77 | /// | |
78 | /// When data from a new sector is encountered, the method | |
79 | /// FindLocalMaxima is called on the data from the previous sector, and | |
80 | /// the calibration/data objects are updated with the "cluster" | |
81 | /// info. Finally the arrays are cleared. | |
82 | /// | |
83 | /// The requirements for a local maxima is: | |
84 | /// Charge in bin is >= 5 ADC channels. | |
85 | /// Charge in bin is larger than all the 8 neighboring bins. | |
86 | /// At least one of the two pad neighbors has a signal. | |
87 | /// At least one of the two time neighbors has a signal. | |
88 | /// | |
89 | /// Before accessing the data it is expected that the Analyse method is | |
90 | /// called. This normalizes some of the data objects to per event or per | |
91 | /// cluster. | |
92 | /// If more data is passed to the class after Analyse has been called | |
93 | /// the normalization is reversed and Analyse has to be called again. | |
0ffacf98 | 94 | |
95 | //Root includes | |
96 | #include <TH1F.h> | |
0ffacf98 | 97 | #include <TString.h> |
98 | #include <TMath.h> | |
0ffacf98 | 99 | #include <TDirectory.h> |
100 | #include <TFile.h> | |
266f8637 | 101 | #include <TError.h> |
ac940b58 | 102 | #include <TMap.h> |
6a50ff96 | 103 | #include <TProfile.h> |
909e332a | 104 | #include <TObjArray.h> |
0ffacf98 | 105 | //AliRoot includes |
106 | #include "AliRawReader.h" | |
107 | #include "AliRawReaderRoot.h" | |
108 | #include "AliRawReaderDate.h" | |
0c25417d | 109 | #include "AliTPCRawStreamV3.h" |
0ffacf98 | 110 | #include "AliTPCCalROC.h" |
111 | #include "AliTPCROC.h" | |
112 | #include "AliMathBase.h" | |
113 | #include "TTreeStream.h" | |
0ffacf98 | 114 | |
115 | //date | |
116 | #include "event.h" | |
117 | #include "AliTPCCalPad.h" | |
258cd111 | 118 | #include "AliTPCPreprocessorOnline.h" |
0ffacf98 | 119 | |
120 | //header file | |
121 | #include "AliTPCdataQA.h" | |
ce0175fa | 122 | #include "AliLog.h" |
0ffacf98 | 123 | |
92ae9768 | 124 | |
7d855b04 | 125 | /// \cond CLASSIMP |
0ffacf98 | 126 | ClassImp(AliTPCdataQA) |
7d855b04 | 127 | /// \endcond |
0ffacf98 | 128 | |
7d855b04 | 129 | AliTPCdataQA::AliTPCdataQA() : /*FOLD00*/ |
0ffacf98 | 130 | fFirstTimeBin(60), |
131 | fLastTimeBin(1000), | |
909e332a | 132 | fAdcMin(3), |
133 | fAdcMax(1000), | |
134 | fMinQMax(5.f), | |
135 | fRequireNeighbouringPad(kTRUE), | |
0ffacf98 | 136 | fMapping(NULL), |
f11b3071 | 137 | fPedestal(0), |
138 | fNoise(0), | |
266f8637 | 139 | fNLocalMaxima(0), |
0ffacf98 | 140 | fMaxCharge(0), |
f11b3071 | 141 | fMeanCharge(0), |
142 | fNoThreshold(0), | |
266f8637 | 143 | fNTimeBins(0), |
144 | fNPads(0), | |
145 | fTimePosition(0), | |
c94a79e1 | 146 | fOverThreshold10(0), |
147 | fOverThreshold20(0), | |
148 | fOverThreshold30(0), | |
23c9ab21 | 149 | fHistQVsTimeSideA(0), |
150 | fHistQVsTimeSideC(0), | |
151 | fHistQMaxVsTimeSideA(0), | |
152 | fHistQMaxVsTimeSideC(0), | |
ce0175fa | 153 | fHistOccupancyVsEvent(0), |
154 | fHistNclustersVsEvent(0), | |
266f8637 | 155 | fEventCounter(0), |
156 | fIsAnalysed(kFALSE), | |
ce0175fa | 157 | fMaxEvents(500000), // Max events for event histograms |
158 | fEventsPerBin(1000), // Events per bin for event histograms | |
159 | fSignalCounter(0), // Signal counter | |
160 | fClusterCounter(0), // Cluster counter | |
909e332a | 161 | fActiveChambers(72), |
266f8637 | 162 | fAllBins(0), |
163 | fAllSigBins(0), | |
164 | fAllNSigBins(0), | |
165 | fRowsMax(0), | |
166 | fPadsMax(0), | |
0ab2a4cc | 167 | fTimeBinsMax(0), |
168 | fIsDQM(kFALSE), | |
169 | fHistOccVsSector(0x0), | |
92ae9768 | 170 | fHistOcc2dVsSector(0x0), |
0ab2a4cc | 171 | fHistQVsSector(0x0), |
172 | fHistQmaxVsSector(0x0), | |
173 | fOccVec(0x0), | |
92ae9768 | 174 | fOccMaxVec(0x0), |
175 | fOccVecFine(0x0), | |
176 | fOccMaxVecFine(0x0) | |
0ffacf98 | 177 | { |
178 | // | |
179 | // default constructor | |
180 | // | |
909e332a | 181 | |
182 | for (Int_t i=0; i<72; ++i) {fActiveChambers.SetBitNumber(i,kTRUE);} | |
0ffacf98 | 183 | } |
184 | ||
0ffacf98 | 185 | //_____________________________________________________________________ |
186 | AliTPCdataQA::AliTPCdataQA(const AliTPCdataQA &ped) : /*FOLD00*/ | |
336156cc | 187 | TH1F(ped), |
0ffacf98 | 188 | fFirstTimeBin(ped.GetFirstTimeBin()), |
189 | fLastTimeBin(ped.GetLastTimeBin()), | |
190 | fAdcMin(ped.GetAdcMin()), | |
191 | fAdcMax(ped.GetAdcMax()), | |
909e332a | 192 | fMinQMax(ped.GetMinQMax()), |
193 | fRequireNeighbouringPad(ped.GetRequireNeighbouringPad()), | |
266f8637 | 194 | fMapping(NULL), |
195 | fPedestal(0), | |
196 | fNoise(0), | |
197 | fNLocalMaxima(0), | |
198 | fMaxCharge(0), | |
199 | fMeanCharge(0), | |
200 | fNoThreshold(0), | |
266f8637 | 201 | fNTimeBins(0), |
202 | fNPads(0), | |
203 | fTimePosition(0), | |
c94a79e1 | 204 | fOverThreshold10(0), |
205 | fOverThreshold20(0), | |
206 | fOverThreshold30(0), | |
23c9ab21 | 207 | fHistQVsTimeSideA(0), |
208 | fHistQVsTimeSideC(0), | |
209 | fHistQMaxVsTimeSideA(0), | |
210 | fHistQMaxVsTimeSideC(0), | |
ce0175fa | 211 | fHistOccupancyVsEvent(0), |
212 | fHistNclustersVsEvent(0), | |
266f8637 | 213 | fEventCounter(ped.GetEventCounter()), |
214 | fIsAnalysed(ped.GetIsAnalysed()), | |
ce0175fa | 215 | fMaxEvents(ped.GetMaxEvents()), |
216 | fEventsPerBin(ped.GetEventsPerBin()), | |
217 | fSignalCounter(ped.GetSignalCounter()), | |
218 | fClusterCounter(ped.GetClusterCounter()), | |
909e332a | 219 | fActiveChambers(ped.fActiveChambers), |
266f8637 | 220 | fAllBins(0), |
221 | fAllSigBins(0), | |
222 | fAllNSigBins(0), | |
223 | fRowsMax(0), | |
224 | fPadsMax(0), | |
0ab2a4cc | 225 | fTimeBinsMax(0), |
226 | fIsDQM(ped.GetIsDQM()), | |
227 | fHistOccVsSector(0x0), | |
92ae9768 | 228 | fHistOcc2dVsSector(0x0), |
0ab2a4cc | 229 | fHistQVsSector(0x0), |
230 | fHistQmaxVsSector(0x0), | |
231 | fOccVec(0x0), | |
92ae9768 | 232 | fOccMaxVec(0x0), |
233 | fOccVecFine(0x0), | |
234 | fOccMaxVecFine(0x0) | |
0ffacf98 | 235 | { |
7d855b04 | 236 | /// copy constructor |
237 | ||
266f8637 | 238 | if(ped.GetNLocalMaxima()) |
239 | fNLocalMaxima = new AliTPCCalPad(*ped.GetNLocalMaxima()); | |
240 | if(ped.GetMaxCharge()) | |
241 | fMaxCharge = new AliTPCCalPad(*ped.GetMaxCharge()); | |
242 | if(ped.GetMeanCharge()) | |
243 | fMeanCharge = new AliTPCCalPad(*ped.GetMeanCharge()); | |
244 | if(ped.GetNoThreshold()) | |
245 | fNoThreshold = new AliTPCCalPad(*ped.GetNoThreshold()); | |
246 | if(ped.GetNTimeBins()) | |
247 | fNTimeBins = new AliTPCCalPad(*ped.GetNTimeBins()); | |
248 | if(ped.GetNPads()) | |
249 | fNPads = new AliTPCCalPad(*ped.GetNPads()); | |
250 | if(ped.GetTimePosition()) | |
251 | fTimePosition = new AliTPCCalPad(*ped.GetTimePosition()); | |
252 | if(ped.GetOverThreshold10()) | |
253 | fOverThreshold10 = new AliTPCCalPad(*ped.GetOverThreshold10()); | |
254 | if(ped.GetOverThreshold20()) | |
255 | fOverThreshold20 = new AliTPCCalPad(*ped.GetOverThreshold20()); | |
256 | if(ped.GetOverThreshold30()) | |
257 | fOverThreshold30 = new AliTPCCalPad(*ped.GetOverThreshold30()); | |
1cb9ffdb | 258 | if(ped.GetHistQVsTimeSideA()) { |
23c9ab21 | 259 | fHistQVsTimeSideA = new TProfile(*ped.GetHistQVsTimeSideA()); |
1cb9ffdb | 260 | fHistQVsTimeSideA->SetDirectory(0); |
261 | } | |
262 | if(ped.GetHistQVsTimeSideC()) { | |
23c9ab21 | 263 | fHistQVsTimeSideC = new TProfile(*ped.GetHistQVsTimeSideC()); |
1cb9ffdb | 264 | fHistQVsTimeSideC->SetDirectory(0); |
265 | } | |
266 | if(ped.GetHistQMaxVsTimeSideA()) { | |
23c9ab21 | 267 | fHistQMaxVsTimeSideA = new TProfile(*ped.GetHistQMaxVsTimeSideA()); |
1cb9ffdb | 268 | fHistQMaxVsTimeSideA->SetDirectory(0); |
269 | } | |
270 | if(ped.GetHistQMaxVsTimeSideC()) { | |
23c9ab21 | 271 | fHistQMaxVsTimeSideC = new TProfile(*ped.GetHistQMaxVsTimeSideC()); |
1cb9ffdb | 272 | fHistQMaxVsTimeSideC->SetDirectory(0); |
273 | } | |
ce0175fa | 274 | if(ped.GetHistOccupancyVsEventConst()) { |
275 | fHistOccupancyVsEvent = new TH1F(*ped.GetHistOccupancyVsEventConst()); | |
276 | fHistOccupancyVsEvent->SetDirectory(0); | |
277 | } | |
278 | if(ped.GetHistNclustersVsEventConst()) { | |
279 | fHistNclustersVsEvent = new TH1F(*ped.GetHistNclustersVsEventConst()); | |
280 | fHistNclustersVsEvent->SetDirectory(0); | |
281 | } | |
0ffacf98 | 282 | } |
283 | ||
ac940b58 | 284 | //_____________________________________________________________________ |
7d855b04 | 285 | AliTPCdataQA::AliTPCdataQA(const TMap *config) : /*FOLD00*/ |
ac940b58 | 286 | TH1F("TPCRAW","TPCRAW",100,0,100), |
287 | fFirstTimeBin(60), | |
288 | fLastTimeBin(1000), | |
909e332a | 289 | fAdcMin(3), |
290 | fAdcMax(1000), | |
291 | fMinQMax(5.f), | |
292 | fRequireNeighbouringPad(kTRUE), | |
ac940b58 | 293 | fMapping(NULL), |
294 | fPedestal(0), | |
295 | fNoise(0), | |
296 | fNLocalMaxima(0), | |
297 | fMaxCharge(0), | |
298 | fMeanCharge(0), | |
299 | fNoThreshold(0), | |
300 | fNTimeBins(0), | |
301 | fNPads(0), | |
302 | fTimePosition(0), | |
303 | fOverThreshold10(0), | |
304 | fOverThreshold20(0), | |
305 | fOverThreshold30(0), | |
23c9ab21 | 306 | fHistQVsTimeSideA(0), |
307 | fHistQVsTimeSideC(0), | |
308 | fHistQMaxVsTimeSideA(0), | |
309 | fHistQMaxVsTimeSideC(0), | |
ce0175fa | 310 | fHistOccupancyVsEvent(0), |
311 | fHistNclustersVsEvent(0), | |
ac940b58 | 312 | fEventCounter(0), |
313 | fIsAnalysed(kFALSE), | |
ce0175fa | 314 | fMaxEvents(500000), |
315 | fEventsPerBin(1000), | |
316 | fSignalCounter(0), | |
317 | fClusterCounter(0), | |
909e332a | 318 | fActiveChambers(72), |
ac940b58 | 319 | fAllBins(0), |
320 | fAllSigBins(0), | |
321 | fAllNSigBins(0), | |
322 | fRowsMax(0), | |
323 | fPadsMax(0), | |
0ab2a4cc | 324 | fTimeBinsMax(0), |
325 | fIsDQM(kFALSE), | |
326 | fHistOccVsSector(0x0), | |
92ae9768 | 327 | fHistOcc2dVsSector(0x0), |
0ab2a4cc | 328 | fHistQVsSector(0x0), |
329 | fHistQmaxVsSector(0x0), | |
330 | fOccVec(0x0), | |
92ae9768 | 331 | fOccMaxVec(0x0), |
332 | fOccVecFine(0x0), | |
333 | fOccMaxVecFine(0x0) | |
ac940b58 | 334 | { |
7d855b04 | 335 | /// default constructor |
336 | ||
ac940b58 | 337 | if (config->GetValue("FirstTimeBin")) fFirstTimeBin = ((TObjString*)config->GetValue("FirstTimeBin"))->GetString().Atoi(); |
338 | if (config->GetValue("LastTimeBin")) fLastTimeBin = ((TObjString*)config->GetValue("LastTimeBin"))->GetString().Atoi(); | |
339 | if (config->GetValue("AdcMin")) fAdcMin = ((TObjString*)config->GetValue("AdcMin"))->GetString().Atoi(); | |
340 | if (config->GetValue("AdcMax")) fAdcMax = ((TObjString*)config->GetValue("AdcMax"))->GetString().Atoi(); | |
909e332a | 341 | if (config->GetValue("MinQMax")) fMinQMax = ((TObjString*)config->GetValue("MinQMax"))->GetString().Atof(); |
ce0175fa | 342 | if (config->GetValue("MaxEvents")) fMaxEvents = ((TObjString*)config->GetValue("MaxEvents"))->GetString().Atoi(); |
1267cf3a | 343 | if (config->GetValue("EventsPerBin")) fEventsPerBin = ((TObjString*)config->GetValue("EventsPerBin"))->GetString().Atoi(); |
909e332a | 344 | if (config->GetValue("RequireNeighbouringPad")) fRequireNeighbouringPad = ((TObjString*)config->GetValue("RequireNeighbouringPad"))->GetString().Atoi(); |
345 | for (Int_t i=0; i<72; ++i) {fActiveChambers.SetBitNumber(i,kTRUE);} | |
ac940b58 | 346 | } |
0ffacf98 | 347 | |
348 | //_____________________________________________________________________ | |
349 | AliTPCdataQA& AliTPCdataQA::operator = (const AliTPCdataQA &source) | |
350 | { | |
7d855b04 | 351 | /// assignment operator |
352 | ||
0ffacf98 | 353 | if (&source == this) return *this; |
354 | new (this) AliTPCdataQA(source); | |
355 | ||
356 | return *this; | |
357 | } | |
358 | ||
359 | ||
360 | //_____________________________________________________________________ | |
361 | AliTPCdataQA::~AliTPCdataQA() /*FOLD00*/ | |
362 | { | |
7d855b04 | 363 | /// destructor |
0ffacf98 | 364 | |
365 | // do not delete fMapping, because we do not own it. | |
266f8637 | 366 | // do not delete fMapping, because we do not own it. |
367 | // do not delete fNoise and fPedestal, because we do not own them. | |
368 | ||
369 | delete fNLocalMaxima; | |
370 | delete fMaxCharge; | |
371 | delete fMeanCharge; | |
372 | delete fNoThreshold; | |
373 | delete fNTimeBins; | |
374 | delete fNPads; | |
375 | delete fTimePosition; | |
376 | delete fOverThreshold10; | |
377 | delete fOverThreshold20; | |
378 | delete fOverThreshold30; | |
23c9ab21 | 379 | delete fHistQVsTimeSideA; |
380 | delete fHistQVsTimeSideC; | |
381 | delete fHistQMaxVsTimeSideA; | |
382 | delete fHistQMaxVsTimeSideC; | |
ce0175fa | 383 | delete fHistOccupancyVsEvent; |
384 | delete fHistNclustersVsEvent; | |
266f8637 | 385 | |
0ab2a4cc | 386 | // DQM |
387 | delete fHistOccVsSector; | |
92ae9768 | 388 | delete fHistOcc2dVsSector; |
0ab2a4cc | 389 | delete fHistQVsSector; |
390 | delete fHistQmaxVsSector; | |
391 | delete fOccVec; | |
392 | delete fOccMaxVec; | |
92ae9768 | 393 | delete fOccVecFine; |
394 | delete fOccMaxVecFine; | |
7d855b04 | 395 | |
266f8637 | 396 | for (Int_t iRow = 0; iRow < fRowsMax; iRow++) { |
397 | delete [] fAllBins[iRow]; | |
398 | delete [] fAllSigBins[iRow]; | |
7d855b04 | 399 | } |
266f8637 | 400 | delete [] fAllBins; |
401 | delete [] fAllSigBins; | |
402 | delete [] fAllNSigBins; | |
0ffacf98 | 403 | } |
ce0175fa | 404 | |
405 | //_____________________________________________________________________ | |
406 | TH1F* AliTPCdataQA::GetHistOccupancyVsEvent() | |
407 | { | |
7d855b04 | 408 | /// Create Occupancy vs event histogram |
409 | /// (we create this histogram differently then the other histograms | |
410 | /// because this we want to be able to access and copy | |
411 | /// from AliTPCQAMakerRec before it normally would be created) | |
412 | ||
ce0175fa | 413 | if(!fHistOccupancyVsEvent) { |
414 | ||
415 | Int_t nBins = fMaxEvents/fEventsPerBin; | |
416 | fHistOccupancyVsEvent = new TH1F("hOccupancyVsEvent", "Occupancy vs event number (~time); Event number; Occupancy", nBins, 0, nBins*fEventsPerBin); | |
417 | fHistOccupancyVsEvent->SetDirectory(0); | |
ce0175fa | 418 | } |
7d855b04 | 419 | |
ce0175fa | 420 | return fHistOccupancyVsEvent; |
421 | } | |
422 | ||
423 | //_____________________________________________________________________ | |
424 | TH1F* AliTPCdataQA::GetHistNclustersVsEvent() | |
425 | { | |
7d855b04 | 426 | /// Create Nclusters vs event histogram |
427 | /// (we create this histogram differently then the other histograms | |
428 | /// because this we want to be able to access and copy | |
429 | /// from AliTPCQAMakerRec before it normally would be created) | |
430 | ||
ce0175fa | 431 | if(!fHistNclustersVsEvent) { |
432 | ||
433 | Int_t nBins = fMaxEvents/fEventsPerBin; | |
434 | fHistNclustersVsEvent = new TH1F("hNclustersVsEvent", "Nclusters vs event number (~time); Event number; Nclusters per event", nBins, 0, nBins*fEventsPerBin); | |
435 | fHistNclustersVsEvent->SetDirectory(0); | |
ce0175fa | 436 | } |
7d855b04 | 437 | |
ce0175fa | 438 | return fHistNclustersVsEvent; |
439 | } | |
440 | ||
441 | //_____________________________________________________________________ | |
442 | void AliTPCdataQA::UpdateEventHistograms() | |
443 | { | |
7d855b04 | 444 | /// Update histograms that display occupancy and |
445 | /// number of clusters as a function of number of | |
446 | /// events | |
447 | ||
ce0175fa | 448 | if (!fHistOccupancyVsEvent) |
449 | GetHistOccupancyVsEvent(); | |
450 | if (!fHistNclustersVsEvent) | |
451 | GetHistNclustersVsEvent(); | |
7d855b04 | 452 | |
1267cf3a | 453 | if(fEventCounter > fMaxEvents) { |
7d855b04 | 454 | |
1267cf3a | 455 | // we have to expand the histogram to handle the larger number of |
456 | // events. The way it is done now is to double the range and the | |
457 | // number of events per bin (so the number of histogram bins stays | |
458 | // constant) | |
459 | fEventsPerBin *= 2; | |
460 | fMaxEvents *= 2; | |
461 | ||
462 | // Change histogram limits | |
463 | const Int_t nBins = fHistOccupancyVsEvent->GetXaxis()->GetNbins(); | |
464 | fHistOccupancyVsEvent->GetXaxis()->Set(nBins, fHistOccupancyVsEvent->GetXaxis()->GetNbins(), fMaxEvents); | |
465 | fHistNclustersVsEvent->GetXaxis()->Set(nBins, fHistNclustersVsEvent->GetXaxis()->GetNbins(), fMaxEvents); | |
466 | ||
467 | // Rebin the histogram | |
468 | for(Int_t bin = 1; bin <= nBins; bin+=2) { | |
469 | ||
470 | Int_t newBin = TMath::Nint(Float_t(bin+1)/2.0); | |
471 | Float_t newContent = (fHistOccupancyVsEvent->GetBinContent(bin)+ | |
472 | fHistOccupancyVsEvent->GetBinContent(bin+1))/2.0; | |
7d855b04 | 473 | fHistOccupancyVsEvent->SetBinContent(newBin, newContent); |
1267cf3a | 474 | |
475 | newContent = (fHistNclustersVsEvent->GetBinContent(bin)+ | |
476 | fHistNclustersVsEvent->GetBinContent(bin+1))/2.0; | |
7d855b04 | 477 | fHistNclustersVsEvent->SetBinContent(newBin, newContent); |
1267cf3a | 478 | } |
479 | ||
480 | // Set the remaining bins to 0 | |
481 | Int_t lastHalf = nBins/2 +1; | |
482 | for(Int_t bin = lastHalf; bin <= nBins; bin++) { | |
483 | ||
7d855b04 | 484 | fHistOccupancyVsEvent->SetBinContent(bin, 0); |
485 | fHistNclustersVsEvent->SetBinContent(bin, 0); | |
1267cf3a | 486 | } |
487 | ||
488 | // In this case we should nut update but wait untill the new | |
489 | // number of events per bin is reached! | |
490 | return; | |
491 | } | |
492 | ||
493 | const Int_t bin = TMath::Nint(Float_t(fEventCounter)/fEventsPerBin); | |
494 | ||
ce0175fa | 495 | Float_t averageOccupancy = |
496 | Float_t(fSignalCounter)/fEventsPerBin/(fLastTimeBin - fFirstTimeBin +1.0) | |
1267cf3a | 497 | / 570132.0; // 570,132 is number of pads |
498 | fHistOccupancyVsEvent->SetBinContent(bin, averageOccupancy); | |
ce0175fa | 499 | fSignalCounter = 0; |
7d855b04 | 500 | |
ce0175fa | 501 | Float_t averageNclusters = |
502 | Float_t(fClusterCounter)/fEventsPerBin; | |
1267cf3a | 503 | fHistNclustersVsEvent->SetBinContent(bin, averageNclusters); |
ce0175fa | 504 | fClusterCounter = 0; |
505 | } | |
506 | ||
0c25417d | 507 | //_____________________________________________________________________ |
6a50ff96 | 508 | Bool_t AliTPCdataQA::ProcessEvent(AliTPCRawStreamV3 *const rawStreamV3) |
0c25417d | 509 | { |
7d855b04 | 510 | /// Event Processing loop - AliTPCRawStreamV3 |
511 | ||
0c25417d | 512 | Bool_t withInput = kFALSE; |
513 | Int_t nSignals = 0; | |
514 | Int_t lastSector = -1; | |
909e332a | 515 | |
516 | Init(); | |
7d855b04 | 517 | |
0c25417d | 518 | while ( rawStreamV3->NextDDL() ){ |
1267cf3a | 519 | |
0c25417d | 520 | while ( rawStreamV3->NextChannel() ){ |
7d855b04 | 521 | |
0c25417d | 522 | Int_t iSector = rawStreamV3->GetSector(); // current sector |
523 | Int_t iRow = rawStreamV3->GetRow(); // current row | |
524 | Int_t iPad = rawStreamV3->GetPad(); // current pad | |
92ae9768 | 525 | Int_t iPatch = rawStreamV3->GetPatchIndex(); // current patch |
526 | Int_t iBranch = rawStreamV3->GetBranch(); // current branch | |
0c25417d | 527 | if (iRow<0 || iPad<0) continue; |
528 | // Call local maxima finder if the data is in a new sector | |
529 | if(iSector != lastSector) { | |
7d855b04 | 530 | |
0c25417d | 531 | if(nSignals>0) |
532 | FindLocalMaxima(lastSector); | |
7d855b04 | 533 | |
0c25417d | 534 | CleanArrays(); |
535 | lastSector = iSector; | |
536 | nSignals = 0; | |
537 | } | |
7d855b04 | 538 | |
0c25417d | 539 | while ( rawStreamV3->NextBunch() ){ |
1267cf3a | 540 | |
0c25417d | 541 | Int_t startTbin = (Int_t)rawStreamV3->GetStartTimeBin(); |
542 | Int_t bunchlength = (Int_t)rawStreamV3->GetBunchLength(); | |
543 | const UShort_t *sig = rawStreamV3->GetSignals(); | |
7d855b04 | 544 | |
0c25417d | 545 | for (Int_t iTimeBin = 0; iTimeBin<bunchlength; iTimeBin++){ |
546 | Float_t signal=(Float_t)sig[iTimeBin]; | |
92ae9768 | 547 | nSignals += Update(iSector,iRow,iPad,startTbin--,signal, iPatch, iBranch); |
0c25417d | 548 | withInput = kTRUE; |
549 | } | |
550 | } | |
551 | } | |
552 | } | |
7d855b04 | 553 | |
554 | if (lastSector>=0&&nSignals>0) | |
0c25417d | 555 | FindLocalMaxima(lastSector); |
909e332a | 556 | |
557 | CleanArrays(); | |
7d855b04 | 558 | |
0c25417d | 559 | return withInput; |
560 | } | |
561 | ||
562 | //_____________________________________________________________________ | |
6a50ff96 | 563 | Bool_t AliTPCdataQA::ProcessEvent(AliRawReader *const rawReader) |
0c25417d | 564 | { |
7d855b04 | 565 | /// Event processing loop - AliRawReader |
566 | ||
92ae9768 | 567 | AliTPCRawStreamV3 rawStreamV3(rawReader,(AliAltroMapping**)fMapping); |
c75ba816 | 568 | Bool_t res=ProcessEvent(&rawStreamV3); |
ce0175fa | 569 | if(res) { |
0c25417d | 570 | fEventCounter++; // only increment event counter if there is TPC data |
ce0175fa | 571 | |
7d855b04 | 572 | if(fEventCounter%fEventsPerBin==0) |
ce0175fa | 573 | UpdateEventHistograms(); |
574 | } | |
0c25417d | 575 | return res; |
576 | } | |
0ffacf98 | 577 | |
0ffacf98 | 578 | //_____________________________________________________________________ |
6a50ff96 | 579 | Bool_t AliTPCdataQA::ProcessEvent(eventHeaderStruct *const event) |
0ffacf98 | 580 | { |
7d855b04 | 581 | /// process date event |
0ffacf98 | 582 | |
c75ba816 | 583 | AliRawReaderDate rawReader((void*)event); |
584 | Bool_t result=ProcessEvent(&rawReader); | |
0ffacf98 | 585 | return result; |
586 | } | |
587 | ||
588 | ||
589 | ||
590 | //_____________________________________________________________________ | |
591 | void AliTPCdataQA::DumpToFile(const Char_t *filename, const Char_t *dir, Bool_t append) /*FOLD00*/ | |
592 | { | |
7d855b04 | 593 | /// Write class to file |
0ffacf98 | 594 | |
595 | TString sDir(dir); | |
596 | TString option; | |
597 | ||
598 | if ( append ) | |
599 | option = "update"; | |
600 | else | |
601 | option = "recreate"; | |
602 | ||
603 | TDirectory *backup = gDirectory; | |
604 | TFile f(filename,option.Data()); | |
605 | f.cd(); | |
606 | if ( !sDir.IsNull() ){ | |
607 | f.mkdir(sDir.Data()); | |
608 | f.cd(sDir); | |
609 | } | |
610 | this->Write(); | |
611 | f.Close(); | |
612 | ||
613 | if ( backup ) backup->cd(); | |
614 | } | |
615 | ||
616 | ||
617 | //_____________________________________________________________________ | |
266f8637 | 618 | Int_t AliTPCdataQA::Update(const Int_t iSector, /*FOLD00*/ |
619 | const Int_t iRow, | |
620 | const Int_t iPad, | |
621 | const Int_t iTimeBin, | |
92ae9768 | 622 | Float_t signal, |
623 | const Int_t iPatch, | |
624 | const Int_t iBranch) | |
0ffacf98 | 625 | { |
7d855b04 | 626 | /// Signal filling method |
627 | ||
909e332a | 628 | if (!fActiveChambers[iSector]) return 0; |
266f8637 | 629 | // |
630 | // TimeBin cut | |
631 | // | |
632 | if (iTimeBin<fFirstTimeBin) return 0; | |
633 | if (iTimeBin>fLastTimeBin) return 0; | |
7d855b04 | 634 | |
f11b3071 | 635 | // if pedestal calibrations are loaded subtract pedestals |
636 | if(fPedestal) { | |
637 | ||
266f8637 | 638 | Float_t ped = fPedestal->GetCalROC(iSector)->GetValue(iRow, iPad); |
639 | // Don't use data from pads where pedestals are abnormally small or large | |
640 | if(ped<10 || ped>90) | |
f11b3071 | 641 | return 0; |
266f8637 | 642 | signal -= ped; |
f11b3071 | 643 | } |
7d855b04 | 644 | |
0ab2a4cc | 645 | if(fIsDQM) { |
646 | ||
647 | fOccVec->GetArray()[iSector] += 1.0; | |
92ae9768 | 648 | // To change before committing |
649 | if(iPatch>=0 && iBranch>=0 && iPatch<=5 && iBranch <= 1) | |
650 | fOccVecFine->GetArray()[(iSector%36)*12+iPatch*2+iBranch] += 1.0; | |
0ab2a4cc | 651 | } else { |
652 | // In fNoThreshold we fill all data to estimate the ZS volume | |
653 | Float_t count = fNoThreshold->GetCalROC(iSector)->GetValue(iRow, iPad); | |
654 | fNoThreshold->GetCalROC(iSector)->SetValue(iRow, iPad,count+1); | |
655 | } | |
656 | ||
f11b3071 | 657 | // Require at least 3 ADC channels |
909e332a | 658 | if (signal < fAdcMin) |
f11b3071 | 659 | return 0; |
660 | ||
661 | // if noise calibrations are loaded require at least 3*sigmaNoise | |
662 | if(fNoise) { | |
7d855b04 | 663 | |
266f8637 | 664 | Float_t noise = fNoise->GetCalROC(iSector)->GetValue(iRow, iPad); |
7d855b04 | 665 | |
266f8637 | 666 | if(signal < noise*3.0) |
f11b3071 | 667 | return 0; |
668 | } | |
266f8637 | 669 | |
f11b3071 | 670 | // |
266f8637 | 671 | // This signal is ok and we store it in the cluster map |
0ffacf98 | 672 | // |
f11b3071 | 673 | |
266f8637 | 674 | SetExpandDigit(iRow, iPad, iTimeBin, signal); |
ce0175fa | 675 | |
676 | fSignalCounter++; | |
7d855b04 | 677 | |
266f8637 | 678 | return 1; // signal was accepted |
f11b3071 | 679 | } |
266f8637 | 680 | |
f11b3071 | 681 | //_____________________________________________________________________ |
266f8637 | 682 | void AliTPCdataQA::FindLocalMaxima(const Int_t iSector) |
f11b3071 | 683 | { |
7d855b04 | 684 | /// This method is called after the data from each sector has been |
685 | /// exapanded into an array | |
686 | /// Loop over the signals and identify local maxima and fill the | |
687 | /// calibration objects with the information | |
266f8637 | 688 | |
909e332a | 689 | if (!fActiveChambers[iSector]) return; |
7d855b04 | 690 | |
266f8637 | 691 | Int_t nLocalMaxima = 0; |
7d855b04 | 692 | const Int_t maxTimeBin = fTimeBinsMax+4; // Used to step between neighboring pads |
693 | // Because we have tha pad-time data in a | |
266f8637 | 694 | // 1d array |
695 | ||
696 | for (Int_t iRow = 0; iRow < fRowsMax; iRow++) { | |
697 | ||
698 | Float_t* allBins = fAllBins[iRow]; | |
699 | Int_t* sigBins = fAllSigBins[iRow]; | |
700 | const Int_t nSigBins = fAllNSigBins[iRow]; | |
7d855b04 | 701 | |
266f8637 | 702 | for (Int_t iSig = 0; iSig < nSigBins; iSig++) { |
703 | ||
704 | Int_t bin = sigBins[iSig]; | |
705 | Float_t *b = &allBins[bin]; | |
706 | ||
707 | // | |
708 | // Now we check if this is a local maximum | |
709 | // | |
710 | ||
711 | Float_t qMax = b[0]; | |
712 | ||
713 | // First check that the charge is bigger than the threshold | |
7d855b04 | 714 | if (qMax<fMinQMax) |
266f8637 | 715 | continue; |
7d855b04 | 716 | |
266f8637 | 717 | // Require at least one neighboring pad with signal |
909e332a | 718 | if (fRequireNeighbouringPad && (b[-maxTimeBin]+b[maxTimeBin]<=0) ) continue; |
266f8637 | 719 | |
720 | // Require at least one neighboring time bin with signal | |
721 | if (b[-1]+b[1]<=0) continue; | |
7d855b04 | 722 | |
266f8637 | 723 | // |
724 | // Check that this is a local maximum | |
725 | // Note that the checking is done so that if 2 charges has the same | |
7d855b04 | 726 | // qMax then only 1 cluster is generated |
266f8637 | 727 | // (that is why there is BOTH > and >=) |
728 | // | |
729 | if (b[-maxTimeBin] >= qMax) continue; | |
7d855b04 | 730 | if (b[-1 ] >= qMax) continue; |
731 | if (b[+maxTimeBin] > qMax) continue; | |
732 | if (b[+1 ] > qMax) continue; | |
266f8637 | 733 | if (b[-maxTimeBin-1] >= qMax) continue; |
7d855b04 | 734 | if (b[+maxTimeBin-1] >= qMax) continue; |
735 | if (b[+maxTimeBin+1] > qMax) continue; | |
266f8637 | 736 | if (b[-maxTimeBin+1] >= qMax) continue; |
7d855b04 | 737 | |
266f8637 | 738 | // |
739 | // Now we accept the local maximum and fill the calibration/data objects | |
740 | // | |
909e332a | 741 | ++nLocalMaxima; |
266f8637 | 742 | |
743 | Int_t iPad, iTimeBin; | |
744 | GetPadAndTimeBin(bin, iPad, iTimeBin); | |
7d855b04 | 745 | |
0ab2a4cc | 746 | if(!fIsDQM) { |
747 | Float_t count = fNLocalMaxima->GetCalROC(iSector)->GetValue(iRow, iPad); | |
748 | fNLocalMaxima->GetCalROC(iSector)->SetValue(iRow, iPad, count+1); | |
7d855b04 | 749 | |
0ab2a4cc | 750 | count = fTimePosition->GetCalROC(iSector)->GetValue(iRow, iPad); |
751 | fTimePosition->GetCalROC(iSector)->SetValue(iRow, iPad, count+iTimeBin); | |
7d855b04 | 752 | |
0ab2a4cc | 753 | Float_t charge = fMaxCharge->GetCalROC(iSector)->GetValue(iRow, iPad); |
754 | fMaxCharge->GetCalROC(iSector)->SetValue(iRow, iPad, charge + qMax); | |
7d855b04 | 755 | |
0ab2a4cc | 756 | if(qMax>=10) { |
757 | count = fOverThreshold10->GetCalROC(iSector)->GetValue(iRow, iPad); | |
758 | fOverThreshold10->GetCalROC(iSector)->SetValue(iRow, iPad, count+1); | |
759 | } | |
760 | if(qMax>=20) { | |
761 | count = fOverThreshold20->GetCalROC(iSector)->GetValue(iRow, iPad); | |
762 | fOverThreshold20->GetCalROC(iSector)->SetValue(iRow, iPad, count+1); | |
763 | } | |
764 | if(qMax>=30) { | |
765 | count = fOverThreshold30->GetCalROC(iSector)->GetValue(iRow, iPad); | |
766 | fOverThreshold30->GetCalROC(iSector)->SetValue(iRow, iPad, count+1); | |
767 | } | |
266f8637 | 768 | } |
769 | ||
770 | // | |
771 | // Calculate the total charge as the sum over the region: | |
772 | // | |
773 | // o o o o o | |
774 | // o i i i o | |
775 | // o i C i o | |
776 | // o i i i o | |
777 | // o o o o o | |
778 | // | |
779 | // with qmax at the center C. | |
780 | // | |
781 | // The inner charge (i) we always add, but we only add the outer | |
782 | // charge (o) if the neighboring inner bin (i) has a signal. | |
783 | // | |
784 | Int_t minP = 0, maxP = 0, minT = 0, maxT = 0; | |
785 | Float_t qTot = qMax; | |
786 | for(Int_t i = -1; i<=1; i++) { | |
787 | for(Int_t j = -1; j<=1; j++) { | |
7d855b04 | 788 | |
266f8637 | 789 | if(i==0 && j==0) |
790 | continue; | |
7d855b04 | 791 | |
77f88633 | 792 | Float_t charge1 = GetQ(b, i, j, maxTimeBin, minT, maxT, minP, maxP); |
793 | qTot += charge1; | |
794 | if(charge1>0) { | |
266f8637 | 795 | // see if the next neighbor is also above threshold |
796 | if(i*j==0) { | |
7d855b04 | 797 | qTot += GetQ(b, 2*i, 2*j, maxTimeBin, minT, maxT, minP, maxP); |
266f8637 | 798 | } else { |
799 | // we are in a diagonal corner | |
7d855b04 | 800 | qTot += GetQ(b, i, 2*j, maxTimeBin, minT, maxT, minP, maxP); |
801 | qTot += GetQ(b, 2*i, j, maxTimeBin, minT, maxT, minP, maxP); | |
802 | qTot += GetQ(b, 2*i, 2*j, maxTimeBin, minT, maxT, minP, maxP); | |
266f8637 | 803 | } |
804 | } | |
805 | } | |
806 | } | |
7d855b04 | 807 | |
0ab2a4cc | 808 | if(fIsDQM) { |
809 | fHistQVsSector->Fill(iSector, qTot); | |
810 | fHistQmaxVsSector->Fill(iSector, qMax); | |
23c9ab21 | 811 | } else { |
0ab2a4cc | 812 | Float_t charge = fMeanCharge->GetCalROC(iSector)->GetValue(iRow, iPad); |
813 | fMeanCharge->GetCalROC(iSector)->SetValue(iRow, iPad, charge + qTot); | |
7d855b04 | 814 | |
0ab2a4cc | 815 | Float_t count = fNTimeBins->GetCalROC(iSector)->GetValue(iRow, iPad); |
816 | fNTimeBins->GetCalROC(iSector)->SetValue(iRow, iPad, count + maxT-minT+1); | |
7d855b04 | 817 | |
0ab2a4cc | 818 | count = fNPads->GetCalROC(iSector)->GetValue(iRow, iPad); |
819 | fNPads->GetCalROC(iSector)->SetValue(iRow, iPad, count + maxP-minP+1); | |
7d855b04 | 820 | |
0ab2a4cc | 821 | if((iSector%36)<18) { // A side |
822 | fHistQVsTimeSideA->Fill(iTimeBin, qTot); | |
823 | fHistQMaxVsTimeSideA->Fill(iTimeBin, qMax); | |
824 | } else { | |
825 | fHistQVsTimeSideC->Fill(iTimeBin, qTot); | |
7d855b04 | 826 | fHistQMaxVsTimeSideC->Fill(iTimeBin, qMax); |
0ab2a4cc | 827 | } |
23c9ab21 | 828 | } |
266f8637 | 829 | } // end loop over signals |
830 | } // end loop over rows | |
7d855b04 | 831 | |
ce0175fa | 832 | fClusterCounter += nLocalMaxima; |
0ffacf98 | 833 | } |
11ccf1c1 | 834 | |
f11b3071 | 835 | //_____________________________________________________________________ |
836 | void AliTPCdataQA::Analyse() | |
837 | { | |
7d855b04 | 838 | /// Calculate calibration constants |
839 | ||
1267cf3a | 840 | AliInfo("Analyse called"); |
f11b3071 | 841 | |
0ab2a4cc | 842 | if(fIsDQM == kTRUE) { |
7d855b04 | 843 | |
0ab2a4cc | 844 | AliInfo("DQM flas is set -> No 2d information to analyze"); |
845 | return; | |
846 | } | |
847 | ||
266f8637 | 848 | if(fIsAnalysed == kTRUE) { |
7d855b04 | 849 | |
1267cf3a | 850 | AliInfo("No new data since Analyse was called last time"); |
266f8637 | 851 | return; |
852 | } | |
f11b3071 | 853 | |
266f8637 | 854 | if(fEventCounter==0) { |
7d855b04 | 855 | |
1267cf3a | 856 | AliInfo("EventCounter == 0, Cannot analyse"); |
f11b3071 | 857 | return; |
858 | } | |
7d855b04 | 859 | |
f11b3071 | 860 | Int_t nTimeBins = fLastTimeBin - fFirstTimeBin +1; |
1267cf3a | 861 | AliInfo(Form("EventCounter: %d , TimeBins: %d", fEventCounter, nTimeBins)); |
f11b3071 | 862 | |
f11b3071 | 863 | Float_t normalization = 1.0 / Float_t(fEventCounter * nTimeBins); |
7d855b04 | 864 | fNoThreshold->Multiply(normalization); |
865 | ||
266f8637 | 866 | fMeanCharge->Divide(fNLocalMaxima); |
867 | fMaxCharge->Divide(fNLocalMaxima); | |
868 | fNTimeBins->Divide(fNLocalMaxima); | |
869 | fNPads->Divide(fNLocalMaxima); | |
870 | fTimePosition->Divide(fNLocalMaxima); | |
871 | ||
872 | fIsAnalysed = kTRUE; | |
11ccf1c1 | 873 | } |
258cd111 | 874 | |
875 | ||
266f8637 | 876 | //_____________________________________________________________________ |
6a50ff96 | 877 | void AliTPCdataQA::MakeTree(const char *fname) const { |
7d855b04 | 878 | /// Export result to the tree -located in the file |
879 | /// This file can be analyzed using AliTPCCalibViewer | |
880 | ||
258cd111 | 881 | AliTPCPreprocessorOnline preprocesor; |
266f8637 | 882 | |
883 | if (fNLocalMaxima) preprocesor.AddComponent(fNLocalMaxima); | |
7d855b04 | 884 | if (fMaxCharge) preprocesor.AddComponent(fMaxCharge); |
885 | if (fMeanCharge) preprocesor.AddComponent(fMeanCharge); | |
266f8637 | 886 | if (fNoThreshold) preprocesor.AddComponent(fNoThreshold); |
887 | if (fNTimeBins) preprocesor.AddComponent(fNTimeBins); | |
888 | if (fNPads) preprocesor.AddComponent(fNPads); | |
889 | if (fTimePosition) preprocesor.AddComponent(fTimePosition); | |
890 | if (fOverThreshold10) preprocesor.AddComponent(fOverThreshold10); | |
891 | if (fOverThreshold20) preprocesor.AddComponent(fOverThreshold20); | |
892 | if (fOverThreshold30) preprocesor.AddComponent(fOverThreshold30); | |
893 | ||
7d855b04 | 894 | preprocesor.DumpToFile(fname); |
258cd111 | 895 | } |
c322f08a | 896 | |
897 | ||
266f8637 | 898 | //_____________________________________________________________________ |
c322f08a | 899 | void AliTPCdataQA::MakeArrays(){ |
7d855b04 | 900 | /// The arrays for expanding the raw data are defined and |
901 | /// som parameters are intialised | |
902 | ||
c322f08a | 903 | AliTPCROC * roc = AliTPCROC::Instance(); |
904 | // | |
7d855b04 | 905 | // To make the array big enough for all sectors we take |
266f8637 | 906 | // the dimensions from the outer row of an OROC (the last sector) |
907 | // | |
908 | fRowsMax = roc->GetNRows(roc->GetNSector()-1); | |
909 | fPadsMax = roc->GetNPads(roc->GetNSector()-1,fRowsMax-1); | |
7d855b04 | 910 | fTimeBinsMax = fLastTimeBin - fFirstTimeBin +1; |
266f8637 | 911 | |
912 | // | |
7d855b04 | 913 | // Since we have added 2 pads (TimeBins) before and after the real pads (TimeBins) |
914 | // to make sure that we can always query the exanded table even when the | |
266f8637 | 915 | // max is on the edge |
916 | // | |
917 | ||
7d855b04 | 918 | |
266f8637 | 919 | fAllBins = new Float_t*[fRowsMax]; |
920 | fAllSigBins = new Int_t*[fRowsMax]; | |
921 | fAllNSigBins = new Int_t[fRowsMax]; | |
922 | ||
923 | for (Int_t iRow = 0; iRow < fRowsMax; iRow++) { | |
c322f08a | 924 | // |
7d855b04 | 925 | Int_t maxBin = (fTimeBinsMax+4)*(fPadsMax+4); |
c322f08a | 926 | fAllBins[iRow] = new Float_t[maxBin]; |
266f8637 | 927 | memset(fAllBins[iRow],0,sizeof(Float_t)*maxBin); // set all values to 0 |
c322f08a | 928 | fAllSigBins[iRow] = new Int_t[maxBin]; |
266f8637 | 929 | fAllNSigBins[iRow] = 0; |
c322f08a | 930 | } |
931 | } | |
932 | ||
933 | ||
266f8637 | 934 | //_____________________________________________________________________ |
c322f08a | 935 | void AliTPCdataQA::CleanArrays(){ |
7d855b04 | 936 | /// |
266f8637 | 937 | |
938 | for (Int_t iRow = 0; iRow < fRowsMax; iRow++) { | |
42919b08 | 939 | |
940 | // To speed up the performance by a factor 2 on cosmic data (and | |
941 | // presumably pp data as well) where the ocupancy is low, the | |
942 | // memset is only called if there is more than 1000 signals for a | |
943 | // row (of the order 1% occupancy) | |
944 | if(fAllNSigBins[iRow]<1000) { | |
7d855b04 | 945 | |
42919b08 | 946 | Float_t* allBins = fAllBins[iRow]; |
947 | Int_t* sigBins = fAllSigBins[iRow]; | |
948 | const Int_t nSignals = fAllNSigBins[iRow]; | |
949 | for(Int_t i = 0; i < nSignals; i++) | |
7d855b04 | 950 | allBins[sigBins[i]]=0; |
42919b08 | 951 | } else { |
23c9ab21 | 952 | |
7d855b04 | 953 | Int_t maxBin = (fTimeBinsMax+4)*(fPadsMax+4); |
42919b08 | 954 | memset(fAllBins[iRow],0,sizeof(Float_t)*maxBin); |
955 | } | |
956 | ||
c322f08a | 957 | fAllNSigBins[iRow]=0; |
958 | } | |
959 | } | |
960 | ||
266f8637 | 961 | //_____________________________________________________________________ |
962 | void AliTPCdataQA::GetPadAndTimeBin(Int_t bin, Int_t& iPad, Int_t& iTimeBin){ | |
7d855b04 | 963 | /// Return pad and timebin for a given bin |
964 | ||
266f8637 | 965 | // Int_t bin = iPad*(fTimeBinsMax+4)+iTimeBin; |
966 | iTimeBin = bin%(fTimeBinsMax+4); | |
967 | iPad = (bin-iTimeBin)/(fTimeBinsMax+4); | |
968 | ||
969 | iPad -= 2; | |
970 | iTimeBin -= 2; | |
971 | iTimeBin += fFirstTimeBin; | |
972 | ||
973 | R__ASSERT(iPad>=0 && iPad<=fPadsMax); | |
974 | R__ASSERT(iTimeBin>=fFirstTimeBin && iTimeBin<=fLastTimeBin); | |
975 | } | |
976 | ||
977 | //_____________________________________________________________________ | |
7d855b04 | 978 | void AliTPCdataQA::SetExpandDigit(const Int_t iRow, Int_t iPad, |
979 | Int_t iTimeBin, const Float_t signal) | |
266f8637 | 980 | { |
7d855b04 | 981 | /// |
982 | ||
266f8637 | 983 | R__ASSERT(iRow>=0 && iRow<fRowsMax); |
984 | R__ASSERT(iPad>=0 && iPad<=fPadsMax); | |
985 | R__ASSERT(iTimeBin>=fFirstTimeBin && iTimeBin<=fLastTimeBin); | |
7d855b04 | 986 | |
266f8637 | 987 | iTimeBin -= fFirstTimeBin; |
988 | iPad += 2; | |
989 | iTimeBin += 2; | |
7d855b04 | 990 | |
266f8637 | 991 | Int_t bin = iPad*(fTimeBinsMax+4)+iTimeBin; |
992 | fAllBins[iRow][bin] = signal; | |
993 | fAllSigBins[iRow][fAllNSigBins[iRow]] = bin; | |
994 | fAllNSigBins[iRow]++; | |
995 | } | |
996 | ||
0ab2a4cc | 997 | //______________________________________________________________________________ |
7d855b04 | 998 | Float_t AliTPCdataQA::GetQ(const Float_t* adcArray, const Int_t time, |
999 | const Int_t pad, const Int_t maxTimeBins, | |
1000 | Int_t& timeMin, Int_t& timeMax, | |
6a50ff96 | 1001 | Int_t& padMin, Int_t& padMax) const |
266f8637 | 1002 | { |
7d855b04 | 1003 | /// This methods return the charge in the bin time+pad*maxTimeBins |
1004 | /// If the charge is above 0 it also updates the padMin, padMax, timeMin | |
1005 | /// and timeMax if necessary | |
1006 | ||
266f8637 | 1007 | Float_t charge = adcArray[time + pad*maxTimeBins]; |
1008 | if(charge > 0) { | |
1009 | timeMin = TMath::Min(time, timeMin); timeMax = TMath::Max(time, timeMax); | |
1010 | padMin = TMath::Min(pad, padMin); padMax = TMath::Max(pad, padMax); | |
1011 | } | |
7d855b04 | 1012 | return charge; |
c322f08a | 1013 | } |
ce4b4255 | 1014 | |
1015 | //______________________________________________________________________________ | |
6a50ff96 | 1016 | void AliTPCdataQA::Streamer(TBuffer &xRuub) |
ce4b4255 | 1017 | { |
7d855b04 | 1018 | /// Automatic schema evolution was first used from revision 4 |
1019 | /// Code based on: | |
1020 | /// http://root.cern.ch/root/roottalk/roottalk02/3207.html | |
ce4b4255 | 1021 | |
6a50ff96 | 1022 | UInt_t xRuus, xRuuc; |
1023 | if (xRuub.IsReading()) { | |
1024 | Version_t xRuuv = xRuub.ReadVersion(&xRuus, &xRuuc); | |
ce4b4255 | 1025 | //we use the automatic algorithm for class version > 3 |
6a50ff96 | 1026 | if (xRuuv > 3) { |
1027 | AliTPCdataQA::Class()->ReadBuffer(xRuub, this, xRuuv, xRuus, | |
1028 | xRuuc); | |
ce4b4255 | 1029 | return; |
1030 | } | |
6a50ff96 | 1031 | TH1F::Streamer(xRuub); |
1032 | xRuub >> fFirstTimeBin; | |
1033 | xRuub >> fLastTimeBin; | |
1034 | xRuub >> fAdcMin; | |
1035 | xRuub >> fAdcMax; | |
1036 | xRuub >> fNLocalMaxima; | |
1037 | xRuub >> fMaxCharge; | |
1038 | xRuub >> fMeanCharge; | |
1039 | xRuub >> fNoThreshold; | |
1040 | xRuub >> fNTimeBins; | |
1041 | xRuub >> fNPads; | |
1042 | xRuub >> fTimePosition; | |
1043 | xRuub >> fEventCounter; | |
1044 | xRuub >> fIsAnalysed; | |
1045 | xRuub.CheckByteCount(xRuus, xRuuc, AliTPCdataQA::IsA()); | |
ce4b4255 | 1046 | } else { |
6a50ff96 | 1047 | AliTPCdataQA::Class()->WriteBuffer(xRuub,this); |
ce4b4255 | 1048 | } |
1049 | } | |
0ab2a4cc | 1050 | |
1051 | //____________________________________________________________________________________________ | |
1052 | void AliTPCdataQA::FillOccupancyProfile() | |
1053 | { | |
7d855b04 | 1054 | /// This has to be filled at the end of the loop over data |
1055 | ||
1056 | if(!fIsDQM) | |
0ab2a4cc | 1057 | AliInfo("Method only meaningful for DQM"); |
7d855b04 | 1058 | |
0ab2a4cc | 1059 | for(Int_t i = 0; i < 72; i++) { |
1060 | ||
1061 | fOccVec->GetArray()[i] /= fOccMaxVec->GetArray()[i]; | |
1062 | fHistOccVsSector->Fill(i, fOccVec->GetArray()[i]); | |
1063 | } | |
92ae9768 | 1064 | |
1065 | const Int_t nBranches = 36*12; | |
1066 | for(Int_t i = 0; i < nBranches; i++) { | |
1067 | ||
1068 | fOccVecFine->GetArray()[i] /= fOccMaxVecFine->GetArray()[i]; | |
1069 | ||
1070 | const Int_t fullSector = Int_t(i/12); | |
1071 | ||
1072 | Int_t branch = i - fullSector*12; | |
1073 | const Int_t patch = Int_t(branch/2); | |
1074 | ||
1075 | branch -= patch*2; | |
1076 | ||
1077 | fHistOcc2dVsSector->Fill(fullSector+0.5*branch+0.1, patch+0.5, fOccVecFine->GetArray()[i]); | |
1078 | } | |
0ab2a4cc | 1079 | } |
1080 | ||
1081 | //____________________________________________________________________________________________ | |
1082 | void AliTPCdataQA::ResetProfiles() | |
1083 | { | |
7d855b04 | 1084 | if(!fIsDQM) |
0ab2a4cc | 1085 | AliInfo("Method only meaningful for DQM"); |
7d855b04 | 1086 | |
0ab2a4cc | 1087 | if(fHistQVsSector) |
1088 | fHistQVsSector->Reset(); | |
1089 | if(fHistQmaxVsSector) | |
1090 | fHistQmaxVsSector->Reset(); | |
1091 | if(fHistOccVsSector) | |
1092 | fHistOccVsSector->Reset(); | |
92ae9768 | 1093 | if(fHistOcc2dVsSector) |
1094 | fHistOcc2dVsSector->Reset(); | |
0ab2a4cc | 1095 | |
1096 | if(fOccVec) | |
1097 | for(Int_t i = 0; i < 72; i++) | |
1098 | fOccVec->GetArray()[i] = 0.0; | |
92ae9768 | 1099 | if(fOccVecFine) |
1100 | for(Int_t i = 0; i < 36*12; i++) | |
1101 | fOccVecFine->GetArray()[i] = 0.0; | |
0ab2a4cc | 1102 | } |
909e332a | 1103 | |
1104 | //____________________________________________________________________________________________ | |
1105 | void AliTPCdataQA::Init() | |
1106 | { | |
7d855b04 | 1107 | /// Define the calibration objects the first time Update is called |
1108 | /// NB! This has to be done first even if the data is rejected by the time | |
1109 | /// cut to make sure that the objects are available in Analyse | |
1110 | ||
909e332a | 1111 | if(!fIsDQM) { |
7d855b04 | 1112 | |
909e332a | 1113 | if (!fNLocalMaxima){ |
1114 | TObjArray configArr(72); | |
1115 | fNLocalMaxima = new AliTPCCalPad(ConfigArrRocs(&configArr,"NLocalMaxima")); | |
1116 | fMaxCharge = new AliTPCCalPad(ConfigArrRocs(&configArr,"MaxCharge")); | |
1117 | fMeanCharge = new AliTPCCalPad(ConfigArrRocs(&configArr,"MeanCharge")); | |
1118 | fNoThreshold = new AliTPCCalPad(ConfigArrRocs(&configArr,"NoThreshold")); | |
1119 | fNTimeBins = new AliTPCCalPad(ConfigArrRocs(&configArr,"NTimeBins")); | |
1120 | fNPads = new AliTPCCalPad(ConfigArrRocs(&configArr,"NPads")); | |
1121 | fTimePosition = new AliTPCCalPad(ConfigArrRocs(&configArr,"TimePosition")); | |
1122 | fOverThreshold10 = new AliTPCCalPad(ConfigArrRocs(&configArr,"OverThreshold10")); | |
1123 | fOverThreshold20 = new AliTPCCalPad(ConfigArrRocs(&configArr,"OverThreshold20")); | |
1124 | fOverThreshold30 = new AliTPCCalPad(ConfigArrRocs(&configArr,"OverThreshold30")); | |
1125 | ||
1126 | fHistQVsTimeSideA = new TProfile("hQVsTimeSideA", "Q vs time (side A); Time [Timebin]; Q [ADC ch]", 100, 0, 1000); | |
1127 | fHistQVsTimeSideA->SetDirectory(0); | |
1128 | fHistQVsTimeSideC = new TProfile("hQVsTimeSideC", "Q vs time (side C); Time [Timebin]; Q [ADC ch]", 100, 0, 1000); | |
1129 | fHistQVsTimeSideC->SetDirectory(0); | |
1130 | fHistQMaxVsTimeSideA = new TProfile("hQMaxVsTimeSideA", "Q_{MAX} vs time (side A); Time [Timebin]; Q_{MAX} [ADC ch]", 100, 0, 1000); | |
1131 | fHistQMaxVsTimeSideA->SetDirectory(0); | |
1132 | fHistQMaxVsTimeSideC = new TProfile("hQMaxVsTimeSideC", "Q_{MAX} vs time (side C); Time [Timebin]; Q_{MAX} [ADC ch]", 100, 0, 1000); | |
1133 | fHistQMaxVsTimeSideC->SetDirectory(0); | |
1134 | } | |
1135 | } else { // DQM histograms and array | |
1136 | ||
1137 | if (!fHistOccVsSector) { | |
1138 | fHistOccVsSector = new TProfile("hOccVsSector", "Occupancy vs sector; Sector; Occupancy", 72, 0, 72); | |
1139 | fHistOccVsSector->SetDirectory(0); | |
1140 | ||
1141 | fHistOcc2dVsSector = new TProfile2D("hOcc2dVsSector", "Occupancy vs sector and patch; Sector; Patch", 72, 0, 36, 6, 0, 6); | |
1142 | fHistOcc2dVsSector->SetDirectory(0); | |
1143 | ||
1144 | fHistQVsSector = new TProfile("hQVsSector", "Q vs sector; Sector; Q [ADC ch]", 72, 0, 72); | |
1145 | fHistQVsSector->SetDirectory(0); | |
1146 | ||
1147 | fHistQmaxVsSector = new TProfile("hQmaxVsSector", "Qmax vs sector; Sector; Qmax [ADC ch]", 72, 0, 72); | |
1148 | fHistQmaxVsSector->SetDirectory(0); | |
1149 | ||
1150 | fOccVec = new TArrayD(72); | |
1151 | for(Int_t i = 0; i < 72; i++) | |
1152 | fOccVec->GetArray()[i] = 0; | |
1153 | ||
1154 | fOccMaxVec = new TArrayD(72); | |
1155 | const Double_t nTimeBins = fLastTimeBin - fFirstTimeBin +1; | |
1156 | for(Int_t i = 0; i < 72; i++) | |
1157 | ||
1158 | if(i<36) // IROCs (5504 pads) | |
1159 | fOccMaxVec->GetArray()[i] = nTimeBins*5504; | |
1160 | else // OROCs (9984 pads) | |
1161 | fOccMaxVec->GetArray()[i] = nTimeBins*9984; | |
1162 | ||
1163 | // 12 branches for each full sector | |
1164 | const Int_t nBranches = 36*12; | |
1165 | fOccVecFine = new TArrayD(nBranches); | |
1166 | for(Int_t i = 0; i < nBranches; i++) | |
1167 | fOccVecFine->GetArray()[i] = 0; | |
1168 | ||
1169 | // Pads per patch same for all sectors | |
1170 | Int_t nPads0[6] = {1152, 1536, 1152, 1280, 1280, 1280}; | |
1171 | Int_t nPads1[6] = {1152, 1664, 1152, 1280, 1280, 1280}; | |
1172 | ||
1173 | fOccMaxVecFine = new TArrayD(nBranches); | |
1174 | for(Int_t i = 0; i < nBranches; i++) { | |
1175 | ||
1176 | const Int_t fullSector = Int_t(i/12); | |
1177 | Int_t branch = i - fullSector*12; | |
1178 | R__ASSERT(branch>=0 && branch<12); | |
1179 | ||
1180 | const Int_t patch = Int_t(branch/2); | |
1181 | branch -= patch*2; | |
1182 | ||
1183 | R__ASSERT(branch>=0 && branch<2); | |
1184 | if(branch == 0) | |
1185 | fOccMaxVecFine->GetArray()[i] = nTimeBins*nPads0[patch]; | |
1186 | else // OROCs (9984 pads) | |
1187 | fOccMaxVecFine->GetArray()[i] = nTimeBins*nPads1[patch]; | |
1188 | } | |
1189 | } | |
1190 | } | |
1191 | // Make the arrays for expanding the data | |
7d855b04 | 1192 | |
909e332a | 1193 | if (!fAllBins) |
1194 | MakeArrays(); | |
7d855b04 | 1195 | |
909e332a | 1196 | // |
1197 | // If Analyse has been previously called we need now to denormalize the data | |
1198 | // as more data is coming | |
1199 | // | |
1200 | if(fIsAnalysed == kTRUE && !fIsDQM) { | |
1201 | ||
1202 | const Int_t nTimeBins = fLastTimeBin - fFirstTimeBin +1; | |
1203 | const Float_t denormalization = Float_t(fEventCounter * nTimeBins); | |
1204 | fNoThreshold->Multiply(denormalization); | |
1205 | ||
1206 | fMeanCharge->Multiply(fNLocalMaxima); | |
1207 | fMaxCharge->Multiply(fNLocalMaxima); | |
1208 | fNTimeBins->Multiply(fNLocalMaxima); | |
1209 | fNPads->Multiply(fNLocalMaxima); | |
1210 | fTimePosition->Multiply(fNLocalMaxima); | |
1211 | fIsAnalysed = kFALSE; | |
1212 | } | |
1213 | } | |
1214 | ||
1215 | //____________________________________________________________________________________________ | |
1216 | void AliTPCdataQA::ResetData() | |
1217 | { | |
7d855b04 | 1218 | /// reset all data |
1219 | ||
909e332a | 1220 | if(!fIsDQM) { |
7d855b04 | 1221 | |
909e332a | 1222 | if (fNLocalMaxima){ |
1223 | fNoThreshold->Reset(); | |
1224 | fNLocalMaxima->Reset(); | |
1225 | fMeanCharge->Reset(); | |
1226 | fMaxCharge->Reset(); | |
1227 | fNTimeBins->Reset(); | |
1228 | fNPads->Reset(); | |
1229 | fTimePosition->Reset(); | |
1230 | fOverThreshold10->Reset(); | |
1231 | fOverThreshold20->Reset(); | |
1232 | fOverThreshold30->Reset(); | |
7d855b04 | 1233 | |
909e332a | 1234 | fHistQVsTimeSideA->Reset(); |
1235 | fHistQVsTimeSideC->Reset(); | |
1236 | fHistQMaxVsTimeSideA->Reset(); | |
1237 | fHistQMaxVsTimeSideC->Reset(); | |
1238 | ||
1239 | fIsAnalysed = kFALSE; | |
7d855b04 | 1240 | |
909e332a | 1241 | } |
1242 | } | |
7d855b04 | 1243 | |
909e332a | 1244 | fEventCounter=0; |
1245 | fClusterCounter=0; | |
1246 | } | |
1247 | ||
1248 | TObjArray *AliTPCdataQA::ConfigArrRocs(TObjArray *arr, const Text_t* name) | |
1249 | { | |
7d855b04 | 1250 | /// GetArray with confiured ROCs |
909e332a | 1251 | |
1252 | arr->Clear(); | |
1253 | arr->SetName(name); | |
1254 | for (Int_t i=0; i<72; ++i){ | |
1255 | if (fActiveChambers[i]) arr->AddAt(new AliTPCCalROC(i),i); | |
1256 | } | |
1257 | return arr; | |
7d855b04 | 1258 | } |