FairRoot/PandaRoot
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
PndSdsCalcPixel Class Reference

Calculates the pixels (digis) fired from a particle hitting the sensor. More...

#include <PndSdsCalcPixel.h>

Public Member Functions

 PndSdsCalcPixel ()
 Default constructor. More...
 
 PndSdsCalcPixel (Double_t w, Double_t l, Double_t threshold=0, Double_t noise=0)
 
std::vector< PndSdsPixelGetPixels (Double_t inx, Double_t iny, Double_t outx, Double_t outy, Double_t energy)
 Main function to calculate the vector<PndSdsPixel> of fired pixel. More...
 
Int_t GetPixelsAlternative (Double_t inx, Double_t iny, Double_t outx, Double_t outy, Double_t energy, std::vector< Int_t > &cols, std::vector< Int_t > &rows, std::vector< Double_t > &charges)
 
void SetVerboseLevel (Int_t level)
 
std::ostreamoperator<< (std::ostream &out)
 

Private Types

enum  EQuadrantType {
  kQuadUNDEF, kUR, kUL, kDL,
  kDR
}
 
enum  ENextPixelType {
  kPixelUNDEF, kU, kD, kL,
  kR
}
 

Private Member Functions

void CalcConMatrix ()
 
void ApplyConMatrix ()
 
void CalcQuadrant ()
 
void CalcCperL (Double_t Energy)
 
void CalcStartPixel ()
 
void CalcPixel ()
 
void ConvertPixels ()
 
Double_t SmearCharge (Double_t charge)
 

Private Attributes

std::vector< PndSdsPixelfPixels
 
Double_t fPixelWidth
 
Double_t fPixelLength
 
Double_t fThreshold
 
Double_t fNoise
 
Double_t fEnergy
 
Int_t fVerboseLevel
 
EQuadrantType fQuad
 
ENextPixelType fNextPixel
 
FairGeoVector fIn
 
FairGeoVector fOut
 
FairGeoVector fDir
 
FairGeoVector fPos
 
FairGeoVector fCon
 
PndSdsPixel fActivePixel
 
Double_t fCperL
 
bool fStop
 

Detailed Description

Calculates the pixels (digis) fired from a particle hitting the sensor.

Author
Tobias Stockmanns t.sto.nosp@m.ckma.nosp@m.nns@f.nosp@m.z-ju.nosp@m.elich.nosp@m..de This class gets as an input the point where the particle enters the sensor, where it leaves the sensor and the deposited energy. It calculates the track of the particle between these two points and determines the pixels lying on the track. The total energy of the particle is then distributed acording to the pathlength to the pixels. The output is a vector<PndSdsPixel> of the fired sensor pixels with the energy deposited in the pixels. If a noise value is given a gausian distributed energy with a sigma of (noise) is added (or substracted) to the energy deposited in one pixel. If a threshold value is given all pixels with energies below threshold are ignored

Definition at line 23 of file PndSdsCalcPixel.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

PndSdsCalcPixel::PndSdsCalcPixel ( )

Default constructor.

Definition at line 6 of file PndSdsCalcPixel.cxx.

6  :
7  fPixels(),
8  fPixelWidth(0.),
9  fPixelLength(0.),
10  fThreshold(0.),
11  fNoise(0.),
12  fEnergy(0.),
13  fVerboseLevel(0),
16  fIn(),
17  fOut(),
18  fDir(),
19  fPos(),
20  fCon(),
21  fActivePixel(),
22  fCperL(-1),
23  fStop(false)
24 {
25 }
EQuadrantType fQuad
FairGeoVector fDir
FairGeoVector fOut
FairGeoVector fCon
std::vector< PndSdsPixel > fPixels
Double_t fPixelWidth
FairGeoVector fIn
ENextPixelType fNextPixel
PndSdsPixel fActivePixel
FairGeoVector fPos
Double_t fPixelLength
PndSdsCalcPixel::PndSdsCalcPixel ( Double_t  w,
Double_t  l,
Double_t  threshold = 0,
Double_t  noise = 0 
)

