CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/RecoTracker/TkMSParametrization/src/MSLayersKeeperX0Averaged.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkMSParametrization/interface/MSLayersKeeperX0Averaged.h"
00002 #include "RecoTracker/TkMSParametrization/interface/MSLayersKeeperX0AtEta.h"
00003 #include "RecoTracker/TkMSParametrization/interface/MultipleScatteringGeometry.h"
00004 
00005 using namespace std;
00006 
00007 void MSLayersKeeperX0Averaged::init(const edm::EventSetup &iSetup)
00008 {
00009   if (isInitialised) return;
00010   isInitialised = true;
00011 //  cout << "HERE INITIALISATION! MSLayersKeeperX0Averaged"<<endl;
00012   MSLayersKeeperX0AtEta layersX0Eta;
00013   layersX0Eta.init(iSetup);
00014   MultipleScatteringGeometry geom(iSetup);
00015   vector<MSLayer> allLayers = geom.detLayers(iSetup);
00016   vector<MSLayer>::iterator it;
00017   for (int i=-1;i<=1;i++) {
00018     float eta = i*(-1.8);
00019     vector<MSLayer> tmpLayers = geom.otherLayers(eta,iSetup);
00020     vector<MSLayer>::const_iterator ic;
00021     for (ic = tmpLayers.begin(); ic != tmpLayers.end(); ic++) {
00022       it = find(allLayers.begin(), allLayers.end(), *ic);  
00023       if (it == allLayers.end()) allLayers.push_back(*ic);
00024     }
00025   }
00026 
00027   
00028 
00029 for (it = allLayers.begin(); it != allLayers.end(); it++) {
00030     float cotTheta = (it->face()==GeomDetEnumerators::barrel) ?
00031         it->range().mean()/it->position()
00032       : it->position()/it->range().mean();
00033 
00034     int nbins = 0;
00035     float sumX0 = 0.;
00036     for (int ibin = 0; ibin < 2*layersX0Eta.theHalfNBins; ibin++) { 
00037       const MSLayersAtAngle & layers = layersX0Eta.theLayersData[ibin];
00038       const MSLayer * aLayer = layers.findLayer(*it);
00039       if (aLayer) { nbins++; sumX0 += getDataX0(*aLayer).x0; }
00040     }
00041     if ( nbins==0) nbins=1;
00042 
00043     float hrange= (it->range().max()-it->range().min())/2.;
00044     DataX0 dataX0;
00045     if (it->face()==GeomDetEnumerators::endcap) {
00046       float cot1 = it->position()/(it->range().mean()-hrange/2); 
00047       float cot2 = it->position()/(it->range().mean()+hrange/2); 
00048       const MSLayer * aLayer1 = layersX0Eta.layers(cot1).findLayer(*it);
00049       const MSLayer * aLayer2 = layersX0Eta.layers(cot1).findLayer(*it);
00050       float sum1 = aLayer1 ? aLayer1->sumX0D(cot1) : 0.;
00051       float sum2 = aLayer2 ? aLayer2->sumX0D(cot2) : 0.;
00052       float slope = (sum2-sum1)/(1/cot2-1/cot1);
00053       float sumX0D = sum1 + slope*(1/cotTheta-1/cot1);
00054       dataX0 = DataX0(sumX0/nbins, sumX0D, cotTheta);
00055       dataX0.setForwardSumX0DSlope(slope);
00056     } else {
00057       float sumX0D = 0;
00058       int nb=10;
00059       for (int i=0; i<nb; i++) {
00060         float cot = (it->range().mean()+(2*i+1-nb)*hrange/nb)/it->position();
00061         float sin = 1/sqrt(1+cot*cot);
00062         const MSLayer * aLayer = layersX0Eta.layers(cot).findLayer(*it);
00063         if (aLayer) sumX0D += aLayer->sumX0D(cot) * sqrt(sin);
00064       } 
00065       dataX0 = DataX0(sumX0/nbins, sumX0D/nb, 0);
00066     }
00067     setDataX0(*it, dataX0);
00068   }
00069   theLayersData = MSLayersAtAngle(allLayers);
00070 //  cout << "MSLayersKeeperX0Averaged - LAYERS:"<<endl;
00071 //  theLayersData.print();
00072 //  cout << "END OF LAYERS"<<endl;
00073 }