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