CMS 3D CMS Logo

DTMeantimerPatternReco4D.cc
Go to the documentation of this file.
1 
7 
10 
12 // For the 2D reco I use thei reconstructor!
15 
22 
24 
25 using namespace std;
26 using namespace edm;
27 
28 // TODO
29 // Throw an exception if a theta segment container is requested and in the event
30 // there isn't it. (Or launch a "lazy" reco on demand)
31 
33  : DTRecSegment4DBaseAlgo(pset), theAlgoName("DTMeantimerPatternReco4D") {
34  // debug parameter
35  debug = pset.getUntrackedParameter<bool>("debug");
36 
37  //do you want the T0 correction?
38  applyT0corr = pset.getParameter<bool>("performT0SegCorrection");
39 
40  computeT0corr = pset.existsAs<bool>("computeT0Seg") ? pset.getParameter<bool>("computeT0Seg") : true;
41 
42  // the updator
44 
45  // the input type.
46  // If true the instructions in setDTRecSegment2DContainer will be schipped and the
47  // theta segment will be recomputed from the 1D rechits
48  // If false the theta segment will be taken from the Event. Caveat: in this case the
49  // event must contain the 2D segments!
50  allDTRecHits = pset.getParameter<bool>("AllDTRecHits");
51 
52  // Get the concrete 2D-segments reconstruction algo from the factory
53  // For the 2D reco I use this reconstructor!
54  the2DAlgo = new DTMeantimerPatternReco(pset.getParameter<ParameterSet>("Reco2DAlgoConfig"));
55 }
56 
58  delete the2DAlgo;
59  delete theUpdator;
60 }
61 
66 }
67 
69  // Set the chamber
71 }
72 
74  theHitsFromPhi1.clear();
75  theHitsFromPhi2.clear();
76  theHitsFromTheta.clear();
77 
78  DTRecHitCollection::range rangeHitsFromPhi1 =
80  DTRecHitCollection::range rangeHitsFromPhi2 =
82 
83  vector<DTRecHit1DPair> hitsFromPhi1(rangeHitsFromPhi1.first, rangeHitsFromPhi1.second);
84  vector<DTRecHit1DPair> hitsFromPhi2(rangeHitsFromPhi2.first, rangeHitsFromPhi2.second);
85  if (debug)
86  cout << "Number of DTRecHit1DPair in the SL 1 (Phi 1): " << hitsFromPhi1.size() << endl
87  << "Number of DTRecHit1DPair in the SL 3 (Phi 2): " << hitsFromPhi2.size() << endl;
88 
89  theHitsFromPhi1 = hitsFromPhi1;
90  theHitsFromPhi2 = hitsFromPhi2;
91 
92  if (allDTRecHits) {
93  DTRecHitCollection::range rangeHitsFromTheta =
95 
96  vector<DTRecHit1DPair> hitsFromTheta(rangeHitsFromTheta.first, rangeHitsFromTheta.second);
97  if (debug)
98  cout << "Number of DTRecHit1DPair in the SL 2 (Theta): " << hitsFromTheta.size() << endl;
99  theHitsFromTheta = hitsFromTheta;
100  }
101 }
102 
104  theSegments2DTheta.clear();
105 
106  if (!allDTRecHits) {
107  //Extract the DTRecSegment2DCollection range for the theta SL
108  DTRecSegment2DCollection::range rangeTheta = all2DSegments->get(DTSuperLayerId(theChamber->id(), 2));
109 
110  // Fill the DTRecSegment2D container for the theta SL
111  vector<DTSLRecSegment2D> segments2DTheta(rangeTheta.first, rangeTheta.second);
112 
113  if (debug)
114  cout << "Number of 2D-segments in the second SL (Theta): " << segments2DTheta.size() << endl;
115  theSegments2DTheta = segments2DTheta;
116  }
117 }
118 
121 
122  if (debug) {
123  cout << "Segments in " << theChamber->id() << endl;
124  cout << "Reconstructing Phi segments" << endl;
125  }
126 
127  vector<std::shared_ptr<DTHitPairForFit>> pairPhiOwned;
128  vector<DTSegmentCand*> resultPhi = buildPhiSuperSegmentsCandidates(pairPhiOwned);
129 
130  if (debug)
131  cout << "There are " << resultPhi.size() << " Phi cand" << endl;
132 
133  if (allDTRecHits) {
134  // take the theta SL of this chamber
135  const DTSuperLayer* sl = theChamber->superLayer(2);
136  // sl points to 0 if the theta SL was not found
137  if (sl) {
138  // reconstruct the theta segments
139  if (debug)
140  cout << "Reconstructing Theta segments" << endl;
142  vector<DTSLRecSegment2D> segments2DTheta(thetaSegs.begin(), thetaSegs.end());
143  theSegments2DTheta = segments2DTheta;
144  }
145  }
146 
147  bool hasZed = false;
148 
149  // has this chamber the Z-superlayer?
150  if (!theSegments2DTheta.empty()) {
151  hasZed = !theSegments2DTheta.empty();
152  if (debug)
153  cout << "There are " << theSegments2DTheta.size() << " Theta cand" << endl;
154  } else {
155  if (debug)
156  cout << "No Theta candidates." << endl;
157  }
158 
159  // Now I want to build the concrete DTRecSegment4D.
160  if (debug)
161  cout << "Building the concrete DTRecSegment4D" << endl;
162  if (!resultPhi.empty()) {
163  for (vector<DTSegmentCand*>::const_iterator phi = resultPhi.begin(); phi != resultPhi.end(); ++phi) {
164  std::unique_ptr<DTChamberRecSegment2D> superPhi(**phi);
165 
166  theUpdator->update(superPhi.get(), true);
167  if (debug)
168  cout << "superPhi: " << *superPhi << endl;
169 
170  if (hasZed) {
171  // Create all the 4D-segment combining the Z view with the Phi one
172  // loop over the Z segments
173  for (vector<DTSLRecSegment2D>::const_iterator zed = theSegments2DTheta.begin(); zed != theSegments2DTheta.end();
174  ++zed) {
175  // Important!!
176  DTSuperLayerId ZedSegSLId(zed->geographicalId().rawId());
177 
178  // Put the theta segment poistion in its 3D place.
179  // note: (superPhi is in the CHAMBER local frame)
180  const DTSuperLayer* zSL = theChamber->superLayer(ZedSegSLId);
181 
182  // FIXME: should rather extrapolate for Y!
183  LocalPoint zPos(
184  zed->localPosition().x(), (zSL->toLocal(theChamber->toGlobal(superPhi->localPosition()))).y(), 0.);
185 
186  const LocalPoint posZInCh = theChamber->toLocal(zSL->toGlobal(zPos));
187  // FIXME: zed->localDirection() is in 2D. Should add the phi direction in the orthogonal plane as well!!
188  const LocalVector dirZInCh = theChamber->toLocal(zSL->toGlobal(zed->localDirection()));
189 
190  DTRecSegment4D* newSeg = new DTRecSegment4D(*superPhi, *zed, posZInCh, dirZInCh);
191 
193  theUpdator->update(newSeg, false, true);
194  if (debug)
195  cout << "Created a 4D seg " << *newSeg << endl;
196 
197  //update the segment with the t0 and possibly vdrift correction
198  if (!applyT0corr && computeT0corr)
199  theUpdator->calculateT0corr(newSeg);
200  if (applyT0corr)
201  theUpdator->update(newSeg, true, true);
202 
203  result.push_back(newSeg);
204  }
205  } else {
206  // Only phi
207  DTRecSegment4D* newSeg = new DTRecSegment4D(*superPhi);
208 
209  if (debug)
210  cout << "Created a 4D segment using only the 2D Phi segment" << endl;
211 
212  //update the segment with the t0 and possibly vdrift correction
213  if (!applyT0corr && computeT0corr)
214  theUpdator->calculateT0corr(newSeg);
215  if (applyT0corr)
216  theUpdator->update(newSeg, true, true);
217 
218  result.push_back(newSeg);
219  }
220  }
221  } else {
222  // DTRecSegment4D from zed projection only (unlikely, not so useful, but...)
223  if (hasZed) {
224  for (vector<DTSLRecSegment2D>::const_iterator zed = theSegments2DTheta.begin(); zed != theSegments2DTheta.end();
225  ++zed) {
226  // Important!!
227  DTSuperLayerId ZedSegSLId(zed->geographicalId().rawId());
228 
229  const LocalPoint posZInCh =
230  theChamber->toLocal(theChamber->superLayer(ZedSegSLId)->toGlobal(zed->localPosition()));
231  const LocalVector dirZInCh =
232  theChamber->toLocal(theChamber->superLayer(ZedSegSLId)->toGlobal(zed->localDirection()));
233 
234  DTRecSegment4D* newSeg = new DTRecSegment4D(*zed, posZInCh, dirZInCh);
235  // <<
236 
237  if (debug)
238  cout << "Created a 4D segment using only the 2D Theta segment" << endl;
239 
240  if (!applyT0corr && computeT0corr)
241  theUpdator->calculateT0corr(newSeg);
242  if (applyT0corr)
243  theUpdator->update(newSeg, true, true);
244 
245  result.push_back(newSeg);
246  }
247  }
248  }
249  // finally delete the candidates!
250  for (vector<DTSegmentCand*>::iterator phi = resultPhi.begin(); phi != resultPhi.end(); ++phi)
251  delete *phi;
252 
253  return result;
254 }
255 
257  vector<std::shared_ptr<DTHitPairForFit>>& pairPhiOwned) {
258  DTSuperLayerId slId;
259 
260  if (!theHitsFromPhi1.empty())
261  slId = theHitsFromPhi1.front().wireId().superlayerId();
262  else if (!theHitsFromPhi2.empty())
263  slId = theHitsFromPhi2.front().wireId().superlayerId();
264  else {
265  if (debug)
266  cout << "DTMeantimerPatternReco4D::buildPhiSuperSegmentsCandidates: "
267  << "No Hits in the two Phi SL" << endl;
268  return vector<DTSegmentCand*>();
269  }
270 
271  const DTSuperLayer* sl = theDTGeometry->superLayer(slId);
272 
273  vector<std::shared_ptr<DTHitPairForFit>> pairPhi1 = the2DAlgo->initHits(sl, theHitsFromPhi1);
274  // same sl!! Since the fit will be in the sl phi 1!
275  vector<std::shared_ptr<DTHitPairForFit>> pairPhi2 = the2DAlgo->initHits(sl, theHitsFromPhi2);
276  // copy the pairPhi2 in the pairPhi1 vector
277  copy(pairPhi2.begin(), pairPhi2.end(), back_inserter(pairPhi1));
278 
279  pairPhiOwned.swap(pairPhi1);
280  // Build the segment candidate
281  return the2DAlgo->buildSegments(sl, pairPhiOwned);
282 }
Vector3DBase< float, LocalTag >
DTChamber::id
DTChamberId id() const
Return the DTChamberId of this chamber.
Definition: DTChamber.cc:32
DTMeantimerPatternReco4D::setDTRecSegment2DContainer
void setDTRecSegment2DContainer(edm::Handle< DTRecSegment2DCollection > all2DSegments) override
Definition: DTMeantimerPatternReco4D.cc:103
DTSuperLayerId
Definition: DTSuperLayerId.h:12
DDAxes::y
DTRecSegment4D
Definition: DTRecSegment4D.h:23
DTMeantimerPatternReco4D::buildPhiSuperSegmentsCandidates
std::vector< DTSegmentCand * > buildPhiSuperSegmentsCandidates(std::vector< std::shared_ptr< DTHitPairForFit >> &pairPhiOwned)
Definition: DTMeantimerPatternReco4D.cc:256
DTMeantimerPatternReco4D::computeT0corr
bool computeT0corr
Definition: DTMeantimerPatternReco4D.h:85
DTMeantimerPatternReco4D::theUpdator
DTSegmentUpdator * theUpdator
Definition: DTMeantimerPatternReco4D.h:78
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
edm::OwnVector::end
iterator end()
Definition: OwnVector.h:285
DTSegmentUpdator::calculateT0corr
void calculateT0corr(DTRecSegment2D *seg) const
Definition: DTSegmentUpdator.cc:618
DTMeantimerPatternReco::initHits
std::vector< std::shared_ptr< DTHitPairForFit > > initHits(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits)
Definition: DTMeantimerPatternReco.cc:85
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DTMeantimerPatternReco::buildSegments
std::vector< DTSegmentCand * > buildSegments(const DTSuperLayer *sl, const std::vector< std::shared_ptr< DTHitPairForFit >> &hits)
Definition: DTMeantimerPatternReco.cc:94
DTMeantimerPatternReco::reconstruct
edm::OwnVector< DTSLRecSegment2D > reconstruct(const DTSuperLayer *sl, const std::vector< DTRecHit1DPair > &hits) override
this function is called in the producer
Definition: DTMeantimerPatternReco.cc:57
DTMeantimerPatternReco4D::~DTMeantimerPatternReco4D
~DTMeantimerPatternReco4D() override
Destructor.
Definition: DTMeantimerPatternReco4D.cc:57
DTMeantimerPatternReco4D::theAlgoName
std::string theAlgoName
Definition: DTMeantimerPatternReco4D.h:65
DTSuperLayer
Definition: DTSuperLayer.h:24
DTMeantimerPatternReco4D.h
edm::Handle< DTRecHitCollection >
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
DTMeantimerPatternReco.h
DTMeantimerPatternReco4D::debug
bool debug
Definition: DTMeantimerPatternReco4D.h:67
DTGeometry::chamber
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:90
DTMeantimerPatternReco4D::theChamber
const DTChamber * theChamber
Definition: DTMeantimerPatternReco4D.h:80
DTSegmentUpdator
Definition: DTSegmentUpdator.h:43
DTSegmentCand.h
DTMeantimerPatternReco
Definition: DTMeantimerPatternReco.h:43
DTMeantimerPatternReco4D::setDTRecHit1DContainer
void setDTRecHit1DContainer(edm::Handle< DTRecHitCollection > all1DHits) override
Definition: DTMeantimerPatternReco4D.cc:73
DTMeantimerPatternReco4D::setChamber
void setChamber(const DTChamberId &chId) override
Definition: DTMeantimerPatternReco4D.cc:68
DTMeantimerPatternReco4D::theSegments2DTheta
std::vector< DTSLRecSegment2D > theSegments2DTheta
Definition: DTMeantimerPatternReco4D.h:88
DTMeantimerPatternReco4D::allDTRecHits
bool allDTRecHits
Definition: DTMeantimerPatternReco4D.h:83
Point3DBase< float, LocalTag >
GeomDet::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
DTMeantimerPatternReco4D::reconstruct
edm::OwnVector< DTRecSegment4D > reconstruct() override
Operations.
Definition: DTMeantimerPatternReco4D.cc:119
GeomDet::toGlobal
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
edm::ParameterSet
Definition: ParameterSet.h:47
DTRangeMapAccessor::layersBySuperLayer
static std::pair< DTLayerId, DTSuperLayerIdComparator > layersBySuperLayer(DTSuperLayerId slId)
Access by SL objects written into a RangeMap by layer.
Definition: DTRangeMapAccessor.cc:15
DTMeantimerPatternReco4D::theDTGeometry
edm::ESHandle< DTGeometry > theDTGeometry
Definition: DTMeantimerPatternReco4D.h:71
DTRangeMapAccessor.h
DTRecSegment4DBaseAlgo
Definition: DTRecSegment4DBaseAlgo.h:33
DTMeantimerPatternReco4D::the2DAlgo
DTMeantimerPatternReco * the2DAlgo
Definition: DTMeantimerPatternReco4D.h:75
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
DTRecHit1DPair.h
edm::EventSetup
Definition: EventSetup.h:58
DTMeantimerPatternReco::setES
void setES(const edm::EventSetup &setup) override
Definition: DTMeantimerPatternReco.cc:79
DTSegmentUpdator::setES
void setES(const edm::EventSetup &setup)
set the setup
Definition: DTSegmentUpdator.cc:68
get
#define get
DTSegmentUpdator.h
DTChamberRecSegment2D.h
DTMeantimerPatternReco4D::DTMeantimerPatternReco4D
DTMeantimerPatternReco4D(const edm::ParameterSet &pset)
Constructor.
Definition: DTMeantimerPatternReco4D.cc:32
DDAxes::phi
DTMeantimerPatternReco4D::theHitsFromPhi1
std::vector< DTRecHit1DPair > theHitsFromPhi1
Definition: DTMeantimerPatternReco4D.h:89
edm::RangeMap::range
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
std
Definition: JetResolutionObject.h:76
DTWireId.h
EventSetup.h
DTSLRecSegment2D.h
mps_fire.result
result
Definition: mps_fire.py:311
DTGeometry::superLayer
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return a DTSuperLayer given its id.
Definition: DTGeometry.cc:92
DTMeantimerPatternReco4D::setES
void setES(const edm::EventSetup &setup) override
Definition: DTMeantimerPatternReco4D.cc:62
DTChamberId
Definition: DTChamberId.h:14
ParameterSet.h
edm::OwnVector::begin
iterator begin()
Definition: OwnVector.h:280
OwnVector.h
MuonGeometryRecord.h
DTChamber::superLayer
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return the superlayer corresponding to the given id.
Definition: DTChamber.cc:53
DTMeantimerPatternReco4D::theHitsFromPhi2
std::vector< DTRecHit1DPair > theHitsFromPhi2
Definition: DTMeantimerPatternReco4D.h:91
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
DTMeantimerPatternReco4D::applyT0corr
bool applyT0corr
Definition: DTMeantimerPatternReco4D.h:84
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::OwnVector
Definition: OwnVector.h:24
DTMeantimerPatternReco4D::theHitsFromTheta
std::vector< DTRecHit1DPair > theHitsFromTheta
Definition: DTMeantimerPatternReco4D.h:90
DTSegmentUpdator::update
void update(DTRecSegment4D *seg, const bool calcT0, bool allow3par) const
recompute hits position and refit the segment4D
Definition: DTSegmentUpdator.cc:73