CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
magneticfield::bRod Class Reference

#include <bRod.h>

Public Member Functions

 bRod (handles::const_iterator begin, handles::const_iterator end, bool debugVal=false)
 Constructor from list of volumes. More...
 
MagBRodbuildMagBRod () const
 Construct the MagBRod upon request. More...
 
const float RN () const
 Distance from center along sector normal. More...
 
 ~bRod ()=default
 Destructor. More...
 

Private Attributes

bool debug
 
MagBRodmrod
 
std::vector< bSlabslabs
 
handles volumes
 

Detailed Description

Definition at line 17 of file bRod.h.

Constructor & Destructor Documentation

◆ bRod()

bRod::bRod ( handles::const_iterator  begin,
handles::const_iterator  end,
bool  debugVal = false 
)

Constructor from list of volumes.

Definition at line 19 of file bRod.cc.

References ClusterizingHistogram::clusterize(), gather_cfg::cout, debug, f, ClusterizingHistogram::fill(), dqmdumpme::first, mps_fire::i, dqmdumpme::last, phimax, phimin, precomputed_value_sort(), magneticfield::printUniqueNames(), L1TObjectsTimingClient_cff::resolution, slabs, volumes, SiStripMonitorCluster_cfi::zmax, and SiStripMonitorCluster_cfi::zmin.

20  : volumes(begin, end), mrod(nullptr), debug(debugVal) {
22 
23  // Clusterize in Z
24  const float resolution = 5.; // cm
25  float zmin = volumes.front()->center().z() - resolution;
26  float zmax = volumes.back()->center().z() + resolution;
27  ClusterizingHistogram hisZ(int((zmax - zmin) / resolution) + 1, zmin, zmax);
28 
29  if (debug)
30  std::cout << " Z slabs: " << zmin << " " << zmax << std::endl;
31 
32  handles::const_iterator first = volumes.begin();
33  handles::const_iterator last = volumes.end();
34 
35  for (handles::const_iterator i = first; i != last; ++i) {
36  hisZ.fill((*i)->center().z());
37  }
38  std::vector<float> zClust = hisZ.clusterize(resolution);
39 
40  if (debug)
41  std::cout << " Found " << zClust.size() << " clusters in Z, "
42  << " slabs: " << std::endl;
43 
44  handles::const_iterator slabStart = first;
45  handles::const_iterator separ = first;
46 
47  for (unsigned int i = 0; i < zClust.size() - 1; ++i) {
48  float zSepar = (zClust[i] + zClust[i + 1]) / 2.f;
49  while ((*separ)->center().z() < zSepar)
50  ++separ;
51  if (debug) {
52  std::cout << " Slab at: " << zClust[i] << " elements: " << separ - slabStart << " unique volumes: ";
53  printUniqueNames(slabStart, separ);
54  }
55 
56  slabs.push_back(bSlab(slabStart, separ, debug));
57  slabStart = separ;
58  }
59  {
60  if (debug) {
61  std::cout << " Slab at: " << zClust.back() << " elements: " << last - separ << " unique volumes: ";
62  printUniqueNames(separ, last);
63  }
64  slabs.push_back(bSlab(separ, last, debug));
65  }
66 
67  // Check that all slabs have the same dphi.
68  std::vector<bSlab>::const_iterator i = slabs.begin();
69  Geom::Phi<float> phimax = (*i).maxPhi();
70  Geom::Phi<float> phimin = (*i).minPhi();
71  for (++i; i != slabs.end(); ++i) {
72  if (fabs(phimax - (*i).maxPhi()) > 0.001 || fabs(phimin - (*i).minPhi()) > 0.001) {
73  if (debug) {
74  std::cout << "*** WARNING: slabs in this rod have different dphi! minphi " << phimin;
75  std::cout << " != " << (*i).minPhi() << " or maxphi " << phimax << " != " << (*i).maxPhi() << std::endl;
76  }
77  }
78  }
79 }
void printUniqueNames(handles::const_iterator begin, handles::const_iterator end, bool uniq=true)
Just for debugging...
MagBRod * mrod
Definition: bRod.h:34
handles volumes
Definition: bRod.h:33
double f[11][100]
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
std::vector< bSlab > slabs
Definition: bRod.h:32

◆ ~bRod()

magneticfield::bRod::~bRod ( )
default

Destructor.

Member Function Documentation

◆ buildMagBRod()

MagBRod * bRod::buildMagBRod ( ) const

Construct the MagBRod upon request.

Definition at line 81 of file bRod.cc.

References mrod, and slabs.

81  {
82  if (mrod == nullptr) {
83  std::vector<MagBSlab*> mSlabs;
84  for (std::vector<bSlab>::const_iterator slab = slabs.begin(); slab != slabs.end(); ++slab) {
85  mSlabs.push_back((*slab).buildMagBSlab());
86  }
87  mrod = new MagBRod(mSlabs, slabs.front().minPhi()); //FIXME
88  }
89  return mrod;
90 }
MagBRod * mrod
Definition: bRod.h:34
std::vector< bSlab > slabs
Definition: bRod.h:32

◆ RN()

const float magneticfield::bRod::RN ( ) const
inline

Distance from center along sector normal.

Definition at line 26 of file bRod.h.

References volumes.

26 { return volumes.front()->RN(); }
handles volumes
Definition: bRod.h:33

Member Data Documentation

◆ debug

bool magneticfield::bRod::debug
private

◆ mrod

MagBRod* magneticfield::bRod::mrod
mutableprivate

Definition at line 34 of file bRod.h.

Referenced by buildMagBRod().

◆ slabs

std::vector<bSlab> magneticfield::bRod::slabs
private

Definition at line 32 of file bRod.h.

Referenced by bRod(), and buildMagBRod().

◆ volumes

handles magneticfield::bRod::volumes
private

Definition at line 33 of file bRod.h.

Referenced by bRod(), and RN().