Skip to content

Commit

Permalink
remove currently unused code for pf candidate time assignment from pf…
Browse files Browse the repository at this point in the history
…cluster times
  • Loading branch information
bendavid committed Sep 19, 2017
1 parent 2e974d5 commit e4cf917
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 53 deletions.
3 changes: 0 additions & 3 deletions RecoParticleFlow/PFProducer/src/PFAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3284,9 +3284,6 @@ PFAlgo::reconstructCluster(const reco::PFCluster& cluster,
pfCandidates_->back().setVertex(vertexPos);

//*TODO* cluster time is not reliable at the moment, so only use track timing
if (false) {
pfCandidates_->back().setTime( cluster.time(), cluster.timeError() );
}

if(debug_)
cout<<"** candidate: "<<pfCandidates_->back()<<endl;
Expand Down
47 changes: 9 additions & 38 deletions RecoParticleFlow/PFProducer/src/PFEGammaAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2024,45 +2024,16 @@ fillPFCandidates(const pfEGHelpers::HeavyObjectCache* hoc,
refinedscs_.push_back(buildRefinedSuperCluster(RO));

//*TODO* cluster time is not reliable at the moment, so only use track timing
if (false) {
// forward the time from the seed cluster
if (!RO.ecalclusters.empty()) {
auto const & seedPFClust = *RO.ecalclusters.front().first->clusterRef();
// do I have a GSF track too?
float time = seedPFClust.time(), timeErr = seedPFClust.timeError();
float trkTime = 0, trkTimeErr = -1;
if (!RO.primaryGSFs.empty() && RO.primaryGSFs[0].first->isTimeValid()) {
trkTime = RO.primaryGSFs[0].first->time();
trkTimeErr = RO.primaryGSFs[0].first->timeError();
} else if (!RO.primaryKFs.empty() && RO.primaryKFs[0].first->isTimeValid()) {
trkTime = RO.primaryKFs[0].first->time();
trkTimeErr = RO.primaryKFs[0].first->timeError();
}
if (trkTimeErr >= 0) {
if (trkTimeErr > 0 && timeErr > 0) { // weighted average (double precision)
double newErr2 = (1.0/(timeErr*timeErr) + 1.0/(trkTimeErr*trkTimeErr));
time = (double(time/(timeErr*timeErr)) + double(trkTime/(trkTimeErr*trkTimeErr)))/newErr2;
timeErr = std::sqrt(float(newErr2));
} else { // FIXME: should find something smarter
time = 0.5*(time + trkTime);
timeErr = std::max(time,trkTime);
}
}
cand.setTime( time, timeErr );
}
float trkTime = 0, trkTimeErr = -1;
if (!RO.primaryGSFs.empty() && RO.primaryGSFs[0].first->isTimeValid()) {
trkTime = RO.primaryGSFs[0].first->time();
trkTimeErr = RO.primaryGSFs[0].first->timeError();
} else if (!RO.primaryKFs.empty() && RO.primaryKFs[0].first->isTimeValid()) {
trkTime = RO.primaryKFs[0].first->time();
trkTimeErr = RO.primaryKFs[0].first->timeError();
}
else {
float trkTime = 0, trkTimeErr = -1;
if (!RO.primaryGSFs.empty() && RO.primaryGSFs[0].first->isTimeValid()) {
trkTime = RO.primaryGSFs[0].first->time();
trkTimeErr = RO.primaryGSFs[0].first->timeError();
} else if (!RO.primaryKFs.empty() && RO.primaryKFs[0].first->isTimeValid()) {
trkTime = RO.primaryKFs[0].first->time();
trkTimeErr = RO.primaryKFs[0].first->timeError();
}
if (trkTimeErr >= 0) {
cand.setTime( trkTime, trkTimeErr );
}
if (trkTimeErr >= 0) {
cand.setTime( trkTime, trkTimeErr );
}

const reco::SuperCluster& the_sc = refinedscs_.back();
Expand Down
13 changes: 1 addition & 12 deletions RecoParticleFlow/PFSimProducer/plugins/SimPFProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,18 +326,7 @@ void SimPFProducer::produce(edm::StreamID, edm::Event& evt, const edm::EventSetu
}

//*TODO* cluster time is not reliable at the moment, so just keep time from the track if available
if (false) {
const reco::PFCluster *seed = dynamic_cast<const reco::PFCluster *>((*superClustersHandle)[supercluster_index].seed().get());
assert(seed != nullptr);
if (seed->timeError() > 0) {
if (candidate.isTimeValid() && candidate.timeError() > 0) {
double wCand = 1.0/std::pow(candidate.timeError(),2), wSeed = 1.0/std::pow(seed->timeError(),2);
candidate.setTime((wCand*candidate.time() + wSeed*seed->time())/(wCand + wSeed) , 1.0f/std::sqrt(float(wCand + wSeed)));
} else {
candidate.setTime(seed->time(), seed->timeError());
}
}
}

}
}
}
Expand Down

0 comments on commit e4cf917

Please sign in to comment.