Skip to content

Commit

Permalink
merge the consumes changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ptraczyk authored and slava77devel committed Apr 24, 2014
1 parent 3ca6f62 commit 6d3131b
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 40 deletions.
Expand Up @@ -66,7 +66,7 @@ DTCombinatorialExtendedPatternReco::reconstruct(const DTSuperLayer* sl,

DTSLRecSegment2D *segment = (**cand);

theUpdator->update(segment);
theUpdator->update(segment,0);

result.push_back(segment);

Expand Down Expand Up @@ -419,7 +419,7 @@ DTCombinatorialExtendedPatternReco::buildPointsCollection(vector<DTSegmentCand::
}

DTSegmentCand* newCand = new DTSegmentCand(pointsSet,sl);
if (theUpdator->fit(newCand)) candidates.push_back(newCand);
if (theUpdator->fit(newCand,0,0)) candidates.push_back(newCand);
else delete newCand; // bad seg, too few hits
}
}
Expand Down Expand Up @@ -490,7 +490,7 @@ DTCombinatorialExtendedPatternReco::extendCandidates(vector<DTSegmentCand*>& can
}
// fit the segment
if (debug) cout << "extended cands nHits: " << extendedCand->nHits() <<endl;
if (theUpdator->fit(extendedCand)) {
if (theUpdator->fit(extendedCand,0,0)) {
// add to result
result.push_back(extendedCand);
} else {
Expand Down
4 changes: 2 additions & 2 deletions RecoLocalMuon/DTSegment/src/DTCombinatorialPatternReco.cc
Expand Up @@ -65,7 +65,7 @@ DTCombinatorialPatternReco::reconstruct(const DTSuperLayer* sl,

DTSLRecSegment2D *segment = (**cand);

theUpdator->update(segment);
theUpdator->update(segment,0);

result.push_back(segment);

Expand Down Expand Up @@ -427,7 +427,7 @@ DTCombinatorialPatternReco::buildPointsCollection(vector<DTSegmentCand::AssPoint
}

DTSegmentCand* newCand = new DTSegmentCand(pointsSet,sl);
if (theUpdator->fit(newCand)) candidates.push_back(newCand);
if (theUpdator->fit(newCand,0,0)) candidates.push_back(newCand);
else delete newCand; // bad seg, too few hits
}
}
Expand Down
10 changes: 5 additions & 5 deletions RecoLocalMuon/DTSegment/src/DTCombinatorialPatternReco4D.cc
Expand Up @@ -169,7 +169,7 @@ DTCombinatorialPatternReco4D::reconstruct() {

std::auto_ptr<DTChamberRecSegment2D> superPhi(**phi);

theUpdator->update(superPhi.get());
theUpdator->update(superPhi.get(),0);
if(debug) cout << "superPhi: " << *superPhi << endl;

if (hasZed) {
Expand Down Expand Up @@ -201,12 +201,12 @@ DTCombinatorialPatternReco4D::reconstruct() {
if (debug) cout << "Created a 4D seg " << *newSeg << endl;

/// 4d segment: I have the pos along the wire => further update!
theUpdator->update(newSeg);
theUpdator->update(newSeg,0,0);
if (debug) cout << " seg updated " << *newSeg << endl;


if(!applyT0corr && computeT0corr) theUpdator->calculateT0corr(newSeg);
if(applyT0corr) theUpdator->update(newSeg,true);
if(applyT0corr) theUpdator->update(newSeg,true,0);

result.push_back(newSeg);
}
Expand All @@ -219,7 +219,7 @@ DTCombinatorialPatternReco4D::reconstruct() {

//update the segment with the t0 and possibly vdrift correction
if(!applyT0corr && computeT0corr) theUpdator->calculateT0corr(newSeg);
if(applyT0corr) theUpdator->update(newSeg,true);
if(applyT0corr) theUpdator->update(newSeg,true,0);

result.push_back(newSeg);
}
Expand All @@ -243,7 +243,7 @@ DTCombinatorialPatternReco4D::reconstruct() {
*newSeg << endl;

if(!applyT0corr && computeT0corr) theUpdator->calculateT0corr(newSeg);
if(applyT0corr) theUpdator->update(newSeg,true);
if(applyT0corr) theUpdator->update(newSeg,true,0);

result.push_back(newSeg);
}
Expand Down
8 changes: 4 additions & 4 deletions RecoLocalMuon/DTSegment/src/DTLinearFit.cc
Expand Up @@ -292,7 +292,7 @@ void DTLinearFit::fit4Var( const vector<float>& xfit,

if (nptfit >= 3) {

fitNpar(3,xfit,yfit,lfit,tfit,sigy,aminf,bminf,cminf,vminf,chi2fit,debug);
fitNpar(3,xfit,yfit,lfit,tfit,sigy,bminf,aminf,cminf,vminf,chi2fit,debug);
chi2fit3 = chi2fit;

if (cminf!=-999.) {
Expand Down Expand Up @@ -320,14 +320,14 @@ void DTLinearFit::fit4Var( const vector<float>& xfit,


if (nptfit>=5) {
fitNpar(4,xfit,yfit,lfit,tfit,sigy,aminf,bminf,cminf,vminf,chi2fit,debug);
fitNpar(4,xfit,yfit,lfit,tfit,sigy,bminf,aminf,cminf,vminf,chi2fit,debug);

if (vminf!=0) {
nppar = 4;
if (nptfit<=nppar){
chi2fitN4=-1;
} else{
chi2fitN4= chi2fit / (nptfit-nppar);
chi2fitN4= chi2fit / (nptfit-nppar);
}
} else {
if (nptfit <= nppar) chi2fitN4=-1;
Expand Down
2 changes: 1 addition & 1 deletion RecoLocalMuon/DTSegment/src/DTMeantimerPatternReco.cc
Expand Up @@ -71,7 +71,7 @@ DTMeantimerPatternReco::reconstruct(const DTSuperLayer* sl,
while (cand<candidates.end()) {

DTSLRecSegment2D *segment = (**cand);
theUpdator->update(segment);
theUpdator->update(segment,1);

if (debug)
cout<<"Reconstructed 2D segments "<<*segment<<endl;
Expand Down
10 changes: 5 additions & 5 deletions RecoLocalMuon/DTSegment/src/DTMeantimerPatternReco4D.cc
Expand Up @@ -170,7 +170,7 @@ DTMeantimerPatternReco4D::reconstruct(){

std::auto_ptr<DTChamberRecSegment2D> superPhi(**phi);

theUpdator->update(superPhi.get());
theUpdator->update(superPhi.get(),1);
if(debug) cout << "superPhi: " << *superPhi << endl;

if (hasZed) {
Expand Down Expand Up @@ -199,12 +199,12 @@ DTMeantimerPatternReco4D::reconstruct(){
DTRecSegment4D* newSeg = new DTRecSegment4D(*superPhi,*zed,posZInCh,dirZInCh);

/// 4d segment: I have the pos along the wire => further update!
theUpdator->update(newSeg);
theUpdator->update(newSeg,0,1);
if (debug) cout << "Created a 4D seg " << *newSeg << endl;

//update the segment with the t0 and possibly vdrift correction
if(!applyT0corr && computeT0corr) theUpdator->calculateT0corr(newSeg);
if(applyT0corr) theUpdator->update(newSeg,true);
if(applyT0corr) theUpdator->update(newSeg,true,1);

result.push_back(newSeg);
}
Expand All @@ -216,7 +216,7 @@ DTMeantimerPatternReco4D::reconstruct(){

//update the segment with the t0 and possibly vdrift correction
if(!applyT0corr && computeT0corr) theUpdator->calculateT0corr(newSeg);
if(applyT0corr) theUpdator->update(newSeg,true);
if(applyT0corr) theUpdator->update(newSeg,true,1);

result.push_back(newSeg);
}
Expand All @@ -239,7 +239,7 @@ DTMeantimerPatternReco4D::reconstruct(){
if (debug) cout << "Created a 4D segment using only the 2D Theta segment" << endl;

if(!applyT0corr && computeT0corr) theUpdator->calculateT0corr(newSeg);
if(applyT0corr) theUpdator->update(newSeg,true);
if(applyT0corr) theUpdator->update(newSeg,true,1);

result.push_back(newSeg);
}
Expand Down
2 changes: 1 addition & 1 deletion RecoLocalMuon/DTSegment/src/DTRefitAndCombineReco4D.cc
Expand Up @@ -125,7 +125,7 @@ DTRefitAndCombineReco4D::reconstruct(){
//<<

/// 4d segment: I have the pos along the wire => further update!
theUpdator->update(newSeg);
theUpdator->update(newSeg,0,1);
if (debug) cout << "Created a 4D seg " << endl;
result.push_back(newSeg);
}
Expand Down
2 changes: 1 addition & 1 deletion RecoLocalMuon/DTSegment/src/DTSegment4DT0Corrector.cc
Expand Up @@ -82,7 +82,7 @@ void DTSegment4DT0Corrector::produce(Event& event, const EventSetup& setup){

if(newSeg == 0) continue;

theUpdator->update(newSeg,true);
theUpdator->update(newSeg,true,0);
result.push_back(*newSeg);

}
Expand Down
29 changes: 15 additions & 14 deletions RecoLocalMuon/DTSegment/src/DTSegmentUpdator.cc
Expand Up @@ -71,7 +71,7 @@ void DTSegmentUpdator::setES(const EventSetup& setup){
theAlgo->setES(setup);
}

void DTSegmentUpdator::update(DTRecSegment4D* seg, const bool calcT0) const {
void DTSegmentUpdator::update(DTRecSegment4D* seg, const bool calcT0, bool allow3par) const {

if(debug) cout << "[DTSegmentUpdator] Starting to update the DTRecSegment4D" << endl;

Expand All @@ -94,19 +94,19 @@ void DTSegmentUpdator::update(DTRecSegment4D* seg, const bool calcT0) const {
if(hasPhi) updateHits(seg->phiSegment(),pos,dir,step);
if(hasZed) updateHits(seg->zSegment() ,pos,dir,step);

fit(seg);
fit(seg,allow3par);
}

void DTSegmentUpdator::update(DTRecSegment2D* seg) const {
void DTSegmentUpdator::update(DTRecSegment2D* seg, bool allow3par) const {
if(debug) cout << "[DTSegmentUpdator] Starting to update the DTRecSegment2D" << endl;
GlobalPoint pos = (theGeom->idToDet(seg->geographicalId()))->toGlobal(seg->localPosition());
GlobalVector dir = (theGeom->idToDet(seg->geographicalId()))->toGlobal(seg->localDirection());

updateHits(seg,pos,dir);
fit(seg,1);
fit(seg,allow3par);
}

void DTSegmentUpdator::fit(DTRecSegment4D* seg) const {
void DTSegmentUpdator::fit(DTRecSegment4D* seg, bool allow3par) const {
if(debug) cout << "[DTSegmentUpdator] Fit DTRecSegment4D:" << endl;
// after the update must refit the segments

Expand All @@ -122,7 +122,7 @@ void DTSegmentUpdator::fit(DTRecSegment4D* seg) const {
if(seg->hasZed()) {

// fit in-time Phi segments with the 2par fit and out-of-time segments with the 3par fit
if (fabs(seg->phiSegment()->t0())<40.) {
if (fabs(seg->phiSegment()->t0())<20.) {
fit(seg->phiSegment(),0);
fit(seg->zSegment(),0);
} else {
Expand Down Expand Up @@ -376,10 +376,11 @@ void DTSegmentUpdator::fit(const vector<float>& x,

// If we have at least one left and one right hit we can try the 3 parameter fit (if it is switched on)
// FIXME: currently the covariance matrix from the 2-par fit is kept
if (leftHits && rightHits && (leftHits+rightHits>3)) {
if (leftHits && rightHits && (leftHits+rightHits>3) && allow3par) {
theFitter->fitNpar(3,x,y,lfit,dist,sigy,slope,intercept,cminf,vminf,chi2,debug);
double t0_corr=-cminf/0.00543;
if (fabs(t0_corr)<20. && !allow3par) {
// if (fabs(t0_corr)<20. && !allow3par) {
if (fabs(t0_corr)<20.) {
theFitter->fit(x,y,x.size(),sigy,slope,intercept,chi2,covss,covii,covsi);
cminf=0;
}
Expand Down Expand Up @@ -585,16 +586,16 @@ void DTSegmentUpdator::rejectBadHits(DTChamberRecSegment2D* phiSeg) const {
}
}

phiSeg->update(updatedRecHits);
phiSeg->update(updatedRecHits);

//final check!
if(debug){
if(debug){

vector<float> x_upd;
vector<float> y_upd;

cout << " Check the update action: " << endl;

vector<DTRecHit1D> hits_upd = phiSeg->specificRecHits();
for (vector<DTRecHit1D>::const_iterator hit=hits_upd.begin();
hit!=hits_upd.end(); ++hit) {
Expand Down
8 changes: 4 additions & 4 deletions RecoLocalMuon/DTSegment/src/DTSegmentUpdator.h
Expand Up @@ -51,7 +51,7 @@ class DTSegmentUpdator{

/** do the linear fit on the hits of the segment candidate and update it.
* Returns false if the segment candidate is not good() */
bool fit(DTSegmentCand* seg, bool allow3par = false, const bool fitdebug = false) const;
bool fit(DTSegmentCand* seg, bool allow3par, const bool fitdebug) const;

/** ditto for true segment: since the fit is applied on a true segment, by
* definition the segment is "good", while it's not the case for just
Expand All @@ -62,13 +62,13 @@ class DTSegmentUpdator{
* the 4D direction and position is built. Since the fit is applied on a
* true segment, by definition the segment is "good", while it's not the
* case for just candidates */
void fit(DTRecSegment4D* seg) const;
void fit(DTRecSegment4D* seg, bool allow3par) const;

/// recompute hits position and refit the segment4D
void update(DTRecSegment4D* seg, const bool calcT0 = false) const;
void update(DTRecSegment4D* seg, const bool calcT0, bool allow3par) const;

/// recompute hits position and refit the segment2D
void update(DTRecSegment2D* seg) const;
void update(DTRecSegment2D* seg, bool allow3par) const;

void calculateT0corr(DTRecSegment2D* seg) const;
void calculateT0corr(DTRecSegment4D* seg) const;
Expand Down

0 comments on commit 6d3131b

Please sign in to comment.