CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/Geometry/CSCGeometry/src/CSCGeometry.cc

Go to the documentation of this file.
00001 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
00002 #include "Geometry/CSCGeometry/interface/CSCChamber.h"
00003 #include "Geometry/CSCGeometry/interface/CSCChamberSpecs.h"
00004 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h"
00007 
00008 #include <string>
00009 
00010 CSCGeometry::CSCGeometry():  debugV_(false), gangedstripsME1a_(true), 
00011    onlywiresME1a_(false), realWireGeometry_(true), useCentreTIOffsets_(false) {
00012    if ( debugV_ ) queryModelling();
00013 }
00014 
00015 CSCGeometry::CSCGeometry( bool dbgv, bool gangedstripsME1a, bool onlywiresME1a, bool realWireGeometry, bool useCentreTIOffsets ) :  
00016    debugV_(dbgv), gangedstripsME1a_( gangedstripsME1a ), onlywiresME1a_( onlywiresME1a ), 
00017    realWireGeometry_( realWireGeometry ), useCentreTIOffsets_( useCentreTIOffsets ) {
00018    if ( debugV_ ) queryModelling();
00019 }
00020 
00021 CSCGeometry::~CSCGeometry(){
00022 
00023   // delete all the chambers (which will delete the layers)
00024   for (ChamberContainer::const_iterator ich=theChambers.begin();
00025        ich!=theChambers.end(); ++ich) delete (*ich);
00026 
00027   // delete specs
00028   for ( CSCSpecsContainer::const_iterator it =
00029            specsContainer.begin(); it!=specsContainer.end(); ++it) {
00030     delete (*it).second; // they are never shared per chamber type so should be no possible double deletion.
00031   }
00032 
00033 }  
00034 
00035 
00036 void CSCGeometry::addChamber(CSCChamber* ch){
00037   theChambers.push_back(ch);
00038   addDet(ch);
00039 }
00040 
00041 
00042 void CSCGeometry::addLayer(CSCLayer* l) {
00043   theDetUnits.push_back(l);
00044   theLayers.push_back(l);
00045   theDetTypes.push_back(const_cast<GeomDetType*>(&(l->type()))); //@@ FIXME drop const_cast asap!
00046   theDetUnitIds.push_back(l->geographicalId());
00047   addDet(l);
00048 }
00049 
00050 
00051 void CSCGeometry::addDetType(GeomDetType* type) {
00052   theDetTypes.push_back(type);
00053 }
00054 
00055 
00056 void CSCGeometry::addDet(GeomDet* det){
00057   theDets.push_back(det);  
00058   theDetIds.push_back(det->geographicalId());
00059   theMap.insert(CSCDetMap::value_type(det->geographicalId(),det));
00060 }
00061 
00062 
00063 const CSCGeometry::DetTypeContainer& CSCGeometry::detTypes() const 
00064 {
00065   return theDetTypes;
00066 }
00067 
00068 
00069 const CSCGeometry::DetUnitContainer& CSCGeometry::detUnits() const
00070 {
00071   return theDetUnits;
00072 }
00073 
00074 
00075 const CSCGeometry::DetContainer& CSCGeometry::dets() const
00076 {
00077   return theDets;
00078 }
00079 
00080 
00081 const CSCGeometry::DetIdContainer& CSCGeometry::detUnitIds() const 
00082 {
00083   return theDetUnitIds;
00084 }
00085 
00086 
00087 const CSCGeometry::DetIdContainer& CSCGeometry::detIds() const 
00088 {
00089   return theDetIds;
00090 }
00091 
00092 
00093 const GeomDetUnit* CSCGeometry::idToDetUnit(DetId id) const
00094 {
00095   return dynamic_cast<const GeomDetUnit*>(idToDet(id));
00096 }
00097 
00098 
00099 const GeomDet* CSCGeometry::idToDet(DetId id) const{
00100   CSCDetMap::const_iterator i = theMap.find(id);
00101   return (i != theMap.end()) ?
00102     i->second : 0 ;
00103 }
00104 
00105 
00106 const CSCGeometry::ChamberContainer& CSCGeometry::chambers() const
00107 {
00108   return theChambers;
00109 }
00110 
00111 
00112 const CSCGeometry::LayerContainer& CSCGeometry::layers() const
00113 {
00114   return theLayers;
00115 }
00116 
00117 
00118 const CSCChamber* CSCGeometry::chamber(CSCDetId id) const {
00119   CSCDetId id1(id.endcap(), id.station(), id.ring(), id.chamber(), 0);
00120   return dynamic_cast<const CSCChamber*>(idToDet(id1));
00121 }
00122 
00123 
00124 const CSCLayer* CSCGeometry::layer(CSCDetId id) const {
00125   return dynamic_cast<const CSCLayer*>(idToDetUnit(id));
00126 }
00127 
00128 void CSCGeometry::queryModelling() const {
00129   // Dump user-selected overall modelling parameters.
00130   // Only requires calling once per job.
00131 
00132   LogTrace("CSCGeometry|CSC")  << "CSCGeometry::queryModelling entered...";
00133 
00134   edm::LogInfo("CSC") << "CSCGeometry version 18-Oct-2012 queryModelling...\n";
00135 
00136   std::string gs = " ";
00137   if ( gangedstripsME1a_ )
00138     gs = "GANGED";
00139   else
00140     gs = "UNGANGED";
00141 
00142   edm::LogInfo("CSC") << "CSCGeometry: in ME1a use " << gs << " strips" << "\n";
00143 
00144   std::string wo = " ";
00145   if ( onlywiresME1a_ )
00146     wo = "WIRES ONLY";
00147   else
00148     wo = "WIRES & STRIPS";
00149 
00150   edm::LogInfo("CSC") << "CSCGeometry: in ME1a use  " << wo << "\n";
00151 
00152   std::string wg = " ";
00153   if ( realWireGeometry_ )
00154     wg = "REAL";
00155   else
00156     wg = "PSEUDO";
00157 
00158   edm::LogInfo("CSC") << "CSCGeometry: wires are modelled using " << wg << " wire geometry " << "\n";
00159 
00160   std::string cti = " ";
00161   if ( useCentreTIOffsets_ )
00162     cti = "WITH";
00163   else
00164     cti = "WITHOUT";
00165 
00166   edm::LogInfo("CSC") << "CSCGeometry: strip plane centre-to-intersection ideal " << cti << " corrections " << "\n";
00167 }
00168 
00169 const CSCChamberSpecs* CSCGeometry::findSpecs( int iChamberType ) {
00170   const CSCChamberSpecs* aSpecs = 0;
00171   CSCSpecsContainer::const_iterator it = specsContainer.find( iChamberType );
00172   if (  it != specsContainer.end() )  aSpecs = (*it).second;
00173   return aSpecs;
00174 } 
00175 
00176 const CSCChamberSpecs* CSCGeometry::buildSpecs( int iChamberType,
00177                                          const std::vector<float>& fpar,
00178                                          const std::vector<float>& fupar,
00179                                          const CSCWireGroupPackage& wg ) {
00180 
00181   // Note arg list order is hbot, htop, apothem, hthickness
00182   TrapezoidalPlaneBounds bounds( fpar[0], fpar[1], fpar[3], fpar[2] );
00183   const CSCChamberSpecs* aSpecs = new CSCChamberSpecs( this, iChamberType, bounds, fupar, wg );
00184   specsContainer[ iChamberType ] = aSpecs;
00185   return aSpecs;
00186 }