]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCCalibRaw.cxx
Use the object name to create the output file name (Marian)
[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>
f113dfeb 65#include <TMap.h>
66#include <TObjString.h>
ddeb9c4f 67
68//AliRoot includes
69#include "AliTPCCalROC.h"
70#include "AliAltroRawStream.h"
71#include "AliLog.h"
ddeb9c4f 72//class header
73#include "AliTPCCalibRaw.h"
74
75ClassImp(AliTPCCalibRaw)
76
77AliTPCCalibRaw::AliTPCCalibRaw() :
78 AliTPCCalibRawBase(),
79 fPeakDetMinus(1),
80 fPeakDetPlus(2),
81 fNFailL1Phase(0),
82 fFirstTimeStamp(0),
83 fNSecTime(600), //default 10 minutes
84 fNBinsTime(60), //default 60*10 minutes = 10 hours
85 fPadProcessed(kFALSE),
86 fCurrentChannel(-1),
87 fCurrentSector(-1),
88 fLastSector(-2),
89 fCurrentRow(-1),
90 fCurrentPad(-1),
91 fLastTimeBinProc(0),
92 fPeakTimeBin(0),
93 fLastSignal(0),
94 fNOkPlus(0),
95 fNOkMinus(0),
96 fArrCurrentPhaseDist(4),
97 fArrALTROL1Phase(1000),
98 fArrALTROL1PhaseEvent(216),
99 fArrALTROL1PhaseFailEvent(216),
100 fHnDrift(0x0)
101{
102 //
103 // Default ctor
104 //
105 SetNameTitle("AliTPCCalibRaw","AliTPCCalibRaw");
106 CreateDVhist();
107 fFirstTimeBin=850;
f113dfeb 108 fLastTimeBin=1020;
ddeb9c4f 109}
f113dfeb 110//_____________________________________________________________________
111AliTPCCalibRaw::AliTPCCalibRaw(const TMap *config) :
112AliTPCCalibRawBase(),
113fPeakDetMinus(1),
114fPeakDetPlus(2),
115fNFailL1Phase(0),
116fFirstTimeStamp(0),
117fNSecTime(600), //default 10 minutes
118fNBinsTime(60), //default 60*10 minutes = 10 hours
119fPadProcessed(kFALSE),
120fCurrentChannel(-1),
121fCurrentSector(-1),
122fLastSector(-2),
123fCurrentRow(-1),
124fCurrentPad(-1),
125fLastTimeBinProc(0),
126fPeakTimeBin(0),
127fLastSignal(0),
128fNOkPlus(0),
129fNOkMinus(0),
130fArrCurrentPhaseDist(4),
131fArrALTROL1Phase(1000),
132fArrALTROL1PhaseEvent(216),
133fArrALTROL1PhaseFailEvent(216),
134fHnDrift(0x0)
135{
136 //
137 // Default ctor
138 //
139 SetNameTitle("AliTPCCalibRaw","AliTPCCalibRaw");
140 CreateDVhist();
141 fFirstTimeBin=850;
142 fLastTimeBin=1020;
143 if (config->GetValue("FirstTimeBin")) fFirstTimeBin = ((TObjString*)config->GetValue("FirstTimeBin"))->GetString().Atoi();
144 if (config->GetValue("LastTimeBin")) fLastTimeBin = ((TObjString*)config->GetValue("LastTimeBin"))->GetString().Atoi();
145}
146
ddeb9c4f 147//_____________________________________________________________________
148AliTPCCalibRaw::~AliTPCCalibRaw()
149{
150 //
151 // dtor
152 //
153 delete fHnDrift;
154}
155//_____________________________________________________________________
156// AliTPCCalibRaw& AliTPCCalibRaw::operator = (const AliTPCCalibRaw &source)
157// {
158// //
159// // assignment operator
160// //
161// if (&source == this) return *this;
162// new (this) AliTPCCalibRaw(source);
163//
164// return *this;
165// }
166
167//_____________________________________________________________________
168Int_t AliTPCCalibRaw::Update(const Int_t isector, const Int_t iRow, const Int_t iPad,
169 const Int_t iTimeBin, const Float_t signal)
170{
171 //
172 // Data filling method
173 //
174 if (iRow<0) return 0;
175 if (iPad<0) return 0;
176 if (iTimeBin<0) return 0;
177 if (!fFirstTimeStamp) fFirstTimeStamp=GetTimeStamp();
ddeb9c4f 178 if ( (iTimeBin>fLastTimeBin) || (iTimeBin<fFirstTimeBin) ) return 0;
179 //don't process edge pads
180 if (IsEdgePad(isector,iRow,iPad)) return 0;
181// Double_t x[kHnBinsDV]={1,isector,0};
182// fHnDrift->Fill(x);
183 Int_t iChannel = fROC->GetRowIndexes(isector)[iRow]+iPad; // global pad position in sector
184 if (fCurrentChannel==iChannel){
185 if (fPadProcessed) return 0;
186 } else {
187 fPadProcessed=kFALSE;
188 fNOkPlus=0;
189 fNOkMinus=0;
190 fPeakTimeBin=0;
191 fLastSignal=0;
192 }
193// Double_t x2[kHnBinsDV]={2,isector,0};
194// fHnDrift->Fill(x2);
195
196
197 if (signal>fLastSignal) ++fNOkPlus;
198 else if(signal<fLastSignal && fNOkPlus>=fPeakDetPlus){
199 ++fNOkMinus;
200 if (!fPeakTimeBin) fPeakTimeBin=fLastTimeBinProc;
201 if ( fNOkMinus>=fPeakDetMinus ) {
202 Double_t x[kHnBinsDV]={fPeakTimeBin,isector,(fTimeStamp-fFirstTimeStamp)/fNSecTime};
203 fHnDrift->Fill(x);
204 }
205 } else {
206 fNOkPlus=0;
207 fNOkMinus=0;
208 fPeakTimeBin=0;
209 fLastSignal=0;
210 }
211
212 fLastTimeBinProc=iTimeBin;
213 fLastSignal=TMath::Nint(signal);
214 fCurrentChannel = iChannel;
215 return 0;
5312f439 216}
217//_____________________________________________________________________
218void AliTPCCalibRaw::UpdateDDL(){
219 //
220 // fill ALTRO L1 information
221 //
222// if (fCurrDDLNum!=fPrevDDLNum){
223 TVectorF *arr=MakeArrL1PhaseRCU(fCurrDDLNum,kTRUE);
224 if (arr->GetNrows()<=fNevents) arr->ResizeTo(arr->GetNrows()+1000);
225 // phase as a position of a quarter time bin
226 Int_t phase=(Int_t)(GetL1PhaseTB()*4.);
d73f0401 227// printf("DDL: %03d, phase: %d (%f))\n",fCurrDDLNum,phase,GetL1PhaseTB());
5312f439 228 //Fill pahse information of current rcu and event
229 (arr->GetMatrixArray())[fNevents]=phase;
230 //increase phase counter
231 ++((fArrCurrentPhaseDist.GetMatrixArray())[phase]);
232// printf("RCUId: %03d (%03d), DDL: %03d, sector: %02d\n",fCurrRCUId, fPrevRCUId, fCurrDDLNum, isector);
233// }
234
ddeb9c4f 235}
236//_____________________________________________________________________
237void AliTPCCalibRaw::ResetEvent()
238{
239 //
240 // Reset event counters
241 //
242
243 fCurrentChannel=-1;
244 fArrCurrentPhaseDist.Zero();
245}
246//_____________________________________________________________________
247void AliTPCCalibRaw::EndEvent()
248{
249 //
250 // End event analysis
251 //
252
253
254 //find phase of the current event
255 Int_t phaseMaxEntries=-1;
256 Int_t maxEntries=0;
257 for (Int_t i=0;i<fArrCurrentPhaseDist.GetNrows();++i){
258 Int_t entries=(Int_t)fArrCurrentPhaseDist[i];
259 if (maxEntries<entries) {
260 maxEntries=entries;
261 phaseMaxEntries=i;
262 }
263 }
264 // store phase of current event
265 if (fArrALTROL1Phase.GetNrows()<=GetNevents())
266 fArrALTROL1Phase.ResizeTo(GetNevents()+1000);
267 (fArrALTROL1Phase.GetMatrixArray())[GetNevents()]=phaseMaxEntries;
268
269 //loop over RCUs and test failures
270 for (Int_t ircu=0;ircu<216;++ircu){
271 const TVectorF *arr=GetALTROL1PhaseEventsRCU(ircu);//MakeArrL1PhaseRCU(ircu);
272 if (!arr) continue;
273 TVectorF *arrF=MakeArrL1PhaseFailRCU(ircu,kTRUE);
274 if (arrF->GetNrows()<=fNevents) arrF->ResizeTo(arrF->GetNrows()+1000);
275 if ((arr->GetMatrixArray())[fNevents]!=phaseMaxEntries){
276 (arrF->GetMatrixArray())[fNevents]=1;
277 ++fNFailL1Phase;
278 }
279 }
280 IncrementNevents();
281}
282//_____________________________________________________________________
283TH2C *AliTPCCalibRaw::MakeHistL1RCUEvents(Int_t type)
284{
285 // Create a 2D histo RCU:Events indicating the there was a deviation
286 // from the mean L1 phase of the event
287 //
288 //type: 0=Failures, 1=Phases
289 TH2C *h2 = new TH2C("hL1FailRCUEvents","L1 Failures;RCU;Event",216,0,216,GetNevents(),0,GetNevents());
5312f439 290 Int_t add=0;
ddeb9c4f 291 for (Int_t ircu=0;ircu<216;++ircu) {
292 const TVectorF *v=0;
5312f439 293 if (type==0){
294 v=GetALTROL1PhaseFailEventsRCU(ircu);
295 add=1;
296 h2->SetMinimum(0);
297 h2->SetMaximum(2);
298 } else if (type==1) {
299 v=GetALTROL1PhaseEventsRCU(ircu);
300 add=0;
301 h2->SetMinimum(0);
302 h2->SetMaximum(4);
303 }
ddeb9c4f 304 if (!v) continue;
305 for (Int_t iev=0;iev<GetNevents();++iev) {
5312f439 306 h2->SetBinContent(ircu+1,iev+1,(*v)(iev)+add);
ddeb9c4f 307 }
308 }
309 return h2;
310}
311//_____________________________________________________________________
312TH2C *AliTPCCalibRaw::MakeHistL1RCUEventsIROC(Int_t type)
313{
314 //
315 // Create a 2D histo RCU:Events indicating the there was a deviation
316 // from the mean L1 phase of the event
317 //
318 TH2C *h2 = new TH2C("hL1FailRCUEventsIROC","L1 Failures IROCs;RCU;Event",72,0,36,GetNevents(),0,GetNevents());
319 for (Int_t ircu=0;ircu<72;++ircu) {
320 const TVectorF *v=0;
321 if (type==0) v=GetALTROL1PhaseFailEventsRCU(ircu);
322 else if (type==1) v=GetALTROL1PhaseEventsRCU(ircu);
323 if (!v) continue;
324 for (Int_t iev=0;iev<GetNevents();++iev) {
5312f439 325 h2->SetBinContent(ircu+1,iev+1,(*v)(iev));
ddeb9c4f 326 }
327 }
328 return h2;
329}
330//_____________________________________________________________________
331TH2C *AliTPCCalibRaw::MakeHistL1RCUEventsOROC(Int_t type)
332{
333 //
334 // Create a 2D histo RCU:Events indicating the there was a deviation
335 // from the mean L1 phase of the event
336 //
337 TH2C *h2 = new TH2C("hL1FailRCUEventsOROC","L1 Failures OROCs;RCU;Event",144,0,36,GetNevents(),0,GetNevents());
338 for (Int_t ircu=72;ircu<216;++ircu) {
339 const TVectorF *v=0;
340 if (type==0) v=GetALTROL1PhaseFailEventsRCU(ircu);
341 else if (type==1) v=GetALTROL1PhaseEventsRCU(ircu);
342 if (!v) continue;
343 for (Int_t iev=0;iev<GetNevents();++iev) {
5312f439 344 h2->SetBinContent(ircu-72+1,iev+1,(*v)(iev));
ddeb9c4f 345 }
346 }
347 return h2;
348}
349//_____________________________________________________________________
350void AliTPCCalibRaw::CreateDVhist()
351{
352 //
353 // Setup the HnSparse for the drift velocity determination
354 //
355 if (fHnDrift) return;
356 //HnSparse bins
357 //time bin, roc, time
f113dfeb 358 Int_t bins[kHnBinsDV] = {fLastTimeBin-fFirstTimeBin, 72, fNBinsTime};
359 Double_t xmin[kHnBinsDV] = {fFirstTimeBin,0,0};
360 Double_t xmax[kHnBinsDV] = {fLastTimeBin,72,fNBinsTime};
ddeb9c4f 361 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);
362
363}
364//_____________________________________________________________________
365void AliTPCCalibRaw::Analyse()
366{
367 //
368 // Analyse Data
369 //
370
371 //resize arrays
372 fArrALTROL1Phase.ResizeTo(GetNevents());
373 for (Int_t ircu=0;ircu<216;++ircu){
374 TVectorF *arr=MakeArrL1PhaseRCU(ircu);//MakeArrL1PhaseRCU(ircu);
375 if (!arr) continue;
376 TVectorF *arrF=MakeArrL1PhaseFailRCU(ircu);
377 arr->ResizeTo(GetNevents());
378 arrF->ResizeTo(GetNevents());
379 }
380
381 //Analyse drift velocity
382
383}
384