Skip to content

Commit ba7797e

Browse files
authored
Merge pull request cms-sw#32673 from kpedro88/dev-finecalo_CMSSW_11_3_X_2021-01-15-1100
finecalo patches v1 (rebased)
2 parents 39c47ca + 708f9ee commit ba7797e

File tree

25 files changed

+557
-128
lines changed

25 files changed

+557
-128
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import FWCore.ParameterSet.Config as cms
2+
3+
fineCalo = cms.Modifier()

SimCalorimetry/EcalElectronicsEmulation/src/EcalSimpleProducer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void EcalSimpleProducer::produce(edm::Event &evt, const edm::EventSetup &) {
8686
double em = simHitFormula_->Eval(iEta0, iPhi0, ievt - 1);
8787
double eh = 0.;
8888
double t = 0.;
89-
const PCaloHit hit(EBDetId(iEta1, iPhi).rawId(), em, eh, t, 0);
89+
const PCaloHit hit(EBDetId(iEta1, iPhi).rawId(), em, eh, t, 0, 0);
9090
hits->push_back(hit);
9191
}
9292
}

SimDataFormats/CaloHit/src/PCaloHit.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
PCaloHit::PCaloHit(float eEM, float eHad, float t, int i, uint16_t d) : myTime(t), myItra(i), myDepth(d) {
55
myEnergy = eEM + eHad;
6-
myEMFraction = (myEnergy <= 0. ? 1. : eEM / myEnergy);
6+
myEMFraction = (myEnergy <= 0.f ? 1.f : eEM / myEnergy);
77
}
88

99
PCaloHit::PCaloHit(unsigned int id, float eEM, float eHad, float t, int i, uint16_t d)
1010
: myTime(t), myItra(i), detId(id), myDepth(d) {
1111
myEnergy = eEM + eHad;
12-
myEMFraction = (myEnergy <= 0. ? 1. : eEM / myEnergy);
12+
myEMFraction = (myEnergy <= 0.f ? 1.f : eEM / myEnergy);
1313
}
1414

