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>
125 outputCollectionName_(iConfig.getParameter<
std::
string>(
"outputCollectionName")),
126 debug_(iConfig.getParameter<
int>(
"debug")) {
133 produces<std::vector<double>>(
"L1GTTInputTrackPtExpected");
134 produces<std::vector<double>>(
"L1GTTInputTrackEtaExpected");
168 log <<
"generate_eta_lut::The eta_lut_[" <<
kEtaLutSize <<
"] values are ... \n";
189 log <<
"generate_pt_lut::The pt_lut_[" <<
kPtLutSize <<
"] values are ... \n";
203 int digitizedValue =
bits;
204 if (
bits & (1 << (nBits - 1))) {
205 digitizedValue -= (1 << nBits);
209 return (
double(digitizedValue) + 0.5) *
lsb;
222 double theta = (
M_PI / 2.0) - atan(tanl);
225 edm::LogInfo(
"L1GTTInputProducer") <<
"indexTanLambda2Eta::tanl index = " << indexTanLambda <<
"\n" 226 <<
"indexTanLambda2Eta::tanl value = " << tanl <<
"\n" 227 <<
"indexTanLambda2Eta::theta = " <<
theta <<
"\n" 228 <<
"indexTanLambda2Eta::eta = " <<
eta;
247 const L1Track&
track,
out_eta_t& etaBits,
double& expected,
double& maxErrPerc,
double& maxErrEpsilon)
const {
254 if (expected > maxValuePossible) {
255 expected = maxValuePossible;
267 indexTanLambda ^=
mask;
268 indexTanLambda +=
sign;
289 if (
delta > maxErrEpsilon) {
290 maxErrPerc = perc_diff;
291 maxErrEpsilon =
delta;
295 edm::LogError(
"L1GTTInputProducer") <<
"getEtaBits::MISMATCH!!!\n" 296 <<
"\tTTTrack tanL = " <<
track.tanL() <<
"\n" 297 <<
"\tTTTrack eta = " <<
track.momentum().eta() <<
"\n" 298 <<
"\tTTTrack_TrackWord = " <<
track.getTrackWord().to_string(2) <<
"\n" 299 <<
"\tTTTrack_TrackWord tanlWord = " <<
track.getTanlWord() <<
" (" 300 <<
track.getTanlWord().to_string(2) <<
")\n" 301 <<
"\tin_eta_t value = " <<
value <<
" (" <<
value.to_string(2) <<
")\n" 302 <<
"\tExpected value = " << expected <<
"\n" 303 <<
"\tCalculated eta = " << etaBits.to_double() <<
" (" << etaBits.to_string(2)
304 <<
") @ index " << indexTanLambda <<
"\n" 305 <<
"\tDelta = " <<
delta <<
"\tpercentage error = " << perc_diff;
310 <<
"getEtaBits::SUCCESS (TTTrack, floating eta calculation, bitwise calculation, initial index, lut index) = " 311 <<
"(" <<
track.momentum().eta() <<
", " << expected <<
", " << etaBits <<
", " <<
value <<
", " 312 << indexTanLambda <<
")";
324 double& maxErrEpsilon,
326 double& minExpected)
const {
335 if (
std::abs(expected) > maxValuePossible) {
336 expected = maxValuePossible;
360 double charge = 1. - (2 * chargeBit.to_uint());
366 if (
delta > maxErrEpsilon) {
367 maxErrPerc = perc_diff;
368 maxErrEpsilon =
delta;
369 }
else if (delta < minExpected && !saturation && minErrPerc > 100.0) {
370 minErrPerc = perc_diff;
371 minExpected = expected;
375 edm::LogError(
"L1GTTInputProducer") <<
"getPtBits::MISMATCH!!!\n" 376 <<
"\tTTTrack Rinv = " <<
track.rInv() <<
"\n" 377 <<
"\tTTTrack pt = " <<
track.momentum().transverse() <<
"\n" 378 <<
"\tTTTrack_TrackWord = " <<
track.getTrackWord().to_string(2) <<
"\n" 379 <<
"\tTTTrack_TrackWord RinvWord = " <<
track.getRinvWord() <<
" (" 380 <<
track.getRinvWord().to_string(2) <<
")\n" 381 <<
"\tin_pt_t value = " << value_initial <<
" (" << value_initial.to_string(2)
383 <<
"\tExpected value = " << expected <<
"\n" 384 <<
"\tCalculated pt = " << ptBits.to_double() <<
" (" << ptBits.to_string(2)
385 <<
") @ index " <<
value <<
"\n" 386 <<
"\tcharge = " <<
charge <<
" (bit = " << chargeBit <<
")\n" 387 <<
"\tDelta = " <<
delta <<
"\tpercentage error = " << perc_diff;
391 edm::LogInfo(
"L1GTTInputProducer") <<
"getPtBits::SUCCESS (TTTrack, floating pt calculation, charge, bitwise " 392 "calculation, initial index, lut index) = " 393 <<
"(" <<
sgn(
track.rInv()) *
track.momentum().transverse() <<
", " << expected
394 <<
", " <<
charge <<
", " << ptBits <<
", " << value_initial <<
", " <<
value 404 auto vTTTrackOutput = std::make_unique<TTTrackCollection>();
405 auto vPtOutput = std::make_unique<std::vector<double>>();
406 auto vEtaOutput = std::make_unique<std::vector<double>>();
416 unsigned int error_pt_c = 0;
417 unsigned int error_eta_c = 0;
418 double expectedPt = 0.0;
419 double expectedEta = 0.0;
420 double maxErrPercPt = 0.0;
421 double maxErrPercEta = 0.0;
422 double maxErrEpsilonPt = 0.0;
423 double maxErrEpsilonEta = 0.0;
424 double minErrPercPt = 10000000.0;
425 double minExpectedPt = 10000000.0;
427 unsigned int nOutput = l1TracksHandle->size();
428 vTTTrackOutput->reserve(nOutput);
429 vPtOutput->reserve(nOutput);
430 vEtaOutput->reserve(nOutput);
431 for (
const auto&
track : *l1TracksHandle) {
434 <<
"L1GTTInputProducer::produce method is called with numFitPars_ = " <<
track.nFitPars()
435 <<
". The only possible values are 4/5.";
439 vTTTrackOutput->push_back(
track);
440 auto& currentTrackRef = vTTTrackOutput->back();
442 edm::LogInfo(
"L1GTTInputProducer") <<
"produce::word before anything " 443 << currentTrackRef.getTrackWord().to_string(2);
447 currentTrackRef.setTrackWordBits();
449 edm::LogInfo(
"L1GTTInputProducer") <<
"produce::word after initial setting of the track word " 450 << currentTrackRef.getTrackWord().to_string(2);
455 currentTrackRef, ptBits, chargeBit, expectedPt, maxErrPercPt, maxErrEpsilonPt, minErrPercPt, minExpectedPt);
456 error_eta_c +=
getEtaBits(currentTrackRef, etaBits, expectedEta, maxErrPercEta, maxErrEpsilonEta);
459 ptBitsShifted = ptBits.range();
460 etaBitsShifted = etaBits.range();
463 ptBitsShifted = ptBitsShifted << 2;
464 etaBitsShifted = etaBitsShifted << 8;
470 currentTrackRef.setTrackWord(currentTrackRef.getValidWord(),
472 currentTrackRef.getPhiWord(),
474 currentTrackRef.getZ0Word(),
475 currentTrackRef.getD0Word(),
476 currentTrackRef.getChi2RPhiWord(),
477 currentTrackRef.getChi2RZWord(),
478 currentTrackRef.getBendChi2Word(),
479 currentTrackRef.getHitPatternWord(),
480 currentTrackRef.getMVAQualityWord(),
481 currentTrackRef.getMVAOtherWord());
483 edm::LogInfo(
"L1GTTInputProducer") <<
"produce::charge after all conversions " << chargeBit <<
"\n" 484 <<
"produce::ptBits after all conversions " << ptBits.to_string(2) <<
" (" 485 << ptBitsShifted.to_string(2) <<
" = " << ptBitsShifted.to_uint() <<
")\n" 486 <<
"produce::etaBits after all conversions " << etaBits.to_string(2) <<
" (" 487 << etaBitsShifted.to_string(2) <<
" = " << etaBitsShifted.to_uint() <<
")\n" 488 <<
"produce::word after all conversions " 489 << vTTTrackOutput->back().getTrackWord().to_string(2);
493 vPtOutput->push_back(expectedPt);
494 vEtaOutput->push_back(expectedEta);
498 edm::LogInfo(
"L1GTTInputProducer") <<
"\nNumber of converted tracks: " << nOutput <<
"\n\n" 499 <<
"q/r ==> pt conversion:\n" 501 <<
"\tMax error: " << maxErrEpsilonPt
502 <<
" GeV difference with percentage: " << maxErrPercPt <<
"% @ " 503 << 100.0 * maxErrEpsilonPt / maxErrPercPt <<
" GeV" 505 <<
"\tError @ max range: " << minExpectedPt
506 <<
" GeV with precentage: " << minErrPercPt <<
"%" 508 <<
"\tTotal number of errors: " << error_pt_c <<
"\n\n" 509 <<
"tan(lambda) ==> eta conversion:\n" 511 <<
"\tMax error: " << maxErrEpsilonEta <<
" with percentage: " << maxErrPercEta
512 <<
"% @ " << 100.0 * maxErrEpsilonEta / maxErrPercEta <<
"\n" 513 <<
"\tTotal number of errors: " << error_eta_c;
516 if (error_pt_c + error_eta_c) {
517 edm::LogError(
"L1GTTInputProducer") <<
"produce::" << error_pt_c <<
"/" << error_eta_c
518 <<
" pt/eta mismatches detected!!!";
531 desc.add<
int>(
"debug", 0)->setComment(
"Verbosity levels: 0, 1, 2, 3");
533 desc.add<
std::string>(
"outputCollectionName",
"Level1TTTracksConverted");
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
Geom::Theta< T > theta() const
Power< A, B >::type pow(const A &a, const B &b)