Separating run-dependent mapping data from data, which are not
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerEfficiencyCells.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 // $Id$
17
18 #include "AliMUONTriggerEfficiencyCells.h"
19 #include "AliMpConstants.h"
20
21 // Classes for display
22 #include "AliMUONTriggerDisplay.h"
23 #include "AliCDBManager.h"
24 #include "AliMpDDLStore.h"
25 #include "AliMpLocalBoard.h"
26 #include "AliMpPad.h"
27 #include "AliMpVSegmentation.h"
28 #include "AliMpSegmentation.h"
29
30 #include "AliLog.h"
31
32 #include "TRandom.h"
33 #include "Riostream.h"
34 #include "TSystem.h"
35 #include "TFile.h"
36 #include "TH1F.h"
37 #include "TMath.h"
38
39 #include "TH2F.h"
40 #include "TH3F.h"
41 #include "TF1.h"
42 #include "TStyle.h"
43 #include "TPaveLabel.h"
44 #include "TCanvas.h"
45
46 #include <fstream>
47 #include <cassert>
48
49 //-----------------------------------------------------------------------------
50 /// \class AliMUONTriggerEfficiencyCells
51 /// A class to store and give access to the trigger chamber efficiency.
52 ///
53 /// Efficiency is stored per cathode on local boards
54 ///
55 /// The main method of this class is IsTriggered().
56 ///
57 /// $ALICE_ROOT/MUON/data/efficiencyCells.dat contains efficiency 
58 /// for each chamber (i.e. DetElement). 
59 ///
60 /// In the case of local boards, efficiency is stored from left to right
61 /// per increasing board number (from 1 to 234)
62 ///
63 /// The file can be edited in order to change efficiency
64 /// in a chosen local board/region of the chamber.
65 ///
66 ///
67 /// But please note that this object is also available from the CDB 
68 ///
69 /// \author Diego Stocco; INFN Torino
70 //-----------------------------------------------------------------------------
71
72 /// \cond CLASSIMP
73 ClassImp(AliMUONTriggerEfficiencyCells)
74 /// \endcond
75
76 //__________________________________________________________________________
77 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells()
78 :
79 TObject(),
80 fCountHistoList(0x0),
81 fNoCountHistoList(0x0),
82 fFiredStrips(0x0),
83 fDisplayHistoList(0x0),
84 fBoardLabelList(0x0),
85 fFiredFitHistoList(0x0),
86 fFiredDisplayHistoList(0x0)
87 {
88 ///  Default constructor.
89   CheckConstants();
90   Reset();
91   InitHistos();
92 }
93
94 //__________________________________________________________________________
95 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const Char_t* filename)
96 :
97 TObject(),
98 fCountHistoList(0x0),
99 fNoCountHistoList(0x0),
100 fFiredStrips(0x0),
101 fDisplayHistoList(0x0),
102 fBoardLabelList(0x0),
103 fFiredFitHistoList(0x0),
104 fFiredDisplayHistoList(0x0)
105 {
106 ///  Constructor using an ASCII file.
107   CheckConstants();
108   Reset();
109   ReadFile(filename);
110 }
111
112 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(TList *countHistoList,
113                                                              TList *noCountHistoList)
114 :
115 TObject(),
116 fCountHistoList(countHistoList),
117 fNoCountHistoList(noCountHistoList),
118 fFiredStrips(0x0),
119 fDisplayHistoList(0x0),
120 fBoardLabelList(0x0),
121 fFiredFitHistoList(0x0),
122 fFiredDisplayHistoList(0x0)
123 {
124 ///  Constructor using an ASCII file.
125   CheckConstants();
126   Reset();
127   InitHistos();
128   FillHistosFromList();
129 }
130
131 //_____________________________________________________________________________
132 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const AliMUONTriggerEfficiencyCells& other)
133 :
134 TObject(other),
135 fCountHistoList(other.fCountHistoList),
136 fNoCountHistoList(other.fNoCountHistoList),
137 fFiredStrips(other.fFiredStrips),
138 fDisplayHistoList(other.fDisplayHistoList),
139 fBoardLabelList(other.fBoardLabelList),
140 fFiredFitHistoList(other.fFiredFitHistoList),
141 fFiredDisplayHistoList(other.fFiredDisplayHistoList)
142 {
143 /// Copy constructor
144
145   for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
146     fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
147     fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
148   }
149 }
150
151 //_____________________________________________________________________________
152 AliMUONTriggerEfficiencyCells& AliMUONTriggerEfficiencyCells::operator=(const AliMUONTriggerEfficiencyCells& other)
153 {
154   /// Asignment operator
155   // check assignement to self
156   if (this == &other)
157     return *this;
158
159   for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
160     fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
161     fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
162   }
163
164   fCountHistoList = other.fCountHistoList;
165   fNoCountHistoList = other.fNoCountHistoList;
166   fFiredStrips = other.fFiredStrips;
167
168   fDisplayHistoList = other.fDisplayHistoList;
169   fBoardLabelList = other.fBoardLabelList;
170   fFiredFitHistoList = other.fFiredFitHistoList;
171   fFiredDisplayHistoList = other.fFiredDisplayHistoList;
172     
173   return *this;
174 }
175
176 //__________________________________________________________________________
177 AliMUONTriggerEfficiencyCells::~AliMUONTriggerEfficiencyCells()
178 {
179 ///  Destructor.
180 }
181
182
183 //__________________________________________________________________________
184 void AliMUONTriggerEfficiencyCells::GetCellEfficiency(Int_t detElemId, Int_t localBoard, Float_t &eff1, Float_t &eff2) const
185 {
186 ///  Get the efficiencies of the 2 cathodes at a given local board
187
188   Int_t chamber = FindChamberIndex(detElemId);
189   Int_t bin = fBoardEfficiency[chamber]->FindBin(localBoard);
190   eff1 = fBoardEfficiency[chamber]->GetBinContent(bin);
191   eff2 = fBoardEfficiency[fgkNchambers+chamber]->GetBinContent(bin);
192 }
193
194
195 //__________________________________________________________________________
196 void 
197 AliMUONTriggerEfficiencyCells::IsTriggered(Int_t detElemId, Int_t localBoard, Bool_t &trig1, Bool_t &trig2) const
198 {
199 ///  Whether or not a given local board has a chance to trig, on each cathode.
200
201   Float_t eff1 = 0.0;
202   Float_t eff2 = 0.0;
203   GetCellEfficiency(detElemId, localBoard, eff1, eff2);
204   trig1 = kTRUE; 
205   trig2 = kTRUE;
206   if(gRandom->Rndm()>eff1)trig1 = kFALSE;
207   if(gRandom->Rndm()>eff2)trig2 = kFALSE;
208 }
209
210
211 //__________________________________________________________________________
212 void AliMUONTriggerEfficiencyCells::ReadFile(const Char_t* filename)
213 {
214 ///  Reads a file containing the efficiency map.
215
216   TString fileName = gSystem->ExpandPathName(filename);
217   if(fileName.EndsWith(".root")){
218       ReadHistoBoards(fileName.Data());
219       return;
220   }
221
222   InitHistos();
223   ifstream file(fileName.Data());
224   Char_t dat[50];
225   if (file.good()){
226       file >> dat;
227       if(!strcmp(dat,"localBoards"))ReadFileBoards(file);
228       else AliWarning("File .dat in wrong format");
229       file.close();
230   } else {
231       AliWarning(Form("Can't read file %s",fileName.Data()));
232   }
233 }
234
235
236 //__________________________________________________________________________
237 void AliMUONTriggerEfficiencyCells::ReadFileBoards(ifstream &file)
238 {
239 ///  Structure of file (.dat) containing local board efficency
240   Int_t datInt=0, detEl=0, chamber=0, chCath=0, bin=0;
241     Float_t datFloat=0.0;
242     Char_t dat[50];
243
244     while (file >> dat) {
245             file >> detEl;
246             chamber = FindChamberIndex(detEl);
247             for(Int_t cath=0; cath<fgkNcathodes; cath++){
248                 chCath = fgkNchambers*cath + chamber;
249                 file >> dat;
250                 file >> datInt;
251                 for(Int_t board=1; board<=AliMpConstants::NofLocalBoards(); board++){
252                     file >> datFloat;
253                     bin = fBoardEfficiency[chCath]->FindBin(board);
254                     fBoardEfficiency[chCath]->SetBinContent(bin, datFloat);
255                 }
256             }
257     }
258 }
259
260
261 //__________________________________________________________________________
262 void AliMUONTriggerEfficiencyCells::ReadHistoBoards(const Char_t *filename)
263 {
264 ///  Structure of file (.root) containing local board efficency
265     TFile *file = new TFile(filename, "read");
266     if(!file) {
267         AliWarning(Form("Can't read file %s",filename));
268         return;
269     }
270     TString histoName;
271     TString cathCode[fgkNcathodes] = {"bendPlane", "nonBendPlane"};
272     enum {kAllChEff, kChNonEff, kNumOfHistoTypes};
273     TString histoTypeName[2] = {"CountInCh", "NonCountInCh"};
274
275     if(!fCountHistoList) fCountHistoList = new TList();
276     else fCountHistoList->Delete();
277     if(!fNoCountHistoList) fNoCountHistoList = new TList();
278     else fNoCountHistoList->Delete();
279
280     TList *currList[2] = {fCountHistoList, fNoCountHistoList};
281
282     TH1F *histo = 0x0;
283     
284     for(Int_t cath=0; cath<fgkNcathodes; cath++){
285       for(Int_t hType=0; hType<kNumOfHistoTypes; hType++){
286         histoName = Form("%sChamber%s", cathCode[cath].Data(), histoTypeName[hType].Data());
287         histo = (TH1F*)file->Get(histoName.Data());
288         currList[hType]->Add(histo);
289       }
290     }
291
292     for(Int_t cath=0; cath<fgkNcathodes; cath++){
293       for(Int_t ch=0; ch<fgkNchambers; ch++){
294         for(Int_t hType=0; hType<kNumOfHistoTypes; hType++){
295           histoName = Form("%sSlat%s%i", cathCode[cath].Data(), histoTypeName[hType].Data(), 11+ch);
296           histo = (TH1F*)file->Get(histoName.Data());
297           currList[hType]->Add(histo);
298         }
299       }
300     }
301
302     for(Int_t cath=0; cath<fgkNcathodes; cath++){
303       for(Int_t ch=0; ch<fgkNchambers; ch++){
304         for(Int_t hType=0; hType<kNumOfHistoTypes; hType++){
305           histoName = Form("%sBoard%s%i", cathCode[cath].Data(), histoTypeName[hType].Data(), 11+ch);
306           histo = (TH1F*)file->Get(histoName.Data());
307           currList[hType]->Add(histo);
308         }
309       }
310     }
311
312     InitHistos();
313     FillHistosFromList();
314 }
315
316
317 //_____________________________________________________________________________
318 void AliMUONTriggerEfficiencyCells::CheckConstants() const
319 {
320 /// Check consistence of redefined constants 
321
322   assert(fgkNcathodes == AliMpConstants::NofCathodes());    
323   assert(fgkNchambers == AliMpConstants::NofTriggerChambers());    
324   assert(fgkNplanes == AliMpConstants::NofTriggerChambers() * fgkNcathodes);    
325 }
326
327
328 //__________________________________________________________________________
329 Int_t AliMUONTriggerEfficiencyCells::FindChamberIndex(Int_t detElemId) const
330 {
331 ///  From detElemId to chamber number
332
333   // Int_t iChamber = AliMpDEManager::GetChamberId(detElemId);
334   Int_t iChamber = detElemId/100 - 1;
335   Int_t chamber = iChamber-AliMpConstants::NofTrackingChambers();
336   return chamber;
337 }
338
339
340 //__________________________________________________________________________
341 void
342 AliMUONTriggerEfficiencyCells::Reset()
343 {
344 ///  Sets our internal array contents to zero.
345
346   for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
347     fBoardEfficiency[chCath] = 0x0;
348     fSlatEfficiency[chCath] = 0x0;
349   }
350 }
351
352
353 //__________________________________________________________________________
354 void
355 AliMUONTriggerEfficiencyCells::InitHistos()
356 {
357 ///  Sets our internal array contents to zero.
358
359   const Int_t kNumOfBoards = AliMpConstants::NofLocalBoards();
360   const Int_t kNslats = 18;
361   Int_t chCath=0;
362   TString histoName;
363
364   TString cathCode[fgkNcathodes] = {"bendPlane", "nonBendPlane"};
365
366   for(Int_t ch=0; ch<fgkNchambers; ch++){
367     for(Int_t cath=0; cath<fgkNcathodes; cath++){
368       chCath = fgkNchambers*cath + ch;
369       histoName = Form("%sBoardEffChamber%i", cathCode[cath].Data(), 11+ch);
370       fBoardEfficiency[chCath] = new TH1F(histoName.Data(), histoName.Data(), kNumOfBoards, 1-0.5, kNumOfBoards+1.-0.5);
371       histoName = Form("%sSlatEffChamber%i", cathCode[cath].Data(), 11+ch);
372       fSlatEfficiency[chCath] = new TH1F(histoName.Data(), histoName.Data(), kNslats, 0-0.5, kNslats-0.5);
373     }
374   }
375 }
376
377
378 //__________________________________________________________________________
379 void
380 AliMUONTriggerEfficiencyCells::FillHistosFromList()
381 {
382 ///  Fills internal histos from list.
383
384   Int_t nHistoBins=0;
385   TH1F *histoNum = 0x0, *histoDen=0x0, *currHisto = 0x0;
386   TString slatName = "Slat", boardName = "Board", histoName;
387   Int_t iHistoBoard = -1, iHistoSlat = -1;
388   Float_t efficiency, efficiencyError;
389
390   Int_t nentries = fCountHistoList->GetEntries();
391
392   for(Int_t iEntry=0; iEntry<nentries; iEntry++){
393     histoNum = (TH1F*)fCountHistoList->At(iEntry);
394     histoDen = (TH1F*)fNoCountHistoList->At(iEntry);
395
396     if(!histoNum) {
397       AliWarning("Histogram not found in fCountHistoList. Skip to next");
398       continue;
399     }
400     if(!histoDen) {
401       AliWarning("Histogram not found in fNoCountHistoList. Skip to next");
402       continue;
403     }
404
405     histoName = histoNum->GetName();
406     nHistoBins = histoNum->GetNbinsX();
407
408     if(histoName.Contains(boardName)){
409       iHistoBoard++;
410       currHisto = fBoardEfficiency[iHistoBoard];
411     }
412     else if(histoName.Contains(slatName)){
413       iHistoSlat++;
414       currHisto = fSlatEfficiency[iHistoSlat];
415     }
416     else continue;
417
418     for(Int_t iBin=1; iBin<=nHistoBins; iBin++){
419       CalculateEfficiency((Int_t)histoNum->GetBinContent(iBin), (Int_t)histoNum->GetBinContent(iBin) + (Int_t)histoDen->GetBinContent(iBin), efficiency, efficiencyError, kFALSE);
420
421       currHisto->SetBinContent(iBin, efficiency);
422       currHisto->SetBinError(iBin, efficiencyError);
423     }
424   }
425 }
426
427
428 //_____________________________________________________________________________
429 void AliMUONTriggerEfficiencyCells::CalculateEfficiency(Int_t trigger44, Int_t trigger34,
430                                                         Float_t &efficiency, Float_t &error,
431                                                         Bool_t failuresAsInput)
432 {
433     //
434     /// Returns the efficiency.
435     //
436
437     efficiency=-9.;
438     error=0.;
439     if(trigger34>0){
440         efficiency=(Double_t)trigger44/((Double_t)trigger34);
441         if(failuresAsInput)efficiency=1.-(Double_t)trigger44/((Double_t)trigger34);
442     }
443     Double_t q = TMath::Abs(1-efficiency);
444     if(efficiency<0)error=0.0;
445     else error = TMath::Sqrt(efficiency*q/((Double_t)trigger34));
446 }
447
448
449 //_____________________________________________________________________________
450 void AliMUONTriggerEfficiencyCells::CheckFiredStrips(const Char_t* cdbStorage,
451                                                      Int_t runNumber)
452 {
453   //
454   /// Check for fired strips participating to efficiency
455   /// calculation (when available).
456   /// Strips inside a local board should be quite homogeneously hit
457   /// If not, this could be a problem of electronics (i.e. ADULT board off).
458   //
459
460   if(!fFiredStrips) {
461     AliWarning("List of fired pads not present. Check not performable.");
462     return;
463   }
464
465   GetListsForCheck(cdbStorage, runNumber);
466
467   TString histoName;
468
469   // Check fired pads (when available)
470   if(fFiredFitHistoList){
471     TH1F *histo1D = 0x0;
472     TF1 *fitFunc = 0x0;
473     TCanvas *histoFiredCan[20];
474     Int_t nEntries = fFiredFitHistoList->GetEntries();
475     for(Int_t iEntry=0; iEntry<nEntries; iEntry++){
476       histo1D = (TH1F*)fFiredFitHistoList->At(iEntry);
477       printf("Problems found in %s\n", histo1D->GetTitle());
478     }
479     Int_t nPrintCan = nEntries;
480     if(nPrintCan>20) {
481       AliWarning("Too many boards with problems: only 20 will be shown");
482       nPrintCan = 20;
483     }
484     for(Int_t iCan=0; iCan<nPrintCan; iCan++){
485       histo1D = (TH1F*)fFiredFitHistoList->At(iCan);
486       histoName = histo1D->GetName();
487       histoName.Append("Can");
488       histoFiredCan[iCan] = new TCanvas(histoName.Data(), histoName.Data(), 100+10*iCan, 10*iCan, 700, 700);
489       histoFiredCan[iCan]->SetRightMargin(0.14);
490       histoFiredCan[iCan]->SetLeftMargin(0.12);
491       histo1D->Draw("E");
492       fitFunc = histo1D->GetFunction("pol0");
493       fitFunc->SetLineColor(2);
494       fitFunc->Draw("same");
495     }
496     if(nEntries==0){
497       printf("\nAll local boards seem ok!!\n\n");
498     }
499   }
500 }
501
502
503 //_____________________________________________________________________________
504 void AliMUONTriggerEfficiencyCells::DisplayEfficiency(Bool_t perSlat,
505                                                       const Char_t* cdbStorage,
506                                                       Int_t runNumber)
507 {
508   //
509   /// Display calculated efficiency.
510   //
511
512   Bool_t isInitSlat = kFALSE, isInitBoard = kFALSE;
513   for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
514     if(fBoardEfficiency[chCath]->GetEntries()>0) isInitBoard = kTRUE;
515     if(fSlatEfficiency[chCath]->GetEntries()>0) isInitSlat = kTRUE;
516   }
517
518   if(!isInitBoard){
519     printf("Trigger efficiency not initialized per board.\nDisplay not yet implemented.\n");
520     return;
521   }
522   if(!isInitSlat && perSlat){
523     printf("Trigger efficiency not initialized for slat.\nPlease try option kFALSE.\n");
524     return;
525   }
526   
527   GetListsForCheck(cdbStorage, runNumber);
528
529   //const Int_t kNumOfBoards = AliMpConstants::NofLocalBoards();
530
531   TH2F *histo = 0x0;
532   TString histoName, histoTitle;
533
534   // Plot fired strips (when available)
535   if(fFiredDisplayHistoList){
536     TCanvas *displayFiredCan[fgkNplanes];
537     for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
538       histo = (TH2F*)fFiredDisplayHistoList->At(chCath);
539       histoName = Form("%sCan", histo->GetName());
540       histoTitle = Form("%s", histo->GetTitle());
541       displayFiredCan[chCath] = new TCanvas(histoName.Data(), histoTitle.Data(), 100+10*chCath, 10*chCath, 700, 700);
542       displayFiredCan[chCath]->SetRightMargin(0.14);
543       displayFiredCan[chCath]->SetLeftMargin(0.12);
544       histo->GetYaxis()->SetTitleOffset(1.4);
545       histo->SetStats(kFALSE);
546       histo->Draw("COLZ");
547     }
548   }
549
550   // Plot efficiency
551   if(fDisplayHistoList){
552     TCanvas *can[fgkNplanes];
553     for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
554       Int_t currChCath = chCath;
555       if(perSlat==kTRUE) currChCath += fgkNplanes;
556       histo = (TH2F*)fDisplayHistoList->At(currChCath);
557       histoName = Form("%sCan", histo->GetName());
558       histoTitle = Form("%s", histo->GetTitle());
559       can[chCath] = new TCanvas(histoName.Data(), histoTitle.Data(), 100+10*chCath, 10*chCath, 700, 700);
560       can[chCath]->SetRightMargin(0.14);
561       can[chCath]->SetLeftMargin(0.12);
562       histo->GetZaxis()->SetRangeUser(0.,1.);
563       histo->GetYaxis()->SetTitleOffset(1.4);
564       histo->SetStats(kFALSE);
565       histo->Draw("COLZ");
566       if(perSlat==kTRUE) continue;
567       histo = (TH2F*)fBoardLabelList->At(currChCath);
568       histo->Draw("textsame");
569     }
570   }
571 }
572
573
574 //__________________________________________________________________________
575 Bool_t AliMUONTriggerEfficiencyCells::GetListsForCheck(const Char_t* cdbStorage,
576                                                        Int_t runNumber)
577 {
578   //
579   /// Getting histograms for efficiency, 
580   /// map of fired strips entering efficiency calculations,
581   /// fits for checking switched-off elements in chambers.
582   //
583   const Float_t kChi2RedMax = 1.5;
584   const Float_t kDummyFired = 1e-5;
585
586   if(fDisplayHistoList || fBoardLabelList || fFiredFitHistoList || fFiredDisplayHistoList) return kTRUE;
587
588   if(!fDisplayHistoList) fDisplayHistoList = new TList();
589   if(!fBoardLabelList) fBoardLabelList = new TList(); 
590   if(!fFiredFitHistoList && fFiredStrips) fFiredFitHistoList = new TList();
591   if(!fFiredDisplayHistoList && fFiredStrips) fFiredDisplayHistoList = new TList();
592
593   AliCDBManager::Instance()->SetDefaultStorage(cdbStorage);
594   AliCDBManager::Instance()->SetRun(runNumber);
595
596   TH3F* padFired = 0x0;
597   TH2F* displayHisto = 0x0;
598   TH1F* histoFired[fgkNplanes][234];
599   TF1* fitFunc = 0x0;
600   Bool_t isStripOffInBoard[fgkNplanes][234];
601   Int_t bin=0;
602   TString histoName, histoTitle;
603   TString cathName[fgkNcathodes] = {"bendPlane", "nonBendPlane"};
604
605   AliMUONTriggerDisplay triggerDisplay;
606   // Book histos
607   for(Int_t iCath=0; iCath<fgkNcathodes; iCath++){
608     if(fFiredStrips) padFired = (TH3F*)fFiredStrips->At(iCath);
609     for(Int_t iCh=0; iCh<fgkNchambers; iCh++){
610       Int_t chCath = fgkNchambers*iCath + iCh;
611       Int_t currCh = 11 + iCh;
612       histoName = Form("%sChamber%i", cathName[iCath].Data(), currCh);
613       histoTitle = Form("Chamber %i: efficiency %s", currCh, cathName[iCath].Data());
614       displayHisto = 
615         (TH2F*)triggerDisplay.GetDisplayHistogram(fBoardEfficiency[chCath], histoName,
616                                                   AliMUONTriggerDisplay::kDisplayBoards,
617                                                   iCath,currCh,histoTitle,
618                                                   AliMUONTriggerDisplay::kShowZeroes);
619       fDisplayHistoList->Add(displayHisto);
620
621       histoName = Form("labels%sChamber%i", cathName[iCath].Data(), currCh);
622       displayHisto = 
623         (TH2F*)triggerDisplay.GetBoardNumberHisto(histoName,currCh);
624       fBoardLabelList->Add(displayHisto);
625
626       if(!fFiredStrips) continue;
627       histoName = Form("firedPads%sChamber%i", cathName[iCath].Data(), currCh);
628       histoTitle = Form("Chamber %i: Fired pads %s", currCh, cathName[iCath].Data());
629       bin = padFired->GetXaxis()->FindBin(currCh);
630       padFired->GetXaxis()->SetRange(bin,bin);
631       displayHisto = 
632         (TH2F*)triggerDisplay.GetDisplayHistogram(padFired->Project3D("zy"),histoName,
633                                                   AliMUONTriggerDisplay::kDisplayStrips,
634                                                   iCath,currCh,histoTitle);
635       fFiredDisplayHistoList->Add(displayHisto);
636       
637       for(Int_t ib=0; ib<AliMpConstants::NofLocalBoards(); ib++){
638         histoName = Form("%sChamber%iBoard%i", cathName[iCath].Data(), currCh, ib+1);
639         histoTitle = Form("Chamber %i: fired pads %s board = %i", currCh, cathName[iCath].Data(), ib+1);
640         histoFired[chCath][ib] = new TH1F(histoName.Data(), histoTitle.Data(), 16, -0.5, 15.5);
641         histoFired[chCath][ib]->SetXTitle("board");
642         isStripOffInBoard[chCath][ib] = kFALSE;
643       } // loop on board
644     } // loop on chamber
645   } // loop on cathode
646
647   for(Int_t iCath=0; iCath<fgkNcathodes; iCath++){
648     for(Int_t iCh=0; iCh<fgkNchambers; iCh++){
649       Int_t chCath = fgkNchambers*iCath + iCh;
650       Int_t currCh = 11+iCh;
651       histoName = Form("%sChamber%iSlatEff", cathName[iCath].Data(), currCh);
652       histoTitle = Form("Chamber %i: efficiency %s per slat", currCh, cathName[iCath].Data());
653       displayHisto = 
654         (TH2F*)triggerDisplay.GetDisplayHistogram(fSlatEfficiency[chCath], histoName,
655                                                   AliMUONTriggerDisplay::kDisplaySlats,
656                                                   iCath,currCh,histoTitle);
657       fDisplayHistoList->Add(displayHisto);
658     }
659   }
660
661   if(!fFiredStrips) return kTRUE;
662
663   // Check fired pads (when available)
664   for(Int_t iLoc = 0; iLoc < AliMpConstants::NofLocalBoards(); iLoc++) {  
665     Int_t iBoard = iLoc+1;
666     for(Int_t iCh=0; iCh<AliMpConstants::NofChambers(); iCh++){
667       Int_t iChamber = iCh + AliMpConstants::NofTrackingChambers();
668
669       Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromLocalBoard(iBoard, iChamber);
670
671       if (!detElemId) continue;
672
673       AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(iBoard, kFALSE);
674
675       // skip copy cards
676       if( !localBoard->IsNotified()) 
677         continue;
678       
679       for(Int_t iCath=0; iCath<AliMpConstants::NofCathodes(); iCath++){
680         Int_t chCath = fgkNchambers*iCath + iCh;
681         // loop over strips
682         const AliMpVSegmentation* seg = 
683           AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(iCath));
684         Int_t nStrips=0;
685         for (Int_t iStrip = 0; iStrip < 16; ++iStrip) {
686           AliMpPad pad = seg->PadByLocation(AliMpIntPair(iBoard,iStrip),kFALSE);
687           if (!pad.IsValid()) continue;
688           nStrips++;
689           padFired = (TH3F*)fFiredStrips->At(iCath);
690           Float_t nFired = padFired->GetBinContent(11+iCh, iBoard, iStrip);
691           if(nFired==0.) nFired = kDummyFired;
692           histoFired[chCath][iLoc]->Fill(iStrip, nFired);
693         }
694
695         histoFired[chCath][iLoc]->Fit("pol0","Q0R","",0., (Float_t)nStrips-1.);
696         fitFunc = histoFired[chCath][iLoc]->GetFunction("pol0");
697         Float_t chi2 = fitFunc->GetChisquare();
698         Float_t ndf = (Float_t)fitFunc->GetNDF();
699         Float_t reducedChi2 = chi2/ndf;
700         if(reducedChi2>kChi2RedMax) {
701           isStripOffInBoard[chCath][iLoc] = kTRUE;
702           fFiredFitHistoList->Add(histoFired[chCath][iLoc]);
703         }
704       } // loop on cathodes
705     } // loop on chambers
706   } // loop on local boards 
707
708   return kTRUE;
709 }
710
711 //__________________________________________________________________________
712 Bool_t AliMUONTriggerEfficiencyCells::SumRunEfficiency(const AliMUONTriggerEfficiencyCells &other)
713 {
714 ///  Sums results from different runs and gives the efficiency
715   if(!fCountHistoList || !fNoCountHistoList) {
716     AliWarning("Histograms for efficiency calculations not implemented in object");
717     return kFALSE;
718   }
719   if(!other.fCountHistoList || !other.fNoCountHistoList) {
720     AliWarning("Histograms for efficiency calculations not implemented in object passed as argument");
721     return kFALSE;
722   }
723
724   Int_t nentries = fCountHistoList->GetEntries();
725   TH1F *currNum = 0x0, *currDen = 0x0, *otherNum = 0x0, *otherDen = 0x0;
726
727   for(Int_t iEntry=0; iEntry<nentries; iEntry++){
728     currNum = (TH1F*)fCountHistoList->At(iEntry);
729     currDen = (TH1F*)fNoCountHistoList->At(iEntry);
730     otherNum = (TH1F*)other.fCountHistoList->At(iEntry);
731     otherDen = (TH1F*)other.fNoCountHistoList->At(iEntry);
732     currNum->Add(otherNum);
733     currDen->Add(otherDen);
734   }
735
736   FillHistosFromList();
737
738   if(!fFiredStrips) {
739     AliWarning("Histograms for fired region check not implemented in object");
740     return kFALSE;
741   }
742   if(!other.fFiredStrips) {
743     AliWarning("Histograms for fired region check not implemented in object passed as argument");
744     return kFALSE;
745   }
746   
747   TH3F *currFired = 0x0, *otherFired = 0x0;
748   nentries = fFiredStrips->GetEntries();
749   for(Int_t iEntry=0; iEntry<nentries; iEntry++){
750     currFired  = (TH3F*)fFiredStrips->At(iEntry);
751     otherFired = (TH3F*)fFiredStrips->At(iEntry);
752     currFired->Add(otherFired);
753   }
754     
755   return kTRUE;
756 }