CMS 3D CMS Logo

MSLayersKeeperX0Averaged.cc
Go to the documentation of this file.
4 
5 using namespace std;
6 
8  // cout << "HERE INITIALISATION! MSLayersKeeperX0Averaged"<<endl;
9  MSLayersKeeperX0AtEta layersX0Eta(tracker, bfield);
11  vector<MSLayer> allLayers = geom.detLayers();
12  vector<MSLayer>::iterator it;
13  for (int i = -1; i <= 1; i++) {
14  float eta = i * (-1.8);
15  vector<MSLayer> tmpLayers = geom.otherLayers(eta);
16  vector<MSLayer>::const_iterator ic;
17  for (ic = tmpLayers.begin(); ic != tmpLayers.end(); ic++) {
18  it = find(allLayers.begin(), allLayers.end(), *ic);
19  if (it == allLayers.end())
20  allLayers.push_back(*ic);
21  }
22  }
23 
24  for (it = allLayers.begin(); it != allLayers.end(); it++) {
25  float cotTheta = (it->face() == GeomDetEnumerators::barrel) ? it->range().mean() / it->position()
26  : it->position() / it->range().mean();
27 
28  int nbins = 0;
29  float sumX0 = 0.;
30  for (int ibin = 0; ibin < 2 * layersX0Eta.theHalfNBins; ibin++) {
31  const MSLayersAtAngle &layers = layersX0Eta.theLayersData[ibin];
32  const MSLayer *aLayer = layers.findLayer(*it);
33  if (aLayer) {
34  nbins++;
35  sumX0 += getDataX0(*aLayer).x0;
36  }
37  }
38  if (nbins == 0)
39  nbins = 1;
40 
41  float hrange = (it->range().max() - it->range().min()) / 2.;
42  DataX0 dataX0;
43  if (it->face() == GeomDetEnumerators::endcap) {
44  float cot1 = it->position() / (it->range().mean() - hrange / 2);
45  float cot2 = it->position() / (it->range().mean() + hrange / 2);
46  const MSLayer *aLayer1 = layersX0Eta.layers(cot1).findLayer(*it);
47  const MSLayer *aLayer2 = layersX0Eta.layers(cot1).findLayer(*it);
48  float sum1 = aLayer1 ? aLayer1->sumX0D(cot1) : 0.;
49  float sum2 = aLayer2 ? aLayer2->sumX0D(cot2) : 0.;
50  float slope = (sum2 - sum1) / (1 / cot2 - 1 / cot1);
51  float sumX0D = sum1 + slope * (1 / cotTheta - 1 / cot1);
52  dataX0 = DataX0(sumX0 / nbins, sumX0D, cotTheta);
53  dataX0.setForwardSumX0DSlope(slope);
54  } else {
55  float sumX0D = 0;
56  int nb = 10;
57  for (int i = 0; i < nb; i++) {
58  float cot = (it->range().mean() + (2 * i + 1 - nb) * hrange / nb) / it->position();
59  float sin = 1 / sqrt(1 + cot * cot);
60  const MSLayer *aLayer = layersX0Eta.layers(cot).findLayer(*it);
61  if (aLayer)
62  sumX0D += aLayer->sumX0D(cot) * sqrt(sin);
63  }
64  dataX0 = DataX0(sumX0 / nbins, sumX0D / nb, 0);
65  }
66  setDataX0(*it, dataX0);
67  }
68  theLayersData = MSLayersAtAngle(allLayers);
69  // cout << "MSLayersKeeperX0Averaged - LAYERS:"<<endl;
70  // theLayersData.print();
71  // cout << "END OF LAYERS"<<endl;
72 }
static const double slope[3]
MSLayer::DataX0 DataX0
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const MSLayersAtAngle & layers(float cotTheta) const override
const MSLayer * findLayer(const MSLayer &layer) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
static void setDataX0(MSLayer &l, const DataX0 &x0Data)
T sqrt(T t)
Definition: SSEVec.h:23
static const DataX0 & getDataX0(const MSLayer &l)
MSLayersKeeperX0Averaged(const GeometricSearchTracker &tracker, const MagneticField &bfield)
float sumX0D(float cotTheta) const
Definition: MSLayer.cc:144
std::vector< MSLayersAtAngle > theLayersData