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"
20 #include "AliMUONTriggerEfficiencyCells.h"
21 #include "AliMUONConstants.h"
25 #include "AliMpVSegmentation.h"
26 #include "AliMpTriggerSegmentation.h"
27 #include "AliMpTrigger.h"
31 // A class to store and give access to the trigger chamber efficiency.
33 // Efficiency is stored per cathode, on "cells" of a given size.
35 // The main method of this class is IsTriggered().
37 // $ALICE_ROOT/MUON/data/TriggerChamberefficiencyCells.dat contains efficiency
38 // for each chamber (i.e. DetElement).
39 // The 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:
44 //<----------------------------------|
46 // --------------------------- |
47 // | 0.97 | 0.97 | 0.97 | 0.97 | |
48 // --------------------------- |
49 // | 0.97 | 0.97 | 0.97 | 0.97 | |
50 // --------------------------- |
51 // | 0.97 | 0.97 | 0.97 | 0.97 | |
52 // --------------------------- |
56 // The file can be edited in order to change efficiency in a chosen region
59 // But please note that this object is also available from the CDB
60 // (generated using the MUONCDB.C macro)
63 ClassImp(AliMUONTriggerEfficiencyCells)
65 //__________________________________________________________________________
66 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells()
74 //__________________________________________________________________________
75 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const char* filename)
79 // Ctor using an ASCII file.
85 //__________________________________________________________________________
86 AliMUONTriggerEfficiencyCells::~AliMUONTriggerEfficiencyCells()
88 // dtor. Does nothing ;-)
91 //__________________________________________________________________________
92 Float_t AliMUONTriggerEfficiencyCells::GetCellEfficiency(Int_t detElemId, Int_t cathode, Float_t x, Float_t y)
94 // Get the efficiency at a given position (x,y) for a given cathode
96 Int_t chamber = FindChamberIndex(detElemId);
97 Int_t slat = FindSlatIndex(detElemId);
98 TArrayI cell = CellByCoord(detElemId,x,y);
99 Float_t efficiency = 0.0;
100 if (cell.At(0)>=0 && cell.At(1)>=0)
102 efficiency = fCellContent[chamber][slat][cathode][cell.At(0)][cell.At(1)];
108 //__________________________________________________________________________
109 void AliMUONTriggerEfficiencyCells::GetCellEfficiency(Int_t detElemId, Float_t x, Float_t y, Float_t &eff1, Float_t &eff2)
111 // Get the efficiencies of the 2 cathode at a given location (x,y)
112 Int_t chamber = FindChamberIndex(detElemId);
113 Int_t slat = FindSlatIndex(detElemId);
114 TArrayI cell = CellByCoord(detElemId,x,y);
117 if(cell.At(0)>=0 && cell.At(1)>=0)
119 eff1 = fCellContent[chamber][slat][0][cell.At(0)][cell.At(1)];
120 eff2 = fCellContent[chamber][slat][1][cell.At(0)][cell.At(1)];
125 //__________________________________________________________________________
127 AliMUONTriggerEfficiencyCells::IsTriggered(Int_t detElemId, Int_t cathode, Float_t x, Float_t y)
129 // Random decision of whether a given "location" (x,y) trigs or not.
130 Float_t efficiency = GetCellEfficiency(detElemId, cathode, x, y);
131 Bool_t trigger = kTRUE;
132 if(gRandom->Rndm()>efficiency)
140 //__________________________________________________________________________
142 AliMUONTriggerEfficiencyCells::IsTriggered(Int_t detElemId, Float_t x, Float_t y, Bool_t &trig1, Bool_t &trig2)
144 // Whether or not a given location (x,y) has a chance to trig, on each cathode.
147 GetCellEfficiency(detElemId, x, y, eff1, eff2);
150 if(gRandom->Rndm()>eff1)trig1 = kFALSE;
151 if(gRandom->Rndm()>eff2)trig2 = kFALSE;
155 //__________________________________________________________________________
156 TArrayI AliMUONTriggerEfficiencyCells::CellByCoord(Int_t detElemId, Float_t x, Float_t y)
158 // Get the efficiencies at a given location.
159 Int_t chamber = FindChamberIndex(detElemId);
160 Int_t slat = FindSlatIndex(detElemId);
161 Int_t cell[2]={-1,-1};
162 Float_t maxX = fCellSize[chamber][slat][0]*((Float_t)fCellNumber[chamber][slat][0]);
163 Float_t maxY = fCellSize[chamber][slat][1]*((Float_t)fCellNumber[chamber][slat][1]);
164 if(x>=0 & x<maxX & y>=0 & y<maxY)
166 cell[0] = (Int_t)(x/fCellSize[chamber][slat][0]);
167 cell[1] = (Int_t)(y/fCellSize[chamber][slat][1]);
169 return TArrayI(2,cell);
172 //__________________________________________________________________________
173 void AliMUONTriggerEfficiencyCells::ReadFile(const char* filename)
175 // Reads a file containing the efficiency map.
176 TString fileName = gSystem->ExpandPathName(filename);
177 ifstream file(fileName.Data());
178 Int_t datInt=0, detEl=0, chamber=0, rpc=0;
179 Float_t datFloat=0.0;
182 while (file >> dat) {
184 chamber = FindChamberIndex(detEl);
185 rpc = FindSlatIndex(detEl);
187 for(Int_t i=0; i<2; i++){
189 fCellNumber[chamber][rpc][i] = datInt;
192 for(Int_t i=0; i<2; i++){
194 fCellSize[chamber][rpc][i] = datFloat;
197 for(Int_t cath=0; cath<2; cath++){
200 for(Int_t iy=0; iy<fCellNumber[chamber][rpc][1]; iy++){
201 for(Int_t ix=0; ix<fCellNumber[chamber][rpc][0]; ix++){
203 fCellContent[chamber][rpc][cath][ix][iy] = datFloat;
210 AliWarning(Form("Can't read file %s",fileName.Data()));
215 //__________________________________________________________________________
216 Int_t AliMUONTriggerEfficiencyCells::FindChamberIndex(Int_t detElemId)
218 // From detElemId to chamber number
219 Int_t offset = 100*(AliMUONConstants::NTrackingCh()+1);
220 Int_t chamber = (detElemId-offset)/100;
225 //__________________________________________________________________________
226 Int_t AliMUONTriggerEfficiencyCells::FindSlatIndex(Int_t detElemId)
228 // From detElemId to slat index.
229 Int_t offset = 100*(AliMUONConstants::NTrackingCh()+1);
230 Int_t chamber = FindChamberIndex(detElemId);
231 Int_t slat = detElemId-offset-(chamber*100);
236 //__________________________________________________________________________
237 TVector2 AliMUONTriggerEfficiencyCells::ChangeReferenceFrame(Float_t x, Float_t y, Float_t x0, Float_t y0)
239 //(x0,y0) position of the local reference frame (center of the chamber)
240 Float_t x1 = x0-x;//reflection of axis
242 return TVector2(x1,y1);
245 //__________________________________________________________________________
247 AliMUONTriggerEfficiencyCells::Reset()
250 // Sets our internal array contents to zero.
252 for(Int_t chamber=0; chamber<4; chamber++)
254 for(Int_t slat=0; slat<18; slat++)
256 for(Int_t cath=0; cath<2; cath++)
258 fCellSize[chamber][slat][cath]=0.0;
259 fCellNumber[chamber][slat][cath]=0;
260 for(Int_t ix=0; ix<fgkNofCells; ix++)
262 for(Int_t iy=0; iy<fgkNofCells; iy++)
264 fCellContent[chamber][slat][cath][ix][iy]=0.0;