14 del_tk_ts_layer1_(conf.getParameter<double>(
"delta_tk_ts_layer1")),
15 del_tk_ts_int_(conf.getParameter<double>(
"delta_tk_ts_interface")),
16 timing_quality_threshold_(conf.getParameter<double>(
"timing_quality_threshold")) {}
34 std::pair<float, float> rMinMax =
hgcons_->
rangeR(zVal,
true);
37 std::pair<float, float> rMinMax_interface =
hgcons_->
rangeR(zVal_interface,
true);
39 for (
int iSide = 0; iSide < 2; ++iSide) {
40 float zSide = (iSide == 0) ? (-1. * zVal) : zVal;
47 zSide = (iSide == 0) ? (-1. * zVal_interface) : zVal_interface;
51 SimpleDiskBounds(rMinMax_interface.first, rMinMax_interface.second, zSide - 0.5, zSide + 0.5))
58 std::array<TICLLayerTile, 2> &tracksterTiles) {
61 Vector const &baryc =
t.barycenter();
62 Vector directnv =
t.eigenvectors(0);
71 directnv = baryc.unit();
72 zVal *= (baryc.Z() > 0) ? 1 : -1;
73 float par = (zVal - baryc.Z()) / directnv.Z();
74 float xOnSurface = par * directnv.X() + baryc.X();
75 float yOnSurface = par * directnv.Y() + baryc.Y();
76 Vector tPoint(xOnSurface, yOnSurface, zVal);
77 if (tPoint.Eta() > 0) {
78 tracksterTiles[1].fill(tPoint.Eta(), tPoint.Phi(),
idx);
79 }
else if (tPoint.Eta() < 0) {
80 tracksterTiles[0].fill(tPoint.Eta(), tPoint.Phi(),
idx);
87 const std::vector<std::pair<Vector, unsigned>> &seedingCollection,
88 const std::array<TICLLayerTile, 2> &tracksterTiles,
89 const std::vector<Vector> &tracksterPropPoints,
91 unsigned trackstersSize,
92 std::vector<std::vector<unsigned>> &resultCollection,
93 bool useMask =
false) {
99 std::vector<int>
mask(trackstersSize, 0);
102 for (
auto &
i : seedingCollection) {
103 float seed_eta =
i.first.Eta();
104 float seed_phi =
i.first.Phi();
106 auto sideZ = seed_eta > 0;
114 std::vector<unsigned> in_delta;
116 std::vector<float> energies;
117 for (
int eta_i = search_box[0]; eta_i <= search_box[1]; ++eta_i) {
118 for (
int phi_i = search_box[2]; phi_i <= search_box[3]; ++phi_i) {
120 for (
const unsigned &t_i : in_tile) {
122 auto sep2 = (tracksterPropPoints[t_i].Eta() - seed_eta) * (tracksterPropPoints[t_i].Eta() - seed_eta) +
123 (tracksterPropPoints[t_i].
Phi() - seed_phi) * (tracksterPropPoints[t_i].
Phi() - seed_phi);
125 in_delta.push_back(t_i);
127 energies.push_back(tracksters[t_i].raw_energy());
134 std::vector<unsigned>
indices(in_delta.size());
140 const auto &t_i = in_delta[
index];
142 resultCollection[
seedId].push_back(t_i);
164 return energyCompatible;
170 float tsT = trackster.
time();
173 bool timeCompatible =
false;
175 timeCompatible =
true;
177 const auto &barycenter = trackster.
barycenter();
179 const auto deltaSoverV =
std::sqrt((barycenter.x() - tkMtdPos.
x()) * (barycenter.x() - tkMtdPos.
x()) +
180 (barycenter.y() - tkMtdPos.
y()) * (barycenter.y() - tkMtdPos.
y()) +
181 (barycenter.z() - tkMtdPos.
z()) * (barycenter.z() - tkMtdPos.
z())) /
182 (tkBeta * 29.9792458);
184 const auto deltaT = tsT - tkT;
192 if (!(energyCompatible))
193 LogDebug(
"GeneralInterpretationAlgo")
194 <<
"energy incompatible : track p " <<
track.p() <<
" trackster energy " << trackster.
raw_energy() <<
"\n" 195 <<
" total_raw_energy " << total_raw_energy <<
" greater than track p + threshold " 197 if (!(timeCompatible))
198 LogDebug(
"GeneralInterpretationAlgo") <<
"time incompatible : track time " << tkT <<
" +/- " << tkTErr
199 <<
" trackster time " << tsT <<
" +/- " << tsTErr <<
"\n";
202 return energyCompatible && timeCompatible;
207 std::vector<Trackster> &resultTracksters,
208 std::vector<int> &resultCandidate) {
210 const auto tkH =
input.tracksHandle;
211 const auto maskTracks =
input.maskedTracks;
212 const auto &
tracks = *tkH;
213 const auto &tracksters =
input.tracksters;
221 std::vector<std::pair<Vector, unsigned>> trackPColl;
222 std::vector<std::pair<Vector, unsigned>> tkPropIntColl;
224 trackPColl.reserve(
tracks.size());
225 tkPropIntColl.reserve(
tracks.size());
227 std::array<TICLLayerTile, 2> tracksterPropTiles = {};
228 std::array<TICLLayerTile, 2> tsPropIntTiles = {};
231 LogDebug(
"GeneralInterpretationAlgo") <<
"------- Geometric Linking ------- \n";
234 std::vector<unsigned> candidateTrackIds;
235 candidateTrackIds.reserve(
tracks.size());
236 for (
unsigned i = 0;
i <
tracks.size(); ++
i) {
239 candidateTrackIds.push_back(
i);
242 std::sort(candidateTrackIds.begin(), candidateTrackIds.end(), [&](
unsigned i,
unsigned j) {
246 for (
auto const i : candidateTrackIds) {
248 int iSide =
int(tk.eta() > 0);
252 if (tsos.isValid()) {
253 Vector trackP(tsos.globalPosition().x(), tsos.globalPosition().y(), tsos.globalPosition().z());
254 trackPColl.emplace_back(trackP,
i);
258 if (tsos_int.isValid()) {
259 Vector trackP(tsos_int.globalPosition().x(), tsos_int.globalPosition().y(), tsos_int.globalPosition().z());
260 tkPropIntColl.emplace_back(trackP,
i);
263 tkPropIntColl.shrink_to_fit();
264 trackPColl.shrink_to_fit();
265 candidateTrackIds.shrink_to_fit();
272 std::vector<Vector> tsAllProp;
273 std::vector<Vector> tsAllPropInt;
274 tsAllProp.reserve(tracksters.size());
275 tsAllPropInt.reserve(tracksters.size());
278 for (
unsigned i = 0;
i < tracksters.size(); ++
i) {
279 const auto &
t = tracksters[
i];
281 LogDebug(
"GeneralInterpretationAlgo")
282 <<
"trackster " <<
i <<
" - eta " <<
t.barycenter().eta() <<
" phi " <<
t.barycenter().phi() <<
" time " 283 <<
t.time() <<
" energy " <<
t.raw_energy() <<
"\n";
288 tsAllProp.emplace_back(tsP);
293 tsAllPropInt.emplace_back(tsP);
298 std::vector<std::vector<unsigned>> tsNearTk(
tracks.size());
300 tracksters, trackPColl, tracksterPropTiles, tsAllProp,
del_tk_ts_layer1_, tracksters.size(), tsNearTk);
303 std::vector<std::vector<unsigned>> tsNearTkAtInt(
tracks.size());
305 tracksters, tkPropIntColl, tsPropIntTiles, tsAllPropInt,
del_tk_ts_int_, tracksters.size(), tsNearTkAtInt);
307 std::vector<unsigned int> chargedHadronsFromTk;
308 std::vector<std::vector<unsigned int>> trackstersInTrackIndices;
309 trackstersInTrackIndices.resize(
tracks.size());
311 std::vector<bool> chargedMask(tracksters.size(),
true);
312 for (
unsigned &
i : candidateTrackIds) {
313 if (tsNearTk[
i].
empty() && tsNearTkAtInt[
i].empty()) {
317 std::vector<unsigned int> chargedCandidate;
318 float total_raw_energy = 0.f;
320 float track_time = 0.f;
321 float track_timeErr = 0.f;
323 float track_beta = 0.f;
326 auto const &inputTimingView = (*inputTiming_h).const_view();
327 track_time = inputTimingView.time()[
i];
328 track_timeErr = inputTimingView.timeErr()[
i];
330 track_beta = inputTimingView.beta()[
i];
332 inputTimingView.posInMTD_x()[
i], inputTimingView.posInMTD_y()[
i], inputTimingView.posInMTD_z()[
i]};
335 for (
auto const tsIdx : tsNearTk[
i]) {
345 chargedCandidate.push_back(tsIdx);
346 chargedMask[tsIdx] =
false;
347 total_raw_energy += tracksters[tsIdx].raw_energy();
350 for (
const unsigned tsIdx : tsNearTkAtInt[
i]) {
360 chargedCandidate.push_back(tsIdx);
361 chargedMask[tsIdx] =
false;
362 total_raw_energy += tracksters[tsIdx].raw_energy();
365 trackstersInTrackIndices[
i] = chargedCandidate;
368 for (
size_t iTrack = 0; iTrack < trackstersInTrackIndices.size(); iTrack++) {
369 if (!trackstersInTrackIndices[iTrack].
empty()) {
370 if (trackstersInTrackIndices[iTrack].size() == 1) {
371 auto tracksterId = trackstersInTrackIndices[iTrack][0];
372 resultCandidate[iTrack] = resultTracksters.size();
373 resultTracksters.push_back(
input.tracksters[tracksterId]);
379 bool isHadron =
false;
380 for (
auto const tracksterId : trackstersInTrackIndices[iTrack]) {
383 regr_en +=
input.tracksters[tracksterId].regressed_energy();
384 if (
input.tracksters[tracksterId].isHadronic())
387 resultCandidate[iTrack] = resultTracksters.size();
388 resultTracksters.push_back(outTrackster);
389 resultTracksters.back().setRegressedEnergy(regr_en);
399 for (
size_t iTrackster = 0; iTrackster <
input.tracksters.size(); iTrackster++) {
400 if (chargedMask[iTrackster]) {
401 resultTracksters.push_back(
input.tracksters[iTrackster]);
408 "1.48 < abs(eta) < 3.0 && pt > 1. && quality(\"highPurity\") && " 409 "hitPattern().numberOfLostHits(\"MISSING_OUTER_HITS\") < 5");
410 desc.add<
double>(
"delta_tk_ts_layer1", 0.02);
411 desc.add<
double>(
"delta_tk_ts_interface", 0.03);
412 desc.add<
double>(
"timing_quality_threshold", 0.5);
double waferZ(int layer, bool reco) const
hgcal::RecHitTools rhtools_
static DiskPointer build(Args &&... args)
void initialize(const HGCalDDDConstants *hgcons, const hgcal::RecHitTools rhtools, const edm::ESHandle< MagneticField > bfieldH, const edm::ESHandle< Propagator > propH) override
edm::ESHandle< MagneticField > bfield_
bool timeAndEnergyCompatible(float &total_raw_energy, const reco::Track &track, const Trackster &trackster, const float &tkTime, const float &tkTimeErr, const float &tkQual, const float &tkBeta, const GlobalPoint &tkMtdPos, bool useMTDTiming)
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)
const HGCalDDDConstants * hgcons_
uint32_t cc[maxCellsPerHit]
static constexpr int nPhiBins
std::unique_ptr< GeomDet > firstDisk_[2]
const Vector & barycenter() const
std::unique_ptr< GeomDet > interfaceDisk_[2]
static constexpr float maxEta
const float timing_quality_threshold_
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
const float timeError() const
static std::string const input
T const * product() const
void mergeTracksters(const Trackster &other)
edm::ESHandle< Propagator > propagator_
const float raw_energy() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
~GeneralInterpretationAlgo() override
Abs< T >::type abs(const T &t)
const float del_tk_ts_int_
static constexpr float minEta
static void fillPSetDescription(edm::ParameterSetDescription &desc)
std::pair< double, double > rangeR(double z, bool reco) const
const float del_tk_ts_layer1_
void findTrackstersInWindow(const MultiVectorManager< Trackster > &tracksters, const std::vector< std::pair< Vector, unsigned >> &seedingCollection, const std::array< TICLLayerTile, 2 > &tracksterTiles, const std::vector< Vector > &tracksterPropPoints, float delta, unsigned trackstersSize, std::vector< std::vector< unsigned >> &resultCollection, bool useMask)
Vector propagateTrackster(const Trackster &t, const unsigned idx, float zVal, std::array< TICLLayerTile, 2 > &tracksterTiles)
void makeCandidates(const Inputs &input, edm::Handle< MtdHostCollection > inputTiming_h, std::vector< Trackster > &resultTracksters, std::vector< int > &resultCandidate) override
GeneralInterpretationAlgo(const edm::ParameterSet &conf, edm::ConsumesCollector iC)