Skip to content
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

Add additional track variables to the Run 3 scouting electron collection for low pT electrons. #41025

Merged
merged 1 commit into from Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 35 additions & 15 deletions DataFormats/Scouting/interface/Run3ScoutingElectron.h
Expand Up @@ -13,15 +13,19 @@ class Run3ScoutingElectron {
float eta,
float phi,
float m,
float d0,
float dz,
std::vector<float> trkd0,
std::vector<float> trkdz,
std::vector<float> trkpt,
std::vector<float> trketa,
std::vector<float> trkphi,
std::vector<float> trkchi2overndf,
float dEtaIn,
float dPhiIn,
float sigmaIetaIeta,
float hOverE,
float ooEMOop,
int missingHits,
int charge,
std::vector<int> trkcharge,
float ecalIso,
float hcalIso,
float trackIso,
Expand All @@ -37,15 +41,19 @@ class Run3ScoutingElectron {
eta_(eta),
phi_(phi),
m_(m),
d0_(d0),
dz_(dz),
trkd0_(std::move(trkd0)),
trkdz_(std::move(trkdz)),
trkpt_(std::move(trkpt)),
trketa_(std::move(trketa)),
trkphi_(std::move(trkphi)),
trkchi2overndf_(std::move(trkchi2overndf)),
dEtaIn_(dEtaIn),
dPhiIn_(dPhiIn),
sigmaIetaIeta_(sigmaIetaIeta),
hOverE_(hOverE),
ooEMOop_(ooEMOop),
missingHits_(missingHits),
charge_(charge),
trkcharge_(std::move(trkcharge)),
ecalIso_(ecalIso),
hcalIso_(hcalIso),
trackIso_(trackIso),
Expand All @@ -63,15 +71,19 @@ class Run3ScoutingElectron {
eta_(0),
phi_(0),
m_(0),
d0_(0),
dz_(0),
trkd0_(0),
trkdz_(0),
trkpt_(0),
trketa_(0),
trkphi_(0),
trkchi2overndf_(0),
dEtaIn_(0),
dPhiIn_(0),
sigmaIetaIeta_(0),
hOverE_(0),
ooEMOop_(0),
missingHits_(0),
charge_(0),
trkcharge_(0),
ecalIso_(0),
hcalIso_(0),
trackIso_(0),
Expand All @@ -86,15 +98,19 @@ class Run3ScoutingElectron {
float eta() const { return eta_; }
float phi() const { return phi_; }
float m() const { return m_; }
float d0() const { return d0_; }
float dz() const { return dz_; }
arsahasransu marked this conversation as resolved.
Show resolved Hide resolved
std::vector<float> const& trkd0() const { return trkd0_; }
std::vector<float> const& trkdz() const { return trkdz_; }
std::vector<float> const& trkpt() const { return trkpt_; }
std::vector<float> const& trketa() const { return trketa_; }
std::vector<float> const& trkphi() const { return trkphi_; }
std::vector<float> const& trkchi2overndf() const { return trkchi2overndf_; }
float dEtaIn() const { return dEtaIn_; }
float dPhiIn() const { return dPhiIn_; }
float sigmaIetaIeta() const { return sigmaIetaIeta_; }
float hOverE() const { return hOverE_; }
float ooEMOop() const { return ooEMOop_; }
int missingHits() const { return missingHits_; }
int charge() const { return charge_; }
arsahasransu marked this conversation as resolved.
Show resolved Hide resolved
std::vector<int> const& trkcharge() const { return trkcharge_; }
float ecalIso() const { return ecalIso_; }
float hcalIso() const { return hcalIso_; }
float trackIso() const { return trackIso_; }
Expand All @@ -112,15 +128,19 @@ class Run3ScoutingElectron {
float eta_;
float phi_;
float m_;
float d0_;
float dz_;
arsahasransu marked this conversation as resolved.
Show resolved Hide resolved
std::vector<float> trkd0_;
std::vector<float> trkdz_;
std::vector<float> trkpt_;
std::vector<float> trketa_;
std::vector<float> trkphi_;
std::vector<float> trkchi2overndf_;
float dEtaIn_;
float dPhiIn_;
float sigmaIetaIeta_;
float hOverE_;
float ooEMOop_;
int missingHits_;
int charge_;
arsahasransu marked this conversation as resolved.
Show resolved Hide resolved
std::vector<int> trkcharge_;
float ecalIso_;
float hcalIso_;
float trackIso_;
Expand Down
32 changes: 30 additions & 2 deletions DataFormats/Scouting/src/classes_def.xml
Expand Up @@ -41,11 +41,39 @@
<class name="Run3ScoutingVertex" ClassVersion="3">
<version ClassVersion="3" checksum="316446070"/>
</class>
<class name="Run3ScoutingElectron" ClassVersion="5">
<class name="Run3ScoutingElectron" ClassVersion="6">
<version ClassVersion="3" checksum="1086011373"/>
<version ClassVersion="4" checksum="1250202632"/>
<version ClassVersion="5" checksum="2230390721"/>
</class>
<version ClassVersion="6" checksum="2815634332"/>
</class>

<!-- Adding ioread rules for backwards compatibility -->

<ioread sourceClass="Run3ScoutingElectron" version="[3-5]"
source="float d0_;"
targetClass="Run3ScoutingElectron" target="trkd0_">
<![CDATA[
trkd0_.clear();
Copy link
Contributor

@makortel makortel Mar 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused why this clear() is needed (but I acknowledge the evidence #41025 (comment), #41025 (comment)). @pcanal Could you comment if from ROOT point of view this clear() serves a purpose, or if the need for one is a sign of something else going on?

Copy link
Contributor

@pcanal pcanal Mar 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since trkd0 is a 'new' data member, when reading back an old version on of the object, this data member will be untouched. So indeed the clear is necessary to insure that the vector contains only new data. Note that if more than one rule want to put elements in the vector, the clear should (of course) be called only in the 'first' rule to be executed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pcanal for the explanation. If the change would keep the member variable name the same instead (i.e. float d0_ -> std::vector<float> d0_), the rule would be along (right?)

source="float d0_"
target="d0_"

then the d0_.clear() would not be needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure the clear would still be needed if one were using the 'recommended' way of reading back data which has one reusing the same object over and over. cmsRun doesn't do that and instead forcibly creates a new object for each event.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

. If the change would keep the member variable name the same
then the d0_.clear() would not be needed?

Actually yes (the in-memory version of d0_ would also be untouched by the I/0 in that case).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. In the end it is probably cleaner to keep the io rule as it is.

trkd0_.push_back(onfile.d0_);]]>
</ioread>

<ioread sourceClass="Run3ScoutingElectron" version="[3-5]"
source="float dz_;"
targetClass="Run3ScoutingElectron" target="trkdz_">
<![CDATA[
trkdz_.clear();
trkdz_.push_back(onfile.dz_);]]>
</ioread>

<ioread sourceClass="Run3ScoutingElectron" version="[3-5]"
source="int charge_;"
targetClass="Run3ScoutingElectron" target="trkcharge_">
<![CDATA[
trkcharge_.clear();
trkcharge_.push_back(onfile.charge_);]]>
</ioread>

<class name="Run3ScoutingMuon" ClassVersion="4">
<version ClassVersion="3" checksum="3882497397"/>
<version ClassVersion="4" checksum="4206297195"/>
Expand Down
42 changes: 32 additions & 10 deletions HLTrigger/Egamma/plugins/HLTScoutingEgammaProducer.cc
Expand Up @@ -273,21 +273,39 @@ void HLTScoutingEgammaProducer::produce(edm::StreamID sid, edm::Event& iEvent, e
continue;
}

float d0 = 0.0;
float dz = 0.0;
int charge = -999;
unsigned int const maxTrkSize = EgammaGsfTrackCollection->size();
std::vector<float> trkd0;
std::vector<float> trkdz;
std::vector<float> trkpt;
std::vector<float> trketa;
std::vector<float> trkphi;
std::vector<float> trkchi2overndf;
std::vector<int> trkcharge;
trkd0.reserve(maxTrkSize);
trkdz.reserve(maxTrkSize);
trkpt.reserve(maxTrkSize);
trketa.reserve(maxTrkSize);
trkphi.reserve(maxTrkSize);
trkchi2overndf.reserve(maxTrkSize);
trkcharge.reserve(maxTrkSize);

for (auto& track : *EgammaGsfTrackCollection) {
RefToBase<TrajectorySeed> seed = track.extra()->seedRef();
reco::ElectronSeedRef elseed = seed.castTo<reco::ElectronSeedRef>();
RefToBase<reco::CaloCluster> caloCluster = elseed->caloCluster();
reco::SuperClusterRef scRefFromTrk = caloCluster.castTo<reco::SuperClusterRef>();
if (scRefFromTrk == scRef) {
d0 = track.d0();
dz = track.dz();
charge = track.charge();
trkd0.push_back(track.d0());
trkdz.push_back(track.dz());
trkpt.push_back(track.pt());
trketa.push_back(track.eta());
trkphi.push_back(track.phi());
auto const trackndof = track.ndof();
trkchi2overndf.push_back(((trackndof == 0) ? -1 : (track.chi2() / trackndof)));
trkcharge.push_back(track.charge());
}
}
arsahasransu marked this conversation as resolved.
Show resolved Hide resolved
if (charge == -999) { // No associated track. Candidate is a scouting photon
if (trkcharge.empty()) { // No associated track. Candidate is a scouting photon
outPhotons->emplace_back(candidate.pt(),
candidate.eta(),
candidate.phi(),
Expand All @@ -310,15 +328,19 @@ void HLTScoutingEgammaProducer::produce(edm::StreamID sid, edm::Event& iEvent, e
candidate.eta(),
candidate.phi(),
candidate.mass(),
d0,
dz,
trkd0,
trkdz,
trkpt,
trketa,
trkphi,
trkchi2overndf,
(*DetaMap)[candidateRef],
(*DphiMap)[candidateRef],
(*SigmaIEtaIEtaMap)[candidateRef],
HoE,
(*OneOEMinusOneOPMap)[candidateRef],
(*MissingHitsMap)[candidateRef],
charge,
trkcharge,
(*EcalPFClusterIsoMap)[candidateRef],
(*HcalPFClusterIsoMap)[candidateRef],
(*EleGsfTrackIsoMap)[candidateRef],
Expand Down