CMS 3D CMS Logo

DTRefitAndCombineReco4D.cc
Go to the documentation of this file.
1 
12 
15 
19 
23 
25 
26 using namespace std;
27 using namespace edm;
28 
30  : DTRecSegment4DBaseAlgo(pset), theAlgoName("DTRefitAndCombineReco4D") {
31  // debug parameter
32  debug = pset.getUntrackedParameter<bool>("debug");
33 
34  // the updator
36 
37  // the max allowd chi^2 for the fit of th combination of two phi segments
38  theMaxChi2forPhi = pset.getParameter<double>("MaxChi2forPhi");
39 }
40 
44  // the2DAlgo->setES(setup);
45 }
46 
48  // Set the chamber
50 }
51 
53  theSegments2DPhi1.clear();
54  theSegments2DTheta.clear();
55  theSegments2DPhi2.clear();
56 
57  // Get the chamber
58  // const DTChamber *chamber = theDTGeometry->chamber(chId);
59 
60  const DTChamberId chId = theChamber->id();
61 
62  //Extract the DTRecSegment2DCollection ranges for the three different SL
63  DTRecSegment2DCollection::range rangePhi1 = allHits->get(DTSuperLayerId(chId, 1));
64  DTRecSegment2DCollection::range rangeTheta = allHits->get(DTSuperLayerId(chId, 2));
65  DTRecSegment2DCollection::range rangePhi2 = allHits->get(DTSuperLayerId(chId, 3));
66 
67  // Fill the DTSLRecSegment2D containers for the three different SL
68  vector<DTSLRecSegment2D> segments2DPhi1(rangePhi1.first, rangePhi1.second);
69  vector<DTSLRecSegment2D> segments2DTheta(rangeTheta.first, rangeTheta.second);
70  vector<DTSLRecSegment2D> segments2DPhi2(rangePhi2.first, rangePhi2.second);
71 
72  if (debug)
73  cout << "Number of 2D-segments in the first SL (Phi)" << segments2DPhi1.size() << endl
74  << "Number of 2D-segments in the second SL (Theta)" << segments2DTheta.size() << endl
75  << "Number of 2D-segments in the third SL (Phi)" << segments2DPhi2.size() << endl;
76 
77  theSegments2DPhi1 = segments2DPhi1;
78  theSegments2DTheta = segments2DTheta;
79  theSegments2DPhi2 = segments2DPhi2;
80 }
81 
84 
85  if (debug)
86  cout << "Segments in " << theChamber->id() << endl;
87 
88  vector<DTChamberRecSegment2D> resultPhi = refitSuperSegments();
89 
90  if (debug)
91  cout << "There are " << resultPhi.size() << " Phi cand" << endl;
92 
93  bool hasZed = false;
94 
95  // has this chamber the Z-superlayer?
96  if (!theSegments2DTheta.empty()) {
97  hasZed = !theSegments2DTheta.empty();
98  if (debug)
99  cout << "There are " << theSegments2DTheta.size() << " Theta cand" << endl;
100  } else {
101  if (debug)
102  cout << "No Theta SL" << endl;
103  }
104 
105  // Now I want to build the concrete DTRecSegment4D.
106  if (!resultPhi.empty()) {
107  for (vector<DTChamberRecSegment2D>::const_iterator phi = resultPhi.begin(); phi != resultPhi.end(); ++phi) {
108  if (hasZed) {
109  // Create all the 4D-segment combining the Z view with the Phi one
110  // loop over the Z segments
111  for (vector<DTSLRecSegment2D>::const_iterator zed = theSegments2DTheta.begin(); zed != theSegments2DTheta.end();
112  ++zed) {
113  //>> Important!!
114  DTSuperLayerId ZedSegSLId(zed->geographicalId().rawId());
115 
116  const LocalPoint posZInCh =
117  theChamber->toLocal(theChamber->superLayer(ZedSegSLId)->toGlobal(zed->localPosition()));
118  const LocalVector dirZInCh =
119  theChamber->toLocal(theChamber->superLayer(ZedSegSLId)->toGlobal(zed->localDirection()));
120 
121  DTRecSegment4D* newSeg = new DTRecSegment4D(*phi, *zed, posZInCh, dirZInCh);
122  //<<
123 
125  theUpdator->update(newSeg, false, true);
126  if (debug)
127  cout << "Created a 4D seg " << endl;
128  result.push_back(newSeg);
129  }
130  } else {
131  // Only phi
132  DTRecSegment4D* newSeg = new DTRecSegment4D(*phi);
133  if (debug)
134  cout << "Created a 4D segment using only the 2D Phi segment" << endl;
135  result.push_back(newSeg);
136  }
137  }
138  } else {
139  // DTRecSegment4D from zed projection only (unlikely, not so useful, but...)
140  if (hasZed) {
141  for (vector<DTSLRecSegment2D>::const_iterator zed = theSegments2DTheta.begin(); zed != theSegments2DTheta.end();
142  ++zed) {
143  // Important!!
144  DTSuperLayerId ZedSegSLId(zed->geographicalId().rawId());
145 
146  const LocalPoint posZInCh =
147  theChamber->toLocal(theChamber->superLayer(ZedSegSLId)->toGlobal(zed->localPosition()));
148  const LocalVector dirZInCh =
149  theChamber->toLocal(theChamber->superLayer(ZedSegSLId)->toGlobal(zed->localDirection()));
150 
151  DTRecSegment4D* newSeg = new DTRecSegment4D(*zed, posZInCh, dirZInCh);
152  //<<
153 
154  if (debug)
155  cout << "Created a 4D segment using only the 2D Theta segment" << endl;
156  result.push_back(newSeg);
157  }
158  }
159  }
160 
161  return result;
162 }
163 
164 vector<DTChamberRecSegment2D> DTRefitAndCombineReco4D::refitSuperSegments() {
165  vector<DTChamberRecSegment2D> result;
166 
167  //double-loop over all the DTSLRecSegment2D in order to make all the possible pairs
168  for (vector<DTSLRecSegment2D>::const_iterator segment2DPhi1 = theSegments2DPhi1.begin();
169  segment2DPhi1 != theSegments2DPhi1.end();
170  ++segment2DPhi1) {
171  for (vector<DTSLRecSegment2D>::const_iterator segment2DPhi2 = theSegments2DPhi2.begin();
172  segment2DPhi2 != theSegments2DPhi2.end();
173  ++segment2DPhi2) {
174  // check the id
175  if (segment2DPhi1->chamberId() != segment2DPhi2->chamberId())
176  throw cms::Exception("refitSuperSegments") << "he phi segments have different chamber id" << std::endl;
177 
178  // create a super phi starting from 2 phi
179  vector<DTRecHit1D> recHitsSeg2DPhi1 = segment2DPhi1->specificRecHits();
180  vector<DTRecHit1D> recHitsSeg2DPhi2 = segment2DPhi2->specificRecHits();
181  // copy the recHitsSeg2DPhi2 in the recHitsSeg2DPhi1 container
182  copy(recHitsSeg2DPhi2.begin(), recHitsSeg2DPhi2.end(), back_inserter(recHitsSeg2DPhi1));
183 
184  const DTChamberId chId = segment2DPhi1->chamberId();
185 
186  // create the super phi
187  DTChamberRecSegment2D superPhi(chId, recHitsSeg2DPhi1);
188 
189  // refit it!
190  theUpdator->fit(&superPhi, false, false);
191 
192  // cut on the chi^2
193  if (superPhi.chi2() > theMaxChi2forPhi)
194  result.push_back(superPhi);
195  }
196  }
197  // TODO clean the container!!!
198  // there are some possible repetition!
199  // maybe using the cleaner, previous a conversion from DTChamberRecSegment2D to DTSegmentCandidate
200  return result;
201 }
Vector3DBase< float, LocalTag >
DTChamber::id
DTChamberId id() const
Return the DTChamberId of this chamber.
Definition: DTChamber.cc:32
DTRefitAndCombineReco4D::theSegments2DPhi2
std::vector< DTSLRecSegment2D > theSegments2DPhi2
Definition: DTRefitAndCombineReco4D.h:82
DTRecSegment2DCollection.h
DTRefitAndCombineReco4D::theUpdator
DTSegmentUpdator * theUpdator
Definition: DTRefitAndCombineReco4D.h:77
DTSuperLayerId
Definition: DTSuperLayerId.h:12
DTRefitAndCombineReco4D::theDTGeometry
edm::ESHandle< DTGeometry > theDTGeometry
Definition: DTRefitAndCombineReco4D.h:71
DTRecSegment4D
Definition: DTRecSegment4D.h:23
DTRefitAndCombineReco4D::debug
bool debug
Definition: DTRefitAndCombineReco4D.h:67
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DTRefitAndCombineReco4D::setChamber
void setChamber(const DTChamberId &chId) override
Definition: DTRefitAndCombineReco4D.cc:47
edm
HLT enums.
Definition: AlignableModifier.h:19
DTRefitAndCombineReco4D.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::Handle
Definition: AssociativeIterator.h:50
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
DTGeometry::chamber
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:90
DTRefitAndCombineReco4D::setES
void setES(const edm::EventSetup &setup) override
Definition: DTRefitAndCombineReco4D.cc:41
DTSegmentUpdator
Definition: DTSegmentUpdator.h:43
DTSegmentCand.h
DTRefitAndCombineReco4D::setDTRecSegment2DContainer
void setDTRecSegment2DContainer(edm::Handle< DTRecSegment2DCollection > all2DSegments) override
Definition: DTRefitAndCombineReco4D.cc:52
DTRefitAndCombineReco4D::theMaxChi2forPhi
double theMaxChi2forPhi
Definition: DTRefitAndCombineReco4D.h:65
DTRefitAndCombineReco4D::DTRefitAndCombineReco4D
DTRefitAndCombineReco4D(const edm::ParameterSet &pset)
Constructor.
Definition: DTRefitAndCombineReco4D.cc:29
DTRefitAndCombineReco4D::theChamber
const DTChamber * theChamber
Definition: DTRefitAndCombineReco4D.h:79
DTSegmentUpdator::fit
bool fit(DTSegmentCand *seg, bool allow3par, const bool fitdebug) const
Definition: DTSegmentUpdator.cc:216
Point3DBase< float, LocalTag >
GeomDet::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
DTRefitAndCombineReco4D::theSegments2DPhi1
std::vector< DTSLRecSegment2D > theSegments2DPhi1
Definition: DTRefitAndCombineReco4D.h:80
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
DTRecSegment2D::chi2
double chi2() const override
the chi2 of the fit
Definition: DTRecSegment2D.h:96
DTRecSegment4DBaseAlgo
Definition: DTRecSegment4DBaseAlgo.h:33
DTChamberRecSegment2D
Definition: DTChamberRecSegment2D.h:31
edm::EventSetup
Definition: EventSetup.h:57
DTRefitAndCombineReco4D::refitSuperSegments
std::vector< DTChamberRecSegment2D > refitSuperSegments()
Definition: DTRefitAndCombineReco4D.cc:164
DTSegmentUpdator::setES
void setES(const edm::EventSetup &setup)
set the setup
Definition: DTSegmentUpdator.cc:68
get
#define get
DTSegmentUpdator.h
DTChamberRecSegment2D.h
DDAxes::phi
edm::RangeMap::range
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
std
Definition: JetResolutionObject.h:76
EventSetup.h
Exception.h
DTRefitAndCombineReco4D::reconstruct
edm::OwnVector< DTRecSegment4D > reconstruct() override
Operations.
Definition: DTRefitAndCombineReco4D.cc:82
mps_fire.result
result
Definition: mps_fire.py:311
cms::Exception
Definition: Exception.h:70
DTRefitAndCombineReco4D::theSegments2DTheta
std::vector< DTSLRecSegment2D > theSegments2DTheta
Definition: DTRefitAndCombineReco4D.h:81
DTChamberId
Definition: DTChamberId.h:14
ParameterSet.h
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
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::OwnVector
Definition: OwnVector.h:24
DTSegmentUpdator::update
void update(DTRecSegment4D *seg, const bool calcT0, bool allow3par) const
recompute hits position and refit the segment4D
Definition: DTSegmentUpdator.cc:73