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
170 AliTPCRawStreamFast *rawStreamFast = new AliTPCRawStreamFast(rawReader, (AliAltroMapping**)fMapping);
171 Bool_t res=ProcessEventFast(rawStreamFast);
172 delete rawStreamFast;
176 //_____________________________________________________________________
177 Bool_t AliTPCdataQA::ProcessEvent(AliTPCRawStream *rawStream)
180 // Event Processing loop - AliTPCRawStream
183 rawStream->SetOldRCUFormat(fOldRCUformat);
185 Bool_t withInput = kFALSE;
187 while (rawStream->Next()) {
189 Int_t iSector = rawStream->GetSector(); // current ROC
190 Int_t iRow = rawStream->GetRow(); // current row
191 Int_t iPad = rawStream->GetPad(); // current pad
192 Int_t iTimeBin = rawStream->GetTime(); // current time bin
193 Float_t signal = rawStream->GetSignal(); // current ADC signal
195 Update(iSector,iRow,iPad,iTimeBin,signal);
203 //_____________________________________________________________________
204 Bool_t AliTPCdataQA::ProcessEvent(AliRawReader *rawReader)
207 // Event processing loop - AliRawReader
210 // if fMapping is NULL the rawstream will crate its own mapping
213 AliTPCRawStream rawStream(rawReader, (AliAltroMapping**)fMapping);
214 rawReader->Select("TPC");
215 return ProcessEvent(&rawStream);
219 //_____________________________________________________________________
220 Bool_t AliTPCdataQA::ProcessEvent(eventHeaderStruct *event)
223 // process date event
226 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
227 Bool_t result=ProcessEvent(rawReader);
234 //_____________________________________________________________________
235 void AliTPCdataQA::DumpToFile(const Char_t *filename, const Char_t *dir, Bool_t append) /*FOLD00*/
238 // Write class to file
249 TDirectory *backup = gDirectory;
250 TFile f(filename,option.Data());
252 if ( !sDir.IsNull() ){
253 f.mkdir(sDir.Data());
259 if ( backup ) backup->cd();
263 //_____________________________________________________________________
264 Int_t AliTPCdataQA::Update(const Int_t icsector, /*FOLD00*/
267 const Int_t icTimeBin,
268 const Float_t csignal)
271 // Signal filling method
273 if (icTimeBin<fFirstTimeBin) return 0;
274 if (icTimeBin>fLastTimeBin) return 0;
276 if (!fMaxCharge) fMaxCharge = new AliTPCCalPad("MaxCharge","MaxCharge");
277 if (!fMeanCharge) fMeanCharge = new AliTPCCalPad("MeanCharge","MeanCharge");
278 if (!fNoThreshold) fNoThreshold = new AliTPCCalPad("NoThreshold","NoThreshold");
279 if (!fOverThreshold0) fOverThreshold0 = new AliTPCCalPad("OverThreshold0","OverThreshold0");
280 if (!fOverThreshold5) fOverThreshold5 = new AliTPCCalPad("OverThreshold5","OverThreshold5");
281 if (!fOverThreshold10) fOverThreshold10 = new AliTPCCalPad("OverThreshold10","OverThreshold10");
282 if (!fOverThreshold20) fOverThreshold20 = new AliTPCCalPad("OverThreshold20","OverThreshold20");
283 if (!fOverThreshold30) fOverThreshold30 = new AliTPCCalPad("OverThreshold30","OverThreshold30");
286 Int_t signal = Int_t(csignal);
288 // if pedestal calibrations are loaded subtract pedestals
291 Int_t pedestal = Int_t(fPedestal->GetCalROC(icsector)->GetValue(icRow, icPad));
292 if(pedestal<10 || pedestal>90)
300 Float_t count = fNoThreshold->GetCalROC(icsector)->GetValue(icRow, icPad);
301 fNoThreshold->GetCalROC(icsector)->SetValue(icRow, icPad,count+1);
304 // Require at least 3 ADC channels
308 // if noise calibrations are loaded require at least 3*sigmaNoise
311 Float_t noise = fNoise->GetCalROC(icsector)->GetValue(icRow, icPad);
317 // this signal is ok - now see if the previous signal was connected
318 // this is a bit ugly since the standard decoder goes down in time bins
319 // (10, 9, 8..) while the fast HLT decoder goes up in time bins (1, 2, 3..)
321 if(fSectorLast==icsector && fRowLast==icRow && fPadLast==icPad &&
322 fTimeBinLast==icTimeBin+1 || fTimeBinLast==icTimeBin-1)
325 fNAboveThreshold = 1;
327 if(fNAboveThreshold==2) {
330 // This is the only special case, because before we did not know if we
331 // should store the information
333 UpdateSignalHistograms(fSectorLast, fRowLast, fPadLast, fTimeBinLast,
337 // keep the information for the next signal
338 fSectorLast = icsector;
341 fTimeBinLast = icTimeBin;
342 fSignalLast = signal;
344 if(fNAboveThreshold==1) // we don't know if this information should be stored
347 UpdateSignalHistograms(fSectorLast, fRowLast, fPadLast, fTimeBinLast,
352 //_____________________________________________________________________
353 void AliTPCdataQA::UpdateSignalHistograms(const Int_t icsector, /*FOLD00*/
356 const Int_t icTimeBin,
357 const Float_t signal)
360 // Signal filling method
364 Float_t charge = fMeanCharge->GetCalROC(icsector)->GetValue(icRow, icPad);
365 fMeanCharge->GetCalROC(icsector)->SetValue(icRow, icPad, charge + signal);
368 if (signal>fMaxCharge->GetCalROC(icsector)->GetValue(icRow, icPad)){
369 fMaxCharge->GetCalROC(icsector)->SetValue(icRow, icPad,signal);
373 Float_t count = fOverThreshold0->GetCalROC(icsector)->GetValue(icRow, icPad);
374 fOverThreshold0->GetCalROC(icsector)->SetValue(icRow, icPad,count+1);
378 Float_t count = fOverThreshold5->GetCalROC(icsector)->GetValue(icRow, icPad);
379 fOverThreshold5->GetCalROC(icsector)->SetValue(icRow, icPad,count+1);
382 Float_t count = fOverThreshold10->GetCalROC(icsector)->GetValue(icRow, icPad);
383 fOverThreshold10->GetCalROC(icsector)->SetValue(icRow, icPad,count+1);
386 Float_t count = fOverThreshold20->GetCalROC(icsector)->GetValue(icRow, icPad);
387 fOverThreshold20->GetCalROC(icsector)->SetValue(icRow, icPad,count+1);
390 Float_t count = fOverThreshold30->GetCalROC(icsector)->GetValue(icRow, icPad);
391 fOverThreshold30->GetCalROC(icsector)->SetValue(icRow, icPad,count+1);
395 //_____________________________________________________________________
396 void AliTPCdataQA::Analyse()
399 // Calculate calibration constants
402 cout << "Analyse called" << endl;
404 if(fEventCounter==0) {
406 cout << "EventCounter == 0, Cannot analyse" << endl;
410 Int_t nTimeBins = fLastTimeBin - fFirstTimeBin +1;
412 cout << "Analyse called" << endl
413 << "EventCounter: " << fEventCounter << endl
414 << "TimeBins: " << nTimeBins << endl;
416 fMeanCharge->Divide(fNoThreshold);
418 Float_t normalization = 1.0 / Float_t(fEventCounter * nTimeBins);
419 fNoThreshold->Multiply(normalization);
420 fOverThreshold0->Multiply(normalization);
421 fOverThreshold5->Multiply(normalization);
422 fOverThreshold10->Multiply(normalization);
423 fOverThreshold20->Multiply(normalization);
424 fOverThreshold30->Multiply(normalization);