CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
HFNoseSD Class Reference

#include <HFNoseSD.h>

Inheritance diagram for HFNoseSD:
CaloSD Observer< const BeginOfJob *> SensitiveCaloDetector Observer< const BeginOfRun *> Observer< const BeginOfEvent *> Observer< const BeginOfTrack *> Observer< const EndOfTrack *> Observer< const EndOfEvent *> SensitiveDetector

Public Member Functions

 HFNoseSD (const std::string &, const HGCalDDDConstants *, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
 
uint32_t setDetUnitId (const G4Step *step) override
 
 ~HFNoseSD () override=default
 
- Public Member Functions inherited from CaloSD
 CaloSD (const std::string &aSDname, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, float timeSlice=1., bool ignoreTkID=false, const std::string &newcolname="")
 
void clear () override
 
void clearHits () override
 
void DrawAll () override
 
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
void fillHits (edm::PCaloHitContainer &, const std::string &) override
 
void Initialize (G4HCofThisEvent *HCE) override
 
bool isItFineCalo (const G4VTouchable *touch)
 
void newCollection (const std::string &name, edm::ParameterSet const &p)
 
void PrintAll () override
 
G4bool ProcessHits (G4Step *step, G4TouchableHistory *) override
 
bool ProcessHits (G4GFlashSpot *aSpot, G4TouchableHistory *) override
 
void reset () override
 
 ~CaloSD () override
 
- Public Member Functions inherited from SensitiveCaloDetector
 SensitiveCaloDetector (const std::string &iname, const SensitiveDetectorCatalog &clg, const std::string &newcollname="")
 
- Public Member Functions inherited from SensitiveDetector
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
const std::vector< std::string > & getNames () const
 
void Initialize (G4HCofThisEvent *eventHC) override
 
bool isCaloSD () const
 
 SensitiveDetector (const std::string &iname, const SensitiveDetectorCatalog &, bool calo, const std::string &newcollname="")
 
 ~SensitiveDetector () override
 
- Public Member Functions inherited from Observer< const BeginOfRun *>
 Observer ()
 
void slotForUpdate (const BeginOfRun * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfEvent *>
 Observer ()
 
void slotForUpdate (const BeginOfEvent * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfTrack *>
 Observer ()
 
void slotForUpdate (const BeginOfTrack * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfTrack *>
 Observer ()
 
void slotForUpdate (const EndOfTrack * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfEvent *>
 Observer ()
 
void slotForUpdate (const EndOfEvent * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfJob *>
 Observer ()
 
void slotForUpdate (const BeginOfJob * iT)
 
virtual ~Observer ()
 

Protected Member Functions

bool filterHit (CaloG4Hit *, double) override
 
double getEnergyDeposit (const G4Step *) override
 
void initRun () override
 
void update (const BeginOfTrack *trk) override
 
void update (const ::EndOfEvent *) override
 
void update (const BeginOfRun *) override
 
void update (const EndOfTrack *trk) override
 
void update (const BeginOfEvent *) override
 
void update (const BeginOfJob *) override
 This routine will be called when the appropriate signal arrives. More...
 
- Protected Member Functions inherited from CaloSD
bool checkHit (int k=0)
 
CaloG4HitcreateNewHit (const G4Step *, const G4Track *, int k)
 
virtual void endEvent ()
 
virtual double EnergyCorrected (const G4Step &step, const G4Track *)
 
unsigned int findBoundaryCrossingParent (const G4Track *track, bool markParentAsSaveable=true)
 
double getAttenuation (const G4Step *aStep, double birk1, double birk2, double birk3) const
 
virtual uint16_t getDepth (const G4Step *)
 
virtual bool getFromLibrary (const G4Step *step)
 
int getNumberOfHits (int k=0)
 
double getResponseWt (const G4Track *, int k=0)
 
virtual int getTrackID (const G4Track *)
 
bool hitExists (const G4Step *, int k)
 
void ignoreRejection ()
 
virtual void initEvent (const BeginOfEvent *)
 
void printDetectorLevels (const G4VTouchable *) const
 
void processHit (const G4Step *step)
 
virtual void processSecondHit (const G4Step *, const G4Track *)
 
void resetForNewPrimary (const G4Step *)
 
void setNumberCheckedHits (int val, int k=0)
 
void setParameterized (bool val)
 
G4ThreeVector setToGlobal (const G4ThreeVector &, const G4VTouchable *) const
 
G4ThreeVector setToLocal (const G4ThreeVector &, const G4VTouchable *) const
 
virtual int setTrackID (const G4Step *)
 
void setUseMap (bool val)
 
std::string shortreprID (const CaloHitID &ID)
 
std::string shortreprID (const CaloG4Hit *hit)
 
void update (const BeginOfRun *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfEvent *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfTrack *trk) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfTrack *trk) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const ::EndOfEvent *) override
 
void updateHit (CaloG4Hit *, int k)
 
- Protected Member Functions inherited from SensitiveDetector
TrackInformationcmsTrackInformation (const G4Track *aTrack)
 
Local3DPoint ConvertToLocal3DPoint (const G4ThreeVector &point) const
 
Local3DPoint FinalStepPosition (const G4Step *step, coordinates) const
 
Local3DPoint InitialStepPosition (const G4Step *step, coordinates) const
 
Local3DPoint LocalPostStepPosition (const G4Step *step) const
 
Local3DPoint LocalPreStepPosition (const G4Step *step) const
 
void NaNTrap (const G4Step *step) const
 
void setNames (const std::vector< std::string > &)
 
- Protected Member Functions inherited from Observer< const EndOfEvent *>
virtual void update (const EndOfEvent *)=0
 This routine will be called when the appropriate signal arrives. More...
 

Private Member Functions

bool isItinFidVolume (const G4ThreeVector &)
 
uint32_t setDetUnitId (int, int, int, int, G4ThreeVector &)
 

Private Attributes

std::vector< double > angles_
 
bool checkID_
 
int cornerMinMask_
 
double distanceFromEdge_
 
double eminHit_
 
bool fiducialCut_
 
HGCalGeometryMode::GeometryMode geom_mode_
 
std::unique_ptr< HGCGuardRingguardRing_
 
const HGCalDDDConstantshgcons_
 
int levelT1_
 
int levelT2_
 
std::unique_ptr< HGCMouseBitemouseBite_
 
double mouseBiteCut_
 
std::string nameX_
 
std::unique_ptr< HFNoseNumberingSchemenumberingScheme_
 
bool rejectMB_
 
double slopeMin_
 
bool storeAllG4Hits_
 
const double tan30deg_
 
int useSimWt_
 
int verbose_
 
bool waferRot_
 
double weight_
 

Additional Inherited Members

- Protected Types inherited from SensitiveDetector
enum  coordinates { WorldCoordinates, LocalCoordinates }
 
- Static Protected Member Functions inherited from CaloSD
static std::string printableDecayChain (const std::vector< unsigned int > &decayChain)
 
- Protected Attributes inherited from CaloSD
std::string collName_ [2]
 
CaloG4HitcurrentHit [2]
 
CaloHitID currentID [2]
 
std::string detName_
 
float edepositEM
 
float edepositHAD
 
double eminHit
 
double energyCut
 
G4ThreeVector entranceLocal
 
G4ThreeVector entrancePoint
 
bool forceSave
 
std::vector< std::string > hcn_
 
float incidentEnergy
 
double kmaxIon
 
double kmaxNeutron
 
double kmaxProton
 
int nHC_
 
G4ThreeVector posGlobal
 
CaloHitID previousID [2]
 
bool suppressHeavy
 
double tmaxHit
 
std::vector< int > useResMap_
 

Detailed Description

Definition at line 21 of file HFNoseSD.h.

Constructor & Destructor Documentation

◆ HFNoseSD()

HFNoseSD::HFNoseSD ( const std::string &  name,
const HGCalDDDConstants hgc,
const SensitiveDetectorCatalog clg,
edm::ParameterSet const &  p,
const SimTrackManager manager 
)

Definition at line 27 of file HFNoseSD.cc.

References angles_, cornerMinMask_, distanceFromEdge_, eminHit_, fiducialCut_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), guardRing_, mouseBite_, Skims_PA_cff::name, nameX_, numberingScheme_, AlCaHLTBitMon_ParallelJobs::p, rejectMB_, CaloSD::setNumberCheckedHits(), CaloSD::setUseMap(), storeAllG4Hits_, and waferRot_.

32  : CaloSD(name,
33  clg,
34  p,
35  manager,
36  (float)(p.getParameter<edm::ParameterSet>("HFNoseSD").getParameter<double>("TimeSliceUnit")),
37  p.getParameter<edm::ParameterSet>("HFNoseSD").getParameter<bool>("IgnoreTrackID")),
38  hgcons_(hgc),
39  slopeMin_(0),
40  levelT1_(99),
41  levelT2_(99),
42  useSimWt_(0),
43  tan30deg_(std::tan(30.0 * CLHEP::deg)) {
44  numberingScheme_.reset(nullptr);
45  guardRing_.reset(nullptr);
46  mouseBite_.reset(nullptr);
47 
48  edm::ParameterSet m_HFN = p.getParameter<edm::ParameterSet>("HFNoseSD");
49  eminHit_ = m_HFN.getParameter<double>("EminHit") * CLHEP::MeV;
50  fiducialCut_ = m_HFN.getParameter<bool>("FiducialCut");
51  distanceFromEdge_ = m_HFN.getParameter<double>("DistanceFromEdge");
52  storeAllG4Hits_ = m_HFN.getParameter<bool>("StoreAllG4Hits");
53  rejectMB_ = m_HFN.getParameter<bool>("RejectMouseBite");
54  waferRot_ = m_HFN.getParameter<bool>("RotatedWafer");
55  cornerMinMask_ = m_HFN.getParameter<int>("CornerMinMask");
56  angles_ = m_HFN.getUntrackedParameter<std::vector<double>>("WaferAngles");
57 
58  nameX_ = ((name.find("HFNoseHits") != std::string::npos) ? "HGCalHFNoseSensitive" : "HFNoseSensitive");
59 
60  if (storeAllG4Hits_) {
61  setUseMap(false);
63  }
64 
65 #ifdef EDM_ML_DEBUG
66  edm::LogVerbatim("HFNSim") << "**************************************************"
67  << "\n"
68  << "* *"
69  << "\n"
70  << "* Constructing a HFNoseSD with name " << name << "\n"
71  << "* *"
72  << "\n"
73  << "**************************************************";
74 #endif
75  edm::LogVerbatim("HFNSim") << "HFNoseSD:: Threshold for storing hits: " << eminHit_ << " for " << name;
76  edm::LogVerbatim("HFNSim") << "Flag for storing individual Geant4 Hits " << storeAllG4Hits_;
77  edm::LogVerbatim("HFNSim") << "Fiducial volume cut with cut from eta/phi "
78  << "boundary " << fiducialCut_ << " at " << distanceFromEdge_;
79  edm::LogVerbatim("HFNSim") << "Reject MosueBite Flag: " << rejectMB_ << " cuts along " << angles_.size()
80  << " axes: " << angles_[0] << ", " << angles_[1];
81 }
Log< level::Info, true > LogVerbatim
double eminHit_
Definition: HFNoseSD.h:49
std::unique_ptr< HFNoseNumberingScheme > numberingScheme_
Definition: HFNoseSD.h:44
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
int cornerMinMask_
Definition: HFNoseSD.h:51
void setNumberCheckedHits(int val, int k=0)
Definition: CaloSD.h:126
bool storeAllG4Hits_
Definition: HFNoseSD.h:52
int levelT1_
Definition: HFNoseSD.h:51
bool fiducialCut_
Definition: HFNoseSD.h:53
double distanceFromEdge_
Definition: HFNoseSD.h:50
bool rejectMB_
Definition: HFNoseSD.h:53
void setUseMap(bool val)
Definition: CaloSD.h:115
bool waferRot_
Definition: HFNoseSD.h:53
T getUntrackedParameter(std::string const &, T const &) const
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
const double tan30deg_
Definition: HFNoseSD.h:55
int useSimWt_
Definition: HFNoseSD.h:54
CaloSD(const std::string &aSDname, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, float timeSlice=1., bool ignoreTkID=false, const std::string &newcolname="")
Definition: CaloSD.cc:34
int levelT2_
Definition: HFNoseSD.h:51
const HGCalDDDConstants * hgcons_
Definition: HFNoseSD.h:43
std::string nameX_
Definition: HFNoseSD.h:47
std::unique_ptr< HGCMouseBite > mouseBite_
Definition: HFNoseSD.h:46
std::unique_ptr< HGCGuardRing > guardRing_
Definition: HFNoseSD.h:45
std::vector< double > angles_
Definition: HFNoseSD.h:56
double slopeMin_
Definition: HFNoseSD.h:49

◆ ~HFNoseSD()

HFNoseSD::~HFNoseSD ( )
overridedefault

Member Function Documentation

◆ filterHit()

bool HFNoseSD::filterHit ( CaloG4Hit aHit,
double  time 
)
overrideprotectedvirtual

Reimplemented from CaloSD.

Definition at line 199 of file HFNoseSD.cc.

References eminHit_, CaloG4Hit::getEnergyDeposit(), hcalRecHitTable_cff::time, and CaloSD::tmaxHit.

199  {
200  return ((time <= tmaxHit) && (aHit->getEnergyDeposit() > eminHit_));
201 }
double eminHit_
Definition: HFNoseSD.h:49
double tmaxHit
Definition: CaloSD.h:148
double getEnergyDeposit() const
Definition: CaloG4Hit.h:79

◆ getEnergyDeposit()

double HFNoseSD::getEnergyDeposit ( const G4Step *  aStep)
overrideprotectedvirtual

Reimplemented from CaloSD.

Definition at line 83 of file HFNoseSD.cc.

References funct::abs(), CaloSD::getResponseWt(), alignCSCRings::r, slopeMin_, weight_, and z.

83  {
84  double r = aStep->GetPreStepPoint()->GetPosition().perp();
85  double z = std::abs(aStep->GetPreStepPoint()->GetPosition().z());
86 #ifdef EDM_ML_DEBUG
87  G4int parCode = aStep->GetTrack()->GetDefinition()->GetPDGEncoding();
88  G4String parName = aStep->GetTrack()->GetDefinition()->GetParticleName();
89  G4LogicalVolume* lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
90  edm::LogVerbatim("HFNSim") << "HFNoseSD: Hit from standard path from " << lv->GetName() << " for Track "
91  << aStep->GetTrack()->GetTrackID() << " (" << parCode << ":" << parName << ") R = " << r
92  << " Z = " << z << " slope = " << r / z << ":" << slopeMin_;
93 #endif
94  // Apply fiducial cut
95  if (r < z * slopeMin_) {
96 #ifdef EDM_ML_DEBUG
97  edm::LogVerbatim("HFNSim") << "HFNoseSD: Fiducial Volume cut";
98 #endif
99  return 0.0;
100  }
101 
102  double wt1 = getResponseWt(aStep->GetTrack());
103  double wt2 = aStep->GetTrack()->GetWeight();
104  double destep = weight_ * wt1 * (aStep->GetTotalEnergyDeposit());
105  if (wt2 > 0)
106  destep *= wt2;
107 #ifdef EDM_ML_DEBUG
108  edm::LogVerbatim("HFNSim") << "HFNoseSD: weights= " << weight_ << ":" << wt1 << ":" << wt2 << " Total weight "
109  << weight_ * wt1 * wt2 << " deStep: " << aStep->GetTotalEnergyDeposit() << ":" << destep;
110 #endif
111  return destep;
112 }
Log< level::Info, true > LogVerbatim
double weight_
Definition: HFNoseSD.h:49
double getResponseWt(const G4Track *, int k=0)
Definition: CaloSD.cc:929
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double slopeMin_
Definition: HFNoseSD.h:49

◆ initRun()

void HFNoseSD::initRun ( )
overrideprotectedvirtual

Reimplemented from CaloSD.

Definition at line 197 of file HFNoseSD.cc.

197 {}

◆ isItinFidVolume()

bool HFNoseSD::isItinFidVolume ( const G4ThreeVector &  pos)
private

Definition at line 212 of file HFNoseSD.cc.

References distanceFromEdge_, HGCalDDDConstants::distFromEdgeHex(), fiducialCut_, and hgcons_.

212  {
213  if (fiducialCut_) {
214  return (hgcons_->distFromEdgeHex(pos.x(), pos.y(), pos.z()) > distanceFromEdge_);
215  } else {
216  return true;
217  }
218 }
bool fiducialCut_
Definition: HFNoseSD.h:53
double distanceFromEdge_
Definition: HFNoseSD.h:50
const HGCalDDDConstants * hgcons_
Definition: HFNoseSD.h:43
double distFromEdgeHex(double x, double y, double z) const

◆ setDetUnitId() [1/2]

uint32_t HFNoseSD::setDetUnitId ( const G4Step *  step)
overridevirtual

Implements CaloSD.

Definition at line 114 of file HFNoseSD.cc.

References TauDecayModes::dec, fiducialCut_, l1ctLayer2EG_cff::id, nano_mu_digi_cff::layer, levelT1_, levelT2_, mouseBite_, rejectMB_, useSimWt_, and HFNoseDetId::waferUV().

114  {
115  const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
116  const G4VTouchable* touch = preStepPoint->GetTouchable();
117 
118  //determine the exact position in global coordinates in the mass geometry
119  G4ThreeVector hitPoint = preStepPoint->GetPosition();
120  float globalZ = touch->GetTranslation(0).z();
121  int iz(globalZ > 0 ? 1 : -1);
122 
123  int layer(-1), moduleLev(-1), cell(-1);
124  if (useSimWt_ > 0) {
125  layer = touch->GetReplicaNumber(2);
126  moduleLev = 1;
127  } else if ((touch->GetHistoryDepth() == levelT1_) || (touch->GetHistoryDepth() == levelT2_)) {
128  layer = touch->GetReplicaNumber(0);
129  } else {
130  layer = touch->GetReplicaNumber(3);
131  cell = touch->GetReplicaNumber(1);
132  moduleLev = 2;
133  }
134  int module = (moduleLev >= 0) ? touch->GetReplicaNumber(moduleLev) : -1;
135 #ifdef EDM_ML_DEBUG
136  edm::LogVerbatim("HFNSim") << "DepthsInside: " << touch->GetHistoryDepth() << " name "
137  << touch->GetVolume(0)->GetName() << " layer:module:cell " << layer << ":" << moduleLev
138  << ":" << module << ":" << cell;
139  G4Material* mat = aStep->GetPreStepPoint()->GetMaterial();
140  edm::LogVerbatim("HFNSim") << "Depths: " << touch->GetHistoryDepth() << " name " << touch->GetVolume(0)->GetName()
141  << ":" << touch->GetReplicaNumber(0) << " " << touch->GetVolume(1)->GetName() << ":"
142  << touch->GetReplicaNumber(1) << " " << touch->GetVolume(2)->GetName() << ":"
143  << touch->GetReplicaNumber(2) << " " << touch->GetVolume(3)->GetName() << ":"
144  << touch->GetReplicaNumber(3) << " " << touch->GetVolume(4)->GetName() << ":"
145  << touch->GetReplicaNumber(4) << " "
146  << " layer:module:cell " << layer << ":" << module << ":" << cell << " Material "
147  << mat->GetName() << ":" << mat->GetRadlen();
148 #endif
149  // The following statement should be examined later before elimination
150  if (aStep->GetPreStepPoint()->GetMaterial()->GetRadlen() > 100000.)
151  return 0;
152 
153  uint32_t id = setDetUnitId(layer, module, cell, iz, hitPoint);
154  if ((rejectMB_ || fiducialCut_) && id != 0) {
155  auto uv = HFNoseDetId(id).waferUV();
156 #ifdef EDM_ML_DEBUG
157  edm::LogVerbatim("HFNSim") << "ID " << std::hex << id << std::dec << " " << HFNoseDetId(id);
158 #endif
159  if ((rejectMB_) && (mouseBite_->exclude(hitPoint, iz, layer, uv.first, uv.second))) {
160  id = 0;
161 #ifdef EDM_ML_DEBUG
162  edm::LogVerbatim("HFNSim") << "Rejected by MouseBite cutoff *****";
163 #endif
164  }
165  }
166  return id;
167 }
Log< level::Info, true > LogVerbatim
int levelT1_
Definition: HFNoseSD.h:51
bool fiducialCut_
Definition: HFNoseSD.h:53
uint32_t setDetUnitId(const G4Step *step) override
Definition: HFNoseSD.cc:114
bool rejectMB_
Definition: HFNoseSD.h:53
std::pair< int, int > waferUV() const
Definition: HFNoseDetId.h:82
int useSimWt_
Definition: HFNoseSD.h:54
int levelT2_
Definition: HFNoseSD.h:51
std::unique_ptr< HGCMouseBite > mouseBite_
Definition: HFNoseSD.h:46

◆ setDetUnitId() [2/2]

uint32_t HFNoseSD::setDetUnitId ( int  layer,
int  module,
int  cell,
int  iz,
G4ThreeVector &  pos 
)
private

Definition at line 203 of file HFNoseSD.cc.

References cornerMinMask_, hgcons_, l1ctLayer2EG_cff::id, nano_mu_digi_cff::layer, HGCalDDDConstants::maskCell(), numberingScheme_, and weight_.

203  {
204  uint32_t id = numberingScheme_ ? numberingScheme_->getUnitID(layer, module, cell, iz, pos, weight_) : 0;
205  if (cornerMinMask_ > 2) {
207  id = 0;
208  }
209  return id;
210 }
bool maskCell(const DetId &id, int corners) const
std::unique_ptr< HFNoseNumberingScheme > numberingScheme_
Definition: HFNoseSD.h:44
int cornerMinMask_
Definition: HFNoseSD.h:51
double weight_
Definition: HFNoseSD.h:49
Definition: DetId.h:17
const HGCalDDDConstants * hgcons_
Definition: HFNoseSD.h:43

◆ update() [1/6]

void CaloSD::update
overrideprotected

Definition at line 752 of file CaloSD.cc.

Referenced by MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), and MatrixUtil.Steps::overwrite().

752  {
753 #ifdef EDM_ML_DEBUG
754  edm::LogVerbatim("CaloSim") << "CaloSD: Dispatched BeginOfEvent for " << GetName() << " !";
755 #endif
756  clearHits();
757  initEvent(g4Event);
758 }
Log< level::Info, true > LogVerbatim
virtual void initEvent(const BeginOfEvent *)
Definition: CaloSD.cc:870
void clearHits() override
Definition: CaloSD.cc:849

◆ update() [2/6]

void CaloSD::update
overrideprotected

Definition at line 781 of file CaloSD.cc.

Referenced by MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), and MatrixUtil.Steps::overwrite().

781  {
782  endEvent();
783  for (int k = 0; k < nHC_; ++k) {
784  slave[k].get()->ReserveMemory(theHC[k]->entries());
785 
786  int count(0);
787  double eEM(0.0);
788  double eHAD(0.0);
789  double eEM2(0.0);
790  double eHAD2(0.0);
791 #ifdef EDM_ML_DEBUG
792  int wrong(0);
793  double tt(0.0);
794  double zloc(0.0);
795  double zglob(0.0);
796  double ee(0.0);
797 #endif
798  int hc_entries = theHC[k]->entries();
799  for (int i = 0; i < hc_entries; ++i) {
800 #ifdef EDM_ML_DEBUG
801  if (!saveHit((*theHC[k])[i], k)) {
802  ++wrong;
803  }
804 #else
805  saveHit((*theHC[k])[i], k);
806 #endif
807 
808  ++count;
809  double x = (*theHC[k])[i]->getEM();
810  eEM += x;
811  eEM2 += x * x;
812  x = (*theHC[k])[i]->getHadr();
813  eHAD += x;
814  eHAD2 += x * x;
815 #ifdef EDM_ML_DEBUG
816  tt += (*theHC[k])[i]->getTimeSlice();
817  ee += (*theHC[k])[i]->getIncidentEnergy();
818  zglob += std::abs((*theHC[k])[i]->getEntry().z());
819  zloc += std::abs((*theHC[k])[i]->getEntryLocal().z());
820 #endif
821  }
822 
823  double norm = (count > 0) ? 1.0 / count : 0.0;
824  eEM *= norm;
825  eEM2 *= norm;
826  eHAD *= norm;
827  eHAD2 *= norm;
828  eEM2 = std::sqrt(eEM2 - eEM * eEM);
829  eHAD2 = std::sqrt(eHAD2 - eHAD * eHAD);
830 #ifdef EDM_ML_DEBUG
831  tt *= norm;
832  ee *= norm;
833  zglob *= norm;
834  zloc *= norm;
835  edm::LogVerbatim("CaloSim") << "CaloSD: " << GetName() << " store " << count << " hits; " << wrong
836  << " track IDs not given properly and " << totalHits - count
837  << " hits not passing cuts\n EmeanEM= " << eEM << " ErmsEM= " << eEM2
838  << "\n EmeanHAD= " << eHAD << " ErmsHAD= " << eHAD2 << " TimeMean= " << tt
839  << " E0mean= " << ee << " Zglob= " << zglob << " Zloc= " << zloc << " ";
840 #endif
841  std::vector<std::unique_ptr<CaloG4Hit>>().swap(reusehit[k]);
842  if (useMap)
843  hitMap[k].erase(hitMap[k].begin(), hitMap[k].end());
844  }
845  tkMap.erase(tkMap.begin(), tkMap.end());
847 }
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
Definition: RootTree.cc:527
Log< level::Info, true > LogVerbatim
std::map< CaloHitID, CaloG4Hit * > hitMap[2]
Definition: CaloSD.h:195
bool useMap
Definition: CaloSD.h:179
CaloG4HitCollection * theHC[2]
Definition: CaloSD.h:174
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
bool saveHit(CaloG4Hit *, int k=0)
Definition: CaloSD.cc:950
std::unordered_map< unsigned int, unsigned int > boundaryCrossingParentMap_
Definition: CaloSD.h:197
int nHC_
Definition: CaloSD.h:158
Definition: TTTypes.h:54
T sqrt(T t)
Definition: SSEVec.h:23
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< std::unique_ptr< CaloG4Hit > > reusehit[2]
Definition: CaloSD.h:198
int totalHits[2]
Definition: CaloSD.h:185
virtual void endEvent()
Definition: CaloSD.cc:872
std::map< int, TrackWithHistory * > tkMap
Definition: CaloSD.h:196
std::unique_ptr< CaloSlaveSD > slave[2]
Definition: CaloSD.h:171

◆ update() [3/6]

void CaloSD::update
overrideprotected

Definition at line 1014 of file CaloSD.cc.

Referenced by MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), and MatrixUtil.Steps::overwrite().

