CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/CalibTracker/SiStripESProducers/plugins/geom/SiStripRegionConnectivity.cc

Go to the documentation of this file.
00001 #include "CalibTracker/SiStripESProducers/plugins/geom/SiStripRegionConnectivity.h"
00002 #include "FWCore/Framework/interface/ESHandle.h"
00003 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00004 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
00005 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00006 #include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
00007 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
00008 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
00009 
00010 using namespace sistrip;
00011 
00012 SiStripRegionConnectivity::SiStripRegionConnectivity(const edm::ParameterSet& pset) :
00013 
00014   etadivisions_(pset.getUntrackedParameter<unsigned int>("EtaDivisions",10)),
00015   phidivisions_(pset.getUntrackedParameter<unsigned int>("PhiDivisions",10)),
00016   etamax_(pset.getUntrackedParameter<double>("EtaMax",2.4))
00017 
00018 {
00019   setWhatProduced(this, &SiStripRegionConnectivity::produceRegionCabling);
00020 }
00021 
00022 SiStripRegionConnectivity::~SiStripRegionConnectivity() {}
00023 
00024 std::auto_ptr<SiStripRegionCabling> SiStripRegionConnectivity::produceRegionCabling( const SiStripRegionCablingRcd& iRecord ) {
00025 
00026   edm::ESHandle<SiStripDetCabling> detcabling;
00027   iRecord.getRecord<SiStripDetCablingRcd>().get( detcabling );
00028 
00029   edm::ESHandle<TrackerGeometry> tkgeom;
00030   iRecord.getRecord<TrackerDigiGeometryRecord>().get( tkgeom );
00031   
00032   //here build an object of type SiStripRegionCabling using the information from class SiStripDetCabling **PLUS** the geometry.
00033   
00034   //Construct region cabling object
00035   SiStripRegionCabling* RegionConnections = new SiStripRegionCabling(etadivisions_,phidivisions_,etamax_);
00036 
00037   //Construct region cabling map
00038   SiStripRegionCabling::Cabling regioncabling(etadivisions_*phidivisions_,SiStripRegionCabling::RegionCabling(SiStripRegionCabling::ALLSUBDETS,SiStripRegionCabling::WedgeCabling(SiStripRegionCabling::ALLLAYERS,SiStripRegionCabling::ElementCabling())));
00039   
00040   //Loop det cabling
00041   std::map< uint32_t, std::vector<const FedChannelConnection *> >::const_iterator idet = detcabling->getDetCabling().begin();
00042   for (;idet!=detcabling->getDetCabling().end();idet++) {
00043     if (!idet->first || (idet->first == sistrip::invalid32_)) continue;
00044 
00045     // Check if geom det unit exists
00046     GeomDetUnit* geom_det = const_cast<GeomDetUnit*>( tkgeom->idToDetUnit(DetId(idet->first)) );
00047     StripGeomDetUnit* strip_det = dynamic_cast<StripGeomDetUnit*>( geom_det );
00048     if ( !strip_det ) { continue; }
00049     
00050     //Calculate region from geometry
00051     double eta = tkgeom->idToDet(DetId(idet->first))->position().eta();
00052     double phi = tkgeom->idToDet(DetId(idet->first))->position().phi().value();
00053     uint32_t reg = RegionConnections->region(SiStripRegionCabling::Position(eta,phi));
00054   
00055     //Find subdet from det-id 
00056     uint32_t subdet = static_cast<uint32_t>(SiStripRegionCabling::subdetFromDetId(idet->first));
00057     
00058     //Find layer from det-id
00059     uint32_t layer = SiStripRegionCabling::layerFromDetId(idet->first);
00060 
00061     //@@ BELOW IS TEMP FIX TO HANDLE BUG IN DET CABLING
00062     std::vector<const FedChannelConnection *> conns = idet->second;
00063     std::vector<const FedChannelConnection *>::iterator iconn = conns.begin();
00064     std::vector<const FedChannelConnection *>::iterator jconn = conns.end();
00065 
00066     //Update region cabling map
00067     regioncabling[reg][subdet][layer][idet->first].resize(conns.size());
00068     for ( ; iconn != jconn; ++iconn ) {
00069       if ( ((*iconn) != 0) && ((*iconn)->apvPairNumber() < conns.size()) ) { 
00070         regioncabling[reg][subdet][layer][idet->first][(*iconn)->apvPairNumber()] = **iconn;
00071       }
00072     }
00073   }
00074 
00075   //Add map to region cabling object
00076   RegionConnections->setRegionCabling(regioncabling);
00077   
00078   return std::auto_ptr<SiStripRegionCabling>( RegionConnections );
00079 }
00080