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 **************************************************************************/
18 ////////////////////////////////////////////////////////////////////////////////////////
20 // Implementation of the TPC Raw drift velocity and Altro L1 Phase calibration //
22 // Origin: Jens Wiechula, J.Wiechula@gsi.de //
24 ////////////////////////////////////////////////////////////////////////////////////////
27 // *************************************************************************************
28 // * Class Description *
29 // *************************************************************************************
33 TFile f("CalibAltro.root");
34 AliTPCCalibRaw *al=(AliTPCCalibRaw*)f.Get(f.GetListOfKeys()->At(0)->GetName())
36 TCanvas *c1=(TCanvas*)gROOT->FindObject("c1");
37 if (!c1) c1=new TCanvas("c1","c1");
40 TH2F h2f("h2","h2;RCU;fail",216,0,216,al->GetNevents(),0,al->GetNevents());
44 TVectorF *v=al->GetALTROL1PhaseFailEventsRCU(i);
46 for (iev=0;iev<al->GetNevents();++iev) {
47 h2f->SetBinContent(i+1,iev+1,(*v)(iev));
50 // h.SetLineColor(i/216.*50+50);
51 // ((TH1F*)h.Clone(Form("h%d",i)))->Draw(first?"":"same");
67 #include "AliTPCCalROC.h"
68 #include "AliAltroRawStream.h"
72 #include "AliTPCCalibRaw.h"
74 ClassImp(AliTPCCalibRaw)
76 AliTPCCalibRaw::AliTPCCalibRaw() :
82 fNSecTime(600), //default 10 minutes
83 fNBinsTime(60), //default 60*10 minutes = 10 hours
84 fPadProcessed(kFALSE),
95 fArrCurrentPhaseDist(4),
96 fArrALTROL1Phase(1000),
97 fArrALTROL1PhaseEvent(216),
98 fArrALTROL1PhaseFailEvent(216),
104 SetNameTitle("AliTPCCalibRaw","AliTPCCalibRaw");
109 //_____________________________________________________________________
110 AliTPCCalibRaw::~AliTPCCalibRaw()
117 //_____________________________________________________________________
118 // AliTPCCalibRaw& AliTPCCalibRaw::operator = (const AliTPCCalibRaw &source)
121 // // assignment operator
123 // if (&source == this) return *this;
124 // new (this) AliTPCCalibRaw(source);
129 //_____________________________________________________________________
130 Int_t AliTPCCalibRaw::Update(const Int_t isector, const Int_t iRow, const Int_t iPad,
131 const Int_t iTimeBin, const Float_t signal)
134 // Data filling method
136 if (iRow<0) return 0;
137 if (iPad<0) return 0;
138 if (iTimeBin<0) return 0;
139 if (!fFirstTimeStamp) fFirstTimeStamp=GetTimeStamp();
140 if (fCurrDDLNum!=fPrevDDLNum){
141 TVectorF *arr=MakeArrL1PhaseRCU(fCurrDDLNum,kTRUE);
142 if (arr->GetNrows()<=fNevents) arr->ResizeTo(arr->GetNrows()+1000);
143 // phase as a position of a quarter time bin
144 Int_t phase=(Int_t)(GetL1PhaseTB()*4.);
145 // printf("DDL: %03d, phase: %d (%f))\n",fCurrDDLNum,phase,GetL1PhaseTB());
146 //Fill pahse information of current rcu and event
147 (arr->GetMatrixArray())[fNevents]=phase;
148 //increase phase counter
149 ++((fArrCurrentPhaseDist.GetMatrixArray())[phase]);
150 // printf("RCUId: %03d (%03d), DDL: %03d, sector: %02d\n",fCurrRCUId, fPrevRCUId, fCurrDDLNum, isector);
153 if ( (iTimeBin>fLastTimeBin) || (iTimeBin<fFirstTimeBin) ) return 0;
154 //don't process edge pads
155 if (IsEdgePad(isector,iRow,iPad)) return 0;
156 // Double_t x[kHnBinsDV]={1,isector,0};
157 // fHnDrift->Fill(x);
158 Int_t iChannel = fROC->GetRowIndexes(isector)[iRow]+iPad; // global pad position in sector
159 if (fCurrentChannel==iChannel){
160 if (fPadProcessed) return 0;
162 fPadProcessed=kFALSE;
168 // Double_t x2[kHnBinsDV]={2,isector,0};
169 // fHnDrift->Fill(x2);
172 if (signal>fLastSignal) ++fNOkPlus;
173 else if(signal<fLastSignal && fNOkPlus>=fPeakDetPlus){
175 if (!fPeakTimeBin) fPeakTimeBin=fLastTimeBinProc;
176 if ( fNOkMinus>=fPeakDetMinus ) {
177 Double_t x[kHnBinsDV]={fPeakTimeBin,isector,(fTimeStamp-fFirstTimeStamp)/fNSecTime};
187 fLastTimeBinProc=iTimeBin;
188 fLastSignal=TMath::Nint(signal);
189 fCurrentChannel = iChannel;
192 //_____________________________________________________________________
193 void AliTPCCalibRaw::ResetEvent()
196 // Reset event counters
200 fArrCurrentPhaseDist.Zero();
202 //_____________________________________________________________________
203 void AliTPCCalibRaw::EndEvent()
206 // End event analysis
210 //find phase of the current event
211 Int_t phaseMaxEntries=-1;
213 for (Int_t i=0;i<fArrCurrentPhaseDist.GetNrows();++i){
214 Int_t entries=(Int_t)fArrCurrentPhaseDist[i];
215 if (maxEntries<entries) {
220 // store phase of current event
221 if (fArrALTROL1Phase.GetNrows()<=GetNevents())
222 fArrALTROL1Phase.ResizeTo(GetNevents()+1000);
223 (fArrALTROL1Phase.GetMatrixArray())[GetNevents()]=phaseMaxEntries;
225 //loop over RCUs and test failures
226 for (Int_t ircu=0;ircu<216;++ircu){
227 const TVectorF *arr=GetALTROL1PhaseEventsRCU(ircu);//MakeArrL1PhaseRCU(ircu);
229 TVectorF *arrF=MakeArrL1PhaseFailRCU(ircu,kTRUE);
230 if (arrF->GetNrows()<=fNevents) arrF->ResizeTo(arrF->GetNrows()+1000);
231 if ((arr->GetMatrixArray())[fNevents]!=phaseMaxEntries){
232 (arrF->GetMatrixArray())[fNevents]=1;
238 //_____________________________________________________________________
239 TH2C *AliTPCCalibRaw::MakeHistL1RCUEvents(Int_t type)
241 // Create a 2D histo RCU:Events indicating the there was a deviation
242 // from the mean L1 phase of the event
244 //type: 0=Failures, 1=Phases
245 TH2C *h2 = new TH2C("hL1FailRCUEvents","L1 Failures;RCU;Event",216,0,216,GetNevents(),0,GetNevents());
246 for (Int_t ircu=0;ircu<216;++ircu) {
248 if (type==0) v=GetALTROL1PhaseFailEventsRCU(ircu);
249 else if (type==1) v=GetALTROL1PhaseEventsRCU(ircu);
251 for (Int_t iev=0;iev<GetNevents();++iev) {
252 h2->SetBinContent(ircu+1,iev+1,(*v)(iev)+1);
257 //_____________________________________________________________________
258 TH2C *AliTPCCalibRaw::MakeHistL1RCUEventsIROC(Int_t type)
261 // Create a 2D histo RCU:Events indicating the there was a deviation
262 // from the mean L1 phase of the event
264 TH2C *h2 = new TH2C("hL1FailRCUEventsIROC","L1 Failures IROCs;RCU;Event",72,0,36,GetNevents(),0,GetNevents());
265 for (Int_t ircu=0;ircu<72;++ircu) {
267 if (type==0) v=GetALTROL1PhaseFailEventsRCU(ircu);
268 else if (type==1) v=GetALTROL1PhaseEventsRCU(ircu);
270 for (Int_t iev=0;iev<GetNevents();++iev) {
271 h2->SetBinContent(ircu+1,iev+1,(*v)(iev)+1);
276 //_____________________________________________________________________
277 TH2C *AliTPCCalibRaw::MakeHistL1RCUEventsOROC(Int_t type)
280 // Create a 2D histo RCU:Events indicating the there was a deviation
281 // from the mean L1 phase of the event
283 TH2C *h2 = new TH2C("hL1FailRCUEventsOROC","L1 Failures OROCs;RCU;Event",144,0,36,GetNevents(),0,GetNevents());
284 for (Int_t ircu=72;ircu<216;++ircu) {
286 if (type==0) v=GetALTROL1PhaseFailEventsRCU(ircu);
287 else if (type==1) v=GetALTROL1PhaseEventsRCU(ircu);
289 for (Int_t iev=0;iev<GetNevents();++iev) {
290 h2->SetBinContent(ircu-72+1,iev+1,(*v)(iev)+1);
295 //_____________________________________________________________________
296 void AliTPCCalibRaw::CreateDVhist()
299 // Setup the HnSparse for the drift velocity determination
301 if (fHnDrift) return;
303 //time bin, roc, time
304 Int_t bins[kHnBinsDV] = {1000, 72, fNBinsTime};
305 Double_t xmin[kHnBinsDV] = {0,0,0};
306 Double_t xmax[kHnBinsDV] = {1000,72,fNBinsTime};
307 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);
310 //_____________________________________________________________________
311 void AliTPCCalibRaw::Analyse()
318 fArrALTROL1Phase.ResizeTo(GetNevents());
319 for (Int_t ircu=0;ircu<216;++ircu){
320 TVectorF *arr=MakeArrL1PhaseRCU(ircu);//MakeArrL1PhaseRCU(ircu);
322 TVectorF *arrF=MakeArrL1PhaseFailRCU(ircu);
323 arr->ResizeTo(GetNevents());
324 arrF->ResizeTo(GetNevents());
327 //Analyse drift velocity