CMS 3D CMS Logo

MuRodBarrelLayer.cc
Go to the documentation of this file.
1 
13 
16 
17 #include "GeneralBinFinderInPhi.h"
18 #include "PhiBorderFinder.h"
19 
20 #include <algorithm>
21 #include <iostream>
22 
23 using namespace std;
24 
25 MuRodBarrelLayer::MuRodBarrelLayer(vector<const DetRod*>& rods)
26  : RodBarrelLayer(false), theRods(rods), theBinFinder(nullptr), isOverlapping(false) {
27  // Sort rods in phi
29 
30  theComponents.reserve(theRods.size());
31  std::copy(theRods.begin(), theRods.end(), back_inserter(theComponents));
32 
33  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuRodBarrelLayer";
34 
35  // Cache chamber pointers (the basic components_)
36  for (vector<const DetRod*>::const_iterator it = rods.begin(); it != rods.end(); it++) {
37  vector<const GeomDet*> tmp2 = (*it)->basicComponents();
38  theBasicComps.insert(theBasicComps.end(), tmp2.begin(), tmp2.end());
39  }
40 
41  // Initialize the binfinder
44 
45  if (bf.isPhiPeriodic()) {
46  theBinFinder = new PeriodicBinFinderInPhi<double>(theRods.front()->position().phi(), theRods.size());
47  } else {
49  }
50 
51  // Compute the layer's surface and bounds (from the components())
53 
54  LogTrace(metname) << "Constructing MuRodBarrelLayer: " << basicComponents().size() << " Dets " << theRods.size()
55  << " Rods "
56  << " R: " << specificSurface().radius() << " Per.: " << bf.isPhiPeriodic()
57  << " Overl.: " << isOverlapping;
58 }
59 
61  delete theBinFinder;
62  for (vector<const DetRod*>::iterator i = theRods.begin(); i < theRods.end(); i++) {
63  delete *i;
64  }
65 }
66 
67 vector<GeometricSearchDet::DetWithState> MuRodBarrelLayer::compatibleDets(const TrajectoryStateOnSurface& startingState,
68  const Propagator& prop,
69  const MeasurementEstimator& est) const {
70  const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuRodBarrelLayer";
71  vector<DetWithState> result;
72 
73  LogTrace(metname) << "MuRodBarrelLayer::compatibleDets, Cyl R: " << specificSurface().radius()
74  << " TSOS at R= " << startingState.globalPosition().perp()
75  << " phi= " << startingState.globalPosition().phi();
76 
77  pair<bool, TrajectoryStateOnSurface> compat = compatible(startingState, prop, est);
78  if (!compat.first) {
79  LogTrace(metname) << " MuRodBarrelLayer::compatibleDets: not compatible"
80  << " (should not have been selected!)";
81  return vector<DetWithState>();
82  }
83 
84  TrajectoryStateOnSurface& tsos = compat.second;
85 
86  LogTrace(metname) << " MuRodBarrelLayer::compatibleDets, reached layer at: " << tsos.globalPosition()
87  << " R = " << tsos.globalPosition().perp() << " phi = " << tsos.globalPosition().phi();
88 
89  int closest = theBinFinder->binIndex(tsos.globalPosition().phi());
90  const DetRod* closestRod = theRods[closest];
91 
92  // Check the closest rod
93  LogTrace(metname) << " MuRodBarrelLayer::compatibleDets, closestRod: " << closest
94  << " phi : " << closestRod->surface().position().phi()
95  << " FTS phi: " << tsos.globalPosition().phi();
96 
97  result = closestRod->compatibleDets(tsos, prop, est);
98 
99  int nclosest = result.size(); // Debug counter
100 
101  bool checknext = false;
102  double dist;
103 
104  if (!result.empty()) {
105  // Check if the track go outside closest rod, then look for closest.
106  TrajectoryStateOnSurface& predictedState = result.front().second;
107  float xErr = xError(predictedState, est);
108  float halfWid = closestRod->surface().bounds().width() / 2.;
109  dist = predictedState.localPosition().x();
110 
111  // If the layer is overlapping, additionally reduce halfWid by 10%
112  // to account for overlap.
113  // FIXME: should we account for the real amount of overlap?
114  if (isOverlapping)
115  halfWid *= 0.9;
116 
117  if (fabs(dist) + xErr > halfWid) {
118  checknext = true;
119  }
120  } else { // Rod is not compatible
121  //FIXME: Usually next cannot be either. Implement proper logic.
122  // (in general at least one rod should be when this method is called by
123  // compatibleDets() which calls compatible())
124  checknext = true;
125 
126  // Look for the next-to closest in phi.
127  // Note Geom::Phi, subtraction is pi-border-safe
128  if (tsos.globalPosition().phi() - closestRod->surface().position().phi() > 0.) {
129  dist = -1.;
130  } else {
131  dist = +1.;
132  }
133 
134  LogTrace(metname) << " MuRodBarrelLayer::fastCompatibleDets, none on closest rod!";
135  }
136 
137  if (checknext) {
138  int next;
139  if (dist < 0.)
140  next = closest + 1;
141  else
142  next = closest - 1;
143 
144  next = theBinFinder->binIndex(next); // Bin Periodicity
145  const DetRod* nextRod = theRods[next];
146 
147  LogTrace(metname) << " MuRodBarrelLayer::fastCompatibleDets, next-to closest"
148  << " rod: " << next << " dist " << dist << " phi : " << nextRod->surface().position().phi()
149  << " FTS phi: " << tsos.globalPosition().phi();
150 
151  vector<DetWithState> nextRodDets = nextRod->compatibleDets(tsos, prop, est);
152  result.insert(result.end(), nextRodDets.begin(), nextRodDets.end());
153  }
154 
155  LogTrace(metname) << " MuRodBarrelLayer::fastCompatibleDets: found: " << result.size()
156  << " on closest: " << nclosest << " # checked rods: " << 1 + int(checknext);
157 
158  return result;
159 }
160 
162  const Propagator& prop,
163  const MeasurementEstimator& est) const {
164  // FIXME should return only 1 group
165  cout << "dummy implementation of MuRodBarrelLayer::groupedCompatibleDets()" << endl;
166  return vector<DetGroup>();
167 }
168 
170 
171 const vector<const GeometricSearchDet*>& MuRodBarrelLayer::components() const { return theComponents; }
172 
174  const float nSigmas = 3.f;
175  if (tsos.hasError()) {
176  return nSigmas * sqrt(tsos.localError().positionError().xx());
177  } else
178  return nSigmas * 0.5;
179 }
MuRodBarrelLayer::xError
float xError(const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const
Definition: MuRodBarrelLayer.cc:173
Propagator.h
MuRodBarrelLayer::theComponents
std::vector< const GeometricSearchDet * > theComponents
Definition: MuRodBarrelLayer.h:50
GeomDetEnumerators::SubDetector
SubDetector
Definition: GeomDetEnumerators.h:10
MeasurementEstimator
Definition: MeasurementEstimator.h:19
mps_fire.i
i
Definition: mps_fire.py:355
PeriodicBinFinderInPhi.h
Bounds::width
virtual float width() const =0
MessageLogger.h
funct::false
false
Definition: Factorize.h:34
PhiBorderFinder
Definition: PhiBorderFinder.h:27
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
LocalTrajectoryError::positionError
LocalError positionError() const
Definition: LocalTrajectoryError.h:81
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
gather_cfg.cout
cout
Definition: gather_cfg.py:144
MuRodBarrelLayer::theRods
std::vector< const DetRod * > theRods
Definition: MuRodBarrelLayer.h:49
BarrelDetLayer::initialize
virtual void initialize()
Definition: BarrelDetLayer.cc:18
MuRodBarrelLayer::~MuRodBarrelLayer
~MuRodBarrelLayer() override
Definition: MuRodBarrelLayer.cc:60
GeometricSearchDet::compatibleDets
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
Definition: GeometricSearchDet.cc:35
precomputed_value_sort.h
Propagator
Definition: Propagator.h:44
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
LocalError::xx
float xx() const
Definition: LocalError.h:22
TrajectoryStateOnSurface::hasError
bool hasError() const
Definition: TrajectoryStateOnSurface.h:56
PhiBorderFinder::isPhiPeriodic
bool isPhiPeriodic() const
Returns true if the Dets are periodic in phi.
Definition: PhiBorderFinder.h:39
MeasurementEstimator.h
DetRod
Definition: DetRod.h:13
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
Surface::bounds
const Bounds & bounds() const
Definition: Surface.h:87
MuRodBarrelLayer::components
const std::vector< const GeometricSearchDet * > & components() const override
Definition: MuRodBarrelLayer.cc:171
GeneralBinFinderInPhi.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MuRodBarrelLayer::rods
virtual const std::vector< const DetRod * > & rods() const
Return the vector of rods.
Definition: MuRodBarrelLayer.h:44
TrajectoryStateOnSurface::localPosition
LocalPoint localPosition() const
Definition: TrajectoryStateOnSurface.h:74
DetRod::surface
const BoundSurface & surface() const final
The surface of the GeometricSearchDet.
Definition: DetRod.h:19
RodBarrelLayer
createfilelist.int
int
Definition: createfilelist.py:10
MuRodBarrelLayer::MuRodBarrelLayer
MuRodBarrelLayer(std::vector< const DetRod * > &rods)
Constructor, takes ownership of pointers.
Definition: MuRodBarrelLayer.cc:25
MuRodBarrelLayer::basicComponents
const std::vector< const GeomDet * > & basicComponents() const override
Definition: MuRodBarrelLayer.h:26
geomsort::ExtractPhi
Definition: GeometricSorting.h:45
MuRodBarrelLayer::subDetector
SubDetector subDetector() const override
Definition: MuRodBarrelLayer.cc:169
MuRodBarrelLayer::compatibleDets
std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
Definition: MuRodBarrelLayer.cc:67
GloballyPositioned::position
const PositionType & position() const
Definition: GloballyPositioned.h:36
MuRodBarrelLayer::groupedCompatibleDets
std::vector< DetGroup > groupedCompatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
Definition: MuRodBarrelLayer.cc:161
GeomDet.h
std
Definition: JetResolutionObject.h:76
MuRodBarrelLayer::theBasicComps
std::vector< const GeomDet * > theBasicComps
Definition: MuRodBarrelLayer.h:51
PeriodicBinFinderInPhi
Definition: MagBLayer.h:22
GeometricSorting.h
MuRodBarrelLayer.h
GeneralBinFinderInPhi
Definition: GeneralBinFinderInPhi.h:18
MuRodBarrelLayer::theBinFinder
BaseBinFinder< double > * theBinFinder
Definition: MuRodBarrelLayer.h:52
mps_fire.result
result
Definition: mps_fire.py:303
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
PhiBorderFinder.h
PhiBorderFinder::isPhiOverlapping
bool isPhiOverlapping() const
Returns true if any 2 of the Det overlap in phi.
Definition: PhiBorderFinder.h:42
precomputed_value_sort
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
Definition: precomputed_value_sort.h:17
TrajectoryStateOnSurface::localError
const LocalTrajectoryError & localError() const
Definition: TrajectoryStateOnSurface.h:77
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
MuRodBarrelLayer::isOverlapping
bool isOverlapping
Definition: MuRodBarrelLayer.h:53
BaseBinFinder::binIndex
virtual int binIndex(T pos) const =0
Return the index of bin at given position.
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:43
MuDetRod.h