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 "Riostream.h"
21 #include "AliMUONTriggerEfficiencyCells.h"
22 #include "AliMUONConstants.h"
25 /// \class AliMUONTriggerEfficiencyCells
26 /// A class to store and give access to the trigger chamber efficiency.
28 /// Efficiency is stored per cathode on local boards, or, alternatively,
29 /// on "cells" of a given size.
31 /// The main method of this class is IsTriggered().
33 /// $ALICE_ROOT/MUON/data/TriggerChamberefficiencyCells.dat contains efficiency
34 /// for each chamber (i.e. DetElement).
36 /// In the case of local boards, efficiency is stored from left to right
37 /// per increasing board number (from 1 to 234)
39 /// Otherwise, he efficiency cells goes from right to left and
40 /// from bottom to top of the chamber, namely, the efficiencies tabulated in the
41 /// file refers to the following reference frame:
45 /// <----------------------------------|
47 /// --------------------------- |
48 /// | 0.97 | 0.97 | 0.97 | 0.97 | |
49 /// --------------------------- |
50 /// | 0.97 | 0.97 | 0.97 | 0.97 | |
51 /// --------------------------- |
52 /// | 0.97 | 0.97 | 0.97 | 0.97 | |
53 /// --------------------------- |
58 /// In both cases, the file can be edited in order to change efficiency
59 /// in a chosen local board/region of the chamber.
62 /// But please note that this object is also available from the CDB
63 /// (generated using the MUONCDB.C macro)
65 /// \author Diego Stocco; INFN Torino
68 ClassImp(AliMUONTriggerEfficiencyCells)
71 //__________________________________________________________________________
72 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells()
76 /// Default constructor.
80 //__________________________________________________________________________
81 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const char* filename)
85 /// Constructor using an ASCII file.
91 //__________________________________________________________________________
92 AliMUONTriggerEfficiencyCells::~AliMUONTriggerEfficiencyCells()
94 /// Destructor. Does nothing ;-)
98 //__________________________________________________________________________
99 void AliMUONTriggerEfficiencyCells::GetCellEfficiency(Int_t detElemId, Float_t x, Float_t y, Float_t &eff1, Float_t &eff2)
101 /// Get the efficiencies of the 2 cathodes at a given location (x,y)
103 Int_t chamber = FindChamberIndex(detElemId);
104 Int_t slat = FindSlatIndex(detElemId);
105 TArrayI cell = CellByCoord(detElemId,x,y);
108 if(cell.At(0)>=0 && cell.At(1)>=0)
110 eff1 = fCellContent[chamber][slat][0][cell.At(0)][cell.At(1)];
111 eff2 = fCellContent[chamber][slat][1][cell.At(0)][cell.At(1)];
116 //__________________________________________________________________________
117 void AliMUONTriggerEfficiencyCells::GetCellEfficiency(Int_t detElemId, Int_t localBoard, Float_t &eff1, Float_t &eff2)
119 /// Get the efficiencies of the 2 cathodes at a given local board
121 Int_t chamber = FindChamberIndex(detElemId);
122 eff1 = fBoardContent[chamber][0][localBoard];
123 eff2 = fBoardContent[chamber][1][localBoard];
127 //__________________________________________________________________________
129 AliMUONTriggerEfficiencyCells::IsTriggered(Int_t detElemId, Float_t x, Float_t y, Bool_t &trig1, Bool_t &trig2)
131 /// Whether or not a given location (x,y) has a chance to trig, on each cathode.
135 GetCellEfficiency(detElemId, x, y, eff1, eff2);
138 if(gRandom->Rndm()>eff1)trig1 = kFALSE;
139 if(gRandom->Rndm()>eff2)trig2 = kFALSE;
143 //__________________________________________________________________________
145 AliMUONTriggerEfficiencyCells::IsTriggered(Int_t detElemId, Int_t localBoard, Bool_t &trig1, Bool_t &trig2)
147 /// Whether or not a given local board has a chance to trig, on each cathode.
151 GetCellEfficiency(detElemId, localBoard, eff1, eff2);
154 if(gRandom->Rndm()>eff1)trig1 = kFALSE;
155 if(gRandom->Rndm()>eff2)trig2 = kFALSE;
158 //__________________________________________________________________________
159 TArrayI AliMUONTriggerEfficiencyCells::CellByCoord(Int_t detElemId, Float_t x, Float_t y)
161 /// Get the efficiencies at a given location.
163 Int_t chamber = FindChamberIndex(detElemId);
164 Int_t slat = FindSlatIndex(detElemId);
165 Int_t cell[2]={-1,-1};
166 Float_t maxX = fCellSize[chamber][slat][0]*((Float_t)fCellNumber[chamber][slat][0]);
167 Float_t maxY = fCellSize[chamber][slat][1]*((Float_t)fCellNumber[chamber][slat][1]);
168 if(x>=0 & x<maxX & y>=0 & y<maxY)
170 cell[0] = (Int_t)(x/fCellSize[chamber][slat][0]);
171 cell[1] = (Int_t)(y/fCellSize[chamber][slat][1]);
173 return TArrayI(2,cell);
176 //__________________________________________________________________________
177 void AliMUONTriggerEfficiencyCells::ReadFile(const char* filename)
179 /// Reads a file containing the efficiency map.
181 TString fileName = gSystem->ExpandPathName(filename);
182 ifstream file(fileName.Data());
186 if(!strcmp(dat,"localBoards"))ReadFileBoards(file);
187 else ReadFileXY(file);
190 AliWarning(Form("Can't read file %s",fileName.Data()));
195 //__________________________________________________________________________
196 void AliMUONTriggerEfficiencyCells::ReadFileXY(ifstream &file)
198 /// Structure of file containing geometrical efficency
199 Int_t datInt=0, detEl=0, chamber=0, rpc=0;
200 Float_t datFloat=0.0;
203 while (file >> dat) {
205 chamber = FindChamberIndex(detEl);
206 rpc = FindSlatIndex(detEl);
208 for(Int_t i=0; i<2; i++){
210 fCellNumber[chamber][rpc][i] = datInt;
213 for(Int_t i=0; i<2; i++){
215 fCellSize[chamber][rpc][i] = datFloat;
218 for(Int_t cath=0; cath<2; cath++){
221 for(Int_t iy=0; iy<fCellNumber[chamber][rpc][1]; iy++){
222 for(Int_t ix=0; ix<fCellNumber[chamber][rpc][0]; ix++){
224 fCellContent[chamber][rpc][cath][ix][iy] = datFloat;
231 //__________________________________________________________________________
232 void AliMUONTriggerEfficiencyCells::ReadFileBoards(ifstream &file)
234 /// Structure of file containing local board efficency
235 Int_t datInt=0, detEl=0, chamber=0;
236 Float_t datFloat=0.0;
239 while (file >> dat) {
241 chamber = FindChamberIndex(detEl);
242 //rpc = FindSlatIndex(detEl);
243 for(Int_t cath=0; cath<2; cath++){
246 for(Int_t board=0; board<fgkNofBoards; board++){
248 fBoardContent[chamber][cath][board] = datFloat;
254 //__________________________________________________________________________
255 Int_t AliMUONTriggerEfficiencyCells::FindChamberIndex(Int_t detElemId)
257 /// From detElemId to chamber number
259 Int_t offset = 100*(AliMUONConstants::NTrackingCh()+1);
260 Int_t chamber = (detElemId-offset)/100;
265 //__________________________________________________________________________
266 Int_t AliMUONTriggerEfficiencyCells::FindSlatIndex(Int_t detElemId)
268 /// From detElemId to slat index.
270 Int_t offset = 100*(AliMUONConstants::NTrackingCh()+1);
271 Int_t chamber = FindChamberIndex(detElemId);
272 Int_t slat = detElemId-offset-(chamber*100);
277 //__________________________________________________________________________
278 TVector2 AliMUONTriggerEfficiencyCells::ChangeReferenceFrame(Float_t x, Float_t y, Float_t x0, Float_t y0)
280 /// (x0,y0) position of the local reference frame (center of the chamber)
282 Float_t x1 = x0-x;//reflection of axis
284 return TVector2(x1,y1);
287 //__________________________________________________________________________
289 AliMUONTriggerEfficiencyCells::Reset()
291 /// Sets our internal array contents to zero.
293 for(Int_t chamber=0; chamber<4; chamber++)
295 for(Int_t slat=0; slat<18; slat++)
297 for(Int_t cath=0; cath<2; cath++)
299 fCellSize[chamber][slat][cath]=0.0;
300 fCellNumber[chamber][slat][cath]=0;
301 for(Int_t ix=0; ix<fgkNofCells; ix++)
303 for(Int_t iy=0; iy<fgkNofCells; iy++)
305 fCellContent[chamber][slat][cath][ix][iy]=0.0;
310 for(Int_t cath=0; cath<2; cath++)
312 for(Int_t board=0; board<fgkNofBoards; board++)
314 fBoardContent[chamber][cath][board]=0.0;