CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  * $Date: 2008/04/23 13:59:30 $
7  * $Revision: 1.6 $
8  * \author N. Amapane - INFN Torino
9  */
10 
16 
17 using namespace SurfaceOrientation;
18 
20 
21 //The ctor is in charge of finding slabs inside the rod.
22 MagGeoBuilderFromDDD::bRod::bRod(handles::const_iterator begin,
23  handles::const_iterator end) :
24  volumes(begin,end),
25  mrod(0)
26 {
28 
29  // Clusterize in Z
30  const float resolution = 5.; // cm
31  float zmin = volumes.front()->center().z()-resolution;
32  float zmax = volumes.back()->center().z()+resolution;
33  ClusterizingHistogram hisZ( int((zmax-zmin)/resolution) + 1, zmin, zmax);
34 
35  if (MagGeoBuilderFromDDD::debug) std::cout << " Z slabs: " << zmin << " " << zmax << std::endl;
36 
37  handles::const_iterator first = volumes.begin();
38  handles::const_iterator last = volumes.end();
39 
40  for (handles::const_iterator i=first; i!=last; ++i){
41  hisZ.fill((*i)->center().z());
42  }
43  std::vector<float> zClust = hisZ.clusterize(resolution);
44 
45  if (MagGeoBuilderFromDDD::debug) std::cout << " Found " << zClust.size() << " clusters in Z, "
46  << " slabs: " << std::endl;
47 
48  handles::const_iterator slabStart = first;
49  handles::const_iterator separ = first;
50 
51  for (unsigned int i=0; i<zClust.size() - 1; ++i) {
52  float zSepar = (zClust[i] + zClust[i+1])/2.f;
53  while ((*separ)->center().z() < zSepar) ++separ;
55  std::cout << " Slab at: " << zClust[i]
56  << " elements: " << separ-slabStart << " unique volumes: ";
57  volumeHandle::printUniqueNames(slabStart, separ);
58  }
59 
60  slabs.push_back(bSlab(slabStart, separ));
61  slabStart = separ;
62  }
63  {
65  std::cout << " Slab at: " << zClust.back() <<" elements: " << last-separ
66  << " unique volumes: ";
68  }
69  slabs.push_back(bSlab(separ, last));
70  }
71 
72  // Check that all slabs have the same dphi.
73  std::vector<bSlab>::const_iterator i = slabs.begin();
74  Geom::Phi<float> phimax = (*i).maxPhi();
75  Geom::Phi<float> phimin = (*i).minPhi();
76  for (++i; i!= slabs.end(); ++i) {
77  if(fabs(phimax - (*i).maxPhi()) > 0.001 ||
78  fabs(phimin - (*i).minPhi()) > 0.001){
79  if (MagGeoBuilderFromDDD::debug) std::cout << "*** WARNING: slabs in this rod have different dphi!" <<std::endl;
80  }
81  }
82 }
83 
84 
85 
87  if (mrod==0) {
88  std::vector<MagBSlab*> mSlabs;
89  for (std::vector<bSlab>::const_iterator slab = slabs.begin();
90  slab!=slabs.end(); ++slab) {
91  mSlabs.push_back((*slab).buildMagBSlab());
92  }
93  mrod = new MagBRod(mSlabs,slabs.front().minPhi()); //FIXME
94  }
95  return mrod;
96 }
int i
Definition: DBlmapReader.cc:9
static void printUniqueNames(handles::const_iterator begin, handles::const_iterator end)
Just for debugging...
~bRod()
Destructor.
Definition: bRod.cc:19
std::vector< bSlab > slabs
Definition: bRod.h:36
std::vector< float > clusterize(float resolution)
double f[11][100]
#define end
Definition: vmac.h:38
bool first
Definition: L1TdeRCT.cc:94
MagBRod * buildMagBRod() const
Construct the MagBRod upon request.
Definition: bRod.cc:86
#define begin
Definition: vmac.h:31
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr)
tuple cout
Definition: gather_cfg.py:121
bRod(handles::const_iterator begin, handles::const_iterator end)
Constructor from list of volumes.
Definition: bRod.cc:22