StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StPxlDigmapsSim.cxx
1 /*
2  *
3  * Author: M. Mustafa
4  *
5  *
6  **********************************************************
7  * $Log: StPxlDigmapsSim.cxx,v $
8  * Revision 1.6 2018/03/16 06:40:01 dongx
9  * Suppress warning output
10  *
11  * Revision 1.5 2018/03/15 21:37:42 dongx
12  * Added the single hit efficiency loaded from pxlSimPar table
13  *
14  * Revision 1.4 2017/11/08 23:14:51 smirnovd
15  * StPxlDigmapsSim: Remove pointless pointer validation
16  *
17  * Revision 1.3 2017/11/08 23:14:44 smirnovd
18  * StPxlDigmapsSim: Initialize member pointer in constructor
19  *
20  * Revision 1.2 2017/10/19 19:38:17 jeromel
21  * Merging PXL201709UPD back to MAIN
22  *
23  * Revision 1.1.2.3 2017/09/22 19:29:56 dongx
24  * Review comments from Victor implemented
25  *
26  * Revision 1.1.2.2 2017/09/20 21:13:02 dongx
27  * Review comments from Jason implemented
28  * - Int_t -> int etc.
29  * - documentation
30  * - random generator using STAR standard
31  *
32  * Revision 1.1.2.1 2017/09/11 20:15:14 dongx
33  * Pxl slow simulator added
34  *
35  */
36 
37 #include <stdio.h>
38 
39 #include "StMessMgr.h"
40 #include "Stypes.h"
41 #include "StPxlDigmapsSim.h"
42 #include "StMcEvent/StMcPxlHit.hh"
43 #include "StMcEvent/StMcPxlHitCollection.hh"
44 #include "StPxlDbMaker/StPxlDb.h"
45 #include "tables/St_pxlControl_Table.h"
46 #include "tables/St_pxlDigmapsSim_Table.h"
47 #include "tables/St_pxlSimPar_Table.h"
48 #include "tables/St_HitError_Table.h"
49 #include "StPxlRawHitMaker/StPxlRawHitCollection.h"
50 #include "StPxlRawHitMaker/StPxlRawHit.h"
51 
52 #include "TDataSet.h"
53 #include "TMath.h"
54 #include "TRandom3.h"
55 #include "TDataSet.h"
56 #include "TObjectSet.h"
57 #include "TF1.h"
58 #include "TVector3.h"
59 
60 #include "DIGMAPS/digplane.h"
61 #include "DIGMAPS/digadc.h"
62 #include "DIGMAPS/digtransport.h"
63 #include "DIGMAPS/digparticle.h"
64 #include "DIGMAPS/digevent.h"
65 
66 StPxlDigmapsSim::StPxlDigmapsSim(const Char_t *name): StPxlISim(name),
67  mRndGen(nullptr), mOwnRndSeed(0), mDigPlane(new DIGPlane()), mDigAdc(new DIGADC()), mDigTransport(new DIGTransport()),
68  mPxlDb(nullptr),
69  mdEdxvsBGNorm(nullptr), mHitEffMode(0), mMomCut(0.), mHitEffInner(1.0), mHitEffOuter(1.0)
70 {}
71 
73 {
74  delete mRndGen;
75  delete mDigAdc;
76  delete mDigPlane;
77  delete mDigTransport;
78  delete mPxlDb;
79  delete mdEdxvsBGNorm;
80 }
81 
82 int StPxlDigmapsSim::initRun(const TDataSet& calib_db, const TObjectSet* pxlDbDataSet, const Int_t run)
83 {
84  LOG_INFO << "StPxlDigmapsSim::init()" << endm;
85 
86  mRndGen = (TRandom3 *)gRandom;
87  if ( 0 == mRndGen || mOwnRndSeed > 0 ) mRndGen = new TRandom3(mOwnRndSeed);
88 
89  if (pxlDbDataSet != 0)
90  {
91  mPxlDb = (StPxlDb *)pxlDbDataSet->GetObject();
92  if (!mPxlDb)
93  {
94  LOG_ERROR << "StPxlDigmapsSim - E - mPxlDb is not available" << endm;
95  return kStFatal;
96  }
97  }
98  else
99  {
100  LOG_ERROR << "StPxlDigmapsSim - E - no PxlDb" << endm;
101  return kStFatal;
102  }
103 
104  pxlControl_st const* const pxlControlTable = mPxlDb->pxlControl();
105  mSensorGoodStatusMin = pxlControlTable[0].sensorGoodStatusMin;
106  mSensorGoodStatusMax = pxlControlTable[0].sensorGoodStatusMax;
107  mRowColumnGoodStatus = pxlControlTable[0].rowColumnGoodStatus;
108 
109  pxlDigmapsSim_st const* const pxlDigmapsSimTable = mPxlDb->pxlDigmapsSim();
110  // set ADC threshold(s)
111  int nAdcBits = 1;
112  int nAdcThresholds = int(TMath::Power(2.0, nAdcBits) - 1);
113  Bool_t adcLinear = 0;
114  float adcElectronConversion = -999;
115  float adcThresholds[] = {pxlDigmapsSimTable[0].adcThreshold}; // one threshold only
116  float adcLsb = adcThresholds[0];
117 
118  mDigAdc->SetNbits(nAdcBits);
119  mDigAdc->SetNThresholds(nAdcThresholds);
120  mDigAdc->SetADC_linear(adcLinear);
121  mDigAdc->SetLSB(adcLsb);
122  mDigAdc->SetElectron_Conversion(adcElectronConversion);
123  mDigAdc->SetADC_thresholds(adcThresholds, nAdcThresholds);
124 
125  // set transport
126  int transportChargeModel = (int)pxlDigmapsSimTable[0].transportChargeModel;
127  float transportRangeLimit_InPitchUnit = pxlDigmapsSimTable[0].transportRangeLimit;
128  float transport_l1dimgauslor_Norm_g_1st = pxlDigmapsSimTable[0].transport_Norm_g_1st;
129  float transport_l1dimgauslor_x0_g_1st = pxlDigmapsSimTable[0].transport_x0_g_1st;
130  float transport_l1dimgauslor_sigma_g_1st = pxlDigmapsSimTable[0].transport_sigma_g_1st;
131  float transport_l1dimgauslor_Gamma_lor_1st = pxlDigmapsSimTable[0].transport_Gamma_lor_1st;
132  float transport_l1dimgauslor_x0_lor_1st = pxlDigmapsSimTable[0].transport_x0_lor_1st;
133  float transport_l1dimgauslor_norm_lor_1st = pxlDigmapsSimTable[0].transport_norm_lor_1st;
134  float transport_l1dimgauslor_Norm_g_2nd = pxlDigmapsSimTable[0].transport_Norm_g_2nd;
135  float transport_l1dimgauslor_x0_g_2nd = pxlDigmapsSimTable[0].transport_x0_g_2nd;
136  float transport_l1dimgauslor_sigma_g_2nd = pxlDigmapsSimTable[0].transport_sigma_g_2nd;
137  float transport_l1dimgauslor_Gamma_lor_2nd = pxlDigmapsSimTable[0].transport_Gamma_lor_2nd;
138  float transport_l1dimgauslor_x0_lor_2nd = pxlDigmapsSimTable[0].transport_x0_lor_2nd;
139  float transport_l1dimgauslor_norm_lor_2nd = pxlDigmapsSimTable[0].transport_norm_lor_2nd;
140 
141  mDigTransport->SetChargeModel(transportChargeModel);
142  mDigTransport->SetRangeLimit_InPitchUnit(transportRangeLimit_InPitchUnit);
143  mDigTransport->Setf1dimgauslor_Norm_g_1st(transport_l1dimgauslor_Norm_g_1st);
144  mDigTransport->Setf1dimgauslor_x0_g_1st(transport_l1dimgauslor_x0_g_1st);
145  mDigTransport->Setf1dimgauslor_sigma_g_1st(transport_l1dimgauslor_sigma_g_1st);
146  mDigTransport->Setf1dimgauslor_Gamma_lor_1st(transport_l1dimgauslor_Gamma_lor_1st);
147  mDigTransport->Setf1dimgauslor_x0_lor_1st(transport_l1dimgauslor_x0_lor_1st);
148  mDigTransport->Setf1dimgauslor_norm_lor_1st(transport_l1dimgauslor_norm_lor_1st);
149  mDigTransport->Setf1dimgauslor_Norm_g_2nd(transport_l1dimgauslor_Norm_g_2nd);
150  mDigTransport->Setf1dimgauslor_x0_g_2nd(transport_l1dimgauslor_x0_g_2nd);
151  mDigTransport->Setf1dimgauslor_sigma_g_2nd(transport_l1dimgauslor_sigma_g_2nd);
152  mDigTransport->Setf1dimgauslor_Gamma_lor_2nd(transport_l1dimgauslor_Gamma_lor_2nd);
153  mDigTransport->Setf1dimgauslor_x0_lor_2nd(transport_l1dimgauslor_x0_lor_2nd);
154  mDigTransport->Setf1dimgauslor_norm_lor_2nd(transport_l1dimgauslor_norm_lor_2nd);
155 
156  // set plane
157  float planePitchX = StPxlConsts::kPixelSize * 1e4;
158  float planePitchY = StPxlConsts::kPixelSize * 1e4;
159  float planeEpitaxialThickness = pxlDigmapsSimTable[0].planeEpitaxialThickness;
160  float planeNoiseElectrons = pxlDigmapsSimTable[0].planeNoiseElectrons;
161  int planeNpixelsX = kNumberOfPxlRowsOnSensor; // row - local X - DIGMAPS X
162  int planeNpixelsY = kNumberOfPxlColumnsOnSensor; // column - local z - DIGMAPS Y
163  float planeTemprature = pxlDigmapsSimTable[0].planeTemprature;
164  float planeIonizationEnergy = pxlDigmapsSimTable[0].planeIonizationEnergy;
165  float planeSegmentSize = pxlDigmapsSimTable[0].planeSegmentSize;
166  float planeMaximumSegmentSize = pxlDigmapsSimTable[0].planeMaxSegmentSize;
167  float planeMaximumChargePerSegment = pxlDigmapsSimTable[0].planeMaxChargePerSegment;
168  float planeDiffusionMaximumRangeInX = pxlDigmapsSimTable[0].planeDiffusionMaxX;
169  float planeDiffusionMaximumRangeInY = pxlDigmapsSimTable[0].planeDiffusionMaxY;
170  float planeReflexionCoefficient = pxlDigmapsSimTable[0].planeReflexCoefficient;
171  float planeBasicModel_SigmaTenMicrons = pxlDigmapsSimTable[0].planeMod_SigTenMicrons;
172 
173  mDigPlane->SetPitch(planePitchX, planePitchY);
174  mDigPlane->SetNpixels(planeNpixelsX, planeNpixelsY);
175  mDigPlane->SetDimensions(planePitchX * planeNpixelsX, planePitchY * planeNpixelsY, planeEpitaxialThickness);
176  mDigPlane->SetNoiseElectrons(planeNoiseElectrons);
177  mDigPlane->SetTemperature(planeTemprature);
178  mDigPlane->SetIonizationEnergy(planeIonizationEnergy);
179  mDigPlane->SetSegmentSize(planeSegmentSize);
180  mDigPlane->SetMaximumSegmentSize(planeMaximumSegmentSize);
181  mDigPlane->SetMaximumChargePerSegment(planeMaximumChargePerSegment);
182  mDigPlane->SetDiffusionMaximumRange(planeDiffusionMaximumRangeInX, planeDiffusionMaximumRangeInY);
183  mDigPlane->SetReflexionCoefficient(planeReflexionCoefficient);
184  mDigPlane->SetBasicModel_SigmaTenMicrons(planeBasicModel_SigmaTenMicrons);
185 
186  mEnergyLandauMean = pxlDigmapsSimTable[0].energyLandauMean;
187  mEnergyLandauSigma = pxlDigmapsSimTable[0].energyLandauSigma;
188  for(int i=0;i<10;i++) {
189  mScalePar[i] = (double)(pxlDigmapsSimTable[0].par[i]);
190  }
191  mdEdxvsBGNorm = new TF1("dEdxvsBGNorm",this,&StPxlDigmapsSim::dEdxvsBGNorm,0.1,1e5,6);
192  mdEdxvsBGNorm->SetParameters(&mScalePar[0]);
193 
194  mResAddX = pxlDigmapsSimTable[0].resAddX;
195  mResAddZ = pxlDigmapsSimTable[0].resAddZ;
196 
197  // initialize the sensor offset values due to other contributions
198  for(int i=0;i<kNumberOfPxlSectors;i++) {
199  for(int j=0;j<kNumberOfPxlLaddersPerSector;j++) {
200  for(int k=0;k<kNumberOfPxlSensorsPerLadder;k++) {
201  mOffsetX[i][j][k] = mRndGen->Gaus(0.,mResAddX);
202  mOffsetZ[i][j][k] = mRndGen->Gaus(0.,mResAddZ);
203  }
204  }
205  }
206 
207  // MC->RC hit efficiency (momentum dependence - default)
208  pxlSimPar_st const* const pxlSimParTable = mPxlDb->pxlSimPar();
209  mHitEffMode = pxlSimParTable[0].mode;
210  mMomCut = pxlSimParTable[0].pCut;
211  mHitEffInner = pxlSimParTable[0].effPxlInner; // best knowledge from ZF cosmic ray study - inner tunable
212  mHitEffOuter = pxlSimParTable[0].effPxlOuter; // best knowledge from ZF cosmic ray study - checked for outer
213 
214  LOG_INFO << " PXL MC hit efficiency mode used for PXL slow simulator: " << mHitEffMode << endm;
215  LOG_INFO << " +++ Hit Efficiency at p > " << mMomCut << " GeV/c (Inner/Outer) = " << mHitEffInner << "/" << mHitEffOuter << endm;
216 
217  return kStOk;
218 }
219 //____________________________________________________________
220 int StPxlDigmapsSim::addPxlRawHits(const StMcPxlHitCollection& mcPxlHitCol,
221  StPxlRawHitCollection& pxlRawHitCol)
222 {
223  for (unsigned int iSec = 0; iSec < mcPxlHitCol.numberOfSectors(); ++iSec)
224  {
225  const StMcPxlSectorHitCollection* mcPxlSectorHitCol = mcPxlHitCol.sector(iSec);
226  if (!mcPxlSectorHitCol) continue;
227 
228  for (unsigned int iLad = 0; iLad < mcPxlSectorHitCol->numberOfLadders(); ++iLad)
229  {
230  const StMcPxlLadderHitCollection* mcPxlLadderHitCol = mcPxlSectorHitCol->ladder(iLad);
231  if (!mcPxlLadderHitCol) continue;
232 
233  for (unsigned int iSen = 0; iSen < mcPxlLadderHitCol->numberOfSensors(); ++iSen)
234  {
235  const StMcPxlSensorHitCollection* mcPxlSensorHitCol = mcPxlLadderHitCol->sensor(iSen);
236  if (!mcPxlSensorHitCol) continue;
237 
238  if (!goodSensor(iSec+1, iLad+1, iSen+1))
239  {
240  LOG_DEBUG << " ##Skip bad sensor " << iSec << "/" << iLad << "/" << iSen << " StatusCode = " << mPxlDb->sensorStatus(iSec + 1, iLad + 1, iSen + 1) << endm;
241  continue;
242  }
243 
244  unsigned int nSenHits = mcPxlSensorHitCol->hits().size();
245  LOG_DEBUG << "Sector/Ladder/Sensor = " << iSec+1 << "/" << iLad+1 << "/" << iSen+1 << ". Number of sensor hits = " << nSenHits << endm;
246 
247  // Loop over hits in the sensor
248  for (unsigned int iHit = 0; iHit < nSenHits; ++iHit)
249  {
250  StMcPxlHit const* const mcPix = mcPxlSensorHitCol->hits()[iHit];
251  if (!mcPix) continue;
252 
253  float hitEff = 1.0;
254  switch (mHitEffMode) {
255  case 0: // ideal case 100% efficiency
256  break;
257  case 1: // momemum dependent efficiency
258  if(mcPix->parentTrack()) {
259  float const ptot = mcPix->parentTrack()->momentum().mag();
260  if( iLad==0 ) { // linear dependence 0 at p=0 and minimum at p=mMomCut
261  hitEff = 1.0 - (1. - mHitEffInner)*ptot/mMomCut;
262  if(hitEff<mHitEffInner) hitEff = mHitEffInner;
263  } else {
264  hitEff = 1.0 - (1. - mHitEffOuter)*ptot/mMomCut;
265  if(hitEff<mHitEffOuter) hitEff = mHitEffOuter;
266  }
267  }
268  break;
269  case 2: // constant efficiency
270  if( iLad==0 ) {
271  hitEff = mHitEffInner;
272  } else {
273  hitEff = mHitEffOuter;
274  }
275  break;
276  default:
277  break;
278  }
279 
280  if( mRndGen->Rndm()>hitEff ) continue;
281 
282  int sensorId = ( iSec * kNumberOfPxlLaddersPerSector + iLad ) * kNumberOfPxlSensorsPerLadder + iSen + 1;
283  DIGEvent fdigevent{};
284  fillDigmapsEvent(sensorId, mcPix, fdigevent);
285 
286  int n_pxl = 0; // number of pixels passing digQ threshold
287  int n_pxl_wmask = 0; // number of pixels passing digQ threshold and with mask
288  for (int j = 0; j < fdigevent.GetReadoutmap()->GetNpixels(); ++j)
289  {
290  if(fdigevent.GetReadoutmap()->GetDigitalCharge()[j] > 0)
291  {
292  ++n_pxl;
293  int const Npixel = fdigevent.GetReadoutmap()->GetPixelMap()[j];
294  int const iy = Npixel / mDigPlane->GetNpixelsX();
295  int const ix = (mDigPlane->GetNpixelsX()-1) - Npixel % mDigPlane->GetNpixelsX(); // local X direction goes from row number MAX->0
296 
297  if (goodPixel(iSec+1 , iLad+1, iSen+1, ix, iy))
298  {
299  ++n_pxl_wmask;
300  int const idTruth = mcPix->parentTrack()? mcPix->parentTrack()->key() : 0;
301  LOG_DEBUG << " adding a new pxlRawHit sector/ladder/sensor = " << iSec + 1 << "/" << iLad + 1 << "/" << iSen + 1 << " ix/iy=" << ix << "/" << iy << " idTruth=" << idTruth << endm;
302 
303  pxlRawHitCol.addRawHit(StPxlRawHit(iSec + 1, iLad + 1, iSen + 1, ix, iy, idTruth));
304  }
305  }
306  }
307 
308  LOG_DEBUG << " ReadoutMap Npixels = " << fdigevent.GetReadoutmap()->GetNpixels() << "\t Npixels Dig Cut = " << n_pxl << "\t Npixels Mask Cut = " << n_pxl_wmask << endm;
309  } // end for hits
310  } // end sensor loop
311  } // end ladder loop
312  } // end sector loop
313 
314  return kStOK;
315 }
316 
317 void StPxlDigmapsSim::fillDigmapsEvent(int sensorId, StMcPxlHit const* const mcPix, DIGEvent& fdigevent) const
318 {
319  TVector3 inPos{};
320  TVector3 outPos{};
321  calculateIncidencePositions(sensorId, mcPix, inPos, outPos);
322  float const betagamma = betaGamma(mcPix->parentTrack());
323  float const depositedEnergy = calculateDepositedEnergy((inPos-outPos).Mag(), betagamma);
324  LOG_DEBUG << " Energy deposit for this hit = " << depositedEnergy << "\t totalLength = " << (inPos-outPos).Mag() << "\t betagamma = " << betagamma << endm;
325 
326  DIGParticle fdigparticle(inPos.X(), inPos.Y(), inPos.Z(), outPos.X(), outPos.Y(), outPos.Z(), depositedEnergy);
327  LOG_DEBUG << " InPos = " << inPos.X() << "/" << inPos.Y() << "/" << inPos.Z() << "\t outPos = " << outPos.X() << "/" << outPos.Y() << "/" << outPos.Z() << " E = " << depositedEnergy << endm;
328 
329  //---------charge generation
330  fdigparticle.ComputeChargeDeposition(mDigPlane->GetSegmentSize(), mDigPlane->GetMaximumSegmentSize(), mDigPlane->GetMaximumChargePerSegment());
331  //---------charge transport
332  fdigparticle.ComputeChargeTransport(mDigPlane, mDigTransport);
333  //---------random noise (should be removed if one wants to avoid double noise on double hit pixels)
334  fdigparticle.AddRandomNoise(mDigPlane);
335  //---------ADC (stored only for reference)
336  fdigparticle.AnalogToDigitalconversion(mDigAdc, mDigPlane);
337 
338  fdigevent.AddParticle(fdigparticle);
339  auto chargevector = fdigparticle.GetAnalogCharge();
340  auto pixmapvector = fdigparticle.GetPixelMap();
341 
342  for (int ipix = 0 ; ipix < fdigparticle.GetNpixels() ; ++ipix)
343  {
344  (fdigevent.GetReadoutmap())->UpdatePixel(chargevector[ipix], pixmapvector[ipix]);
345  }
346 
347  //---------Build readout map:
348  (fdigevent.GetReadoutmap())->AnalogToDigitalconversion(mDigAdc, mDigPlane);
349 
350  LOG_DEBUG << " DigPlane NpixX = " << mDigPlane->GetNpixelsX() << "\t DigPlane NpixY = " << mDigPlane->GetNpixelsY() << endm;
351 }
352 
353 float StPxlDigmapsSim::calculateDepositedEnergy(float const totalLength, float const betagamma) const
354 {
355  float const energyMPV = mEnergyLandauMean * totalLength;
356  float const energySigma = mEnergyLandauSigma * totalLength;
357  float energy = mRndGen->Landau(energyMPV, energySigma) * mdEdxvsBGNorm->Eval(betagamma);
358  LOG_DEBUG << " energyMPV/Sigma = " << energyMPV << " " << energySigma << "\t betagamma = " << betagamma << " dEdx correction = " << mdEdxvsBGNorm->Eval(betagamma) << endm;
359 
360  int count=0;
361  while (energy > 50000 && count < 50) // count to avoid infinite loop in case of large energy deposit
362  {
363  LOG_DEBUG << "Energy too high -> Energy regenerated " << energy << " MPV/sigma= " << energyMPV << " " << energySigma << " betagamma=" << betagamma << " Correction=" << mdEdxvsBGNorm->Eval(betagamma) << " Seed = " << mRndGen->GetSeed() << endm;
364  mRndGen->SetSeed(mRndGen->GetSeed()*mRndGen->GetSeed());
365  energy = mRndGen->Landau(energyMPV, energySigma) * mdEdxvsBGNorm->Eval(betagamma);
366  count++;
367  }
368  if(count==50)
369  LOG_WARN << " Failed in Sample: energy= " << energy << " MPV/sigma= " << energyMPV << " " << energySigma << " betagamma=" << betagamma << " Correction=" << mdEdxvsBGNorm->Eval(betagamma) << " Seed = " << mRndGen->GetSeed() << endm;
370 
371  return energy;
372 }
373 
374 double StPxlDigmapsSim::dEdxvsBGNorm(double *x, double *par)
375 {
376  static const double threshold = 10.;
377  double beta2 = x[0]*x[0]/(1+x[0]*x[0]);
378  double delta = TMath::Log(x[0])+par[2];
379  if(x[0]<=threshold) {
380  return par[0]/beta2*(0.5*TMath::Log(x[0]*x[0]*par[1])-beta2-delta/2.);
381  } else {
382  return par[3] + par[4]*TMath::Log(x[0])+par[5]*TMath::Log(x[0])*TMath::Log(x[0]);
383  }
384 }
385 
386 void StPxlDigmapsSim::calculateIncidencePositions(int sensorId, StMcPxlHit const* const mcPix, TVector3& inPos, TVector3& outPos) const
387 {
388  int iSec = (sensorId - 1) / (kNumberOfPxlLaddersPerSector * kNumberOfPxlSensorsPerLadder);
389  int iLad = (sensorId - 1) % (kNumberOfPxlLaddersPerSector * kNumberOfPxlSensorsPerLadder) / kNumberOfPxlSensorsPerLadder;
390  int iSen = (sensorId - 1) % kNumberOfPxlSensorsPerLadder;
391 
392  double localPixHitPos[3] = {mcPix->position().x() + mOffsetX[iSec][iLad][iSen], mcPix->position().y(), mcPix->position().z() + mOffsetZ[iSec][iLad][iSen]};
393  double localPxlMom[3] = {mcPix->localMomentum().x(), mcPix->localMomentum().y(), mcPix->localMomentum().z()};
394 
395  // convert to um (all DIGMAPS units are in um)
396  localPixHitPos[0] *= 10000.0;
397  localPixHitPos[1] *= 10000.0;
398  localPixHitPos[2] *= 10000.0;
399 
400  // LOG_DEBUG << "globalPixHitPos = " << globalPixHitPos[0] << " " << globalPixHitPos[1] << " " << globalPixHitPos[2] << endm;
401  LOG_DEBUG << "localPixHitPos = " << localPixHitPos[0] << " " << localPixHitPos[1] << " " << localPixHitPos[2] << "\n";
402  LOG_DEBUG << "localPxlMom = " << localPxlMom[0] << " " << localPxlMom[1] << " " << localPxlMom[2] << "\n";
403  LOG_DEBUG << " DigPlane dimensions " << mDigPlane->GetXdimension() << " " << mDigPlane->GetYdimension() << " " << mDigPlane->GetZdimension() << endm;
404 
405  inPos.SetX(localPixHitPos[0] + mDigPlane->GetXdimension() / 2.0 + (mDigPlane->GetZdimension() / 2.0 - localPixHitPos[1]) * localPxlMom[0] / localPxlMom[1]);
406  inPos.SetY(localPixHitPos[2] + mDigPlane->GetYdimension() / 2.0 + (mDigPlane->GetZdimension() / 2.0 - localPixHitPos[1]) * localPxlMom[2] / localPxlMom[1]);
407  inPos.SetZ(mDigPlane->GetZdimension() / 2.0);
408 
409  outPos.SetX(localPixHitPos[0] + mDigPlane->GetXdimension() / 2.0 + (-mDigPlane->GetZdimension() / 2.0 - localPixHitPos[1]) * localPxlMom[0] / localPxlMom[1]);
410  outPos.SetY(localPixHitPos[2] + mDigPlane->GetYdimension() / 2.0 + (-mDigPlane->GetZdimension() / 2.0 - localPixHitPos[1]) * localPxlMom[2] / localPxlMom[1]);
411  outPos.SetZ(-mDigPlane->GetZdimension() / 2.0);
412 
413  LOG_DEBUG << "inHitPos = " << inPos.X() << " " << inPos.Y() << " " << inPos.Z() << "\n";
414  LOG_DEBUG << "outHitPos = " << outPos.X() << " " << outPos.Y() << " " << outPos.Z() << endm;
415 }
416 
417 float StPxlDigmapsSim::betaGamma(StMcTrack const* const mcTrk) const
418 {
419  if (!mcTrk) return 1.;
420 
421  float betagamma = 1.;
422  float const m = mcTrk->fourMomentum().m();
423  if(m>0) betagamma = mcTrk->momentum().mag()/m;
424  LOG_DEBUG << " track info: " << mcTrk->momentum().mag() << " " << m << " " << betagamma << endm;
425  if(m>1.0) LOG_DEBUG << " This is a large mass particle: geantId=" << mcTrk->geantId() << " pdgId=" << mcTrk->pdgId() << endm;
426 
427  return betagamma;
428 }
429 
430 bool StPxlDigmapsSim::goodPixel(int const sec, int const lad, int const sen, int const ix, int const iy) const
431 {
432  // check raw and column status and hot pixels
433  return (mPxlDb->rowStatus(sec, lad, sen, ix) == mRowColumnGoodStatus) &&
434  (mPxlDb->columnStatus(sec, lad, sen, iy) == mRowColumnGoodStatus) &&
435  (!mPxlDb->pixelHot(sec, lad, sen, ix, iy));
436 }
437 
438 bool StPxlDigmapsSim::goodSensor(int const sec, int const lad, int const sen) const
439 {
440  return (mPxlDb->sensorStatus(sec, lad, sen) >= mSensorGoodStatusMin) &&
441  (mPxlDb->sensorStatus(sec, lad, sen) <= mSensorGoodStatusMax);
442 }
Definition: digadc.h:36
virtual int initRun(TDataSet const &calib_db, TObjectSet const *pxlDbDataSet, Int_t run)
initRun function to read in DB entries for slow simulator parameters and masking tables.
const pxlSimPar_st * pxlSimPar()
Definition: StPxlDb.h:136
const pxlDigmapsSim_st * pxlDigmapsSim()
Definition: StPxlDb.h:133
const pxlControl_st * pxlControl()
Definition: StPxlDb.h:130
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...
Definition: StMcTrack.hh:144
Int_t pixelHot(Int_t sector, Int_t ladder, Int_t sensor, Int_t row, Int_t column) const
1: hot; 0: good
Definition: StPxlDb.cxx:181
void addRawHit(const StPxlRawHit &rawHit)
add a raw hit to the collection
Int_t sensorStatus(Int_t sector, Int_t ladder, Int_t sensor) const
status for sensor/row/column
Definition: StPxlDb.cxx:163
Definition: Stypes.h:40
Int_t rowStatus(Int_t sector, Int_t ladder, Int_t sensor, Int_t row) const
1: good status
Definition: StPxlDb.cxx:169
Int_t columnStatus(Int_t sector, Int_t ladder, Int_t sensor, Int_t column) const
1: good status
Definition: StPxlDb.cxx:175
An abstract class (interface) for all PXL simulation algorithms.
Definition: StPxlISim.h:21
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
Definition: TObjectSet.h:56
virtual ~StPxlDigmapsSim()
This class does not own any hit containers. mRandom is deleted here.
Definition: Stypes.h:41