CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
EnergyLossPlain Class Reference

#include <EnergyLossPlain.h>

Public Member Functions

 EnergyLossPlain (const TrackerGeometry *theTracker_, double pixelToStripMultiplier, double pixelToStripExponent)
 
int estimate (const Trajectory *trajectory, std::vector< std::pair< int, double > > &arithmeticMean, std::vector< std::pair< int, double > > &truncatedMean)
 
void loadOptimalWeights ()
 
 ~EnergyLossPlain ()
 

Private Member Functions

double average (std::vector< std::pair< double, double > > &values)
 
double expected (double Delta1, double Delta2)
 
double logTruncate (std::vector< std::pair< double, double > > &values)
 
double optimal (std::vector< std::pair< double, double > > &values)
 
void process (LocalVector ldir, const SiPixelRecHit *recHit, std::vector< std::pair< double, double > > &values)
 
void process (LocalVector ldir, const SiStripRecHit2D *recHit, std::vector< std::pair< double, double > > &values)
 
double truncate (std::vector< std::pair< double, double > > &values)
 

Private Attributes

double pixelToStripExponent
 
double pixelToStripMultiplier
 
const TrackerGeometrytheTracker
 

Static Private Attributes

static bool isFirst = true
 
static float optimalWeight [61][61]
 

Detailed Description

Definition at line 12 of file EnergyLossPlain.h.

Constructor & Destructor Documentation

EnergyLossPlain::EnergyLossPlain ( const TrackerGeometry theTracker_,
double  pixelToStripMultiplier,
double  pixelToStripExponent 
)

Definition at line 52 of file EnergyLossPlain.cc.

References cuy::isFirst.

54  : theTracker(theTracker_),
55  pixelToStripMultiplier(pixelToStripMultiplier_),
56  pixelToStripExponent (pixelToStripExponent_ )
57 {
58  // Load data
59  if(isFirst == true)
60  {
62  isFirst = false;
63  }
64 }
double pixelToStripExponent
double pixelToStripMultiplier
const TrackerGeometry * theTracker
static bool isFirst
EnergyLossPlain::~EnergyLossPlain ( )

Definition at line 67 of file EnergyLossPlain.cc.

68 {
69 }

Member Function Documentation

double EnergyLossPlain::average ( std::vector< std::pair< double, double > > &  values)
private

Definition at line 96 of file EnergyLossPlain.cc.

References i, and makeHLTPrescaleTable::values.

97 {
98  int num = values.size();
99  double sum[2] = {0.,0.};
100 
101  for(int i = 0; i < num; i++)
102  {
103  sum[1] += values[i].first;
104  sum[0] += 1;
105  }
106 
107  return sum[1] / sum[0];
108 }
int i
Definition: DBlmapReader.cc:9
long long int num
Definition: procUtils.cc:71
int EnergyLossPlain::estimate ( const Trajectory trajectory,
std::vector< std::pair< int, double > > &  arithmeticMean,
std::vector< std::pair< int, double > > &  truncatedMean 
)

Definition at line 297 of file EnergyLossPlain.cc.

References a, PDRates::average, TrackingRecHit::geographicalId(), i, TrackingRecHit::isValid(), m, Trajectory::measurements(), ProjectedSiStripRecHit2D::originalHit(), GeomDetEnumerators::PixelBarrel, GeomDetEnumerators::PixelEndcap, LaserDQM_cfg::process, alignCSCRings::s, findQualityFiles::v, hltHiggsPostProcessors_cff::vstr, and detailsBasic3DVector::y.

Referenced by EnergyLossProducer::produce().

