Adding AliTPCTracklet to the repository (M.Mager)
[u/mrichter/AliRoot.git] / TPC / AliTPCMonitor.cxx
CommitLineData
48265b32 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/*
17$Log$
fb3305d1 18Revision 1.3 2007/10/12 13:36:27 cvetan
19Coding convention fixes from Stefan
20
ca7b8371 21Revision 1.2 2007/09/18 09:44:45 cvetan
22Sorting out some issues concerning the compilation with and without DATE support
23
1954d2d0 24Revision 1.1 2007/09/17 10:23:31 cvetan
25New TPC monitoring package from Stefan Kniege. The monitoring package can be started by running TPCMonitor.C macro located in macros folder.
26
48265b32 27*/
28
ca7b8371 29////////////////////////////////////////////////////////////////////////
fb3305d1 30////
31//// AliTPCMonitor class
32////
33//// Main class for TPC Monitor
34//// Monitor can handle rootified data, files and online streams in DATE format.
35//// The monitor GUI is started by the macro TPCMonitor.C
36////
37//// In the The data are read in in two read cycles.
38//// If no sector is specified (sectorid==-1) all sectors are read and only the max value
39//// for each channel is stored in a global histogram for Side A and C.
40//// In this way the whole TPC can be read in at once.
41////
42//// If the sector is specified only one sector is read in and additional quantities
43//// e.g baseline and baseline rms are calculated and stored.
44////
45//// Author: Stefan Kniege, IKF, Frankfurt
46////
47////
ca7b8371 48/////////////////////////////////////////////////////////////////////////
49
50
51
52#include "AliLog.h"
53#include "AliTPCMonitor.h"
54#include "AliTPCMonitorMappingHandler.h"
55#include "AliTPCMonitorDateFile.h"
56#include "AliTPCMonitorDateFormat.h"
57#include "AliTPCMonitorAltro.h"
58#include "AliTPCMonitorFFT.h"
59#include "AliRawReaderRoot.h"
60#include "AliRawReader.h"
61#include "TH2F.h"
62#include "TF1.h"
63#include "TMath.h"
64#include "TCanvas.h"
65#include "TH3S.h"
66#include "TLegend.h"
67#include "TROOT.h"
68#include "TDirectory.h"
69#include "TSystem.h"
70#include "TPaveText.h"
71#include "TFile.h"
72#include <Riostream.h>
1954d2d0 73#include "AliTPCMonitorDateMonitor.h"
ca7b8371 74
48265b32 75ClassImp(AliTPCMonitor)
76
77//____________________________________________________________________________
ca7b8371 78AliTPCMonitor::AliTPCMonitor(char* name, char* title) :
79 AliTPCMonitorConfig(name,title),
80 fPad(new Int_t*[GetMaxHwAddr()]),
81 fPadMapHw(new Float_t[GetMaxHwAddr()]),
82 fPadMapRCU(new Int_t*[GetMaxHwAddr()]),
83 fHistIROC(0),
84 fHistOROC(0),
85 fHistIROCIndex(0),
86 fHistOROCIndex(0),
87 fHistIROCTime(0),
88 fHistOROCTime(0),
89 fHistIROCClone(0),
90 fHistOROCClone(0),
91 fHistIROCRMS(0),
92 fHistOROCRMS(0),
93 fHistIROCBASE(0),
94 fHistOROCBASE(0),
95 fHistIROCSUM(0),
96 fHistOROCSUM(0),
97 fHistChannelTime(0),
98 fHistAddrMapIndex(0),
99 fHistAddrMaxAdc(0),
100 fHistAddrBaseMean(0),
101 fHistAddrMaxAdcX(0),
102 fHistAddrAdcSum(0),
103 fHistAddrBaseRms(0),
104 fHistDistrSumIROC(0),
105 fHistDistrMaxIROC(0),
106 fHistDistrSumOROC(0),
107 fHistDistrMaxOROC(0),
108 fHistDistrBase2dIROC(0),
109 fHistDistrBase2dOROC(0),
110 fHistDistrBaseRmsIROC(0),
111 fHistDistrBaseMeanIROC(0),
112 fHistDistrBaseRmsOROC(0),
113 fHistDistrBaseMeanOROC(0),
114 fHistGlobalMaxA(0),
115 fHistGlobalMaxC(0),
116 fHistList(new TObjArray()),
117
118 fkNRowsIroc(63),
119 fkNRowsOroc(96),
120
121 fkNPadsIroc(110),
122 fkNPadsOroc(140),
123 fkNPadMinIroc(-55),
124 fkNPadMinOroc(-70),
125 fkNPadMaxIroc(55),
126 fkNPadMaxOroc(70),
127 fVerb(0),
128 fLastEv(0),
129 fEventNumber(0),
130 fEventNumberOld(0),
131 fDisableFit(0),
132 fExecGlob(0),
133 fExecPlaneMax(0),
134 fExecPadIrocRms(0),
135 fExecPadOrocRms(0),
136 fRunId(0),
137 fEqId(0),
138 fPadUsedRoc(-1),
139 fPadUsedHwAddr(-1),
140 fGdcId(0),
141 fLdcId(0),
142 fLdcIdOld(1),
143 fMapEqidsSec(new Int_t*[36]),
144 fMapEqidsRcu(new Int_t[1000]),
145 fMirror(1),
146 fChannelIter(0),
147 fMapHand(0),
148 fReaderROOT(0),
149 fReaderDATE(0),
150 fReaderDATEMon(0)
48265b32 151{
ca7b8371 152 // Constructor
48265b32 153
48265b32 154 for(Int_t i = 0; i<GetMaxHwAddr(); i++) { fPad[i] = new Int_t[GetTimeBins()];}
48265b32 155 for(Int_t i = 0; i<GetMaxHwAddr(); i++) { fPadMapRCU[i] = new Int_t[6];}
48265b32 156 for(Int_t i = 0; i<36; i++) { fMapEqidsSec[i] = new Int_t[6];}
ca7b8371 157
48265b32 158 if (gDirectory)
159 {
160 if (!gDirectory->GetList())
161 {
162 Warning("Build","Current directory is not a valid directory");
ca7b8371 163 return;
48265b32 164 }
165 AliTPCMonitor *hold = (AliTPCMonitor*)gDirectory->GetList()->FindObject(GetName());
166 if(hold)
167 {
168 Warning("Build","Replacing existing histogram: %s (Potential memory leak).",GetName());
169 gDirectory->GetList()->Remove(hold);
170 }
171 gDirectory->Append(this);
ca7b8371 172 }
173 CreateHistos();
174 SetEqIds();
48265b32 175
ca7b8371 176}
48265b32 177
ca7b8371 178//____________________________________________________________________________
179AliTPCMonitor::AliTPCMonitor(const AliTPCMonitor &monitor):
180 AliTPCMonitorConfig(monitor.GetName(),monitor.GetTitle()),
181 fPad(new Int_t*[GetMaxHwAddr()]),
182 fPadMapHw(new Float_t[GetMaxHwAddr()]),
183 fPadMapRCU(new Int_t*[GetMaxHwAddr()]),
184 fHistIROC(0),
185 fHistOROC(0),
186 fHistIROCIndex(0),
187 fHistOROCIndex(0),
188 fHistIROCTime(0),
189 fHistOROCTime(0),
190 fHistIROCClone(0),
191 fHistOROCClone(0),
192 fHistIROCRMS(0),
193 fHistOROCRMS(0),
194 fHistIROCBASE(0),
195 fHistOROCBASE(0),
196 fHistIROCSUM(0),
197 fHistOROCSUM(0),
198 fHistChannelTime(0),
199 fHistAddrMapIndex(0),
200 fHistAddrMaxAdc(0),
201 fHistAddrBaseMean(0),
202 fHistAddrMaxAdcX(0),
203 fHistAddrAdcSum(0),
204 fHistAddrBaseRms(0),
205 fHistDistrSumIROC(0),
206 fHistDistrMaxIROC(0),
207 fHistDistrSumOROC(0),
208 fHistDistrMaxOROC(0),
209 fHistDistrBase2dIROC(0),
210 fHistDistrBase2dOROC(0),
211 fHistDistrBaseRmsIROC(0),
212 fHistDistrBaseMeanIROC(0),
213 fHistDistrBaseRmsOROC(0),
214 fHistDistrBaseMeanOROC(0),
215 fHistGlobalMaxA(0),
216 fHistGlobalMaxC(0),
217 fHistList(new TObjArray()),
218 fkNRowsIroc(monitor.fkNRowsIroc),
219 fkNRowsOroc(monitor.fkNRowsOroc),
220 fkNPadsIroc(monitor.fkNPadsIroc),
221 fkNPadsOroc(monitor.fkNPadsOroc),
222 fkNPadMinIroc(monitor.fkNPadMinIroc),
223 fkNPadMinOroc(monitor.fkNPadMinOroc),
224 fkNPadMaxIroc(monitor.fkNPadMaxIroc),
225 fkNPadMaxOroc(monitor.fkNPadMaxOroc),
226 fVerb(monitor.fVerb),
227 fLastEv(monitor.fLastEv),
228 fEventNumber(monitor.fEventNumber),
229 fEventNumberOld(monitor.fEventNumberOld),
230 fDisableFit(monitor.fDisableFit),
231 fExecGlob(monitor.fExecGlob),
232 fExecPlaneMax(monitor.fExecPlaneMax),
233 fExecPadIrocRms(monitor.fExecPadIrocRms),
234 fExecPadOrocRms(monitor.fExecPadOrocRms),
235 fRunId(monitor.fRunId),
236 fEqId(monitor.fEqId),
237 fPadUsedRoc(monitor.fPadUsedRoc),
238 fPadUsedHwAddr(monitor.fPadUsedHwAddr),
239 fGdcId(monitor.fGdcId),
240 fLdcId(monitor.fLdcId),
241 fLdcIdOld(monitor.fLdcIdOld),
242 fMapEqidsSec(new Int_t*[36]),
243 fMapEqidsRcu(new Int_t[1000]),
244 fMirror(monitor.fMirror),
245 fChannelIter(monitor.fChannelIter),
246 fMapHand(monitor.fMapHand),
247 fReaderROOT(monitor.fReaderROOT),
248 fReaderDATE(monitor.fReaderDATE),
249 fReaderDATEMon(monitor.fReaderDATEMon)
250{
251 // copy constructor
252
253 fHistIROC=(TH2F*)monitor.fHistIROC->Clone(); fHistList->Add(fHistIROC);
254 fHistOROC=(TH2F*)monitor.fHistOROC->Clone(); fHistList->Add(fHistOROC);
255 fHistIROCIndex=(TH2S*)monitor.fHistIROCIndex->Clone(); fHistList->Add(fHistIROCIndex);
256 fHistOROCIndex=(TH2S*)monitor.fHistOROCIndex->Clone(); fHistList->Add(fHistOROCIndex);
257 fHistIROCTime=(TH2F*)monitor.fHistIROCTime->Clone(); fHistList->Add(fHistIROCTime);
258 fHistOROCTime=(TH2F*)monitor.fHistOROCTime->Clone(); fHistList->Add(fHistOROCTime);
259 fHistIROCClone=(TH2F*)monitor.fHistIROCClone->Clone(); fHistList->Add(fHistIROCClone);
260 fHistOROCClone=(TH2F*)monitor.fHistOROCClone->Clone(); fHistList->Add(fHistOROCClone);
261 fHistIROCRMS=(TH2F*)monitor.fHistIROCRMS->Clone(); fHistList->Add(fHistIROCRMS);
262 fHistOROCRMS=(TH2F*)monitor.fHistOROCRMS->Clone(); fHistList->Add(fHistOROCRMS);
263 fHistIROCBASE=(TH2F*)monitor.fHistIROCBASE->Clone(); fHistList->Add(fHistIROCBASE);
264 fHistOROCBASE=(TH2F*)monitor.fHistOROCBASE->Clone(); fHistList->Add(fHistOROCBASE);
265 fHistIROCSUM=(TH2F*)monitor.fHistIROCSUM->Clone(); fHistList->Add(fHistIROCSUM);
266 fHistOROCSUM=(TH2F*)monitor.fHistOROCSUM->Clone(); fHistList->Add(fHistOROCSUM);
267
268 fHistChannelTime=(TH2F*)monitor.fHistChannelTime->Clone(); fHistList->Add(fHistChannelTime);
269
270 fHistAddrMapIndex=(TH1F*)monitor.fHistAddrMapIndex->Clone(); fHistList->Add(fHistAddrMapIndex);
271 fHistAddrMaxAdc=(TH1F*)monitor.fHistAddrMaxAdc->Clone(); fHistList->Add(fHistAddrMaxAdc);
272 fHistAddrBaseMean=(TH1F*)monitor.fHistAddrBaseMean->Clone(); fHistList->Add(fHistAddrBaseMean);
273 fHistAddrMaxAdcX=(TH1F*)monitor.fHistAddrMaxAdcX->Clone(); fHistList->Add(fHistAddrMaxAdcX);
274 fHistAddrAdcSum=(TH1F*)monitor.fHistAddrAdcSum->Clone(); fHistList->Add(fHistAddrAdcSum);
275 fHistAddrBaseRms=(TH1F*)monitor.fHistAddrBaseRms->Clone(); fHistList->Add(fHistAddrBaseRms);
276
277
278 fHistDistrSumIROC=(TH1F*)monitor.fHistDistrSumIROC->Clone(); fHistList->Add(fHistDistrSumIROC);
279 fHistDistrMaxIROC=(TH1F*)monitor.fHistDistrMaxIROC->Clone(); fHistList->Add(fHistDistrMaxIROC);
280 fHistDistrSumOROC=(TH1F*)monitor.fHistDistrSumOROC->Clone(); fHistList->Add(fHistDistrSumOROC);
281 fHistDistrMaxOROC=(TH1F*)monitor.fHistDistrMaxOROC->Clone(); fHistList->Add(fHistDistrMaxOROC);
282
283 fHistDistrBase2dIROC=(TH2F*)monitor.fHistDistrBase2dIROC->Clone(); fHistList->Add(fHistDistrBase2dIROC);
284 fHistDistrBase2dOROC=(TH2F*)monitor.fHistDistrBase2dOROC->Clone(); fHistList->Add(fHistDistrBase2dOROC);
285 fHistDistrBaseRmsIROC=(TH1D*)monitor.fHistDistrBaseRmsIROC->Clone(); fHistList->Add(fHistDistrBaseRmsIROC);
286 fHistDistrBaseMeanIROC=(TH1D*)monitor.fHistDistrBaseMeanIROC->Clone(); fHistList->Add(fHistDistrBaseMeanIROC);
287 fHistDistrBaseRmsOROC=(TH1D*)monitor.fHistDistrBaseRmsOROC->Clone(); fHistList->Add(fHistDistrBaseRmsOROC);
288 fHistDistrBaseMeanOROC=(TH1D*)monitor.fHistDistrBaseMeanOROC->Clone(); fHistList->Add(fHistDistrBaseMeanOROC);
289
290 fHistGlobalMaxA=(TH2S*)monitor.fHistGlobalMaxA->Clone(); fHistList->Add(fHistGlobalMaxA);
291 fHistGlobalMaxC=(TH2S*)monitor.fHistGlobalMaxC->Clone(); fHistList->Add(fHistGlobalMaxC);
292
293 // fPad = new Int_t*[monitor.GetMaxHwAddr()];
294 for(Int_t i = 0; i<GetMaxHwAddr(); i++) { fPad[i] = new Int_t[monitor.GetTimeBins()];}
295
296 //fPadMapRCU = new Int_t*[monitor.GetMaxHwAddr()];
297 for(Int_t i = 0; i<monitor.GetMaxHwAddr(); i++) { fPadMapRCU[i] = new Int_t[6];}
298
299 //fPadMapHw = new Float_t[monitor.GetMaxHwAddr()];
300
301 //fMapEqidsRcu = new Int_t[1000];
302 //fMapEqidsSec = new Int_t*[36];
303 for(Int_t i = 0; i<36; i++) { fMapEqidsSec[i] = new Int_t[6];}
48265b32 304 SetEqIds();
ca7b8371 305
306 if (gDirectory)
307 {
308 if (!gDirectory->GetList())
309 {
310 Warning("Build","Current directory is not a valid directory");
311
312 }
313 else
314 {
315 AliTPCMonitor *hold = (AliTPCMonitor*)gDirectory->GetList()->FindObject(monitor.GetName());
316 if(hold)
317 {
318 Warning("Build","Replacing existing histogram: %s (Potential memory leak).",monitor.GetName());
319 gDirectory->GetList()->Remove(hold);
320 }
321 gDirectory->Append(this);
322 }
323 }
324}
325
326
327//____________________________________________________________________________
48265b32 328
ca7b8371 329AliTPCMonitor &AliTPCMonitor:: operator= (const AliTPCMonitor& monitor)
330{
331 // assigment operator
332 if(this!=&monitor)
333 {
334 ((AliTPCMonitorConfig *)this)->operator=(monitor);
335 fkNRowsIroc=monitor.fkNRowsIroc;
336 fkNRowsOroc=monitor.fkNRowsOroc;
337 fkNPadsIroc=monitor.fkNPadsIroc;
338 fkNPadsOroc=monitor.fkNPadsOroc;
339 fkNPadMinIroc=monitor.fkNPadMinIroc;
340 fkNPadMinOroc=monitor.fkNPadMinOroc;
341 fkNPadMaxIroc=monitor.fkNPadMaxIroc;
342 fkNPadMaxOroc=monitor.fkNPadMaxOroc;
343 fVerb=monitor.fVerb;
344 fLastEv=monitor.fLastEv;
345 fEventNumber=monitor.fEventNumber;
346 fEventNumberOld=monitor.fEventNumberOld;
347 fDisableFit=monitor.fDisableFit;
348 fExecGlob=monitor.fExecGlob;
349 fExecPlaneMax=monitor.fExecPlaneMax;
350 fExecPadIrocRms=monitor.fExecPadIrocRms;
351 fExecPadOrocRms=monitor.fExecPadOrocRms;
352 fRunId=monitor.fRunId;
353 fEqId=monitor.fEqId;
354 fPadUsedRoc=monitor.fPadUsedRoc;
355 fPadUsedHwAddr=monitor.fPadUsedHwAddr;
356 fGdcId=monitor.fGdcId;
357 fLdcId=monitor.fLdcId;
358 fLdcIdOld=monitor.fLdcIdOld;
359 fMapHand=monitor.fMapHand;
360 fReaderROOT=monitor.fReaderROOT;
361 fReaderDATE=monitor.fReaderDATE;
362
363
364 fHistList = new TObjArray();
365 fHistIROC=(TH2F*)monitor.fHistIROC->Clone(); fHistList->Add(fHistIROC);
366 fHistOROC=(TH2F*)monitor.fHistOROC->Clone(); fHistList->Add(fHistOROC);
367 fHistIROCIndex=(TH2S*)monitor.fHistIROCIndex->Clone(); fHistList->Add(fHistIROCIndex);
368 fHistOROCIndex=(TH2S*)monitor.fHistOROCIndex->Clone(); fHistList->Add(fHistOROCIndex);
369 fHistIROCTime=(TH2F*)monitor.fHistIROCTime->Clone(); fHistList->Add(fHistIROCTime);
370 fHistOROCTime=(TH2F*)monitor.fHistOROCTime->Clone(); fHistList->Add(fHistOROCTime);
371 fHistIROCClone=(TH2F*)monitor.fHistIROCClone->Clone(); fHistList->Add(fHistIROCClone);
372 fHistOROCClone=(TH2F*)monitor.fHistOROCClone->Clone(); fHistList->Add(fHistOROCClone);
373 fHistIROCRMS=(TH2F*)monitor.fHistIROCRMS->Clone(); fHistList->Add(fHistIROCRMS);
374 fHistOROCRMS=(TH2F*)monitor.fHistOROCRMS->Clone(); fHistList->Add(fHistOROCRMS);
375 fHistIROCBASE=(TH2F*)monitor.fHistIROCBASE->Clone(); fHistList->Add(fHistIROCBASE);
376 fHistOROCBASE=(TH2F*)monitor.fHistOROCBASE->Clone(); fHistList->Add(fHistOROCBASE);
377 fHistIROCSUM=(TH2F*)monitor.fHistIROCSUM->Clone(); fHistList->Add(fHistIROCSUM);
378 fHistOROCSUM=(TH2F*)monitor.fHistOROCSUM->Clone(); fHistList->Add(fHistOROCSUM);
379
380 fHistChannelTime=(TH2F*)monitor.fHistChannelTime->Clone(); fHistList->Add(fHistChannelTime);
381
382 fHistAddrMapIndex=(TH1F*)monitor.fHistAddrMapIndex->Clone(); fHistList->Add(fHistAddrMapIndex);
383 fHistAddrMaxAdc=(TH1F*)monitor.fHistAddrMaxAdc->Clone(); fHistList->Add(fHistAddrMaxAdc);
384 fHistAddrBaseMean=(TH1F*)monitor.fHistAddrBaseMean->Clone(); fHistList->Add(fHistAddrBaseMean);
385 fHistAddrMaxAdcX=(TH1F*)monitor.fHistAddrMaxAdcX->Clone(); fHistList->Add(fHistAddrMaxAdcX);
386 fHistAddrAdcSum=(TH1F*)monitor.fHistAddrAdcSum->Clone(); fHistList->Add(fHistAddrAdcSum);
387 fHistAddrBaseRms=(TH1F*)monitor.fHistAddrBaseRms->Clone(); fHistList->Add(fHistAddrBaseRms);
388
389
390 fHistDistrSumIROC=(TH1F*)monitor.fHistDistrSumIROC->Clone(); fHistList->Add(fHistDistrSumIROC);
391 fHistDistrMaxIROC=(TH1F*)monitor.fHistDistrMaxIROC->Clone(); fHistList->Add(fHistDistrMaxIROC);
392 fHistDistrSumOROC=(TH1F*)monitor.fHistDistrSumOROC->Clone(); fHistList->Add(fHistDistrSumOROC);
393 fHistDistrMaxOROC=(TH1F*)monitor.fHistDistrMaxOROC->Clone(); fHistList->Add(fHistDistrMaxOROC);
394
395 fHistDistrBase2dIROC=(TH2F*)monitor.fHistDistrBase2dIROC->Clone(); fHistList->Add(fHistDistrBase2dIROC);
396 fHistDistrBase2dOROC=(TH2F*)monitor.fHistDistrBase2dOROC->Clone(); fHistList->Add(fHistDistrBase2dOROC);
397 fHistDistrBaseRmsIROC=(TH1D*)monitor.fHistDistrBaseRmsIROC->Clone(); fHistList->Add(fHistDistrBaseRmsIROC);
398 fHistDistrBaseMeanIROC=(TH1D*)monitor.fHistDistrBaseMeanIROC->Clone(); fHistList->Add(fHistDistrBaseMeanIROC);
399 fHistDistrBaseRmsOROC=(TH1D*)monitor.fHistDistrBaseRmsOROC->Clone(); fHistList->Add(fHistDistrBaseRmsOROC);
400 fHistDistrBaseMeanOROC=(TH1D*)monitor.fHistDistrBaseMeanOROC->Clone(); fHistList->Add(fHistDistrBaseMeanOROC);
401
402 fHistGlobalMaxA=(TH2S*)monitor.fHistGlobalMaxA->Clone(); fHistList->Add(fHistGlobalMaxA);
403 fHistGlobalMaxC=(TH2S*)monitor.fHistGlobalMaxC->Clone(); fHistList->Add(fHistGlobalMaxC);
404
405 fPad = new Int_t*[monitor.GetMaxHwAddr()];
406 for(Int_t i = 0; i<GetMaxHwAddr(); i++) { fPad[i] = new Int_t[monitor.GetTimeBins()];}
407
408 fPadMapRCU = new Int_t*[monitor.GetMaxHwAddr()];
409 for(Int_t i = 0; i<monitor.GetMaxHwAddr(); i++) { fPadMapRCU[i] = new Int_t[6];}
410
411 fPadMapHw = new Float_t[monitor.GetMaxHwAddr()];
412
413 fMapEqidsRcu = new Int_t[1000];
414 fMapEqidsSec = new Int_t*[36];
415 for(Int_t i = 0; i<36; i++) { fMapEqidsSec[i] = new Int_t[6];}
416 SetEqIds();
417
418 if (gDirectory)
419 {
420 if (!gDirectory->GetList())
421 {
422 Warning("Build","Current directory is not a valid directory");
423 return *this;
424 }
425 AliTPCMonitor *hold = (AliTPCMonitor*)gDirectory->GetList()->FindObject(monitor.GetName());
426 if(hold)
427 {
428 Warning("Build","Replacing existing histogram: %s (Potential memory leak).",monitor.GetName());
429 gDirectory->GetList()->Remove(hold);
430 }
431 gDirectory->Append(this);
432 }
433 fReaderDATEMon=monitor.fReaderDATEMon;
434 }
435 return *this;
48265b32 436}
ca7b8371 437
438
48265b32 439//____________________________________________________________________________
440AliTPCMonitor::~AliTPCMonitor()
441{
442 // Destructor
443
444 for(Int_t i = 0; i<GetMaxHwAddr(); i++) { delete[] fPad[i] ;}
445 for(Int_t i = 0; i<GetMaxHwAddr(); i++) { delete[] fPadMapRCU[i];}
446 delete[] fPadMapHw ;
447 DeleteHistos();
448}
449
450//____________________________________________________________________________
451void AliTPCMonitor::CreateHistos()
452{
453 // Create histograms to be displayed
454
455 if(fVerb) cout << " create new ones " << endl;
ca7b8371 456 fHistIROC = new TH2F("fHistIROC" ,"fHistIROC" ,fkNRowsIroc,0,fkNRowsIroc,fkNPadsIroc, fkNPadMinIroc, fkNPadMaxIroc); fHistList->Add(fHistIROC);
457 fHistOROC = new TH2F("fHistOROC" ,"fHistOROC" ,fkNRowsOroc,0,fkNRowsOroc,fkNPadsOroc, fkNPadMinOroc, fkNPadMaxOroc); fHistList->Add(fHistOROC);
48265b32 458
ca7b8371 459 fHistIROCIndex = new TH2S("fHistIROCIndex" ,"fHistIROCIndex" ,fkNRowsIroc,0,fkNRowsIroc,fkNPadsIroc, fkNPadMinIroc, fkNPadMaxIroc); fHistList->Add(fHistIROCIndex);
460 fHistOROCIndex = new TH2S("fHistOROCIndex" ,"fHistOROCIndex" ,fkNRowsOroc,0,fkNRowsOroc,fkNPadsOroc, fkNPadMinOroc, fkNPadMaxOroc); fHistList->Add(fHistOROCIndex);
48265b32 461
ca7b8371 462 fHistIROCTime = new TH2F("fHistIROCTime" ,"fHistIROCTime" ,fkNRowsIroc,0,fkNRowsIroc,fkNPadsIroc, fkNPadMinIroc, fkNPadMaxIroc); fHistList->Add(fHistIROCTime);
463 fHistOROCTime = new TH2F("fHistOROCTime" ,"fHistOROCTime" ,fkNRowsOroc,0,fkNRowsOroc,fkNPadsOroc, fkNPadMinOroc, fkNPadMaxOroc); fHistList->Add(fHistOROCTime);
48265b32 464
ca7b8371 465 fHistIROCRMS = new TH2F("fHistIROCRMS" ,"fHistIROCRMS" ,fkNRowsIroc,0,fkNRowsIroc,fkNPadsIroc, fkNPadMinIroc, fkNPadMaxIroc); fHistList->Add(fHistIROCRMS);
466 fHistOROCRMS = new TH2F("fHistOROCRMS" ,"fHistOROCRMS" ,fkNRowsOroc,0,fkNRowsOroc,fkNPadsOroc, fkNPadMinOroc, fkNPadMaxOroc); fHistList->Add(fHistOROCRMS);
48265b32 467
ca7b8371 468 fHistIROCSUM = new TH2F("fHistIROCSUM" ,"fHistIROCSUM" ,fkNRowsIroc,0,fkNRowsIroc,fkNPadsIroc, fkNPadMinIroc, fkNPadMaxIroc); fHistList->Add(fHistIROCSUM);
469 fHistOROCSUM = new TH2F("fHistOROCSUM" ,"fHistOROCSUM" ,fkNRowsOroc,0,fkNRowsOroc,fkNPadsOroc, fkNPadMinOroc, fkNPadMaxOroc); fHistList->Add(fHistOROCSUM);
48265b32 470
ca7b8371 471 fHistIROCBASE = new TH2F("fHistIROCBASE" ,"fHistIROCBASE" ,fkNRowsIroc,0,fkNRowsIroc,fkNPadsIroc, fkNPadMinIroc, fkNPadMaxIroc); fHistList->Add(fHistIROCBASE);
472 fHistOROCBASE = new TH2F("fHistOROCBASE" ,"fHistOROCBASE" ,fkNRowsOroc,0,fkNRowsOroc,fkNPadsOroc, fkNPadMinOroc, fkNPadMaxOroc); fHistList->Add(fHistOROCBASE);
48265b32 473
474
475 fHistChannelTime = new TH2F("fHistChannelTime" ,"fHistChannelTime" ,GetNumOfChannels(),0,GetNumOfChannels(),GetTimeBins(),0,GetTimeBins());fHistList->Add(fHistChannelTime);
476 fHistAddrMapIndex = new TH1F("fHistAddrMapIndex" ,"fHistAddrMapIndex" ,GetMaxHwAddr() ,0,GetMaxHwAddr()); fHistList->Add(fHistAddrMapIndex);
477 fHistAddrMaxAdc = new TH1F("fHistAddrMaxAdc" ,"fHistAddrMaxAdc" ,GetMaxHwAddr(),0,GetMaxHwAddr()); fHistList->Add(fHistAddrMaxAdc);
478 fHistAddrMaxAdcX = new TH1F("fHistAddrMaxAdcX" ,"fHistAddrMaxAdcX" ,GetMaxHwAddr(),0,GetMaxHwAddr()); fHistList->Add(fHistAddrMaxAdcX);
479 fHistAddrBaseMean = new TH1F("fHistAddrBaseMean" ,"fHistAddrBaseMean" ,GetMaxHwAddr(),0,GetMaxHwAddr()); fHistList->Add(fHistAddrBaseMean);
480 fHistAddrAdcSum = new TH1F("fHistAddrAdcSum" ,"fHistAddrAdcSum" ,GetMaxHwAddr(),0,GetMaxHwAddr()); fHistList->Add(fHistAddrAdcSum);
481 fHistAddrBaseRms = new TH1F("fHistAddrBaseRms" ,"fHistAddrBaseRms" ,GetMaxHwAddr(),0,GetMaxHwAddr()); fHistList->Add(fHistAddrBaseRms);
482 fHistDistrSumIROC = new TH1F("fHistDistrSumIROC" ,"fHistDistrSumIROC" ,400,0.0,4000.0); fHistList->Add(fHistDistrSumIROC);
483 fHistDistrMaxIROC = new TH1F("fHistDistrMaxIROC" ,"fHistDistrMaxIROC" ,500,0.0,1000.0); fHistList->Add(fHistDistrMaxIROC);
484 fHistDistrSumOROC = new TH1F("fHistDistrSumOROC" ,"fHistDistrSumOROC" ,400,0.0,4000.0); fHistList->Add(fHistDistrSumOROC);
485 fHistDistrMaxOROC = new TH1F("fHistDistrMaxOROC" ,"fHistDistrMaxOROC" ,500,0.0,1000.0); fHistList->Add(fHistDistrMaxOROC);
486
487 fHistDistrBase2dIROC = new TH2F("fHistDistrBase2dIROC" ,"fHistDistrBase2dIROC",100,0.0,100.0,100,0.0,10.0); fHistList->Add(fHistDistrBase2dIROC);
488 fHistDistrBase2dOROC = new TH2F("fHistDistrBase2dOROC" ,"fHistDistrBase2dOROC",100,0.0,100.0,100,0.0,10.0); fHistList->Add(fHistDistrBase2dOROC);
489
490 fHistGlobalMaxA = new TH2S("SIDE A" ,"SIDE A" ,500,-3000,3000,500,-3000,3000); fHistList->Add(fHistGlobalMaxA);
491 fHistGlobalMaxC = new TH2S("SIDE C" ,"SIDE C" ,500,-3000,3000,500,-3000,3000); fHistList->Add(fHistGlobalMaxC);
492
493 ResetArrays();
494}
495//____________________________________________________________________________
496Int_t AliTPCMonitor::ProcessEvent()
497{
498 // Process Event
499 // Depending on the value of the sector id all sectors (sectorid == -1) are processed.
500 //
501 // In this case only the maximum values are calculated per pad and filled to the global histograms
502 // In a second loop the last processed(displayed) sector will be processed (sectorid!=-1)
503 // again and the baseline rms and further quantities are calculated
504 //
505 // If only one sector should be processed SetProcOneSector(1) should be set.
506 // In this case only the specified (last/last displayed) sector will be processed.
507 //
508 // If GetProcNextEvent()==0 the same event will be processed again
509
510
511 Int_t sectorid = 0;
512 Int_t retflag = 0; // id of last sector + 1000, or error flag
513 if(GetProcNextEvent()==1 && fLastEv) { AliInfo("Last event already processed"); }
514 if(GetProcNextEvent()==1) ResetSectorArray();
515
516
517 if(GetProcNextEvent()==0 || GetProcOneSector()==1 ) sectorid = GetLastSector();
518 else sectorid = -1;
519
520 // first iteration
521 retflag = ReadData(sectorid);
522
523 SetLastProcFile(GetFile());
524
525 if(retflag>=10 && retflag<1000){ AliError("Could not read event properly: Check file name and format or try next event"); return 0 ;}
526
527 DrawHists(3);
528
529 // second iteration
530 if(sectorid==-1 && retflag >1000)
531 {
532 AliInfo("Second read cycle");
533 SetProcNextEvent(0);
534 if(GetLastSectorDisplayed()==-1) {sectorid = GetLastSector() ; }
535 else {sectorid = GetLastSectorDisplayed(); SetLastSector(sectorid) ; }
536 retflag = ReadData(sectorid);
537 }
538
539 SetLastSectorDisplayed(sectorid) ;
540 fMapHand->ReadfecHwMap(GetLastSector());
541 FillHistsPadPlane();
542 DrawHists(1);
543 SetEventProcessed(1);
544 return retflag;
545}
546
547//__________________________________________________________________
548Int_t AliTPCMonitor::ReadData(Int_t secid)
549{
ca7b8371 550 // Read Data File/Stream for specified Format.
48265b32 551 // Payload will be extracted from either ROOT or DATE format
552 // and passed to FillHistsDecode for decoding of the adc information
553
554 Int_t format = GetFormat();
555
556
557 //if(format==2 && !gSystem->Getenv("DATE_ROOT")) { AliError("DATE not initialized on this system"); return 11;}
558
559 if( format==0) {return ReadDataROOT(secid);}
560 else if(format==1) {return ReadDataDATEFile(secid);}
561 else if(format==2)
562 {
48265b32 563 return ReadDataDATEStream(secid);
48265b32 564 }
565
566 AliWarning("Function should already be left");
567 return 11;
568}
569//__________________________________________________________________
570Int_t AliTPCMonitor::ReadDataDATEFile(Int_t secid)
571{
572 // Read Data in Date format.
573 // Date file and monitor will be handled in this function.
574
575 if(fReaderROOT) { delete fReaderROOT ; fReaderROOT=0;}
576
1954d2d0 577#ifdef ALI_DATE
48265b32 578 if(fReaderDATEMon) { delete fReaderDATEMon ; fReaderDATEMon=0;}
579#endif
580
581 Char_t* eventPtr = 0;
ca7b8371 582 AliTPCMonitorDateFormat* dateform = 0;
48265b32 583
584 // Create objects //
585 if( fReaderDATE==0 || ( fReaderDATE!=0 && (strcmp(GetLastProcFile(),GetFile())!=0) ) )
586 {
587 cout << " Create new DATE file "<< endl;
588 if(fReaderDATE) { delete fReaderDATE ; fReaderDATE=0; }
589 fReaderDATE = new AliTPCMonitorDateFile() ;
590 fReaderDATE->SetName("fReaderDATE") ;
591 fReaderDATE->OpenDateFile(GetFile()) ;
592 fEventNumber =0;
593 }
594
595 // Get Event pointer ///
596 if(fReaderDATE->IsDateFileOpen() ==false ) { AliError("Could not open Date File"); return 11 ; }
597 // Rewind event if new event number is smaller than old one
ca7b8371 598 if(fEventNumberOld>fEventNumber ) { fReaderDATE->ResetFilePos(); }
48265b32 599 while(GetProcNextEvent() || fEventNumber==0)
600 {
601 fReaderDATE->ReadEvent();
602 eventPtr = fReaderDATE->GetMemoryPointer();
ca7b8371 603 dateform = new AliTPCMonitorDateFormat(eventPtr);
604 Int_t currentev = dateform->GetEventID();
605 if(fEventNumber <= currentev ){ break; }
48265b32 606 }
ca7b8371 607
48265b32 608 eventPtr = fReaderDATE->GetMemoryPointer();
609
ca7b8371 610 if(dateform==0) dateform = new AliTPCMonitorDateFormat(eventPtr);
611 fEventNumber = dateform->GetEventID();
612 fEventNumberOld = dateform->GetEventID();
48265b32 613
614 if(fReaderDATE->IsLastEvent()) fLastEv =1;
ca7b8371 615 if(dateform->IsEventEndOfRun()) { AliInfo("Event is end of run: eventType END_OF_RUN "); }
48265b32 616
617 if(fReaderDATE->IsEventValid() == false ) {AliInfo("Skipping Event because invalid"); return 10; }
ca7b8371 618 if(dateform->IsEventPhysicsEvent() == false ) {AliInfo("Skipping Header/event because not Physics event"); return 12; }
48265b32 619
620 ResetHistos() ;
621
ca7b8371 622 Int_t lastrcu = ReadDataDATESubEventLoop(dateform,secid);
48265b32 623
ca7b8371 624 delete dateform;
48265b32 625 if(fVerb) cout << " last rcu " << lastrcu << endl;
626 return lastrcu;
627}
628
629
1954d2d0 630#ifdef ALI_DATE
48265b32 631//__________________________________________________________________
632Int_t AliTPCMonitor::ReadDataDATEStream(Int_t secid)
633{
634 // Read Data from DATE stream.
635 // Can also be used for DATE file.
636
637
638 if(fReaderROOT) { delete fReaderROOT ; fReaderROOT=0;}
639 if(fReaderDATE) { delete fReaderDATE ; fReaderDATE =0; }
640
641 Char_t* eventPtr = 0;
642
ca7b8371 643 AliTPCMonitorDateFormat* dateform =0 ;
48265b32 644
645 // Create objects ///
646 if((fReaderDATEMon==0 || ( fReaderDATEMon!=0 && (strcmp(GetLastProcFile(),GetFile())!=0) )))
647 {
648 if(fReaderDATEMon!=0)
649 {
650 fReaderDATEMon->Logout();
651 delete fReaderDATEMon;
652 }
653 fReaderDATEMon = new AliTPCMonitorDateMonitor();
654 fReaderDATEMon->SetName("DMon");
655 Int_t status = fReaderDATEMon->OpenMonitoring(GetFile());
656 if(status) { AliError(Form("Could not read event online: Error: %s",fReaderDATEMon->DecodeError(status))); return 11; }
657 }
658
659 if(GetProcNextEvent())
660 {
661 fReaderDATEMon->Free();
662 Int_t status = fReaderDATEMon->GetEvent();
663 if(status) { AliError(Form("Could not read event online: Error: %s",fReaderDATEMon->DecodeError(status))); return 11 ;}
664 //fReaderDATEMon->Logout();
665 }
666
667 eventPtr = fReaderDATEMon->GetEventPointerasChar();
668
ca7b8371 669 if(dateform==0) dateform = new AliTPCMonitorDateFormat(eventPtr);
670 fEventNumber = dateform->GetEventID();
671 fEventNumberOld = dateform->GetEventID();
48265b32 672
ca7b8371 673 if(dateform->IsEventEndOfRun()) { AliInfo("Event is end of run: eventType END_OF_RUN "); }
674 if(dateform->IsEventPhysicsEvent() == false ) {AliInfo("Skipping Header/event because not Physics event"); return 12; }
48265b32 675
676 ResetHistos() ;
677
ca7b8371 678 Int_t lastrcu = ReadDataDATESubEventLoop(dateform,secid);
48265b32 679
ca7b8371 680 delete dateform;
48265b32 681 if(fVerb) cout << " last rcu " << lastrcu << endl;
682 return lastrcu;
683}
1954d2d0 684#else
685//__________________________________________________________________
686Int_t AliTPCMonitor::ReadDataDATEStream(Int_t /*secid*/)
687{
688 // Read Data from DATE stream.
689 // Can also be used for DATE file.
690 // In case DATE is not install
691 // this method is dummy
692
693 AliError("DATE not initialized on this system");
694 return 11;
695}
48265b32 696#endif
697
ca7b8371 698Int_t AliTPCMonitor::ReadDataDATESubEventLoop(AliTPCMonitorDateFormat* dateform, Int_t secid)
48265b32 699{
700 // Loop over DATE Subevents
701
702 Bool_t exitSubEventLoop = false;
ca7b8371 703 Int_t lastrcuid = 0;
704 Int_t lasteq = 0;
48265b32 705 Int_t start = 1;
ca7b8371 706 Int_t rcupatch = 0;
48265b32 707 Char_t* eventPtr = 0;
708 UInt_t* eventPtrUI = 0;
709
710 fChannelIter =0;
711
712 while(exitSubEventLoop == false)
713 {
ca7b8371 714 if(start==1) { dateform->GotoSubEventHeader() ; start=0;}
715 else { dateform->GotoNextSubEventHeader(); }
716 if(dateform->IsLastSubEventHeader()) exitSubEventLoop = true;
48265b32 717
ca7b8371 718 if(fVerb) cout << " next subevent LDC " << (Int_t)dateform->GetSubEventLDC() << endl;
48265b32 719
ca7b8371 720 lasteq = 0 ;
48265b32 721 Int_t neq = 0 ;
722
ca7b8371 723 while(lasteq==0)
48265b32 724 {
ca7b8371 725 if(neq ==0){ dateform->GotoFirstEquipment();}
726 else { dateform->GotoNextEquipment();}
48265b32 727
ca7b8371 728 fGdcId = dateform->GetSubEventGDC() ;
729 fLdcId = dateform->GetSubEventLDC();
730 fRunId = dateform->GetEventRunID();
731 fEqId = dateform->GetEquipmentID();
732 rcupatch = GetRCUPatch(fRunId, fEqId);
733 lastrcuid = (rcupatch+1000);
48265b32 734 neq++;
735
736 if(fLdcIdOld!=fLdcId && fChannelIter!=0) {
737 if(secid==-1)
738 {
739 FillGlobal(GetLastSector());
740 ResetArrays();
741 fChannelIter =0;
742 }
743 else
744 {
ca7b8371 745 return lastrcuid;
48265b32 746 }
747 }
748 fLdcIdOld = fLdcId ;
749
750
ca7b8371 751 if(dateform->IsLastEquipment() != false ) lasteq = 1;
48265b32 752
ca7b8371 753 eventPtr = dateform->GetFirstDataPointer();
48265b32 754 eventPtrUI = (UInt_t *) eventPtr;
ca7b8371 755 Int_t payload = dateform->GetPayloadSize();
48265b32 756
ca7b8371 757 if(fVerb)DumpHeader(dateform);
48265b32 758 if(fVerb) cout << "Check sector and fEqId " << endl;
759
760 if(fVerb && secid >0 )
761 {
762 cout << "secid : "<< secid << " fEqId "<< fEqId << " equipment 0 form map " << endl;
763 cout << fMapEqidsSec[secid][0] << endl;
764 cout << " showed map_eqids " << endl;
765 }
766
767 if(CheckEqId(secid,fEqId))
768 {
769 if(fVerb) cout << " init altro " << endl;
770 AliTPCMonitorAltro* altro = new AliTPCMonitorAltro((UInt_t *)eventPtrUI,(payload/4),1);
771 altro->SetWrite10Bit(GetWrite10Bit());
772 altro->SetActFilename(GetFile());
773 if(fVerb) cout << " allocated 10bit " << endl;
774 altro->Allocate10BitArray();
775 altro->Decodeto10Bit(fEqId);
ca7b8371 776 AliInfo(Form("Process eqid %i , patch %i ",fEqId,rcupatch%6));
777 FillHistsDecode(altro,(rcupatch%6),secid);
778 if(fChannelIter!=0 && secid==-1 ) SetSectorFilled(rcupatch/6);
48265b32 779 delete altro;
780 }// if(CheckID)
781 }// while last eq
ca7b8371 782 SetLastSector(rcupatch/6);
48265b32 783 }
784 if(fChannelIter!=0 && secid==-1){ FillGlobal(GetLastSector()); }
ca7b8371 785 return lastrcuid;
48265b32 786
787}
788//__________________________________________________________________
789Int_t AliTPCMonitor::ReadDataROOT(Int_t secid)
790{
791 // Read in data in ROOT format
792 if(fReaderDATE){ delete fReaderDATE ; fReaderDATE=0;}
793 fChannelIter =0;
ca7b8371 794 Int_t lastrcuid = 0;
795 Int_t rcupatch = 0;
48265b32 796 Int_t equipmentSize = 0;
797 UChar_t* eventPtr = 0 ;
798 UInt_t* eventPtrUI = 0 ;
799 Int_t evtype = 0;
800
801 if(fReaderROOT==0 || ( fReaderROOT!=0 && (strcmp(GetLastProcFile(),GetFile())!=0) ) )
ca7b8371 802 {
48265b32 803 if(fVerb) cout << "AliTPCMonitor::ReadDataROOT create new reader " << endl;
804 if(fReaderROOT) { delete fReaderROOT ; fReaderROOT=0; }
ca7b8371 805 fReaderROOT = new AliRawReaderRoot(GetFile());
48265b32 806 if(!fReaderROOT) { AliError("Could not initiate AliRawReaderRoo "); return 10;}
807 fEventNumber=0;
808 }
809
810 // reset to beginning of the event
811 fReaderROOT->Reset();
812
813 // Rewind event if new event number is smaller than old one
814 if(fEventNumberOld>fEventNumber) fReaderROOT->RewindEvents();
815
816 while(GetProcNextEvent() || fEventNumber==0)
817 {
818 if(fVerb) cout << "AliTPCMonitor::ReadDataROOT get event " << endl;
819 if(!fReaderROOT->NextEvent()) { AliError("Could not get next Event"); return 11 ;}
ca7b8371 820 Int_t currentev = *(fReaderROOT->GetEventId());
48265b32 821
ca7b8371 822 if(fEventNumber <= currentev ){ break; }
48265b32 823 }
824
825 fEventNumber = *(fReaderROOT->GetEventId());
826 fEventNumberOld = *(fReaderROOT->GetEventId());
827
828 ResetHistos() ;
829
830 while(fReaderROOT->ReadHeader())
831 {
832 if(fVerb) cout << "AliTPCMonitor::ReadDataROOT read header " << endl;
833 fGdcId = fReaderROOT->GetGDCId() ;
834 fLdcId = fReaderROOT->GetLDCId() ;
835 fRunId = fReaderROOT->GetRunNumber() ;
836 equipmentSize = fReaderROOT->GetEquipmentSize();
837 fEqId = fReaderROOT->GetEquipmentId();
838 evtype = fReaderROOT->GetType();
ca7b8371 839 rcupatch = GetRCUPatch(fRunId, fEqId);
840 lastrcuid = (rcupatch+1000);
48265b32 841
842 if(evtype==1) { AliWarning(Form("EventType==1 in event %i ",fEventNumber)); return 10; }
843 if(equipmentSize==0) { AliWarning(Form("Equipmentsize ==0 in event %i ",fEventNumber)); return 10; }
844
845 if(fVerb) DumpHeader(fReaderROOT);
846
847 if(fLdcIdOld!=fLdcId && fChannelIter!=0) {
848 if(secid==-1)
849 {
850 FillGlobal(GetLastSector());
851 ResetArrays();
852 fChannelIter =0;
853 }
854 else
855 {
ca7b8371 856 return lastrcuid;
48265b32 857 }
858 }
859 fLdcIdOld = fLdcId ;
860
861 if(CheckEqId(secid,fEqId))
862 {
863 fReaderROOT->ReadNextData(eventPtr);
864 eventPtrUI = (UInt_t *) eventPtr;
865 Int_t offset = 16;
866 Int_t fsize = (Int_t)((equipmentSize/4) -offset) +1;
867 AliTPCMonitorAltro* altro = new AliTPCMonitorAltro((UInt_t *)eventPtrUI,fsize,2);
868 altro->SetWrite10Bit(GetWrite10Bit());
869 if(fVerb) cout << "AliTPCMonitor::ReadDataROOT Set Write10bit to " << GetWrite10Bit() << endl;
870 altro->SetActFilename(GetFile());
871 altro->Allocate10BitArray();
872 altro->Decodeto10Bit(fEqId);
ca7b8371 873 AliInfo(Form("Process sector %i eqid %i , patch %i ",rcupatch/6,fEqId,rcupatch%6));
874 FillHistsDecode(altro,(rcupatch%6),secid);
875 if(fChannelIter!=0 && secid==-1 ) SetSectorFilled(rcupatch/6);
48265b32 876 delete altro;
877 }
ca7b8371 878 SetLastSector(rcupatch/6);
48265b32 879 }
880 if(fChannelIter!=0 && secid==-1) { FillGlobal(GetLastSector()); }
ca7b8371 881 return lastrcuid;
48265b32 882}
883
884
885//____________________________________________________________________________
ca7b8371 886void AliTPCMonitor::FillHistsDecode(AliTPCMonitorAltro* altro ,Int_t rcupatch, Int_t secid)
48265b32 887{
888 // Decode Channels, calculate base mean and rms depending on the
889 // value of secid (see ProcessEvent) and fill histograms
890
891
ca7b8371 892 if(fVerb) cout << "FillHistsDecode : rcupatch " << rcupatch << " id " << secid << endl;
893 Int_t timestamp = 0;
894 Int_t sampleiter = 0;
895 Int_t samplelength = 0;
896 Int_t samplebins = 0;
48265b32 897 Float_t max = 0;
ca7b8371 898 Float_t maxx = 0;
48265b32 899 Float_t sum = 0.0;
900 Int_t sumn = 0;
ca7b8371 901 Int_t blockpos = 0;
48265b32 902 Int_t hw = 0;
903 Int_t nwords = 0;
904 Int_t nextHwAddress = 0;
905 Int_t ntime = 0;
906 Int_t adc = 0;
907 Int_t nextpos = 0;
908 Int_t lastpos = altro->Get10BitArraySize()-1;
909 Short_t* entries = altro->Get10BitArray();
ca7b8371 910 Double_t hrms = 0.0;
911 Double_t hmean = 0.0;
48265b32 912 Int_t supnextpos = 0;
913 TH1D* hbase = new TH1D("hbase","hbase",GetTimeBins(),0.5,(GetTimeBins()+0.5));
914
915 while(lastpos>0)
916 {
917 nextpos = altro->DecodeTrailer(lastpos);
918 supnextpos = altro->GetNextTrailerPos();
919 if(nextpos==-1) { break; }
920
921 lastpos = nextpos;
ca7b8371 922 blockpos = altro->GetTrailerBlockPos();
48265b32 923 hw = altro->GetTrailerHwAddress();
924 nwords = altro->GetTrailerNWords();
ca7b8371 925 nextHwAddress = ( hw + (rcupatch<<12) );
48265b32 926 fPad[fChannelIter][0] = nextHwAddress ;
927
928 if(fPadMapHw[nextHwAddress]!=-1 )
929 {
930 //Int_t hw_before1 = fPad[fChannelIter-2][0];
931 //Int_t hw_before2 = fPad[fChannelIter-3][0];
932
933 if(fVerb){ cout <<"\n //// Ambiguous hwaddress " << nextHwAddress << " write 10bit files and check file for eqid : " << fEqId << " /////// " << endl;}
934
935 if( TMath::Abs(fPadMapRCU[nextHwAddress][4] - fChannelIter)==1)
936 {
937 if(fVerb) cout << "//// Difference to previous channel==1 : reset branch bit of hw from last channel to 1 " << endl;
938 Int_t hwreset = (nextHwAddress + (1<<11));
939 fPad[fChannelIter-1][0] = hwreset;
940
941 fPadMapHw[hwreset] = fChannelIter-1 ;
ca7b8371 942 fPadMapRCU[hwreset][0]= rcupatch ;
48265b32 943 fPadMapRCU[hwreset][1]= ((hwreset & AliTPCMonitorAltro::GetHwMaskBranch()) >> 11);
944 fPadMapRCU[hwreset][2]= ((hwreset & AliTPCMonitorAltro::GetHwMaskFEC()) >>7 );
945 fPadMapRCU[hwreset][3]= ( hwreset & AliTPCMonitorAltro::GetHwMaskFECChannel() );
946 fPadMapRCU[hwreset][4]= fChannelIter-1;
947 fPadMapRCU[hwreset][5]= altro->GetTrailerPos();
948 }
949 }
950
951 fPadMapHw[nextHwAddress] = fChannelIter ;
ca7b8371 952 fPadMapRCU[nextHwAddress][0]= rcupatch ;
48265b32 953 fPadMapRCU[nextHwAddress][1]= ((nextHwAddress & AliTPCMonitorAltro::GetHwMaskBranch())>> 11) ;
954 fPadMapRCU[nextHwAddress][2]= ((nextHwAddress & AliTPCMonitorAltro::GetHwMaskFEC()) >>7);
955 fPadMapRCU[nextHwAddress][3]= (nextHwAddress & AliTPCMonitorAltro::GetHwMaskFECChannel());
956 fPadMapRCU[nextHwAddress][4]= fChannelIter;
957 fPadMapRCU[nextHwAddress][5]= altro->GetTrailerPos();
958
ca7b8371 959 timestamp = 0;
960 sampleiter = 0;
961 samplelength = 0;
962 samplebins = 0;
48265b32 963
964 max = 0.0;
ca7b8371 965 maxx = 0.0;
48265b32 966 sum = 0.0;
967 sumn = 0;
968
969 hbase->Reset();
970
ca7b8371 971 for(Int_t iterwords = 0 ; iterwords< nwords ; iterwords++)
48265b32 972 {
ca7b8371 973 if(entries[blockpos-iterwords]==682) { continue; }
974 if(entries[blockpos-iterwords]!=682 && sampleiter==0)
48265b32 975 {
ca7b8371 976 samplelength = entries[blockpos-iterwords];
977 sampleiter = samplelength;
978 samplebins = 0;
979 timestamp = entries[blockpos-iterwords-1];
980 iterwords++;
48265b32 981 }
982 else
983 {
ca7b8371 984 ntime = timestamp-samplebins;
985 adc = entries[blockpos-iterwords];
48265b32 986 fPad[fChannelIter][ntime] = adc;
987 if( (adc!=0) && (ntime>=GetRangeBaseMin() ) && (ntime<GetRangeBaseMax() )) {hbase->Fill(adc) ;}
ca7b8371 988 if( (adc>max) && (ntime>=GetRangeMaxAdcMin()) && (ntime<GetRangeMaxAdcMax() )) {max = adc;maxx = ntime ;}
48265b32 989 if( (ntime>=GetRangeSumMin()) && (ntime<GetRangeSumMax() )) {sum+=adc; sumn++;}
ca7b8371 990 samplebins++;
48265b32 991 }
992 }
993
ca7b8371 994 hmean = hbase->GetMean();
995 hbase->GetXaxis()->SetRangeUser(hmean- hmean/3 , hmean + hmean/3);
996 hmean = hbase->GetMean();
997 hrms = hbase->GetRMS();
48265b32 998
ca7b8371 999 if( GetPedestals()==1) fHistAddrMaxAdc->SetBinContent( nextHwAddress,max- hmean);
48265b32 1000 else fHistAddrMaxAdc->SetBinContent( nextHwAddress,max );
1001
1002 if(secid!=-1)
1003 {
ca7b8371 1004 if(rcupatch<2)
48265b32 1005 {
ca7b8371 1006 fHistDistrBase2dIROC->Fill(hmean,hrms);
48265b32 1007 fHistDistrSumIROC->Fill(sum);
ca7b8371 1008 if( GetPedestals()==1 ) { fHistDistrMaxIROC->Fill(max-hmean); fHistDistrSumIROC->Fill(sum -sumn*hmean);}
48265b32 1009 else { fHistDistrMaxIROC->Fill(max); fHistDistrSumIROC->Fill(sum );}
1010 }
1011 else
1012 {
ca7b8371 1013 fHistDistrBase2dOROC->Fill(hmean,hrms);
48265b32 1014 fHistDistrSumOROC->Fill(sum);
ca7b8371 1015 if( GetPedestals()==1 ){ fHistDistrMaxOROC->Fill(max-hmean); fHistDistrSumOROC->Fill(sum -sumn*hmean);}
48265b32 1016 else { fHistDistrMaxOROC->Fill(max); fHistDistrSumOROC->Fill(sum) ;}
1017 }
1018
1019 fHistAddrAdcSum->SetBinContent( nextHwAddress,sum);
1020 fHistAddrMapIndex->SetBinContent(nextHwAddress,fChannelIter);
ca7b8371 1021 fHistAddrBaseMean->SetBinContent(nextHwAddress,hmean);
1022 fHistAddrMaxAdcX->SetBinContent( nextHwAddress,maxx);
1023 fHistAddrBaseRms->SetBinContent( nextHwAddress,hrms);
48265b32 1024 }
1025 fChannelIter++;
1026 if(nextpos<0) { AliError("Error : next pos < 0 "); break ;}
1027 }
1028 delete hbase;
1029 return ;
1030}
1031
1032
1033//____________________________________________________________________________
1034void AliTPCMonitor::FillHistsPadPlane()
1035{
1036 // Fill 2Dim histograms for IROC and OROC (max , rms and sum)
1037
1038 if(fVerb)cout << "AliTPCMonitor::FillHistsPadPlane() Start " << endl;
1039 if(fVerb)PrintConfig();
1040
1041 Int_t pad = 0;
1042 Int_t row = 0;
1043 Int_t padmax = 0;
1044 Int_t hwadd = 0;
1045
1046 for(Int_t ch = 0; ch<fChannelIter; ch++)
1047 {
1048 hwadd= fPad[ch][0];
1049 fHistChannelTime->SetCellContent(ch,0,hwadd);
1050
1051 for(Int_t bin = 1; bin <GetTimeBins(); bin++)
1052 {
1053 if( fHistChannelTime->GetCellContent(ch,bin)!=0) cout << " cellcontent already set " << endl;
1054 if( GetPedestals()==1 ) fHistChannelTime->SetCellContent(ch,bin,(fPad[ch][bin]- fHistAddrBaseMean->GetBinContent(hwadd)));
1055 else fHistChannelTime->SetCellContent(ch,bin,(fPad[ch][bin]));
1056 }
1057
1058 pad = fMapHand->GetPad( hwadd);
1059 row = fMapHand->GetPadRow(hwadd);
1060 padmax = fMapHand->GetNumofPads(row);
1061
1062 if(row<63)
1063 {
1064 fHistIROC->SetCellContent( row +1 ,pad +55 -padmax/2 +1,fHistAddrMaxAdc->GetBinContent( hwadd));
1065 fHistIROCIndex->SetCellContent(row +1 ,pad +55 -padmax/2 +1,ch);
1066 fHistIROCRMS->SetCellContent( row +1 ,pad +55 -padmax/2 +1,fHistAddrBaseRms->GetBinContent( hwadd));
1067 fHistIROCBASE->SetCellContent( row +1 ,pad +55 -padmax/2 +1,fHistAddrBaseMean->GetBinContent(hwadd));
1068 fHistIROCSUM->SetCellContent( row +1 ,pad +55 -padmax/2 +1,fHistAddrAdcSum->GetBinContent( hwadd));
1069 }
1070 else
1071 {
1072 fHistOROC->SetCellContent( row-63 +1 ,pad +70 -padmax/2 +1,fHistAddrMaxAdc->GetBinContent( hwadd));
1073 fHistOROCIndex->SetCellContent(row-63 +1 ,pad +70 -padmax/2 +1,ch);
1074 fHistOROCRMS->SetCellContent( row-63 +1 ,pad +70 -padmax/2 +1,fHistAddrBaseRms->GetBinContent( hwadd));
1075 fHistOROCBASE->SetCellContent( row-63 +1 ,pad +70 -padmax/2 +1,fHistAddrBaseMean->GetBinContent(hwadd));
1076 fHistOROCSUM->SetCellContent( row-63 +1 ,pad +70 -padmax/2 +1,fHistAddrAdcSum->GetBinContent( hwadd));
1077 }
1078 }
1079
1080 fHistChannelTime->GetXaxis()->SetRange(0,fChannelIter);
1081 fHistChannelTime->GetYaxis()->SetRange(0,GetTimeBins());
1082}
1083
1084
1085
1086//____________________________________________________________________________
1087void AliTPCMonitor::ResetArrays()
1088{
1089 // Reset data arrays
ca7b8371 1090 for(Int_t row = 0 ; row < fkNRowsIroc; row++)
48265b32 1091 {
ca7b8371 1092 for(Int_t pad = 0 ; pad < fkNPadsIroc ; pad++)
48265b32 1093 {
1094 fHistIROCIndex->SetCellContent(row+1,pad+1,-1);
1095 }
1096 }
ca7b8371 1097 for(Int_t row = 0 ; row < fkNRowsOroc; row++)
48265b32 1098 {
ca7b8371 1099 for(Int_t pad = 0 ; pad < fkNPadsOroc ; pad++)
48265b32 1100 {
1101 fHistOROCIndex->SetCellContent(row+1,pad+1,-1);
1102 }
1103 }
1104
1105 for(Int_t ch= 0; ch<GetMaxHwAddr(); ch++)
1106 {
1107 fHistAddrMaxAdcX->SetBinContent(ch,-1);
1108 fHistAddrMapIndex->SetBinContent(ch,-1);
1109 fHistAddrMaxAdc->SetBinContent( ch, 0);
1110 fHistAddrBaseMean->SetBinContent( ch, 0);
1111 fHistAddrAdcSum->SetBinContent( ch, 0);
1112 fHistAddrBaseRms->SetBinContent(ch, 0);
1113 }
1114
1115 for(Int_t ch = 0; ch< GetNumOfChannels(); ch++)
1116 {
1117 for(Int_t bin = 0; bin< GetTimeBins(); bin++)
1118 {
1119 fPad[ch][bin] = 0;
1120 }
1121 }
1122 for(Int_t ch = 0; ch< GetMaxHwAddr(); ch++)
1123 {
1124 fPadMapHw[ch]=-1;
1125 fPadMapRCU[ch][0]=-1;
1126 fPadMapRCU[ch][1]=-1;
1127 fPadMapRCU[ch][2]=-1;
1128 fPadMapRCU[ch][3]=-1;
1129 fPadMapRCU[ch][4]=-1;
1130 fPadMapRCU[ch][5]=-1;
1131 }
1132 fPadUsedHwAddr=-1;
1133}
1134
1135
1136//____________________________________________________________________________
1137void AliTPCMonitor::ResetHistos()
1138{
1139 // Reset all but
1140 for(Int_t i =0; i<fHistList->GetEntries(); i++)
1141 {
1142 if(GetProcNextEvent()==0 && strcmp(((TH1*)fHistList->At(i))->GetName(),"SIDE A")==0) continue;
1143 if(GetProcNextEvent()==0 && strcmp(((TH1*)fHistList->At(i))->GetName(),"SIDE C")==0) continue;
1144 ((TH1*)fHistList->At(i))->Reset();
1145 }
1146 ResetArrays();
1147}
1148
1149//____________________________________________________________________________
1150void AliTPCMonitor::DeleteHistos()
1151{
1152 // Delete histograms
1153 for(Int_t i =0; i<fHistList->GetEntries(); i++)
1154 {
1155 delete (TH1*)fHistList->At(i);
1156 }
1157}
1158
1159
1160//__________________________________________________________________
1161Int_t AliTPCMonitor::CheckEqId(Int_t secid,Int_t eqid)
1162{
1163 // Check if equipment id corresponds to any rcu patch in sector
1164 // Equipment ids changed during commisioning in 2006 (starting from run 704)
1165 // However Runids started from 0 again in 2007
1166 // Now only runids from commissioning in 2006 after runid 704 and all new ones are supported.
1167 // Comment in equipment check for runids < 704 if old runs should be processed
1168
1169 if(fVerb) cout << "AliTPCMonitor::CheckEqId : SectorId " << secid << " EquipmentId " << eqid << " runid " << fRunId << endl;
1170 Int_t passed =1;
1171 if(fRunId<704 && 0) // commented out --> runs with runid < 704 in 2006 are not recognized anymore
1172 {
1173 if( (secid>-1) && (secid<36) ) // if ( secid is in range) { take only specific eqids} else { take all }
1174 {
1175 if( (secid==13) && ( eqid!=408 && eqid!=409 && eqid!=509 && eqid!=512 && eqid!=513 && eqid!=517 )) {passed=0;}
1176 else if( (secid==4) && ( eqid!=404 && eqid!=504 && eqid!=407 && eqid!=503 && eqid!=508 && eqid!=506 )) {passed=0;}
1177 }
1178 else {if(fVerb) cout << "passed check "<< endl; }
1179 }
1180 else
1181 {
1182 if( (secid>-1) && (secid<36) ) // if ( secid is in range) { take only specific eqids} else { take all }
1183 {
1184 if(eqid!=fMapEqidsSec[secid][0] && eqid!= fMapEqidsSec[secid][1] && eqid!=fMapEqidsSec[secid][2] &&
1185 eqid!=fMapEqidsSec[secid][3] && eqid!= fMapEqidsSec[secid][4] && eqid!=fMapEqidsSec[secid][5] ) {passed=0;}
1186 }
1187 else {if(fVerb) cout << "passed check "<< endl;}
1188 }
1189 return passed;
1190}
1191
1192//__________________________________________________________________
1193void AliTPCMonitor::SetEqIds()
1194{
1195 // Set mapping for equipment ids
1196 for(Int_t i = 0; i<36 ; i++)
1197 {
1198 for(Int_t j = 0; j<6; j++)
1199 {
1200 if(j<2) fMapEqidsSec[i][j]= 768+i*2+j;
1201 else fMapEqidsSec[i][j]= 840+i*4+j-2;
1202 }
1203 }
1204
1205 for(Int_t i = 0; i<36 ; i++)
1206 {
1207 for(Int_t j = 0; j<6; j++)
1208 {
1209 if(j<2) fMapEqidsRcu[768+i*2+j] = i*6 +j;
1210 else fMapEqidsRcu[840+i*4+j-2] = i*6 +j;
1211 }
1212 }
1213}
1214
1215//__________________________________________________________________
1216void AliTPCMonitor::FillGlobal(Int_t sector)
1217{
1218
1219 // Fill global histograms with max adc for each channel
1220
1221 TH2S* hglob =0;
1222 if((sector/18) ==0) hglob = fHistGlobalMaxA;
1223 else hglob = fHistGlobalMaxC;
1224
1225 Float_t rotsec = (2*TMath::Pi()/18.0);
1226 Float_t rot = (-rotsec*(sector%18) +4*rotsec);
1227
1228 Float_t m11 = TMath::Cos(rot);
1229 Float_t m12 = TMath::Sin(rot);
1230 Float_t m21 = -1*TMath::Sin(rot);
1231 Float_t m22 = TMath::Cos(rot);
1232
1233 Int_t max = 0; // use integer for global view
1234
1235 Double_t xval = 0.0;
1236 Double_t yval = 0.0;
1237
1238 Int_t pad = 0;
1239 Int_t row = 0;
1240 Int_t padmax = 0;
1241
1242 Float_t xdr = 0;
1243 Float_t ydr = 0;
1244
1245 for(Int_t hw = 0; hw<fHistAddrMaxAdc->GetNbinsX(); hw++)
1246 {
1247 max = (Int_t)fHistAddrMaxAdc->GetBinContent(hw);
1248 if(max!=-1)
1249 {
1250 pad = fMapHand->GetPad( hw);
1251 row = fMapHand->GetPadRow(hw);
1252 padmax = fMapHand->GetNumofPads(row);
1253 GetXY(xval ,yval , padmax,row ,pad);
1254 xdr = xval*m11 +yval*m12;
1255 ydr = xval*m21 +yval*m22;
1256 if(hglob->GetBinContent(hglob->GetXaxis()->FindBin(xdr),hglob->GetYaxis()->FindBin(ydr))==0) hglob->Fill(xdr,ydr,(Int_t)max);
1257 }
1258 }
1259}
1260
1261
1262//__________________________________________________________________
ca7b8371 1263void AliTPCMonitor::GetXY( Double_t& xval , Double_t& yval , Int_t padmax, Int_t row , Int_t pad) const
48265b32 1264{
1265 // Get x and y position of pad
1266
1267 if(row<63)
1268 {
1269 xval = fMirror*( 2*padmax -4*pad -2);
1270 yval = 852.25 +7.5*row;
1271 }
1272 else
1273 {
1274 xval = fMirror*( 3*padmax -6*pad -3);
1275 if((row-63)<63) { yval = 10*(row-63) +1351; }
1276 else { yval = 15*(row-63-64)+1993.5; }
1277 }
1278
1279}
1280
1281//__________________________________________________________________
ca7b8371 1282Int_t AliTPCMonitor::GetPadAtX(Float_t xval, Int_t row, Int_t padmax) const
48265b32 1283{
1284 // Get pad number at given position in x
1285 Int_t pad = 0;
1286
1287 if(row<63) {pad = (Int_t)( ( (xval/fMirror) +2 -2*padmax)/-4);}
1288 else {pad = (Int_t)( ( (xval/fMirror) +3 -3*padmax)/-6);}
1289
1290 if(pad>=padmax) return -1;
1291 else return pad ;
1292
1293}
1294
1295//__________________________________________________________________
ca7b8371 1296Int_t AliTPCMonitor::GetPadAtX(Float_t xval, Int_t row) const
48265b32 1297{
1298
1299 // Get pad number at given position in x
1300
1301 Int_t padmax = fMapHand->GetNumofPads(row);
1302 Int_t pad = 0;
1303
1304 if(row<63) {pad = (Int_t)( ( (xval/fMirror) +2 -2*padmax)/-4);}
1305 else {pad = (Int_t)( ( (xval/fMirror) +3 -3*padmax)/-6);}
1306
1307 if(pad>=padmax) return -1;
1308 else return pad ;
1309
1310}
1311
1312//__________________________________________________________________
1313void AliTPCMonitor::DrawHists(Int_t histos)
1314{
1315
1316 // Draw sets of histograms
1317 // histos==1 : 2Dim histos for MAX adc and add executables
1318 // histos==2 : distributions max/rms/sum
1319 // histos==3 : global max adc for specified SideA/C
1320
1321
1322 if(fVerb) cout << " Draw histos " << endl;
1323 Char_t cside[10];
1324 if(GetLastSector()/18==0 ) sprintf(cside,"A");
1325 else sprintf(cside,"C");
1326
1327 Char_t titleSEC[256]; sprintf(titleSEC ,"Sector %i Side %s Run : %05i EventID %i " ,GetLastSector()%18,cside,fRunId, fEventNumber);
1328 Char_t titleEvent[256]; sprintf(titleEvent ,"Time <-> Channles %s" ,titleSEC);
1329 Char_t titleIROC[256]; sprintf(titleIROC ,"IROC %s" ,titleSEC);
1330 Char_t titleOROC[256]; sprintf(titleOROC ,"OROC %s" ,titleSEC);
1331
1332 Char_t titleMAX[256]; sprintf(titleMAX ,"Max (timebin: %i,%i) %s" ,GetRangeMaxAdcMin(),GetRangeMaxAdcMax(),titleSEC);
1333 Char_t titleSUM[256]; sprintf(titleSUM ,"Sum (timebin: %i,%i) %s" ,GetRangeSumMin() ,GetRangeSumMax() ,titleSEC);
1334 Char_t titleBASE[256]; sprintf(titleBASE ,"Baseline RMS<->Mean (timebin: %i-%i) %s" ,GetRangeBaseMin() ,GetRangeBaseMax() ,titleSEC);
1335 Char_t titleMEAN[256]; sprintf(titleMEAN ,"Baseline Mean (timebin: %i-%i) %s" ,GetRangeBaseMin() ,GetRangeBaseMax() ,titleSEC);
1336 Char_t titleRMS[256] ; sprintf(titleRMS ,"Baseline RMS (timebin: %i-%i) %s" ,GetRangeBaseMin() ,GetRangeBaseMax() ,titleSEC);
1337
1338 if(histos==1)
1339 {
1340 // IROC _______________________________________________________________
1341 TCanvas* ciroc = 0;
1342 ciroc = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("ciroc");
1343 if(!ciroc)
1344 {
1345 ciroc = CreateCanvas("ciroc");
1346 fExecPlaneMax=0;
1347 }
1348 ciroc->cd();
1349
1350 fHistIROC->SetXTitle("row");
1351 fHistIROC->SetYTitle("pad");
1352 if(GetPedestals()) fHistIROC->SetZTitle("max ADC (baseline sub)");
1353 else fHistIROC->SetZTitle("max ADC ");
1354 fHistIROC->SetTitle(titleIROC);
1355 fHistIROC->SetMinimum(0.01);
1356 fHistIROC->Draw("COLZ");
1357 ciroc->UseCurrentStyle();
1358
1359
1360 fHistIROCTime->SetXTitle("row"); fHistIROCTime->SetZTitle("peak time (fit)"); fHistIROCTime->SetYTitle("pad"); fHistIROCTime->SetTitle(titleIROC);
1361 fHistIROCRMS->SetXTitle("row"); fHistIROCRMS->SetZTitle( "baseline rms (ADC)"); fHistIROCRMS->SetYTitle("pad"); fHistIROCRMS->SetTitle(titleIROC);
1362
1363 // OROC
1364 TCanvas* coroc = 0;
1365 coroc =(TCanvas*)gROOT->GetListOfCanvases()->FindObject("coroc");
1366 if(!coroc) {
1367 coroc = CreateCanvas("coroc");
1368 fExecPlaneMax=0;
1369 }
1370 coroc->cd();
1371
1372 fHistOROC->SetXTitle("row");
1373 fHistOROC->SetYTitle("pad");
1374 if(GetPedestals()) fHistOROC->SetZTitle("max ADC (baseline sub)");
1375 else fHistOROC->SetZTitle("max ADC ");
1376 fHistOROC->SetTitle(titleOROC);
1377 fHistOROC->SetMinimum(0.01);
1378 fHistOROC->Draw("COLZ");
1379 coroc->UseCurrentStyle();
1380
1381
1382 fHistOROCTime->SetXTitle("row"); fHistOROCTime->SetZTitle("peak time (fit) (timebins)"); fHistOROCTime->SetYTitle("pad"); fHistOROCTime->SetTitle(titleOROC);
1383 fHistOROCRMS->SetXTitle("row"); fHistOROCRMS->SetZTitle("baseline rms (ADC)"); fHistOROCRMS->SetYTitle("pad"); fHistOROCRMS->SetTitle(titleOROC);
1384
1385 // SUM
ca7b8371 1386 Char_t namesum[256] ; sprintf(namesum,"ADC sum (bins: %i, %i)",GetRangeSumMin() ,GetRangeSumMax() );
1387 fHistIROCSUM->SetXTitle("row"); fHistIROCSUM->SetZTitle(namesum); fHistIROCSUM->SetYTitle("pad"); fHistIROCSUM->SetTitle(titleIROC);
1388 fHistOROCSUM->SetXTitle("row"); fHistOROCSUM->SetZTitle(namesum); fHistOROCSUM->SetYTitle("pad"); fHistOROCSUM->SetTitle(titleOROC);
48265b32 1389
1390 // BASE
ca7b8371 1391 Char_t namebase[256] ; sprintf(namebase ,"base mean (timbebin: %i, %i )",GetRangeBaseMin(),GetRangeBaseMax());
1392 fHistIROCBASE->SetXTitle("row"); fHistIROCBASE->SetZTitle(namebase); fHistIROCBASE->SetYTitle("pad"); fHistIROCBASE->SetTitle(titleIROC);
1393 fHistOROCBASE->SetXTitle("row"); fHistOROCBASE->SetZTitle(namebase); fHistOROCBASE->SetYTitle("pad"); fHistOROCBASE->SetTitle(titleOROC);
48265b32 1394
1395 if(fHistIROCClone) fHistIROCClone->Delete();
1396 if(fHistOROCClone) fHistOROCClone->Delete();
1397 fHistIROCClone = (TH2F*)fHistIROC->Clone("fHistIROCClone");
1398 fHistOROCClone = (TH2F*)fHistOROC->Clone("fHistOROCClone");
1399
1400 // Executables
1401 if(fExecPlaneMax==0)
1402 {
1403 Char_t carry1[100];
1404 sprintf(carry1,".x %s/TPC/AliTPCMonitorExec.C(1)",gSystem->Getenv("ALICE_ROOT"));
1405 ciroc->AddExec("pad",carry1);
1406 coroc->AddExec("pad",carry1);
1407
1408 Char_t carry2[100];
1409 sprintf(carry2,".x %s/TPC/AliTPCMonitorExec.C(2)",gSystem->Getenv("ALICE_ROOT"));
1410 ciroc->AddExec("row",carry2);
1411 coroc->AddExec("row",carry2);
1412 fExecPlaneMax=1;
1413 }
1414 coroc->Update();
1415 ciroc->Update();
1416 }
1417 else if(histos==2)
1418 {
1419 // MAX ADC distribution ____________________________________________
1420 TCanvas* cmax = 0;
1421 cmax = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("cmax");
1422 if(!cmax) cmax = CreateCanvas("cmax");
1423
1424 cmax->cd();
1425 fHistDistrMaxIROC->GetXaxis()->SetRangeUser(0.0,1000.0);
1426 fHistDistrMaxIROC->SetXTitle("max ADC (ADC)");
1427 fHistDistrMaxIROC->SetYTitle("counts");
1428 fHistDistrMaxIROC->SetTitle(titleMAX);
1429 fHistDistrMaxIROC->Draw("");
1430 fHistDistrMaxOROC->SetLineColor(2);
1431 fHistDistrMaxOROC->Draw("same");
1432
1433 if(fHistDistrMaxOROC->GetMaximum()> fHistDistrMaxIROC->GetMaximum()) fHistDistrMaxIROC->SetMaximum(fHistDistrMaxOROC->GetMaximum()*1.1);
1434
1435 TLegend* legio = new TLegend(0.6,0.6,0.8,0.8);
1436 legio->SetFillColor(0);
1437 legio->AddEntry(fHistDistrMaxIROC,"IROC","l");
1438 legio->AddEntry(fHistDistrMaxOROC,"OROC","l");
1439 legio->Draw("same");
1440
1441 // ADC sum distribution
1442 TCanvas* csum = 0;
1443 csum = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("csum");
1444 if(!csum) csum = CreateCanvas("csum") ;
1445 csum->cd();
1446
1447 fHistDistrSumIROC->SetXTitle("sum ADC (ADC)");
1448 fHistDistrSumIROC->SetYTitle("counts");
1449 fHistDistrSumIROC->SetTitle(titleSUM);
1450 fHistDistrSumIROC->Draw("");
1451 fHistDistrSumOROC->SetLineColor(2);
1452 fHistDistrSumOROC->Draw("same");
1453 if(fHistDistrSumOROC->GetMaximum()> fHistDistrSumIROC->GetMaximum()) fHistDistrSumIROC->SetMaximum(fHistDistrSumOROC->GetMaximum()*1.1);
1454 legio->Draw("same");
1455
1456 // BASELINE MEAN distribution
1457 TCanvas* cbasemean = 0;
1458 cbasemean = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("cbasemean");
1459 if(!cbasemean) cbasemean = CreateCanvas("cbasemean");
1460 cbasemean->cd();
1461
1462 fHistDistrBaseMeanIROC = fHistDistrBase2dIROC->ProjectionX("fHistDistrBaseMeanIROC");
1463 fHistDistrBaseMeanIROC->SetXTitle("base mean (ADC)");
1464 fHistDistrBaseMeanIROC->SetYTitle("counts");
1465 fHistDistrBaseMeanIROC->SetTitle(titleMEAN);
1466 fHistDistrBaseMeanIROC->Draw("");
1467
1468 fHistDistrBaseMeanOROC = fHistDistrBase2dOROC->ProjectionX("fHistDistrBaseMeanOROC");
1469 fHistDistrBaseMeanOROC->SetLineColor(2);
1470 fHistDistrBaseMeanOROC->Draw("same");
1471 if(fHistDistrBaseMeanOROC->GetMaximum()>fHistDistrBaseMeanIROC->GetMaximum()) fHistDistrBaseMeanIROC->SetMaximum(fHistDistrBaseMeanOROC->GetMaximum()*1.1);
1472 legio->Draw("same");
1473
1474 TCanvas* cbaserms = 0;
1475 cbaserms = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("cbaserms");
1476 if(!cbaserms) cbaserms = CreateCanvas("cbaserms") ;
1477 cbaserms->cd();
1478
1479 // BASELINE RMS distribution
1480 fHistDistrBaseRmsIROC = fHistDistrBase2dIROC->ProjectionY("fHistDistrBaseRmsIROC");
1481 fHistDistrBaseRmsIROC->SetXTitle("base rms (ADC)");
1482 fHistDistrBaseRmsIROC->SetYTitle("counts");
1483 fHistDistrBaseRmsIROC->SetTitle(titleRMS);
1484 fHistDistrBaseRmsIROC->Draw("");
1485
1486 fHistDistrBaseRmsOROC = fHistDistrBase2dOROC->ProjectionY("fHistDistrBaseRmsOROC");
1487 fHistDistrBaseRmsOROC->SetLineColor(2);
1488 fHistDistrBaseRmsOROC->Draw("same");
1489 if(fHistDistrBaseRmsOROC->GetMaximum()>fHistDistrBaseRmsIROC->GetMaximum()) fHistDistrBaseRmsIROC->SetMaximum(fHistDistrBaseRmsOROC->GetMaximum()*1.1);
1490 legio->Draw("same");
1491
1492 cmax->Update();
1493 csum->Update();
1494 cbasemean->Update();
1495 cbaserms->Update();
1496 }
1497 else if(histos==3)
1498 {
1499 // GLOBAL MAX ADC _________________________________
1500 if(GetProcNextEvent()==1)
1501 {
1502 TCanvas* cglobA =0;
1503 TCanvas* cglobC =0;
1504
1505 if(!(cglobC=(TCanvas*)gROOT->GetListOfCanvases()->FindObject("SIDE C all"))) cglobC = CreateCanvas("SIDE C all");
1506 if(!(cglobA=(TCanvas*)gROOT->GetListOfCanvases()->FindObject("SIDE A all"))) cglobA = CreateCanvas("SIDE A all");
1507
ca7b8371 1508 Char_t globtitle1[256]; sprintf(globtitle1,"SIDE A Run %05i (EventID %i)",fRunId,fEventNumber);
1509 Char_t globtitle2[256]; sprintf(globtitle2,"SIDE C Run %05i (EventID %i)",fRunId,fEventNumber);
48265b32 1510
ca7b8371 1511 fHistGlobalMaxA->SetTitle(globtitle1);
1512 fHistGlobalMaxC->SetTitle(globtitle2);
48265b32 1513 fHistGlobalMaxA->SetXTitle("x/mm");
1514 fHistGlobalMaxA->SetYTitle("y/mm");
1515 fHistGlobalMaxC->SetXTitle("x/mm");
1516 fHistGlobalMaxC->SetYTitle("y/mm");
1517
1518 if(GetPedestals()==0) { fHistGlobalMaxA->SetZTitle("max adc (not baseline sub)"); fHistGlobalMaxC->SetZTitle("max adc (not baseline sub)"); }
1519 else { fHistGlobalMaxA->SetZTitle("max adc "); fHistGlobalMaxC->SetZTitle("max adc "); }
1520
1521 fHistGlobalMaxA->SetMinimum(0.01);
1522 fHistGlobalMaxC->SetMinimum(0.01);
1523
1524 cglobC->cd() ; fHistGlobalMaxC->Draw("COLZ");
1525 cglobA->cd() ; fHistGlobalMaxA->Draw("COLZ");
1526
ca7b8371 1527 Char_t nameom[256];
1528 sprintf(nameom,".x %s/TPC/AliTPCMonitorExec.C(3)",gSystem->Getenv("ALICE_ROOT"));
48265b32 1529
1530 if(fExecGlob==0)
1531 {
ca7b8371 1532 if(fVerb)cout << " set exec " << nameom << endl;
1533 cglobC->AddExec("glob",nameom);
1534 cglobA->AddExec("glob",nameom);
48265b32 1535 fExecGlob = 1;
1536 }
1537 else
1538 {
1539 cglobC->DeleteExec("glob");
1540 cglobA->DeleteExec("glob");
1541
ca7b8371 1542 if(fVerb) cout << " set exec " << nameom << endl;
1543 cglobC->AddExec("glob",nameom);
1544 cglobA->AddExec("glob",nameom);
48265b32 1545
1546 }
1547 cglobC->Update();
1548 cglobA->Update();
1549 }
1550
1551 }
1552}
1553
1554
1555
1556//__________________________________________________________________
1557void AliTPCMonitor::DrawRMSMap()
1558{
1559 // Draw 2Dim rms histos for IROC and OROC
1560 // and set executables for canvases
1561
1562 TCanvas* crmsoroc =0;
1563 TCanvas* crmsiroc =0;
1564 if(!(crmsoroc = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("crmsoroc"))) crmsoroc = CreateCanvas("crmsoroc");
1565 if(!(crmsiroc = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("crmsiroc"))) crmsiroc = CreateCanvas("crmsiroc");
1566
1567 crmsiroc->cd(); fHistIROCRMS->Draw("COLZ");
1568 crmsoroc->cd(); fHistOROCRMS->Draw("COLZ");
1569
1570 Char_t carry1[100]; sprintf(carry1,".x %s/TPC/AliTPCMonitorExec.C(1)",gSystem->Getenv("ALICE_ROOT"));
1571 Char_t carry2[100]; sprintf(carry2,".x %s/TPC/AliTPCMonitorExec.C(2)",gSystem->Getenv("ALICE_ROOT"));
1572
1573 if(fExecPadIrocRms==0)
1574 {
1575 crmsiroc->AddExec("pad",carry1);
1576 crmsiroc->AddExec("row",carry2);
1577 fExecPadIrocRms=1;
1578 }
1579
1580 if(fExecPadOrocRms==0)
1581 {
1582 crmsoroc->AddExec("pad",carry1);
1583 crmsoroc->AddExec("row",carry2);
1584 fExecPadOrocRms=1;
1585 }
1586
1587 crmsiroc->Update();
1588 crmsoroc->Update();
1589
1590 DrawHists(2);
1591
1592}
1593
1594//__________________________________________________________________
1595void AliTPCMonitor::ExecPad()
1596{
1597
1598 // Executable for Pad
1599 // Show time profile for channel the mouse is pointing at
1600
1601 Int_t event = gPad->GetEvent();
1602 if (event != 51) return;
1603
1604 TObject *select = gPad->GetSelected();
1605 if(!select) return;
1606 if(!select->InheritsFrom("TH2")) { return; }
1607 gPad->GetCanvas()->FeedbackMode(kTRUE);
1608
1609 // get position
1610 Int_t px = gPad->GetEventX();
1611 Int_t py = gPad->GetEventY();
1612 Float_t upy = gPad->AbsPixeltoY(py);
1613 Float_t upx = gPad->AbsPixeltoX(px);
1614 Float_t y = gPad->PadtoY(upy);
1615 Float_t x = gPad->PadtoX(upx);
1616
1617 Int_t setrange = 0;
1618
1619 TCanvas* cpad = 0;
1620 // Char_t namehist[50];
1621 Char_t projhist[60];
1622 Char_t namesel[256];
1623 Char_t namecanv[256];
1624
ca7b8371 1625 Int_t xbinmin = 0;
1626 Int_t xbinmax = 0;
1627 Float_t ybinmin = 0;
1628 Float_t ybinmax = 0;
1629 Int_t rocid = 0;
48265b32 1630
1631 // Check wich Canvas executed the event
1632 TH2S* fHistIndex=0;
1633 sprintf(namesel,select->GetName());
1634 if(strcmp(namesel,"fHistOROC")==0 || strcmp(namesel,"fHistOROCRMS")==0 || strcmp(namesel,"fHistOROCTime")==0 )
1635 {
ca7b8371 1636 rocid = 1;
48265b32 1637 fPadUsedRoc =1;
1638 sprintf(projhist,"ProjectionOROC");
1639 sprintf(namecanv,"coroc_ch");
1640 fHistIndex = fHistOROCIndex;
1641 }
1642 if(strcmp(namesel,"fHistIROC")==0 || strcmp(namesel,"fHistIROCRMS")==0 || strcmp(namesel,"fHistIROCTime")==0 )
1643 {
ca7b8371 1644 rocid = 0;
48265b32 1645 fPadUsedRoc=0;
1646 sprintf(projhist,"ProjectionIROC");
1647 sprintf(namecanv,"ciroc_ch");
ca7b8371 1648 fHistIndex = fHistIROCIndex;
48265b32 1649 }
1650
1651 // Check if Canvas already existed and get Ranges from former Prjection histogram
ca7b8371 1652 if((cpad=(TCanvas*)gROOT->GetListOfCanvases()->FindObject(namecanv)))
48265b32 1653 {
1654 cpad->cd();
1655 if(gROOT->Get(projhist))
1656 {
1657 setrange = 1;
ca7b8371 1658 xbinmin = ((TH1D*)gROOT->Get(projhist))->GetXaxis()->GetFirst();
1659 xbinmax = ((TH1D*)gROOT->Get(projhist))->GetXaxis()->GetLast();
1660 ybinmin = ((TH1D*)gROOT->Get(projhist))->GetMinimum();
1661 ybinmax = ((TH1D*)gROOT->Get(projhist))->GetMaximum();
48265b32 1662 delete gROOT->Get("legfit");
1663 delete gROOT->Get("fg");
1664 }
1665 }
1666 else
1667 {
1668 cpad = CreateCanvas(namecanv); cpad->cd();
1669 }
1670
1671 // Get Bin
1672 Int_t testy = fHistIndex->GetYaxis()->FindBin(y);
1673 Int_t testx = fHistIndex->GetXaxis()->FindBin(x);
1674 Int_t binchannel = (Int_t)fHistIndex->GetCellContent(testx,testy);
1675 if(binchannel>30000 || binchannel<0) return;
1676
1677 if(gROOT->Get(projhist)) delete gROOT->Get(projhist);
1678 // Get Projection
1679 TH1D *hp = (TH1D*)(((TH1D*)fHistChannelTime->ProjectionY("hp",binchannel,binchannel))->Clone(projhist));
1680
1681 // Make title and Pave for channel Info
1682 Char_t title[256];
1683 Int_t npadRow , npad , nhw , nmax , hwadd;
1684
1685 hwadd = (Int_t)fHistChannelTime->GetCellContent(binchannel,0);
1686 fPadUsedHwAddr = hwadd;
1687
ca7b8371 1688 if(rocid==0)npadRow = fMapHand->GetPadRow(hwadd);
1689 else npadRow = fMapHand->GetPadRow(hwadd)-63;
1690 npad = fMapHand->GetPad(hwadd);
1691 nhw = hwadd;
1692 nmax = (Int_t)hp->GetMaximum();
48265b32 1693
1694
1695 TPaveText* legstat = new TPaveText(0.18,0.65,0.3,0.8,"NDC");
1696
1697 Int_t connector = fMapHand->GetFECconnector(hwadd);
ca7b8371 1698 Int_t fecnr = fMapHand->GetFECfromHw(hwadd);
1699 Int_t fecch = fMapHand->GetFECchannel(hwadd);
1700 Int_t altrochip = fMapHand->GetAltro(hwadd);
1701 Int_t altrochannel= (fMapHand->GetAltroChannel(hwadd))%16;
1702 Int_t fecloc = fMapHand->U2fGetFECinRCU(fecnr) ;
1703 Int_t feclocbran = fMapHand->U2fGetFECinBranch(fecnr);
1704 Int_t branch = fMapHand->U2fGetBranch(fecnr);
48265b32 1705
1706
1707 Short_t fecget = (hwadd & AliTPCMonitorAltro::GetHwMaskFEC()) >> 7;
1708 Short_t branchget = (hwadd & AliTPCMonitorAltro::GetHwMaskBranch())>> 11;
1709
1710
1711 Char_t nstat1[100]; Char_t nstat2[100]; Char_t nstat3[100]; Char_t nstat4[100];
1712 Char_t nstat5[100]; Char_t nstat6[100]; Char_t nstat7[100]; Char_t nstat8[100];
1713
1714 sprintf(nstat1,"Branch (map) \t %i (%i) \n",branchget,branch);
ca7b8371 1715 sprintf(nstat2,"Fec in patch \t %i \n",fecloc);
1716 sprintf(nstat8,"Fec in branch (map)\t %i (%i)\n",fecget,feclocbran);
48265b32 1717 sprintf(nstat7,"Connector \t %i \n",connector);
ca7b8371 1718 sprintf(nstat3,"Fec No. \t %i \n",fecnr);
1719 sprintf(nstat4,"Fec chan \t %i \n",fecch);
1720 sprintf(nstat5,"Altro chip\t %i \n",altrochip);
1721 sprintf(nstat6,"Altro chan\t %i \n",altrochannel);
48265b32 1722
1723 legstat->AddText(nstat1); legstat->AddText(nstat2); legstat->AddText(nstat8); legstat->AddText(nstat7);
1724 legstat->AddText(nstat3); legstat->AddText(nstat4); legstat->AddText(nstat5); legstat->AddText(nstat6);
1725
1726 sprintf(title,"Row=%d Pad=%d Hw =%d maxADC =%d count =%d",npadRow,npad,nhw,nmax,binchannel);
1727
1728 hp->SetName(projhist);
1729 hp->SetTitleSize(0.04);
1730 hp->SetTitle(title);
1731 hp->SetYTitle("ADC");
1732 hp->SetXTitle("Timebin");
1733 hp->GetXaxis()->SetTitleColor(1);
1734
1735 if(setrange)
1736 {
ca7b8371 1737 hp->GetXaxis()->SetRange(xbinmin,xbinmax);
1738 hp->SetMinimum(ybinmin);
1739 hp->SetMaximum(ybinmax);
48265b32 1740 }
1741 else
1742 {
1743 hp->SetMinimum(0.0);
1744 hp->SetMaximum(1000.0);
1745 }
1746
1747 cpad->cd();
1748 hp->Draw();
1749
1750 // Make Fit to peak
1751 if(GetPedestals() && fDisableFit==0)
1752 {
ca7b8371 1753 Int_t maxx = (Int_t)fHistAddrMaxAdcX->GetBinContent(hwadd);
48265b32 1754 Float_t max = (Float_t)fHistAddrMaxAdc->GetBinContent(hwadd);
1755 Float_t base = (Float_t)fHistAddrBaseMean->GetBinContent(hwadd);
1756 if(base!=0)
1757 {
1758 if( ((max+base)/base)>1.2)
1759 {
ca7b8371 1760 TF1* fg = new TF1("fg",AliTPCMonitor::Gamma4,maxx-5,maxx+5,4);
48265b32 1761 fg->SetParName(0,"Normalisation");
1762 fg->SetParName(1,"Minimum");
1763 fg->SetParName(2,"Width");
1764 fg->SetParName(3,"Base");
1765 fg->SetParameter(0,max);
ca7b8371 1766 fg->SetParameter(1,maxx-2);
48265b32 1767 fg->SetParameter(2,1.5);
1768 fg->FixParameter(3,0);
1769 fg->SetLineColor(4);
1770 fg->SetLineWidth(1);
1771 hp->Fit("fg","RQ");
1772
1773 TLegend* legfit = new TLegend(0.6,0.7,0.7,0.8);
1774 legfit->AddEntry("fg","#Gamma 4 fit","l");
1775 legfit->SetFillColor(0);
1776 legfit->SetName("legfit");
1777 legfit->Draw("same");
1778 }
1779 }
1780 }
1781 legstat->SetFillColor(0);
1782 legstat->Draw("same");
1783 cpad->Update();
1784 return;
1785}
1786
1787//__________________________________________________________________
1788void AliTPCMonitor::ExecRow()
1789{
1790
1791 // Executable for Pad
1792 // Show profile of max adc over given pad row
1793 // and 2dim histo adc(pad-in-row,time bin)
1794
1795 Int_t event = gPad->GetEvent();
1796 if (event != 61) return;
1797 gPad->cd();
1798 TObject *select = gPad->GetSelected();
1799 if(!select) return;
1800 if(!select->InheritsFrom("TH2")) { return; }
1801
ca7b8371 1802 Int_t rocid = 0;
48265b32 1803 // Char_t namehist[50];
1804 Char_t rowhist[60];
ca7b8371 1805 Char_t rowhistsum[60];
1806 Char_t rowhistmax[60];
1807 Char_t rowhistxmax[60];
48265b32 1808
ca7b8371 1809 sprintf(rowhist, "hrowtime");
1810 sprintf(rowhistxmax ,"hxmax");
1811 sprintf(rowhistmax , "hrowmax");
48265b32 1812
1813 // get position
1814 Int_t px = gPad->GetEventX();
1815 Int_t py = gPad->GetEventY();
1816 Float_t upy = gPad->AbsPixeltoY(py);
1817 Float_t upx = gPad->AbsPixeltoX(px);
1818 Float_t y = gPad->PadtoY(upy);
1819 Float_t x = gPad->PadtoX(upx);
1820
ca7b8371 1821 TCanvas*crowtime = 0;
1822 TCanvas*crowmax = 0;
1823 TCanvas*cxmax = 0;
48265b32 1824
1825 TH2S* fHistIndex = 0;
1826
1827 // ranges from already existing histos
ca7b8371 1828 Int_t rowtimexmin = 0;
1829 Int_t rowtimexmax = 0;
1830 Int_t rowtimeymin = 0;
1831 Int_t rowtimeymax = 0;
1832 Float_t rowtimezmin = 0;
1833 Float_t rowtimezmax = 0;
48265b32 1834
fb3305d1 1835 Int_t profrowxmin = 0;
1836 Int_t profrowxmax = 0;
1837 Double_t profrowymin = 0;
1838 Double_t profrowymax = 0;
48265b32 1839
ca7b8371 1840 Int_t profxxmin = 0;
1841 Int_t profxxmax = 0;
1842 Double_t profxymin = 0;
1843 Double_t profxymax = 0;
48265b32 1844
1845
1846 Int_t setrange = 0;
1847
1848
ca7b8371 1849 if( strcmp(select->GetName(),"fHistIROC")==0 || strcmp(select->GetName(),"fHistIROCRMS")==0 ) { fHistIndex = fHistIROCIndex; rocid =1; }
1850 else if(strcmp(select->GetName(),"fHistOROC")==0 || strcmp(select->GetName(),"fHistOROCRMS")==0 ) { fHistIndex = fHistOROCIndex; rocid =2; }
48265b32 1851 else { cout << " not implemented for this histo " << endl; return; }
1852
1853 gPad->GetCanvas()->FeedbackMode(kTRUE);
1854
1855
1856
1857 // check if canvases exist //
ca7b8371 1858 crowtime = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("crowtime");
1859 crowmax = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("crowmax");
1860 cxmax = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("cxmax");
48265b32 1861
ca7b8371 1862 if(!crowtime) crowtime = CreateCanvas("crowtime") ;
1863 if(!crowmax) crowmax = CreateCanvas("crowmax") ;
1864 if(!cxmax ) cxmax = CreateCanvas("cxmax") ;
48265b32 1865
1866 // check ranges of already existing histos
1867 if(gROOT->Get(rowhist))
1868 {
ca7b8371 1869 rowtimexmin = ((TH2F*)gROOT->Get(rowhist))->GetXaxis()->GetFirst();
1870 rowtimexmax = ((TH2F*)gROOT->Get(rowhist))->GetXaxis()->GetLast();
1871 rowtimeymin = ((TH2F*)gROOT->Get(rowhist))->GetYaxis()->GetFirst();
1872 rowtimeymax = ((TH2F*)gROOT->Get(rowhist))->GetYaxis()->GetLast();
1873 rowtimezmin = ((TH2F*)gROOT->Get(rowhist))->GetMinimum();
1874 rowtimezmax = ((TH2F*)gROOT->Get(rowhist))->GetMaximum();
48265b32 1875
fb3305d1 1876 profrowxmin = ((TH1F*)gROOT->Get(rowhistmax))->GetXaxis()->GetFirst();
1877 profrowxmax = ((TH1F*)gROOT->Get(rowhistmax))->GetXaxis()->GetLast();
1878 profrowymin = ((TH1F*)gROOT->Get(rowhistmax))->GetMinimum();
1879 profrowymax = ((TH1F*)gROOT->Get(rowhistmax))->GetMaximum();
48265b32 1880
ca7b8371 1881 profxxmin = ((TH1F*)gROOT->Get(rowhistxmax))->GetXaxis()->GetFirst();
1882 profxxmax = ((TH1F*)gROOT->Get(rowhistxmax))->GetXaxis()->GetLast();
1883 profxymin = ((TH1F*)gROOT->Get(rowhistxmax))->GetMinimum();
1884 profxymax = ((TH1F*)gROOT->Get(rowhistxmax))->GetMaximum();
48265b32 1885
1886 setrange =1;
1887
1888 delete gROOT->Get(rowhist);
ca7b8371 1889 delete gROOT->Get(rowhistmax);
1890 delete gROOT->Get(rowhistsum);
1891 delete gROOT->Get("hxmax");
48265b32 1892 delete gROOT->Get("legrow");
1893 }
1894
1895 // get channel for xy bin -> getRow -> getNrows -> getHw for each Pad in Row -> get channel for each hw -> make proj
1896 Int_t testy = fHistIndex->GetYaxis()->FindBin(y);
1897 Int_t testx = fHistIndex->GetXaxis()->FindBin(x);
1898 Int_t binchannel = (Int_t)fHistIndex->GetCellContent(testx,testy);
1899
1900 if(binchannel>30000) return;
ca7b8371 1901 if(binchannel<=0 ) { crowtime->Update() ; crowmax->Update() ; return ; }
48265b32 1902
1903 // get hwaddress
1904 Int_t hwadd = (Int_t)fHistChannelTime->GetCellContent(binchannel,0);
1905 Int_t row = fMapHand->GetPadRow(hwadd);
1906 Int_t pad = fMapHand->GetPad(hwadd) ;
1907 Int_t numofpads = fMapHand->GetNumofPads(row);
1908
1909 // create histos
ca7b8371 1910 TH2F *hrowtime = new TH2F(rowhist , "" ,numofpads,0,numofpads,GetTimeBins(),0.0,GetTimeBins());
1911 TH1F *hrowmax = new TH1F(rowhistmax , "" ,numofpads,0,numofpads);
1912 TH1F *hxmax = new TH1F(rowhistxmax, "" ,159,0,159 );
48265b32 1913
1914 // Row profile ///////////
1915 if(fVerb) cout << " Number of pads " << numofpads << endl;
1916 for(Int_t padnr = 0; padnr<numofpads;padnr++)
1917 {
1918 Int_t addrinrow = fMapHand->GetPadAddInRow(row,padnr );
1919 Int_t channel = (Int_t)fHistAddrMapIndex->GetBinContent(addrinrow);
1920 if(channel==-1) continue;
1921
ca7b8371 1922 hrowmax->SetBinContent(padnr+1,fHistAddrMaxAdc->GetBinContent(addrinrow));
48265b32 1923 TH1D *hp = fHistChannelTime->ProjectionY("hp",channel,channel);
1924 for(Int_t time = 0;time<GetTimeBins();time++) {
1925
1926 Float_t val = hp->GetBinContent(time);
ca7b8371 1927 hrowtime->SetCellContent(padnr+1,time+1,val);
48265b32 1928 }
1929 }
1930
1931 // X profile /////////////
1932 Double_t xval = 0.0;
1933 Double_t yval = 0.0;
1934 GetXY(xval,yval,numofpads,row,pad);
1935
1936 Int_t padnr = 0;
1937 Int_t hw = 0;
1938 for(Int_t nrow = 0; nrow<159; nrow++)
1939 {
1940 padnr = GetPadAtX(xval,nrow);
1941 if(padnr>=0)
1942 {
1943 hw = fMapHand->GetPadAddInRow(nrow,padnr);
1944 if(fPadMapHw[hw]==-1){ continue ; }
ca7b8371 1945 else { hxmax->SetBinContent(nrow+1,fHistAddrMaxAdc->GetBinContent(hw)) ; }
48265b32 1946 }
1947 }
1948
ca7b8371 1949 cxmax->cd();
1950 Char_t hxtitle[50] ; sprintf(hxtitle,"max adc in pads at x=%5.1f mm",xval);
1951 hxmax->SetTitle(hxtitle);
1952 hxmax->SetXTitle("row");
1953 if(!GetPedestals()) hxmax->SetYTitle("max adc (baseline sub.)");
1954 else hxmax->SetYTitle("max adc ");
1955 hxmax->SetMinimum(0.01);
1956 hxmax->Draw("l");
48265b32 1957
1958 if(setrange)
1959 {
ca7b8371 1960 hxmax->GetXaxis()->SetRange(profxxmin,profxxmax);
1961 hxmax->SetMinimum(profxymin);
1962 hxmax->SetMaximum(profxymax);
48265b32 1963 }
1964
ca7b8371 1965 cxmax->Update();
48265b32 1966
ca7b8371 1967 crowtime->cd();
48265b32 1968 Char_t title[256];
ca7b8371 1969 Char_t titlemax[256];
1970 if(rocid==1) {sprintf(title,"%s Row=%d",((TH2*)select)->GetTitle(),row) ; sprintf(titlemax,"IROC max/sum Row=%d",row );}
1971 else {sprintf(title,"%s Row=%d",((TH2*)select)->GetTitle(),row-63); sprintf(titlemax,"OROC max/sum Row=%d",row-63);}
48265b32 1972 if(fVerb) cout << " set name " << endl;
1973
1974
1975 // row vs time
ca7b8371 1976 crowtime->cd();
1977 hrowtime->SetTitleSize(0.04);
1978 hrowtime->SetTitle(title);
1979 hrowtime->SetYTitle("timbin");
1980 hrowtime->SetXTitle("pad in row");
1981 hrowtime->SetZTitle("signal (ADC)");
48265b32 1982
ca7b8371 1983 hrowtime->GetXaxis()->SetTitleColor(1);
1984 hrowtime->SetMaximum(1000.0);
1985 hrowtime->SetMinimum(0.0);
48265b32 1986
1987 if(setrange)
1988 {
ca7b8371 1989 hrowtime->GetXaxis()->SetRange(rowtimexmin,rowtimexmax);
1990 hrowtime->GetYaxis()->SetRange(rowtimeymin,rowtimeymax);
1991 hrowtime->SetMinimum(rowtimezmin);
1992 hrowtime->SetMaximum(rowtimezmax);
48265b32 1993 }
1994
ca7b8371 1995 hrowtime->Draw("COLZ");
1996 crowtime->UseCurrentStyle();
1997 crowtime->Update();
48265b32 1998
1999 // max and sum /////////////////////////
ca7b8371 2000 crowmax->cd();
48265b32 2001 if(setrange) {
fb3305d1 2002 hrowmax->GetXaxis()->SetRange(profrowxmin,profrowxmax);
2003 hrowmax->SetMinimum(profrowymin);
2004 hrowmax->SetMaximum(profrowymax);
48265b32 2005 }
ca7b8371 2006 hrowmax->SetTitleSize(0.04);
2007 hrowmax->SetTitle(title);
2008 hrowmax->SetYTitle("max adc");
2009 hrowmax->SetXTitle("pad in row");
2010 hrowmax->GetXaxis()->SetTitleColor(1);
48265b32 2011
ca7b8371 2012 hrowmax->SetLineColor(2);
2013 hrowmax->Draw("l");
2014 crowmax->Update();
48265b32 2015
2016 return;
2017}
2018
2019//__________________________________________________________________
2020void AliTPCMonitor::Write10bitChannel()
2021{
2022
2023 // Write 10 bit words form histogram for active(last pointed) channel
2024
2025 if(fPadUsedHwAddr==-1){ AliWarning(" No active pad "); return ;}
2026
2027 Int_t pad = (Int_t)fMapHand->GetPad( fPadUsedHwAddr);
2028 Int_t row = (Int_t)fMapHand->GetPadRow(fPadUsedHwAddr);
2029 Int_t channel = (Int_t)fPadMapHw[fPadUsedHwAddr];
2030
ca7b8371 2031 Char_t filenameroot[256];
2032 Char_t filenamedat[256];
48265b32 2033 Char_t projhist[256];
2034
2035 if(fPadUsedRoc==1) { sprintf(projhist,"ProjectionOROC"); }
2036 if(fPadUsedRoc==0) { sprintf(projhist,"ProjectionIROC"); }
2037
ca7b8371 2038 sprintf(filenamedat, "Channel_Run%05i_EventID_%i_Pad_%i_Row_%i.dat" ,fRunId,fEventNumber,pad,row);
2039 sprintf(filenameroot,"Channel_Run%05i_EventID_%i_Pad_%i_Row_%i.root" ,fRunId,fEventNumber,pad,row);
48265b32 2040
2041 TH1D* hpr = 0;
ca7b8371 2042 if((hpr=(TH1D*)gROOT->Get(projhist)))
48265b32 2043 {
2044 // root histo
ca7b8371 2045 TFile f(filenameroot,"recreate");
48265b32 2046 hpr->Write();
2047 f.Close();
2048
2049 // raw singal
ca7b8371 2050 ofstream datout(filenamedat,ios::out);
48265b32 2051 datout <<"Timebin \t ADC value " << endl;
2052 for(Int_t i = 1; i <GetTimeBins(); i++)
2053 {
2054 datout << i << " \t \t " << fPad[channel][i] << endl;
2055 }
2056 datout.close();
2057 }
2058 else
2059 {
2060 AliWarning("No projection histo found ");
2061 }
2062}
2063
2064//__________________________________________________________________
2065void AliTPCMonitor::ExecTransform()
2066{
2067
2068 // Make Fast Fourier Transformation for active pad
2069 // fft is only performed for a data sample of size 2^n
2070 // reduce window according to largest power of 2 which is smaller than the viewing range
2071
2072 Char_t namecanv[256];
2073 Char_t projhist[256];
ca7b8371 2074 Char_t namehtrimag[256];
2075 Char_t namehtrreal[256];
48265b32 2076
2077 if(fPadUsedRoc==1) { sprintf(namecanv,"coroc_ch_trans") ; sprintf(projhist,"ProjectionOROC"); }
2078 if(fPadUsedRoc==0) { sprintf(namecanv,"ciroc_ch_trans") ; sprintf(projhist,"ProjectionIROC"); }
2079
2080 TH1D* hproj = 0;
2081
2082 if((TH1D*)gROOT->Get(projhist)==0){AliWarning("Proj histo does not exist \n Move mouse over 2d histo choose channel \n and drag mouse form histo again!"); return ;}
2083 else hproj = (TH1D*)gROOT->Get(projhist) ;
2084
2085
ca7b8371 2086 if(fPadUsedRoc==1) { sprintf(namehtrimag,"htransimagfreq_oroc"); sprintf(namehtrreal,"htransrealfreq_oroc"); }
2087 else { sprintf(namehtrimag,"htransimagfreq_iroc"); sprintf(namehtrreal,"htransrealfreq_iroc"); }
48265b32 2088
ca7b8371 2089 if( gROOT->Get(namehtrimag)) delete gROOT->Get(namehtrimag);
2090 if( gROOT->Get(namehtrreal)) delete gROOT->Get(namehtrreal);
48265b32 2091
2092 TCanvas *ctrans = 0;
2093 if(!(ctrans = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(namecanv)))
2094 {
2095 ctrans = CreateCanvas(namecanv);
2096 ctrans->Divide(1,2);
2097 }
2098
ca7b8371 2099 Int_t binfirst = hproj->GetXaxis()->GetFirst();
2100 Int_t binlast = hproj->GetXaxis()->GetLast();
2101 Int_t bins = binlast -binfirst +1;
48265b32 2102
2103 Int_t power = 0;
2104 for(Int_t pot = 0; pot<=10 ; pot++)
2105 {
2106 Int_t comp = (Int_t)TMath::Power(2,pot);
2107 if(bins>=comp)power = pot;
2108 }
2109
2110 bins = (Int_t)TMath::Power(2,power);
2111
2112 // sampling frequency ;
ca7b8371 2113 Double_t deltat = 1.0/(Float_t)GetSamplingFrequency();
48265b32 2114
2115 // output histo
ca7b8371 2116 TH1D* htransrealfreq = new TH1D(namehtrreal,namehtrreal,10000,-1/(2*deltat),1/(2*deltat));
2117 TH1D* htransimagfreq = new TH1D(namehtrimag,namehtrimag,10000,-1/(2*deltat),1/(2*deltat));
48265b32 2118
2119
ca7b8371 2120 Char_t titlereal[256];
2121 Char_t titleimag[256];
2122 if(fPadUsedRoc==1) { sprintf(titlereal,"OROC DFT real part"); sprintf(titleimag,"OROC DFT imag part"); }
2123 else { sprintf(titlereal,"IROC DFT real part"); sprintf(titleimag,"IROC DFT imag part"); }
48265b32 2124
ca7b8371 2125 htransrealfreq->SetTitle(titlereal); htransrealfreq->SetXTitle("f/hz"); htransrealfreq->SetYTitle("z_{real}(f)");
2126 htransimagfreq->SetTitle(titleimag); htransimagfreq->SetXTitle("f/hz"); htransimagfreq->SetYTitle("z_{imag}(f)");
48265b32 2127
2128
2129 // create complex packed data array
ca7b8371 2130 const Int_t kdatasiz = 2*bins;
2131 Double_t* data = new Double_t[kdatasiz];
48265b32 2132 for(Int_t i=0;i<2*bins;i++) { data[i] = 0.0;}
ca7b8371 2133 for(Int_t i=0;i<bins;i++) { data[2*i] = (Double_t)hproj->GetBinContent(binfirst+i); }
48265b32 2134
2135 // make fourier transformation
2136 AliTPCMonitorFFT* four = new AliTPCMonitorFFT();
2137 four->ComplexRadix2ForwardWrap(data,1,bins);
2138
2139 // write output and fill histos forward
2140 Double_t freq = 0.0;
2141 for(Int_t i=0;i<2*bins;i++)
2142 {
2143 if(i<bins)
2144 {
ca7b8371 2145 if(i<(bins/2)) { freq = i/(bins*deltat) ; }
2146 else { freq = -1*((bins-i)/(bins*deltat)); }
2147 htransrealfreq->Fill( freq,data[2*i] );
2148 htransimagfreq->Fill( freq,data[2*i+1]);
48265b32 2149
2150
2151 }
2152 }
2153
2154 ctrans->cd(1);
ca7b8371 2155 htransrealfreq->Draw();
48265b32 2156 ctrans->cd(2);
ca7b8371 2157 htransimagfreq->Draw();
48265b32 2158 ctrans->Update();
2159 delete four;
2160 delete data;
2161}
2162
2163//__________________________________________________________________
ca7b8371 2164void AliTPCMonitor::ShowSel(Int_t* compval)
48265b32 2165{
2166
2167 // Show only selected components
2168 // First restore original histogram from clone
2169 // Than remove all not matching pads form histos
2170
2171 Int_t connector = 0;
ca7b8371 2172 Int_t fecnr = 0;
fb3305d1 2173 Int_t altrochip = 0;
ca7b8371 2174 Int_t feclocbran = 0;
48265b32 2175 Int_t branch = 0;
2176 Short_t rcuget = 0;
2177 Int_t emptyI = 1;
2178 Int_t index = -1;
2179 Int_t hwadd = 0;
2180
2181 Float_t maxiroc = fHistIROCClone->GetMaximum();
2182 Float_t maxoroc = fHistOROCClone->GetMaximum();
2183
2184
2185 // restore original histos
ca7b8371 2186 for(Int_t row = 0; row<fkNRowsIroc; row++)
48265b32 2187 {
ca7b8371 2188 for(Int_t pad = 0; pad<fkNPadsIroc; pad++)
48265b32 2189 {
2190 index = (Int_t)fHistIROCIndex->GetCellContent(row+1,pad+1);
2191 if(index==-1)continue;
2192 else fHistIROC->SetCellContent(row+1,pad+1,fHistIROCClone->GetCellContent(row+1,pad+1));
2193 }
2194 }
ca7b8371 2195 for(Int_t row = 0; row<fkNRowsOroc; row++)
48265b32 2196 {
ca7b8371 2197 for(Int_t pad = 0; pad<fkNPadsOroc; pad++)
48265b32 2198 {
2199 index = (Int_t)fHistOROCIndex->GetCellContent(row+1,pad+1);
2200 if(index==-1)continue;
2201 else fHistOROC->SetCellContent(row+1,pad+1,fHistOROCClone->GetCellContent(row+1,pad+1));
2202 }
2203 }
2204
2205
2206 // remove not matching entries from fHistIROC/fHistOROC
2207
2208 TH2F* fHist =0;
2209 TH2S* fHistIndex =0;
2210 Int_t npads =0;
2211 Int_t subrows =0;
2212
ca7b8371 2213 for(Int_t row = 0; row< (fkNRowsIroc + fkNRowsOroc); row++)
48265b32 2214 {
ca7b8371 2215 if(row<fkNRowsIroc) { fHist=fHistIROC ; fHistIndex = fHistIROCIndex; npads = fkNPadsIroc; subrows =0 ;}
2216 else { fHist=fHistOROC ; fHistIndex = fHistOROCIndex; npads = fkNPadsOroc; subrows =fkNRowsIroc;}
48265b32 2217
2218 for(Int_t pad = 0; pad<npads; pad++)
2219 {
2220 index = (Int_t)fHistIndex->GetCellContent(row -subrows +1,pad+1);
2221 if(index==-1) continue ;
2222 hwadd = (Int_t)fHistChannelTime->GetCellContent(index,0);
2223
2224 // global fecnr
ca7b8371 2225 fecnr = fMapHand->GetFECfromHw(hwadd);
2226 if(compval[0]!=-1 && fecnr!=compval[0]) { fHist->SetCellContent(row-subrows+1,pad+1,0); continue; }
48265b32 2227
2228 // rcu
2229 rcuget = (hwadd & AliTPCMonitorAltro::GetHwMaskRCU())>> 12;
ca7b8371 2230 if(compval[1]!=-1 && rcuget!=compval[1]) { fHist->SetCellContent(row-subrows+1,pad+1,0); continue; }
48265b32 2231
2232 // branch
ca7b8371 2233 branch = fMapHand->U2fGetBranch(fecnr) ;
2234 if(compval[2]!=-1 && branch!=compval[2]) { fHist->SetCellContent(row-subrows+1,pad+1,0); continue; }
48265b32 2235
2236 // local fec
ca7b8371 2237 feclocbran= fMapHand->U2fGetFECinBranch(fecnr) ;
2238 if(compval[3]!=-1 && feclocbran!=compval[3]) { fHist->SetCellContent(row-subrows+1,pad+1,0); continue; }
48265b32 2239
2240 // connector
2241 connector = fMapHand->GetFECconnector(hwadd);
ca7b8371 2242 if(compval[4]!=-1 && connector!=compval[4]) { fHist->SetCellContent(row-subrows+1,pad+1,0); continue; }
48265b32 2243
2244 // Altro chip
ca7b8371 2245 altrochip = fMapHand->GetAltro(hwadd);
2246 if(compval[5]!=-1 && altrochip!=compval[5]) { fHist->SetCellContent(row-subrows+1,pad+1,0); continue; }
48265b32 2247 emptyI =0;
2248 }
2249 }
2250
2251 TCanvas* c1 =0;
2252 TCanvas* c2 =0;
2253 if(gROOT->GetListOfCanvases()->FindObject("ciroc"))
2254 {
2255 c1 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("ciroc");
2256 c1->cd() ;
2257 fHistIROC->Draw("COLZ");
2258 fHistIROC->SetMaximum(maxiroc);
2259 fHistIROC->SetMinimum(0.0);
2260 c1->Update();
2261 }
2262 if(gROOT->GetListOfCanvases()->FindObject("coroc"))
2263 {
2264 c2 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("coroc");
2265 c2->cd() ;
2266 fHistOROC->Draw("COLZ");
2267 fHistOROC->SetMaximum(maxoroc);
2268 fHistOROC->SetMinimum(0.0);
2269 c2->Update();
2270 }
2271 return ;
2272}
2273
2274//__________________________________________________________________
2275void AliTPCMonitor::ResizeCanv()
2276{
2277 // Resize canvases and delete some of them
2278
2279 Char_t carry1[100];
2280 sprintf(carry1,".x %s/TPC/AliTPCMonitorExec.C(1)",gSystem->Getenv("ALICE_ROOT"));
2281 Char_t carry3[100];
2282 sprintf(carry3,".x %s/TPC/AliTPCMonitorExec.C(2)",gSystem->Getenv("ALICE_ROOT"));
2283 if(fVerb) cout << " canv 1 " << endl;
2284
2285 if(gROOT->GetListOfCanvases()->FindObject( "coroc_ch")) { delete gROOT->GetListOfCanvases()->FindObject("coroc_ch") ; }
2286 if(gROOT->GetListOfCanvases()->FindObject( "ciroc_ch")) { delete gROOT->GetListOfCanvases()->FindObject("ciroc_ch") ; }
2287
2288 // for 2dim plots delete create and draw again
2289 if(gROOT->GetListOfCanvases()->FindObject("ciroc"))
2290 {
2291 delete gROOT->GetListOfCanvases()->FindObject("ciroc");
2292 TCanvas* ciroc = CreateCanvas("ciroc");
2293 ciroc->cd();
2294 fHistIROC->Draw("COLZ");
2295 ciroc->AddExec("pad",carry1);
2296 ciroc->AddExec("row",carry3);
2297 fExecPlaneMax=1;
2298 ciroc->Update();
2299 }
2300 // for 2dim plots delete create and draw again
2301 if(gROOT->GetListOfCanvases()->FindObject("coroc"))
2302 {
2303 delete gROOT->GetListOfCanvases()->FindObject("coroc");
2304 TCanvas* coroc = CreateCanvas("coroc");
2305 coroc->cd();
2306 fHistOROC->Draw("COLZ");
2307
2308 coroc->AddExec("pad",carry1);
2309 coroc->AddExec("row",carry3);
2310 coroc->Update();
2311 fExecPlaneMax=1;
2312 }
2313
2314 if(gROOT->GetListOfCanvases()->FindObject( "cbasemean")) { delete gROOT->GetListOfCanvases()->FindObject("cbasemean"); }
2315 if(gROOT->GetListOfCanvases()->FindObject( "cbase")) { delete gROOT->GetListOfCanvases()->FindObject("cbase");}
2316 if(gROOT->GetListOfCanvases()->FindObject( "cbaserms")) { delete gROOT->GetListOfCanvases()->FindObject("cbaserms"); }
2317 if(gROOT->GetListOfCanvases()->FindObject( "cmax")) { delete gROOT->GetListOfCanvases()->FindObject("cmax"); }
2318 if(gROOT->GetListOfCanvases()->FindObject( "csum")) { delete gROOT->GetListOfCanvases()->FindObject("csum"); }
2319 if(gROOT->GetListOfCanvases()->FindObject( "ciroc_ch_trans")) { delete gROOT->GetListOfCanvases()->FindObject("ciroc_ch_trans");}
2320 if(gROOT->GetListOfCanvases()->FindObject( "coroc_ch_trans")) { delete gROOT->GetListOfCanvases()->FindObject("coroc_ch_trans");}
ca7b8371 2321 if(gROOT->GetListOfCanvases()->FindObject( "crowtime")) { delete gROOT->GetListOfCanvases()->FindObject("crowtime"); }
2322 if(gROOT->GetListOfCanvases()->FindObject( "crowmax")) { delete gROOT->GetListOfCanvases()->FindObject("crowmax"); }
2323 if(gROOT->GetListOfCanvases()->FindObject( "cxmax")) { delete gROOT->GetListOfCanvases()->FindObject("cxmax"); }
48265b32 2324 if(gROOT->GetListOfCanvases()->FindObject( "crmsoroc")) { delete gROOT->GetListOfCanvases()->FindObject("crmsoroc"); fExecPadOrocRms = 0; }
2325 if(gROOT->GetListOfCanvases()->FindObject( "crmsiroc")) { delete gROOT->GetListOfCanvases()->FindObject("crmsiroc"); fExecPadIrocRms = 0; }
ca7b8371 2326 if(gROOT->GetListOfCanvases()->FindObject( "crowmax")) { delete gROOT->GetListOfCanvases()->FindObject("crowmax"); }
2327 if(gROOT->GetListOfCanvases()->FindObject( "crowmax")) { delete gROOT->GetListOfCanvases()->FindObject("crowmax"); }
48265b32 2328
2329}
2330
2331
2332
2333
2334//__________________________________________________________________
2335Int_t AliTPCMonitor::ExecProcess()
2336{
2337 // Executable for global Histogram
2338 // Will be called from /TPC/AliTPCMonitorExec.C(3)
2339 // Call ProcessEvent for same event and sector pointed at
2340
2341 Int_t side = 0;
2342 Int_t sector = 0;
2343
2344 Int_t event = gPad->GetEvent();
2345 if(event != 61) return -1;
2346
2347 TObject *select = gPad->GetSelected();
2348 if(!select) return -1;
2349 if(!select->InheritsFrom("TH2")) {gPad->SetUniqueID(0); return -1; }
2350 if( strcmp(select->GetName(),"hglobal" )==0 || ( strcmp(select->GetName(),"SIDE A" )==0) ) side = 0;
2351 else if( strcmp(select->GetName(),"hglobal2")==0 || ( strcmp(select->GetName(),"SIDE C" )==0) ) side = 1;
2352
2353 // get position
2354 Int_t px = gPad->GetEventX();
2355 Int_t py = gPad->GetEventY();
2356 Float_t upy = gPad->AbsPixeltoY(py);
2357 Float_t upx = gPad->AbsPixeltoX(px);
2358 Float_t y = gPad->PadtoY(upy);
2359 Float_t x = gPad->PadtoX(upx);
2360
2361 Int_t testy = ((TH2*)select)->GetYaxis()->FindBin(y);
2362 Int_t testx = ((TH2*)select)->GetXaxis()->FindBin(x);
2363 if(((TH2*)select)->GetCellContent(testx,testy)==0) return -1 ;
2364
2365 Float_t alpha = 0.0;
2366 if(x>0.0 && y > 0.0) alpha = TMath::Abs(TMath::ATan(TMath::Abs(x/y)));
2367 if(x>0.0 && y < 0.0) alpha = TMath::Abs(TMath::ATan(TMath::Abs(y/x)));
2368 if(x<0.0 && y < 0.0) alpha = TMath::Abs(TMath::ATan(TMath::Abs(x/y)));
2369 if(x<0.0 && y > 0.0) alpha = TMath::Abs(TMath::ATan(TMath::Abs(y/x)));
2370
2371 if(x>0.0 && y < 0.0) alpha += ( TMath::Pi()/2);
2372 if(x<0.0 && y < 0.0) alpha += ( TMath::Pi());
2373 if(x<0.0 && y > 0.0) alpha += (1.5*TMath::Pi());
2374
2375 sector = (Int_t)(alpha/(2*TMath::Pi()/18.0));
2376 if(alpha> (sector+0.5)*(2*TMath::Pi()/18.0)) sector+=1;
2377
2378 if(sector==18 && side ==0 ) {
2379 AliWarning("There was a wromg assignment of sector 0 with sector 18. Check sectors");
2380 sector =0;
2381 }
2382
2383 sector = (18-sector +4)%18;
2384 SetLastSector(sector+ side*18);
2385 SetProcNextEvent(0);
2386
2387 if(fVerb) cout << "AliTPCMonitor::ExecProcess() next side " << side << " next sector " << sector << endl;
2388
2389 return (Int_t)ProcessEvent();
2390
2391}
2392
2393//__________________________________________________________________
fb3305d1 2394Int_t AliTPCMonitor::GetRCUPatch(Int_t runid, Int_t eqid) const
48265b32 2395{
2396
2397 // Return RCU patch index for given equipment id eqid
2398 Int_t patch = 0;
2399 //if(runid>=704)
2400 if(runid>=0)
2401 {
2402 if(eqid>=1000) return 0;
2403 patch = fMapEqidsRcu[eqid] ;
2404 }
2405 else
2406 {
2407 if(eqid==408) {patch = 13*6+4 +0; }
2408 if(eqid==409) {patch = 13*6+5 +0; }
2409 if(eqid==509) {patch = 13*6+0 +0; }
2410 if(eqid==512) {patch = 13*6+3 +0; }
2411 if(eqid==513) {patch = 13*6+1 +0; }
2412 if(eqid==517) {patch = 13*6+2 +0; }
2413
2414 if(eqid==404) {patch = 4*6+5 +0; }
2415 if(eqid==504) {patch = 4*6+4 +0; }
2416 if(eqid==407) {patch = 4*6+3 +0; }
2417 if(eqid==503) {patch = 4*6+2 +0; }
2418 if(eqid==508) {patch = 4*6+1 +0; }
2419 if(eqid==506) {patch = 4*6+0 +0; }
2420 }
2421 return patch;
2422}
2423
2424//__________________________________________________________________
ca7b8371 2425void AliTPCMonitor::DumpHeader(AliRawReaderRoot * fReaderROOT) const
48265b32 2426{
2427 // Dump Event header for ROOT format
2428
2429 cout << "EventHeader : fReaderROOT->GetEquipmentSize() :" << fReaderROOT->GetEquipmentSize() << endl;
2430 cout << "EventHeader : fReaderROOT->GetType() :" << fReaderROOT->GetType() << endl;
2431 cout << "EventHeader : fReaderROOT->GetRunNumber() :" << fReaderROOT->GetRunNumber() << endl;
2432 cout << "EventHeader : fReaderROOT->GetEventId() :" << *(fReaderROOT->GetEventId()) << endl;
2433 cout << "EventHeader : fReaderROOT->GetLDCId() :" << fReaderROOT->GetLDCId() << endl;
2434 cout << "EventHeader : fReaderROOT->GetGDCId() :" << fReaderROOT->GetGDCId() << endl;
2435}
2436
2437//__________________________________________________________________
ca7b8371 2438void AliTPCMonitor::DumpHeader(AliTPCMonitorDateFormat* dateform) const
48265b32 2439{
2440 // Dump Event header for DATE format
2441
ca7b8371 2442 cout << "EquipmentHeader : dateform->GetEquipmentSize() :" << dateform->GetEquipmentSize() << endl;
2443 cout << "EquipmentHeader : dateform->GetEquipmentType() :" << dateform->GetEquipmentType() << endl;
2444 cout << "EquipmentHeader : dateform->GetEquipmentID() :" << dateform->GetEquipmentID() << endl;
2445 cout << "EquipmentHeader : dateform->GetEquipmentTypeAttribute() :" << dateform->GetEquipmentTypeAttribute() << endl;
2446 cout << "EquipmentHeader : dateform->GetEquipmentBasicSize() :" << dateform->GetEquipmentBasicSize() << endl;
2447 cout << "EquipmentHeader : dateform->GetEquipmentHeaderSize() :" << dateform->GetEquipmentHeaderSize() << endl;
2448 cout << "EquipmentHeader : dateform->IsLastSubEventHeader() :" << dateform->IsLastSubEventHeader() << endl;
48265b32 2449}
2450
2451//__________________________________________________________________
2452Double_t AliTPCMonitor::Gamma4(Double_t* x, Double_t* par) {
2453
2454 // Gamma4 function used to fit signals
2455 // Defined in sections: diverging branch set to 0
2456
2457 Double_t val = 0.0;
2458 if(x[0] > par[1])
2459 val = par[0]*exp(4.0)* pow((x[0]-par[1])/par[2],4)*exp(-4.0*(x[0]-par[1])/par[2])+ par[3];
2460 else
2461 val = 0;
2462 return val;
2463}
2464
2465//__________________________________________________________________
2466TCanvas* AliTPCMonitor::CreateCanvas(Char_t* name)
2467{
2468 // Create Canvases
2469
2470 TCanvas* canv =0;
2471
2472 Int_t xoffset = GetCanvasXOffset();
2473 Int_t xsize = GetCanvasXSize();
2474 Int_t ysize = GetCanvasYSize();
2475 Int_t xspace = GetCanvasXSpace();
2476 Int_t yspace = GetCanvasYSpace();
2477
2478 // ROC 2dim max distribution
2479 if( strcmp(name,"coroc" )==0) { canv = new TCanvas("coroc" ,"coroc" , -1+xoffset,(Int_t)(yspace+0.5*ysize) ,(Int_t)(1.5*xsize),(Int_t)(1.5*ysize)); return canv; }
2480 else if(strcmp(name,"ciroc" )==0) { canv = new TCanvas("ciroc" ,"ciroc" , -1+xoffset, 0 ,(Int_t)(1.5*xsize),(Int_t)(1.5*ysize)); return canv; }
2481 // ROC 2dim rms distribution
2482 else if(strcmp(name,"crmsoroc" )==0) { canv = new TCanvas("crmsoroc" ,"crmsoroc" , -1+xoffset,(Int_t)(yspace+0.5*ysize) ,(Int_t)(1.5*xsize),(Int_t)(1.5*ysize)); return canv; }
2483 else if(strcmp(name,"crmsiroc" )==0) { canv = new TCanvas("crmsiroc" ,"crmsiroc" , -1+xoffset, 0 ,(Int_t)(1.5*xsize),(Int_t)(1.5*ysize)); return canv; }
2484 // Global ADC max Histos
2485 else if(strcmp(name,"SIDE C all" )==0) { canv = new TCanvas("SIDE C all" ,"SIDE C all" , (Int_t)(3*xspace+ xoffset),(Int_t)(yspace+0.5*ysize) ,(Int_t)(1.5*xsize),(Int_t)(1.5*ysize)); return canv; }
2486 else if(strcmp(name,"SIDE A all" )==0) { canv = new TCanvas("SIDE A all" ,"SIDE A all" , (Int_t)(3*xspace+ xoffset), 0 ,(Int_t)(1.5*xsize),(Int_t)(1.5*ysize)); return canv; }
2487 // 1 dim max sum basekine distribution
2488 else if(strcmp(name,"cmax" )==0) { canv = new TCanvas("cmax" ,"cmax" , -1+xoffset, 3*yspace ,(Int_t)(1.0*xsize),(Int_t)(1.0*ysize)); return canv; }
2489 else if(strcmp(name,"csum" )==0) { canv = new TCanvas("csum" ,"csum" , xspace+xoffset, 3*yspace ,(Int_t)(1.0*xsize),(Int_t)(1.0*ysize)); return canv; }
2490 else if(strcmp(name,"cbasemean" )==0) { canv = new TCanvas("cbasemean" ,"cbasemean" , 2*xspace+xoffset, 3*yspace ,(Int_t)(1.0*xsize),(Int_t)(1.0*ysize)); return canv; }
2491 else if(strcmp(name,"cbaserms" )==0) { canv = new TCanvas("cbaserms" ,"cbaserms" , 3*xspace+xoffset, 3*yspace ,(Int_t)(1.0*xsize),(Int_t)(1.0*ysize)); return canv; }
2492 // Projections of single channel
2493 else if(strcmp(name,"coroc_ch" )==0) { canv = new TCanvas("coroc_ch" ,"coroc_ch" , (Int_t)(1.5*xspace+xoffset),(Int_t)(yspace+0.5*ysize),(Int_t)(1.5*xsize),(Int_t)(1.5*ysize)); return canv; }
2494 else if(strcmp(name,"ciroc_ch" )==0) { canv = new TCanvas("ciroc_ch" ,"ciroc_ch" , (Int_t)(1.5*xspace+xoffset), 0 ,(Int_t)(1.5*xsize),(Int_t)(1.5*ysize)); return canv; }
2495 // FFT for single channel
2496 else if(strcmp(name,"coroc_ch_trans")==0) { canv = new TCanvas("coroc_ch_trans","coroc_ch_trans",(Int_t)(3.0*xspace+xoffset),(Int_t)(yspace+0.5*ysize),(Int_t)(1.5*xsize),(Int_t)(1.5*ysize)); return canv; }
2497 else if(strcmp(name,"ciroc_ch_trans")==0) { canv = new TCanvas("ciroc_ch_trans","ciroc_ch_trans",(Int_t)(3.0*xspace+xoffset), 0 ,(Int_t)(1.5*xsize),(Int_t)(1.5*ysize)); return canv; }
2498 // row profile histograms
ca7b8371 2499 else if(strcmp(name,"crowtime" )==0) { canv = new TCanvas("crowtime" ,"crowtime" , 1*xspace+xoffset, 2*yspace +ysize ,(Int_t)(1.0*xsize),(Int_t)(1.0*ysize)); return canv; }
2500 else if(strcmp(name,"crowmax" )==0) { canv = new TCanvas("crowmax" ,"crowmax" , 2*xspace+xoffset, 2*yspace +ysize ,(Int_t)(1.0*xsize),(Int_t)(1.0*ysize)); return canv; }
2501 else if(strcmp(name,"cxmax" )==0) { canv = new TCanvas("cxmax" ,"cxmax" , 3*xspace+xoffset, 2*yspace +ysize ,(Int_t)(1.0*xsize),(Int_t)(1.0*ysize)); return canv; }
48265b32 2502 else { cout << " Warning Canvas name unknown " << endl; return 0 ; }
2503}
2504
2505//__________________________________________________________________
2506void AliTPCMonitor::WriteHistos()
2507{
2508 // Writes all available histograms to a file in current directory
2509 // File name will be specified by : sector, side, runid and eventnumber
2510
2511 if(GetEventProcessed())
2512 {
2513 AliInfo("Write histos to file");
2514 Char_t name[256];
2515 sprintf(name,"SIDE_%i_SECTOR_%02i_RUN_%05i_EventID_%06i.root",(GetLastSector()/18),(GetLastSector()%18),fRunId,fEventNumber);
2516 TFile* f = new TFile(name,"recreate");
2517 for(Int_t i =0; i<fHistList->GetEntries(); i++)
2518 {
2519 if(((TH1*)fHistList->At(i))!=0)
2520 {
2521 ((TH1*)fHistList->At(i))->Write();
2522 }
2523 }
2524 f->ls();
2525 f->Close();
2526 }
2527 else
2528 {
2529 AliError("No Event Processed : Chose Format , File and push 'Next Event' ");
2530 }
2531}
2532
2533
2534//__________________________________________________________________
2535TH1* AliTPCMonitor::GetHisto(char* histname)
2536{
2537
2538 // Returns histogram specified by histname
2539 // check available names for histos in CreateHistos()
2540
2541 TH1* hist = 0;
2542 if((TH1*)fHistList->FindObject(histname))
2543 {
2544 hist = (TH1*)fHistList->FindObject(histname);
2545 }
ca7b8371 2546 else
48265b32 2547 {
2548 cout << " AliTPCMonitor::GetHisto :: Can not find histo with name " << histname << endl;
2549 }
2550 return hist ;
2551}