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"
30 /// \class AliMUONTriggerEfficiencyCells
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:
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 /// --------------------------- |
57 /// The file can be edited in order to change efficiency in a chosen region
60 /// But please note that this object is also available from the CDB
61 /// (generated using the MUONCDB.C macro)
63 /// \author Diego Stocco; INFN Torino
66 ClassImp(AliMUONTriggerEfficiencyCells)
69 //__________________________________________________________________________
70 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells()
74 /// Default constructor.
78 //__________________________________________________________________________
79 AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const char* filename)
83 /// Constructor using an ASCII file.
89 //__________________________________________________________________________
90 AliMUONTriggerEfficiencyCells::~AliMUONTriggerEfficiencyCells()
92 /// Destructor. Does nothing ;-)
95 //__________________________________________________________________________
96 Float_t AliMUONTriggerEfficiencyCells::GetCellEfficiency(Int_t detElemId, Int_t cathode, Float_t x, Float_t y)
98 /// Get the efficiency at a given position (x,y) for a given cathode
100 Int_t chamber = FindChamberIndex(detElemId);
101 Int_t slat = FindSlatIndex(detElemId);
102 TArrayI cell = CellByCoord(detElemId,x,y);
103 Float_t efficiency = 0.0;
104 if (cell.At(0)>=0 && cell.At(1)>=0)
106 efficiency = fCellContent[chamber][slat][cathode][cell.At(0)][cell.At(1)];
112 //__________________________________________________________________________
113 void AliMUONTriggerEfficiencyCells::GetCellEfficiency(Int_t detElemId, Float_t x, Float_t y, Float_t &eff1, Float_t &eff2)
115 /// Get the efficiencies of the 2 cathode at a given location (x,y)
117 Int_t chamber = FindChamberIndex(detElemId);
118 Int_t slat = FindSlatIndex(detElemId);
119 TArrayI cell = CellByCoord(detElemId,x,y);
122 if(cell.At(0)>=0 && cell.At(1)>=0)
124 eff1 = fCellContent[chamber][slat][0][cell.At(0)][cell.At(1)];
125 eff2 = fCellContent[chamber][slat][1][cell.At(0)][cell.At(1)];
130 //__________________________________________________________________________
132 AliMUONTriggerEfficiencyCells::IsTriggered(Int_t detElemId, Int_t cathode, Float_t x, Float_t y)
134 /// Random decision of whether a given "location" (x,y) trigs or not.
136 Float_t efficiency = GetCellEfficiency(detElemId, cathode, x, y);
137 Bool_t trigger = kTRUE;
138 if(gRandom->Rndm()>efficiency)
146 //__________________________________________________________________________
148 AliMUONTriggerEfficiencyCells::IsTriggered(Int_t detElemId, Float_t x, Float_t y, Bool_t &trig1, Bool_t &trig2)
150 /// Whether or not a given location (x,y) has a chance to trig, on each cathode.
154 GetCellEfficiency(detElemId, x, y, eff1, eff2);
157 if(gRandom->Rndm()>eff1)trig1 = kFALSE;
158 if(gRandom->Rndm()>eff2)trig2 = kFALSE;
162 //__________________________________________________________________________
163 TArrayI AliMUONTriggerEfficiencyCells::CellByCoord(Int_t detElemId, Float_t x, Float_t y)
165 /// Get the efficiencies at a given location.
167 Int_t chamber = FindChamberIndex(detElemId);
168 Int_t slat = FindSlatIndex(detElemId);
169 Int_t cell[2]={-1,-1};
170 Float_t maxX = fCellSize[chamber][slat][0]*((Float_t)fCellNumber[chamber][slat][0]);
171 Float_t maxY = fCellSize[chamber][slat][1]*((Float_t)fCellNumber[chamber][slat][1]);
172 if(x>=0 & x<maxX & y>=0 & y<maxY)
174 cell[0] = (Int_t)(x/fCellSize[chamber][slat][0]);
175 cell[1] = (Int_t)(y/fCellSize[chamber][slat][1]);
177 return TArrayI(2,cell);
180 //__________________________________________________________________________
181 void AliMUONTriggerEfficiencyCells::ReadFile(const char* filename)
183 /// Reads a file containing the efficiency map.
185 TString fileName = gSystem->ExpandPathName(filename);
186 ifstream file(fileName.Data());
187 Int_t datInt=0, detEl=0, chamber=0, rpc=0;
188 Float_t datFloat=0.0;
191 while (file >> dat) {
193 chamber = FindChamberIndex(detEl);
194 rpc = FindSlatIndex(detEl);
196 for(Int_t i=0; i<2; i++){
198 fCellNumber[chamber][rpc][i] = datInt;
201 for(Int_t i=0; i<2; i++){
203 fCellSize[chamber][rpc][i] = datFloat;
206 for(Int_t cath=0; cath<2; cath++){
209 for(Int_t iy=0; iy<fCellNumber[chamber][rpc][1]; iy++){
210 for(Int_t ix=0; ix<fCellNumber[chamber][rpc][0]; ix++){
212 fCellContent[chamber][rpc][cath][ix][iy] = datFloat;
219 AliWarning(Form("Can't read file %s",fileName.Data()));
224 //__________________________________________________________________________
225 Int_t AliMUONTriggerEfficiencyCells::FindChamberIndex(Int_t detElemId)
227 /// From detElemId to chamber number
229 Int_t offset = 100*(AliMUONConstants::NTrackingCh()+1);
230 Int_t chamber = (detElemId-offset)/100;
235 //__________________________________________________________________________
236 Int_t AliMUONTriggerEfficiencyCells::FindSlatIndex(Int_t detElemId)
238 /// From detElemId to slat index.
240 Int_t offset = 100*(AliMUONConstants::NTrackingCh()+1);
241 Int_t chamber = FindChamberIndex(detElemId);
242 Int_t slat = detElemId-offset-(chamber*100);
247 //__________________________________________________________________________
248 TVector2 AliMUONTriggerEfficiencyCells::ChangeReferenceFrame(Float_t x, Float_t y, Float_t x0, Float_t y0)
250 /// (x0,y0) position of the local reference frame (center of the chamber)
252 Float_t x1 = x0-x;//reflection of axis
254 return TVector2(x1,y1);
257 //__________________________________________________________________________
259 AliMUONTriggerEfficiencyCells::Reset()
261 /// Sets our internal array contents to zero.
263 for(Int_t chamber=0; chamber<4; chamber++)
265 for(Int_t slat=0; slat<18; slat++)
267 for(Int_t cath=0; cath<2; cath++)
269 fCellSize[chamber][slat][cath]=0.0;
270 fCellNumber[chamber][slat][cath]=0;
271 for(Int_t ix=0; ix<fgkNofCells; ix++)
273 for(Int_t iy=0; iy<fgkNofCells; iy++)
275 fCellContent[chamber][slat][cath][ix][iy]=0.0;