]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCMonitor.cxx
Obsolete macro removed
[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       if (row==-1) continue;
955       padmax = fMapHand->GetNumofPads(row);
956       if (sector%36>17) fMirror=-1;
957       else fMirror=1;
958       GetXY(xval ,yval , padmax,row ,pad);
959       xdr    =  xval*m11 +yval*m12;
960       ydr    =  xval*m21 +yval*m22;
961       if(hglob->GetBinContent(hglob->GetXaxis()->FindBin(xdr),hglob->GetYaxis()->FindBin(ydr))==0)   hglob->Fill(xdr,ydr,(Int_t)max);
962     }
963   }
964 }
965
966
967 //__________________________________________________________________
968 void AliTPCMonitor::GetXY( Double_t& xval , Double_t& yval , Int_t padmax, Int_t row , Int_t pad) const 
969 {
970   // Get x and y position of pad
971   
972   if(row<63)
973   {
974     xval = fMirror*( 2*padmax -4*pad -2);
975     yval = 852.25 +7.5*row;
976   }
977   else
978   {
979     xval = fMirror*( 3*padmax -6*pad -3);
980     if((row-63)<63) {     yval = 10*(row-63) +1351;     }
981     else              {   yval = 15*(row-63-64)+1993.5; }
982   }
983   
984
985
986 //__________________________________________________________________
987 Int_t AliTPCMonitor::GetPadAtX(Float_t xval, Int_t row, Int_t padmax) const
988 {
989   // Get pad number at given position in x
990   Int_t pad    = 0;
991   
992   if(row<63) {pad = (Int_t)( ( (xval/fMirror) +2 -2*padmax)/-4);}
993   else       {pad = (Int_t)( ( (xval/fMirror) +3 -3*padmax)/-6);}
994   
995   if(pad>=padmax) return -1;
996   else            return pad ;
997   
998 }
999
1000 //__________________________________________________________________
1001 Int_t AliTPCMonitor::GetPadAtX(Float_t xval, Int_t row) const
1002 {
1003   
1004  // Get pad number at given position in x
1005   
1006   Int_t padmax = fMapHand->GetNumofPads(row);
1007   Int_t pad    = 0;
1008   
1009   if(row<63) {pad = (Int_t)( ( (xval/fMirror) +2 -2*padmax)/-4);}
1010   else       {pad = (Int_t)( ( (xval/fMirror) +3 -3*padmax)/-6);}
1011   
1012   if(pad>=padmax) return -1;
1013   else            return pad ;
1014   
1015 }
1016
1017 //__________________________________________________________________
1018 void AliTPCMonitor::DrawHists(Int_t histos) 
1019 {
1020   
1021   // Draw sets of histograms
1022   // histos==1 : 2Dim histos for MAX adc  and add executables
1023   // histos==2 : distributions max/rms/sum
1024   // histos==3 : global max adc for specified SideA/C
1025   
1026   
1027   if(fVerb)    cout << " Draw histos " << endl;
1028   TString cside;
1029   if(GetLastSector()/18==0 ) cside="A";
1030   else                       cside="C";
1031   
1032   TString titleSEC  = Form("Sector %i Side %s Run : %05i EventID %i "       ,GetLastSector()%18,cside.Data(),fRunId, fEventNumber);
1033   TString titleEvent= Form("Time <-> Channles  %s"                          ,titleSEC.Data());
1034   TString titleIROC = Form("IROC %s"                                        ,titleSEC.Data());
1035   TString titleOROC = Form("OROC %s"                                        ,titleSEC.Data());
1036   
1037   TString titleMAX  = Form("Max (timebin: %i,%i) %s"                        ,GetRangeMaxAdcMin(),GetRangeMaxAdcMax(),titleSEC.Data());
1038   TString titleSUM  = Form("Sum (timebin: %i,%i) %s"                        ,GetRangeSumMin()   ,GetRangeSumMax()   ,titleSEC.Data());
1039   TString titleBASE = Form("Baseline RMS<->Mean  (timebin: %i-%i) %s"       ,GetRangeBaseMin()  ,GetRangeBaseMax()  ,titleSEC.Data());
1040   TString titleMEAN = Form("Baseline Mean (timebin: %i-%i) %s"              ,GetRangeBaseMin()  ,GetRangeBaseMax()  ,titleSEC.Data());
1041   TString titleRMS  = Form("Baseline RMS (timebin: %i-%i) %s"               ,GetRangeBaseMin()  ,GetRangeBaseMax()  ,titleSEC.Data());
1042   
1043   if(histos==1)
1044   {
1045       // IROC _______________________________________________________________
1046     TCanvas* ciroc = 0;
1047     ciroc = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("ciroc");
1048     if(!ciroc)
1049     {
1050       ciroc = CreateCanvas("ciroc");
1051       fExecPlaneMax=0;
1052     }
1053     ciroc->cd();
1054     
1055     fHistIROC->SetXTitle("row");
1056     fHistIROC->SetYTitle("pad");
1057     if(GetPedestals()) fHistIROC->SetZTitle("max ADC (baseline sub)");
1058     else               fHistIROC->SetZTitle("max ADC ");
1059     fHistIROC->SetTitle(titleIROC.Data());
1060     fHistIROC->SetMinimum(0.01);
1061     fHistIROC->Draw("COLZ");
1062     ciroc->UseCurrentStyle();
1063     
1064     
1065     fHistIROCTime->SetXTitle("row"); fHistIROCTime->SetZTitle("peak time (fit)");       fHistIROCTime->SetYTitle("pad");      fHistIROCTime->SetTitle(titleIROC.Data());
1066     fHistIROCRMS->SetXTitle("row");  fHistIROCRMS->SetZTitle( "baseline rms (ADC)");    fHistIROCRMS->SetYTitle("pad");       fHistIROCRMS->SetTitle(titleIROC.Data());
1067     
1068       // OROC
1069     TCanvas* coroc = 0;
1070     coroc =(TCanvas*)gROOT->GetListOfCanvases()->FindObject("coroc");
1071     if(!coroc) {
1072       coroc = CreateCanvas("coroc");
1073       fExecPlaneMax=0;
1074     }
1075     coroc->cd();
1076     
1077     fHistOROC->SetXTitle("row");
1078     fHistOROC->SetYTitle("pad");
1079     if(GetPedestals()) fHistOROC->SetZTitle("max ADC (baseline sub)");
1080     else               fHistOROC->SetZTitle("max ADC ");
1081     fHistOROC->SetTitle(titleOROC.Data());
1082     fHistOROC->SetMinimum(0.01);
1083     fHistOROC->Draw("COLZ");
1084     coroc->UseCurrentStyle();
1085     
1086     
1087     fHistOROCTime->SetXTitle("row"); fHistOROCTime->SetZTitle("peak time (fit) (timebins)"); fHistOROCTime->SetYTitle("pad"); fHistOROCTime->SetTitle(titleOROC.Data());
1088     fHistOROCRMS->SetXTitle("row");  fHistOROCRMS->SetZTitle("baseline rms (ADC)");          fHistOROCRMS->SetYTitle("pad");  fHistOROCRMS->SetTitle(titleOROC.Data());
1089     
1090     // SUM
1091     TString namesum=Form("ADC sum (bins: %i, %i)",GetRangeSumMin() ,GetRangeSumMax() );
1092     fHistIROCSUM->SetXTitle("row");
1093     fHistIROCSUM->SetZTitle(namesum.Data());
1094     fHistIROCSUM->SetYTitle("pad");
1095     fHistIROCSUM->SetTitle(titleIROC.Data());
1096     
1097     fHistOROCSUM->SetXTitle("row");
1098     fHistOROCSUM->SetZTitle(namesum);
1099     fHistOROCSUM->SetYTitle("pad");
1100     fHistOROCSUM->SetTitle(titleOROC.Data());
1101     
1102     // BASE
1103     TString namebase=Form("base mean (timbebin: %i, %i )",GetRangeBaseMin(),GetRangeBaseMax());
1104     fHistIROCBASE->SetXTitle("row");
1105     fHistIROCBASE->SetZTitle(namebase.Data());
1106     fHistIROCBASE->SetYTitle("pad");
1107     fHistIROCBASE->SetTitle(titleIROC.Data());
1108     
1109     fHistOROCBASE->SetXTitle("row");
1110     fHistOROCBASE->SetZTitle(namebase);
1111     fHistOROCBASE->SetYTitle("pad");
1112     fHistOROCBASE->SetTitle(titleOROC.Data());
1113     
1114     if(fHistIROCClone) fHistIROCClone->Delete();
1115     if(fHistOROCClone) fHistOROCClone->Delete();
1116     fHistIROCClone = (TH2F*)fHistIROC->Clone("fHistIROCClone");
1117     fHistOROCClone = (TH2F*)fHistOROC->Clone("fHistOROCClone");
1118     
1119       // Executables
1120     if(fExecPlaneMax==0)
1121     {
1122       TString carry1=Form(".x %s/TPC/AliTPCMonitorExec.C(1)",gSystem->Getenv("ALICE_ROOT"));
1123       ciroc->AddExec("pad",carry1.Data());
1124       coroc->AddExec("pad",carry1.Data());
1125       
1126       TString carry2=Form(".x %s/TPC/AliTPCMonitorExec.C(2)",gSystem->Getenv("ALICE_ROOT"));
1127       ciroc->AddExec("row",carry2.Data());
1128       coroc->AddExec("row",carry2.Data());
1129       fExecPlaneMax=1;
1130     }
1131     coroc->Update();
1132     ciroc->Update();
1133   }
1134   else if(histos==2)
1135   {
1136       // MAX ADC distribution  ____________________________________________
1137     TCanvas* cmax = 0;
1138     cmax = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("cmax");
1139     if(!cmax)  cmax = CreateCanvas("cmax");
1140     
1141     cmax->cd();
1142     fHistDistrMaxIROC->GetXaxis()->SetRangeUser(0.0,1000.0);
1143     fHistDistrMaxIROC->SetXTitle("max ADC (ADC)");
1144     fHistDistrMaxIROC->SetYTitle("counts");
1145     fHistDistrMaxIROC->SetTitle(titleMAX.Data());
1146     fHistDistrMaxIROC->Draw("");
1147     fHistDistrMaxOROC->SetLineColor(2);
1148     fHistDistrMaxOROC->Draw("same");
1149     
1150     if(fHistDistrMaxOROC->GetMaximum()> fHistDistrMaxIROC->GetMaximum())  fHistDistrMaxIROC->SetMaximum(fHistDistrMaxOROC->GetMaximum()*1.1);
1151     
1152     TLegend* legio = new TLegend(0.6,0.6,0.8,0.8);
1153     legio->SetFillColor(0);
1154     legio->AddEntry(fHistDistrMaxIROC,"IROC","l");
1155     legio->AddEntry(fHistDistrMaxOROC,"OROC","l");
1156     legio->Draw("same");
1157     
1158       // ADC sum distribution
1159     TCanvas* csum = 0;
1160     csum = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("csum");
1161     if(!csum)  csum = CreateCanvas("csum") ;
1162     csum->cd();
1163     
1164     fHistDistrSumIROC->SetXTitle("sum ADC (ADC)");
1165     fHistDistrSumIROC->SetYTitle("counts");
1166     fHistDistrSumIROC->SetTitle(titleSUM.Data());
1167     fHistDistrSumIROC->Draw("");
1168     fHistDistrSumOROC->SetLineColor(2);
1169     fHistDistrSumOROC->Draw("same");
1170     if(fHistDistrSumOROC->GetMaximum()> fHistDistrSumIROC->GetMaximum())  fHistDistrSumIROC->SetMaximum(fHistDistrSumOROC->GetMaximum()*1.1);
1171     legio->Draw("same");
1172     
1173       // BASELINE MEAN distribution
1174     TCanvas* cbasemean = 0;
1175     cbasemean = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("cbasemean");
1176     if(!cbasemean)  cbasemean = CreateCanvas("cbasemean");
1177     cbasemean->cd();
1178     
1179     fHistDistrBaseMeanIROC = fHistDistrBase2dIROC->ProjectionX("fHistDistrBaseMeanIROC");
1180     fHistDistrBaseMeanIROC->SetXTitle("base mean (ADC)");
1181     fHistDistrBaseMeanIROC->SetYTitle("counts");
1182     fHistDistrBaseMeanIROC->SetTitle(titleMEAN.Data());
1183     fHistDistrBaseMeanIROC->Draw("");
1184     
1185     fHistDistrBaseMeanOROC = fHistDistrBase2dOROC->ProjectionX("fHistDistrBaseMeanOROC");
1186     fHistDistrBaseMeanOROC->SetLineColor(2);
1187     fHistDistrBaseMeanOROC->Draw("same");
1188     if(fHistDistrBaseMeanOROC->GetMaximum()>fHistDistrBaseMeanIROC->GetMaximum())   fHistDistrBaseMeanIROC->SetMaximum(fHistDistrBaseMeanOROC->GetMaximum()*1.1);
1189     legio->Draw("same");
1190     
1191     TCanvas* cbaserms = 0;
1192     cbaserms = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("cbaserms");
1193     if(!cbaserms) cbaserms = CreateCanvas("cbaserms") ;
1194     cbaserms->cd();
1195     
1196       // BASELINE RMS distribution
1197     fHistDistrBaseRmsIROC = fHistDistrBase2dIROC->ProjectionY("fHistDistrBaseRmsIROC");
1198     fHistDistrBaseRmsIROC->SetXTitle("base rms (ADC)");
1199     fHistDistrBaseRmsIROC->SetYTitle("counts");
1200     fHistDistrBaseRmsIROC->SetTitle(titleRMS.Data());
1201     fHistDistrBaseRmsIROC->Draw("");
1202     
1203     fHistDistrBaseRmsOROC = fHistDistrBase2dOROC->ProjectionY("fHistDistrBaseRmsOROC");
1204     fHistDistrBaseRmsOROC->SetLineColor(2);
1205     fHistDistrBaseRmsOROC->Draw("same");
1206     if(fHistDistrBaseRmsOROC->GetMaximum()>fHistDistrBaseRmsIROC->GetMaximum())  fHistDistrBaseRmsIROC->SetMaximum(fHistDistrBaseRmsOROC->GetMaximum()*1.1);
1207     legio->Draw("same");
1208     
1209     cmax->Update();
1210     csum->Update();
1211     cbasemean->Update();
1212     cbaserms->Update();
1213   }
1214   else  if(histos==3)
1215   {
1216       // GLOBAL MAX ADC _________________________________
1217     if(GetProcNextEvent()==1)
1218     {
1219       TCanvas* cglobA =0;
1220       TCanvas* cglobC =0;
1221       
1222       if(!(cglobC=(TCanvas*)gROOT->GetListOfCanvases()->FindObject("SIDE C all"))) cglobC = CreateCanvas("SIDE C all");
1223       if(!(cglobA=(TCanvas*)gROOT->GetListOfCanvases()->FindObject("SIDE A all"))) cglobA = CreateCanvas("SIDE A all");
1224       
1225       TString globtitle1=Form("SIDE A Run %05i (EventID %i)",fRunId,fEventNumber);
1226       TString globtitle2=Form("SIDE C Run %05i (EventID %i)",fRunId,fEventNumber);
1227       
1228       fHistGlobalMaxA->SetTitle(globtitle1.Data());
1229       fHistGlobalMaxC->SetTitle(globtitle2.Data());
1230       fHistGlobalMaxA->SetXTitle("x/mm");
1231       fHistGlobalMaxA->SetYTitle("y/mm");
1232       fHistGlobalMaxC->SetXTitle("x/mm");
1233       fHistGlobalMaxC->SetYTitle("y/mm");
1234       
1235       if(GetPedestals()==0)     {             fHistGlobalMaxA->SetZTitle("max adc (not baseline sub)");   fHistGlobalMaxC->SetZTitle("max adc (not baseline sub)");  }
1236       else                          {         fHistGlobalMaxA->SetZTitle("max adc ");                     fHistGlobalMaxC->SetZTitle("max adc ");                          }
1237       
1238       fHistGlobalMaxA->SetMinimum(0.01);
1239       fHistGlobalMaxC->SetMinimum(0.01);
1240       
1241       cglobC->cd() ; fHistGlobalMaxC->Draw("COLZ");
1242       cglobA->cd() ; fHistGlobalMaxA->Draw("COLZ");
1243       
1244       TString nameom=Form(".x  %s/TPC/AliTPCMonitorExec.C(3)",gSystem->Getenv("ALICE_ROOT"));
1245       
1246       if(fExecGlob==0)
1247       {
1248         if(fVerb)cout << " set exec " << nameom.Data() << endl;
1249         cglobC->AddExec("glob",nameom.Data());
1250         cglobA->AddExec("glob",nameom.Data());
1251         fExecGlob = 1;
1252       }
1253       else
1254       {
1255         cglobC->DeleteExec("glob");
1256         cglobA->DeleteExec("glob");
1257         
1258         if(fVerb)  cout << " set exec " << nameom.Data() << endl;
1259         cglobC->AddExec("glob",nameom.Data());
1260         cglobA->AddExec("glob",nameom.Data());
1261         
1262       }
1263       cglobC->Update();
1264       cglobA->Update();
1265     }
1266     
1267   }
1268 }
1269
1270
1271
1272 //__________________________________________________________________
1273 void AliTPCMonitor::DrawRMSMap() 
1274 {
1275   // Draw 2Dim rms histos for IROC and OROC
1276   // and set executables for canvases
1277   
1278   TCanvas* crmsoroc =0;
1279   TCanvas* crmsiroc =0;
1280   if(!(crmsoroc = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("crmsoroc")))    crmsoroc    = CreateCanvas("crmsoroc");
1281   if(!(crmsiroc = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("crmsiroc")))    crmsiroc    = CreateCanvas("crmsiroc");
1282   
1283   crmsiroc->cd();  fHistIROCRMS->Draw("COLZ");
1284   crmsoroc->cd();  fHistOROCRMS->Draw("COLZ");
1285   
1286   TString carry1=Form(".x %s/TPC/AliTPCMonitorExec.C(1)",gSystem->Getenv("ALICE_ROOT"));
1287   TString carry2=Form(".x %s/TPC/AliTPCMonitorExec.C(2)",gSystem->Getenv("ALICE_ROOT"));
1288   
1289   if(fExecPadIrocRms==0)
1290   {
1291     crmsiroc->AddExec("pad",carry1.Data());
1292     crmsiroc->AddExec("row",carry2.Data());
1293     fExecPadIrocRms=1;
1294   }
1295   
1296   if(fExecPadOrocRms==0)
1297   {
1298     crmsoroc->AddExec("pad",carry1.Data());
1299     crmsoroc->AddExec("row",carry2.Data());
1300     fExecPadOrocRms=1;
1301   }
1302   
1303   crmsiroc->Update();
1304   crmsoroc->Update();
1305   
1306   DrawHists(2);
1307   
1308 }
1309
1310 //__________________________________________________________________
1311 void AliTPCMonitor::ExecPad() 
1312 {
1313   
1314   // Executable for Pad
1315   // Show time profile for channel the mouse is pointing at
1316   
1317   Int_t event = gPad->GetEvent();
1318   if (event != 51)   return;
1319   
1320   TObject *select = gPad->GetSelected();
1321   if(!select)    return;
1322   if(!select->InheritsFrom("TH2")) { return;  }
1323   gPad->GetCanvas()->FeedbackMode(kTRUE);
1324   
1325   // get position
1326   Int_t    px        = gPad->GetEventX();
1327   Int_t    py        = gPad->GetEventY();
1328   Float_t  upy       = gPad->AbsPixeltoY(py);
1329   Float_t  upx       = gPad->AbsPixeltoX(px);
1330   Float_t  y         = gPad->PadtoY(upy);
1331   Float_t  x         = gPad->PadtoX(upx);
1332   
1333   Int_t    setrange  = 0;
1334   
1335   TCanvas* cpad      = 0;
1336   //  Char_t   namehist[50];
1337   TString   projhist;
1338   TString   namesel;
1339   TString   namecanv;
1340   
1341   Int_t    xbinmin  = 0;
1342   Int_t    xbinmax  = 0;
1343   Float_t  ybinmin  = 0;
1344   Float_t  ybinmax  = 0;
1345   Int_t    rocid     = 0;
1346   // Check wich Canvas executed the event
1347   TH2S* fHistIndex=0;
1348   namesel=select->GetName();
1349   if(namesel=="fHistOROC" || namesel=="fHistOROCRMS" || namesel=="fHistOROCTime" )
1350   {
1351     rocid = 1;
1352     fPadUsedRoc =1;
1353     projhist=Form("ProjectionOROC");
1354     namecanv=Form("coroc_ch");
1355     fHistIndex = fHistOROCIndex;
1356   }
1357   if(namesel=="fHistIROC" || namesel=="fHistIROCRMS" || namesel=="fHistIROCTime" )
1358   {
1359     rocid = 0;
1360     fPadUsedRoc=0;
1361     projhist=Form("ProjectionIROC");
1362     namecanv=Form("ciroc_ch");
1363     fHistIndex = fHistIROCIndex;
1364   }
1365   
1366   // Check if Canvas already existed and get Ranges from former Prjection histogram
1367   if((cpad=(TCanvas*)gROOT->GetListOfCanvases()->FindObject(namecanv)))
1368   {
1369     cpad->cd();
1370     if(gROOT->Get(projhist))
1371     {
1372       setrange = 1;
1373       xbinmin = ((TH1D*)gROOT->Get(projhist))->GetXaxis()->GetFirst();
1374       xbinmax = ((TH1D*)gROOT->Get(projhist))->GetXaxis()->GetLast();
1375       ybinmin = ((TH1D*)gROOT->Get(projhist))->GetMinimum();
1376       ybinmax = ((TH1D*)gROOT->Get(projhist))->GetMaximum();
1377       delete gROOT->Get("legfit");
1378       delete gROOT->Get("fg");
1379     }
1380   }
1381   else
1382   {
1383     cpad = CreateCanvas(namecanv); cpad->cd();
1384   }
1385   
1386   // Get Bin
1387   if (!fHistIndex) return;
1388   Int_t testy = fHistIndex->GetYaxis()->FindBin(y);
1389   Int_t testx = fHistIndex->GetXaxis()->FindBin(x);
1390   Int_t binchannel = (Int_t)fHistIndex->GetCellContent(testx,testy);
1391   if(binchannel>30000 || binchannel<0) return;
1392   
1393   TH1D *hp=(TH1D*)gROOT->Get(projhist);
1394   if(!hp)  hp=new TH1D(projhist,projhist,GetTimeBins(),0,GetTimeBins());//delete gROOT->Get(projhist);
1395   // Get Projection
1396 //   TH1D *hp = (TH1D*)(((TH1D*)fHistChannelTime->ProjectionY("hp",binchannel,binchannel))->Clone(projhist));
1397 //   TH1D *hp = fHistChannelTime->ProjectionY(projhist,binchannel,binchannel);
1398 //   hp->Reset();
1399   Int_t nbinsx=fHistChannelTime->GetNbinsX();
1400   for (Int_t itb=0;itb<GetTimeBins();++itb){
1401     hp->GetArray()[itb]=fHistChannelTime->GetArray()[binchannel+itb*(nbinsx+2)];
1402   }
1403 //   printf("hi\n");
1404 //   return;
1405   
1406   // Make title and Pave for channel Info
1407   Int_t npadRow , npad  , nhw , nmax , hwadd;
1408   
1409   hwadd   = (Int_t)fHistChannelTime->GetCellContent(binchannel,0);
1410   fPadUsedHwAddr = hwadd;
1411   
1412   if(rocid==0)npadRow = fMapHand->GetPadRow(hwadd);
1413   else        npadRow = fMapHand->GetPadRow(hwadd)-63;
1414   npad                = fMapHand->GetPad(hwadd);
1415   nhw                 = hwadd;
1416   nmax                = (Int_t)hp->GetMaximum();
1417   
1418   
1419   TPaveText*  legstat = new TPaveText(0.18,0.65,0.3,0.8,"NDC");
1420   
1421   Int_t   connector   =  fMapHand->GetFECconnector(hwadd);
1422   Int_t   fecnr       =  fMapHand->GetFECfromHw(hwadd);
1423   Int_t   fecch       =  fMapHand->GetFECchannel(hwadd);
1424   Int_t   altrochip   =  fMapHand->GetAltro(hwadd);
1425   Int_t   altrochannel=  (fMapHand->GetAltroChannel(hwadd))%16;
1426   Int_t   fecloc      =  fMapHand->U2fGetFECinRCU(fecnr) ;
1427   Int_t   feclocbran  =  fMapHand->U2fGetFECinBranch(fecnr);
1428   Int_t   branch      =  fMapHand->U2fGetBranch(fecnr);
1429   
1430   
1431   Short_t fecget      = (hwadd & fgkHwMaskFEC)   >> 7;
1432   Short_t branchget   = (hwadd & fgkHwMaskBranch)>> 11;
1433   
1434   legstat->AddText(Form("Branch (map) \t %i (%i) \n",branchget,branch));
1435   legstat->AddText(Form("Fec in patch \t %i \n",fecloc));
1436   legstat->AddText(Form("Fec in branch (map)\t %i (%i)\n",fecget,feclocbran));
1437   legstat->AddText(Form("Connector  \t %i \n",connector));
1438   legstat->AddText(Form("Fec No.   \t %i \n",fecnr));
1439   legstat->AddText(Form("Fec chan  \t %i \n",fecch));
1440   legstat->AddText(Form("Altro chip\t %i \n",altrochip));
1441   legstat->AddText(Form("Altro chan\t %i \n",altrochannel));
1442   
1443   TString title=Form("Row=%d Pad=%d Hw =%d maxADC =%d count =%d",npadRow,npad,nhw,nmax,binchannel);
1444   
1445 //   hp->SetName(projhist);
1446   hp->SetTitleSize(0.04);
1447   hp->SetTitle(title.Data());
1448   hp->SetYTitle("ADC");
1449   hp->SetXTitle("Timebin");
1450   hp->GetXaxis()->SetTitleColor(1);
1451   
1452   if(setrange)
1453   {
1454     hp->GetXaxis()->SetRange(xbinmin,xbinmax);
1455     hp->SetMinimum(ybinmin);
1456     hp->SetMaximum(ybinmax);
1457   }
1458   else
1459   {
1460     hp->SetMinimum(0.0);
1461     hp->SetMaximum(1000.0);
1462   }
1463   
1464   cpad->cd();
1465   hp->Draw();
1466   
1467   // Make Fit to peak
1468   if(GetPedestals() && fDisableFit==0)
1469   {
1470     Int_t maxx  =    (Int_t)fHistAddrMaxAdcX->GetBinContent(hwadd);
1471     Float_t max  =  (Float_t)fHistAddrMaxAdc->GetBinContent(hwadd);
1472     Float_t base =  (Float_t)fHistAddrBaseMean->GetBinContent(hwadd);
1473     if(base!=0)
1474     {
1475       if( ((max+base)/base)>1.2)
1476       {
1477         TF1* fg = new TF1("fg",AliTPCMonitor::Gamma4,maxx-5,maxx+5,4);
1478         fg->SetParName(0,"Normalisation");
1479         fg->SetParName(1,"Minimum");
1480         fg->SetParName(2,"Width");
1481         fg->SetParName(3,"Base");
1482         fg->SetParameter(0,max);
1483         fg->SetParameter(1,maxx-2);
1484         fg->SetParameter(2,1.5);
1485         fg->FixParameter(3,0);
1486         fg->SetLineColor(4);
1487         fg->SetLineWidth(1);
1488         hp->Fit("fg","RQ");
1489         
1490         TLegend* legfit = new TLegend(0.6,0.7,0.7,0.8);
1491         legfit->AddEntry("fg","#Gamma 4 fit","l");
1492         legfit->SetFillColor(0);
1493         legfit->SetName("legfit");
1494         legfit->Draw("same");
1495       }
1496     }
1497   }
1498   legstat->SetFillColor(0);
1499   legstat->Draw("same");
1500   cpad->Update();
1501   return;
1502 }
1503
1504 //__________________________________________________________________
1505 void AliTPCMonitor::ExecRow() 
1506 {
1507   
1508   // Executable for Pad
1509   // Show profile of max adc over given pad row
1510   // and 2dim histo  adc(pad-in-row,time bin)
1511   
1512   Int_t event = gPad->GetEvent();
1513   if (event != 61)    return;
1514   gPad->cd();
1515   TObject *select = gPad->GetSelected();
1516   if(!select)    return;
1517   if(!select->InheritsFrom("TH2")) {   return;  }
1518   
1519   Int_t rocid = 0;
1520   
1521   const Char_t *rowhist="hrowtime";
1522   const Char_t *rowhistxmax="hxmax";
1523   const Char_t *rowhistmax="hrowmax";
1524   
1525   // get position
1526   Int_t   px  = gPad->GetEventX();
1527   Int_t   py  = gPad->GetEventY();
1528   Float_t upy = gPad->AbsPixeltoY(py);
1529   Float_t upx = gPad->AbsPixeltoX(px);
1530   Float_t y   = gPad->PadtoY(upy);
1531   Float_t x   = gPad->PadtoX(upx);
1532   
1533   TCanvas*crowtime   = 0;
1534   TCanvas*crowmax    = 0;
1535   TCanvas*cxmax      = 0;
1536   
1537   TH2S*  fHistIndex  = 0;
1538   
1539   // ranges from already existing histos
1540   Int_t    rowtimexmin = 0;
1541   Int_t    rowtimexmax = 0;
1542   Int_t    rowtimeymin = 0;
1543   Int_t    rowtimeymax = 0;
1544   Float_t  rowtimezmin = 0;
1545   Float_t  rowtimezmax = 0;
1546   
1547   Int_t    profrowxmin = 0;
1548   Int_t    profrowxmax = 0;
1549   Double_t profrowymin = 0;
1550   Double_t profrowymax = 0;
1551   
1552   Int_t    profxxmin   = 0;
1553   Int_t    profxxmax   = 0;
1554   Double_t profxymin   = 0;
1555   Double_t profxymax   = 0;
1556   
1557   
1558   Int_t    setrange      = 0;
1559   
1560   TString name=select->GetName();
1561   if(     name=="fHistIROC" || name=="fHistIROCRMS" ) { fHistIndex = fHistIROCIndex;     rocid =1;   }
1562   else if(name=="fHistOROC" || name=="fHistOROCRMS" ) { fHistIndex = fHistOROCIndex;     rocid =2;   }
1563   else  { cout << " not implemented for this histo " << endl; return; }
1564   
1565   gPad->GetCanvas()->FeedbackMode(kTRUE);
1566   
1567   
1568   
1569   // check if canvases exist //
1570   crowtime  = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("crowtime");
1571   crowmax   = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("crowmax");
1572   cxmax     = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("cxmax");
1573   
1574   if(!crowtime)   crowtime   = CreateCanvas("crowtime") ;
1575   if(!crowmax)    crowmax    = CreateCanvas("crowmax")  ;
1576   if(!cxmax  )    cxmax      = CreateCanvas("cxmax")    ;
1577   
1578   // check ranges of already existing histos
1579   if(gROOT->Get(rowhist))
1580   {
1581     rowtimexmin  = ((TH2F*)gROOT->Get(rowhist))->GetXaxis()->GetFirst();
1582     rowtimexmax  = ((TH2F*)gROOT->Get(rowhist))->GetXaxis()->GetLast();
1583     rowtimeymin  = ((TH2F*)gROOT->Get(rowhist))->GetYaxis()->GetFirst();
1584     rowtimeymax  = ((TH2F*)gROOT->Get(rowhist))->GetYaxis()->GetLast();
1585     rowtimezmin  = ((TH2F*)gROOT->Get(rowhist))->GetMinimum();
1586     rowtimezmax  = ((TH2F*)gROOT->Get(rowhist))->GetMaximum();
1587     
1588     profrowxmin  = ((TH1F*)gROOT->Get(rowhistmax))->GetXaxis()->GetFirst();
1589     profrowxmax  = ((TH1F*)gROOT->Get(rowhistmax))->GetXaxis()->GetLast();
1590     profrowymin  = ((TH1F*)gROOT->Get(rowhistmax))->GetMinimum();
1591     profrowymax  = ((TH1F*)gROOT->Get(rowhistmax))->GetMaximum();
1592     
1593     profxxmin    = ((TH1F*)gROOT->Get(rowhistxmax))->GetXaxis()->GetFirst();
1594     profxxmax    = ((TH1F*)gROOT->Get(rowhistxmax))->GetXaxis()->GetLast();
1595     profxymin    = ((TH1F*)gROOT->Get(rowhistxmax))->GetMinimum();
1596     profxymax    = ((TH1F*)gROOT->Get(rowhistxmax))->GetMaximum();
1597     
1598     setrange =1;
1599     
1600     delete gROOT->Get(rowhist);
1601     delete gROOT->Get(rowhistmax);
1602     delete gROOT->Get("hxmax");
1603     delete gROOT->Get("legrow");
1604   }
1605   
1606   // get channel for xy bin -> getRow -> getNrows -> getHw for each Pad in Row -> get channel for each hw -> make proj
1607   Int_t testy      = fHistIndex->GetYaxis()->FindBin(y);
1608   Int_t testx      = fHistIndex->GetXaxis()->FindBin(x);
1609   Int_t binchannel = (Int_t)fHistIndex->GetCellContent(testx,testy);
1610   
1611   if(binchannel>30000)    return;
1612   if(binchannel<=0 ) { crowtime->Update() ;    crowmax->Update() ;    return ;  }
1613   
1614   // get hwaddress
1615   Int_t hwadd     = (Int_t)fHistChannelTime->GetCellContent(binchannel,0);
1616   Int_t row       = fMapHand->GetPadRow(hwadd);
1617   Int_t pad       = fMapHand->GetPad(hwadd)   ;
1618   Int_t numofpads =  fMapHand->GetNumofPads(row);
1619   
1620   // create histos
1621   TH2F *hrowtime = new TH2F(rowhist     , ""  ,numofpads,0,numofpads,GetTimeBins(),0.0,GetTimeBins());
1622   TH1F *hrowmax  = new TH1F(rowhistmax , ""  ,numofpads,0,numofpads);
1623   TH1F *hxmax    = new TH1F(rowhistxmax, ""  ,159,0,159      );
1624   
1625   // Row profile ///////////
1626   if(fVerb) cout << " Number of pads " << numofpads << endl;
1627   for(Int_t padnr = 0; padnr<numofpads;padnr++)
1628   {
1629     Int_t addrinrow = fMapHand->GetPadAddInRow(row,padnr );
1630     Int_t channel   = (Int_t)fHistAddrMapIndex->GetBinContent(addrinrow);
1631     if(channel==-1) continue;
1632     
1633     hrowmax->SetBinContent(padnr+1,fHistAddrMaxAdc->GetBinContent(addrinrow));
1634     TH1D *hp = fHistChannelTime->ProjectionY("hp",channel,channel);
1635     for(Int_t time = 0;time<GetTimeBins();time++) {
1636       
1637       Float_t val = hp->GetBinContent(time);
1638       hrowtime->SetCellContent(padnr+1,time+1,val);
1639     }
1640   }
1641   
1642   // X profile  /////////////
1643   Double_t xval  = 0.0;
1644   Double_t yval  = 0.0;
1645   GetXY(xval,yval,numofpads,row,pad);
1646   
1647   Int_t padnr = 0;
1648   Int_t hw    = 0;
1649   for(Int_t nrow = 0; nrow<159; nrow++)
1650   {
1651     padnr = GetPadAtX(xval,nrow);
1652     if(padnr>=0)
1653     {
1654       hw = fMapHand->GetPadAddInRow(nrow,padnr);
1655       if(fPadMapHw[hw]==-1){ continue                                                      ; }
1656       else                { hxmax->SetBinContent(nrow+1,fHistAddrMaxAdc->GetBinContent(hw))   ; }
1657     }
1658   }
1659   
1660   cxmax->cd();
1661   hxmax->SetTitle(Form("max adc in pads at x=%5.1f mm",xval));
1662   hxmax->SetXTitle("row");
1663   if(!GetPedestals()) hxmax->SetYTitle("max adc (baseline sub.)");
1664   else                hxmax->SetYTitle("max adc ");
1665   hxmax->SetMinimum(0.01);
1666   hxmax->Draw("l");
1667   
1668   if(setrange)
1669   {
1670     hxmax->GetXaxis()->SetRange(profxxmin,profxxmax);
1671     hxmax->SetMinimum(profxymin);
1672     hxmax->SetMaximum(profxymax);
1673   }
1674   
1675   cxmax->Update();
1676   
1677   crowtime->cd();
1678   TString title;
1679   TString titlemax;
1680   if(rocid==1) {
1681     title.Form("%s Row=%d",((TH2*)select)->GetTitle(),row)   ;
1682     titlemax.Form("IROC  max/sum Row=%d",row   );
1683   }  else  {
1684     title.Form("%s Row=%d",((TH2*)select)->GetTitle(),row-63);
1685     titlemax.Form("OROC  max/sum Row=%d",row-63);
1686   }
1687   
1688   if(fVerb) cout << " set name " << endl;
1689   
1690   
1691   // row vs time
1692   crowtime->cd();
1693   hrowtime->SetTitleSize(0.04);
1694   hrowtime->SetTitle(title.Data());
1695   hrowtime->SetYTitle("timbin");
1696   hrowtime->SetXTitle("pad in row");
1697   hrowtime->SetZTitle("signal (ADC)");
1698   
1699   hrowtime->GetXaxis()->SetTitleColor(1);
1700   hrowtime->SetMaximum(1000.0);
1701   hrowtime->SetMinimum(0.0);
1702   
1703   if(setrange)
1704   {
1705     hrowtime->GetXaxis()->SetRange(rowtimexmin,rowtimexmax);
1706     hrowtime->GetYaxis()->SetRange(rowtimeymin,rowtimeymax);
1707     hrowtime->SetMinimum(rowtimezmin);
1708     hrowtime->SetMaximum(rowtimezmax);
1709   }
1710   
1711   hrowtime->Draw("COLZ");
1712   crowtime->UseCurrentStyle();
1713   crowtime->Update();
1714   
1715   // max and sum /////////////////////////
1716   crowmax->cd();
1717   if(setrange) {
1718     hrowmax->GetXaxis()->SetRange(profrowxmin,profrowxmax);
1719     hrowmax->SetMinimum(profrowymin);
1720     hrowmax->SetMaximum(profrowymax);
1721   }
1722   hrowmax->SetTitleSize(0.04);
1723   hrowmax->SetTitle(title.Data());
1724   hrowmax->SetYTitle("max adc");
1725   hrowmax->SetXTitle("pad in row");
1726   hrowmax->GetXaxis()->SetTitleColor(1);
1727   
1728   hrowmax->SetLineColor(2);
1729   hrowmax->Draw("l");
1730   crowmax->Update();
1731   
1732   return;
1733 }
1734
1735 //__________________________________________________________________
1736 void AliTPCMonitor::Write10bitChannel()
1737 {
1738   
1739   // Write 10 bit words form histogram for active(last pointed)  channel
1740   
1741   if(fPadUsedHwAddr==-1){ AliWarning(" No active pad "); return ;}
1742   
1743   Int_t  pad     = (Int_t)fMapHand->GetPad(   fPadUsedHwAddr);
1744   Int_t  row     = (Int_t)fMapHand->GetPadRow(fPadUsedHwAddr);
1745   Int_t  channel = (Int_t)fPadMapHw[fPadUsedHwAddr];
1746   
1747   TString filenameroot;
1748   TString filenamedat;
1749   TString projhist;
1750   
1751   if(fPadUsedRoc==1) { projhist.Form("ProjectionOROC"); }
1752   if(fPadUsedRoc==0) { projhist.Form("ProjectionIROC"); }
1753   
1754   filenamedat.Form("Channel_Run%05i_EventID_%i_Pad_%i_Row_%i.dat"      ,fRunId,fEventNumber,pad,row);
1755   filenameroot.Form("Channel_Run%05i_EventID_%i_Pad_%i_Row_%i.root"     ,fRunId,fEventNumber,pad,row);
1756   
1757   TH1D* hpr = 0;
1758   if((hpr=(TH1D*)gROOT->Get(projhist)))
1759   {
1760       // root histo
1761     TFile f(filenameroot.Data(),"recreate");
1762     hpr->Write();
1763     f.Close();
1764     
1765       // raw singal
1766     ofstream datout(filenamedat.Data(),ios::out);
1767     datout <<"Timebin \t ADC value " << endl;
1768     for(Int_t i = 1; i <GetTimeBins(); i++)
1769     {
1770       datout << i << " \t \t " << fPad[channel][i] << endl;
1771     }
1772     datout.close();
1773   }
1774   else
1775   {
1776     AliWarning("No projection histo found ");
1777   }
1778 }
1779
1780 //__________________________________________________________________
1781 void AliTPCMonitor::ExecTransform() 
1782 {
1783   
1784   // Make Fast Fourier Transformation for active pad
1785   // fft is only performed for a data sample of size 2^n
1786   // reduce window according to largest  power of 2 which is smaller than the viewing  range
1787   
1788   TString namecanv;
1789   TString namecanv2;
1790   TString projhist;
1791   TString namehtrimag;
1792   TString namehtrreal;
1793   TString namehtrmag;
1794   
1795   if(fPadUsedRoc==1) {    namecanv="coroc_ch_trans"; namecanv2="coroc_ch_trans2";  projhist="ProjectionOROC";  }
1796   if(fPadUsedRoc==0) {    namecanv="ciroc_ch_trans"; namecanv2="ciroc_ch_trans2";  projhist="ProjectionIROC";  }
1797   
1798   TH1D*  hproj = 0;
1799   
1800   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 ;}
1801   else      hproj = (TH1D*)gROOT->Get(projhist.Data()) ;
1802   
1803   
1804   if(fPadUsedRoc==1) {  namehtrimag="htransimagfreq_oroc";    namehtrreal="htransrealfreq_oroc"; namehtrmag="htransmagfreq_oroc";  }
1805   else               {  namehtrimag="htransimagfreq_iroc";    namehtrreal="htransrealfreq_iroc"; namehtrmag="htransmagfreq_iroc";  }
1806   
1807   if( gROOT->Get(namehtrimag.Data()))  delete  gROOT->Get(namehtrimag.Data());
1808   if( gROOT->Get(namehtrreal.Data()))  delete  gROOT->Get(namehtrreal.Data());
1809   if( gROOT->Get(namehtrmag.Data()))  delete  gROOT->Get(namehtrmag.Data());
1810   
1811   TCanvas *ctrans = 0;
1812   if(!(ctrans = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(namecanv.Data())))
1813   {
1814     ctrans = CreateCanvas(namecanv.Data());
1815     ctrans->Divide(1,2);
1816   }
1817   TCanvas *ctrans2 = 0;
1818   if(!(ctrans2 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(namecanv2.Data())))
1819   {
1820     ctrans2 = CreateCanvas(namecanv2.Data());
1821 //      ctrans2->Divide(1,2);
1822   }
1823   
1824   Int_t binfirst  =  hproj->GetXaxis()->GetFirst();
1825   Int_t binlast   =  hproj->GetXaxis()->GetLast();
1826   Int_t bins       =  binlast -binfirst +1;
1827   
1828   Int_t power = 0;
1829   for(Int_t pot = 0; pot<=10 ; pot++)
1830   {
1831     Int_t comp =  (Int_t)TMath::Power(2,pot);
1832     if(bins>=comp)power = pot;
1833   }
1834   
1835   bins = (Int_t)TMath::Power(2,power);
1836   
1837   // sampling frequency ;
1838   Double_t  deltat = 1.0/(Float_t)GetSamplingFrequency();
1839   
1840   // output histo
1841   TH1D* htransrealfreq = new TH1D(namehtrreal.Data(),namehtrreal.Data(),10000,-1/(2*deltat),1/(2*deltat));
1842   TH1D* htransimagfreq = new TH1D(namehtrimag.Data(),namehtrimag.Data(),10000,-1/(2*deltat),1/(2*deltat));
1843   TH1D* htransmag      = new TH1D(namehtrmag.Data(),namehtrmag.Data(),10000,-1/(2*deltat),1/(2*deltat));
1844   
1845   TString titlereal;
1846   TString titleimag;
1847   TString titlemag;
1848   if(fPadUsedRoc==1) {    titlereal="OROC DFT real part";  titleimag="OROC DFT imag part";  titlemag="OROC DFT magnitude";  }
1849   else {                  titlereal="IROC DFT real part";  titleimag="IROC DFT imag part";  titlemag="IROC DFT magnitude";  }
1850   
1851   htransrealfreq->SetTitle(titlereal.Data());  htransrealfreq->SetXTitle("f/hz");  htransrealfreq->SetYTitle("z_{real}(f)");
1852   htransimagfreq->SetTitle(titleimag.Data());  htransimagfreq->SetXTitle("f/hz");  htransimagfreq->SetYTitle("z_{imag}(f)");
1853   htransmag->SetTitle(titlemag.Data());  htransmag->SetXTitle("f/hz");  htransmag->SetYTitle("mag(f)");
1854   
1855   // create complex packed data array
1856   const Int_t kdatasiz = 2*bins;
1857   Double_t*  data = new Double_t[kdatasiz];
1858   for(Int_t i=0;i<2*bins;i++)  { data[i]   =  0.0;}
1859   for(Int_t i=0;i<bins;i++)    { data[2*i] = (Double_t)hproj->GetBinContent(binfirst+i); }
1860   
1861   // make fourier transformation
1862   AliTPCMonitorFFT* four = new AliTPCMonitorFFT();
1863   four->ComplexRadix2ForwardWrap(data,1,bins);
1864   
1865   // write output  and fill histos forward
1866   Double_t freq =  0.0;
1867   for(Int_t i=0;i<2*bins;i++)
1868   {
1869     if(i<bins)
1870     {
1871       if(i<(bins/2))  { freq = i/(bins*deltat)            ; }
1872       else            { freq = -1*((bins-i)/(bins*deltat)); }
1873       htransrealfreq->Fill( freq,data[2*i]  );
1874       htransimagfreq->Fill( freq,data[2*i+1]);
1875       htransmag->Fill( freq, TMath::Sqrt(data[2*i]*data[2*i]+data[2*i+1]*data[2*i+1]) );
1876     }
1877   }
1878   
1879   ctrans->cd(1);
1880   htransrealfreq->Draw();
1881   ctrans->cd(2);
1882   htransimagfreq->Draw();
1883   ctrans->Update();
1884   ctrans2->cd();
1885   htransmag->Draw();
1886   ctrans2->Update();
1887   delete four;
1888   delete [] data;
1889 }
1890
1891 //__________________________________________________________________
1892 void AliTPCMonitor::ShowSel(Int_t* compval)               
1893 {
1894   
1895   // Show only selected components
1896   // First restore original histogram from clone
1897   // Than remove all not matching pads form histos
1898   
1899   Int_t   connector   =  0;
1900   Int_t   fecnr       =  0;
1901   Int_t   altrochip   =  0;
1902   Int_t   feclocbran  =  0;
1903   Int_t   branch      =  0;
1904   Short_t rcuget      =  0;
1905   Int_t   emptyI      =  1;
1906   Int_t   index       = -1;
1907   Int_t   hwadd       =  0;
1908   
1909   Float_t maxiroc     =  fHistIROCClone->GetMaximum();
1910   Float_t maxoroc     =  fHistOROCClone->GetMaximum();
1911   
1912   
1913   //  restore original histos
1914   for(Int_t row = 0; row<fkNRowsIroc;  row++)
1915   {
1916     for(Int_t pad = 0; pad<fkNPadsIroc;  pad++)
1917     {
1918       index = (Int_t)fHistIROCIndex->GetCellContent(row+1,pad+1);
1919       if(index==-1)continue;
1920       else  fHistIROC->SetCellContent(row+1,pad+1,fHistIROCClone->GetCellContent(row+1,pad+1));
1921     }
1922   }
1923   for(Int_t row = 0; row<fkNRowsOroc;  row++)
1924   {
1925     for(Int_t pad = 0; pad<fkNPadsOroc;  pad++)
1926     {
1927       index = (Int_t)fHistOROCIndex->GetCellContent(row+1,pad+1);
1928       if(index==-1)continue;
1929       else    fHistOROC->SetCellContent(row+1,pad+1,fHistOROCClone->GetCellContent(row+1,pad+1));
1930     }
1931   }
1932   
1933   
1934   // remove not matching entries from fHistIROC/fHistOROC
1935   
1936   TH2F* fHist       =0;
1937   TH2S* fHistIndex  =0;
1938   Int_t npads       =0;
1939   Int_t subrows     =0;
1940   
1941   for(Int_t row = 0; row< (fkNRowsIroc + fkNRowsOroc);  row++)
1942   {
1943     if(row<fkNRowsIroc) {  fHist=fHistIROC ; fHistIndex = fHistIROCIndex; npads = fkNPadsIroc; subrows =0         ;}
1944     else                {  fHist=fHistOROC ; fHistIndex = fHistOROCIndex; npads = fkNPadsOroc; subrows =fkNRowsIroc;}
1945     
1946     for(Int_t pad = 0; pad<npads;  pad++)
1947     {
1948       index    = (Int_t)fHistIndex->GetCellContent(row -subrows +1,pad+1);
1949       if(index==-1)  continue ;
1950       hwadd    = (Int_t)fHistChannelTime->GetCellContent(index,0);
1951       
1952     // global fecnr
1953       fecnr     =  fMapHand->GetFECfromHw(hwadd);
1954       if(compval[0]!=-1 && fecnr!=compval[0])      {      fHist->SetCellContent(row-subrows+1,pad+1,0);           continue;     }
1955       
1956     // rcu
1957       rcuget      = (hwadd & fgkHwMaskRCU)>> 12;
1958       if(compval[1]!=-1 && rcuget!=compval[1])     {      fHist->SetCellContent(row-subrows+1,pad+1,0);           continue;     }
1959       
1960     // branch
1961       branch    =  fMapHand->U2fGetBranch(fecnr) ;
1962       if(compval[2]!=-1 && branch!=compval[2])     {      fHist->SetCellContent(row-subrows+1,pad+1,0);           continue;     }
1963       
1964     // local fec
1965       feclocbran=   fMapHand->U2fGetFECinBranch(fecnr) ;
1966       if(compval[3]!=-1 && feclocbran!=compval[3]) {      fHist->SetCellContent(row-subrows+1,pad+1,0);           continue;     }
1967       
1968     // connector
1969       connector =  fMapHand->GetFECconnector(hwadd);
1970       if(compval[4]!=-1 && connector!=compval[4])  {      fHist->SetCellContent(row-subrows+1,pad+1,0);           continue;     }
1971       
1972     // Altro chip
1973       altrochip     =  fMapHand->GetAltro(hwadd);
1974       if(compval[5]!=-1 && altrochip!=compval[5])      {          fHist->SetCellContent(row-subrows+1,pad+1,0);           continue;     }
1975       emptyI =0;
1976     }
1977   }
1978   
1979   TCanvas* c1 =0;
1980   TCanvas* c2 =0;
1981   if(gROOT->GetListOfCanvases()->FindObject("ciroc"))
1982   {
1983     c1 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("ciroc");
1984     c1->cd() ;
1985     fHistIROC->Draw("COLZ");
1986     fHistIROC->SetMaximum(maxiroc);
1987     fHistIROC->SetMinimum(0.0);
1988     c1->Update();
1989   }
1990   if(gROOT->GetListOfCanvases()->FindObject("coroc"))
1991   {
1992     c2 =  (TCanvas*)gROOT->GetListOfCanvases()->FindObject("coroc");
1993     c2->cd() ;
1994     fHistOROC->Draw("COLZ");
1995     fHistOROC->SetMaximum(maxoroc);
1996     fHistOROC->SetMinimum(0.0);
1997     c2->Update();
1998   }
1999   return ;
2000 }
2001
2002 //__________________________________________________________________
2003 void AliTPCMonitor::ResizeCanv() 
2004 {
2005   // Resize canvases and delete some of them
2006   
2007   TString carry1=Form(".x %s/TPC/AliTPCMonitorExec.C(1)",gSystem->Getenv("ALICE_ROOT"));
2008   TString carry3=Form(".x %s/TPC/AliTPCMonitorExec.C(2)",gSystem->Getenv("ALICE_ROOT"));
2009   if(fVerb) cout <<  " canv 1 " << endl;
2010   
2011   if(gROOT->GetListOfCanvases()->FindObject(        "coroc_ch")) {  delete gROOT->GetListOfCanvases()->FindObject("coroc_ch") ; }
2012   if(gROOT->GetListOfCanvases()->FindObject(        "ciroc_ch")) {  delete gROOT->GetListOfCanvases()->FindObject("ciroc_ch") ; }
2013   
2014   // for 2dim plots delete create and draw again
2015   if(gROOT->GetListOfCanvases()->FindObject("ciroc"))
2016   {
2017     delete  gROOT->GetListOfCanvases()->FindObject("ciroc");
2018     TCanvas* ciroc = CreateCanvas("ciroc");
2019     ciroc->cd();
2020     fHistIROC->Draw("COLZ");
2021     ciroc->AddExec("pad",carry1.Data());
2022     ciroc->AddExec("row",carry3.Data());
2023     fExecPlaneMax=1;
2024     ciroc->Update();
2025   }
2026   // for 2dim plots delete create and draw again
2027   if(gROOT->GetListOfCanvases()->FindObject("coroc"))
2028   {
2029     delete gROOT->GetListOfCanvases()->FindObject("coroc");
2030     TCanvas* coroc = CreateCanvas("coroc");
2031     coroc->cd();
2032     fHistOROC->Draw("COLZ");
2033     
2034     coroc->AddExec("pad",carry1.Data());
2035     coroc->AddExec("row",carry3.Data());
2036     coroc->Update();
2037     fExecPlaneMax=1;
2038   }
2039   
2040   if(gROOT->GetListOfCanvases()->FindObject(       "cbasemean")) {    delete gROOT->GetListOfCanvases()->FindObject("cbasemean"); }
2041   if(gROOT->GetListOfCanvases()->FindObject(           "cbase")) {    delete gROOT->GetListOfCanvases()->FindObject("cbase");}
2042   if(gROOT->GetListOfCanvases()->FindObject(        "cbaserms")) {    delete gROOT->GetListOfCanvases()->FindObject("cbaserms");  }
2043   if(gROOT->GetListOfCanvases()->FindObject(            "cmax")) {    delete gROOT->GetListOfCanvases()->FindObject("cmax");      }
2044   if(gROOT->GetListOfCanvases()->FindObject(            "csum")) {    delete gROOT->GetListOfCanvases()->FindObject("csum");      }
2045   if(gROOT->GetListOfCanvases()->FindObject(  "ciroc_ch_trans")) {    delete gROOT->GetListOfCanvases()->FindObject("ciroc_ch_trans");}
2046   if(gROOT->GetListOfCanvases()->FindObject(  "coroc_ch_trans")) {    delete gROOT->GetListOfCanvases()->FindObject("coroc_ch_trans");}
2047   if(gROOT->GetListOfCanvases()->FindObject(       "crowtime")) {    delete gROOT->GetListOfCanvases()->FindObject("crowtime"); }
2048   if(gROOT->GetListOfCanvases()->FindObject(        "crowmax")) {    delete gROOT->GetListOfCanvases()->FindObject("crowmax");  }
2049   if(gROOT->GetListOfCanvases()->FindObject(          "cxmax")) {    delete gROOT->GetListOfCanvases()->FindObject("cxmax");    }
2050   if(gROOT->GetListOfCanvases()->FindObject(        "crmsoroc")) {    delete gROOT->GetListOfCanvases()->FindObject("crmsoroc");         fExecPadOrocRms = 0;   }
2051   if(gROOT->GetListOfCanvases()->FindObject(        "crmsiroc")) {    delete gROOT->GetListOfCanvases()->FindObject("crmsiroc");         fExecPadIrocRms = 0;   }
2052   if(gROOT->GetListOfCanvases()->FindObject(        "crowmax")) {    delete gROOT->GetListOfCanvases()->FindObject("crowmax");  }
2053   if(gROOT->GetListOfCanvases()->FindObject(        "crowmax")) {    delete gROOT->GetListOfCanvases()->FindObject("crowmax");  }
2054   
2055 }
2056
2057
2058
2059
2060 //__________________________________________________________________
2061 Int_t AliTPCMonitor::ExecProcess() 
2062 {
2063   // Executable for global Histogram
2064   // Will be called from /TPC/AliTPCMonitorExec.C(3)
2065   // Call ProcessEvent for same event and sector pointed at
2066   
2067   Int_t side   = 0;
2068   Int_t sector = 0;
2069   
2070   Int_t event = gPad->GetEvent();
2071   if(event != 61)  return -1;
2072   
2073   TObject *select = gPad->GetSelected();
2074   if(!select)  return -1;
2075   TString name=select->GetName();
2076   if(!select->InheritsFrom("TH2")) {gPad->SetUniqueID(0);    return -1;  }
2077   if(       name=="hglobal"  || name=="SIDE A"  ) side = 0;
2078   else  if( name=="hglobal2" || name=="SIDE C"  ) side = 1;
2079   
2080   // get position
2081   Int_t   px    = gPad->GetEventX();
2082   Int_t   py    = gPad->GetEventY();
2083   Float_t upy   = gPad->AbsPixeltoY(py);
2084   Float_t upx   = gPad->AbsPixeltoX(px);
2085   Float_t y     = gPad->PadtoY(upy);
2086   Float_t x     = gPad->PadtoX(upx);
2087   
2088   Int_t testy = ((TH2*)select)->GetYaxis()->FindBin(y);
2089   Int_t testx = ((TH2*)select)->GetXaxis()->FindBin(x);
2090   if(((TH2*)select)->GetCellContent(testx,testy)==0) return -1 ;
2091   
2092   Float_t alpha = 0.0;
2093   if(x>0.0 && y > 0.0)    alpha = TMath::Abs(TMath::ATan(TMath::Abs(x/y)));
2094   if(x>0.0 && y < 0.0)    alpha = TMath::Abs(TMath::ATan(TMath::Abs(y/x)));
2095   if(x<0.0 && y < 0.0)    alpha = TMath::Abs(TMath::ATan(TMath::Abs(x/y)));
2096   if(x<0.0 && y > 0.0)    alpha = TMath::Abs(TMath::ATan(TMath::Abs(y/x)));
2097   
2098   if(x>0.0 && y < 0.0)    alpha += (    TMath::Pi()/2);
2099   if(x<0.0 && y < 0.0)    alpha += (    TMath::Pi());
2100   if(x<0.0 && y > 0.0)    alpha += (1.5*TMath::Pi());
2101   
2102   sector =   (Int_t)(alpha/(2*TMath::Pi()/18.0));
2103   if(alpha> (sector+0.5)*(2*TMath::Pi()/18.0))  sector+=1;
2104   
2105   if(sector==18 && side ==0 ) {
2106     AliWarning("There was a wromg assignment of sector 0 with sector 18. Check sectors");
2107     sector =0;
2108   }
2109   
2110   sector = (18-sector +4)%18;
2111   SetLastSector(sector+ side*18);
2112   SetProcNextEvent(0);
2113   
2114   if(fVerb) cout << "AliTPCMonitor::ExecProcess()  next side          " <<   side    << " next sector        " <<    sector  << endl;
2115   
2116   return (Int_t)ProcessEvent();
2117   
2118 }
2119
2120 //__________________________________________________________________
2121 Int_t AliTPCMonitor::GetRCUPatch(Int_t runid, Int_t eqid) const
2122 {
2123   
2124   // Return RCU patch index for given equipment id eqid
2125   Int_t patch = 0;
2126   //if(runid>=704)
2127   if(runid>=0)
2128   {
2129     if ( eqid<768 || eqid>983 ) return 0; //no TPC eqid
2130 //     if(eqid>=1000) return 0;
2131     patch = fMapEqidsRcu[eqid] ;
2132   }
2133   else
2134   {
2135     if(eqid==408) {patch =  13*6+4 +0;  }
2136     if(eqid==409) {patch =  13*6+5 +0;  }
2137     if(eqid==509) {patch =  13*6+0 +0;  }
2138     if(eqid==512) {patch =  13*6+3 +0;  }
2139     if(eqid==513) {patch =  13*6+1 +0;  }
2140     if(eqid==517) {patch =  13*6+2 +0;  }
2141     
2142     if(eqid==404) {patch =  4*6+5 +0;   }
2143     if(eqid==504) {patch =  4*6+4 +0;   }
2144     if(eqid==407) {patch =  4*6+3 +0;   }
2145     if(eqid==503) {patch =  4*6+2 +0;   }
2146     if(eqid==508) {patch =  4*6+1 +0;   }
2147     if(eqid==506) {patch =  4*6+0 +0;   }
2148   }
2149   return patch;
2150 }
2151
2152 //__________________________________________________________________
2153 void AliTPCMonitor::DumpHeader(AliRawReader * reader) const
2154 {
2155   // Dump Event header for  format
2156   
2157   cout << "EventHeader     : fReader->GetEquipmentSize()            :" << reader->GetEquipmentSize()        << endl;
2158   cout << "EventHeader     : fReader->GetType()                     :" << reader->GetType()                 << endl;
2159   cout << "EventHeader     : fReader->GetRunNumber()                :" << reader->GetRunNumber()            << endl;
2160   cout << "EventHeader     : fReader->GetEventId()                  :" << *(reader->GetEventId())           << endl;
2161   cout << "EventHeader     : fReader->GetLDCId()                    :" << reader->GetLDCId()                << endl;
2162   cout << "EventHeader     : fReader->GetGDCId()                    :" << reader->GetGDCId()                << endl;
2163 }
2164
2165
2166 //__________________________________________________________________
2167 Double_t AliTPCMonitor::Gamma4(Double_t* x, Double_t* par) {
2168   
2169   // Gamma4 function used to fit signals
2170   // Defined in sections: diverging branch set to 0
2171   
2172   Double_t val  = 0.0;
2173   if(x[0] > par[1])
2174     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];
2175   else
2176     val = 0;
2177   return val;
2178 }
2179
2180 //__________________________________________________________________
2181 TCanvas* AliTPCMonitor::CreateCanvas(const Char_t* name)
2182 {
2183   // Create Canvases
2184   
2185   TCanvas* canv =0;
2186   
2187   Int_t xoffset  = GetCanvasXOffset();
2188   Int_t xsize    = GetCanvasXSize();
2189   Int_t ysize    = GetCanvasYSize();
2190   Int_t xspace   = GetCanvasXSpace();
2191   Int_t yspace   = GetCanvasYSpace();
2192
2193   TString sname=name;
2194   // ROC 2dim max distribution
2195   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;  }
2196   else if(sname=="ciroc") {    canv   = new TCanvas("ciroc"         ,"ciroc"      ,                   -1+xoffset,                     0    ,(Int_t)(1.5*xsize),(Int_t)(1.5*ysize)); return canv;  }
2197   // ROC  2dim rms distribution
2198   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;  }
2199   else if(sname=="crmsiroc") {    canv   = new TCanvas("crmsiroc"      ,"crmsiroc"   ,                   -1+xoffset,                        0 ,(Int_t)(1.5*xsize),(Int_t)(1.5*ysize)); return canv;  }
2200   // Global ADC max Histos
2201   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;  }
2202   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;  }
2203   // 1 dim max sum basekine distribution
2204   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;  }
2205   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;  }
2206   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;  }
2207   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;  }
2208   // Projections of single channel
2209   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;  }
2210   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;  }
2211   // FFT for single channel
2212   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;  }
2213   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;  }
2214   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;  }
2215   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;  }
2216   // row profile histograms
2217   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;  }
2218   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;  }
2219   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;  }
2220   else                                      {    cout   << " Warning Canvas name unknown "  << endl;                                                                                                  return 0   ;  }
2221 }
2222
2223 //__________________________________________________________________
2224 void AliTPCMonitor::WriteHistos()  
2225 {
2226   // Writes all available histograms to a file in current directory
2227   // File name will be specified by : sector, side, runid and eventnumber
2228   
2229   if(GetEventProcessed())
2230   {
2231     AliInfo("Write histos to file");
2232     TString name=Form("SIDE_%i_SECTOR_%02i_RUN_%05i_EventID_%06i.root",(GetLastSector()/18),(GetLastSector()%18),fRunId,fEventNumber);
2233     TFile* f = new TFile(name.Data(),"recreate");
2234     for(Int_t i =0; i<fHistList->GetEntries(); i++)
2235     {
2236       if(((TH1*)fHistList->At(i))!=0)
2237       {
2238         ((TH1*)fHistList->At(i))->Write();
2239       }
2240     }
2241     f->ls();
2242     f->Close();
2243   }
2244   else
2245   {
2246     AliError("No Event Processed : Chose Format , File and push 'Next Event' ");
2247   }
2248 }
2249
2250
2251 //__________________________________________________________________
2252 TH1* AliTPCMonitor::GetHisto(char* histname) 
2253 {
2254   
2255   // Returns histogram specified by histname
2256   // check available names for histos in CreateHistos()
2257   
2258   TH1* hist = 0;
2259   if((TH1*)fHistList->FindObject(histname))
2260   {
2261     hist = (TH1*)fHistList->FindObject(histname);
2262   }
2263   else
2264   {
2265     cout << " AliTPCMonitor::GetHisto :: Can not find histo with name " << histname << endl;
2266   }
2267   return hist ;
2268 }