40 #define _USE_MATH_DEFINES 84 typedef ap_fixed<kEtaOutputSize, kEtaMagSize, AP_RND_CONV, AP_SAT>
out_eta_t;
86 typedef ap_ufixed<kPTOutputSize, kPTMagSize, AP_RND_CONV, AP_SAT>
out_pt_t;
94 const L1Track&
track,
out_eta_t& etaBits,
double& expected,
double& maxErrPerc,
double& maxErrEpsilon)
const;
100 double& maxErrEpsilon,
102 double& minExpected)
const;
106 template <
typename T>
126 outputCollectionName_(iConfig.getParameter<
std::
string>(
"outputCollectionName")),
127 setTrackWordBits_(iConfig.getParameter<
bool>(
"setTrackWordBits")),
128 debug_(iConfig.getParameter<
int>(
"debug")) {
135 produces<std::vector<double>>(
"L1GTTInputTrackPtExpected");
136 produces<std::vector<double>>(
"L1GTTInputTrackEtaExpected");
170 log <<
"generate_eta_lut::The eta_lut_[" <<
kEtaLutSize <<
"] values are ... \n";
191 log <<
"generate_pt_lut::The pt_lut_[" <<
kPtLutSize <<
"] values are ... \n";
205 int digitizedValue =
bits;
206 if (
bits & (1 << (nBits - 1))) {
207 digitizedValue -= (1 << nBits);
211 return (
double(digitizedValue) + 0.5) *
lsb;
224 double theta = (
M_PI / 2.0) - atan(tanl);
227 edm::LogInfo(
"L1GTTInputProducer") <<
"indexTanLambda2Eta::tanl index = " << indexTanLambda <<
"\n" 228 <<
"indexTanLambda2Eta::tanl value = " << tanl <<
"\n" 229 <<
"indexTanLambda2Eta::theta = " <<
theta <<
"\n" 230 <<
"indexTanLambda2Eta::eta = " <<
eta;
249 const L1Track&
track,
out_eta_t& etaBits,
double& expected,
double& maxErrPerc,
double& maxErrEpsilon)
const {
256 if (expected > maxValuePossible) {
257 expected = maxValuePossible;
269 indexTanLambda ^=
mask;
270 indexTanLambda +=
sign;
291 if (
delta > maxErrEpsilon) {
292 maxErrPerc = perc_diff;
293 maxErrEpsilon =
delta;
297 edm::LogError(
"L1GTTInputProducer") <<
"getEtaBits::MISMATCH!!!\n" 298 <<
"\tTTTrack tanL = " <<
track.tanL() <<
"\n" 299 <<
"\tTTTrack eta = " <<
track.momentum().eta() <<
"\n" 300 <<
"\tTTTrack_TrackWord = " <<
track.getTrackWord().to_string(2) <<
"\n" 301 <<
"\tTTTrack_TrackWord tanlWord = " <<
track.getTanlWord() <<
" (" 302 <<
track.getTanlWord().to_string(2) <<
")\n" 303 <<
"\tin_eta_t value = " <<
value <<
" (" <<
value.to_string(2) <<
")\n" 304 <<
"\tExpected value = " << expected <<
"\n" 305 <<
"\tCalculated eta = " << etaBits.to_double() <<
" (" << etaBits.to_string(2)
306 <<
") @ index " << indexTanLambda <<
"\n" 307 <<
"\tDelta = " <<
delta <<
"\tpercentage error = " << perc_diff;
312 <<
"getEtaBits::SUCCESS (TTTrack, floating eta calculation, bitwise calculation, initial index, lut index) = " 313 <<
"(" <<
track.momentum().eta() <<
", " << expected <<
", " << etaBits <<
", " <<
value <<
", " 314 << indexTanLambda <<
")";
326 double& maxErrEpsilon,
328 double& minExpected)
const {
337 if (
std::abs(expected) > maxValuePossible) {
338 expected = maxValuePossible;
362 double charge = 1. - (2 * chargeBit.to_uint());
368 if (
delta > maxErrEpsilon) {
369 maxErrPerc = perc_diff;
370 maxErrEpsilon =
delta;
371 }
else if (delta < minExpected && !saturation && minErrPerc > 100.0) {
372 minErrPerc = perc_diff;
373 minExpected = expected;
377 edm::LogError(
"L1GTTInputProducer") <<
"getPtBits::MISMATCH!!!\n" 378 <<
"\tTTTrack Rinv = " <<
track.rInv() <<
"\n" 379 <<
"\tTTTrack pt = " <<
track.momentum().transverse() <<
"\n" 380 <<
"\tTTTrack_TrackWord = " <<
track.getTrackWord().to_string(2) <<
"\n" 381 <<
"\tTTTrack_TrackWord RinvWord = " <<
track.getRinvWord() <<
" (" 382 <<
track.getRinvWord().to_string(2) <<
")\n" 383 <<
"\tin_pt_t value = " << value_initial <<
" (" << value_initial.to_string(2)
385 <<
"\tExpected value = " << expected <<
"\n" 386 <<
"\tCalculated pt = " << ptBits.to_double() <<
" (" << ptBits.to_string(2)
387 <<
") @ index " <<
value <<
"\n" 388 <<
"\tcharge = " <<
charge <<
" (bit = " << chargeBit <<
")\n" 389 <<
"\tDelta = " <<
delta <<
"\tpercentage error = " << perc_diff;
393 edm::LogInfo(
"L1GTTInputProducer") <<
"getPtBits::SUCCESS (TTTrack, floating pt calculation, charge, bitwise " 394 "calculation, initial index, lut index) = " 395 <<
"(" <<
sgn(
track.rInv()) *
track.momentum().transverse() <<
", " << expected
396 <<
", " <<
charge <<
", " << ptBits <<
", " << value_initial <<
", " <<
value 406 auto vTTTrackOutput = std::make_unique<TTTrackCollection>();
407 auto vPtOutput = std::make_unique<std::vector<double>>();
408 auto vEtaOutput = std::make_unique<std::vector<double>>();
418 unsigned int error_pt_c = 0;
419 unsigned int error_eta_c = 0;
420 double expectedPt = 0.0;
421 double expectedEta = 0.0;
422 double maxErrPercPt = 0.0;
423 double maxErrPercEta = 0.0;
424 double maxErrEpsilonPt = 0.0;
425 double maxErrEpsilonEta = 0.0;
426 double minErrPercPt = 10000000.0;
427 double minExpectedPt = 10000000.0;
429 unsigned int nOutput = l1TracksHandle->size();
430 vTTTrackOutput->reserve(nOutput);
431 vPtOutput->reserve(nOutput);
432 vEtaOutput->reserve(nOutput);
433 for (
const auto&
track : *l1TracksHandle) {
436 <<
"L1GTTInputProducer::produce method is called with numFitPars_ = " <<
track.nFitPars()
437 <<
". The only possible values are 4/5.";
441 vTTTrackOutput->push_back(
track);
442 auto& currentTrackRef = vTTTrackOutput->back();
444 edm::LogInfo(
"L1GTTInputProducer") <<
"produce::word before anything with setTrackWordBits_ = " 450 currentTrackRef.setTrackWordBits();
452 edm::LogInfo(
"L1GTTInputProducer") <<
"produce::word after initial setting of the track word " 453 << currentTrackRef.getTrackWord().to_string(2);
458 currentTrackRef, ptBits, chargeBit, expectedPt, maxErrPercPt, maxErrEpsilonPt, minErrPercPt, minExpectedPt);
459 error_eta_c +=
getEtaBits(currentTrackRef, etaBits, expectedEta, maxErrPercEta, maxErrEpsilonEta);
462 ptBitsShifted = ptBits.range();
463 etaBitsShifted = etaBits.range();
466 ptBitsShifted = ptBitsShifted << 2;
467 etaBitsShifted = etaBitsShifted << 8;
473 currentTrackRef.setTrackWord(currentTrackRef.getValidWord(),
475 currentTrackRef.getPhiWord(),
477 currentTrackRef.getZ0Word(),
478 currentTrackRef.getD0Word(),
479 currentTrackRef.getChi2RPhiWord(),
480 currentTrackRef.getChi2RZWord(),
481 currentTrackRef.getBendChi2Word(),
482 currentTrackRef.getHitPatternWord(),
483 currentTrackRef.getMVAQualityWord(),
484 currentTrackRef.getMVAOtherWord());
486 edm::LogInfo(
"L1GTTInputProducer") <<
"produce::charge after all conversions " << chargeBit <<
"\n" 487 <<
"produce::ptBits after all conversions " << ptBits.to_string(2) <<
" (" 488 << ptBitsShifted.to_string(2) <<
" = " << ptBitsShifted.to_uint() <<
")\n" 489 <<
"produce::etaBits after all conversions " << etaBits.to_string(2) <<
" (" 490 << etaBitsShifted.to_string(2) <<
" = " << etaBitsShifted.to_uint() <<
")\n" 491 <<
"produce::word after all conversions " 492 << vTTTrackOutput->back().getTrackWord().to_string(2);
496 vPtOutput->push_back(expectedPt);
497 vEtaOutput->push_back(expectedEta);
501 edm::LogInfo(
"L1GTTInputProducer") <<
"\nNumber of converted tracks: " << nOutput <<
"\n\n" 502 <<
"q/r ==> pt conversion:\n" 504 <<
"\tMax error: " << maxErrEpsilonPt
505 <<
" GeV difference with percentage: " << maxErrPercPt <<
"% @ " 506 << 100.0 * maxErrEpsilonPt / maxErrPercPt <<
" GeV" 508 <<
"\tError @ max range: " << minExpectedPt
509 <<
" GeV with precentage: " << minErrPercPt <<
"%" 511 <<
"\tTotal number of errors: " << error_pt_c <<
"\n\n" 512 <<
"tan(lambda) ==> eta conversion:\n" 514 <<
"\tMax error: " << maxErrEpsilonEta <<
" with percentage: " << maxErrPercEta
515 <<
"% @ " << 100.0 * maxErrEpsilonEta / maxErrPercEta <<
"\n" 516 <<
"\tTotal number of errors: " << error_eta_c;
519 if (error_pt_c + error_eta_c) {
520 edm::LogError(
"L1GTTInputProducer") <<
"produce::" << error_pt_c <<
"/" << error_eta_c
521 <<
" pt/eta mismatches detected!!!";
534 desc.add<
int>(
"debug", 0)->setComment(
"Verbosity levels: 0, 1, 2, 3");
536 desc.add<
std::string>(
"outputCollectionName",
"Level1TTTracksConverted");
537 desc.add<
bool>(
"setTrackWordBits",
true)
539 "flag indicated whether the TTTrack_TrackWord should be set from float parameters or skipped (if TrackWord " 540 "set by e.g. GTTFileReader decoding)");
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Log< level::Error, false > LogError
static constexpr double stepRinv
Tan< T >::type tan(const T &t)
ap_uint< TrackBitWidths::kRinvSize > rinv_t
Abs< T >::type abs(const T &t)
static constexpr double stepTanL
#define DEFINE_FWK_MODULE(type)
Log< level::Info, false > LogInfo
Class to store the L1 Track Trigger tracks.
ap_uint< TrackBitWidths::kTanlSize > tanl_t
Power< A, B >::type pow(const A &a, const B &b)