]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTriggerEfficiencyCells.cxx
Update rawdata format for trigger (Christian)
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerEfficiencyCells.cxx
CommitLineData
70b4a8d6 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16#include <fstream>
17#include <TRandom.h>
18#include "Riostream.h"
19
20#include "AliMUONTriggerEfficiencyCells.h"
21#include "AliMUONConstants.h"
22#include "AliRun.h"
23#include "AliMpPad.h"
24#include "AliMUON.h"
25#include "AliMpVSegmentation.h"
26#include "AliMpTriggerSegmentation.h"
27#include "AliMpTrigger.h"
28#include "AliLog.h"
29
30//
31// A class to store and give access to the trigger chamber efficiency.
32//
33// Efficiency is stored per cathode, on "cells" of a given size.
34//
35// The main method of this class is IsTriggered().
36//
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:
42//
43//x
44//<----------------------------------|
45// |
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// --------------------------- |
53// |
54// \/ y
55//
56// The file can be edited in order to change efficiency in a chosen region
57// of the chamber.
58//
59// But please note that this object is also available from the CDB
60// (generated using the MUONCDB.C macro)
61//
62
63ClassImp(AliMUONTriggerEfficiencyCells)
64
65//__________________________________________________________________________
66AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells()
67:
68TObject()
69{
70 // Default ctor.
71 Reset();
72}
73
74//__________________________________________________________________________
75AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const char* filename)
76:
77TObject()
78{
79 // Ctor using an ASCII file.
80 Reset();
81 ReadFile(filename);
82}
83
84
85//__________________________________________________________________________
86AliMUONTriggerEfficiencyCells::~AliMUONTriggerEfficiencyCells()
87{
88 // dtor. Does nothing ;-)
89}
90
91//__________________________________________________________________________
92Float_t AliMUONTriggerEfficiencyCells::GetCellEfficiency(Int_t detElemId, Int_t cathode, Float_t x, Float_t y)
93{
94 // Get the efficiency at a given position (x,y) for a given cathode
95
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)
101 {
102 efficiency = fCellContent[chamber][slat][cathode][cell.At(0)][cell.At(1)];
103 }
104 return efficiency;
105}
106
107
108//__________________________________________________________________________
109void AliMUONTriggerEfficiencyCells::GetCellEfficiency(Int_t detElemId, Float_t x, Float_t y, Float_t &eff1, Float_t &eff2)
110{
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);
115 eff1 = 0.0;
116 eff2 = 0.0;
117 if(cell.At(0)>=0 && cell.At(1)>=0)
118 {
119 eff1 = fCellContent[chamber][slat][0][cell.At(0)][cell.At(1)];
120 eff2 = fCellContent[chamber][slat][1][cell.At(0)][cell.At(1)];
121 }
122}
123
124
125//__________________________________________________________________________
126Bool_t
127AliMUONTriggerEfficiencyCells::IsTriggered(Int_t detElemId, Int_t cathode, Float_t x, Float_t y)
128{
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)
133 {
134 trigger = kFALSE;
135 }
136 return trigger;
137}
138
139
140//__________________________________________________________________________
141void
142AliMUONTriggerEfficiencyCells::IsTriggered(Int_t detElemId, Float_t x, Float_t y, Bool_t &trig1, Bool_t &trig2)
143{
144 // Whether or not a given location (x,y) has a chance to trig, on each cathode.
145 Float_t eff1 = 0.0;
146 Float_t eff2 = 0.0;
147 GetCellEfficiency(detElemId, x, y, eff1, eff2);
148 trig1 = kTRUE;
149 trig2 = kTRUE;
150 if(gRandom->Rndm()>eff1)trig1 = kFALSE;
151 if(gRandom->Rndm()>eff2)trig2 = kFALSE;
152}
153
154
155//__________________________________________________________________________
156TArrayI AliMUONTriggerEfficiencyCells::CellByCoord(Int_t detElemId, Float_t x, Float_t y)
157{
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)
165 {
166 cell[0] = (Int_t)(x/fCellSize[chamber][slat][0]);
167 cell[1] = (Int_t)(y/fCellSize[chamber][slat][1]);
168 }
169 return TArrayI(2,cell);
170}
171
172//__________________________________________________________________________
173void AliMUONTriggerEfficiencyCells::ReadFile(const char* filename)
174{
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;
180 char dat[50];
181 if (file.good()){
182 while (file >> dat) {
183 file >> detEl;
184 chamber = FindChamberIndex(detEl);
185 rpc = FindSlatIndex(detEl);
186 file >> dat;
187 for(Int_t i=0; i<2; i++){
188 file >> datInt;
189 fCellNumber[chamber][rpc][i] = datInt;
190 file >> dat;
191 }
192 for(Int_t i=0; i<2; i++){
193 file >> datFloat;
194 fCellSize[chamber][rpc][i] = datFloat;
195 if(i==0)file >> dat;
196 }
197 for(Int_t cath=0; cath<2; cath++){
198 file >> dat;
199 file >> datInt;
200 for(Int_t iy=0; iy<fCellNumber[chamber][rpc][1]; iy++){
201 for(Int_t ix=0; ix<fCellNumber[chamber][rpc][0]; ix++){
202 file >> datFloat;
203 fCellContent[chamber][rpc][cath][ix][iy] = datFloat;
204 }
205 }
206 }
207 }
208 file.close();
209 } else {
210 AliWarning(Form("Can't read file %s",fileName.Data()));
211 }
212}
213
214
215//__________________________________________________________________________
216Int_t AliMUONTriggerEfficiencyCells::FindChamberIndex(Int_t detElemId)
217{
218 // From detElemId to chamber number
219 Int_t offset = 100*(AliMUONConstants::NTrackingCh()+1);
220 Int_t chamber = (detElemId-offset)/100;
221 return chamber;
222}
223
224
225//__________________________________________________________________________
226Int_t AliMUONTriggerEfficiencyCells::FindSlatIndex(Int_t detElemId)
227{
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);
232 return slat;
233}
234
235
236//__________________________________________________________________________
237TVector2 AliMUONTriggerEfficiencyCells::ChangeReferenceFrame(Float_t x, Float_t y, Float_t x0, Float_t y0)
238{
239 //(x0,y0) position of the local reference frame (center of the chamber)
240 Float_t x1 = x0-x;//reflection of axis
241 Float_t y1 = y+y0;
242 return TVector2(x1,y1);
243}
244
245//__________________________________________________________________________
246void
247AliMUONTriggerEfficiencyCells::Reset()
248{
249 //
250 // Sets our internal array contents to zero.
251 //
252 for(Int_t chamber=0; chamber<4; chamber++)
253 {
254 for(Int_t slat=0; slat<18; slat++)
255 {
256 for(Int_t cath=0; cath<2; cath++)
257 {
258 fCellSize[chamber][slat][cath]=0.0;
259 fCellNumber[chamber][slat][cath]=0;
260 for(Int_t ix=0; ix<fgkNofCells; ix++)
261 {
262 for(Int_t iy=0; iy<fgkNofCells; iy++)
263 {
264 fCellContent[chamber][slat][cath][ix][iy]=0.0;
265 }
266 }
267 }
268 }
269 }
270}
271