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 **************************************************************************/
32 #include <TDirectory.h>
35 #include "AliRawReader.h"
36 #include "AliRawReaderRoot.h"
37 #include "AliRawReaderDate.h"
38 #include "AliTPCRawStream.h"
39 #include "AliTPCCalROC.h"
40 #include "AliTPCROC.h"
41 #include "AliMathBase.h"
42 #include "TTreeStream.h"
43 #include "AliTPCRawStreamFast.h"
47 #include "AliTPCCalPad.h"
50 #include "AliTPCdataQA.h"
52 ClassImp(AliTPCdataQA)
54 AliTPCdataQA::AliTPCdataQA() : /*FOLD00*/
61 fROC(AliTPCROC::Instance()),
76 // default constructor
88 //_____________________________________________________________________
89 AliTPCdataQA::AliTPCdataQA(const AliTPCdataQA &ped) : /*FOLD00*/
91 fFirstTimeBin(ped.GetFirstTimeBin()),
92 fLastTimeBin(ped.GetLastTimeBin()),
93 fAdcMin(ped.GetAdcMin()),
94 fAdcMax(ped.GetAdcMax()),
95 fOldRCUformat(ped.fOldRCUformat),
96 fROC(AliTPCROC::Instance()),
106 //_____________________________________________________________________
107 AliTPCdataQA& AliTPCdataQA::operator = (const AliTPCdataQA &source)
110 // assignment operator
112 if (&source == this) return *this;
113 new (this) AliTPCdataQA(source);
119 //_____________________________________________________________________
120 AliTPCdataQA::~AliTPCdataQA() /*FOLD00*/
126 // do not delete fMapping, because we do not own it.
133 //_____________________________________________________________________
134 Bool_t AliTPCdataQA::ProcessEventFast(AliTPCRawStreamFast *rawStreamFast)
137 // Event Processing loop - AliTPCRawStream
139 Bool_t withInput = kFALSE;
141 while ( rawStreamFast->NextDDL() ){
142 while ( rawStreamFast->NextChannel() ){
143 Int_t isector = rawStreamFast->GetSector(); // current sector
144 Int_t iRow = rawStreamFast->GetRow(); // current row
145 Int_t iPad = rawStreamFast->GetPad(); // current pad
147 while ( rawStreamFast->NextBunch() ){
148 Int_t startTbin = (Int_t)rawStreamFast->GetStartTimeBin();
149 Int_t endTbin = (Int_t)rawStreamFast->GetEndTimeBin();
151 for (Int_t iTimeBin = startTbin; iTimeBin < endTbin; iTimeBin++){
152 Float_t signal=(Float_t)rawStreamFast->GetSignals()[iTimeBin-startTbin];
153 Update(isector,iRow,iPad,iTimeBin+1,signal);
162 //_____________________________________________________________________
163 Bool_t AliTPCdataQA::ProcessEventFast(AliRawReader *rawReader)
166 // Event processing loop - AliRawReader
169 AliTPCRawStreamFast *rawStreamFast = new AliTPCRawStreamFast(rawReader, (AliAltroMapping**)fMapping);
170 Bool_t res=ProcessEventFast(rawStreamFast);
172 fEventCounter++; // only increment event counter if there is TPC data
173 // otherwise Analyse (called in QA) fails
175 delete rawStreamFast;
179 //_____________________________________________________________________
180 Bool_t AliTPCdataQA::ProcessEvent(AliTPCRawStream *rawStream)
183 // Event Processing loop - AliTPCRawStream
186 rawStream->SetOldRCUFormat(fOldRCUformat);
188 Bool_t withInput = kFALSE;
190 while (rawStream->Next()) {
192 Int_t iSector = rawStream->GetSector(); // current ROC
193 Int_t iRow = rawStream->GetRow(); // current row
194 Int_t iPad = rawStream->GetPad(); // current pad
195 Int_t iTimeBin = rawStream->GetTime(); // current time bin
196 Float_t signal = rawStream->GetSignal(); // current ADC signal
198 Update(iSector,iRow,iPad,iTimeBin,signal);
206 //_____________________________________________________________________
207 Bool_t AliTPCdataQA::ProcessEvent(AliRawReader *rawReader)
210 // Event processing loop - AliRawReader
213 // if fMapping is NULL the rawstream will crate its own mapping
215 AliTPCRawStream rawStream(rawReader, (AliAltroMapping**)fMapping);
216 rawReader->Select("TPC");
217 Bool_t res = ProcessEvent(&rawStream);
220 fEventCounter++; // only increment event counter if there is TPC data
221 // otherwise Analyse (called in QA) fails
226 //_____________________________________________________________________
227 Bool_t AliTPCdataQA::ProcessEvent(eventHeaderStruct *event)
230 // process date event
233 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
234 Bool_t result=ProcessEvent(rawReader);
241 //_____________________________________________________________________
242 void AliTPCdataQA::DumpToFile(const Char_t *filename, const Char_t *dir, Bool_t append) /*FOLD00*/
245 // Write class to file
256 TDirectory *backup = gDirectory;
257 TFile f(filename,option.Data());
259 if ( !sDir.IsNull() ){
260 f.mkdir(sDir.Data());
266 if ( backup ) backup->cd();
270 //_____________________________________________________________________
271 Int_t AliTPCdataQA::Update(const Int_t icsector, /*FOLD00*/
274 const Int_t icTimeBin,
275 const Float_t csignal)
278 // Signal filling method
280 if (icTimeBin<fFirstTimeBin) return 0;
281 if (icTimeBin>fLastTimeBin) return 0;
283 if (!fMaxCharge) fMaxCharge = new AliTPCCalPad("MaxCharge","MaxCharge");
284 if (!fMeanCharge) fMeanCharge = new AliTPCCalPad("MeanCharge","MeanCharge");
285 if (!fNoThreshold) fNoThreshold = new AliTPCCalPad("NoThreshold","NoThreshold");
286 if (!fOverThreshold0) fOverThreshold0 = new AliTPCCalPad("OverThreshold0","OverThreshold0");
287 if (!fOverThreshold5) fOverThreshold5 = new AliTPCCalPad("OverThreshold5","OverThreshold5");
288 if (!fOverThreshold10) fOverThreshold10 = new AliTPCCalPad("OverThreshold10","OverThreshold10");
289 if (!fOverThreshold20) fOverThreshold20 = new AliTPCCalPad("OverThreshold20","OverThreshold20");
290 if (!fOverThreshold30) fOverThreshold30 = new AliTPCCalPad("OverThreshold30","OverThreshold30");
293 Int_t signal = Int_t(csignal);
295 // if pedestal calibrations are loaded subtract pedestals
298 Int_t pedestal = Int_t(fPedestal->GetCalROC(icsector)->GetValue(icRow, icPad));
299 if(pedestal<10 || pedestal>90)
307 Float_t count = fNoThreshold->GetCalROC(icsector)->GetValue(icRow, icPad);
308 fNoThreshold->GetCalROC(icsector)->SetValue(icRow, icPad,count+1);
311 // Require at least 3 ADC channels
315 // if noise calibrations are loaded require at least 3*sigmaNoise
318 Float_t noise = fNoise->GetCalROC(icsector)->GetValue(icRow, icPad);
324 // this signal is ok - now see if the previous signal was connected
325 // this is a bit ugly since the standard decoder goes down in time bins
326 // (10, 9, 8..) while the fast HLT decoder goes up in time bins (1, 2, 3..)
328 if(fSectorLast==icsector && fRowLast==icRow && fPadLast==icPad &&
329 fTimeBinLast==icTimeBin+1 || fTimeBinLast==icTimeBin-1)
332 fNAboveThreshold = 1;
334 if(fNAboveThreshold==2) {
337 // This is the only special case, because before we did not know if we
338 // should store the information
340 UpdateSignalHistograms(fSectorLast, fRowLast, fPadLast, fTimeBinLast,
344 // keep the information for the next signal
345 fSectorLast = icsector;
348 fTimeBinLast = icTimeBin;
349 fSignalLast = signal;
351 if(fNAboveThreshold==1) // we don't know if this information should be stored
354 UpdateSignalHistograms(fSectorLast, fRowLast, fPadLast, fTimeBinLast,
359 //_____________________________________________________________________
360 void AliTPCdataQA::UpdateSignalHistograms(const Int_t icsector, /*FOLD00*/
363 const Int_t icTimeBin,
364 const Float_t signal)
367 // Signal filling method
371 Float_t charge = fMeanCharge->GetCalROC(icsector)->GetValue(icRow, icPad);
372 fMeanCharge->GetCalROC(icsector)->SetValue(icRow, icPad, charge + signal);
375 if (signal>fMaxCharge->GetCalROC(icsector)->GetValue(icRow, icPad)){
376 fMaxCharge->GetCalROC(icsector)->SetValue(icRow, icPad,signal);
380 Float_t count = fOverThreshold0->GetCalROC(icsector)->GetValue(icRow, icPad);
381 fOverThreshold0->GetCalROC(icsector)->SetValue(icRow, icPad,count+1);
385 Float_t count = fOverThreshold5->GetCalROC(icsector)->GetValue(icRow, icPad);
386 fOverThreshold5->GetCalROC(icsector)->SetValue(icRow, icPad,count+1);
389 Float_t count = fOverThreshold10->GetCalROC(icsector)->GetValue(icRow, icPad);
390 fOverThreshold10->GetCalROC(icsector)->SetValue(icRow, icPad,count+1);
393 Float_t count = fOverThreshold20->GetCalROC(icsector)->GetValue(icRow, icPad);
394 fOverThreshold20->GetCalROC(icsector)->SetValue(icRow, icPad,count+1);
397 Float_t count = fOverThreshold30->GetCalROC(icsector)->GetValue(icRow, icPad);
398 fOverThreshold30->GetCalROC(icsector)->SetValue(icRow, icPad,count+1);
402 //_____________________________________________________________________
403 void AliTPCdataQA::Analyse()
406 // Calculate calibration constants
409 cout << "Analyse called" << endl;
411 if(fEventCounter==0) {
413 cout << "EventCounter == 0, Cannot analyse" << endl;
417 Int_t nTimeBins = fLastTimeBin - fFirstTimeBin +1;
419 cout << "EventCounter: " << fEventCounter << endl
420 << "TimeBins: " << nTimeBins << endl;
422 if (fMeanCharge && fNoThreshold) fMeanCharge->Divide(fNoThreshold);
424 Float_t normalization = 1.0 / Float_t(fEventCounter * nTimeBins);
425 if (fNoThreshold) fNoThreshold->Multiply(normalization);
426 if (fOverThreshold0) fOverThreshold0->Multiply(normalization);
427 if (fOverThreshold5) fOverThreshold5->Multiply(normalization);
428 if (fOverThreshold10) fOverThreshold10->Multiply(normalization);
429 if (fOverThreshold20) fOverThreshold20->Multiply(normalization);
430 if (fOverThreshold30) fOverThreshold30->Multiply(normalization);