1014  {
1015  int primary = -1;
1016  TrackInformation* trkInfo = cmsTrackInformation((*trk)());
1017  if (trkInfo->isPrimary())
1018  primary = (*trk)()->GetTrackID();
1019 
1020 #ifdef EDM_ML_DEBUG
1021  edm::LogVerbatim("CaloSim") << "New track: isPrimary " << trkInfo->isPrimary() << " primary ID = " << primary
1022  << " primary ancestor ID " << primAncestor;
1023 #endif
1024 
1025  // update the information if a different primary track ID
1026 
1027  if (primary > 0 && primary != primAncestor) {
1028  primAncestor = primary;
1029 
1030  // clean the hits information
1031 
1032  bool clean(false);
1033  for (int k = 0; k < nHC_; ++k)
1034  if (theHC[k]->entries() > 0)
1035  clean = true;
1036  if (clean)
1038  }
1039 }
Log< level::Info, true > LogVerbatim
bool isPrimary() const
CaloG4HitCollection * theHC[2]
Definition: CaloSD.h:174
int primAncestor
Definition: CaloSD.h:183
void cleanHitCollection()
Definition: CaloSD.cc:1041
static void clean(char *s)
int nHC_
Definition: CaloSD.h:158
TrackInformation * cmsTrackInformation(const G4Track *aTrack)