Main constructor

Parameters
wwidth of sensor pixel [cm]
llength of sensor pixel [cm]
thresholddiscriminator threshold of pixel [e]
noisetotal noise of pixel [e]

Definition at line 27 of file PndSdsCalcPixel.cxx.

27  :
28  fPixels(),
29  fPixelWidth(w),
30  fPixelLength(l),
32  fNoise(noise),
33  fEnergy(0.),
34  fVerboseLevel(0),
37  fIn(),
38  fOut(),
39  fDir(),
40  fPos(),
41  fCon(),
42  fActivePixel(),
43  fCperL(-1),
44  fStop(false)
45 {}
EQuadrantType fQuad
FairGeoVector fDir
FairGeoVector fOut
FairGeoVector fCon
std::vector< PndSdsPixel > fPixels
Double_t fPixelWidth
FairGeoVector fIn
double threshold
ENextPixelType fNextPixel
PndSdsPixel fActivePixel
double noise
FairGeoVector fPos
Double_t fPixelLength

Member Function Documentation

void PndSdsCalcPixel::ApplyConMatrix ( )
private

Definition at line 121 of file PndSdsCalcPixel.cxx.

References fCon, fDir, fIn, fOut, and fPos.

122 {
123  fIn.setX(fCon.getX() * fIn.getX());
124  fIn.setY(fCon.getY() * fIn.getY());
125 
126  fOut.setX(fCon.getX() * fOut.getX());
127  fOut.setY(fCon.getY() * fOut.getY());
128 
129  fPos.setX(fCon.getX() * fPos.getX());
130  fPos.setY(fCon.getY() * fPos.getY());
131 
132  fDir.setX(fCon.getX() * fDir.getX());
133  fDir.setY(fCon.getY() * fDir.getY());
134 
135 }
FairGeoVector fDir
FairGeoVector fOut
FairGeoVector fCon
FairGeoVector fIn
FairGeoVector fPos
void PndSdsCalcPixel::CalcConMatrix ( )
private

Definition at line 111 of file PndSdsCalcPixel.cxx.

References fCon, and fIn.

112 {
113  if (fIn.getX() < 0)
114  fCon.setX(-1);
115  else fCon.setX(1);
116  if (fIn.getY() < 0)
117  fCon.setY(-1);
118  else fCon.setY(1);
119 }
FairGeoVector fCon
FairGeoVector fIn
void PndSdsCalcPixel::CalcCperL ( Double_t  Energy)
private

Definition at line 154 of file PndSdsCalcPixel.cxx.

References Double_t, fCperL, and fDir.

Referenced by GetPixels().

155 {
156  Double_t Charge = Energy / (3.61e-9);
157  fCperL = Charge / fDir.length();
158 }
FairGeoVector fDir
Double_t
void PndSdsCalcPixel::CalcPixel ( )
private

Definition at line 168 of file PndSdsCalcPixel.cxx.

References Double_t, fabs(), fActivePixel, fCperL, fDir, fNextPixel, fOut, fPixelLength, fPixels, fPixelWidth, fPos, fQuad, fStop, fThreshold, fVerboseLevel, PndSdsPixel::GetCol(), PndSdsPixel::GetRow(), kD, kDL, kDR, kL, kQuadUNDEF, kR, kU, kUL, kUR, printf(), PndSdsPixel::SetCharge(), and SmearCharge().

Referenced by GetPixels().

