-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EMTF March 2020 emulator update #29262
Conversation
The code-checks are being triggered in jenkins. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-29262/14307
|
Hi @silviodonato @kpedro88 |
@rekovic that doesn't seem quite in line with the PR description, which mentions Phase 2 and TDR studies several times |
@kpedro88 The new hardware used in Phase-2 will support a different algorithm which will be emulated by a different code (not yet ready for integration). I would like to keep the two separate and avoid possibilities of disrupting development of Phase-2 or endangering backward compatibilities. What is written in this PR description only has to do with the interface, namely ability to read the TPs. This was discussed with @jiafulow. |
@kpedro88 |
#include "DataFormats/RPCDigi/interface/RPCDigi.h" | ||
#include "DataFormats/GEMDigi/interface/GEMPadDigi.h" | ||
#include "DataFormats/GEMDigi/interface/ME0PadDigi.h" | ||
//#include "DataFormats/RPCDigi/interface/RPCDigi.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete commented-out code
RPCDetId CreateRPCDetId() const; | ||
// void ImportGEMDetId (const GEMDetId& _detId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete commented-out code
int Subsystem() const { return subsystem; } | ||
|
||
// See L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h | ||
bool Is_DT() const { return subsystem == 0; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like a good case for an enum
void set_RoadIdx(unsigned int bits) { _RoadIdx = bits; } | ||
EMTFRoad Road() const { return _Road; } | ||
unsigned int RoadIdx() const { return _RoadIdx; } | ||
//void set_Road(const EMTFRoad& bits) { _Road = bits; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete commented-out code
@@ -177,15 +177,22 @@ namespace l1t { | |||
RPC_.Word(), | |||
RPC_.Link()); | |||
|
|||
// Rotate by 20 deg to match RPC convention in CMSSW | |||
int _sector_rpc = (_subsector < 5) ? _sector : (_sector % 6) + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
magic numbers should be named constants (everywhere)
int tp_endcap = (tp_region == -1) ? 2 : tp_region; | ||
int tp_station = tp_detId.station(); | ||
int tp_ring = 1; // tp_detId.ring() does not exist | ||
//int tp_roll = tp_detId.roll(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete commented-out code
bool sub5deg = false; | ||
if (includeNeighbor_) { | ||
if ((endcap_ == tp_endcap) && (get_other_neighbor(sector_) == tp_sector)) { | ||
if (tp_csc_ID == 1 && tp_endcap == 1 && tp_pad >= (767 - 192)) { // higher 1/4 of chamber |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
magic numbers should be named constants
|
||
int tp_bx = tp_data.bx; | ||
int tp_phi = tp_data.radialAngle; | ||
//int tp_phiB = tp_data.bendingAngle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete commented-out code
collector.extractPrimitives(GEMTag(), iEvent, tokenGEM_, muon_primitives); | ||
if (useCSC_) { | ||
collector.extractPrimitives(emtf::CSCTag(), &geometry_translator_, iEvent, tokenCSC_, muon_primitives); | ||
//collector.extractPrimitives(emtf::CSCTag(), &geometry_translator_, iEvent, tokenCSC_, tokenCSCComparator_, muon_primitives); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete commented-out code
int get_trigger_sector(int ring, int station, int chamber) { | ||
int result = 0; | ||
if (station > 1 && ring > 1) { | ||
result = ((static_cast<unsigned>(chamber - 3) & 0x7f) / 6) + 1; // ch 3-8->1, 9-14->2, ... 1,2 -> 6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
magic numbers should be named constants
Thanks @kpedro88 . Thanks for the catch of a wrong size array Some magic numbers should indeed be turned into named constants. In some cases I would say there might not be much point in doing so. |
@rekovic there are several reasons to avoid magic numbers in almost all circumstances. using named constants not only makes the code more readable and understandable for future maintainers by labeling numbers by their meaning, but also it enforces consistency. if a number is changed in one place, should the same number be changed somewhere else? how do i know if that 2 is the same as this other 2? this is always a future problem, not a present one, which is why the policy should always be followed whether or not a problem is "foreseen". |
Regarding I have no idea that commented out codes are against the CMS rules. Sometimes, codes are commented out for now, but might need to be uncommented in the future. Sometimes codes are commented out to leave as a trace, so that if bugs are found in the future, it's easier to debug by checking what the previous version was. Deleting them just makes life harder for the few developers who have to work with the codes. The codes are almost always work in progress, rather than a finished product. It sounds crazy to me that this is instituted as a rule. Regarding the magic numbers, most of the cryptic ones are already explained by the comments next to them. The trivial ones are clear from the context. There's no reason to assume any future human maintainers wouldn't be able to figure that out. |
Hi @kpedro88 , I'm all for clarity, but surely when the "magic" number is just the ID number, you don't increase the clarity by creating a new named constant? For example, in the code above "tp_csc_ID == 1" clearly indicates that the CSC ID must equal 1. This would not be made any clearer by defining some new constant: Cheers, |
If there is a particular reason that a commented-out line of code should be kept, this should be indicated in a separate comment above that line of code. Typically, this is a temporary situation, and therefore the conditions for uncommenting that line of code should be clearly stated. Otherwise, if a line of code is no longer needed, it is still preserved in the git history (and previous releases) for anyone who needs to look back at it. CMSSW has 100s of contributors, with people frequently entering and leaving the collaboration. Leaving a file littered with commented-out lines of code makes it significantly harder to tell what the code is supposed to do. Once code is in the official repository, maintaining it is everyone's responsibility, not just the original developer's. Therefore, a higher standard must be met.
Making human maintainers "figure things out" that computers can do automatically is bad practice.
What if, for some reason, a future muon subdetector geometry swaps what is currently considered chamber 1 with chamber 2? Do you want to go through thousands of lines of code and figure out which "1"s need to be swapped with which "2"s? This is a somewhat contrived example, but there are plenty of non-contrived examples just in this PR. |
"What if, for some reason, a future muon subdetector geometry swaps what is currently considered chamber 1 with chamber 2? Do you want to go through thousands of lines of code and figure out which "1"s need to be swapped with which "2"s?" My answer would be: "absolutely, yes." Because there is no central CMSSW object linking physical chambers to their numerical IDs, and if we decided to create one now, we'd have to go through all the existing L1T and CSC code and update it to use this chamber-map object. If we don't create such an object, then any change to the mapping means we have to go through all the code and find all of the new constants we created and change them by hand anyway. It saves 0 time, and adds 0 clarity compared to just using the ID number. |
In https://cms-sw.github.io/cms_coding_rules.html you can find the "CMSSW rules".
is more understandable than
The code has exactly the same performance (last_month is replaced with About
I think it is rather clear, but the following code is more understandable for people who are not L1T experts
Anyhow, you can keep the 1-line version, if you strongly prefer it. About
you definitely need to use Regarding the commented code, I confirm the policy of deleting commented lines. |
Let me be clear. No one in our group who is responsible for developing/maintaining this particular package would have trouble understanding
or
The hypothetical scenario where a maintainer would struggle to understand them doesn't exist. Not now, not in the future. I'm sorry I simply don't agree that the following code is better:
It's introducing throwaway variables, and it's harder to read than a one-liner. Everyone has different opinions, I've stated my opinions, and I'm not going to argue further on what is 'better' or higher code quality. In the end, our group is the one that takes responsibilities of the output of this particular package. As the developer, I have my own opinions and I am not going to be force-fed bullshit opinions. My job is to submit a PR that does what the L1 group asked of us. If the PR is not doing what is described, I'm happy to fix it. But I'm not entertaining pointless code review comments. Regarding Calling the commented-out codes 'litter' is also a stretch. Most of them are single-line, and only a few of them are 3-4 lines. They don't make it 'significantly harder' to read at all. |
Please note that no developer or group is entitled to have their code included in the official repository. Your group may "take responsibility" for the code in an informal way, but once it is included in the official repository, it is everyone's responsibility - if it breaks, it must be fixed. I deliberately included this statement in my PR review to indicate the relative importance of comments: "some of the code rule/style issues in my review seem preexisting/beyond the scope of this PR, so they can be addressed in a subsequent PR." But I am also happy to reject the PR outright if the developers feel they don't need to follow the rules at all. |
Except that every time the EMTF emulator broke, it was up to us to fix it. If you feel you have the power over all the codes that we contributed, and do not want to address any concerns that your rules are bad and sometimes even pointless, then go ahead and do what you want to do. I've already provided the justifications for the select lines of codes you guys wanted to discuss. There's no reason for me to fix anything that is not broken. |
-1 |
Coming back to this thread.
I agree. For the sake of consistency using constants is preferred. In some cases this could severely jeopardizes the readability, but in the long run it pays off. |
This PR has conflicts, it needs to be rebased. |
moved to #29767 |
PR description:
This PR adds/updates the interface to all the Phase-2 trigger primitives. This is the first PR from a series of EMTF emulator updates planned for 2020.
The EMTF emulator needs to be upgraded to handle all the Phase-2 trigger primitives, including GEM, ME0, and iRPC. It's also nice to be able to handle DT/TwinMux. Majority of the work has been done during the development for Phase-2 EMTF++, and used for L1T Phase-2 Upgrade TDR studies. These changes are now being ported to the official CMSSW. For Run 3 specifically, the GE1/1 interface is needed to continue the rest of the EMTF-GEM integration.
There are a lot of changes because what's in the existing EMTF emulator related to GEM/ME0/iRPC is not correct/updated. Also, unused codes related to converting track trigger stubs into muon trigger primitives have been removed.
Notes:
Subsector()
for EMTFHit converted from RPC hit has changed. It is now consistent with the CSC definition (1 or 2 in ME1, 0 in ME2,3,4). The old definition is no longer stored, but can be recovered viaSubsector_RPC()
.GEMPadDigiClusterCollection
.ME0TriggerDigiCollection
.simTwinMuxDigis
,simDtTriggerPrimitiveDigis
,rpcRecHits
,me0TriggerConvertedPseudoDigis
has been added, but none of them are turned on by default.Additional notes:
PR validation:
From
runTheMatrix.py -l limited -i all -j10
:From
runTheMatrix.py -w upgrade -l 20434.0,20504.0 -j10
:Considering this is a big PR, there might be bugs. But we will try to detect and fix them as soon as possible.
Notifications: @abrinke1 @eyigitba @rekovic