- exclude old HLT TPC calibration components from the list of registered components
[u/mrichter/AliRoot.git] / TPC / AliTPCCalibRaw.cxx
CommitLineData
ddeb9c4f 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
16/* $Id: $ */
17
18////////////////////////////////////////////////////////////////////////////////////////
19// //
20// Implementation of the TPC Raw drift velocity and Altro L1 Phase calibration //
21// //
22// Origin: Jens Wiechula, J.Wiechula@gsi.de //
23// //
24////////////////////////////////////////////////////////////////////////////////////////
25//
26//
27// *************************************************************************************
28// * Class Description *
29// *************************************************************************************
30/*
31
32----example---
33TFile f("CalibAltro.root");
34AliTPCCalibRaw *al=(AliTPCCalibRaw*)f.Get(f.GetListOfKeys()->At(0)->GetName())
35{
36TCanvas *c1=(TCanvas*)gROOT->FindObject("c1");
37if (!c1) c1=new TCanvas("c1","c1");
38c1->Clear();
39
40TH2F h2f("h2","h2;RCU;fail",216,0,216,al->GetNevents(),0,al->GetNevents());
41Bool_t first=kTRUE;
42Int_t i,iev;
43for (i=0;i<216;++i) {
44 TVectorF *v=al->GetALTROL1PhaseFailEventsRCU(i);
45 if (!v) continue;
46 for (iev=0;iev<al->GetNevents();++iev) {
47 h2f->SetBinContent(i+1,iev+1,(*v)(iev));
48 }
49// TH1F h(*v);
50// h.SetLineColor(i/216.*50+50);
51// ((TH1F*)h.Clone(Form("h%d",i)))->Draw(first?"":"same");
52// c1->Modified();
53// c1->Update();
54 first=kFALSE;
55}
56h2f->Draw("col");
57}
58
59*/
60
61
62
63//Root includes
64#include <TH2C.h>
65
66//AliRoot includes
67#include "AliTPCCalROC.h"
68#include "AliAltroRawStream.h"
69#include "AliLog.h"
70
71//class header
72#include "AliTPCCalibRaw.h"
73
74ClassImp(AliTPCCalibRaw)
75
76AliTPCCalibRaw::AliTPCCalibRaw() :
77 AliTPCCalibRawBase(),
78 fPeakDetMinus(1),
79 fPeakDetPlus(2),
80 fNFailL1Phase(0),
81 fFirstTimeStamp(0),
82 fNSecTime(600), //default 10 minutes
83 fNBinsTime(60), //default 60*10 minutes = 10 hours
84 fPadProcessed(kFALSE),
85 fCurrentChannel(-1),
86 fCurrentSector(-1),
87 fLastSector(-2),
88 fCurrentRow(-1),
89 fCurrentPad(-1),
90 fLastTimeBinProc(0),
91 fPeakTimeBin(0),
92 fLastSignal(0),
93 fNOkPlus(0),
94 fNOkMinus(0),
95 fArrCurrentPhaseDist(4),
96 fArrALTROL1Phase(1000),
97 fArrALTROL1PhaseEvent(216),
98 fArrALTROL1PhaseFailEvent(216),
99 fHnDrift(0x0)
100{
101 //
102 // Default ctor
103 //
104 SetNameTitle("AliTPCCalibRaw","AliTPCCalibRaw");
105 CreateDVhist();
106 fFirstTimeBin=850;
107 fLastTimeBin=1000;
108}
109//_____________________________________________________________________
110AliTPCCalibRaw::~AliTPCCalibRaw()
111{
112 //
113 // dtor
114 //
115 delete fHnDrift;
116}
117//_____________________________________________________________________
118// AliTPCCalibRaw& AliTPCCalibRaw::operator = (const AliTPCCalibRaw &source)
119// {
120// //
121// // assignment operator
122// //
123// if (&source == this) return *this;
124// new (this) AliTPCCalibRaw(source);
125//
126// return *this;
127// }
128
129//_____________________________________________________________________
130Int_t AliTPCCalibRaw::Update(const Int_t isector, const Int_t iRow, const Int_t iPad,
131 const Int_t iTimeBin, const Float_t signal)
132{
133 //
134 // Data filling method
135 //
136 if (iRow<0) return 0;
137 if (iPad<0) return 0;
138 if (iTimeBin<0) return 0;
139 if (!fFirstTimeStamp) fFirstTimeStamp=GetTimeStamp();
ddeb9c4f 140 if ( (iTimeBin>fLastTimeBin) || (iTimeBin<fFirstTimeBin) ) return 0;
141 //don't process edge pads
142 if (IsEdgePad(isector,iRow,iPad)) return 0;
143// Double_t x[kHnBinsDV]={1,isector,0};
144// fHnDrift->Fill(x);
145 Int_t iChannel = fROC->GetRowIndexes(isector)[iRow]+iPad; // global pad position in sector
146 if (fCurrentChannel==iChannel){
147 if (fPadProcessed) return 0;
148 } else {
149 fPadProcessed=kFALSE;
150 fNOkPlus=0;
151 fNOkMinus=0;
152 fPeakTimeBin=0;
153 fLastSignal=0;
154 }
155// Double_t x2[kHnBinsDV]={2,isector,0};
156// fHnDrift->Fill(x2);
157
158
159 if (signal>fLastSignal) ++fNOkPlus;
160 else if(signal<fLastSignal && fNOkPlus>=fPeakDetPlus){
161 ++fNOkMinus;
162 if (!fPeakTimeBin) fPeakTimeBin=fLastTimeBinProc;
163 if ( fNOkMinus>=fPeakDetMinus ) {
164 Double_t x[kHnBinsDV]={fPeakTimeBin,isector,(fTimeStamp-fFirstTimeStamp)/fNSecTime};
165 fHnDrift->Fill(x);
166 }
167 } else {
168 fNOkPlus=0;
169 fNOkMinus=0;
170 fPeakTimeBin=0;
171 fLastSignal=0;
172 }
173
174 fLastTimeBinProc=iTimeBin;
175 fLastSignal=TMath::Nint(signal);
176 fCurrentChannel = iChannel;
177 return 0;
178}
179//_____________________________________________________________________
5312f439 180void AliTPCCalibRaw::UpdateDDL(){
181 //
182 // fill ALTRO L1 information
183 //
184// if (fCurrDDLNum!=fPrevDDLNum){
185 TVectorF *arr=MakeArrL1PhaseRCU(fCurrDDLNum,kTRUE);
186 if (arr->GetNrows()<=fNevents) arr->ResizeTo(arr->GetNrows()+1000);
187 // phase as a position of a quarter time bin
188 Int_t phase=(Int_t)(GetL1PhaseTB()*4.);
d73f0401 189// printf("DDL: %03d, phase: %d (%f))\n",fCurrDDLNum,phase,GetL1PhaseTB());
5312f439 190 //Fill pahse information of current rcu and event
191 (arr->GetMatrixArray())[fNevents]=phase;
192 //increase phase counter
193 ++((fArrCurrentPhaseDist.GetMatrixArray())[phase]);
194// printf("RCUId: %03d (%03d), DDL: %03d, sector: %02d\n",fCurrRCUId, fPrevRCUId, fCurrDDLNum, isector);
195// }
196
197}
198//_____________________________________________________________________
ddeb9c4f 199void AliTPCCalibRaw::ResetEvent()
200{
201 //
202 // Reset event counters
203 //
204
205 fCurrentChannel=-1;
206 fArrCurrentPhaseDist.Zero();
207}
208//_____________________________________________________________________
209void AliTPCCalibRaw::EndEvent()
210{
211 //
212 // End event analysis
213 //
214
215
216 //find phase of the current event
217 Int_t phaseMaxEntries=-1;
218 Int_t maxEntries=0;
219 for (Int_t i=0;i<fArrCurrentPhaseDist.GetNrows();++i){
220 Int_t entries=(Int_t)fArrCurrentPhaseDist[i];
221 if (maxEntries<entries) {
222 maxEntries=entries;
223 phaseMaxEntries=i;
224 }
225 }
226 // store phase of current event
227 if (fArrALTROL1Phase.GetNrows()<=GetNevents())
228 fArrALTROL1Phase.ResizeTo(GetNevents()+1000);
229 (fArrALTROL1Phase.GetMatrixArray())[GetNevents()]=phaseMaxEntries;
230
231 //loop over RCUs and test failures
232 for (Int_t ircu=0;ircu<216;++ircu){
233 const TVectorF *arr=GetALTROL1PhaseEventsRCU(ircu);//MakeArrL1PhaseRCU(ircu);
234 if (!arr) continue;
235 TVectorF *arrF=MakeArrL1PhaseFailRCU(ircu,kTRUE);
236 if (arrF->GetNrows()<=fNevents) arrF->ResizeTo(arrF->GetNrows()+1000);
237 if ((arr->GetMatrixArray())[fNevents]!=phaseMaxEntries){
238 (arrF->GetMatrixArray())[fNevents]=1;
239 ++fNFailL1Phase;
240 }
241 }
242 IncrementNevents();
243}
244//_____________________________________________________________________
245TH2C *AliTPCCalibRaw::MakeHistL1RCUEvents(Int_t type)
246{
247 // Create a 2D histo RCU:Events indicating the there was a deviation
248 // from the mean L1 phase of the event
249 //
250 //type: 0=Failures, 1=Phases
251 TH2C *h2 = new TH2C("hL1FailRCUEvents","L1 Failures;RCU;Event",216,0,216,GetNevents(),0,GetNevents());
5312f439 252 Int_t add=0;
ddeb9c4f 253 for (Int_t ircu=0;ircu<216;++ircu) {
254 const TVectorF *v=0;
5312f439 255 if (type==0){
256 v=GetALTROL1PhaseFailEventsRCU(ircu);
257 add=1;
258 h2->SetMinimum(0);
259 h2->SetMaximum(2);
260 } else if (type==1) {
261 v=GetALTROL1PhaseEventsRCU(ircu);
262 add=0;
263 h2->SetMinimum(0);
264 h2->SetMaximum(4);
265 }
ddeb9c4f 266 if (!v) continue;
267 for (Int_t iev=0;iev<GetNevents();++iev) {
5312f439 268 h2->SetBinContent(ircu+1,iev+1,(*v)(iev)+add);
ddeb9c4f 269 }
270 }
271 return h2;
272}
273//_____________________________________________________________________
274TH2C *AliTPCCalibRaw::MakeHistL1RCUEventsIROC(Int_t type)
275{
276 //
277 // Create a 2D histo RCU:Events indicating the there was a deviation
278 // from the mean L1 phase of the event
279 //
280 TH2C *h2 = new TH2C("hL1FailRCUEventsIROC","L1 Failures IROCs;RCU;Event",72,0,36,GetNevents(),0,GetNevents());
281 for (Int_t ircu=0;ircu<72;++ircu) {
282 const TVectorF *v=0;
283 if (type==0) v=GetALTROL1PhaseFailEventsRCU(ircu);
284 else if (type==1) v=GetALTROL1PhaseEventsRCU(ircu);
285 if (!v) continue;
286 for (Int_t iev=0;iev<GetNevents();++iev) {
5312f439 287 h2->SetBinContent(ircu+1,iev+1,(*v)(iev));
ddeb9c4f 288 }
289 }
290 return h2;
291}
292//_____________________________________________________________________
293TH2C *AliTPCCalibRaw::MakeHistL1RCUEventsOROC(Int_t type)
294{
295 //
296 // Create a 2D histo RCU:Events indicating the there was a deviation
297 // from the mean L1 phase of the event
298 //
299 TH2C *h2 = new TH2C("hL1FailRCUEventsOROC","L1 Failures OROCs;RCU;Event",144,0,36,GetNevents(),0,GetNevents());
300 for (Int_t ircu=72;ircu<216;++ircu) {
301 const TVectorF *v=0;
302 if (type==0) v=GetALTROL1PhaseFailEventsRCU(ircu);
303 else if (type==1) v=GetALTROL1PhaseEventsRCU(ircu);
304 if (!v) continue;
305 for (Int_t iev=0;iev<GetNevents();++iev) {
5312f439 306 h2->SetBinContent(ircu-72+1,iev+1,(*v)(iev));
ddeb9c4f 307 }
308 }
309 return h2;
310}
311//_____________________________________________________________________
312void AliTPCCalibRaw::CreateDVhist()
313{
314 //
315 // Setup the HnSparse for the drift velocity determination
316 //
317 if (fHnDrift) return;
318 //HnSparse bins
319 //time bin, roc, time
320 Int_t bins[kHnBinsDV] = {1000, 72, fNBinsTime};
321 Double_t xmin[kHnBinsDV] = {0,0,0};
322 Double_t xmax[kHnBinsDV] = {1000,72,fNBinsTime};
323 fHnDrift=new THnSparseI("fHnDrift",Form("Drift velocity using last time bin;time bin[#times 100ns];ROC;Time bin [#times %us]",fNSecTime),kHnBinsDV, bins, xmin, xmax);
324
325}
326//_____________________________________________________________________
327void AliTPCCalibRaw::Analyse()
328{
329 //
330 // Analyse Data
331 //
332
333 //resize arrays
334 fArrALTROL1Phase.ResizeTo(GetNevents());
335 for (Int_t ircu=0;ircu<216;++ircu){
336 TVectorF *arr=MakeArrL1PhaseRCU(ircu);//MakeArrL1PhaseRCU(ircu);
337 if (!arr) continue;
338 TVectorF *arrF=MakeArrL1PhaseFailRCU(ircu);
339 arr->ResizeTo(GetNevents());
340 arrF->ResizeTo(GetNevents());
341 }
342
343 //Analyse drift velocity
344
345}
346