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 ( handles::const_iterator  begin,
handles::const_iterator  end,
bool  debugVal = false 
)

Constructor from list of volumes.

Definition at line 20 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.

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

Destructor.

Member Function Documentation

MagBRod * bRod::buildMagBRod ( ) const

Construct the MagBRod upon request.

Definition at line 82 of file bRod.cc.

References mrod, and slabs.

Referenced by RN().

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

Distance from center along sector normal.

Definition at line 26 of file bRod.h.

References buildMagBRod(), and volumes.

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

Member Data Documentation

bool magneticfield::bRod::debug
private
MagBRod* magneticfield::bRod::mrod
mutableprivate

Definition at line 34 of file bRod.h.

Referenced by buildMagBRod().

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

Definition at line 32 of file bRod.h.

Referenced by bRod(), and buildMagBRod().

handles magneticfield::bRod::volumes
private

Definition at line 33 of file bRod.h.

Referenced by bRod(), and RN().