CMS 3D CMS Logo

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