Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:24

0001 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
0002 #include "Geometry/CSCGeometry/interface/CSCChamber.h"
0003 #include "Geometry/CSCGeometry/interface/CSCChamberSpecs.h"
0004 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h"
0007 
0008 #include <string>
0009 
0010 CSCGeometry::CSCGeometry()
0011     : debugV_(false),
0012       gangedstripsME1a_(true),
0013       onlywiresME1a_(false),
0014       realWireGeometry_(true),
0015       useCentreTIOffsets_(false) {
0016   if (debugV_)
0017     queryModelling();
0018 }
0019 
0020 CSCGeometry::CSCGeometry(
0021     bool dbgv, bool gangedstripsME1a, bool onlywiresME1a, bool realWireGeometry, bool useCentreTIOffsets)
0022     : debugV_(dbgv),
0023       gangedstripsME1a_(gangedstripsME1a),
0024       onlywiresME1a_(onlywiresME1a),
0025       realWireGeometry_(realWireGeometry),
0026       useCentreTIOffsets_(useCentreTIOffsets) {
0027   if (debugV_)
0028     queryModelling();
0029 }
0030 
0031 CSCGeometry::~CSCGeometry() { deallocate(); }
0032 
0033 void CSCGeometry::clear() {
0034   deallocate();
0035 
0036   theChambers.clear();
0037   theMap.clear();
0038   theDetTypes.clear();
0039   theDets.clear();
0040   theDetUnits.clear();
0041   theDetIds.clear();
0042   theDetUnitIds.clear();
0043   theLayers.clear();
0044   specsContainer.clear();
0045 }
0046 
0047 void CSCGeometry::deallocate() {
0048   // delete all the chambers (which will delete the layers)
0049   for (ChamberContainer::const_iterator ich = theChambers.begin(); ich != theChambers.end(); ++ich)
0050     delete (*ich);
0051 
0052   // delete specs
0053   for (CSCSpecsContainer::const_iterator it = specsContainer.begin(); it != specsContainer.end(); ++it) {
0054     delete (*it).second;  // they are never shared per chamber type so should be no possible double deletion.
0055   }
0056 }
0057 
0058 void CSCGeometry::addChamber(CSCChamber* ch) {
0059   theChambers.emplace_back(ch);
0060   addDet(ch);
0061 }
0062 
0063 void CSCGeometry::addLayer(CSCLayer* l) {
0064   theDetUnits.emplace_back(l);
0065   theLayers.emplace_back(l);
0066   theDetTypes.emplace_back(l->chamber()->specs());
0067   theDetUnitIds.emplace_back(l->geographicalId());
0068   addDet(l);
0069 }
0070 
0071 void CSCGeometry::addDetType(GeomDetType* type) { theDetTypes.emplace_back(type); }
0072 
0073 void CSCGeometry::addDet(GeomDet* det) {
0074   theDets.emplace_back(det);
0075   theDetIds.emplace_back(det->geographicalId());
0076   theMap.insert(CSCDetMap::value_type(det->geographicalId(), det));
0077 }
0078 
0079 const CSCGeometry::DetTypeContainer& CSCGeometry::detTypes() const { return theDetTypes; }
0080 
0081 const CSCGeometry::DetContainer& CSCGeometry::detUnits() const { return theDetUnits; }
0082 
0083 const CSCGeometry::DetContainer& CSCGeometry::dets() const { return theDets; }
0084 
0085 const CSCGeometry::DetIdContainer& CSCGeometry::detUnitIds() const { return theDetUnitIds; }
0086 
0087 const CSCGeometry::DetIdContainer& CSCGeometry::detIds() const { return theDetIds; }
0088 
0089 const GeomDet* CSCGeometry::idToDetUnit(DetId id) const { return dynamic_cast<const GeomDet*>(idToDet(id)); }
0090 
0091 const GeomDet* CSCGeometry::idToDet(DetId id) const {
0092   CSCDetMap::const_iterator i = theMap.find(id);
0093   return (i != theMap.end()) ? i->second : nullptr;
0094 }
0095 
0096 const CSCGeometry::ChamberContainer& CSCGeometry::chambers() const { return theChambers; }
0097 
0098 const CSCGeometry::LayerContainer& CSCGeometry::layers() const { return theLayers; }
0099 
0100 const CSCChamber* CSCGeometry::chamber(CSCDetId id) const {
0101   CSCDetId id1(id.endcap(), id.station(), id.ring(), id.chamber(), 0);
0102   return dynamic_cast<const CSCChamber*>(idToDet(id1));
0103 }
0104 
0105 const CSCLayer* CSCGeometry::layer(CSCDetId id) const { return dynamic_cast<const CSCLayer*>(idToDetUnit(id)); }
0106 
0107 void CSCGeometry::queryModelling() const {
0108   // Dump user-selected overall modelling parameters.
0109   // Only requires calling once per job.
0110 
0111   LogTrace("CSCGeometry|CSC") << "CSCGeometry::queryModelling entered...";
0112 
0113   edm::LogInfo("CSC") << "CSCGeometry version 18-Oct-2012 queryModelling...\n";
0114 
0115   std::string gs = " ";
0116   if (gangedstripsME1a_)
0117     gs = "GANGED";
0118   else
0119     gs = "UNGANGED";
0120 
0121   edm::LogInfo("CSC") << "CSCGeometry: in ME1a use " << gs << " strips"
0122                       << "\n";
0123 
0124   std::string wo = " ";
0125   if (onlywiresME1a_)
0126     wo = "WIRES ONLY";
0127   else
0128     wo = "WIRES & STRIPS";
0129 
0130   edm::LogInfo("CSC") << "CSCGeometry: in ME1a use  " << wo << "\n";
0131 
0132   std::string wg = " ";
0133   if (realWireGeometry_)
0134     wg = "REAL";
0135   else
0136     wg = "PSEUDO";
0137 
0138   edm::LogInfo("CSC") << "CSCGeometry: wires are modelled using " << wg << " wire geometry "
0139                       << "\n";
0140 
0141   std::string cti = " ";
0142   if (useCentreTIOffsets_)
0143     cti = "WITH";
0144   else
0145     cti = "WITHOUT";
0146 
0147   edm::LogInfo("CSC") << "CSCGeometry: strip plane centre-to-intersection ideal " << cti << " corrections "
0148                       << "\n";
0149 }
0150 
0151 const CSCChamberSpecs* CSCGeometry::findSpecs(int iChamberType) {
0152   const CSCChamberSpecs* aSpecs = nullptr;
0153   CSCSpecsContainer::const_iterator it = specsContainer.find(iChamberType);
0154   if (it != specsContainer.end())
0155     aSpecs = (*it).second;
0156   return aSpecs;
0157 }
0158 
0159 const CSCChamberSpecs* CSCGeometry::buildSpecs(int iChamberType,
0160                                                const std::vector<float>& fpar,
0161                                                const std::vector<float>& fupar,
0162                                                const CSCWireGroupPackage& wg) {
0163   // Note arg list order is hbot, htop, apothem, hthickness
0164   TrapezoidalPlaneBounds bounds(fpar[0], fpar[1], fpar[3], fpar[2]);
0165   const CSCChamberSpecs* aSpecs = new CSCChamberSpecs(this, iChamberType, bounds, fupar, wg);
0166   specsContainer[iChamberType] = aSpecs;
0167   return aSpecs;
0168 }