CMS 3D CMS Logo

bRod.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 "bRod.h"
8 #include "printUniqueNames.h"
12 
13 #include <iostream>
14 
15 using namespace SurfaceOrientation;
16 using namespace magneticfield;
17 
18 //The ctor is in charge of finding slabs inside the rod.
19 bRod::bRod(handles::const_iterator begin, handles::const_iterator end, bool debugVal)
20  : volumes(begin, end), mrod(nullptr), debug(debugVal) {
22 
23  // Clusterize in Z
24  const float resolution = 5.; // cm
25  float zmin = volumes.front()->center().z() - resolution;
26  float zmax = volumes.back()->center().z() + resolution;
27  ClusterizingHistogram hisZ(int((zmax - zmin) / resolution) + 1, zmin, zmax);
28 
29  if (debug)
30  std::cout << " Z slabs: " << zmin << " " << zmax << std::endl;
31 
32  handles::const_iterator first = volumes.begin();
33  handles::const_iterator last = volumes.end();
34 
35  for (handles::const_iterator i = first; i != last; ++i) {
36  hisZ.fill((*i)->center().z());
37  }
38  std::vector<float> zClust = hisZ.clusterize(resolution);
39 
40  if (debug)
41  std::cout << " Found " << zClust.size() << " clusters in Z, "
42  << " slabs: " << std::endl;
43 
44  handles::const_iterator slabStart = first;
45  handles::const_iterator separ = first;
46 
47  for (unsigned int i = 0; i < zClust.size() - 1; ++i) {
48  float zSepar = (zClust[i] + zClust[i + 1]) / 2.f;
49  while ((*separ)->center().z() < zSepar)
50  ++separ;
51  if (debug) {
52  std::cout << " Slab at: " << zClust[i] << " elements: " << separ - slabStart << " unique volumes: ";
53  printUniqueNames(slabStart, separ);
54  }
55 
56  slabs.push_back(bSlab(slabStart, separ, debug));
57  slabStart = separ;
58  }
59  {
60  if (debug) {
61  std::cout << " Slab at: " << zClust.back() << " elements: " << last - separ << " unique volumes: ";
62  printUniqueNames(separ, last);
63  }
64  slabs.push_back(bSlab(separ, last, debug));
65  }
66 
67  // Check that all slabs have the same dphi.
68  std::vector<bSlab>::const_iterator i = slabs.begin();
69  Geom::Phi<float> phimax = (*i).maxPhi();
70  Geom::Phi<float> phimin = (*i).minPhi();
71  for (++i; i != slabs.end(); ++i) {
72  if (fabs(phimax - (*i).maxPhi()) > 0.001 || fabs(phimin - (*i).minPhi()) > 0.001) {
73  if (debug) {
74  std::cout << "*** WARNING: slabs in this rod have different dphi! minphi " << phimin;
75  std::cout << " != " << (*i).minPhi() << " or maxphi " << phimax << " != " << (*i).maxPhi() << std::endl;
76  }
77  }
78  }
79 }
80 
82  if (mrod == nullptr) {
83  std::vector<MagBSlab*> mSlabs;
84  for (std::vector<bSlab>::const_iterator slab = slabs.begin(); slab != slabs.end(); ++slab) {
85  mSlabs.push_back((*slab).buildMagBSlab());
86  }
87  mrod = new MagBRod(mSlabs, slabs.front().minPhi()); //FIXME
88  }
89  return mrod;
90 }
ClusterizingHistogram::clusterize
std::vector< float > clusterize(float resolution)
Definition: ClusterizingHistogram.cc:54
mps_fire.i
i
Definition: mps_fire.py:355
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
phimin
float phimin
Definition: ReggeGribovPartonMCHadronizer.h:107
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
magneticfield::bRod::debug
bool debug
Definition: bRod.h:35
precomputed_value_sort.h
magneticfield::bRod::slabs
std::vector< bSlab > slabs
Definition: bRod.h:32
magneticfield::bRod::buildMagBRod
MagBRod * buildMagBRod() const
Construct the MagBRod upon request.
Definition: bRod.cc:81
SiStripMonitorCluster_cfi.zmin
zmin
Definition: SiStripMonitorCluster_cfi.py:200
dqmdumpme.first
first
Definition: dqmdumpme.py:55
bRod.h
magneticfield::ExtractZ
Definition: BaseVolumeHandle.h:159
end
#define end
Definition: vmac.h:39
dqmdumpme.last
last
Definition: dqmdumpme.py:56
debug
#define debug
Definition: HDRShower.cc:19
magneticfield::bSlab
Definition: bSlab.h:23
volumeBasedMagneticField_160812_cfi.volumes
volumes
Definition: volumeBasedMagneticField_160812_cfi.py:57
SiStripMonitorCluster_cfi.zmax
zmax
Definition: SiStripMonitorCluster_cfi.py:201
L1TObjectsTimingClient_cff.resolution
resolution
Definition: L1TObjectsTimingClient_cff.py:52
ClusterizingHistogram::fill
void fill(float x)
Definition: ClusterizingHistogram.cc:38
printUniqueNames.h
Geom::Phi< float >
phimax
float phimax
Definition: ReggeGribovPartonMCHadronizer.h:106
magneticfield::bRod::volumes
handles volumes
Definition: bRod.h:33
ClusterizingHistogram.h
MagBRod
Definition: MagBRod.h:25
MagBRod.h
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
begin
#define begin
Definition: vmac.h:32
magneticfield::bRod::mrod
MagBRod * mrod
Definition: bRod.h:34
ClusterizingHistogram
Definition: ClusterizingHistogram.h:13