169 {
170  Double_t borderX = 0;
171  Double_t borderY = 0;
172  FairGeoVector OutPoint;
173  bool xBeforeY = false;
174 
175  /* if ( fabs(fDir.getX()) < 1e-8 ) {
176  xBeforeY = false;
177  borderY = fPixelWidth * (fActivePixel.GetRow()+1);
178  }
179  else if ( fabs(fDir.getY()) < 1e-8 ) {
180  xBeforeY = true;
181  borderX = fPixelWidth
182  }
183  else switch (fQuad){
184  */
185  switch (fQuad){
186  case kUR : borderX = fPixelLength * (fActivePixel.GetCol()+1);
187  borderY = fPixelWidth * (fActivePixel.GetRow()+1);
188  if ( fabs(fDir.getX()) < 1e-8 ) xBeforeY = false;
189  else if ( ( (borderX - fPos.getX()) * fDir.getY() / fDir.getX() )+fPos.getY() < borderY)
190  xBeforeY = true;
191  else xBeforeY = false;
192  break;
193  case kUL : borderX = fPixelLength * (fActivePixel.GetCol());
194  borderY = fPixelWidth * (fActivePixel.GetRow()+1);
195  if ( fabs(fDir.getX()) < 1e-8 ) xBeforeY = false;
196  else if ( ( (borderX - fPos.getX()) * fDir.getY() / fDir.getX() )+fPos.getY() < borderY)
197  xBeforeY = true;
198  else xBeforeY = false;
199  break;
200  case kDL : borderX = fPixelLength * (fActivePixel.GetCol());
201  borderY = fPixelWidth * (fActivePixel.GetRow());
202  if ( fabs(fDir.getX()) < 1e-8 ) xBeforeY = false;
203  else if ( ( (borderX - fPos.getX()) * fDir.getY() / fDir.getX() )+fPos.getY() > borderY)
204  xBeforeY = true;
205  else xBeforeY = false;
206  break;
207  case kDR : borderX = fPixelLength * (fActivePixel.GetCol()+1);
208  borderY = fPixelWidth * (fActivePixel.GetRow());
209  if ( fabs(fDir.getX()) < 1e-8 ) xBeforeY = false;
210  else if ( ( (borderX - fPos.getX()) * fDir.getY() / fDir.getX() )+fPos.getY() > borderY)
211  xBeforeY = true;
212  else xBeforeY = false;
213  break;
214  case kQuadUNDEF : std::cout<<"PndSdsCalcPixel::CalcPixel : Quadrant not defined!"<<std::endl;
215  //default : ErrMsg(fatal) << " Quadrant not defined! " << endmsg;
216  }
217 
218  if ( xBeforeY ) { //Is borderX reached berfore borderY
219  OutPoint.setXYZ(borderX, ((borderX-fPos.getX())*fDir.getY()/fDir.getX())+fPos.getY(),0);
220 
221  if (fQuad == kUR || fQuad == kDR)
222  fNextPixel = kR;
223  else fNextPixel = kL;
224  }
225  else {
226  OutPoint.setXYZ(((borderY-fPos.getY())*fDir.getX()/fDir.getY())+fPos.getX(), borderY,0);
227 
228  if (fQuad == kUR || fQuad == kUL)
229  fNextPixel = kU;
230  else fNextPixel = kD;
231  }
232  // ErrMsg(warning) << " OutPoint: " << OutPoint << endmsg;
233 
234 
235  if ((OutPoint - fPos).length() > (fOut - fPos).length()){
236  fStop = true;
237  OutPoint = fOut;
238  }
239 
240 
241  Double_t depCharge = (OutPoint - fPos).length() * fCperL;
242  if (fVerboseLevel > 1){
243  printf("len: %g, cperL: %g, depCharge w/o noise: %g\n",(OutPoint - fPos).length(),fCperL,depCharge);
244  }
245 
246  // noise smearing and discriminator threshold cut
247  Double_t smearedCharge = SmearCharge(depCharge);
248  if (smearedCharge<=fThreshold) return;
249 
250  fPos = OutPoint;
251  fActivePixel.SetCharge(smearedCharge);
252 
253 
254  fPixels.push_back(fActivePixel);
255 
256  if (fVerboseLevel > 1){
257  std::cout << fActivePixel << std::endl;
258  }
259 
260 }
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
EQuadrantType fQuad
FairGeoVector fDir
FairGeoVector fOut
Int_t GetCol() const
Definition: PndSdsPixel.h:41
Double_t SmearCharge(Double_t charge)
Int_t GetRow() const
Definition: PndSdsPixel.h:42
std::vector< PndSdsPixel > fPixels
void SetCharge(Double_t charge)
Definition: PndSdsPixel.h:36
Double_t
Double_t fPixelWidth
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
ENextPixelType fNextPixel
PndSdsPixel fActivePixel
FairGeoVector fPos
Double_t fPixelLength
void PndSdsCalcPixel::CalcQuadrant ( )
private

