AliRoot Core  edcc906 (edcc906)
AliEMCALTriggerPatchInfo.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2013, 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  **************************************************************************/
16 #include "AliLog.h"
17 #include "AliEMCALGeometry.h"
18 #include "TArrayI.h"
19 #include "TMath.h"
20 
24 
26  TObject(),
27  fCenterGeo(),
28  fCenterMass(),
29  fEdge1(),
30  fEdge2(),
31  fADCAmp(0),
32  fADCOfflineAmp(0),
33  fEnergySmeared(0),
34  fTriggerBits(0),
35  fOffSet(0), // To be set explicitly by the trigger maker in order to avoid hard coding
36  fRow0(-1),
37  fCol0(-1),
38  fPatchSize(0),
39  fDetectorType(kEMCALdet),
40  fTriggerBitConfig()
41 {
42  fEdgeCell[0] = -1;
43  fEdgeCell[1] = -1;
44 }
45 
47  TObject(p),
48  fCenterGeo(p.fCenterGeo),
49  fCenterMass(p.fCenterMass),
50  fEdge1(p.fEdge1),
51  fEdge2(p.fEdge2),
52  fADCAmp(p.fADCAmp),
53  fADCOfflineAmp(p.fADCOfflineAmp),
54  fEnergySmeared(p.fEnergySmeared),
55  fTriggerBits(p.fTriggerBits),
56  fOffSet(p.fOffSet),
57  fRow0(p.fRow0),
58  fCol0(p.fCol0),
59  fPatchSize(p.fPatchSize),
60  fDetectorType(p.fDetectorType),
61  fTriggerBitConfig(p.fTriggerBitConfig)
62 {
63  // .
64  fEdgeCell[0] = p.fEdgeCell[0];
65  fEdgeCell[1] = p.fEdgeCell[1];
66 }
67 
69 {
70 }
71 
73 {
74  if (this != &p) {
75  new (this) AliEMCALTriggerPatchInfo(p);
76  }
77 
78  return *this;
79 }
80 
82 {
83  new (this) AliEMCALTriggerPatchInfo();
84 }
85 
86 void AliEMCALTriggerPatchInfo::Initialize(UChar_t col0, UChar_t row0, UChar_t size, UInt_t adc, UInt_t offlineAdc, Double_t patchE, UInt_t bitmask, const TVector3& vertex, const AliEMCALGeometry* geom)
87 {
88  fCol0 = col0;
89  fRow0 = row0;
90  fPatchSize = size;
91  fADCAmp = adc;
92  fADCOfflineAmp = offlineAdc;
93  fTriggerBits = bitmask;
94  SetEdgeCell(col0*2, row0*2);
95 
96  if (geom) {
97  Int_t absId=-1;
99  Int_t iSM = -1, iEta = -1, iPhi = -1;
100  geom->GetPositionInSMFromAbsFastORIndex(absId, iSM, iEta, iPhi);
101  if (geom->IsDCALSM(iSM)) {
103  }
104  else {
106  }
107  }
108  RecalculateKinematics(patchE, vertex, geom);
109 }
110 
111 void AliEMCALTriggerPatchInfo::Initialize(UChar_t col0, UChar_t row0, UChar_t size, UInt_t adc, UInt_t offlineAdc, UInt_t bitmask, const AliEMCALGeometry* geom)
112 {
113  fCol0 = col0;
114  fRow0 = row0;
115  fPatchSize = size;
116  fADCAmp = adc;
117  fADCOfflineAmp = offlineAdc;
118  fTriggerBits = bitmask;
119  SetEdgeCell(col0*2, row0*2);
120 
121  if (geom) {
122  Int_t absId=-1;
124  Int_t iSM = -1, iEta = -1, iPhi = -1;
125  geom->GetPositionInSMFromAbsFastORIndex(absId, iSM, iEta, iPhi);
126  if (geom->IsDCALSM(iSM)) {
128  }
129  else {
131  }
132  }
133 }
134 
135 AliEMCALTriggerPatchInfo* AliEMCALTriggerPatchInfo::CreateAndInitialize(UChar_t col0, UChar_t row0, UChar_t size, UInt_t adc, UInt_t offlineAdc, Double_t patchE, UInt_t bitmask, const TVector3& vertex, const AliEMCALGeometry* geom)
136 {
138  patch->Initialize(col0, row0, size, adc, offlineAdc, patchE, bitmask, vertex, geom);
139  return patch;
140 }
141 
142 AliEMCALTriggerPatchInfo* AliEMCALTriggerPatchInfo::CreateAndInitialize(UChar_t col0, UChar_t row0, UChar_t size, UInt_t adc, UInt_t offlineAdc, UInt_t bitmask, const AliEMCALGeometry* geom)
143 {
145  patch->Initialize(col0, row0, size, adc, offlineAdc, bitmask, geom);
146  return patch;
147 }
148 
149 void AliEMCALTriggerPatchInfo::RecalculateKinematics(Double_t patchE, const TVector3& vertex, const AliEMCALGeometry* geom)
150 {
151  if (!geom) {
152  AliError("EMCal geometry pointer not set! Unable to recalculate the trigger patch kinematics!");
153  return;
154  }
155 
156  // get the absolute trigger ID
157  Int_t absId=-1;
159  // convert to the 4 absId of the cells composing the trigger channel
160  Int_t cellAbsId[4]={-1,-1,-1,-1};
161  geom->GetCellIndexFromFastORIndex(absId, cellAbsId);
162  if(cellAbsId[0] < 0 || cellAbsId[1] < 0 || cellAbsId[2] < 0 || cellAbsId[3] < 0){
163  AliWarning(Form("Invalid cell ID [%d|%d|%d|%d]\n", cellAbsId[0], cellAbsId[1], cellAbsId[2], cellAbsId[3]));
164  }
165 
166  // get low left edge (eta max, phi min)
167  TVector3 edge1;
168  geom->GetGlobal(cellAbsId[0], edge1);
169  Int_t colEdge1 = fCol0, rowEdge1 = fRow0, absIdEdge1 = absId, cellIdEdge1 = cellAbsId[0]; // Used in warning for invalid patch position
170 
171  // get up right edge (eta min, phi max)
172  // get the absolute trigger ID
173  Int_t posOffset = fPatchSize - 1;
174 
175  geom->GetAbsFastORIndexFromPositionInEMCAL(fCol0+posOffset, fRow0+posOffset, absId);
176  geom->GetCellIndexFromFastORIndex(absId, cellAbsId);
177  TVector3 edge2;
178  geom->GetGlobal(cellAbsId[3], edge2);
179  Int_t colEdge2 = fCol0+posOffset, rowEdge2 = fRow0+posOffset, absIdEdge2 = absId, cellIdEdge2 = cellAbsId[3]; // Used in warning for invalid patch position
180 
181  // get the geometrical center as an average of two diagonally
182  // adjacent patches in the center
183  // picking two diagonally closest cells from the patches
184  posOffset = fPatchSize / 2 - 1;
185 
186  geom->GetAbsFastORIndexFromPositionInEMCAL(fCol0+posOffset, fRow0+posOffset, absId);
187  geom->GetCellIndexFromFastORIndex(absId, cellAbsId);
188  TVector3 center1;
189  geom->GetGlobal(cellAbsId[3], center1);
190 
191  posOffset = fPatchSize / 2;
192 
193  geom->GetAbsFastORIndexFromPositionInEMCAL(fCol0+posOffset, fRow0+posOffset, absId);
194  geom->GetCellIndexFromFastORIndex(absId, cellAbsId);
195  TVector3 center2;
196  geom->GetGlobal(cellAbsId[0], center2);
197 
198  TVector3 centerGeo(center1);
199  centerGeo += center2;
200  centerGeo *= 0.5;
201 
202  // relate all to primary vertex
203  TVector3 edge1tmp = edge1, edge2tmp = edge2; // Used in warning for invalid patch position
204  centerGeo -= vertex;
205  edge1 -= vertex;
206  edge2 -= vertex;
207  // Check for invalid patch positions
208  if(!(edge1[0] || edge1[1] || edge1[2])){
209  AliWarning(Form("Inconsistency in patch position for edge1: [%f|%f|%f]", edge1[0], edge1[1], edge1[2]));
210  AliWarning("Original vectors:");
211  AliWarning(Form("edge1: [%f|%f|%f]", edge1tmp[0], edge1tmp[1], edge1tmp[2]));
212  AliWarning(Form("vertex: [%f|%f|%f]", vertex[0], vertex[1], vertex[2]));
213  AliWarning(Form("Col: %d, Row: %d, FABSID: %d, Cell: %d", colEdge1, rowEdge1, absIdEdge1, cellIdEdge1));
214  }
215  if(!(edge2[0] || edge2[1] || edge2[2])){
216  AliWarning(Form("Inconsistency in patch position for edge2: [%f|%f|%f]", edge2[0], edge2[1], edge2[2]));
217  AliWarning("Original vectors:");
218  AliWarning(Form("edge2: [%f|%f|%f]", edge2tmp[0], edge2tmp[1], edge2tmp[2]));
219  AliWarning(Form("vertex: [%f|%f|%f]", vertex[0], vertex[1], vertex[2]));
220  AliWarning(Form("Col: %d, Row: %d, FABSID: %d, Cell: %d", colEdge2, rowEdge2, absIdEdge2, cellIdEdge2));
221  }
222 
223  fCenterMass.SetPxPyPzE(0,0,0,0);
224 
225  SetCenterGeo(centerGeo, patchE);
226  SetEdge1(edge1, patchE);
227  SetEdge2(edge2, patchE);
228 }
229 
231 
232  Int_t globCol, globRow, i, j, k, absId, cellAbsId[4];;
233 
234  cells->Set( 1024 );
235 
236  // get corner, convert from cells to trigger channels
237  globCol = GetEdgeCellX() / 2;
238  globRow = GetEdgeCellY() / 2;
239 
240  // get the absolute trigger ID
241  geom->GetAbsFastORIndexFromPositionInEMCAL( globCol, globRow, absId );
242  // convert to the 4 absId of the cells composing the trigger channel
243  geom->GetCellIndexFromFastORIndex( absId, cellAbsId );
244 
245  // sum the available energy in the 32/32 window of cells
246  // step over trigger channels and get all the corresponding cells
247  for( i = 0; i < 16; i++ ){
248  for( j = 0; j < 16; j++ ){
249  // get the 4 cells composing the trigger channel
250  geom->GetAbsFastORIndexFromPositionInEMCAL( globCol+i, globRow+j, absId );
251  geom->GetCellIndexFromFastORIndex( absId, cellAbsId );
252  // add amplitudes and find patch edges
253  for( k = 0; k < 4; k++ ){
254  cells->SetAt( cellAbsId[k], i*16*4+j*4+k );
255  }
256  }
257  } // 32x32 cell window
258 
259 
260 }
261 
262 void AliEMCALTriggerPatchInfo::SetLorentzVector( TLorentzVector &lv, const TVector3 &v, Double_t e ){
263  // sets the vector
264  Double_t r = TMath::Sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2] ) ;
265 
266  lv.SetPxPyPzE( e*v[0]/r, e*v[1]/r, e*v[2]/r, e) ;
267 }
268 
269 Double_t AliEMCALTriggerPatchInfo::GetPhiTransform(Double_t phiin) const{
270  if(phiin < 0) return phiin + TMath::TwoPi();
271  return phiin;
272 }
273 
274 Double_t AliEMCALTriggerPatchInfo::GetET(Double_t energy) const {
275  TLorentzVector en(fCenterGeo.Px(), fCenterGeo.Py(), fCenterGeo.Pz(), energy);
276  return en.Et();
277 }
UChar_t fPatchSize
Trigger patch size.
static AliEMCALTriggerPatchInfo * CreateAndInitialize(UChar_t col0, UChar_t row0, UChar_t size, UInt_t adc, UInt_t offlineAdc, Double_t patchE, UInt_t bitmask, const TVector3 &vertex, const AliEMCALGeometry *geom)
void SetEdgeCell(Int_t x, Int_t y)
Int_t fADCOfflineAmp
offline (FEE) ADC amplitude
void GetCellIndices(AliEMCALGeometry *geom, TArrayI *cells)
TLorentzVector fCenterGeo
geometrical center
void SetEdge1(const TLorentzVector &v)
Float_t p[]
Definition: kNNTest.C:133
Bool_t GetPositionInSMFromAbsFastORIndex(const Int_t id, Int_t &iSM, Int_t &iEta, Int_t &iPhi) const
#define AliWarning(message)
Definition: AliLog.h:541
void SetCenterGeo(const TVector3 &v, Double_t e)
void SetEdge2(const TLorentzVector &v)
AliEMCALTriggerPatchInfo & operator=(const AliEMCALTriggerPatchInfo &p)
void Initialize(UChar_t col0, UChar_t row0, UChar_t size, UInt_t adc, UInt_t offlineAdc, Double_t patchE, UInt_t bitmask, const TVector3 &vertex, const AliEMCALGeometry *geom)
void GetGlobal(const Double_t *loc, Double_t *glob, int ind) const
void RecalculateKinematics(Double_t patchE, const TVector3 &vertex, const AliEMCALGeometry *geom)
Double_t GetET(Double_t energy) const
Int_t fADCAmp
online (trigger) ADC amplitude
Main data structure storing all relevant information of EMCAL/DCAL trigger patches.
void SetLorentzVector(TLorentzVector &lv, const TVector3 &v, Double_t e)
Bool_t GetCellIndexFromFastORIndex(const Int_t id, Int_t idx[4]) const
Int_t fTriggerBits
trigger bit mask, see definitions in AliEMCALTriggerType and TriggerMakerBits_t (above) ...
void SetDetectorType(CaloDetectorType_t t)
Bool_t GetAbsFastORIndexFromPositionInEMCAL(const Int_t iEta, const Int_t iPhi, Int_t &id) const
Bool_t IsDCALSM(Int_t nSupMod) const
Double_t GetPhiTransform(Double_t phiin) const
Int_t fEdgeCell[2]
cell "bottom lower" edge (min phi, max eta)
#define AliError(message)
Definition: AliLog.h:591
TEveGeoShape * geom
Definition: tpc_tracks.C:10
EMCal geometry, singleton.