CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/RecoTracker/TkMSParametrization/src/MSLayersKeeperX0DetLayer.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkMSParametrization/interface/MSLayersKeeperX0DetLayer.h"
00002 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00003 #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
00004 #include "TrackingTools/DetLayers/interface/ForwardDetLayer.h"
00005 #include "DataFormats/GeometrySurface/interface/BoundSurface.h"
00006 #include "DataFormats/GeometrySurface/interface/MediumProperties.h"
00007 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00008 
00009 #include <vector>
00010 
00011 using namespace std;
00012 
00013 void MSLayersKeeperX0DetLayer::init(const edm::EventSetup &iSetup)
00014 {
00015   if (isInitialised) return;
00016   isInitialised = true;
00017   //  vector<MSLayer> allLayers = MSLayersKeeperX0DetLayerGeom().detLayers();
00018   //MP
00019   vector<MSLayer> allLayers;
00020   theLayersData = MSLayersAtAngle(allLayers);
00021   
00022   vector<MSLayer>::iterator it;
00023   PixelRecoPointRZ zero(0.,0.); 
00024   for (it = allLayers.begin(); it != allLayers.end(); it++) {
00025     PixelRecoPointRZ middle = it->face()== GeomDetEnumerators::barrel ?
00026         PixelRecoPointRZ(it->position(), it->range().mean())
00027       : PixelRecoPointRZ(it->range().mean(), it->position());
00028 
00029     float cotTheta = PixelRecoLineRZ(zero,middle).cotLine();
00030     float x0 =  getDataX0(*it).x0;
00031 
00032     DataX0 dataX0;
00033     if (it->face()== GeomDetEnumerators::barrel) {
00034       float sumX0D = theLayersData.sumX0D(zero, middle);
00035       dataX0 = DataX0(x0, sumX0D, cotTheta);      
00036     } else {
00037       float hrange= (it->range().max()-it->range().min())/2.;
00038       float cot1 = it->position()/(it->range().mean()-hrange/2);
00039       float cot2 = it->position()/(it->range().mean()+hrange/2);
00040       PixelRecoLineRZ line1(zero,cot1);
00041       PixelRecoLineRZ line2(zero,cot2);
00042       float sum1 = theLayersData.sumX0D(zero,it->crossing(line1).first);
00043       float sum2 = theLayersData.sumX0D(zero,it->crossing(line2).first);
00044       float slope = (sum2-sum1)/(1/cot2-1/cot1);
00045       float sumX0D = sum1 + slope*(1/cotTheta-1/cot1);
00046       dataX0 = DataX0(x0, sumX0D, cotTheta);
00047       dataX0.setForwardSumX0DSlope(slope);
00048     }
00049     setDataX0(*it, dataX0);
00050     theLayersData.update(*it);
00051   }
00052   cout << "MSLayersKeeperX0DetLayer LAYERS: "<<endl;
00053   theLayersData.print();
00054 }
00055 
00056 // vector<MSLayer>
00057 // MSLayersKeeperX0DetLayer::MSLayersKeeperX0DetLayerGeom::detLayers() const
00058 // {
00059 
00060 //   vector<MSLayer> result;
00061 
00062 //   vector<const DetLayer*>::const_iterator it;
00063 //   for (it = theLayers.begin(); it != theLayers.end(); it++) {
00064 
00065 //     //    const DetUnit * du = (*it)->detUnits().front();
00066 //     const GeomDetUnit * du;
00067 //     //MP how access the geomdetunit??
00068 //    const MediumProperties * mp = du->surface().mediumProperties();
00069 //     float x0 = (mp) ? mp->radLen() : 0.03; 
00070 //     cout << "MediumProperties: "<<mp<<" x0="<<x0<<endl;
00071 //     MSLayer layer(*it, DataX0(x0,0,0));
00072 //     result.push_back( layer);
00073 //   }
00074 //   return result;
00075 // } 
00076