New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timing propagation in HGCAL RECO #28740
Changes from 17 commits
f4eefb9
d050141
8bf5b4e
70645df
4b1699a
b3468b0
97060fe
c96769c
60fb5a9
36c7da3
ac606af
3f665f9
cfb9ee2
cd378b8
5443928
f2ecedb
716ae7c
55493e9
2f95595
60d3b8c
8b212f6
231b930
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ void HGCGraph::makeAndConnectDoublets(const TICLLayerTiles &histo, | |
int nPhiBins, | ||
const std::vector<reco::CaloCluster> &layerClusters, | ||
const std::vector<float> &mask, | ||
const edm::ValueMap<float> &layerClustersTime, | ||
const edm::ValueMap<std::pair<float, float>> &layerClustersTime, | ||
int deltaIEta, | ||
int deltaIPhi, | ||
float minCosTheta, | ||
|
@@ -125,12 +125,15 @@ void HGCGraph::makeAndConnectDoublets(const TICLLayerTiles &histo, | |
|
||
bool HGCGraph::areTimeCompatible(int innerIdx, | ||
int outerIdx, | ||
const edm::ValueMap<float> &layerClustersTime, | ||
const edm::ValueMap<std::pair<float, float>> &layerClustersTime, | ||
float maxDeltaTime) { | ||
float timeIn = layerClustersTime.get(innerIdx); | ||
float timeOut = layerClustersTime.get(outerIdx); | ||
float timeIn = layerClustersTime.get(innerIdx).first; | ||
float timeInE = layerClustersTime.get(innerIdx).second; | ||
float timeOut = layerClustersTime.get(outerIdx).first; | ||
float timeOutE = layerClustersTime.get(outerIdx).second; | ||
|
||
return (timeIn == -99 || timeOut == -99 || std::abs(timeIn - timeOut) < maxDeltaTime); | ||
return (timeIn == -99 || timeOut == -99 || | ||
std::abs(timeIn - timeOut) < maxDeltaTime * sqrt(timeInE * timeInE + timeOutE * timeOutE)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to also check that the Time Error is meaningful, i.e. it is >0? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, should not be the case:
If apart from this timeError is <= 0, it is for a bug somewhere else in the chain. Can I suggest to leave this as it is? (to help spotting the bug in case?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, thanks for checking! |
||
} | ||
|
||
//also return a vector of seedIndex for the reconstructed tracksters | ||
|
@@ -141,7 +144,7 @@ void HGCGraph::findNtuplets(std::vector<HGCDoublet::HGCntuplet> &foundNtuplets, | |
unsigned int maxOutInHops) { | ||
HGCDoublet::HGCntuplet tmpNtuplet; | ||
tmpNtuplet.reserve(minClustersPerNtuplet); | ||
std::vector<std::pair<unsigned int, unsigned int> > outInToVisit; | ||
std::vector<std::pair<unsigned int, unsigned int>> outInToVisit; | ||
for (auto rootDoublet : theRootDoublets_) { | ||
tmpNtuplet.clear(); | ||
outInToVisit.clear(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
#include "FWCore/Utilities/interface/Exception.h" | ||
#include "PatternRecognitionbyCA.h" | ||
#include "HGCGraph.h" | ||
#include "RecoLocalCalo/HGCalRecProducers/interface/ComputeClusterTime.h" | ||
|
||
using namespace ticl; | ||
|
||
|
@@ -70,13 +71,36 @@ void PatternRecognitionbyCA::makeTracksters(const PatternRecognitionAlgoBase::In | |
//#ifdef FP_DEBUG | ||
const auto &doublets = theGraph_->getAllDoublets(); | ||
int tracksterId = 0; | ||
|
||
for (auto const &ntuplet : foundNtuplets) { | ||
std::set<unsigned int> effective_cluster_idx; | ||
std::pair<std::set<unsigned int>::iterator, bool> retVal; | ||
|
||
std::vector<float> times; | ||
std::vector<float> timeErrors; | ||
|
||
for (auto const &doublet : ntuplet) { | ||
auto innerCluster = doublets[doublet].innerClusterId(); | ||
auto outerCluster = doublets[doublet].outerClusterId(); | ||
effective_cluster_idx.insert(innerCluster); | ||
effective_cluster_idx.insert(outerCluster); | ||
|
||
retVal = effective_cluster_idx.insert(innerCluster); | ||
if (retVal.second) { | ||
float time = input.layerClustersTime.get(innerCluster).first; | ||
if (time > -99) { | ||
times.push_back(time); | ||
timeErrors.push_back(1. / pow(input.layerClustersTime.get(innerCluster).second, 2)); | ||
} | ||
} | ||
|
||
retVal = effective_cluster_idx.insert(outerCluster); | ||
if (retVal.second) { | ||
float time = input.layerClustersTime.get(outerCluster).first; | ||
if (time > -99) { | ||
times.push_back(time); | ||
timeErrors.push_back(1. / pow(input.layerClustersTime.get(outerCluster).second, 2)); | ||
} | ||
} | ||
|
||
if (algo_verbosity_ > Advanced) { | ||
LogDebug("HGCPatterRecoByCA") << "New doublet " << doublet << " for trackster: " << result.size() << " InnerCl " | ||
<< innerCluster << " " << input.layerClusters[innerCluster].x() << " " | ||
|
@@ -99,6 +123,14 @@ void PatternRecognitionbyCA::makeTracksters(const PatternRecognitionAlgoBase::In | |
//if a seeding region does not lead to any trackster | ||
tmp.seedID = input.regions[0].collectionID; | ||
tmp.seedIndex = seedIndices[tracksterId]; | ||
|
||
std::pair<float, float> timeTrackster(-99., -1.); | ||
if (times.size() >= 3) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any specific reason why you need at least 3 measurements? Maybe it would make sense to "hide" this into the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3 was tuned looking at the full shower performance using recHits (TDR time). It is kept and propagated in the chain, as reasonable to maximize efficiency and still allow some clustering of the information (truncation and weighted mean) What if I replace this by a configurable parameter, leaving it in the calling code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ciao @amartelli maybe we could do both? If you think the parameter could be different for different use cases, then it makes sense to leave it to the caller and make it parametrizable. Yet, maybe you could include it as a parameter into the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, it's reasonable, I'll change it. thanks |
||
hgcalsimclustertime::ComputeClusterTime timeEstimator; | ||
timeTrackster = timeEstimator.fixSizeHighestDensity(times, timeErrors); | ||
} | ||
tmp.time = timeTrackster.first; | ||
tmp.timeError = timeTrackster.second; | ||
std::copy(std::begin(effective_cluster_idx), std::end(effective_cluster_idx), std::back_inserter(tmp.vertices)); | ||
result.push_back(tmp); | ||
tracksterId++; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#ifndef RecoLocalCalo_HGCalRecProducers_ComputeClusterTime_h | ||
#define RecoLocalCalo_HGCalRecProducers_ComputeClusterTime_h | ||
|
||
// user include files | ||
#include <algorithm> | ||
#include <cmath> | ||
#include <numeric> | ||
#include <vector> | ||
#include "TF1.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove unneeded include? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, thanks |
||
|
||
// functions to select the hits to compute the time of a given cluster | ||
// start with the only hits with timing information | ||
// average among the hits contained in the chosen time interval | ||
// weighted average wrt resolution or preferred function | ||
|
||
// N.B. time is corrected wrt vtx-calorimeter distance | ||
// with straight line and light speed hypothesis | ||
// for charged tracks or heavy particles (longer track length or beta < 1) | ||
// need to correct the offset at analysis level | ||
|
||
namespace hgcalsimclustertime { | ||
|
||
/* | ||
std::vector<size_t> decrease_sorted_indices(const std::vector<float>& v){ | ||
// initialize original index locations | ||
std::vector<size_t> idx(v.size()); | ||
for (size_t i = 0; i != idx.size(); ++i) idx[i] = i; | ||
// sort indices based on comparing values in v (decreasing order) | ||
std::sort(idx.begin(), idx.end(), | ||
[&v](size_t i1, size_t i2) {return v[i1] < v[i2];} ); | ||
return idx; | ||
}; | ||
*/ | ||
|
||
class ComputeClusterTime { | ||
public: | ||
ComputeClusterTime(float Xmix, float Xmax, float Cterm, float Aterm); | ||
ComputeClusterTime(); | ||
|
||
void setParameters(float Xmix, float Xmax, float Cterm, float Aterm); | ||
|
||
//time resolution parametrization | ||
float timeResolution(float xVal); | ||
|
||
float getTimeError(std::string type, float xVal); | ||
|
||
//time-interval based on that ~210ps wide and with the highest number of hits | ||
//apply weights if provided => weighted mean | ||
//return also error on the mean | ||
std::pair<float, float> fixSizeHighestDensity(std::vector<float>& time, | ||
std::vector<float> weight = std::vector<float>(), | ||
float deltaT = 0.210, /*time window in ns*/ | ||
float timeWidthBy = 0.5); | ||
|
||
//same as before but provide weights | ||
//configure the reweight through type | ||
/* std::pair<float,float> fixSizeHighestDensityEnergyResWeig(std::vector<float>& t, */ | ||
/* std::vector<float>& w, */ | ||
/* std::string& type, */ | ||
/* float deltaT = 0.210, //time window in ns */ | ||
/* float timeWidthBy = 0.5) {}; */ | ||
|
||
private: | ||
float _Xmin; | ||
float _Xmax; | ||
float _Cterm; | ||
float _Aterm; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. leading underscores are frowned upon; please use a trailing (or prepend something, like "m") to denote the member data |
||
}; | ||
|
||
} // namespace hgcalsimclustertime | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this go in DataFormats/StdDictionaries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had missed that this was a ValueMap. It definitely should stay here.