Definition at line 137 of file PndSdsCalcPixel.cxx.

References fDir, fQuad, fVerboseLevel, kDL, kDR, kUL, and kUR.

Referenced by GetPixels().

138 {
139  if (fDir.getX() > 0)
140  if (fDir.getY() > 0)
141  fQuad = kUR;
142  else
143  fQuad = kDR;
144  else if (fDir.getY() > 0)
145  fQuad = kUL;
146  else
147  fQuad = kDL;
148 
149  if (fVerboseLevel > 1){
150  std::cout << "CalcQuadrant: " << fQuad << std::endl;
151  }
152 }
EQuadrantType fQuad
FairGeoVector fDir
void PndSdsCalcPixel::CalcStartPixel ( )
private

Definition at line 160 of file PndSdsCalcPixel.cxx.

References col, fActivePixel, fIn, fPixelLength, fPixelWidth, row, PndSdsPixel::SetCol(), and PndSdsPixel::SetRow().

Referenced by GetPixels().

161 {
162  Int_t col = Int_t(fIn.getX() / fPixelLength);
163  Int_t row = Int_t(fIn.getY() / fPixelWidth);
164  fActivePixel.SetCol(col);
165  fActivePixel.SetRow(row);
166 }
int row
Definition: anaLmdDigi.C:67
int col
Definition: anaLmdDigi.C:67
void SetCol(Int_t col)
Definition: PndSdsPixel.h:34
Double_t fPixelWidth
FairGeoVector fIn
void SetRow(Int_t row)
Definition: PndSdsPixel.h:35
PndSdsPixel fActivePixel
Double_t fPixelLength
void PndSdsCalcPixel::ConvertPixels ( )
private

Definition at line 262 of file PndSdsCalcPixel.cxx.

References col, fCon, fPixels, i, and row.

263 {
264  Int_t col, row;
265  for (UInt_t i = 0; i < fPixels.size(); i++){
266  col = fPixels[i].GetCol();
267  row = fPixels[i].GetRow();
268  fPixels[i].SetCol(Int_t(col * fCon.getX()));
269  fPixels[i].SetRow(Int_t(row * fCon.getY()));
270  }
271 }
int row
Definition: anaLmdDigi.C:67
Int_t i
Definition: run_full.C:25
int col
Definition: anaLmdDigi.C:67
FairGeoVector fCon
std::vector< PndSdsPixel > fPixels
std::vector< PndSdsPixel > PndSdsCalcPixel::GetPixels ( Double_t  inx,
Double_t  iny,
Double_t  outx,
Double_t  outy,
Double_t  energy 
)

Main function to calculate the vector<PndSdsPixel> of fired pixel.

Definition at line 66 of file PndSdsCalcPixel.cxx.

References CalcCperL(), CalcPixel(), CalcQuadrant(), CalcStartPixel(), col, fActivePixel, fDir, fIn, fNextPixel, fOut, fPixels, fPos, fStop, fVerboseLevel, PndSdsPixel::GetCol(), PndSdsPixel::GetRow(), kD, kL, kPixelUNDEF, kR, kU, row, PndSdsPixel::SetCharge(), PndSdsPixel::SetCol(), and PndSdsPixel::SetRow().

Referenced by PndSdsHybridHitProducer::Exec(), and GetPixelsAlternative().

