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