Go to the documentation of this file.00001
00008 #include "RecoLocalMuon/DTSegment/src/DTMeantimerPatternReco4D.h"
00009
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011 #include "FWCore/Framework/interface/EventSetup.h"
00012
00013 #include "RecoLocalMuon/DTSegment/src/DTSegmentUpdator.h"
00014
00015 #include "RecoLocalMuon/DTSegment/src/DTMeantimerPatternReco.h"
00016 #include "RecoLocalMuon/DTSegment/src/DTSegmentCand.h"
00017
00018 #include "DataFormats/Common/interface/OwnVector.h"
00019 #include "DataFormats/DTRecHit/interface/DTRangeMapAccessor.h"
00020 #include "DataFormats/MuonDetId/interface/DTWireId.h"
00021 #include "DataFormats/DTRecHit/interface/DTRecHit1DPair.h"
00022 #include "DataFormats/DTRecHit/interface/DTSLRecSegment2D.h"
00023 #include "DataFormats/DTRecHit/interface/DTChamberRecSegment2D.h"
00024
00025 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00026
00027 using namespace std;
00028 using namespace edm;
00029
00030
00031
00032
00033
00034 DTMeantimerPatternReco4D::DTMeantimerPatternReco4D(const ParameterSet& pset):
00035 DTRecSegment4DBaseAlgo(pset), theAlgoName("DTMeantimerPatternReco4D"){
00036
00037
00038 debug = pset.getUntrackedParameter<bool>("debug");
00039
00040
00041 theUpdator = new DTSegmentUpdator(pset);
00042
00043
00044
00045
00046
00047
00048 allDTRecHits = pset.getParameter<bool>("AllDTRecHits");
00049
00050
00051
00052 the2DAlgo = new DTMeantimerPatternReco(pset.getParameter<ParameterSet>("Reco2DAlgoConfig"));
00053 }
00054
00055
00056 DTMeantimerPatternReco4D::~DTMeantimerPatternReco4D(){
00057 delete the2DAlgo;
00058 delete theUpdator;
00059 }
00060
00061 void DTMeantimerPatternReco4D::setES(const EventSetup& setup){
00062 setup.get<MuonGeometryRecord>().get(theDTGeometry);
00063 the2DAlgo->setES(setup);
00064 theUpdator->setES(setup);
00065 }
00066
00067 void DTMeantimerPatternReco4D::setChamber(const DTChamberId &chId){
00068
00069 theChamber = theDTGeometry->chamber(chId);
00070 }
00071
00072 void DTMeantimerPatternReco4D::setDTRecHit1DContainer(Handle<DTRecHitCollection> all1DHits){
00073 theHitsFromPhi1.clear();
00074 theHitsFromPhi2.clear();
00075 theHitsFromTheta.clear();
00076
00077 DTRecHitCollection::range rangeHitsFromPhi1 =
00078 all1DHits->get(DTRangeMapAccessor::layersBySuperLayer( DTSuperLayerId(theChamber->id(),1) ) );
00079 DTRecHitCollection::range rangeHitsFromPhi2 =
00080 all1DHits->get(DTRangeMapAccessor::layersBySuperLayer( DTSuperLayerId(theChamber->id(),3) ) );
00081
00082 vector<DTRecHit1DPair> hitsFromPhi1(rangeHitsFromPhi1.first,rangeHitsFromPhi1.second);
00083 vector<DTRecHit1DPair> hitsFromPhi2(rangeHitsFromPhi2.first,rangeHitsFromPhi2.second);
00084 if(debug)
00085 cout<< "Number of DTRecHit1DPair in the SL 1 (Phi 1): " << hitsFromPhi1.size()<<endl
00086 << "Number of DTRecHit1DPair in the SL 3 (Phi 2): " << hitsFromPhi2.size()<<endl;
00087
00088 theHitsFromPhi1 = hitsFromPhi1;
00089 theHitsFromPhi2 = hitsFromPhi2;
00090
00091 if(allDTRecHits){
00092 DTRecHitCollection::range rangeHitsFromTheta =
00093 all1DHits->get(DTRangeMapAccessor::layersBySuperLayer( DTSuperLayerId(theChamber->id(),2) ) );
00094
00095 vector<DTRecHit1DPair> hitsFromTheta(rangeHitsFromTheta.first,rangeHitsFromTheta.second);
00096 if(debug)
00097 cout<< "Number of DTRecHit1DPair in the SL 2 (Theta): " << hitsFromTheta.size()<<endl;
00098 theHitsFromTheta = hitsFromTheta;
00099 }
00100
00101 }
00102
00103 void DTMeantimerPatternReco4D::setDTRecSegment2DContainer(Handle<DTRecSegment2DCollection> all2DSegments){
00104 theSegments2DTheta.clear();
00105
00106 if(!allDTRecHits){
00107
00108
00109 DTRecSegment2DCollection::range rangeTheta =
00110 all2DSegments->get(DTSuperLayerId(theChamber->id(),2));
00111
00112
00113 vector<DTSLRecSegment2D> segments2DTheta(rangeTheta.first,rangeTheta.second);
00114
00115 if(debug)
00116 cout << "Number of 2D-segments in the second SL (Theta): " << segments2DTheta.size() << endl;
00117 theSegments2DTheta = segments2DTheta;
00118 }
00119
00120 }
00121
00122
00123 OwnVector<DTRecSegment4D>
00124 DTMeantimerPatternReco4D::reconstruct(){
00125
00126 OwnVector<DTRecSegment4D> result;
00127
00128 if (debug){
00129 cout << "Segments in " << theChamber->id() << endl;
00130 cout << "Reconstructing Phi segments"<<endl;
00131 }
00132 vector<DTSegmentCand*> resultPhi = buildPhiSuperSegmentsCandidates();
00133
00134 if (debug) cout << "There are " << resultPhi.size() << " Phi cand" << endl;
00135
00136 if (allDTRecHits){
00137
00138 const DTSuperLayer* sl = theChamber->superLayer(2);
00139
00140 if(sl){
00141
00142 if(debug) cout << "Reconstructing Theta segments"<<endl;
00143 OwnVector<DTSLRecSegment2D> thetaSegs = the2DAlgo->reconstruct(sl, theHitsFromTheta);
00144 vector<DTSLRecSegment2D> segments2DTheta(thetaSegs.begin(),thetaSegs.end());
00145 theSegments2DTheta = segments2DTheta;
00146 }
00147 }
00148
00149 bool hasZed=false;
00150
00151
00152 if (theSegments2DTheta.size()){
00153 hasZed = theSegments2DTheta.size()>0;
00154 if (debug) cout << "There are " << theSegments2DTheta.size() << " Theta cand" << endl;
00155 } else {
00156 if (debug) cout << "No Theta SL" << endl;
00157 }
00158
00159
00160 if(debug) cout<<"Building the concrete DTRecSegment4D"<<endl;
00161 if (resultPhi.size()) {
00162 for (vector<DTSegmentCand*>::const_iterator phi=resultPhi.begin();
00163 phi!=resultPhi.end(); ++phi) {
00164
00165 DTChamberRecSegment2D* superPhi = (**phi);
00166
00167 theUpdator->update(superPhi);
00168
00169 if (hasZed) {
00170
00171
00172
00173 for(vector<DTSLRecSegment2D>::const_iterator zed = theSegments2DTheta.begin();
00174 zed != theSegments2DTheta.end(); ++zed){
00175
00176
00177 DTSuperLayerId ZedSegSLId(zed->geographicalId().rawId());
00178
00179 const LocalPoint posZInCh = theChamber->toLocal( theChamber->superLayer(ZedSegSLId)->toGlobal(zed->localPosition() )) ;
00180 const LocalVector dirZInCh = theChamber->toLocal( theChamber->superLayer(ZedSegSLId)->toGlobal(zed->localDirection() )) ;
00181
00182 DTRecSegment4D* newSeg = new DTRecSegment4D(*superPhi,*zed,posZInCh,dirZInCh);
00183
00184
00186 theUpdator->update(newSeg);
00187 if (debug) cout << "Created a 4D seg " << *newSeg << endl;
00188 result.push_back(newSeg);
00189 }
00190 } else {
00191
00192 DTRecSegment4D* newSeg = new DTRecSegment4D(*superPhi);
00193
00194 if (debug) cout << "Created a 4D segment using only the 2D Phi segment" << endl;
00195 result.push_back(newSeg);
00196 }
00197 }
00198 } else {
00199
00200 if (hasZed) {
00201 for(vector<DTSLRecSegment2D>::const_iterator zed = theSegments2DTheta.begin();
00202 zed != theSegments2DTheta.end(); ++zed){
00203
00204
00205 DTSuperLayerId ZedSegSLId(zed->geographicalId().rawId());
00206
00207 const LocalPoint posZInCh = theChamber->toLocal( theChamber->superLayer(ZedSegSLId)->toGlobal(zed->localPosition() )) ;
00208 const LocalVector dirZInCh = theChamber->toLocal( theChamber->superLayer(ZedSegSLId)->toGlobal(zed->localDirection() )) ;
00209
00210 DTRecSegment4D* newSeg = new DTRecSegment4D( *zed,posZInCh,dirZInCh);
00211
00212
00213 if (debug) cout << "Created a 4D segment using only the 2D Theta segment" << endl;
00214 result.push_back(newSeg);
00215 }
00216 }
00217 }
00218
00219 for (vector<DTSegmentCand*>::iterator phi=resultPhi.begin();
00220 phi!=resultPhi.end(); ++phi) delete *phi;
00221
00222 return result;
00223 }
00224
00225
00226
00227 vector<DTSegmentCand*> DTMeantimerPatternReco4D::buildPhiSuperSegmentsCandidates(){
00228
00229 DTSuperLayerId slId;
00230
00231 if(theHitsFromPhi1.size())
00232 slId = theHitsFromPhi1.front().wireId().superlayerId();
00233 else
00234 if(theHitsFromPhi2.size())
00235 slId = theHitsFromPhi2.front().wireId().superlayerId();
00236 else{
00237 if(debug) cout<<"DTMeantimerPatternReco4D::buildPhiSuperSegmentsCandidates: "
00238 <<"No Hits in the two Phi SL"<<endl;
00239 return vector<DTSegmentCand*>();
00240 }
00241
00242 const DTSuperLayer *sl = theDTGeometry->superLayer(slId);
00243
00244 vector<DTHitPairForFit*> pairPhi1 = the2DAlgo->initHits(sl,theHitsFromPhi1);
00245
00246 vector<DTHitPairForFit*> pairPhi2 = the2DAlgo->initHits(sl,theHitsFromPhi2);
00247
00248 copy(pairPhi2.begin(),pairPhi2.end(),back_inserter(pairPhi1));
00249
00250
00251 return the2DAlgo->buildSegments(sl,pairPhi1);
00252 }