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 **************************************************************************/
16 #include "AliMUONTriggerEfficiencyCells.h"
17 #include "AliMpConstants.h"
19 // Classes for display
20 #include "AliMUONGeometryTransformer.h"
22 #include "AliMpDDLStore.h"
24 #include "AliMpTriggerCrate.h"
25 #include "AliMpLocalBoard.h"
27 #include "AliMpVSegmentation.h"
28 #include "AliMpSegmentation.h"
33 #include "Riostream.h"
43 #include "TPaveLabel.h"
49 //-----------------------------------------------------------------------------
50 /// \class AliMUONTriggerEfficiencyCells
51 /// A class to store and give access to the trigger chamber efficiency.
53 /// Efficiency is stored per cathode on local boards, or, alternatively,
54 /// on "cells" of a given size.
56 /// The main method of this class is IsTriggered().
58 /// $ALICE_ROOT/MUON/data/TriggerChamberefficiencyCells.dat contains efficiency
59 /// for each chamber (i.e. DetElement).
61 /// In the case of local boards, efficiency is stored from left to right
62 /// per increasing board number (from 1 to 234)
64 /// Otherwise, he efficiency cells goes from right to left and
65 /// from bottom to top of the chamber, namely, the efficiencies tabulated in the
66 /// file refers to the following reference frame:
70 /// <----------------------------------|
72 /// --------------------------- |
73 /// | 0.97 | 0.97 | 0.97 | 0.97 | |
74 /// --------------------------- |
75 /// | 0.97 | 0.97 | 0.97 | 0.97 | |
76 /// --------------------------- |
77 /// | 0.97 | 0.97 | 0.97 | 0.97 | |
78 /// --------------------------- |
83 /// In both cases, the file can be edited in order to change efficiency
84 /// in a chosen local board/region of the chamber.
87 /// But please note that this object is also available from the CDB
88 /// (generated using the MUONCDB.C macro)
90 /// \author Diego Stocco; INFN Torino
91 //-----------------------------------------------------------------------------
94 ClassImp(AliMUONTriggerEfficiencyCells)
97 //__________________________________________________________________________
98 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells()
101 fCountHistoList(0x0),
102 fNoCountHistoList(0x0),
104 fDisplayHistoList(0x0),
105 fBoardLabelList(0x0),
106 fFiredFitHistoList(0x0),
107 fFiredDisplayHistoList(0x0)
109 /// Default constructor.
115 //__________________________________________________________________________
116 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const Char_t* filename)
119 fCountHistoList(0x0),
120 fNoCountHistoList(0x0),
122 fDisplayHistoList(0x0),
123 fBoardLabelList(0x0),
124 fFiredFitHistoList(0x0),
125 fFiredDisplayHistoList(0x0)
127 /// Constructor using an ASCII file.
133 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(TList *countHistoList,
134 TList *noCountHistoList)
137 fCountHistoList(countHistoList),
138 fNoCountHistoList(noCountHistoList),
140 fDisplayHistoList(0x0),
141 fBoardLabelList(0x0),
142 fFiredFitHistoList(0x0),
143 fFiredDisplayHistoList(0x0)
145 /// Constructor using an ASCII file.
149 FillHistosFromList();
152 //_____________________________________________________________________________
153 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const AliMUONTriggerEfficiencyCells& other)
156 fCountHistoList(other.fCountHistoList),
157 fNoCountHistoList(other.fNoCountHistoList),
158 fFiredStrips(other.fFiredStrips),
159 fDisplayHistoList(other.fDisplayHistoList),
160 fBoardLabelList(other.fBoardLabelList),
161 fFiredFitHistoList(other.fFiredFitHistoList),
162 fFiredDisplayHistoList(other.fFiredDisplayHistoList)
166 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
167 for(Int_t slat=0; slat<fgkNslats; slat++){
168 fCellContent[chCath][slat] = other.fCellContent[chCath][slat];
170 fCellSize[chCath] = other.fCellSize[chCath];
171 fCellNumber[chCath] = other.fCellNumber[chCath];
172 fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
173 fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
177 //_____________________________________________________________________________
178 AliMUONTriggerEfficiencyCells& AliMUONTriggerEfficiencyCells::operator=(const AliMUONTriggerEfficiencyCells& other)
180 /// Asignment operator
181 // check assignement to self
185 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
186 for(Int_t slat=0; slat<fgkNslats; slat++){
187 fCellContent[chCath][slat] = other.fCellContent[chCath][slat];
189 fCellSize[chCath] = other.fCellSize[chCath];
190 fCellNumber[chCath] = other.fCellNumber[chCath];
191 fBoardEfficiency[chCath] = other.fBoardEfficiency[chCath];
192 fSlatEfficiency[chCath] = other.fSlatEfficiency[chCath];
195 fCountHistoList = other.fCountHistoList;
196 fNoCountHistoList = other.fNoCountHistoList;
197 fFiredStrips = other.fFiredStrips;
199 fDisplayHistoList = other.fDisplayHistoList;
200 fBoardLabelList = other.fBoardLabelList;
201 fFiredFitHistoList = other.fFiredFitHistoList;
202 fFiredDisplayHistoList = other.fFiredDisplayHistoList;
207 //__________________________________________________________________________
208 AliMUONTriggerEfficiencyCells::~AliMUONTriggerEfficiencyCells()
214 //__________________________________________________________________________
215 void AliMUONTriggerEfficiencyCells::GetCellEfficiency(Int_t detElemId, Float_t x, Float_t y, Float_t &eff1, Float_t &eff2) const
217 /// Get the efficiencies of the 2 cathodes at a given location (x,y)
219 Int_t chamber = FindChamberIndex(detElemId);
220 Int_t slat = FindSlatIndex(detElemId);
221 TArrayI cell = CellByCoord(detElemId,x,y);
224 if(cell.At(0)>=0 && cell.At(1)>=0)
226 eff1 = fCellContent[chamber][slat][cell.At(0)][cell.At(1)];
227 eff2 = fCellContent[fgkNchambers+chamber][slat][cell.At(0)][cell.At(1)];
232 //__________________________________________________________________________
233 void AliMUONTriggerEfficiencyCells::GetCellEfficiency(Int_t detElemId, Int_t localBoard, Float_t &eff1, Float_t &eff2) const
235 /// Get the efficiencies of the 2 cathodes at a given local board
237 Int_t chamber = FindChamberIndex(detElemId);
238 Int_t bin = fBoardEfficiency[chamber]->FindBin(localBoard);
239 eff1 = fBoardEfficiency[chamber]->GetBinContent(bin);
240 eff2 = fBoardEfficiency[fgkNchambers+chamber]->GetBinContent(bin);
244 //__________________________________________________________________________
246 AliMUONTriggerEfficiencyCells::IsTriggered(Int_t detElemId, Float_t x, Float_t y, Bool_t &trig1, Bool_t &trig2) const
248 /// Whether or not a given location (x,y) has a chance to trig, on each cathode.
252 GetCellEfficiency(detElemId, x, y, eff1, eff2);
255 if(gRandom->Rndm()>eff1)trig1 = kFALSE;
256 if(gRandom->Rndm()>eff2)trig2 = kFALSE;
260 //__________________________________________________________________________
262 AliMUONTriggerEfficiencyCells::IsTriggered(Int_t detElemId, Int_t localBoard, Bool_t &trig1, Bool_t &trig2) const
264 /// Whether or not a given local board has a chance to trig, on each cathode.
268 GetCellEfficiency(detElemId, localBoard, eff1, eff2);
271 if(gRandom->Rndm()>eff1)trig1 = kFALSE;
272 if(gRandom->Rndm()>eff2)trig2 = kFALSE;
275 //__________________________________________________________________________
276 TArrayI AliMUONTriggerEfficiencyCells::CellByCoord(Int_t detElemId, Float_t x, Float_t y) const
278 /// Get the efficiencies at a given location.
280 Int_t chamber = FindChamberIndex(detElemId);
281 Int_t slat = FindSlatIndex(detElemId);
282 Int_t cell[fgkNcathodes]={-1,-1};
283 Float_t maxX = fCellSize[chamber][slat]*((Float_t)fCellNumber[chamber][slat]);
284 Float_t maxY = fCellSize[fgkNchambers+chamber][slat]*((Float_t)fCellNumber[fgkNchambers+chamber][slat]);
285 if(x>=0 & x<maxX & y>=0 & y<maxY)
287 cell[0] = (Int_t)(x/fCellSize[chamber][slat]);
288 cell[1] = (Int_t)(y/fCellSize[fgkNchambers+chamber][slat]);
290 return TArrayI(fgkNcathodes,cell);
293 //__________________________________________________________________________
294 void AliMUONTriggerEfficiencyCells::ReadFile(const Char_t* filename)
296 /// Reads a file containing the efficiency map.
298 TString fileName = gSystem->ExpandPathName(filename);
299 if(fileName.EndsWith(".root")){
300 ReadHistoBoards(fileName.Data());
305 ifstream file(fileName.Data());
309 if(!strcmp(dat,"localBoards"))ReadFileBoards(file);
310 else ReadFileXY(file);
313 AliWarning(Form("Can't read file %s",fileName.Data()));
318 //__________________________________________________________________________
319 void AliMUONTriggerEfficiencyCells::ReadFileXY(ifstream &file)
321 /// Structure of file (.dat) containing geometrical efficency
322 Int_t datInt=0, detEl=0, chamber=0, rpc=0, chCath=0;
323 Float_t datFloat=0.0;
326 while (file >> dat) {
328 chamber = FindChamberIndex(detEl);
329 rpc = FindSlatIndex(detEl);
331 for(Int_t i=0; i<fgkNcathodes; i++){
332 chCath = fgkNchambers*i + chamber;
334 fCellNumber[chCath][rpc] = datInt;
337 for(Int_t i=0; i<fgkNcathodes; i++){
338 chCath = fgkNchambers*i + chamber;
340 fCellSize[chCath][rpc] = datFloat;
343 for(Int_t cath=0; cath<fgkNcathodes; cath++){
344 chCath = fgkNchambers*cath + chamber;
347 for(Int_t iy=0; iy<fCellNumber[fgkNchambers+chamber][rpc]; iy++){
348 for(Int_t ix=0; ix<fCellNumber[chamber][rpc]; ix++){
350 fCellContent[chCath][rpc][ix][iy] = datFloat;
357 //__________________________________________________________________________
358 void AliMUONTriggerEfficiencyCells::ReadFileBoards(ifstream &file)
360 /// Structure of file (.dat) containing local board efficency
361 Int_t datInt=0, detEl=0, chamber=0, chCath=0, bin=0;
362 Float_t datFloat=0.0;
365 while (file >> dat) {
367 chamber = FindChamberIndex(detEl);
368 //rpc = FindSlatIndex(detEl);
369 for(Int_t cath=0; cath<fgkNcathodes; cath++){
370 chCath = fgkNchambers*cath + chamber;
373 for(Int_t board=1; board<=AliMpConstants::NofLocalBoards(); board++){
375 bin = fBoardEfficiency[chCath]->FindBin(board);
376 fBoardEfficiency[chCath]->SetBinContent(bin, datFloat);
383 //__________________________________________________________________________
384 void AliMUONTriggerEfficiencyCells::ReadHistoBoards(const Char_t *filename)
386 /// Structure of file (.root) containing local board efficency
387 TFile *file = new TFile(filename, "read");
389 AliWarning(Form("Can't read file %s",filename));
392 Char_t histoName[30];
393 Char_t *cathCode[fgkNcathodes] = {"bendPlane", "nonBendPlane"};
395 for(Int_t ch=0; ch<fgkNchambers; ch++){
396 for(Int_t cath=0; cath<fgkNcathodes; cath++){
397 sprintf(histoName, "%sBoardEffChamber%i", cathCode[cath], 11+ch);
398 if(!(TH1F *)file->Get(histoName)) {
399 AliWarning(Form("Can't find histo %s in file %s",histoName, filename));
402 Int_t chCath = fgkNchambers*cath + ch;
403 fBoardEfficiency[chCath] = (TH1F *)file->Get(histoName);
409 //_____________________________________________________________________________
410 void AliMUONTriggerEfficiencyCells::CheckConstants() const
412 /// Check consistence of redefined constants
414 assert(fgkNcathodes == AliMpConstants::NofCathodes());
415 assert(fgkNchambers == AliMpConstants::NofTriggerChambers());
416 assert(fgkNplanes == AliMpConstants::NofTriggerChambers() * fgkNcathodes);
420 //__________________________________________________________________________
421 Int_t AliMUONTriggerEfficiencyCells::FindChamberIndex(Int_t detElemId) const
423 /// From detElemId to chamber number
425 // Int_t iChamber = AliMpDEManager::GetChamberId(detElemId);
426 Int_t iChamber = detElemId/100 - 1;
427 Int_t chamber = iChamber-AliMpConstants::NofTrackingChambers();
432 //__________________________________________________________________________
433 Int_t AliMUONTriggerEfficiencyCells::FindSlatIndex(Int_t detElemId) const
435 /// From detElemId to slat index.
436 Int_t slat = detElemId%100;
441 //__________________________________________________________________________
442 TVector2 AliMUONTriggerEfficiencyCells::ChangeReferenceFrame(Float_t x, Float_t y, Float_t x0, Float_t y0)
444 /// (x0,y0) position of the local reference frame (center of the chamber)
446 Float_t x1 = x0-x;//reflection of axis
448 return TVector2(x1,y1);
451 //__________________________________________________________________________
453 AliMUONTriggerEfficiencyCells::Reset()
455 /// Sets our internal array contents to zero.
457 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
458 fCellSize[chCath].Set(fgkNslats);
459 fCellNumber[chCath].Set(fgkNslats);
460 for(Int_t slat=0; slat<fgkNslats; slat++){
461 fCellContent[chCath][slat].ResizeTo(fgkNcells,fgkNcells);
465 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
466 fCellSize[chCath].Reset();
467 fCellNumber[chCath].Reset();
468 for(Int_t slat=0; slat<fgkNslats; slat++){
469 fCellContent[chCath][slat].Zero();
473 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
474 fBoardEfficiency[chCath] = 0x0;
475 fSlatEfficiency[chCath] = 0x0;
480 //__________________________________________________________________________
482 AliMUONTriggerEfficiencyCells::InitHistos()
484 /// Sets our internal array contents to zero.
486 const Int_t kNumOfBoards = AliMpConstants::NofLocalBoards();
488 Char_t histoName[40];
490 Char_t *cathCode[fgkNcathodes] = {"bendPlane", "nonBendPlane"};
492 for(Int_t ch=0; ch<fgkNchambers; ch++){
493 for(Int_t cath=0; cath<fgkNcathodes; cath++){
494 chCath = fgkNchambers*cath + ch;
495 sprintf(histoName, "%sBoardEffChamber%i", cathCode[cath], 11+ch);
496 fBoardEfficiency[chCath] = new TH1F(histoName, histoName, kNumOfBoards, 1-0.5, kNumOfBoards+1.-0.5);
497 sprintf(histoName, "%sSlatEffChamber%i", cathCode[cath], 11+ch);
498 fSlatEfficiency[chCath] = new TH1F(histoName, histoName, fgkNslats, 0-0.5, fgkNslats-0.5);
504 //__________________________________________________________________________
506 AliMUONTriggerEfficiencyCells::FillHistosFromList()
508 /// Fills internal histos from list.
511 TH1F *histoNum = 0x0, *histoDen=0x0, *currHisto = 0x0;
512 TString slatName = "Slat", boardName = "Board", histoName;
513 Int_t iHistoBoard = -1, iHistoSlat = -1;
514 Float_t efficiency, efficiencyError;
516 Int_t nentries = fCountHistoList->GetEntries();
518 for(Int_t iEntry=0; iEntry<nentries; iEntry++){
519 histoNum = (TH1F*)fCountHistoList->At(iEntry);
520 histoDen = (TH1F*)fNoCountHistoList->At(iEntry);
523 AliWarning("Histogram not found in fCountHistoList. Skip to next");
527 AliWarning("Histogram not found in fNoCountHistoList. Skip to next");
531 histoName = histoNum->GetName();
532 nHistoBins = histoNum->GetNbinsX();
534 if(histoName.Contains(boardName)){
536 currHisto = fBoardEfficiency[iHistoBoard];
538 else if(histoName.Contains(slatName)){
540 currHisto = fSlatEfficiency[iHistoSlat];
544 for(Int_t iBin=1; iBin<=nHistoBins; iBin++){
545 CalculateEfficiency((Int_t)histoNum->GetBinContent(iBin), (Int_t)histoNum->GetBinContent(iBin) + (Int_t)histoDen->GetBinContent(iBin), efficiency, efficiencyError, kFALSE);
547 currHisto->SetBinContent(iBin, efficiency);
548 currHisto->SetBinError(iBin, efficiencyError);
555 //_____________________________________________________________________________
556 void AliMUONTriggerEfficiencyCells::CalculateEfficiency(Int_t trigger44, Int_t trigger34,
557 Float_t &efficiency, Float_t &error,
558 Bool_t failuresAsInput)
561 /// Returns the efficiency.
567 efficiency=(Double_t)trigger44/((Double_t)trigger34);
568 if(failuresAsInput)efficiency=1.-(Double_t)trigger44/((Double_t)trigger34);
570 Double_t q = TMath::Abs(1-efficiency);
571 if(efficiency<0)error=0.0;
572 else error = TMath::Sqrt(efficiency*q/((Double_t)trigger34));
576 //_____________________________________________________________________________
577 void AliMUONTriggerEfficiencyCells::CheckFiredStrips(const Char_t* geoFilename)
580 /// Check for fired strips participating to efficiency
581 /// calculation (when available).
582 /// Strips inside a local board should be quite homogeneously hit
583 /// If not, this could be a problem of electronics (i.e. ADULT board off).
587 AliWarning("List of fired pads not present. Check not performable.");
591 GetListsForCheck(geoFilename);
593 Char_t histoName[40], histoTitle[90];
595 // Check fired pads (when available)
596 if(fFiredFitHistoList){
599 TCanvas *histoFiredCan[20];
600 Int_t nEntries = fFiredFitHistoList->GetEntries();
601 for(Int_t iEntry=0; iEntry<nEntries; iEntry++){
602 histo1D = (TH1F*)fFiredFitHistoList->At(iEntry);
603 printf("Problems found in %s\n", histo1D->GetTitle());
605 Int_t nPrintCan = nEntries;
607 AliWarning("Too many boards with problems: only 20 will be shown");
610 for(Int_t iCan=0; iCan<nPrintCan; iCan++){
611 histo1D = (TH1F*)fFiredFitHistoList->At(iCan);
612 histoFiredCan[iCan] = new TCanvas(histoName, histoTitle, 100+10*iCan, 10*iCan, 700, 700);
613 histoFiredCan[iCan]->SetRightMargin(0.14);
614 histoFiredCan[iCan]->SetLeftMargin(0.12);
616 fitFunc = histo1D->GetFunction("pol0");
617 fitFunc->SetLineColor(2);
618 fitFunc->Draw("same");
621 printf("\nAll local boards seem ok!!\n\n");
627 //_____________________________________________________________________________
628 void AliMUONTriggerEfficiencyCells::DisplayEfficiency(Bool_t perSlat, const Char_t* geoFilename)
631 /// Display calculated efficiency.
634 Bool_t isInitSlat = kFALSE, isInitBoard = kFALSE;
635 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
636 if(fBoardEfficiency[chCath]->GetEntries()>0) isInitBoard = kTRUE;
637 if(fSlatEfficiency[chCath]->GetEntries()>0) isInitSlat = kTRUE;
641 printf("Trigger efficiency not initialized per board.\nDisplay not yet implemented.\n");
644 if(!isInitSlat && perSlat){
645 printf("Trigger efficiency not initialized for slat.\nPlease try option kFALSE.\n");
649 GetListsForCheck(geoFilename);
651 const Int_t kNumOfBoards = AliMpConstants::NofLocalBoards();
654 Char_t histoName[40], histoTitle[90];
655 TPaveLabel *boardLabel = 0x0;
657 // Plot fired strips (when available)
658 if(fFiredDisplayHistoList){
659 TCanvas *displayFiredCan[fgkNplanes];
660 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
661 histo = (TH2F*)fFiredDisplayHistoList->At(chCath);
662 sprintf(histoName, "%sCan", histo->GetName());
663 sprintf(histoTitle, "%s", histo->GetTitle());
664 displayFiredCan[chCath] = new TCanvas(histoName, histoTitle, 100+10*chCath, 10*chCath, 700, 700);
665 displayFiredCan[chCath]->SetRightMargin(0.14);
666 displayFiredCan[chCath]->SetLeftMargin(0.12);
667 histo->GetYaxis()->SetTitleOffset(1.4);
668 histo->SetStats(kFALSE);
670 for (Int_t board = 0; board < kNumOfBoards; board++) {
671 Int_t currLabel = chCath * kNumOfBoards + board;
672 boardLabel = (TPaveLabel*)fBoardLabelList->At(currLabel);
673 boardLabel->Draw("same");
679 if(fDisplayHistoList){
680 TCanvas *can[fgkNplanes];
681 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
682 Int_t currChCath = chCath;
683 if(perSlat==kTRUE) currChCath += fgkNplanes;
684 histo = (TH2F*)fDisplayHistoList->At(currChCath);
685 sprintf(histoName, "%sCan", histo->GetName());
686 sprintf(histoTitle, "%s", histo->GetTitle());
687 can[chCath] = new TCanvas(histoName, histoTitle, 100+10*chCath, 10*chCath, 700, 700);
688 can[chCath]->SetRightMargin(0.14);
689 can[chCath]->SetLeftMargin(0.12);
690 histo->GetZaxis()->SetRangeUser(0.,1.);
691 histo->GetYaxis()->SetTitleOffset(1.4);
692 histo->SetStats(kFALSE);
694 for (Int_t board = 0; board < kNumOfBoards; board++) {
695 Int_t currLabel = chCath * kNumOfBoards + board;
696 if(perSlat==kTRUE) currLabel += kNumOfBoards * fgkNplanes;
697 boardLabel = (TPaveLabel*)fBoardLabelList->At(currLabel);
698 boardLabel->Draw("same");
705 //__________________________________________________________________________
706 Bool_t AliMUONTriggerEfficiencyCells::GetListsForCheck(const Char_t* geoFilename)
709 /// Getting histograms for efficiency,
710 /// map of fired strips entering efficiency calculations,
711 /// fits for checking switched-off elements in chambers.
714 const Int_t kNumOfBoards = AliMpConstants::NofLocalBoards();
715 const Float_t kChi2RedMax = 1.5;
716 const Float_t kDummyFired = 1e-5;
718 if(fDisplayHistoList || fBoardLabelList || fFiredFitHistoList || fFiredDisplayHistoList) return kTRUE;
720 if(!fDisplayHistoList) fDisplayHistoList = new TList();
721 if(!fBoardLabelList) fBoardLabelList = new TList();
722 if(!fFiredFitHistoList && fFiredStrips) fFiredFitHistoList = new TList();
723 if(!fFiredDisplayHistoList && fFiredStrips) fFiredDisplayHistoList = new TList();
725 AliMUONGeometryTransformer *transform = new AliMUONGeometryTransformer();
726 transform->LoadGeometryData(geoFilename);
728 if(!AliMpCDB::LoadDDLStore()) // Load DDL store from OCDB
729 AliFatal("Could not access mapping OCDB");
731 AliMpDDLStore *ddlStore = AliMpDDLStore::Instance();
733 Float_t xLocal1=0., yLocal1=0., xLocal2=0., yLocal2=0.;
734 Float_t xg1, yg1, zg1, xg2, yg2, zg2;
735 Float_t xWidth=0., yWidth=0.;
736 Float_t x1Label=0., x2Label=0., y1Label=0., y2Label=0.;
737 Float_t x1LabelSlat=0., x2LabelSlat=0., y1LabelSlat=0., y2LabelSlat=0.;
738 Int_t x1=0, y1=0, x2=0, y2=0, localId;
740 gStyle->SetPalette(1);
742 Char_t *cathCode[fgkNcathodes] = {"bendPlane", "nonBendPlane"};
744 Float_t boardsX = 280.00; // cm
745 Float_t boardsY = 335.00; // cm
747 // Check fired pads (when available)
748 Int_t maxY[fgkNcathodes] = {64,1};
749 TH3F *padFired[fgkNplanes];
750 TH1F *histoFired[fgkNplanes][234];
751 TH2F *histoFiredDisplay[fgkNplanes];
753 Bool_t isStripOffInBoard[fgkNplanes][234];
755 TH2F *histo[fgkNplanes];
756 TH2F *histoSlat[fgkNplanes];
757 TPaveLabel *boardLabel[fgkNplanes][234];
758 TPaveLabel *boardLabelSlat[fgkNplanes][234];
759 assert(kNumOfBoards==234);
761 Char_t histoName[40], histoTitle[90], labelTxt[5], labelSlatTxt[5];
763 Float_t efficiency, efficiencyError, efficiencySlat, efficiencySlatError;
766 for(Int_t cath=0; cath<fgkNcathodes; cath++){
767 padFired[cath] = 0x0;
768 if(fFiredStrips) padFired[cath] = (TH3F*)fFiredStrips->At(cath);
769 for(Int_t ch=0; ch<fgkNchambers; ch++){
770 Int_t chCath = fgkNchambers*cath + ch;
771 sprintf(histoName, "%sChamber%i", cathCode[cath], 11+ch);
772 sprintf(histoTitle, "Chamber %i: efficiency %s", 11+ch, cathCode[cath]);
773 histo[chCath] = new TH2F(histoName, histoTitle, (Int_t)boardsX, -boardsX, boardsX, (Int_t)boardsY, -boardsY, boardsY);
774 histo[chCath]->SetXTitle("X (cm)");
775 histo[chCath]->SetYTitle("Y (cm)");
776 fDisplayHistoList->Add(histo[chCath]);
778 if(!fFiredStrips) continue;
779 sprintf(histoName, "firedPads%sChamber%i", cathCode[cath], 11+ch);
780 sprintf(histoTitle, "Chamber %i: Fired pads %s", 11+ch, cathCode[cath]);
781 histoFiredDisplay[chCath] = new TH2F(histoName, histoTitle, (Int_t)boardsX, -boardsX, boardsX, (Int_t)boardsY, -boardsY, boardsY);
782 histoFiredDisplay[chCath]->SetXTitle("X (cm)");
783 histoFiredDisplay[chCath]->SetYTitle("Y (cm)");
784 fFiredDisplayHistoList->Add(histoFiredDisplay[chCath]);
786 for(Int_t ib=0; ib<kNumOfBoards; ib++){
787 sprintf(histoName, "%sChamber%iBoard%i", cathCode[cath], 11+ch, ib+1);
788 sprintf(histoTitle, "Chamber %i: fired pads %s board = %i", 11+ch, cathCode[cath], ib+1);
789 histoFired[chCath][ib] = new TH1F(histoName, histoTitle, 16, -0.5, 15.5);
790 histoFired[chCath][ib]->SetXTitle("board");
791 isStripOffInBoard[chCath][ib] = kFALSE;
796 for(Int_t cath=0; cath<fgkNcathodes; cath++){
797 for(Int_t ch=0; ch<fgkNchambers; ch++){
798 Int_t chCath = fgkNchambers*cath + ch;
799 sprintf(histoName, "%sChamber%iSlatEff", cathCode[cath], 11+ch);
800 sprintf(histoTitle, "Chamber %i: efficiency %s per slat", 11+ch, cathCode[cath]);
801 histoSlat[chCath] = new TH2F(histoName, histoTitle, (Int_t)boardsX, -boardsX, boardsX, (Int_t)boardsY, -boardsY, boardsY);
802 histoSlat[chCath]->SetXTitle("X (cm)");
803 histoSlat[chCath]->SetYTitle("Y (cm)");
804 fDisplayHistoList->Add(histoSlat[chCath]);
808 // loop over the trigger DDL (Right: 20, Left: 21)
809 for (Int_t iDDL = 20; iDDL <= 21; ++iDDL) {
810 AliMpDDL* ddl = ddlStore->GetDDL(iDDL);
811 Int_t nCrate = ddl->GetNofTriggerCrates();
812 // loop over the number of crates in DDL
813 for (Int_t index = 0; index < nCrate; ++index) {
815 AliMpTriggerCrate* crate = ddlStore->GetTriggerCrate(iDDL, index);
816 Int_t nLocal = crate->GetNofLocalBoards();
817 for (Int_t iLocal = 0; iLocal < nLocal; ++iLocal) {
818 // get local board Id from crate object
819 localId = crate->GetLocalBoardId(iLocal);
820 // get local board object
821 AliMpLocalBoard* localBoard = ddlStore->GetLocalBoard(localId);
823 if (!localBoard->IsNotified()) continue;
825 // get detection element connected to this board
826 for (Int_t ch = 0; ch < fgkNchambers; ++ch) {
827 Int_t iCh = ch + AliMpConstants::NofTrackingChambers();
828 Int_t detElemId = ddlStore->GetDEfromLocalBoard(localId, iCh);
830 if (!detElemId) continue;
833 for (Int_t cath = 0; cath < fgkNcathodes; ++cath) {
834 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()
835 ->GetMpSegmentation(detElemId,
836 AliMp::GetCathodType(cath));
838 Int_t chCath = fgkNchambers*cath + ch;
839 slat = detElemId%100;
843 for (Int_t ibitxy = 0; ibitxy < 16; ++ibitxy) {
844 // get pad from electronics
845 AliMpPad pad = seg->PadByLocation(AliMpIntPair(localId,
848 if (!pad.IsValid()) continue;
849 if(cath==0){ // Geometry info from bending plane only
851 xLocal1 = pad.Position().X();
852 yLocal1 = pad.Position().Y();
853 xWidth = pad.Dimensions().X();
854 yWidth = pad.Dimensions().Y();
856 xLocal2 = pad.Position().X();
857 yLocal2 = pad.Position().Y();
860 // Check fired pads (when available)
862 Int_t padX = pad.GetIndices().GetFirst();
863 Int_t padY = pad.GetIndices().GetSecond();
864 Int_t currPair = padX*maxY[cath] + padY;
866 //printf("cath %i board = %i (%2i, %2i) -> %i\n",
867 //cath, localId, padX, padY, currPair);
868 Int_t chBin = padFired[cath]->GetXaxis()->FindBin(ch);
869 Int_t slatBin = padFired[cath]->GetYaxis()->FindBin(slat);
870 Int_t pairBin = padFired[cath]->GetZaxis()->FindBin(currPair);
871 Float_t nFired = padFired[cath]->GetBinContent(chBin, slatBin, pairBin);;
873 Float_t dimX = pad.Dimensions().X();
874 Float_t dimY = pad.Dimensions().Y();
876 Float_t stripX1 = pad.Position().X();
877 Float_t stripY1 = pad.Position().Y();
878 Float_t stripX2 = pad.Position().X();
879 Float_t stripY2 = pad.Position().Y();
881 transform->Local2Global(detElemId, stripX1, stripY1, 0, xg1, yg1, zg1);
882 transform->Local2Global(detElemId, stripX2, stripY2, 0, xg2, yg2, zg2);
884 Float_t x1Float = TMath::Min(xg1,xg2) - dimX;
885 Float_t y1Float = TMath::Min(yg1,yg2) - dimY;
886 Float_t x2Float = TMath::Max(xg1,xg2) + dimX;
887 Float_t y2Float = TMath::Max(yg1,yg2) + dimY;
889 Int_t x1Int = histoFiredDisplay[chCath]->GetXaxis()->FindBin(x1Float)+1;
890 Int_t y1Int = histoFiredDisplay[chCath]->GetYaxis()->FindBin(y1Float)+1;
891 Int_t x2Int = histoFiredDisplay[chCath]->GetXaxis()->FindBin(x2Float)-1;
892 Int_t y2Int = histoFiredDisplay[chCath]->GetYaxis()->FindBin(y2Float)-1;
894 for(Int_t binX=x1Int; binX<=x2Int; binX++){
895 for(Int_t binY=y1Int; binY<=y2Int; binY++){
896 histoFiredDisplay[chCath]->SetBinContent(binX, binY, nFired);
900 if(nFired==0.) nFired = kDummyFired;
901 histoFired[chCath][localId-1]->Fill(ibitxy, nFired);
905 if(cath==0){ // Geometry info from bending plane only
906 transform->Local2Global(detElemId, xLocal1, yLocal1, 0, xg1, yg1, zg1);
907 transform->Local2Global(detElemId, xLocal2, yLocal2, 0, xg2, yg2, zg2);
910 x1Label = TMath::Min(xg1,xg2) - xWidth;
911 y1Label = TMath::Min(yg1,yg2) - yWidth;
912 x2Label = TMath::Max(xg1,xg2) + xWidth;
913 y2Label = TMath::Max(yg1,yg2) + yWidth;
915 x1 = histo[ch]->GetXaxis()->FindBin(x1Label)+1;
916 y1 = histo[ch]->GetYaxis()->FindBin(y1Label)+1;
917 x2 = histo[ch]->GetXaxis()->FindBin(x2Label)-1;
918 y2 = histo[ch]->GetYaxis()->FindBin(y2Label)-1;
920 sprintf(labelTxt,"%3d", localId);
923 line = localBoard->GetPosition().GetFirst();
925 x2LabelSlat = x1LabelSlat + 40.;
926 y1LabelSlat = -285. + ((Float_t)(line - 1)) * 68;
927 y2LabelSlat = y1LabelSlat + 34.;
928 if(localId>kNumOfBoards/2){
929 x1LabelSlat = -x2LabelSlat;
930 x2LabelSlat = x1LabelSlat + 40.;
932 sprintf(labelSlatTxt,"%2d", slat);
935 boardLabel[chCath][localId-1] = new TPaveLabel(x1Label, y1Label, x2Label, y2Label, labelTxt);
936 boardLabel[chCath][localId-1]->SetFillStyle(0);
937 boardLabel[chCath][localId-1]->SetBorderSize(0);
939 boardLabelSlat[chCath][localId-1] = new TPaveLabel(x1LabelSlat, y1LabelSlat, x2LabelSlat, y2LabelSlat, labelSlatTxt);
940 boardLabelSlat[chCath][localId-1]->SetFillStyle(0);
941 boardLabelSlat[chCath][localId-1]->SetBorderSize(0);
943 Int_t histoBin = localId;
944 efficiency = fBoardEfficiency[chCath]->GetBinContent(histoBin);
945 efficiencyError = fBoardEfficiency[chCath]->GetBinError(histoBin);
948 efficiencySlat = fSlatEfficiency[chCath]->GetBinContent(histoBin);
949 efficiencySlatError = fSlatEfficiency[chCath]->GetBinError(histoBin);
951 for(Int_t binX=x1; binX<=x2; binX++){
952 for(Int_t binY=y1; binY<=y2; binY++){
953 histo[chCath]->SetBinContent(binX, binY, efficiency);
954 histo[chCath]->SetBinError(binX, binY, efficiencyError);
955 histoSlat[chCath]->SetBinContent(binX, binY, efficiencySlat);
956 histoSlat[chCath]->SetBinError(binX, binY, efficiencySlatError);
960 // Check fired pads (when available)
962 histoFired[chCath][localId-1]->Fit("pol0","Q0R","",0., (Float_t)nStrips-1.);
963 fitFunc = histoFired[chCath][localId-1]->GetFunction("pol0");
964 Float_t chi2 = fitFunc->GetChisquare();
965 Float_t ndf = (Float_t)fitFunc->GetNDF();
966 Float_t reducedChi2 = chi2/ndf;
967 if(reducedChi2>kChi2RedMax) {
968 isStripOffInBoard[chCath][localId-1] = kTRUE;
969 //printf("Chamber = %i Cath = %i Board %i: chi2/NDF = %f\tparam = %f\n", ch, cath, localId, reducedChi2, fitFunc->GetParameter(0));
970 fFiredFitHistoList->Add(histoFired[chCath][localId-1]);
973 } // loop on cathodes
974 } // loop on chambers
979 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
980 for(Int_t ib=0; ib<kNumOfBoards; ib++){
981 fBoardLabelList->Add(boardLabel[chCath][ib]);
984 for(Int_t chCath=0; chCath<fgkNplanes; chCath++){
985 for(Int_t ib=0; ib<kNumOfBoards; ib++){
986 fBoardLabelList->Add(boardLabelSlat[chCath][ib]);
994 //__________________________________________________________________________
995 Bool_t AliMUONTriggerEfficiencyCells::SumRunEfficiency(const AliMUONTriggerEfficiencyCells &other)
997 /// Sums results from different runs and gives the efficiency
998 if(!fCountHistoList || !fNoCountHistoList) {
999 AliWarning("Histograms for efficiency calculations not implemented in object");
1002 if(!other.fCountHistoList || !other.fNoCountHistoList) {
1003 AliWarning("Histograms for efficiency calculations not implemented in object passed as argument");
1007 Int_t nentries = fCountHistoList->GetEntries();
1008 TH1F *currNum = 0x0, *currDen = 0x0, *otherNum = 0x0, *otherDen = 0x0;
1010 for(Int_t iEntry=0; iEntry<nentries; iEntry++){
1011 currNum = (TH1F*)fCountHistoList->At(iEntry);
1012 currDen = (TH1F*)fNoCountHistoList->At(iEntry);
1013 otherNum = (TH1F*)other.fCountHistoList->At(iEntry);
1014 otherDen = (TH1F*)other.fNoCountHistoList->At(iEntry);
1015 currNum->Add(otherNum);
1016 currDen->Add(otherDen);
1019 FillHistosFromList();
1022 AliWarning("Histograms for fired region check not implemented in object");
1025 if(!other.fFiredStrips) {
1026 AliWarning("Histograms for fired region check not implemented in object passed as argument");
1030 TH3F *currFired = 0x0, *otherFired = 0x0;
1031 nentries = fFiredStrips->GetEntries();
1032 for(Int_t iEntry=0; iEntry<nentries; iEntry++){
1033 currFired = (TH3F*)fFiredStrips->At(iEntry);
1034 otherFired = (TH3F*)fFiredStrips->At(iEntry);
1035 currFired->Add(otherFired);