CMS 3D CMS Logo

bRod.cc
Go to the documentation of this file.
1 // #include "Utilities/Configuration/interface/Architecture.h"
2 
3 /*
4  * See header file for a description of this class.
5  *
6  * \author N. Amapane - INFN Torino
7  */
8 
14 
15 using namespace SurfaceOrientation;
16 
18 
19 //The ctor is in charge of finding slabs inside the rod.
20 MagGeoBuilderFromDDD::bRod::bRod(handles::const_iterator begin,
21  handles::const_iterator end) :
22  volumes(begin,end),
23  mrod(nullptr)
24 {
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 }
81 
82 
83 
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 }
#define nullptr
~bRod()
Destructor.
Definition: bRod.cc:17
std::vector< bSlab > slabs
Definition: bRod.h:34
std::vector< float > clusterize(float resolution)
double f[11][100]
#define end
Definition: vmac.h:39
MagBRod * buildMagBRod() const
Construct the MagBRod upon request.
Definition: bRod.cc:84
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
static void printUniqueNames(handles::const_iterator begin, handles::const_iterator end, bool uniq=true)
Just for debugging...
#define begin
Definition: vmac.h:32
bRod(handles::const_iterator begin, handles::const_iterator end)
Constructor from list of volumes.
Definition: bRod.cc:20