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 applyT0corr = pset.getParameter<bool>("performT0SegCorrection");
00042
00043 computeT0corr = pset.existsAs<bool>("computeT0Seg") ?
00044 pset.getParameter<bool>("computeT0Seg") : true;
00045
00046
00047 theUpdator = new DTSegmentUpdator(pset);
00048
00049
00050
00051
00052
00053
00054 allDTRecHits = pset.getParameter<bool>("AllDTRecHits");
00055
00056
00057
00058 the2DAlgo = new DTMeantimerPatternReco(pset.getParameter<ParameterSet>("Reco2DAlgoConfig"));
00059
00060 }
00061
00062
00063 DTMeantimerPatternReco4D::~DTMeantimerPatternReco4D(){
00064 delete the2DAlgo;
00065 delete theUpdator;
00066 }
00067
00068 void DTMeantimerPatternReco4D::setES(const EventSetup& setup){
00069 setup.get<MuonGeometryRecord>().get(theDTGeometry);
00070 the2DAlgo->setES(setup);
00071 theUpdator->setES(setup);
00072 }
00073
00074 void DTMeantimerPatternReco4D::setChamber(const DTChamberId &chId){
00075
00076 theChamber = theDTGeometry->chamber(chId);
00077 }
00078
00079 void DTMeantimerPatternReco4D::setDTRecHit1DContainer(Handle<DTRecHitCollection> all1DHits){
00080 theHitsFromPhi1.clear();
00081 theHitsFromPhi2.clear();
00082 theHitsFromTheta.clear();
00083
00084 DTRecHitCollection::range rangeHitsFromPhi1 =
00085 all1DHits->get(DTRangeMapAccessor::layersBySuperLayer( DTSuperLayerId(theChamber->id(),1) ) );
00086 DTRecHitCollection::range rangeHitsFromPhi2 =
00087 all1DHits->get(DTRangeMapAccessor::layersBySuperLayer( DTSuperLayerId(theChamber->id(),3) ) );
00088
00089 vector<DTRecHit1DPair> hitsFromPhi1(rangeHitsFromPhi1.first,rangeHitsFromPhi1.second);
00090 vector<DTRecHit1DPair> hitsFromPhi2(rangeHitsFromPhi2.first,rangeHitsFromPhi2.second);
00091 if(debug)
00092 cout<< "Number of DTRecHit1DPair in the SL 1 (Phi 1): " << hitsFromPhi1.size()<<endl
00093 << "Number of DTRecHit1DPair in the SL 3 (Phi 2): " << hitsFromPhi2.size()<<endl;
00094
00095 theHitsFromPhi1 = hitsFromPhi1;
00096 theHitsFromPhi2 = hitsFromPhi2;
00097
00098 if(allDTRecHits){
00099 DTRecHitCollection::range rangeHitsFromTheta =
00100 all1DHits->get(DTRangeMapAccessor::layersBySuperLayer( DTSuperLayerId(theChamber->id(),2) ) );
00101
00102 vector<DTRecHit1DPair> hitsFromTheta(rangeHitsFromTheta.first,rangeHitsFromTheta.second);
00103 if(debug)
00104 cout<< "Number of DTRecHit1DPair in the SL 2 (Theta): " << hitsFromTheta.size()<<endl;
00105 theHitsFromTheta = hitsFromTheta;
00106 }
00107
00108 }
00109
00110 void DTMeantimerPatternReco4D::setDTRecSegment2DContainer(Handle<DTRecSegment2DCollection> all2DSegments){
00111 theSegments2DTheta.clear();
00112
00113 if(!allDTRecHits){
00114
00115
00116 DTRecSegment2DCollection::range rangeTheta =
00117 all2DSegments->get(DTSuperLayerId(theChamber->id(),2));
00118
00119
00120 vector<DTSLRecSegment2D> segments2DTheta(rangeTheta.first,rangeTheta.second);
00121
00122 if(debug)
00123 cout << "Number of 2D-segments in the second SL (Theta): " << segments2DTheta.size() << endl;
00124 theSegments2DTheta = segments2DTheta;
00125 }
00126
00127 }
00128
00129
00130 OwnVector<DTRecSegment4D>
00131 DTMeantimerPatternReco4D::reconstruct(){
00132
00133 OwnVector<DTRecSegment4D> result;
00134
00135 if (debug){
00136 cout << "Segments in " << theChamber->id() << endl;
00137 cout << "Reconstructing Phi segments"<<endl;
00138 }
00139 vector<DTSegmentCand*> resultPhi = buildPhiSuperSegmentsCandidates();
00140
00141 if (debug) cout << "There are " << resultPhi.size() << " Phi cand" << endl;
00142
00143 if (allDTRecHits){
00144
00145 const DTSuperLayer* sl = theChamber->superLayer(2);
00146
00147 if(sl){
00148
00149 if(debug) cout << "Reconstructing Theta segments"<<endl;
00150 OwnVector<DTSLRecSegment2D> thetaSegs = the2DAlgo->reconstruct(sl, theHitsFromTheta);
00151 vector<DTSLRecSegment2D> segments2DTheta(thetaSegs.begin(),thetaSegs.end());
00152 theSegments2DTheta = segments2DTheta;
00153 }
00154 }
00155
00156 bool hasZed=false;
00157
00158
00159 if (theSegments2DTheta.size()){
00160 hasZed = theSegments2DTheta.size()>0;
00161 if (debug) cout << "There are " << theSegments2DTheta.size() << " Theta cand" << endl;
00162 } else {
00163 if (debug) cout << "No Theta SL" << endl;
00164 }
00165
00166
00167 if(debug) cout<<"Building the concrete DTRecSegment4D"<<endl;
00168 if (resultPhi.size()) {
00169 for (vector<DTSegmentCand*>::const_iterator phi=resultPhi.begin();
00170 phi!=resultPhi.end(); ++phi) {
00171
00172 DTChamberRecSegment2D* superPhi = (**phi);
00173
00174 theUpdator->update(superPhi);
00175
00176 if (hasZed) {
00177
00178
00179
00180 for(vector<DTSLRecSegment2D>::const_iterator zed = theSegments2DTheta.begin();
00181 zed != theSegments2DTheta.end(); ++zed){
00182
00183
00184 DTSuperLayerId ZedSegSLId(zed->geographicalId().rawId());
00185
00186
00187
00188 const DTSuperLayer* zSL = theChamber->superLayer(ZedSegSLId);
00189
00190
00191 LocalPoint zPos(zed->localPosition().x(),
00192 (zSL->toLocal(theChamber->toGlobal(superPhi->localPosition()))).y(),
00193 0.);
00194
00195 const LocalPoint posZInCh = theChamber->toLocal( zSL->toGlobal(zPos));
00196
00197 const LocalVector dirZInCh = theChamber->toLocal( zSL->toGlobal(zed->localDirection()));
00198
00199 DTRecSegment4D* newSeg = new DTRecSegment4D(*superPhi,*zed,posZInCh,dirZInCh);
00200
00201
00203 theUpdator->update(newSeg);
00204 if (debug) cout << "Created a 4D seg " << *newSeg << endl;
00205
00206
00207 if(!applyT0corr && computeT0corr) theUpdator->calculateT0corr(newSeg);
00208 if(applyT0corr) theUpdator->update(newSeg,true);
00209
00210 result.push_back(newSeg);
00211 }
00212 } else {
00213
00214 DTRecSegment4D* newSeg = new DTRecSegment4D(*superPhi);
00215
00216 if (debug) cout << "Created a 4D segment using only the 2D Phi segment" << endl;
00217
00218
00219 if(!applyT0corr && computeT0corr) theUpdator->calculateT0corr(newSeg);
00220 if(applyT0corr) theUpdator->update(newSeg,true);
00221
00222 result.push_back(newSeg);
00223 }
00224 }
00225 } else {
00226
00227 if (hasZed) {
00228 for(vector<DTSLRecSegment2D>::const_iterator zed = theSegments2DTheta.begin();
00229 zed != theSegments2DTheta.end(); ++zed){
00230
00231
00232 DTSuperLayerId ZedSegSLId(zed->geographicalId().rawId());
00233
00234 const LocalPoint posZInCh = theChamber->toLocal( theChamber->superLayer(ZedSegSLId)->toGlobal(zed->localPosition() )) ;
00235 const LocalVector dirZInCh = theChamber->toLocal( theChamber->superLayer(ZedSegSLId)->toGlobal(zed->localDirection() )) ;
00236
00237 DTRecSegment4D* newSeg = new DTRecSegment4D( *zed,posZInCh,dirZInCh);
00238
00239
00240 if (debug) cout << "Created a 4D segment using only the 2D Theta segment" << endl;
00241
00242 if(!applyT0corr && computeT0corr) theUpdator->calculateT0corr(newSeg);
00243 if(applyT0corr) theUpdator->update(newSeg,true);
00244
00245 result.push_back(newSeg);
00246 }
00247 }
00248 }
00249
00250 for (vector<DTSegmentCand*>::iterator phi=resultPhi.begin();
00251 phi!=resultPhi.end(); ++phi) delete *phi;
00252
00253 return result;
00254 }
00255
00256
00257
00258 vector<DTSegmentCand*> DTMeantimerPatternReco4D::buildPhiSuperSegmentsCandidates(){
00259
00260 DTSuperLayerId slId;
00261
00262 if(theHitsFromPhi1.size())
00263 slId = theHitsFromPhi1.front().wireId().superlayerId();
00264 else
00265 if(theHitsFromPhi2.size())
00266 slId = theHitsFromPhi2.front().wireId().superlayerId();
00267 else{
00268 if(debug) cout<<"DTMeantimerPatternReco4D::buildPhiSuperSegmentsCandidates: "
00269 <<"No Hits in the two Phi SL"<<endl;
00270 return vector<DTSegmentCand*>();
00271 }
00272
00273 const DTSuperLayer *sl = theDTGeometry->superLayer(slId);
00274
00275 vector<DTHitPairForFit*> pairPhi1 = the2DAlgo->initHits(sl,theHitsFromPhi1);
00276
00277 vector<DTHitPairForFit*> pairPhi2 = the2DAlgo->initHits(sl,theHitsFromPhi2);
00278
00279 copy(pairPhi2.begin(),pairPhi2.end(),back_inserter(pairPhi1));
00280
00281
00282 return the2DAlgo->buildSegments(sl,pairPhi1);
00283 }