53 double pixelToStripMultiplier_,
54 double pixelToStripExponent_ ) : theTracker(theTracker_),
55 pixelToStripMultiplier(pixelToStripMultiplier_),
56 pixelToStripExponent (pixelToStripExponent_ )
76 fileInPath(
"QCDAnalysis/ChargedHadronSpectra/data/energyWeights.dat");
77 ifstream inFile(fileInPath.
fullPath().c_str());
79 while(inFile.eof() ==
false)
81 int i;
float w;
int n;
92 <<
" [EnergyLossEstimator] optimal weights loaded";
99 double sum[2] = {0.,0.};
101 for(
int i = 0;
i <
num;
i++)
107 return sum[1] / sum[0];
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);
118 sort(values.begin(), values.end());
120 int num = values.size();
121 double sum[2] = {0.,1.};
123 for(
int i = 0;
i < (num+1)/2;
i++)
127 if(num%2 == 1 &&
i == (num-1)/2) weight = 1./2;
129 sum[1] *=
pow(values[
i], weight);
134 return pow(sum[1], 1./sum[0]);
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);
145 sort(values.begin(), values.end());
147 int num = values.size();
148 double sum[2] = {0.,0.};
150 for(
int i = 0;
i < (num+1)/2;
i++)
154 if(num%2 == 1 &&
i == (num-1)/2) weight = 1./2;
156 sum[1] += weight * values[
i];
160 return sum[1] / sum[0];
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);
171 int num = values.size();
172 sort(values.begin(), values.end());
176 for(
int i = 0;
i <
num;
i++)
179 sum += weight * values[
i];
183 for(
int i = 0;
i <
num;
i++)
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());
195 for(
int i = 0;
i <
num;
i++)
198 sum += weight * values[
i];
207 return log(Delta2/Delta1) / (1/Delta1 - 1/Delta2);
220 if(recHit->
cluster()->minPixelRow() == 0 ||
221 recHit->
cluster()->maxPixelRow() ==
223 recHit->
cluster()->minPixelCol() == 0 ||
224 recHit->
cluster()->maxPixelCol() ==
228 double MeVperElec = 3.61e-6;
231 double elec = recHit->
cluster()->charge();
232 double Delta = elec * MeVperElec;
235 double x = ldir.
mag()/fabsf(ldir.
z()) *
238 double pix = Delta/
x;
241 if(pix > 1.5 * 0.795)
242 values.push_back(std::pair<double,double>(pix, x));
254 if(recHit->
cluster()->firstStrip() == 0 ||
255 int(recHit->
cluster()->firstStrip() +
256 recHit->
cluster()->amplitudes().size()) ==
260 double MeVperAdc = 313 * 3.61e-6;
265 for(std::vector<uint8_t>::const_iterator
270 double delta = (*
i + 0.5) * MeVperAdc;
274 double delta1, delta2;
275 if(*
i == 254) { delta1 = 254 * MeVperAdc; delta2 = 512 * MeVperAdc; }
276 else { delta1 = 512 * MeVperAdc; delta2 =
Tmax; }
278 delta = expected(delta1,delta2);
285 double x = ldir.
mag()/fabsf(ldir.
z()) *
288 double str = Delta/
x;
292 values.push_back(std::pair<double,double>(str, x));
297 (
const Trajectory* trajectory, std::vector<pair<int,double> >& arithmeticMean,
298 std::vector<pair<int,double> >& truncatedMean)
301 std::vector<pair<double,double> > vpix,vstr;
303 for(std::vector<TrajectoryMeasurement>::const_iterator
312 LocalVector ldir = meas->updatedState().localDirection();
314 if(theTracker->idToDet(
id)->subDetector() ==
316 theTracker->idToDet(
id)->subDetector() ==
324 process(ldir,pixelRecHit , vpix);
336 std::pair<double,double>
v;
338 if(stripMatchedRecHit != 0)
344 if(stripProjectedRecHit != 0)
348 process(ldir,stripRecHit, vstr);
354 std::vector<pair<double,double> > vall;
356 for(
unsigned int i = 0;
i < vpix.size();
i++)
361 std::pair<double,double> str(vpix[
i]);
363 double y = str.first / a /
s;
364 if(y > 0.9999) y = 0.9999;
365 if(y <-0.9999) y = -0.9999;
367 str.first = s * atanh(y);
372 for(
unsigned int i = 0;
i < vstr.size();
i++) vall.push_back(vstr[
i]);
375 arithmeticMean.push_back(std::pair<int,double>(vpix.size(),
average(vpix)));
376 arithmeticMean.push_back(std::pair<int,double>(vstr.size(),
average(vstr)));
377 arithmeticMean.push_back(std::pair<int,double>(vall.size(),
average(vall)));
380 truncatedMean.push_back(std::pair<int,double>(vpix.size(), optimal(vpix)));
381 truncatedMean.push_back(std::pair<int,double>(vstr.size(), optimal(vstr)));
382 truncatedMean.push_back(std::pair<int,double>(vall.size(), optimal(vall)));
virtual int nstrips() const =0
double truncate(std::vector< std::pair< double, double > > &values)
virtual int ncolumns() const =0
void loadOptimalWeights()
double optimal(std::vector< std::pair< double, double > > &values)
const SiStripRecHit2D * stereoHit() const
virtual int nrows() const =0
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
void process(LocalVector ldir, const SiPixelRecHit *recHit, std::vector< std::pair< double, double > > &values)
int estimate(const Trajectory *trajectory, std::vector< std::pair< int, double > > &arithmeticMean, std::vector< std::pair< int, double > > &truncatedMean)
Vector2DBase< float, GlobalTag > Global2DVector
virtual float thickness() const =0
U second(std::pair< T, U > const &p)
EnergyLossPlain(const TrackerGeometry *theTracker_, double pixelToStripMultiplier, double pixelToStripExponent)
DataContainer const & measurements() const
const Bounds & bounds() const
Log< T >::type log(const T &t)
double average(std::vector< std::pair< double, double > > &values)
double expected(double Delta1, double Delta2)
ClusterRef const & cluster() const
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
static float optimalWeight[61][61]
double logTruncate(std::vector< std::pair< double, double > > &values)
DetId geographicalId() const
std::string fullPath() const
const SiStripRecHit2D * monoHit() const
ClusterRef const & cluster() const
const SiStripRecHit2D & originalHit() const
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
Power< A, B >::type pow(const A &a, const B &b)