40 using CandidateToDuplicate = std::vector<std::pair<int, int>>;
56 bool useForestFromDB_;
109 desc.
add<
double>(
"minDeltaR3d",-4.0);
110 desc.add<
double>(
"minBDTG",-0.1);
111 desc.add<
double>(
"minpT",0.2);
112 desc.add<
double>(
"minP",0.4);
113 desc.add<
double>(
"maxDCA",30.0);
114 desc.add<
double>(
"maxDPhi",0.30);
115 desc.add<
double>(
"maxDLambda",0.30);
116 desc.add<
double>(
"maxDdsz",10.0);
117 desc.add<
double>(
"maxDdxy",10.0);
118 desc.add<
double>(
"maxDQoP",0.25);
119 desc.add<
std::string>(
"forestLabel",
"MVADuplicate");
121 desc.add<
bool>(
"useInnermostState",
true);
122 desc.add<
std::string>(
"ttrhBuilderName",
"WithAngleAndTemplate");
123 descriptions.add(
"DuplicateTrackMerger", desc);
131 minDeltaR3d2_ = iPara.getParameter<
double>(
"minDeltaR3d"); minDeltaR3d2_*=
std::abs(minDeltaR3d2_);
132 minBDTG_ = iPara.getParameter<
double>(
"minBDTG");
133 minpT2_ = iPara.getParameter<
double>(
"minpT"); minpT2_ *= minpT2_;
134 minP_ = iPara.getParameter<
double>(
"minP");
135 maxDCA2_ = iPara.getParameter<
double>(
"maxDCA"); maxDCA2_*=maxDCA2_;
136 maxDPhi_ = iPara.getParameter<
double>(
"maxDPhi");
137 maxDLambda_ = iPara.getParameter<
double>(
"maxDLambda");
138 maxDdsz_ = iPara.getParameter<
double>(
"maxDdsz");
139 maxDdxy_ = iPara.getParameter<
double>(
"maxDdxy");
140 maxDQoP_ = iPara.getParameter<
double>(
"maxDQoP");
142 produces<std::vector<TrackCandidate> >(
"candidates");
143 produces<CandidateToDuplicate>(
"candidateMap");
145 forestLabel_ = iPara.getParameter<
std::string>(
"forestLabel");
147 dbFileName_ = iPara.getParameter<
std::string>(
"GBRForestFileName");
148 useForestFromDB_ = dbFileName_.empty();
167 DuplicateTrackMerger::~DuplicateTrackMerger()
170 if(!useForestFromDB_)
delete forest_;
177 Stat() : maxCos(1.1), nCand(0),nLoop0(0) {}
179 std::cout <<
"Stats " << nCand <<
' ' << nLoop0 <<
' ' << maxCos << std::endl;
181 std::atomic<float> maxCos;
182 std::atomic<int> nCand, nLoop0;
188 void update_maximum(std::atomic<T>& maximum_value,
T const&
value)
noexcept
190 T prev_value = maximum_value;
191 while(prev_value <
value &&
192 !maximum_value.compare_exchange_weak(prev_value,
value))
197 void update_minimum(std::atomic<T>& minimum_value,
T const&
value)
noexcept
199 T prev_value = minimum_value;
200 while(prev_value >
value &&
201 !minimum_value.compare_exchange_weak(prev_value,
value))
209 merger_.init(iSetup);
212 if(useForestFromDB_){
215 forest_ = forestHandle.
product();
217 TFile gbrfile(dbFileName_.c_str());
218 forest_ =
dynamic_cast<const GBRForest*
>(gbrfile.Get(forestLabel_.c_str()));
230 auto out_duplicateCandidates = std::make_unique<std::vector<TrackCandidate>>();
232 auto out_candidateMap = std::make_unique<CandidateToDuplicate>();
233 LogDebug(
"DuplicateTrackMerger") <<
"Number of tracks to be checked for merging: " <<
tracks.size();
235 for(
int i = 0;
i < (int)
tracks.size();
i++){
242 auto cosT = (*rt1).momentum().unit().Dot((*rt2).momentum().unit());
243 if (cosT<0.)
continue;
257 if(deltaR3d2 < minDeltaR3d2_)
continue;
274 float tmva_dqoverp_ = qoverp1-qoverp2;
275 if (
std::abs(tmva_dqoverp_) > maxDQoP_ )
continue;
283 float tmva_dlambda_ = lambda1-lambda2;
284 if (
std::abs(tmva_dlambda_) > maxDLambda_ )
continue;
288 float tmva_dphi_ = phi1-phi2;
290 if (
std::abs(tmva_dphi_) > maxDPhi_ )
continue;
294 float tmva_ddxy_ = dxy1-dxy2;
295 if (
std::abs(tmva_ddxy_) > maxDdxy_ )
continue;
301 float tmva_ddsz_ = dsz1-dsz2;
302 if (
std::abs(tmva_ddsz_) > maxDdsz_ )
continue;
304 float tmva_d3dr_ = avgPoint.perp();
305 float tmva_d3dz_ = avgPoint.z();
310 gbrVals_[0] = tmva_ddsz_;
311 gbrVals_[1] = tmva_ddxy_;
312 gbrVals_[2] = tmva_dphi_;
313 gbrVals_[3] = tmva_dlambda_;
314 gbrVals_[4] = tmva_dqoverp_;
315 gbrVals_[5] = tmva_d3dr_;
316 gbrVals_[6] = tmva_d3dz_;
317 gbrVals_[7] = tmva_outer_nMissingInner_;
318 gbrVals_[8] = tmva_inner_nMissingOuter_;
321 auto mvaBDTG = forest_->GetClassifier(gbrVals_);
322 if(mvaBDTG < minBDTG_)
continue;
326 out_duplicateCandidates->push_back(merger_.merge(*t1,*t2));
327 out_candidateMap->emplace_back(
i,
j);
332 if (cosT>0) update_minimum(stat.maxCos,
float(cosT));
338 iEvent.
put(
std::move(out_duplicateCandidates),
"candidates");
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const FreeTrajectoryState & theState() const
#define DEFINE_FWK_MODULE(type)
Geom::Phi< T > phi() const
static void fillDescriptions(ConfigurationDescriptions &descriptions)
const math::XYZPoint & outerPosition() const
position of the outermost hit
Geom::Theta< T > theta() const
const math::XYZPoint & innerPosition() const
position of the innermost hit
auto const T2 &decltype(t1.eta()) t2
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
Abs< T >::type abs(const T &t)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
GlobalVector momentum() const
GlobalPoint position() const
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
T const * product() const
int numberOfLostHits(HitCategory category) const
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
int charge() const
track electric charge
double signedInverseMomentum() const
GlobalVector momentum() const