CMS 3D CMS Logo

eSector.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author N. Amapane - INFN Torino
5  */
6 
7 #include "eSector.h"
8 #include "printUniqueNames.h"
12 
13 #include <algorithm>
14 #include <iostream>
15 
16 using namespace SurfaceOrientation;
17 using namespace std;
18 using namespace magneticfield;
19 
20 // The ctor is in charge of finding layers inside the sector.
21 eSector::eSector(handles::const_iterator begin, handles::const_iterator end, bool debugFlag)
22  : theVolumes(begin, end), msector(nullptr), debug(debugFlag) {
23  //FIXME!!!
24  //precomputed_value_sort(theVolumes.begin(), theVolumes.end(), ExtractAbsZ());
26 
27  // Clusterize in Z
28  const float resolution = 1.; // cm //FIXME ??
29  float zmin = theVolumes.front()->center().z() - resolution;
30  float zmax = theVolumes.back()->center().z() + resolution;
31  ClusterizingHistogram hisZ(int((zmax - zmin) / resolution) + 1, zmin, zmax);
32 
33  if (debug)
34  cout << " Z layers: " << zmin << " " << zmax << endl;
35 
36  handles::const_iterator first = theVolumes.begin();
37  handles::const_iterator last = theVolumes.end();
38 
39  for (handles::const_iterator i = first; i != last; ++i) {
40  hisZ.fill((*i)->center().z());
41  }
42  vector<float> zClust = hisZ.clusterize(resolution);
43 
44  if (debug)
45  cout << " Found " << zClust.size() << " clusters in Z, "
46  << " layers: " << endl;
47 
48  handles::const_iterator layStart = 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)
54  ++separ;
55  if (debug) {
56  cout << " Layer at: " << zClust[i] << " elements: " << separ - layStart << " unique volumes: ";
57  printUniqueNames(layStart, separ);
58  }
59 
60  layers.push_back(eLayer(layStart, separ));
61  layStart = separ;
62  }
63  {
64  if (debug) {
65  cout << " Layer at: " << zClust.back() << " elements: " << last - separ << " unique volumes: ";
66  printUniqueNames(separ, last);
67  }
68  layers.push_back(eLayer(separ, last));
69  }
70 
71  // FIXME: Check that all layers have the same dz?.
72 }
73 
75  if (msector == nullptr) {
76  vector<MagELayer*> mLayers;
77  for (vector<eLayer>::const_iterator lay = layers.begin(); lay != layers.end(); ++lay) {
78  mLayers.push_back((*lay).buildMagELayer());
79  }
80  msector = new MagESector(mLayers, theVolumes.front()->minPhi()); //FIXME
81  }
82  return msector;
83 }
ClusterizingHistogram::clusterize
std::vector< float > clusterize(float resolution)
Definition: ClusterizingHistogram.cc:54
mps_fire.i
i
Definition: mps_fire.py:428
magneticfield::eSector::buildMagESector
MagESector * buildMagESector() const
Construct the MagESector upon request.
Definition: eSector.cc:74
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
gather_cfg.cout
cout
Definition: gather_cfg.py:144
magneticfield::printUniqueNames
void printUniqueNames(handles::const_iterator begin, handles::const_iterator end, bool uniq=true)
Just for debugging...
Definition: printUniqueNames.cc:9
magneticfield
Definition: MagFieldConfig.h:22
precomputed_value_sort.h
SiStripMonitorCluster_cfi.zmin
zmin
Definition: SiStripMonitorCluster_cfi.py:200
eSector.h
magneticfield::ExtractZ
Definition: BaseVolumeHandle.h:159
magneticfield::eSector::debug
const bool debug
Definition: eSector.h:34
dqmdumpme.last
last
Definition: dqmdumpme.py:56
debug
#define debug
Definition: HDRShower.cc:19
magneticfield::eSector::theVolumes
handles theVolumes
Definition: eSector.h:32
SiStripMonitorCluster_cfi.zmax
zmax
Definition: SiStripMonitorCluster_cfi.py:201
mps_fire.end
end
Definition: mps_fire.py:242
L1TObjectsTimingClient_cff.resolution
resolution
Definition: L1TObjectsTimingClient_cff.py:52
magneticfield::eSector::msector
MagESector * msector
Definition: eSector.h:33
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
MagESector.h
ClusterizingHistogram::fill
void fill(float x)
Definition: ClusterizingHistogram.cc:38
printUniqueNames.h
BeamSplash_cfg.debugFlag
debugFlag
Definition: BeamSplash_cfg.py:21
std
Definition: JetResolutionObject.h:76
ClusterizingHistogram.h
MagESector
Definition: MagESector.h:18
magneticfield::eLayer
Definition: eLayer.h:15
SurfaceOrientation
Definition: Surface.h:17
precomputed_value_sort
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
Definition: precomputed_value_sort.h:17
magneticfield::eSector::layers
std::vector< eLayer > layers
Definition: eSector.h:31
ClusterizingHistogram
Definition: ClusterizingHistogram.h:13