1515
std::ostream& operator<<(std::ostream& o, const PCaloHit& hit) {

SimDataFormats/Track/interface/SimTrack.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#define SimTrack_H
33

44
#include "SimDataFormats/Track/interface/CoreSimTrack.h"
5+
#include "DataFormats/Math/interface/Vector3D.h"
6+
#include "DataFormats/Math/interface/LorentzVector.h"
7+
#include "FWCore/Utilities/interface/Exception.h"
58

69
class SimTrack : public CoreSimTrack {
710
public:
@@ -44,12 +47,31 @@ class SimTrack : public CoreSimTrack {
4447

4548
inline void setVertexIndex(const int v) { ivert = v; }
4649

50+
void setCrossedBoundaryVars(bool crossedBoundary,
51+
int idAtBoundary,
52+
math::XYZTLorentzVectorF positionAtBoundary,
53+
math::XYZTLorentzVectorF momentumAtBoundary) {
54+
crossedBoundary_ = crossedBoundary;
55+
idAtBoundary_ = idAtBoundary;
56+
positionAtBoundary_ = positionAtBoundary;
57+
momentumAtBoundary_ = momentumAtBoundary;
58+
}
59+
bool crossedBoundary() const { return crossedBoundary_; }
60+
const math::XYZTLorentzVectorF& getPositionAtBoundary() const { return positionAtBoundary_; }
61+
const math::XYZTLorentzVectorF& getMomentumAtBoundary() const { return momentumAtBoundary_; }
62+
int getIDAtBoundary() const { return idAtBoundary_; }
63+
4764
private:
4865
int ivert;
4966
int igenpart;
5067

5168
math::XYZVectorD tkposition;
5269
math::XYZTLorentzVectorD tkmomentum;
70+
71+
bool crossedBoundary_;
72+
int idAtBoundary_;
73+
math::XYZTLorentzVectorF positionAtBoundary_;
74+
math::XYZTLorentzVectorF momentumAtBoundary_;
5375
};
5476

5577
#include <iosfwd>

SimDataFormats/Track/src/SimTrack.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
#include "SimDataFormats/Track/interface/SimTrack.h"
22

3-
SimTrack::SimTrack() : ivert(-1), igenpart(-1) {}
3+
SimTrack::SimTrack() : ivert(-1), igenpart(-1), crossedBoundary_(false) {}
44

5-
SimTrack::SimTrack(int ipart, const math::XYZTLorentzVectorD& p) : Core(ipart, p), ivert(-1), igenpart(-1) {}
5+
SimTrack::SimTrack(int ipart, const math::XYZTLorentzVectorD& p)
6+
: Core(ipart, p), ivert(-1), igenpart(-1), crossedBoundary_(false) {}
67

78
SimTrack::SimTrack(int ipart, const math::XYZTLorentzVectorD& p, int iv, int ig)
8-
: Core(ipart, p), ivert(iv), igenpart(ig) {}
9+
: Core(ipart, p), ivert(iv), igenpart(ig), crossedBoundary_(false) {}
910

1011
SimTrack::SimTrack(int ipart,
1112
const math::XYZTLorentzVectorD& p,
1213
int iv,
1314
int ig,
1415
const math::XYZVectorD& tkp,
1516
const math::XYZTLorentzVectorD& tkm)
16-
: Core(ipart, p), ivert(iv), igenpart(ig), tkposition(tkp), tkmomentum(tkm) {}
17+
: Core(ipart, p), ivert(iv), igenpart(ig), tkposition(tkp), tkmomentum(tkm), crossedBoundary_(false) {}
1718

18-
SimTrack::SimTrack(const CoreSimTrack& t, int iv, int ig) : Core(t), ivert(iv), igenpart(ig) {}
19+
SimTrack::SimTrack(const CoreSimTrack& t, int iv, int ig) : Core(t), ivert(iv), igenpart(ig), crossedBoundary_(false) {}
1920

2021
std::ostream& operator<<(std::ostream& o, const SimTrack& t) {
2122
return o << (SimTrack::Core)(t) << ", " << t.vertIndex() << ", " << t.genpartIndex();

SimDataFormats/Track/src/classes_def.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<class name="CoreSimTrack" ClassVersion="10">
55
<version ClassVersion="10" checksum="3936841839"/>
66
</class>
7-
<class name="SimTrack" ClassVersion="11">
7+
<class name="SimTrack" ClassVersion="12">
8+
<version ClassVersion="12" checksum="3470347245"/>
89
<version ClassVersion="11" checksum="1785575744"/>
910
<version ClassVersion="10" checksum="1430205451"/>
1011
</class>

SimG4CMS/Calo/interface/CaloG4Hit.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class CaloG4Hit : public G4VHit {
6262
void setIncidentEnergy(double e) { theIncidentEnergy = e; }
6363

6464
int getTrackID() const { return hitID.trackID(); }
65+
6566
uint32_t getUnitID() const { return hitID.unitID(); }
6667
double getTimeSlice() const { return hitID.timeSlice(); }
6768
int getTimeSliceID() const { return hitID.timeSliceID(); }
@@ -97,6 +98,8 @@ class CaloG4HitLess {
9798
return (a->getUnitID() < b->getUnitID());
9899
} else if (a->getDepth() != b->getDepth()) {
99100
return (a->getDepth() < b->getDepth());
101+
} else if (a->getID().fineTrackID() != b->getID().fineTrackID()) {
102+
return (a->getID().fineTrackID() < b->getID().fineTrackID());
100103
} else {
101104
return (a->getTimeSliceID() < b->getTimeSliceID());
102105
}
@@ -107,7 +110,7 @@ class CaloG4HitEqual {
107110
public:
108111
bool operator()(const CaloG4Hit* a, const CaloG4Hit* b) {
109112
return (a->getTrackID() == b->getTrackID() && a->getUnitID() == b->getUnitID() && a->getDepth() == b->getDepth() &&
110-
a->getTimeSliceID() == b->getTimeSliceID());
113+
a->getTimeSliceID() == b->getTimeSliceID() && a->getID().fineTrackID() == b->getID().fineTrackID());
111114
}
112115
};
113116

SimG4CMS/Calo/interface/CaloHitID.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class CaloHitID {
2525
void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth = 0);
2626
void reset();
2727

28+
void setTrackID(int trackID) { theTrackID = trackID; }
29+
bool hasFineTrackID() const { return theFineTrackID != -1; }
30+
void setFineTrackID(int fineTrackID) { theFineTrackID = fineTrackID; }
31+
int fineTrackID() const { return hasFineTrackID() ? theFineTrackID : theTrackID; }
32+
2833
bool operator==(const CaloHitID&) const;
2934
bool operator<(const CaloHitID&) const;
3035
bool operator>(const CaloHitID&) const;
@@ -37,6 +42,7 @@ class CaloHitID {
3742
uint16_t theDepth;
3843
float timeSliceUnit;
3944
bool ignoreTrackID;
45+
int theFineTrackID;
4046
};
4147

4248
std::ostream& operator<<(std::ostream&, const CaloHitID&);

SimG4CMS/Calo/interface/CaloSD.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ class CaloSD : public SensitiveCaloDetector,
8484
void resetForNewPrimary(const G4Step*);
8585
double getAttenuation(const G4Step* aStep, double birk1, double birk2, double birk3) const;
8686

87+
static std::string printableDecayChain(const std::vector<unsigned int>& decayChain);
88+
void hitBookkeepingFineCalo(const G4Step* step, const G4Track* currentTrack, CaloG4Hit* hit);
89+
8790
void update(const BeginOfRun*) override;
8891
void update(const BeginOfEvent*) override;
8992
void update(const BeginOfTrack* trk) override;
@@ -174,7 +177,8 @@ class CaloSD : public SensitiveCaloDetector,
174177
float timeSlice;
175178
double eminHitD;
176179
double correctT;
177-
bool useFineCaloID_;
180+
bool doFineCalo_;
181+
double eMinFine_;
178182

179183
std::map<CaloHitID, CaloG4Hit*> hitMap;
180184
std::map<int, TrackWithHistory*> tkMap;

SimG4CMS/Calo/interface/CaloTrkProcessing.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "FWCore/MessageLogger/interface/MessageLogger.h"
88

99
#include "G4VTouchable.hh"
10+
#include "G4Track.hh"
11+
#include "DataFormats/Math/interface/LorentzVector.h"
1012

1113
#include <map>
1214
#include <vector>
@@ -58,7 +60,7 @@ class CaloTrkProcessing : public SensitiveCaloDetector,
5860
void detectorLevel(const G4VTouchable*, int&, int*, G4String*) const;
5961

6062
bool testBeam_, putHistory_, doFineCalo_;
61-
double eMin_, eMinFine_, eMinFinePhoton_;
63+
double eMin_, eMinFine_;
6264
int lastTrackID_;
6365
std::vector<Detector> detectors_, fineDetectors_;
6466
};

0 commit comments

Comments
 (0)