39 using CandidateToDuplicate = std::vector<std::pair<int, int>>;
55 bool useForestFromDB_;
108 desc.
add<
double>(
"minDeltaR3d",-4.0);
109 desc.add<
double>(
"minBDTG",-0.1);
110 desc.add<
double>(
"minpT",0.2);
111 desc.add<
double>(
"minP",0.4);
112 desc.add<
double>(
"maxDCA",30.0);
113 desc.add<
double>(
"maxDPhi",0.30);
114 desc.add<
double>(
"maxDLambda",0.30);
115 desc.add<
double>(
"maxDdsz",10.0);
116 desc.add<
double>(
"maxDdxy",10.0);
117 desc.add<
double>(
"maxDQoP",0.25);
118 desc.add<
std::string>(
"forestLabel",
"MVADuplicate");
120 desc.add<
bool>(
"useInnermostState",
true);
121 desc.add<
std::string>(
"ttrhBuilderName",
"WithAngleAndTemplate");
122 descriptions.add(
"DuplicateTrackMerger", desc);
130 minDeltaR3d2_ = iPara.getParameter<
double>(
"minDeltaR3d"); minDeltaR3d2_*=
std::abs(minDeltaR3d2_);
131 minBDTG_ = iPara.getParameter<
double>(
"minBDTG");
132 minpT2_ = iPara.getParameter<
double>(
"minpT"); minpT2_ *= minpT2_;
133 minP_ = iPara.getParameter<
double>(
"minP");
134 maxDCA2_ = iPara.getParameter<
double>(
"maxDCA"); maxDCA2_*=maxDCA2_;
135 maxDPhi_ = iPara.getParameter<
double>(
"maxDPhi");
136 maxDLambda_ = iPara.getParameter<
double>(
"maxDLambda");
137 maxDdsz_ = iPara.getParameter<
double>(
"maxDdsz");
138 maxDdxy_ = iPara.getParameter<
double>(
"maxDdxy");
139 maxDQoP_ = iPara.getParameter<
double>(
"maxDQoP");
141 produces<std::vector<TrackCandidate> >(
"candidates");
142 produces<CandidateToDuplicate>(
"candidateMap");
144 forestLabel_ = iPara.getParameter<
std::string>(
"forestLabel");
146 dbFileName_ = iPara.getParameter<
std::string>(
"GBRForestFileName");
147 useForestFromDB_ = dbFileName_.empty();
166 DuplicateTrackMerger::~DuplicateTrackMerger()
169 if(!useForestFromDB_)
delete forest_;
176 Stat() : maxCos(1.1), nCand(0),nLoop0(0) {}
178 std::cout <<
"Stats " << nCand <<
' ' << nLoop0 <<
' ' << maxCos << std::endl;
180 std::atomic<float> maxCos;
181 std::atomic<int> nCand, nLoop0;
187 void update_maximum(std::atomic<T>& maximum_value,
T const&
value)
noexcept
189 T prev_value = maximum_value;
190 while(prev_value <
value &&
191 !maximum_value.compare_exchange_weak(prev_value,
value))
196 void update_minimum(std::atomic<T>& minimum_value,
T const&
value)
noexcept
198 T prev_value = minimum_value;
199 while(prev_value >
value &&
200 !minimum_value.compare_exchange_weak(prev_value,
value))
208 merger_.init(iSetup);
211 if(useForestFromDB_){
214 forest_ = forestHandle.
product();
216 TFile gbrfile(dbFileName_.c_str());
217 forest_ =
dynamic_cast<const GBRForest*
>(gbrfile.Get(forestLabel_.c_str()));
229 std::unique_ptr<std::vector<TrackCandidate> > out_duplicateCandidates(
new std::vector<TrackCandidate>());
231 std::unique_ptr<CandidateToDuplicate> out_candidateMap(
new CandidateToDuplicate());
233 for(
int i = 0;
i < (int)
tracks.size();
i++){
240 auto cosT = (*rt1).momentum().unit().Dot((*rt2).momentum().unit());
241 if (cosT<0.)
continue;
255 if(deltaR3d2 < minDeltaR3d2_)
continue;
272 float tmva_dqoverp_ = qoverp1-qoverp2;
273 if (
std::abs(tmva_dqoverp_) > maxDQoP_ )
continue;
281 float tmva_dlambda_ = lambda1-lambda2;
282 if (
std::abs(tmva_dlambda_) > maxDLambda_ )
continue;
286 float tmva_dphi_ = phi1-phi2;
288 if (
std::abs(tmva_dphi_) > maxDPhi_ )
continue;
292 float tmva_ddxy_ = dxy1-dxy2;
293 if (
std::abs(tmva_ddxy_) > maxDdxy_ )
continue;
299 float tmva_ddsz_ = dsz1-dsz2;
300 if (
std::abs(tmva_ddsz_) > maxDdsz_ )
continue;
302 float tmva_d3dr_ = avgPoint.perp();
303 float tmva_d3dz_ = avgPoint.z();
308 gbrVals_[0] = tmva_ddsz_;
309 gbrVals_[1] = tmva_ddxy_;
310 gbrVals_[2] = tmva_dphi_;
311 gbrVals_[3] = tmva_dlambda_;
312 gbrVals_[4] = tmva_dqoverp_;
313 gbrVals_[5] = tmva_d3dr_;
314 gbrVals_[6] = tmva_d3dz_;
315 gbrVals_[7] = tmva_outer_nMissingInner_;
316 gbrVals_[8] = tmva_inner_nMissingOuter_;
319 auto mvaBDTG = forest_->GetClassifier(gbrVals_);
320 if(mvaBDTG < minBDTG_)
continue;
324 out_duplicateCandidates->push_back(merger_.merge(*t1,*t2));
325 out_candidateMap->emplace_back(
i,
j);
330 if (cosT>0) update_minimum(stat.maxCos,
float(cosT));
336 iEvent.
put(
std::move(out_duplicateCandidates),
"candidates");
T getParameter(std::string const &) const
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
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