CMS 3D CMS Logo

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

#include <bRod.h>

Public Member Functions

 bRod (handles::const_iterator begin, handles::const_iterator end)
 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 ()
 Destructor. More...
 

Private Attributes

MagBRodmrod
 
std::vector< bSlabslabs
 
handles volumes
 

Detailed Description

A rod of volumes in a barrel sector. A rod is made of several "slabs".

Author
N. Amapane - INFN Torino

Definition at line 17 of file bRod.h.

Constructor & Destructor Documentation

MagGeoBuilderFromDDD::bRod::bRod ( handles::const_iterator  begin,
handles::const_iterator  end 
)

Constructor from list of volumes.

Definition at line 20 of file bRod.cc.

References ClusterizingHistogram::clusterize(), gather_cfg::cout, MagGeoBuilderFromDDD::debug, f, ClusterizingHistogram::fill(), plotBeamSpotDB::first, mps_fire::i, plotBeamSpotDB::last, phimax, phimin, precomputed_value_sort(), MagGeoBuilderFromDDD::volumeHandle::printUniqueNames(), fftjetproducer_cfi::resolution, slabs, and volumes.

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

Destructor.

Definition at line 17 of file bRod.cc.

17 {}

Member Function Documentation

MagBRod * MagGeoBuilderFromDDD::bRod::buildMagBRod ( ) const

Construct the MagBRod upon request.

Definition at line 84 of file bRod.cc.

References mrod, and slabs.

Referenced by RN().

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

Distance from center along sector normal.

Definition at line 26 of file bRod.h.

References buildMagBRod(), and volumes.

26  {
27  return volumes.front()->RN();
28  }

Member Data Documentation

MagBRod* MagGeoBuilderFromDDD::bRod::mrod
mutableprivate

Definition at line 36 of file bRod.h.

Referenced by buildMagBRod().

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

Definition at line 34 of file bRod.h.

Referenced by bRod(), and buildMagBRod().

handles MagGeoBuilderFromDDD::bRod::volumes
private

Definition at line 35 of file bRod.h.

Referenced by bRod(), and RN().