◆ update() [4/6]

void CaloSD::update
overrideprotected

Definition at line 760 of file CaloSD.cc.

Referenced by MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), and MatrixUtil.Steps::overwrite().

760  {
761  int id = (*trk)()->GetTrackID();
762  TrackInformation* trkI = cmsTrackInformation((*trk)());
763  int lastTrackID = -1;
764  if (trkI)
765  lastTrackID = trkI->getIDonCaloSurface();
766  if (id == lastTrackID) {
767  auto trksForThisEvent = m_trackManager->trackContainer();
768  if (!trksForThisEvent->empty()) {
769  TrackWithHistory* trkH = trksForThisEvent->back();
770  if (trkH->trackID() == id) {
771  tkMap[id] = trkH;
772 #ifdef EDM_ML_DEBUG
773  edm::LogVerbatim("CaloSim") << "CaloSD: get track " << id << " from Container of size "
774  << trksForThisEvent->size() << " with ID " << trkH->trackID();
775 #endif
776  }
777  }
778  }
779 }
Log< level::Info, true > LogVerbatim
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
int getIDonCaloSurface() const
const std::vector< TrackWithHistory * > * trackContainer() const
int trackID() const
std::map< int, TrackWithHistory * > tkMap
Definition: CaloSD.h:196
const SimTrackManager * m_trackManager
Definition: CaloSD.h:169