299 {
300  // (dE/dx, dx)
301  std::vector<pair<double,double> > vpix,vstr;
302 
303  for(std::vector<TrajectoryMeasurement>::const_iterator
304  meas = trajectory->measurements().begin();
305  meas!= trajectory->measurements().end(); meas++)
306  {
307  const TrackingRecHit* recHit = meas->recHit()->hit();
308  DetId id = recHit->geographicalId();
309 
310  if(recHit->isValid())
311  {
312  LocalVector ldir = meas->updatedState().localDirection();
313 
314  if(theTracker->idToDet(id)->subDetector() ==
316  theTracker->idToDet(id)->subDetector() ==
318  {
319  // Pixel
320  const SiPixelRecHit* pixelRecHit =
321  dynamic_cast<const SiPixelRecHit *>(recHit);
322 
323  if(pixelRecHit != 0)
324  process(ldir,pixelRecHit , vpix);
325  }
326  else
327  {
328  // Strip
329  const SiStripMatchedRecHit2D* stripMatchedRecHit =
330  dynamic_cast<const SiStripMatchedRecHit2D *>(recHit);
331  const ProjectedSiStripRecHit2D* stripProjectedRecHit =
332  dynamic_cast<const ProjectedSiStripRecHit2D *>(recHit);
333  const SiStripRecHit2D* stripRecHit =
334  dynamic_cast<const SiStripRecHit2D *>(recHit);
335 
336  std::pair<double,double> v;
337 
338  if(stripMatchedRecHit != 0)
339  {
340  auto m = stripMatchedRecHit->monoHit();
341  auto s = stripMatchedRecHit->stereoHit();
342  process(ldir,&m, vstr);
343  process(ldir,&s, vstr);
344  }
345 
346  if(stripProjectedRecHit != 0)
347  process(ldir,&(stripProjectedRecHit->originalHit()), vstr);
348 
349  if(stripRecHit != 0)
350  process(ldir,stripRecHit, vstr);
351  }
352  }
353  }
354 
355  // Transform
356  std::vector<pair<double,double> > vall;
357 
358  for(unsigned int i = 0; i < vpix.size(); i++)
359  {
360  float a = 0.795;
361  float s = 10.1;
362 
363  std::pair<double,double> str(vpix[i]);
364 
365  double y = str.first / a / s;
366  if(y > 0.9999) y = 0.9999;
367  if(y <-0.9999) y = -0.9999;
368 
369  str.first = s * atanh(y);
370 
371  vall.push_back(str);
372  }
373 
374  for(unsigned int i = 0; i < vstr.size(); i++) vall.push_back(vstr[i]);
375 
376  // Arithmetic mean
377  arithmeticMean.push_back(std::pair<int,double>(vpix.size(), average(vpix)));
378  arithmeticMean.push_back(std::pair<int,double>(vstr.size(), average(vstr)));
379  arithmeticMean.push_back(std::pair<int,double>(vall.size(), average(vall)));
380 
381  // Wighted mean
382  truncatedMean.push_back(std::pair<int,double>(vpix.size(), optimal(vpix)));
383  truncatedMean.push_back(std::pair<int,double>(vstr.size(), optimal(vstr)));
384  truncatedMean.push_back(std::pair<int,double>(vall.size(), optimal(vall)));
385 
386  return vall.size();
387 }
int i
Definition: DBlmapReader.cc:9
double optimal(std::vector< std::pair< double, double > > &values)
virtual SubDetector subDetector() const =0
Which subdetector.
void process(LocalVector ldir, const SiPixelRecHit *recHit, std::vector< std::pair< double, double > > &values)
DataContainer const & measurements() const
Definition: Trajectory.h:215
const TrackerGeometry * theTracker
virtual const GeomDet * idToDet(DetId) const
Definition: DetId.h:20
double average(std::vector< std::pair< double, double > > &values)
bool isValid() const
double a
Definition: hdecay.h:121
DetId geographicalId() const
const SiStripRecHit2D & originalHit() const
Pixel Reconstructed Hit.
double EnergyLossPlain::expected ( double  Delta1,
double  Delta2 
)
private

Definition at line 205 of file EnergyLossPlain.cc.

References create_public_lumi_plots::log.

206 {
207  return log(Delta2/Delta1) / (1/Delta1 - 1/Delta2);
208 // return 1 + (Delta2*log(Delta1) - Delta1*log(Delta2)) / (Delta2 - Delta1);
209 }
void EnergyLossPlain::loadOptimalWeights ( )

Definition at line 73 of file EnergyLossPlain.cc.

References edm::FileInPath::fullPath(), i, LogTrace, n, optimalWeight, and w().

74 {
76  fileInPath("QCDAnalysis/ChargedHadronSpectra/data/energyWeights.dat");
77  ifstream inFile(fileInPath.fullPath().c_str());
78 
79  while(inFile.eof() == false)
80  {
81  int i; float w; int n;
82  inFile >> i;
83  inFile >> w;
84  inFile >> n;
85 
87  }
88 
89  inFile.close();
90 
91  LogTrace("MinBiasTracking")
92  << " [EnergyLossEstimator] optimal weights loaded";
93 }
int i
Definition: DBlmapReader.cc:9
#define LogTrace(id)
static float optimalWeight[61][61]
T w() const
double EnergyLossPlain::logTruncate ( std::vector< std::pair< double, double > > &  values)
private

Definition at line 111 of file EnergyLossPlain.cc.

References i, funct::pow(), python.multivaluedict::sort(), findQualityFiles::v, makeHLTPrescaleTable::values, and histoStyle::weight.

112 {
113  std::vector<double> values;
114  for(std::vector<pair<double,double> >::iterator
115  v = values_.begin(); v!= values_.end(); v++)
116  values.push_back((*v).first);
117 
118  sort(values.begin(), values.end());
119 
120  int num = values.size();
121  double sum[2] = {0.,1.};
122 
123  for(int i = 0; i < (num+1)/2; i++)
124  {
125  double weight = 1.;
126 
127  if(num%2 == 1 && i == (num-1)/2) weight = 1./2;
128 
129  sum[1] *= pow(values[i], weight);
130  sum[0] += weight;
131 
132  }
133 
134  return pow(sum[1], 1./sum[0]);
135 }
int i
Definition: DBlmapReader.cc:9
long long int num
Definition: procUtils.cc:71
int weight
Definition: histoStyle.py:50
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double EnergyLossPlain::optimal ( std::vector< std::pair< double, double > > &  values)
private

Definition at line 164 of file EnergyLossPlain.cc.

References first, i, create_public_lumi_plots::log, edm::second(), python.multivaluedict::sort(), findQualityFiles::v, makeHLTPrescaleTable::values, and histoStyle::weight.

165 {
166  std::vector<double> values;
167  for(std::vector<pair<double,double> >::iterator
168  v = values_.begin(); v!= values_.end(); v++)
169  values.push_back((*v).first);
170 
171  int num = values.size();
172  sort(values.begin(), values.end());
173 
174  // First guess
175  double sum = 0.;
176  for(int i = 0; i < num; i++)
177  {
178  double weight = optimalWeight[num][i];
179  sum += weight * values[i];
180  }
181 
182  // Correct every deposit with log(path)
183  for(int i = 0; i < num; i++)
184  values_[i].first -= 0.178*log(values_[i].second/0.03) * 0.38 * sum;
185 
186  // Sort again
187  values.clear();
188  for(std::vector<pair<double,double> >::iterator
189  v = values_.begin(); v!= values_.end(); v++)
190  values.push_back((*v).first);
191  sort(values.begin(), values.end());
192 
193  // Corrected estimate
194  sum = 0.;
195  for(int i = 0; i < num; i++)
196  {
197  double weight = optimalWeight[num][i];
198  sum += weight * values[i];
199  }
200 
201  return sum;
202 }
int i
Definition: DBlmapReader.cc:9
U second(std::pair< T, U > const &p)
bool first
Definition: L1TdeRCT.cc:94
long long int num
Definition: procUtils.cc:71
static float optimalWeight[61][61]
int weight
Definition: histoStyle.py:50
void EnergyLossPlain::process ( LocalVector  ldir,
const SiPixelRecHit recHit,
std::vector< std::pair< double, double > > &  values 
)
private

Definition at line 213 of file EnergyLossPlain.cc.

References Surface::bounds(), PV3DBase< T, PVType, FrameType >::mag(), PixelTopology::ncolumns(), PixelTopology::nrows(), PixelGeomDetUnit::specificTopology(), GeomDet::surface(), Bounds::thickness(), makeHLTPrescaleTable::values, x, and PV3DBase< T, PVType, FrameType >::z().

Referenced by ConfigBuilder.ConfigBuilder::addExtraStream(), ConfigBuilder.ConfigBuilder::completeInputCommand(), ConfigBuilder.ConfigBuilder::doNotInlineEventContent(), ConfigBuilder.ConfigBuilder.PrintAllModules::leave(), ConfigBuilder.ConfigBuilder::prepare_FASTSIM(), ConfigBuilder.ConfigBuilder::prepare_HLT(), ConfigBuilder.ConfigBuilder::prepare_LHE(), ConfigBuilder.ConfigBuilder::prepare_VALIDATION(), ConfigBuilder.ConfigBuilder::renameHLTprocessInSequence(), ConfigBuilder.ConfigBuilder::renameInputTagsInSequence(), and ConfigBuilder.ConfigBuilder::scheduleSequence().

214 {
215  DetId id = recHit->geographicalId();
216  const PixelGeomDetUnit* pixelDet =
217  dynamic_cast<const PixelGeomDetUnit*> (theTracker->idToDet(id));
218 
219  // Check if cluster does not touch the edge
220  if(recHit->cluster()->minPixelRow() == 0 ||
221  recHit->cluster()->maxPixelRow() ==
222  pixelDet->specificTopology().nrows() - 1 ||
223  recHit->cluster()->minPixelCol() == 0 ||
224  recHit->cluster()->maxPixelCol() ==
225  pixelDet->specificTopology().ncolumns() - 1)
226  return;
227 
228  double MeVperElec = 3.61e-6;
229 
230  // Collect adc
231  double elec = recHit->cluster()->charge();
232  double Delta = elec * MeVperElec;
233 
234  // Length
235  double x = ldir.mag()/fabsf(ldir.z()) *
236  pixelDet->surface().bounds().thickness();
237 
238  double pix = Delta/x;
239 
240  // MeV/cm, only if not low deposit
241  if(pix > 1.5 * 0.795)
242  values.push_back(std::pair<double,double>(pix, x));
243 }
virtual int ncolumns() const =0
virtual int nrows() const =0
const Bounds & bounds() const
Definition: Surface.h:128
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
virtual float thickness() const =0
T mag() const
Definition: PV3DBase.h:67
T z() const
Definition: PV3DBase.h:64
const TrackerGeometry * theTracker
virtual const GeomDet * idToDet(DetId) const
Definition: DetId.h:20
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
Definition: DDAxes.h:10
void EnergyLossPlain::process ( LocalVector  ldir,
const SiStripRecHit2D *  recHit,
std::vector< std::pair< double, double > > &  values 
)
private

Definition at line 247 of file EnergyLossPlain.cc.

References begin, Surface::bounds(), delta, end, i, PV3DBase< T, PVType, FrameType >::mag(), StripTopology::nstrips(), StripGeomDetUnit::specificTopology(), GeomDet::surface(), Bounds::thickness(), Tmax, makeHLTPrescaleTable::values, x, and PV3DBase< T, PVType, FrameType >::z().

Referenced by ConfigBuilder.ConfigBuilder::addExtraStream(), ConfigBuilder.ConfigBuilder::completeInputCommand(), ConfigBuilder.ConfigBuilder::doNotInlineEventContent(), ConfigBuilder.ConfigBuilder.PrintAllModules::leave(), ConfigBuilder.ConfigBuilder::prepare_FASTSIM(), ConfigBuilder.ConfigBuilder::prepare_HLT(), ConfigBuilder.ConfigBuilder::prepare_LHE(), ConfigBuilder.ConfigBuilder::prepare_VALIDATION(), ConfigBuilder.ConfigBuilder::renameHLTprocessInSequence(), ConfigBuilder.ConfigBuilder::renameInputTagsInSequence(), and ConfigBuilder.ConfigBuilder::scheduleSequence().

248 {
249  DetId id = recHit->geographicalId();
250  const StripGeomDetUnit* stripDet =
251  dynamic_cast<const StripGeomDetUnit*> (theTracker->idToDet(id));
252 
253  // Check if cluster does not touch the edge
254  if(recHit->cluster()->firstStrip() == 0 ||
255  int(recHit->cluster()->firstStrip() +
256  recHit->cluster()->amplitudes().size()) ==
257  stripDet->specificTopology().nstrips())
258  return;
259 
260  double MeVperAdc = 313 * 3.61e-6;
261 
262  // Collect adc
263  double Delta = 0;
264 // for(std::vector<uint16_t>::const_iterator
265  for(std::vector<uint8_t>::const_iterator
266  i = (recHit->cluster()->amplitudes()).begin();
267  i!= (recHit->cluster()->amplitudes()).end(); i++)
268  {
269  // MeV
270  double delta = (*i + 0.5) * MeVperAdc;
271 
272  if(*i >= 254)
273  {
274  double delta1, delta2;
275  if(*i == 254) { delta1 = 254 * MeVperAdc; delta2 = 512 * MeVperAdc; }
276  else { delta1 = 512 * MeVperAdc; delta2 = Tmax; }
277 
278  delta = expected(delta1,delta2);
279  }
280 
281  Delta += delta;
282  }
283 
284  // Length
285  double x = ldir.mag()/fabsf(ldir.z()) *
286  stripDet->surface().bounds().thickness();
287 
288  double str = Delta/x;
289 
290  // MeV/cm, only if not low deposit
291  if(str > 1.5)
292  values.push_back(std::pair<double,double>(str, x));
293 }
dbl * delta
Definition: mlp_gen.cc:36
virtual int nstrips() const =0
int i
Definition: DBlmapReader.cc:9
#define Tmax
const Bounds & bounds() const
Definition: Surface.h:128
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
virtual float thickness() const =0
T mag() const
Definition: PV3DBase.h:67
T z() const
Definition: PV3DBase.h:64
#define end
Definition: vmac.h:38
const TrackerGeometry * theTracker
virtual const GeomDet * idToDet(DetId) const
Definition: DetId.h:20
double expected(double Delta1, double Delta2)
#define begin
Definition: vmac.h:31
Definition: DDAxes.h:10
double EnergyLossPlain::truncate ( std::vector< std::pair< double, double > > &  values)
private

Definition at line 138 of file EnergyLossPlain.cc.

References i, python.multivaluedict::sort(), findQualityFiles::v, makeHLTPrescaleTable::values, and histoStyle::weight.

139 {
140  std::vector<double> values;
141  for(std::vector<pair<double,double> >::iterator
142  v = values_.begin(); v!= values_.end(); v++)
143  values.push_back((*v).first);
144 
145  sort(values.begin(), values.end());
146 
147  int num = values.size();
148  double sum[2] = {0.,0.};
149 
150  for(int i = 0; i < (num+1)/2; i++)
151  {
152  double weight = 1.;
153 
154  if(num%2 == 1 && i == (num-1)/2) weight = 1./2;
155 
156  sum[1] += weight * values[i];
157  sum[0] += weight;
158  }
159 
160  return sum[1] / sum[0];
161 }
int i
Definition: DBlmapReader.cc:9
long long int num
Definition: procUtils.cc:71
int weight
Definition: histoStyle.py:50

Member Data Documentation

bool EnergyLossPlain::isFirst = true
staticprivate

Definition at line 40 of file EnergyLossPlain.h.

float EnergyLossPlain::optimalWeight
staticprivate

Definition at line 41 of file EnergyLossPlain.h.

Referenced by loadOptimalWeights().

double EnergyLossPlain::pixelToStripExponent
private

Definition at line 38 of file EnergyLossPlain.h.

double EnergyLossPlain::pixelToStripMultiplier
private

Definition at line 38 of file EnergyLossPlain.h.

const TrackerGeometry* EnergyLossPlain::theTracker
private

Definition at line 37 of file EnergyLossPlain.h.