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