CMS 3D CMS Logo

DDHGCalWaferF.cc
Go to the documentation of this file.
13 
14 #include <string>
15 #include <vector>
16 #include <sstream>
17 
18 //#define EDM_ML_DEBUG
19 
20 class DDHGCalWaferF : public DDAlgorithm {
21 public:
22  // Constructor and Destructor
23  DDHGCalWaferF();
24  ~DDHGCalWaferF() override;
25 
26  void initialize(const DDNumericArguments& nArgs,
27  const DDVectorArguments& vArgs,
28  const DDMapArguments& mArgs,
29  const DDStringArguments& sArgs,
30  const DDStringVectorArguments& vsArgs) override;
31  void execute(DDCompactView& cpv) override;
32 
33 private:
34  std::string material_; // Material name for module with gap
35  double thick_; // Module thickness
36  double waferSize_; // Wafer size
37  double waferSepar_; // Sensor separation
38  std::vector<std::string> layerNames_; // Names of the layers
39  std::vector<std::string> materials_; // Materials of the layers
40  std::vector<double> layerThick_; // Thickness of layers
41  std::vector<int> layerType_; // Layer types
42  std::vector<int> copyNumber_; // Initial copy numbers
43  std::vector<int> layers_; // Number of layers in a section
44  int nCells_; // Half number of cells along u-v axis
45  int cellType_; // Cell Type (0,1,2: Fine, Course 2/3)
46  std::vector<std::string> cellNames_; // Name of the cells
47  std::string nameSpace_; // Namespace to be used
48 };
49 
51 #ifdef EDM_ML_DEBUG
52  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferF: Creating an instance";
53 #endif
54 }
55 
57 
59  const DDVectorArguments& vArgs,
60  const DDMapArguments&,
61  const DDStringArguments& sArgs,
62  const DDStringVectorArguments& vsArgs) {
63  material_ = sArgs["ModuleMaterial"];
64  thick_ = nArgs["ModuleThickness"];
65  waferSize_ = nArgs["WaferSize"];
66  waferSepar_ = nArgs["SensorSeparation"];
67 #ifdef EDM_ML_DEBUG
68  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferF: Module " << parent().name() << " made of " << material_ << " T "
69  << thick_ << " Wafer 2r " << waferSize_ << " Half Separation " << waferSepar_;
70 #endif
71  layerNames_ = vsArgs["LayerNames"];
72  materials_ = vsArgs["LayerMaterials"];
73  layerThick_ = vArgs["LayerThickness"];
74  layerType_ = dbl_to_int(vArgs["LayerTypes"]);
75  copyNumber_.resize(materials_.size(), 1);
76 #ifdef EDM_ML_DEBUG
77  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferF: " << layerNames_.size() << " types of volumes";
78  for (unsigned int i = 0; i < layerNames_.size(); ++i)
79  edm::LogVerbatim("HGCalGeom") << "Volume [" << i << "] " << layerNames_[i] << " of thickness " << layerThick_[i]
80  << " filled with " << materials_[i] << " type " << layerType_[i];
81 #endif
82  layers_ = dbl_to_int(vArgs["Layers"]);
83 #ifdef EDM_ML_DEBUG
84  std::ostringstream st1;
85  for (unsigned int i = 0; i < layers_.size(); ++i)
86  st1 << " [" << i << "] " << layers_[i];
87  edm::LogVerbatim("HGCalGeom") << "There are " << layers_.size() << " blocks" << st1.str();
88 #endif
89  nCells_ = (int)(nArgs["NCells"]);
90  cellType_ = (int)(nArgs["CellType"]);
91  cellNames_ = vsArgs["CellNames"];
93 #ifdef EDM_ML_DEBUG
94  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferF: Cells/Wafer " << nCells_ << " Cell Type " << cellType_
95  << " NameSpace " << nameSpace_ << " # of cells " << cellNames_.size();
96  for (unsigned int k = 0; k < cellNames_.size(); ++k)
97  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferF: Cell[" << k << "] " << cellNames_[k];
98 #endif
99 }
100 
102 #ifdef EDM_ML_DEBUG
103  edm::LogVerbatim("HGCalGeom") << "==>> Executing DDHGCalWaferF...";
104 #endif
105 
106  static constexpr double tol = 0.00001;
107  static const double sqrt3 = std::sqrt(3.0);
108  double rM = 0.5 * (waferSize_ + waferSepar_);
109  double RM2 = rM / sqrt3;
110  double R = waferSize_ / (3.0 * nCells_);
111  double r = 0.5 * R * sqrt3;
112  double r2 = 0.5 * waferSize_;
113  double R2 = r2 / sqrt3;
114 
115  // First the mother
116  std::vector<double> xM = {rM, 0, -rM, -rM, 0, rM};
117  std::vector<double> yM = {RM2, 2 * RM2, RM2, -RM2, -2 * RM2, -RM2};
118  std::vector<double> zw = {-0.5 * thick_, 0.5 * thick_};
119  std::vector<double> zx(2, 0), zy(2, 0), scale(2, 1.0);
120  DDName parentName = parent().name();
121  DDSolid solid = DDSolidFactory::extrudedpolygon(parentName, xM, yM, zw, zx, zy, scale);
123  DDMaterial matter(matName);
124  DDLogicalPart glogM = DDLogicalPart(solid.ddname(), matter, solid);
125 #ifdef EDM_ML_DEBUG
126  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferF: " << solid.name() << " extruded polygon made of " << matName
127  << " z|x|y|s (0) " << zw[0] << ":" << zx[0] << ":" << zy[0] << ":" << scale[0]
128  << " z|x|y|s (1) " << zw[1] << ":" << zx[1] << ":" << zy[1] << ":" << scale[1]
129  << " and " << xM.size() << " edges";
130  for (unsigned int k = 0; k < xM.size(); ++k)
131  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << xM[k] << ":" << yM[k];
132 #endif
133 
134  // Then the types
135  std::vector<double> xL = {r2, 0, -r2, -r2, 0, r2};
136  std::vector<double> yL = {R2, 2 * R2, R2, -R2, -2 * R2, -R2};
137  std::vector<DDLogicalPart> glogs(materials_.size());
138  double zi(-0.5 * thick_), thickTot(0.0);
139  for (unsigned int l = 0; l < layers_.size(); l++) {
140  unsigned int i = layers_[l];
141  if (copyNumber_[i] == 1) {
142  zw[0] = -0.5 * layerThick_[i];
143  zw[1] = 0.5 * layerThick_[i];
144  solid = DDSolidFactory::extrudedpolygon(layerNames_[i], xL, yL, zw, zx, zy, scale);
146  DDMaterial matter(matN);
147  glogs[i] = DDLogicalPart(solid.ddname(), matter, solid);
148 #ifdef EDM_ML_DEBUG
149  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferF: " << solid.name() << " extruded polygon made of " << matN
150  << " z|x|y|s (0) " << zw[0] << ":" << zx[0] << ":" << zy[0] << ":" << scale[0]
151  << " z|x|y|s (1) " << zw[1] << ":" << zx[1] << ":" << zy[1] << ":" << scale[1]
152  << " and " << xL.size() << " edges";
153  for (unsigned int k = 0; k < xL.size(); ++k)
154  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << xL[k] << ":" << yL[k];
155 #endif
156  }
157  DDTranslation tran0(0, 0, (zi + 0.5 * layerThick_[i]));
158  DDRotation rot;
159  cpv.position(glogs[i], glogM, copyNumber_[i], tran0, rot);
160 #ifdef EDM_ML_DEBUG
161  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferF: " << glogs[i].name() << " number " << copyNumber_[i]
162  << " positioned in " << glogM.name() << " at " << tran0 << " with no rotation";
163 #endif
164  ++copyNumber_[i];
165  zi += layerThick_[i];
166  thickTot += layerThick_[i];
167  if (layerType_[i] > 0) {
168  for (int u = 0; u < 2 * nCells_; ++u) {
169  for (int v = 0; v < 2 * nCells_; ++v) {
170  if (((v - u) < nCells_) && (u - v) <= nCells_) {
171  int n2 = nCells_ / 2;
172  double yp = (u - 0.5 * v - n2) * 2 * r;
173  double xp = (1.5 * (v - nCells_) + 1.0) * R;
174  int cell(0);
175  if ((u == 0) && (v == 0))
176  cell = 7;
177  else if ((u == 0) && (v == nCells_ - 1))
178  cell = 8;
179  else if ((u == nCells_) && (v == 2 * nCells_ - 1))
180  cell = 9;
181  else if ((u == 2 * nCells_ - 1) && (v == 2 * nCells_ - 1))
182  cell = 10;
183  else if ((u == 2 * nCells_ - 1) && (v == nCells_ - 1))
184  cell = 11;
185  else if ((u == nCells_) && (v == 0))
186  cell = 12;
187  else if (u == 0)
188  cell = 1;
189  else if ((v - u) == (nCells_ - 1))
190  cell = 4;
191  else if (v == (2 * nCells_ - 1))
192  cell = 2;
193  else if (u == (2 * nCells_ - 1))
194  cell = 5;
195  else if ((u - v) == nCells_)
196  cell = 3;
197  else if (v == 0)
198  cell = 6;
199  DDTranslation tran(xp, yp, 0);
201  cpv.position(DDName(cellNames_[cell]), glogs[i], copy, tran, rot);
202 #ifdef EDM_ML_DEBUG
203  edm::LogVerbatim("HGCalGeom")
204  << "DDHGCalWaferF: " << cellNames_[cell] << " number " << copy << " positioned in " << glogs[i].name()
205  << " at " << tran << " with no rotation";
206 #endif
207  }
208  }
209  }
210  }
211  }
212  if (std::abs(thickTot - thick_) >= tol) {
213  if (thickTot > thick_) {
214  edm::LogError("HGCalGeom") << "Thickness of the partition " << thick_ << " is smaller than " << thickTot
215  << ": thickness of all its components **** ERROR ****";
216  } else {
217  edm::LogWarning("HGCalGeom") << "Thickness of the partition " << thick_ << " does not match with " << thickTot
218  << " of the components";
219  }
220  }
221 }
222 
223 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalWaferF, "hgcal:DDHGCalWaferF");
PluginFactory.h
DDCurrentNamespace.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDHGCalWaferF::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDHGCalWaferF.cc:58
DDSplit.h
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
DDHGCalWaferF::nCells_
int nCells_
Definition: DDHGCalWaferF.cc:44
findQualityFiles.v
v
Definition: findQualityFiles.py:179
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
DDHGCalWaferF::nameSpace_
std::string nameSpace_
Definition: DDHGCalWaferF.cc:47
DDMaterial
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
DDHGCalWaferF::DDHGCalWaferF
DDHGCalWaferF()
Definition: DDHGCalWaferF.cc:50
DDHGCalWaferF
Definition: DDHGCalWaferF.cc:20
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDHGCalWaferF::material_
std::string material_
Definition: DDHGCalWaferF.cc:34
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDBase::name
const N & name() const
Definition: DDBase.h:59
HGCalTypes::packCellTypeUV
static int32_t packCellTypeUV(int type, int u, int v)
Definition: HGCalTypes.cc:28
DDHGCalWaferF::layerThick_
std::vector< double > layerThick_
Definition: DDHGCalWaferF.cc:40
DDSolid.h
dqmdumpme.k
k
Definition: dqmdumpme.py:60
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDHGCalWaferF::copyNumber_
std::vector< int > copyNumber_
Definition: DDHGCalWaferF.cc:42
DDHGCalWaferF::waferSepar_
double waferSepar_
Definition: DDHGCalWaferF.cc:37
DDutils.h
DDSolidFactory::extrudedpolygon
static DDSolid extrudedpolygon(const DDName &name, const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z, const std::vector< double > &zx, const std::vector< double > &zy, const std::vector< double > &zscale)
Definition: DDSolid.cc:570
DDBase::ddname
const N & ddname() const
Definition: DDBase.h:61
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDHGCalWaferF::execute
void execute(DDCompactView &cpv) override
Definition: DDHGCalWaferF.cc:101
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDTypes.h
diffTwoXMLs.r2
r2
Definition: diffTwoXMLs.py:73
DDMaterial.h
createfilelist.int
int
Definition: createfilelist.py:10
DDHGCalWaferF::thick_
double thick_
Definition: DDHGCalWaferF.cc:35
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
DDLogicalPart.h
DDHGCalWaferF::waferSize_
double waferSize_
Definition: DDHGCalWaferF.cc:36
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
alignCSCRings.r
r
Definition: alignCSCRings.py:93
ReadMapType< double >
DDAlgorithm.h
DDHGCalWaferF::~DDHGCalWaferF
~DDHGCalWaferF() override
Definition: DDHGCalWaferF.cc:56
DDHGCalWaferF::layerNames_
std::vector< std::string > layerNames_
Definition: DDHGCalWaferF.cc:38
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DDHGCalWaferF::materials_
std::vector< std::string > materials_
Definition: DDHGCalWaferF.cc:39
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDHGCalWaferF::cellNames_
std::vector< std::string > cellNames_
Definition: DDHGCalWaferF.cc:46
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDHGCalWaferF::layerType_
std::vector< int > layerType_
Definition: DDHGCalWaferF.cc:41
DDHGCalWaferF::cellType_
int cellType_
Definition: DDHGCalWaferF.cc:45
zw
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
Definition: ExtVec.h:75
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dbl_to_int
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
Definition: DDutils.h:7
HGCalTypes.h
DDAlgorithmFactory.h
edm::Log
Definition: MessageLogger.h:70
dttmaxenums::R
Definition: DTTMax.h:29
class-composition.parent
parent
Definition: class-composition.py:88
DDHGCalWaferF::layers_
std::vector< int > layers_
Definition: DDHGCalWaferF.cc:43
DDSplit
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
Definition: DDSplit.cc:3
DDCompactView::position
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
Definition: DDCompactView.cc:76