69 {
70  fPixels.clear();
71  fIn.setXYZ(inx, iny, 0);
72  fOut.setXYZ(outx, outy, 0);
73 
74  fDir = fOut - fIn;
75  fPos = fIn;
76  if (fDir.length() < 0.001){ //1 m
78  fActivePixel.SetCharge(energy/(3.61e-9));
79  fPixels.push_back(fActivePixel);
80  return fPixels;
81  }
82  // CalcConMatrix(); //fCon berechnen
83  // ApplyConMatrix(); //fCon anwenden
84  if (fVerboseLevel > 1){
85  std::cout << "Converted Vectors: " << std::endl;
86  std::cout << fIn << fOut << fDir << fPos << std::endl;
87  }
88  CalcQuadrant();
90 
92 
93  fStop = false;
94  while (fStop != true){
95  CalcPixel();
96  Int_t col = fActivePixel.GetCol();
97  Int_t row = fActivePixel.GetRow();
98  switch (fNextPixel) {
99  case kU : fActivePixel.SetRow(++row); break;
100  case kD : fActivePixel.SetRow(--row); break;
101  case kL : fActivePixel.SetCol(--col); break;
102  case kR : fActivePixel.SetCol(++col); break;
103  case kPixelUNDEF : std::cout << "PndSdsCalcPixel::GetPixels no next pixel."<<std::endl; break;
104  }
105  fActivePixel.SetCharge(-1.0);
106  }
107 
108  // ConvertPixels(); //fCon rueckgaengig
109  return fPixels;
110 }
int row
Definition: anaLmdDigi.C:67
FairGeoVector fDir
FairGeoVector fOut
int col
Definition: anaLmdDigi.C:67
Int_t GetCol() const
Definition: PndSdsPixel.h:41
void CalcCperL(Double_t Energy)
void SetCol(Int_t col)
Definition: PndSdsPixel.h:34
Int_t GetRow() const
Definition: PndSdsPixel.h:42
std::vector< PndSdsPixel > fPixels
void SetCharge(Double_t charge)
Definition: PndSdsPixel.h:36
FairGeoVector fIn
void SetRow(Int_t row)
Definition: PndSdsPixel.h:35
ENextPixelType fNextPixel
PndSdsPixel fActivePixel
FairGeoVector fPos
Double_t energy
Definition: plot_dirc.C:15
Int_t PndSdsCalcPixel::GetPixelsAlternative ( Double_t  inx,
Double_t  iny,
Double_t  outx,
Double_t  outy,
Double_t  energy,
std::vector< Int_t > &  cols,
std::vector< Int_t > &  rows,
std::vector< Double_t > &  charges 
)

Definition at line 47 of file PndSdsCalcPixel.cxx.

References fVerboseLevel, GetPixels(), and i.

52 {
53  std::vector<PndSdsPixel> pixels = GetPixels(inx,iny,outx,outy,energy);
54  Int_t npix=pixels.size();
55  for(Int_t i=0;i<npix;i++)
56  {
57  if(fVerboseLevel>2) Info("PndSdsCalcPixel::GetPixelsAlternative()","pass this pixel: i=%i, c=%i, r=%i, q=%f",i,pixels[i].GetCol(),pixels[i].GetRow(),pixels[i].GetCharge());
58  cols.push_back(pixels[i].GetCol());
59  rows.push_back(pixels[i].GetRow());
60  charges.push_back(pixels[i].GetCharge());
61  }
62  return npix;
63 }
Int_t i
Definition: run_full.C:25
std::vector< PndSdsPixel > GetPixels(Double_t inx, Double_t iny, Double_t outx, Double_t outy, Double_t energy)
Main function to calculate the vector&lt;PndSdsPixel&gt; of fired pixel.
int cols[10]
Definition: evaltrig.C:69
Double_t energy
Definition: plot_dirc.C:15
std::ostream & PndSdsCalcPixel::operator<< ( std::ostream out)

Definition at line 273 of file PndSdsCalcPixel.cxx.

References fPixelLength, fPixelWidth, and out.

274 {
275  out << "PixelWidth: " << fPixelWidth << " PixelLength: " <<
276  fPixelLength << std::endl;
277 
278  return out;
279 }
Double_t fPixelWidth
TFile * out
Definition: reco_muo.C:20
Double_t fPixelLength
void PndSdsCalcPixel::SetVerboseLevel ( Int_t  level)
inline