◆ update() [5/6]

void CaloSD::update
overrideprotected

Definition at line 750 of file CaloSD.cc.

Referenced by MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), and MatrixUtil.Steps::overwrite().

750 { initRun(); }
void initRun() override
Definition: HFNoseSD.cc:197

◆ update() [6/6]

void HFNoseSD::update ( const BeginOfJob )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfJob *>.

Definition at line 169 of file HFNoseSD.cc.

References angles_, Exception, fiducialCut_, geom_mode_, HGCalDDDConstants::geomMode(), HGCalDDDConstants::getParameter(), hgcons_, levelT1_, levelT2_, HGCalDDDConstants::levelTop(), HGCalDDDConstants::minSlope(), HGCalDDDConstants::mouseBite(), mouseBite_, mouseBiteCut_, nameX_, numberingScheme_, rejectMB_, slopeMin_, tan30deg_, HGCalParameters::useOffset_, waferRot_, and HGCalDDDConstants::waferSize().

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

169  {
170  if (hgcons_ != nullptr) {
173  levelT1_ = hgcons_->levelTop(0);
174  levelT2_ = hgcons_->levelTop(1);
175  int useOffset = hgcons_->getParameter()->useOffset_;
176  double waferSize = hgcons_->waferSize(false);
177  double mouseBite = hgcons_->mouseBite(false);
178  mouseBiteCut_ = waferSize * tan30deg_ - mouseBite;
179  if (useOffset > 0) {
180  rejectMB_ = true;
181  fiducialCut_ = true;
182  }
183 #ifdef EDM_ML_DEBUG
184  edm::LogVerbatim("HFNSim") << "HFNoseSD::Initialized with mode " << geom_mode_ << " Slope cut " << slopeMin_
185  << " top Level " << levelT1_ << ":" << levelT2_ << " wafer " << waferSize << ":"
186  << mouseBite << " useOffset " << useOffset;
187 #endif
188 
189  numberingScheme_ = std::make_unique<HFNoseNumberingScheme>(*hgcons_);
190  if (rejectMB_)
191  mouseBite_ = std::make_unique<HGCMouseBite>(*hgcons_, angles_, mouseBiteCut_, waferRot_);
192  } else {
193  throw cms::Exception("Unknown", "HFNoseSD") << "Cannot find HGCalDDDConstants for " << nameX_ << "\n";
194  }
195 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< HFNoseNumberingScheme > numberingScheme_
Definition: HFNoseSD.h:44
const HGCalParameters * getParameter() const
int levelT1_
Definition: HFNoseSD.h:51
bool fiducialCut_
Definition: HFNoseSD.h:53
double mouseBiteCut_
Definition: HFNoseSD.h:50
HGCalGeometryMode::GeometryMode geomMode() const
bool rejectMB_
Definition: HFNoseSD.h:53
bool waferRot_
Definition: HFNoseSD.h:53
HGCalGeometryMode::GeometryMode geom_mode_
Definition: HFNoseSD.h:48
const double tan30deg_
Definition: HFNoseSD.h:55
double mouseBite(bool reco) const
int levelT2_
Definition: HFNoseSD.h:51
double minSlope() const
const HGCalDDDConstants * hgcons_
Definition: HFNoseSD.h:43
std::string nameX_
Definition: HFNoseSD.h:47
std::unique_ptr< HGCMouseBite > mouseBite_
Definition: HFNoseSD.h:46
int levelTop(int ind=0) const
std::vector< double > angles_
Definition: HFNoseSD.h:56
double waferSize(bool reco) const
double slopeMin_
Definition: HFNoseSD.h:49

Member Data Documentation

◆ angles_

std::vector<double> HFNoseSD::angles_
private

Definition at line 56 of file HFNoseSD.h.

Referenced by HFNoseSD(), and update().

◆ checkID_

bool HFNoseSD::checkID_
private

Definition at line 53 of file HFNoseSD.h.

◆ cornerMinMask_

int HFNoseSD::cornerMinMask_
private

Definition at line 51 of file HFNoseSD.h.

Referenced by HFNoseSD(), and setDetUnitId().

◆ distanceFromEdge_

double HFNoseSD::distanceFromEdge_
private

Definition at line 50 of file HFNoseSD.h.

Referenced by HFNoseSD(), and isItinFidVolume().

◆ eminHit_

double HFNoseSD::eminHit_
private

Definition at line 49 of file HFNoseSD.h.

Referenced by filterHit(), and HFNoseSD().

◆ fiducialCut_

bool HFNoseSD::fiducialCut_
private

Definition at line 53 of file HFNoseSD.h.

Referenced by HFNoseSD(), isItinFidVolume(), setDetUnitId(), and update().

◆ geom_mode_

HGCalGeometryMode::GeometryMode HFNoseSD::geom_mode_
private

Definition at line 48 of file HFNoseSD.h.

Referenced by update().

◆ guardRing_

std::unique_ptr<HGCGuardRing> HFNoseSD::guardRing_
private

Definition at line 45 of file HFNoseSD.h.

Referenced by HFNoseSD().

◆ hgcons_

const HGCalDDDConstants* HFNoseSD::hgcons_
private

Definition at line 43 of file HFNoseSD.h.

Referenced by isItinFidVolume(), setDetUnitId(), and update().

◆ levelT1_

int HFNoseSD::levelT1_
private

Definition at line 51 of file HFNoseSD.h.

Referenced by setDetUnitId(), and update().

◆ levelT2_

int HFNoseSD::levelT2_
private

Definition at line 51 of file HFNoseSD.h.

Referenced by setDetUnitId(), and update().

◆ mouseBite_

std::unique_ptr<HGCMouseBite> HFNoseSD::mouseBite_
private

Definition at line 46 of file HFNoseSD.h.

Referenced by HFNoseSD(), setDetUnitId(), and update().

◆ mouseBiteCut_

double HFNoseSD::mouseBiteCut_
private

Definition at line 50 of file HFNoseSD.h.

Referenced by update().

◆ nameX_

std::string HFNoseSD::nameX_
private

Definition at line 47 of file HFNoseSD.h.

Referenced by HFNoseSD(), and update().

◆ numberingScheme_

std::unique_ptr<HFNoseNumberingScheme> HFNoseSD::numberingScheme_
private

Definition at line 44 of file HFNoseSD.h.

Referenced by HFNoseSD(), setDetUnitId(), and update().

◆ rejectMB_

bool HFNoseSD::rejectMB_
private

Definition at line 53 of file HFNoseSD.h.

Referenced by HFNoseSD(), setDetUnitId(), and update().

◆ slopeMin_

double HFNoseSD::slopeMin_
private

Definition at line 49 of file HFNoseSD.h.

Referenced by getEnergyDeposit(), and update().

◆ storeAllG4Hits_

bool HFNoseSD::storeAllG4Hits_
private

Definition at line 52 of file HFNoseSD.h.

Referenced by HFNoseSD().

◆ tan30deg_

const double HFNoseSD::tan30deg_
private

Definition at line 55 of file HFNoseSD.h.

Referenced by update().

◆ useSimWt_

int HFNoseSD::useSimWt_
private

Definition at line 54 of file HFNoseSD.h.

Referenced by setDetUnitId().

◆ verbose_

int HFNoseSD::verbose_
private

Definition at line 54 of file HFNoseSD.h.

◆ waferRot_

bool HFNoseSD::waferRot_
private

Definition at line 53 of file HFNoseSD.h.

Referenced by HFNoseSD(), and update().

◆ weight_

double HFNoseSD::weight_
private

Definition at line 49 of file HFNoseSD.h.

Referenced by getEnergyDeposit(), and setDetUnitId().