AliRoot Core  edcc906 (edcc906)
AliMUONResponseTriggerV1.cxx
Go to the documentation of this file.
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 /* $Id$ */
17 
18 //-----------------------------------------------------------------------------
19 // Class AliMUONTriggerResponseV1
20 // ------------------
21 // Trigger chamber response
22 // with cluster size activated
23 //-----------------------------------------------------------------------------
24 
26 #include "AliMUON.h"
27 #include "AliMUONDigit.h"
29 #include "AliMUONConstants.h"
30 
31 #include "AliCDBManager.h"
32 #include "AliCDBPath.h"
33 #include "AliCDBEntry.h"
34 
35 #include "AliMpPad.h"
36 #include "AliMpSegmentation.h"
37 #include "AliMpVSegmentation.h"
38 #include "AliMpCathodType.h"
39 
40 #include "AliRun.h"
41 #include "AliDCSValue.h"
42 #include "AliLog.h"
43 
44 #include <TMath.h>
45 #include <TRandom.h>
46 #include <TMap.h>
47 #include <iostream>
48 
52 
53 namespace
54 {
55  AliMUON* muon()
56  {
57  return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
58  }
59 
60  void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg, Double_t& xl, Double_t& yl, Double_t& zl)
61  {
62  // ideally should be :
63  // Double_t x,y,z;
64  // AliMUONGeometry::Global2Local(detElemId,xg,yg,zg,x,y,z);
65  // but while waiting for this geometry singleton, let's go through
66  // AliMUON still.
67 
68  const AliMUONGeometryTransformer* transformer = muon()->GetGeometryTransformer();
69  transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
70  }
71 
72 }
73 
74 
75 //------------------------------------------------------------------
76 AliMUONResponseTriggerV1::AliMUONResponseTriggerV1() : AliMUONResponseTrigger(), fGenerCluster(0), fHVvalues(), fBValues(), fWorkCondition(2)
77 {
78 }
79 
80 //------------------------------------------------------------------
82 {
83  //mode: 1=streamer - 2=avalanche
84  SetHV();
85  SetBValues();
86 }
87 
88 //------------------------------------------------------------------
90 {
91 }
92 
93 //------------------------------------------------------------------
95 {
96  // Set the GenerCluster parameter and return 1
97  fGenerCluster = gRandom->Rndm();
98  return 1;
99 }
100 
101 //------------------------------------------------------------------
102 Float_t AliMUONResponseTriggerV1::FireStripProb(Float_t x4,Float_t theta,Int_t rpc,Int_t plane,Int_t cath) const
103 {
107 
108  Float_t hv = fHVvalues.At(18*plane+rpc);
109  Float_t parA, parB, parC;
110 
111  if(fWorkCondition == 2) //avalanche
112  parB = fBValues.At(72*cath+18*plane+rpc);
113  else //streamer
114  parB = 2.966;
115 
116 
117  parA = 6.089 * hv - 52.70;
118  parC = 8.3e-4 * hv - 0.5e-3;
119 
120  return (TMath::Cos(theta)*parA/(parA+TMath::Cos(theta)*TMath::Power(x4*10.,parB))+parC)/(TMath::Cos(theta)+parC);
121 }
122 
123 //------------------------------------------------------------------
124 void AliMUONResponseTriggerV1::DisIntegrate(const AliMUONHit& hit, TList& digits, Float_t /*timeDif*/)
125 {
127 
128  digits.Clear();
129 
130  Float_t xhit = hit.X();
131  Float_t yhit = hit.Y();
132  Float_t zhit = hit.Z();
133  Int_t detElemId = hit.DetElemId();
134  Int_t plane = detElemId/100 - 11; //plane from 0 to 3
135  Int_t rpc = detElemId%100; //rpc from 0 to 3
136 
137  Double_t x,y,z;
138  Global2Local(detElemId,xhit,yhit,zhit,x,y,z);
139 
140  Float_t tof = hit.Age();
141  Int_t twentyNano(100);
143  {
144  twentyNano=1;
145  }
146 
147 
148  Int_t nboard = 0;
149 
150  for(Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath)
151  {
153 
154  AliMpPad pad = seg->PadByPosition(x,y,kFALSE);
155  Int_t ix = pad.GetIx();
156  Int_t iy = pad.GetIy();
157 
158  AliDebug(1,Form("xhit,yhit=%e,%e lx,ly,lz=%e,%e,%e ix,iy=%d,%d",xhit,yhit,x,y,z,ix,iy));
159 
160  if ( !pad.IsValid() )
161  {
162  AliWarning(Form("hit w/o strip %d-%d xhit,yhit=%e,%e local x,y,z ""%e,%e,%e ix,iy=%d,%d",detElemId,cath,xhit,yhit,x,y,z,ix,iy));
163  continue;
164  }
165 
166  if ( cath == AliMp::kCath0 ) nboard = pad.GetLocalBoardId(0);
167 
168  AliMUONDigit* d = new AliMUONDigit(detElemId,nboard,
169  pad.GetLocalBoardChannel(0),
170  cath);
171 
172  d->SetPadXY(ix,iy);
173  d->SetCharge(twentyNano);
174 
175  digits.Add(d);
176 
177  SetGenerCluster(); // 1 randum number per cathode (to be checked)
178 
179  Int_t xList[30], yList[30];
180  Neighbours(cath,ix,iy,xList,yList);
181 
182 
183  Int_t qp = 0; // fired/no-fired strip = 1/0
184  for (Int_t i=0; i<30; i++) // loop on neighbors
185  {
186  if (i==0 || i==15 || qp!=0) // built-up cluster // need to iterate in iy/ix for bending/non-bending plane
187  {
188  Int_t ixNeigh = (cath == 0) ? ix : xList[i];
189  Int_t iyNeigh = (cath == 0) ? yList[i] : iy;
190 
191  AliMpPad padNeigh = seg->PadByIndices(ixNeigh,iyNeigh,kFALSE);
192  if(padNeigh.IsValid()) // existing neighbourg
193  {
194  Int_t dix=-(ixNeigh-ix);
195  Int_t diy=-(iyNeigh-iy);
196  Float_t xlocalNeigh = padNeigh.GetPositionX();
197  Float_t ylocalNeigh = padNeigh.GetPositionY();
198  Float_t dpx = padNeigh.GetDimensionX();
199  Float_t dpy = padNeigh.GetDimensionY();
200  Float_t distX = TMath::Abs((Float_t)dix) * ((Float_t)dix * dpx + xlocalNeigh - x);
201  Float_t distY = TMath::Abs((Float_t)diy) * ((Float_t)diy * dpy + ylocalNeigh - y);
202  Float_t dist = TMath::Sqrt(distX*distX+distY*distY);
203 
204  if(fGenerCluster < FireStripProb(dist,0,rpc,plane,cath))
205  qp = 1;
206  else
207  qp = 0;
208 
209  if(qp == 1)
210  { // this digit is fired
211  AliMUONDigit* dNeigh = new AliMUONDigit(detElemId,padNeigh.GetLocalBoardId(0),padNeigh.GetLocalBoardChannel(0),cath);
212 
213  dNeigh->SetPadXY(ixNeigh,iyNeigh);
214  dNeigh->SetCharge(twentyNano);
215  digits.Add(dNeigh);
216  } // digit fired
217  } // pad is valid
218  } // built-up cluster
219  } // loop on neighbors
220  } // loop on cathode
221 }
222 
223 //------------------------------------------------------------------
225 {
226  //
228  //
229  fHVvalues.Set(72);
230  TString side;
231  Int_t newRPC=0,newPlane=0;
232 
234  AliCDBPath path("MUON/Calib/TriggerDCS");
235  AliCDBEntry *entry = manager->Get(path);
236  if (entry == NULL) {
237  AliWarning("No map found in MUON/Calib/TriggerDCS");
238  return;
239  }
240  TMap *hvMap = dynamic_cast<TMap*>(entry->GetObject());
241  TObjArray *objArr = 0x0;
242 
243  AliDCSValue *dcsValue = 0x0;
244  UInt_t time1,time2,timebegin=0,timeend=0;
245  Int_t nEntries;
246  Float_t voltage = 0;
247 
248  for(Int_t iPlane=0; iPlane<4; iPlane++) //loop on MT
249  {
250  for(Int_t iRPC=0; iRPC<18; iRPC++) //loop on RPC
251  {
252  if(iRPC>=5 && iRPC<=13)
253  {
254  side = "OUTSIDE";
255  newRPC = 14-iRPC;
256  }
257 
258  else
259  {
260  side = "INSIDE";
261 
262  if(iRPC>=14)
263  newRPC = iRPC-13;
264  else
265  newRPC = iRPC+5;
266  }
267 
268  switch(iPlane)
269  {
270  case 0: newPlane = 11; break;
271  case 1: newPlane = 12; break;
272  case 2: newPlane = 21; break;
273  case 3: newPlane = 22; break;
274  }
275 
276  objArr = (TObjArray*)hvMap->GetValue(Form("MTR_%s_MT%d_RPC%d_HV.vEff",side.Data(),newPlane,newRPC));
277  nEntries = objArr->GetEntries();
278 
279  for(Int_t i=0; i<nEntries-1; i++)
280  {
281  dcsValue = (AliDCSValue*)objArr->At(i+1);
282  time2 = dcsValue->GetTimeStamp();
283 
284  if(i==nEntries-2)
285  timeend = time2;
286 
287  dcsValue = (AliDCSValue*)objArr->At(i);
288  time1 = dcsValue->GetTimeStamp();
289 
290  if(i==0)
291  timebegin = time1;
292 
293  voltage += (dcsValue->GetFloat())*(time2-time1);
294  }
295 
296  Double_t deltaTime = timeend - timebegin;
297  Double_t meanVoltage = ( deltaTime == 0. ) ? 0. : voltage/deltaTime/1000.;
298  fHVvalues.AddAt(meanVoltage,18*iPlane+iRPC); //voltage in kV, not in V
299 
300  voltage=0;
301  AliDebug(1,Form("HV value for MTR_%s_MT%d_RPC%d_HV.vEff = %g (kV)",side.Data(),newPlane,newRPC,meanVoltage));
302  }
303  }
304 }
305 
306 //------------------------------------------------------------------
308 {
309  //
311  //
312 
313  fBValues.Set(144);
314 
315  Float_t bValues[2][4][18] = {{{1.97,2.47,2.47,2.47,2.97,2.97,2.47,2.47,1.97,2.22,1.97,2.47,1.97,2.97,2.97,2.47,2.47,1.97}, //MT11BP
316  {2.22,2.22,1.97,2.47,2.97,2.97,1.97,2.47,1.97,1.97,1.97,2.47,1.97,2.97,2.97,1.97,1.97,1.97}, //MT12BP
317  {2.22,2.22,2.47,2.47,2.97,2.97,2.47,2.47,2.22,1.97,1.97,2.47,1.97,2.97,2.97,1.97,1.97,1.97}, //MT21BP
318  {1.97,1.97,2.97,2.97,2.97,2.97,2.47,1.97,1.97,1.97,1.72,2.47,2.22,2.97,2.97,1.97,1.97,1.97}}, //MT22BP
319  {{1.97,2.47,2.47,2.97,2.97,2.97,2.97,2.47,1.97,1.97,2.22,2.47,2.97,2.97,2.97,2.97,1.97,1.72}, //MT11NBP
320  {2.47,1.97,2.22,2.97,2.97,2.97,2.47,2.97,1.97,1.97,1.97,2.97,2.97,2.97,2.97,2.97,1.97,1.97}, //MT12NBP
321  {1.97,2.47,2.47,2.97,2.97,2.97,2.97,2.47,2.22,1.97,2.22,2.47,2.97,2.97,2.97,2.47,1.97,1.97}, //MT21NBP
322  {1.72,1.97,2.97,2.97,2.97,2.97,2.97,1.97,1.72,2.22,1.97,2.47,2.97,2.47,2.97,1.97,1.97,1.97}}};//MT22NBP
323 
324  for(Int_t iCath=0; iCath<2; iCath++) //loop on side
325  {
326  for(Int_t iPlane=0; iPlane<4; iPlane++) //loop on MT
327  {
328  for(Int_t iRPC=0; iRPC<18; iRPC++) //loop on RPC
329  {
330  fBValues.AddAt(bValues[iCath][iPlane][iRPC],72*iCath+18*iPlane+iRPC);
331  }
332  }
333  }
334 }
335 
336 //------------------------------------------------------------------
337 void AliMUONResponseTriggerV1::Neighbours(const Int_t cath, const Int_t ix, const Int_t iy, Int_t Xlist[30], Int_t Ylist[30]) const
338 {
358 
359  for (Int_t i=0; i<30; i++)
360  {
361  Xlist[i] = -1;
362  Ylist[i] = -1;
363  }
364 
365  Int_t iList[30]={29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14};
366 
367  // need to iterate in iy/ix for bending/non-bending plane
368  Int_t iNeigh = (cath == 0) ? iy : ix;
369 
370  Int_t i=0;
371  for (Int_t j=iNeigh-15; j<=iNeigh+15; j++)
372  {
373  if (j == iNeigh)
374  continue;
375 
376  // need to iterate in iy/ix for bending/non-bending plane
377  Int_t ixNeigh = ( cath == 0 ) ? ix : j;
378  Int_t iyNeigh = ( cath == 0 ) ? j : iy;
379 
380 // cout << " " << cath << " " << ix << " " << iy
381 // << " " << ixNeigh << " " << iyNeigh << "\n";
382 
383  Xlist[iList[i]]=ixNeigh;
384  Ylist[iList[i]]=iyNeigh;
385  i++;
386  }
387 }
const AliMpVSegmentation * GetMpSegmentation(Int_t detElemId, AliMp::CathodType cath, Bool_t warn=true) const
static AliMpSegmentation * Instance(Bool_t warn=true)
#define TObjArray
Int_t GetIy() const
Definition: AliMpPad.cxx:280
Top container class for geometry transformations.
const char * path
void Global2Local(Int_t detElemId, Double_t xg, Double_t yg, Double_t zg, Double_t &xl, Double_t &yl, Double_t &zl)
Float_t Age() const
Return Particle Age.
Definition: AliMUONHit.h:53
AliDetector class for MUON subsystem providing simulation data management.
Definition: AliMUON.h:37
Float_t Z() const
Definition: AliHit.h:23
Float_t GetFloat() const
virtual AliMpPad PadByIndices(Int_t ix, Int_t iy, Bool_t warning=true) const =0
Find pad by indices.
#define AliWarning(message)
Definition: AliLog.h:541
virtual void DisIntegrate(const AliMUONHit &hit, TList &digits, Float_t timeDif)
Float_t X() const
Definition: AliHit.h:21
void Neighbours(const Int_t cath, const Int_t iX, const Int_t iY, Int_t Xlist[30], Int_t Ylist[30]) const
AliCDBEntry * Get(const AliCDBId &query, Bool_t forceCaching=kFALSE)
Float_t Y() const
Definition: AliHit.h:22
TObject * GetObject()
Definition: AliCDBEntry.h:56
virtual void SetPadXY(Int_t padx, Int_t pady)
Set pad number along x.
Definition: AliMUONDigit.h:66
Implementation of RPC response.
Float_t fGenerCluster
Random number.
AliModule * GetModule(const char *name) const
Definition: AliRun.cxx:191
Implementation of RPC response.
MUON digit.
Definition: AliMUONDigit.h:17
Double_t GetPositionY() const
Return the pad x position (in cm)
Definition: AliMpPad.h:81
virtual Int_t SetGenerCluster()
Set the GenerCluster parameter.
const AliMUONGeometryTransformer * GetGeometryTransformer() const
Definition: AliMUON.cxx:243
virtual void SetCharge(Float_t q)
Set charge.
Definition: AliMUONDigit.h:67
AliMp::CathodType GetCathodType(Int_t cathodNumber)
Convert integer number in enum;.
AliRun * gAlice
Definition: AliRun.cxx:62
Int_t GetLocalBoardId(Int_t i) const
Definition: AliMpPad.cxx:347
TArrayF fHVvalues
Array containing HV values.
Definition: AliCDBEntry.h:18
Int_t DetElemId() const
Return detection element ID.
Definition: AliMUONHit.h:43
Bool_t IsValid() const
Return validity.
Definition: AliMpPad.h:89
virtual AliMpPad PadByPosition(Double_t x, Double_t y, Bool_t warning=true) const =0
Find pad by position.
#define AliDebug(logLevel, message)
Definition: AliLog.h:300
void Global2Local(Int_t detElemId, Float_t xg, Float_t yg, Float_t zg, Float_t &xl, Float_t &yl, Float_t &zl) const
Int_t GetIx() const
Definition: AliMpPad.cxx:272
AliMUON * muon()
The abstract base class for the segmentation.
MonteCarlo hit.
Definition: AliMUONHit.h:24
Double_t GetDimensionY() const
Return the y pad dimension - half length (in cm)
Definition: AliMpPad.h:86
UInt_t GetTimeStamp() const
Definition: AliDCSValue.h:55
Class which encapsuate all information about a pad.
Definition: AliMpPad.h:22
TArrayF fBValues
Array containing b parameters.
Double_t GetPositionX() const
Return the pad x position (in cm)
Definition: AliMpPad.h:79
static AliCDBManager * Instance(TMap *entryCache=NULL, Int_t run=-1)
static Float_t TriggerTofLimit()
Return Trigger ToF Limit (75 ns)
Int_t fWorkCondition
1=streamer - 2=avalanche
Int_t GetLocalBoardChannel(Int_t i) const
Definition: AliMpPad.cxx:358
Double_t GetDimensionX() const
Return the x pad dimension - half length (in cm)
Definition: AliMpPad.h:84
Float_t FireStripProb(Float_t x4, Float_t theta, Int_t rpc, Int_t plane, Int_t cath) const