CMS 3D CMS Logo

eSector.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 
13 
14 #include <algorithm>
16 
17 using namespace SurfaceOrientation;
18 using namespace std;
19 
20 // The ctor is in charge of finding layers inside the sector.
22  handles::const_iterator end) :
23  theVolumes(begin,end),
24  msector(nullptr)
25 {
26  //FIXME!!!
27  //precomputed_value_sort(theVolumes.begin(), theVolumes.end(), ExtractAbsZ());
29 
30 
31  // Clusterize in Z
32  const float resolution = 1.; // cm //FIXME ??
33  float zmin = theVolumes.front()->center().z()-resolution;
34  float zmax = theVolumes.back()->center().z()+resolution;
35  ClusterizingHistogram hisZ( int((zmax-zmin)/resolution) + 1, zmin, zmax);
36 
37  if (MagGeoBuilderFromDDD::debug) cout << " Z layers: " << zmin << " " << zmax << endl;
38 
39  handles::const_iterator first = theVolumes.begin();
40  handles::const_iterator last = theVolumes.end();
41 
42  for (handles::const_iterator i=first; i!=last; ++i){
43  hisZ.fill((*i)->center().z());
44  }
45  vector<float> zClust = hisZ.clusterize(resolution);
46 
47  if (MagGeoBuilderFromDDD::debug) cout << " Found " << zClust.size() << " clusters in Z, "
48  << " layers: " << endl;
49 
50  handles::const_iterator layStart = first;
51  handles::const_iterator separ = first;
52 
53  for (unsigned int i=0; i<zClust.size() - 1; ++i) {
54  float zSepar = (zClust[i] + zClust[i+1])/2.f;
55  while ((*separ)->center().z() < zSepar) ++separ;
57  cout << " Layer at: " << zClust[i]
58  << " elements: " << separ-layStart << " unique volumes: ";
59  volumeHandle::printUniqueNames(layStart, separ);
60  }
61 
62  layers.push_back(eLayer(layStart, separ));
63  layStart = separ;
64  }
65  {
67  cout << " Layer at: " << zClust.back() <<" elements: " << last-separ
68  << " unique volumes: ";
70  }
71  layers.push_back(eLayer(separ, last));
72  }
73 
74  // FIXME: Check that all layers have the same dz?.
75 
76 }
77 
78 
80 
81 
83  if (msector==nullptr) {
84  vector<MagELayer*> mLayers;
85  for (vector<eLayer>::const_iterator lay = layers.begin();
86  lay!=layers.end(); ++lay) {
87  mLayers.push_back((*lay).buildMagELayer());
88  }
89  msector = new MagESector(mLayers, theVolumes.front()->minPhi()); //FIXME
90  }
91  return msector;
92 }
std::vector< eLayer > layers
Definition: eSector.h:32
MagESector * buildMagESector() const
Construct the MagESector upon request.
Definition: eSector.cc:82
#define nullptr
std::vector< float > clusterize(float resolution)
eSector(handles::const_iterator begin, handles::const_iterator end)
Constructor from list of volumes.
Definition: eSector.cc:21
double f[11][100]
#define end
Definition: vmac.h:39
static void printUniqueNames(handles::const_iterator begin, handles::const_iterator end, bool uniq=true)
Just for debugging...
#define begin
Definition: vmac.h:32
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr)