CMS 3D CMS Logo

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