1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONTriggerEfficiencyCells.h"
19 #include "AliMpConstants.h"
21 // Classes for display
22 #include "AliMUONGeometryTransformer.h"
24 #include "AliCDBManager.h"
25 #include "AliMpDDLStore.h"
27 #include "AliMpTriggerCrate.h"
28 #include "AliMpLocalBoard.h"
30 #include "AliMpVSegmentation.h"
31 #include "AliMpSegmentation.h"
36 #include "Riostream.h"
46 #include "TPaveLabel.h"
52 //-----------------------------------------------------------------------------
53 /// \class AliMUONTriggerEfficiencyCells
54 /// A class to store and give access to the trigger chamber efficiency.
56 /// Efficiency is stored per cathode on local boards
58 /// The main method of this class is IsTriggered().
60 /// $ALICE_ROOT/MUON/data/efficiencyCells.dat contains efficiency
61 /// for each chamber (i.e. DetElement).
63 /// In the case of local boards, efficiency is stored from left to right
64 /// per increasing board number (from 1 to 234)
66 /// The file can be edited in order to change efficiency
67 /// in a chosen local board/region of the chamber.
70 /// But please note that this object is also available from the CDB
72 /// \author Diego Stocco; INFN Torino
73 //-----------------------------------------------------------------------------
76 ClassImp(AliMUONTriggerEfficiencyCells)
79 //__________________________________________________________________________
80 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells()
84 fNoCountHistoList(0x0),
86 fDisplayHistoList(0x0),
88 fFiredFitHistoList(0x0),
89 fFiredDisplayHistoList(0x0)
91 /// Default constructor.
97 //__________________________________________________________________________
98 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const Char_t* filename)
101 fCountHistoList(0x0),
102 fNoCountHistoList(0x0),
104 fDisplayHistoList(0x0),
105 fBoardLabelList(0x0),
106 fFiredFitHistoList(0x0),
107 fFiredDisplayHistoList(0x0)
109 /// Constructor using an ASCII file.
115 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(TList *countHistoList,
116 TList *noCountHistoList)
119 fCountHistoList(countHistoList),
120 fNoCountHistoList(noCountHistoList),
122 fDisplayHistoList(0x0),
123 fBoardLabelList(0x0),
124 fFiredFitHistoList(0x0),
125 fFiredDisplayHistoList(0x0)
127 /// Constructor using an ASCII file.
131 FillHistosFromList();
134 //_____________________________________________________________________________
135 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const AliMUONTriggerEfficiencyCells& other)
138 fCountHistoList(other.fCountHistoList),
139 fNoCountHistoList(other.fNoCountHistoList),
140 fFiredStrips(other.fFiredStrips),
141 fDisplayHistoList(other.fDisplayHistoList),
142 fBoardLabelList(other.fBoardLabelList),
143 fFiredFitHistoList(other.fFiredFitHistoList),
144 fFiredDisplayHistoList(other.fFiredDisplayHistoList)
148 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
149 fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
150 fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
154 //_____________________________________________________________________________
155 AliMUONTriggerEfficiencyCells& AliMUONTriggerEfficiencyCells::operator=(const AliMUONTriggerEfficiencyCells& other)
157 /// Asignment operator
158 // check assignement to self
162 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
163 fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
164 fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
167 fCountHistoList = other.fCountHistoList;
168 fNoCountHistoList = other.fNoCountHistoList;
169 fFiredStrips = other.fFiredStrips;
171 fDisplayHistoList = other.fDisplayHistoList;
172 fBoardLabelList = other.fBoardLabelList;
173 fFiredFitHistoList = other.fFiredFitHistoList;
174 fFiredDisplayHistoList = other.fFiredDisplayHistoList;
179 //__________________________________________________________________________
180 AliMUONTriggerEfficiencyCells::~AliMUONTriggerEfficiencyCells()
186 //__________________________________________________________________________
187 void AliMUONTriggerEfficiencyCells::GetCellEfficiency(Int_t detElemId, Int_t localBoard, Float_t &eff1, Float_t &eff2) const
189 /// Get the efficiencies of the 2 cathodes at a given local board
191 Int_t chamber = FindChamberIndex(detElemId);
192 Int_t bin = fBoardEfficiency[chamber]->FindBin(localBoard);
193 eff1 = fBoardEfficiency[chamber]->GetBinContent(bin);
194 eff2 = fBoardEfficiency[fgkNchambers+chamber]->GetBinContent(bin);
198 //__________________________________________________________________________
200 AliMUONTriggerEfficiencyCells::IsTriggered(Int_t detElemId, Int_t localBoard, Bool_t &trig1, Bool_t &trig2) const
202 /// Whether or not a given local board has a chance to trig, on each cathode.
206 GetCellEfficiency(detElemId, localBoard, eff1, eff2);
209 if(gRandom->Rndm()>eff1)trig1 = kFALSE;
210 if(gRandom->Rndm()>eff2)trig2 = kFALSE;
214 //__________________________________________________________________________
215 void AliMUONTriggerEfficiencyCells::ReadFile(const Char_t* filename)
217 /// Reads a file containing the efficiency map.
219 TString fileName = gSystem->ExpandPathName(filename);
220 if(fileName.EndsWith(".root")){
221 ReadHistoBoards(fileName.Data());
226 ifstream file(fileName.Data());
230 if(!strcmp(dat,"localBoards"))ReadFileBoards(file);
231 else AliWarning("File .dat in wrong format");
234 AliWarning(Form("Can't read file %s",fileName.Data()));
239 //__________________________________________________________________________
240 void AliMUONTriggerEfficiencyCells::ReadFileBoards(ifstream &file)
242 /// Structure of file (.dat) containing local board efficency
243 Int_t datInt=0, detEl=0, chamber=0, chCath=0, bin=0;
244 Float_t datFloat=0.0;
247 while (file >> dat) {
249 chamber = FindChamberIndex(detEl);
250 for(Int_t cath=0; cath<fgkNcathodes; cath++){
251 chCath = fgkNchambers*cath + chamber;
254 for(Int_t board=1; board<=AliMpConstants::NofLocalBoards(); board++){
256 bin = fBoardEfficiency[chCath]->FindBin(board);
257 fBoardEfficiency[chCath]->SetBinContent(bin, datFloat);
264 //__________________________________________________________________________
265 void AliMUONTriggerEfficiencyCells::ReadHistoBoards(const Char_t *filename)
267 /// Structure of file (.root) containing local board efficency
268 TFile *file = new TFile(filename, "read");
270 AliWarning(Form("Can't read file %s",filename));
273 Char_t histoName[40];
274 Char_t *cathCode[fgkNcathodes] = {"bendPlane", "nonBendPlane"};
275 enum {kAllChEff, kChNonEff, kNumOfHistoTypes};
276 Char_t *histoTypeName[2] = {"CountInCh", "NonCountInCh"};
278 if(!fCountHistoList) fCountHistoList = new TList();
279 else fCountHistoList->Delete();
280 if(!fNoCountHistoList) fNoCountHistoList = new TList();
281 else fNoCountHistoList->Delete();
283 TList *currList[2] = {fCountHistoList, fNoCountHistoList};
287 for(Int_t cath=0; cath<fgkNcathodes; cath++){
288 for(Int_t hType=0; hType<kNumOfHistoTypes; hType++){
289 sprintf(histoName, "%sChamber%s", cathCode[cath], histoTypeName[hType]);
290 histo = (TH1F*)file->Get(histoName);
291 currList[hType]->Add(histo);
295 for(Int_t cath=0; cath<fgkNcathodes; cath++){
296 for(Int_t ch=0; ch<fgkNchambers; ch++){
297 for(Int_t hType=0; hType<kNumOfHistoTypes; hType++){
298 sprintf(histoName, "%sSlat%s%i", cathCode[cath], histoTypeName[hType], 11+ch);
299 histo = (TH1F*)file->Get(histoName);
300 currList[hType]->Add(histo);
305 for(Int_t cath=0; cath<fgkNcathodes; cath++){
306 for(Int_t ch=0; ch<fgkNchambers; ch++){
307 for(Int_t hType=0; hType<kNumOfHistoTypes; hType++){
308 sprintf(histoName, "%sBoard%s%i", cathCode[cath], histoTypeName[hType], 11+ch);
309 histo = (TH1F*)file->Get(histoName);
310 currList[hType]->Add(histo);
316 FillHistosFromList();
320 //_____________________________________________________________________________
321 void AliMUONTriggerEfficiencyCells::CheckConstants() const
323 /// Check consistence of redefined constants
325 assert(fgkNcathodes == AliMpConstants::NofCathodes());
326 assert(fgkNchambers == AliMpConstants::NofTriggerChambers());
327 assert(fgkNplanes == AliMpConstants::NofTriggerChambers() * fgkNcathodes);
331 //__________________________________________________________________________
332 Int_t AliMUONTriggerEfficiencyCells::FindChamberIndex(Int_t detElemId) const
334 /// From detElemId to chamber number
336 // Int_t iChamber = AliMpDEManager::GetChamberId(detElemId);
337 Int_t iChamber = detElemId/100 - 1;
338 Int_t chamber = iChamber-AliMpConstants::NofTrackingChambers();
343 //__________________________________________________________________________
345 AliMUONTriggerEfficiencyCells::Reset()
347 /// Sets our internal array contents to zero.
349 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
350 fBoardEfficiency[chCath] = 0x0;
351 fSlatEfficiency[chCath] = 0x0;
356 //__________________________________________________________________________
358 AliMUONTriggerEfficiencyCells::InitHistos()
360 /// Sets our internal array contents to zero.
362 const Int_t kNumOfBoards = AliMpConstants::NofLocalBoards();
363 const Int_t kNslats = 18;
365 Char_t histoName[40];
367 Char_t *cathCode[fgkNcathodes] = {"bendPlane", "nonBendPlane"};
369 for(Int_t ch=0; ch<fgkNchambers; ch++){
370 for(Int_t cath=0; cath<fgkNcathodes; cath++){
371 chCath = fgkNchambers*cath + ch;
372 sprintf(histoName, "%sBoardEffChamber%i", cathCode[cath], 11+ch);
373 fBoardEfficiency[chCath] = new TH1F(histoName, histoName, kNumOfBoards, 1-0.5, kNumOfBoards+1.-0.5);
374 sprintf(histoName, "%sSlatEffChamber%i", cathCode[cath], 11+ch);
375 fSlatEfficiency[chCath] = new TH1F(histoName, histoName, kNslats, 0-0.5, kNslats-0.5);
381 //__________________________________________________________________________
383 AliMUONTriggerEfficiencyCells::FillHistosFromList()
385 /// Fills internal histos from list.
388 TH1F *histoNum = 0x0, *histoDen=0x0, *currHisto = 0x0;
389 TString slatName = "Slat", boardName = "Board", histoName;
390 Int_t iHistoBoard = -1, iHistoSlat = -1;
391 Float_t efficiency, efficiencyError;
393 Int_t nentries = fCountHistoList->GetEntries();
395 for(Int_t iEntry=0; iEntry<nentries; iEntry++){
396 histoNum = (TH1F*)fCountHistoList->At(iEntry);
397 histoDen = (TH1F*)fNoCountHistoList->At(iEntry);
400 AliWarning("Histogram not found in fCountHistoList. Skip to next");
404 AliWarning("Histogram not found in fNoCountHistoList. Skip to next");
408 histoName = histoNum->GetName();
409 nHistoBins = histoNum->GetNbinsX();
411 if(histoName.Contains(boardName)){
413 currHisto = fBoardEfficiency[iHistoBoard];
415 else if(histoName.Contains(slatName)){
417 currHisto = fSlatEfficiency[iHistoSlat];
421 for(Int_t iBin=1; iBin<=nHistoBins; iBin++){
422 CalculateEfficiency((Int_t)histoNum->GetBinContent(iBin), (Int_t)histoNum->GetBinContent(iBin) + (Int_t)histoDen->GetBinContent(iBin), efficiency, efficiencyError, kFALSE);
424 currHisto->SetBinContent(iBin, efficiency);
425 currHisto->SetBinError(iBin, efficiencyError);
431 //_____________________________________________________________________________
432 void AliMUONTriggerEfficiencyCells::CalculateEfficiency(Int_t trigger44, Int_t trigger34,
433 Float_t &efficiency, Float_t &error,
434 Bool_t failuresAsInput)
437 /// Returns the efficiency.
443 efficiency=(Double_t)trigger44/((Double_t)trigger34);
444 if(failuresAsInput)efficiency=1.-(Double_t)trigger44/((Double_t)trigger34);
446 Double_t q = TMath::Abs(1-efficiency);
447 if(efficiency<0)error=0.0;
448 else error = TMath::Sqrt(efficiency*q/((Double_t)trigger34));
452 //_____________________________________________________________________________
453 void AliMUONTriggerEfficiencyCells::CheckFiredStrips(const Char_t* geoFilename,
454 const Char_t* cdbStorage,
458 /// Check for fired strips participating to efficiency
459 /// calculation (when available).
460 /// Strips inside a local board should be quite homogeneously hit
461 /// If not, this could be a problem of electronics (i.e. ADULT board off).
465 AliWarning("List of fired pads not present. Check not performable.");
469 GetListsForCheck(geoFilename, cdbStorage, runNumber);
471 Char_t histoName[40], histoTitle[90];
473 // Check fired pads (when available)
474 if(fFiredFitHistoList){
477 TCanvas *histoFiredCan[20];
478 Int_t nEntries = fFiredFitHistoList->GetEntries();
479 for(Int_t iEntry=0; iEntry<nEntries; iEntry++){
480 histo1D = (TH1F*)fFiredFitHistoList->At(iEntry);
481 printf("Problems found in %s\n", histo1D->GetTitle());
483 Int_t nPrintCan = nEntries;
485 AliWarning("Too many boards with problems: only 20 will be shown");
488 for(Int_t iCan=0; iCan<nPrintCan; iCan++){
489 histo1D = (TH1F*)fFiredFitHistoList->At(iCan);
490 histoFiredCan[iCan] = new TCanvas(histoName, histoTitle, 100+10*iCan, 10*iCan, 700, 700);
491 histoFiredCan[iCan]->SetRightMargin(0.14);
492 histoFiredCan[iCan]->SetLeftMargin(0.12);
494 fitFunc = histo1D->GetFunction("pol0");
495 fitFunc->SetLineColor(2);
496 fitFunc->Draw("same");
499 printf("\nAll local boards seem ok!!\n\n");
505 //_____________________________________________________________________________
506 void AliMUONTriggerEfficiencyCells::DisplayEfficiency(Bool_t perSlat,
507 const Char_t* geoFilename,
508 const Char_t* cdbStorage,
512 /// Display calculated efficiency.
515 Bool_t isInitSlat = kFALSE, isInitBoard = kFALSE;
516 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
517 if(fBoardEfficiency[chCath]->GetEntries()>0) isInitBoard = kTRUE;
518 if(fSlatEfficiency[chCath]->GetEntries()>0) isInitSlat = kTRUE;
522 printf("Trigger efficiency not initialized per board.\nDisplay not yet implemented.\n");
525 if(!isInitSlat && perSlat){
526 printf("Trigger efficiency not initialized for slat.\nPlease try option kFALSE.\n");
530 GetListsForCheck(geoFilename, cdbStorage, runNumber);
532 const Int_t kNumOfBoards = AliMpConstants::NofLocalBoards();
535 Char_t histoName[40], histoTitle[90];
536 TPaveLabel *boardLabel = 0x0;
538 // Plot fired strips (when available)
539 if(fFiredDisplayHistoList){
540 TCanvas *displayFiredCan[fgkNplanes];
541 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
542 histo = (TH2F*)fFiredDisplayHistoList->At(chCath);
543 sprintf(histoName, "%sCan", histo->GetName());
544 sprintf(histoTitle, "%s", histo->GetTitle());
545 displayFiredCan[chCath] = new TCanvas(histoName, histoTitle, 100+10*chCath, 10*chCath, 700, 700);
546 displayFiredCan[chCath]->SetRightMargin(0.14);
547 displayFiredCan[chCath]->SetLeftMargin(0.12);
548 histo->GetYaxis()->SetTitleOffset(1.4);
549 histo->SetStats(kFALSE);
551 for (Int_t board = 0; board < kNumOfBoards; board++) {
552 Int_t currLabel = chCath * kNumOfBoards + board;
553 boardLabel = (TPaveLabel*)fBoardLabelList->At(currLabel);
554 boardLabel->Draw("same");
560 if(fDisplayHistoList){
561 TCanvas *can[fgkNplanes];
562 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
563 Int_t currChCath = chCath;
564 if(perSlat==kTRUE) currChCath += fgkNplanes;
565 histo = (TH2F*)fDisplayHistoList->At(currChCath);
566 sprintf(histoName, "%sCan", histo->GetName());
567 sprintf(histoTitle, "%s", histo->GetTitle());
568 can[chCath] = new TCanvas(histoName, histoTitle, 100+10*chCath, 10*chCath, 700, 700);
569 can[chCath]->SetRightMargin(0.14);
570 can[chCath]->SetLeftMargin(0.12);
571 histo->GetZaxis()->SetRangeUser(0.,1.);
572 histo->GetYaxis()->SetTitleOffset(1.4);
573 histo->SetStats(kFALSE);
575 for (Int_t board = 0; board < kNumOfBoards; board++) {
576 Int_t currLabel = chCath * kNumOfBoards + board;
577 if(perSlat==kTRUE) currLabel += kNumOfBoards * fgkNplanes;
578 boardLabel = (TPaveLabel*)fBoardLabelList->At(currLabel);
579 boardLabel->Draw("same");
586 //__________________________________________________________________________
587 Bool_t AliMUONTriggerEfficiencyCells::GetListsForCheck(const Char_t* geoFilename,
588 const Char_t* cdbStorage,
592 /// Getting histograms for efficiency,
593 /// map of fired strips entering efficiency calculations,
594 /// fits for checking switched-off elements in chambers.
597 const Int_t kNumOfBoards = AliMpConstants::NofLocalBoards();
598 const Float_t kChi2RedMax = 1.5;
599 const Float_t kDummyFired = 1e-5;
601 if(fDisplayHistoList || fBoardLabelList || fFiredFitHistoList || fFiredDisplayHistoList) return kTRUE;
603 if(!fDisplayHistoList) fDisplayHistoList = new TList();
604 if(!fBoardLabelList) fBoardLabelList = new TList();
605 if(!fFiredFitHistoList && fFiredStrips) fFiredFitHistoList = new TList();
606 if(!fFiredDisplayHistoList && fFiredStrips) fFiredDisplayHistoList = new TList();
608 AliCDBManager::Instance()->SetDefaultStorage(cdbStorage);
609 AliCDBManager::Instance()->SetRun(runNumber);
611 AliMUONGeometryTransformer *transform = new AliMUONGeometryTransformer();
612 transform->LoadGeometryData(geoFilename);
614 if(!AliMpCDB::LoadDDLStore()) // Load DDL store from OCDB
615 AliFatal("Could not access mapping OCDB");
617 AliMpDDLStore *ddlStore = AliMpDDLStore::Instance();
619 Float_t xLocal1=0., yLocal1=0., xLocal2=0., yLocal2=0.;
620 Float_t xg1, yg1, zg1, xg2, yg2, zg2;
621 Float_t xWidth=0., yWidth=0.;
622 Float_t x1Label=0., x2Label=0., y1Label=0., y2Label=0.;
623 Float_t x1LabelSlat=0., x2LabelSlat=0., y1LabelSlat=0., y2LabelSlat=0.;
624 Int_t x1=0, y1=0, x2=0, y2=0, localId;
626 gStyle->SetPalette(1);
628 Char_t *cathCode[fgkNcathodes] = {"bendPlane", "nonBendPlane"};
630 Float_t boardsX = 280.00; // cm
631 Float_t boardsY = 335.00; // cm
633 // Check fired pads (when available)
634 Int_t maxY[fgkNcathodes] = {64,1};
635 TH3F *padFired[fgkNplanes];
636 TH1F *histoFired[fgkNplanes][234];
637 TH2F *histoFiredDisplay[fgkNplanes];
639 Bool_t isStripOffInBoard[fgkNplanes][234];
641 TH2F *histo[fgkNplanes];
642 TH2F *histoSlat[fgkNplanes];
643 TPaveLabel *boardLabel[fgkNplanes][234];
644 TPaveLabel *boardLabelSlat[fgkNplanes][234];
645 assert(kNumOfBoards==234);
647 Char_t histoName[40], histoTitle[90], labelTxt[5], labelSlatTxt[5];
649 Float_t efficiency, efficiencyError, efficiencySlat, efficiencySlatError;
652 for(Int_t cath=0; cath<fgkNcathodes; cath++){
653 padFired[cath] = 0x0;
654 if(fFiredStrips) padFired[cath] = (TH3F*)fFiredStrips->At(cath);
655 for(Int_t ch=0; ch<fgkNchambers; ch++){
656 Int_t chCath = fgkNchambers*cath + ch;
657 sprintf(histoName, "%sChamber%i", cathCode[cath], 11+ch);
658 sprintf(histoTitle, "Chamber %i: efficiency %s", 11+ch, cathCode[cath]);
659 histo[chCath] = new TH2F(histoName, histoTitle, (Int_t)boardsX, -boardsX, boardsX, (Int_t)boardsY, -boardsY, boardsY);
660 histo[chCath]->SetXTitle("X (cm)");
661 histo[chCath]->SetYTitle("Y (cm)");
662 fDisplayHistoList->Add(histo[chCath]);
664 if(!fFiredStrips) continue;
665 sprintf(histoName, "firedPads%sChamber%i", cathCode[cath], 11+ch);
666 sprintf(histoTitle, "Chamber %i: Fired pads %s", 11+ch, cathCode[cath]);
667 histoFiredDisplay[chCath] = new TH2F(histoName, histoTitle, (Int_t)boardsX, -boardsX, boardsX, (Int_t)boardsY, -boardsY, boardsY);
668 histoFiredDisplay[chCath]->SetXTitle("X (cm)");
669 histoFiredDisplay[chCath]->SetYTitle("Y (cm)");
670 fFiredDisplayHistoList->Add(histoFiredDisplay[chCath]);
672 for(Int_t ib=0; ib<kNumOfBoards; ib++){
673 sprintf(histoName, "%sChamber%iBoard%i", cathCode[cath], 11+ch, ib+1);
674 sprintf(histoTitle, "Chamber %i: fired pads %s board = %i", 11+ch, cathCode[cath], ib+1);
675 histoFired[chCath][ib] = new TH1F(histoName, histoTitle, 16, -0.5, 15.5);
676 histoFired[chCath][ib]->SetXTitle("board");
677 isStripOffInBoard[chCath][ib] = kFALSE;
682 for(Int_t cath=0; cath<fgkNcathodes; cath++){
683 for(Int_t ch=0; ch<fgkNchambers; ch++){
684 Int_t chCath = fgkNchambers*cath + ch;
685 sprintf(histoName, "%sChamber%iSlatEff", cathCode[cath], 11+ch);
686 sprintf(histoTitle, "Chamber %i: efficiency %s per slat", 11+ch, cathCode[cath]);
687 histoSlat[chCath] = new TH2F(histoName, histoTitle, (Int_t)boardsX, -boardsX, boardsX, (Int_t)boardsY, -boardsY, boardsY);
688 histoSlat[chCath]->SetXTitle("X (cm)");
689 histoSlat[chCath]->SetYTitle("Y (cm)");
690 fDisplayHistoList->Add(histoSlat[chCath]);
694 // loop over the trigger DDL (Right: 20, Left: 21)
695 for (Int_t iDDL = 20; iDDL <= 21; ++iDDL) {
696 AliMpDDL* ddl = ddlStore->GetDDL(iDDL);
697 Int_t nCrate = ddl->GetNofTriggerCrates();
698 // loop over the number of crates in DDL
699 for (Int_t index = 0; index < nCrate; ++index) {
701 AliMpTriggerCrate* crate = ddlStore->GetTriggerCrate(iDDL, index);
702 Int_t nLocal = crate->GetNofLocalBoards();
703 for (Int_t iLocal = 0; iLocal < nLocal; ++iLocal) {
704 // get local board Id from crate object
705 localId = crate->GetLocalBoardId(iLocal);
706 // get local board object
707 AliMpLocalBoard* localBoard = ddlStore->GetLocalBoard(localId);
709 if (!localBoard->IsNotified()) continue;
711 // get detection element connected to this board
712 for (Int_t ch = 0; ch < fgkNchambers; ++ch) {
713 Int_t iCh = ch + AliMpConstants::NofTrackingChambers();
714 Int_t detElemId = ddlStore->GetDEfromLocalBoard(localId, iCh);
716 if (!detElemId) continue;
719 for (Int_t cath = 0; cath < fgkNcathodes; ++cath) {
720 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()
721 ->GetMpSegmentation(detElemId,
722 AliMp::GetCathodType(cath));
724 Int_t chCath = fgkNchambers*cath + ch;
725 slat = detElemId%100;
729 for (Int_t ibitxy = 0; ibitxy < 16; ++ibitxy) {
730 // get pad from electronics
731 AliMpPad pad = seg->PadByLocation(AliMpIntPair(localId,
734 if (!pad.IsValid()) continue;
735 if(cath==0){ // Geometry info from bending plane only
737 xLocal1 = pad.Position().X();
738 yLocal1 = pad.Position().Y();
739 xWidth = pad.Dimensions().X();
740 yWidth = pad.Dimensions().Y();
742 xLocal2 = pad.Position().X();
743 yLocal2 = pad.Position().Y();
746 // Check fired pads (when available)
748 Int_t padX = pad.GetIndices().GetFirst();
749 Int_t padY = pad.GetIndices().GetSecond();
750 Int_t currPair = padX*maxY[cath] + padY;
752 //printf("cath %i board = %i (%2i, %2i) -> %i\n",
753 //cath, localId, padX, padY, currPair);
754 Int_t chBin = padFired[cath]->GetXaxis()->FindBin(ch);
755 Int_t slatBin = padFired[cath]->GetYaxis()->FindBin(slat);
756 Int_t pairBin = padFired[cath]->GetZaxis()->FindBin(currPair);
757 Float_t nFired = padFired[cath]->GetBinContent(chBin, slatBin, pairBin);;
759 Float_t dimX = pad.Dimensions().X();
760 Float_t dimY = pad.Dimensions().Y();
762 Float_t stripX1 = pad.Position().X();
763 Float_t stripY1 = pad.Position().Y();
764 Float_t stripX2 = pad.Position().X();
765 Float_t stripY2 = pad.Position().Y();
767 transform->Local2Global(detElemId, stripX1, stripY1, 0, xg1, yg1, zg1);
768 transform->Local2Global(detElemId, stripX2, stripY2, 0, xg2, yg2, zg2);
770 Float_t x1Float = TMath::Min(xg1,xg2) - dimX;
771 Float_t y1Float = TMath::Min(yg1,yg2) - dimY;
772 Float_t x2Float = TMath::Max(xg1,xg2) + dimX;
773 Float_t y2Float = TMath::Max(yg1,yg2) + dimY;
775 Int_t x1Int = histoFiredDisplay[chCath]->GetXaxis()->FindBin(x1Float)+1;
776 Int_t y1Int = histoFiredDisplay[chCath]->GetYaxis()->FindBin(y1Float)+1;
777 Int_t x2Int = histoFiredDisplay[chCath]->GetXaxis()->FindBin(x2Float)-1;
778 Int_t y2Int = histoFiredDisplay[chCath]->GetYaxis()->FindBin(y2Float)-1;
780 for(Int_t binX=x1Int; binX<=x2Int; binX++){
781 for(Int_t binY=y1Int; binY<=y2Int; binY++){
782 histoFiredDisplay[chCath]->SetBinContent(binX, binY, nFired);
786 if(nFired==0.) nFired = kDummyFired;
787 histoFired[chCath][localId-1]->Fill(ibitxy, nFired);
791 if(cath==0){ // Geometry info from bending plane only
792 transform->Local2Global(detElemId, xLocal1, yLocal1, 0, xg1, yg1, zg1);
793 transform->Local2Global(detElemId, xLocal2, yLocal2, 0, xg2, yg2, zg2);
796 x1Label = TMath::Min(xg1,xg2) - xWidth;
797 y1Label = TMath::Min(yg1,yg2) - yWidth;
798 x2Label = TMath::Max(xg1,xg2) + xWidth;
799 y2Label = TMath::Max(yg1,yg2) + yWidth;
801 x1 = histo[ch]->GetXaxis()->FindBin(x1Label)+1;
802 y1 = histo[ch]->GetYaxis()->FindBin(y1Label)+1;
803 x2 = histo[ch]->GetXaxis()->FindBin(x2Label)-1;
804 y2 = histo[ch]->GetYaxis()->FindBin(y2Label)-1;
806 sprintf(labelTxt,"%3d", localId);
809 line = localBoard->GetPosition().GetFirst();
811 x2LabelSlat = x1LabelSlat + 40.;
812 y1LabelSlat = -285. + ((Float_t)(line - 1)) * 68;
813 y2LabelSlat = y1LabelSlat + 34.;
814 if(localId>kNumOfBoards/2){
815 x1LabelSlat = -x2LabelSlat;
816 x2LabelSlat = x1LabelSlat + 40.;
818 sprintf(labelSlatTxt,"%2d", slat);
821 boardLabel[chCath][localId-1] = new TPaveLabel(x1Label, y1Label, x2Label, y2Label, labelTxt);
822 boardLabel[chCath][localId-1]->SetFillStyle(0);
823 boardLabel[chCath][localId-1]->SetBorderSize(0);
825 boardLabelSlat[chCath][localId-1] = new TPaveLabel(x1LabelSlat, y1LabelSlat, x2LabelSlat, y2LabelSlat, labelSlatTxt);
826 boardLabelSlat[chCath][localId-1]->SetFillStyle(0);
827 boardLabelSlat[chCath][localId-1]->SetBorderSize(0);
829 Int_t histoBin = localId;
830 efficiency = fBoardEfficiency[chCath]->GetBinContent(histoBin);
831 efficiencyError = fBoardEfficiency[chCath]->GetBinError(histoBin);
832 if(efficiency==0.) efficiency = kDummyFired; // It allows to graphically distinguish
833 // efficiency = 0 from no hit on board
836 efficiencySlat = fSlatEfficiency[chCath]->GetBinContent(histoBin);
837 efficiencySlatError = fSlatEfficiency[chCath]->GetBinError(histoBin);
838 if(efficiencySlat==0.) efficiencySlat = kDummyFired; // It allows to graphically distinguish
839 // efficiency = 0 from no hit on slat
841 for(Int_t binX=x1; binX<=x2; binX++){
842 for(Int_t binY=y1; binY<=y2; binY++){
843 histo[chCath]->SetBinContent(binX, binY, efficiency);
844 histo[chCath]->SetBinError(binX, binY, efficiencyError);
845 histoSlat[chCath]->SetBinContent(binX, binY, efficiencySlat);
846 histoSlat[chCath]->SetBinError(binX, binY, efficiencySlatError);
850 // Check fired pads (when available)
852 histoFired[chCath][localId-1]->Fit("pol0","Q0R","",0., (Float_t)nStrips-1.);
853 fitFunc = histoFired[chCath][localId-1]->GetFunction("pol0");
854 Float_t chi2 = fitFunc->GetChisquare();
855 Float_t ndf = (Float_t)fitFunc->GetNDF();
856 Float_t reducedChi2 = chi2/ndf;
857 if(reducedChi2>kChi2RedMax) {
858 isStripOffInBoard[chCath][localId-1] = kTRUE;
859 //printf("Chamber = %i Cath = %i Board %i: chi2/NDF = %f\tparam = %f\n", ch, cath, localId, reducedChi2, fitFunc->GetParameter(0));
860 fFiredFitHistoList->Add(histoFired[chCath][localId-1]);
863 } // loop on cathodes
864 } // loop on chambers
869 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
870 for(Int_t ib=0; ib<kNumOfBoards; ib++){
871 fBoardLabelList->Add(boardLabel[chCath][ib]);
874 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
875 for(Int_t ib=0; ib<kNumOfBoards; ib++){
876 fBoardLabelList->Add(boardLabelSlat[chCath][ib]);
884 //__________________________________________________________________________
885 Bool_t AliMUONTriggerEfficiencyCells::SumRunEfficiency(const AliMUONTriggerEfficiencyCells &other)
887 /// Sums results from different runs and gives the efficiency
888 if(!fCountHistoList || !fNoCountHistoList) {
889 AliWarning("Histograms for efficiency calculations not implemented in object");
892 if(!other.fCountHistoList || !other.fNoCountHistoList) {
893 AliWarning("Histograms for efficiency calculations not implemented in object passed as argument");
897 Int_t nentries = fCountHistoList->GetEntries();
898 TH1F *currNum = 0x0, *currDen = 0x0, *otherNum = 0x0, *otherDen = 0x0;
900 for(Int_t iEntry=0; iEntry<nentries; iEntry++){
901 currNum = (TH1F*)fCountHistoList->At(iEntry);
902 currDen = (TH1F*)fNoCountHistoList->At(iEntry);
903 otherNum = (TH1F*)other.fCountHistoList->At(iEntry);
904 otherDen = (TH1F*)other.fNoCountHistoList->At(iEntry);
905 currNum->Add(otherNum);
906 currDen->Add(otherDen);
909 FillHistosFromList();
912 AliWarning("Histograms for fired region check not implemented in object");
915 if(!other.fFiredStrips) {
916 AliWarning("Histograms for fired region check not implemented in object passed as argument");
920 TH3F *currFired = 0x0, *otherFired = 0x0;
921 nentries = fFiredStrips->GetEntries();
922 for(Int_t iEntry=0; iEntry<nentries; iEntry++){
923 currFired = (TH3F*)fFiredStrips->At(iEntry);
924 otherFired = (TH3F*)fFiredStrips->At(iEntry);
925 currFired->Add(otherFired);