Definition at line 44 of file PndSdsCalcPixel.h.

References fVerboseLevel.

44 { fVerboseLevel = level;};
Double_t PndSdsCalcPixel::SmearCharge ( Double_t  charge)
private

Definition at line 282 of file PndSdsCalcPixel.cxx.

References Double_t, fNoise, and fVerboseLevel.

Referenced by CalcPixel().

283 {
284  Double_t smeared = gRandom->Gaus(charge,fNoise);
285  if (fVerboseLevel > 3) std::cout<<" charge = "<<charge<<", smeared = "<<smeared<<std::endl;
286  return smeared;
287 }
Double_t

Member Data Documentation

PndSdsPixel PndSdsCalcPixel::fActivePixel
private

Definition at line 68 of file PndSdsCalcPixel.h.

Referenced by CalcPixel(), CalcStartPixel(), and GetPixels().

FairGeoVector PndSdsCalcPixel::fCon
private

Definition at line 66 of file PndSdsCalcPixel.h.

Referenced by ApplyConMatrix(), CalcConMatrix(), and ConvertPixels().

Double_t PndSdsCalcPixel::fCperL
private

Definition at line 69 of file PndSdsCalcPixel.h.

Referenced by CalcCperL(), and CalcPixel().

FairGeoVector PndSdsCalcPixel::fDir
private

Definition at line 63 of file PndSdsCalcPixel.h.

Referenced by ApplyConMatrix(), CalcCperL(), CalcPixel(), CalcQuadrant(), and GetPixels().

Double_t PndSdsCalcPixel::fEnergy
private

Definition at line 52 of file PndSdsCalcPixel.h.

FairGeoVector PndSdsCalcPixel::fIn
private

Definition at line 61 of file PndSdsCalcPixel.h.

Referenced by ApplyConMatrix(), CalcConMatrix(), CalcStartPixel(), and GetPixels().

ENextPixelType PndSdsCalcPixel::fNextPixel
private

Definition at line 59 of file PndSdsCalcPixel.h.

Referenced by CalcPixel(), and GetPixels().

Double_t PndSdsCalcPixel::fNoise
private

Definition at line 51 of file PndSdsCalcPixel.h.

Referenced by SmearCharge().

FairGeoVector PndSdsCalcPixel::fOut
private

Definition at line 62 of file PndSdsCalcPixel.h.

Referenced by ApplyConMatrix(), CalcPixel(), and GetPixels().

Double_t PndSdsCalcPixel::fPixelLength
private

Definition at line 49 of file PndSdsCalcPixel.h.

Referenced by CalcPixel(), CalcStartPixel(), and operator<<().

std::vector<PndSdsPixel> PndSdsCalcPixel::fPixels
private

Definition at line 47 of file PndSdsCalcPixel.h.

Referenced by CalcPixel(), ConvertPixels(), and GetPixels().

Double_t PndSdsCalcPixel::fPixelWidth
private

Definition at line 48 of file PndSdsCalcPixel.h.

Referenced by CalcPixel(), CalcStartPixel(), and operator<<().

FairGeoVector PndSdsCalcPixel::fPos
private

Definition at line 64 of file PndSdsCalcPixel.h.

Referenced by ApplyConMatrix(), CalcPixel(), and GetPixels().

EQuadrantType PndSdsCalcPixel::fQuad
private

Definition at line 58 of file PndSdsCalcPixel.h.

Referenced by CalcPixel(), and CalcQuadrant().

bool PndSdsCalcPixel::fStop
private

Definition at line 70 of file PndSdsCalcPixel.h.

Referenced by CalcPixel(), and GetPixels().

Double_t PndSdsCalcPixel::fThreshold
private

Definition at line 50 of file PndSdsCalcPixel.h.

Referenced by CalcPixel().

Int_t PndSdsCalcPixel::fVerboseLevel
private

The documentation for this class was generated from the following files: