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)
 
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 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)
 
- 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)
 
 ~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 ()
 
CaloG4HitcreateNewHit (const G4Step *, const G4Track *)
 
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 ()
 
double getResponseWt (const G4Track *)
 
virtual int getTrackID (const G4Track *)
 
bool hitExists (const G4Step *)
 
void ignoreRejection ()
 
virtual void initEvent (const BeginOfEvent *)
 
void printDetectorLevels (const G4VTouchable *) const
 
void processHit (const G4Step *step)
 
void resetForNewPrimary (const G4Step *)
 
void setNumberCheckedHits (int val)
 
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 *)
 
- 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
CaloG4HitcurrentHit
 
CaloHitID currentID
 
float edepositEM
 
float edepositHAD
 
double eminHit
 
double energyCut
 
G4ThreeVector entranceLocal
 
G4ThreeVector entrancePoint
 
bool forceSave
 
float incidentEnergy
 
double kmaxIon
 
double kmaxNeutron
 
double kmaxProton
 
G4ThreeVector posGlobal
 
CaloHitID previousID
 
bool suppressHeavy
 
double tmaxHit
 

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:303
void setNumberCheckedHits(int val)
Definition: CaloSD.h:122
int cornerMinMask_
Definition: HFNoseSD.h:51
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:111
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
int levelT2_
Definition: HFNoseSD.h:51
const HGCalDDDConstants * hgcons_
Definition: HFNoseSD.h:43
CaloSD(const std::string &aSDname, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, float timeSlice=1., bool ignoreTkID=false)
Definition: CaloSD.cc:33
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:144
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
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double getResponseWt(const G4Track *)
Definition: CaloSD.cc:860
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 689 of file CaloSD.cc.

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

689  {
690 #ifdef EDM_ML_DEBUG
691  edm::LogVerbatim("CaloSim") << "CaloSD: Dispatched BeginOfEvent for " << GetName() << " !";
692 #endif
693  clearHits();
694  initEvent(g4Event);
695 }
Log< level::Info, true > LogVerbatim
virtual void initEvent(const BeginOfEvent *)
Definition: CaloSD.cc:803
void clearHits() override
Definition: CaloSD.cc:784

◆ update() [2/6]

void CaloSD::update
overrideprotected

Definition at line 718 of file CaloSD.cc.

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

718  {
719  endEvent();
720  slave.get()->ReserveMemory(theHC->entries());
721 
722  int count(0);
723  double eEM(0.0);
724  double eHAD(0.0);
725  double eEM2(0.0);
726  double eHAD2(0.0);
727 #ifdef EDM_ML_DEBUG
728  int wrong(0);
729  double tt(0.0);
730  double zloc(0.0);
731  double zglob(0.0);
732  double ee(0.0);
733 #endif
734  int hc_entries = theHC->entries();
735  for (int i = 0; i < hc_entries; ++i) {
736 #ifdef EDM_ML_DEBUG
737  if (!saveHit((*theHC)[i])) {
738  ++wrong;
739  }
740 #else
741  saveHit((*theHC)[i]);
742 #endif
743 
744  ++count;
745  double x = (*theHC)[i]->getEM();
746  eEM += x;
747  eEM2 += x * x;
748  x = (*theHC)[i]->getHadr();
749  eHAD += x;
750  eHAD2 += x * x;
751 #ifdef EDM_ML_DEBUG
752  tt += (*theHC)[i]->getTimeSlice();
753  ee += (*theHC)[i]->getIncidentEnergy();
754  zglob += std::abs((*theHC)[i]->getEntry().z());
755  zloc += std::abs((*theHC)[i]->getEntryLocal().z());
756 #endif
757  }
758 
759  double norm = (count > 0) ? 1.0 / count : 0.0;
760  eEM *= norm;
761  eEM2 *= norm;
762  eHAD *= norm;
763  eHAD2 *= norm;
764  eEM2 = std::sqrt(eEM2 - eEM * eEM);
765  eHAD2 = std::sqrt(eHAD2 - eHAD * eHAD);
766 #ifdef EDM_ML_DEBUG
767  tt *= norm;
768  ee *= norm;
769  zglob *= norm;
770  zloc *= norm;
771  edm::LogVerbatim("CaloSim") << "CaloSD: " << GetName() << " store " << count << " hits; " << wrong
772  << " track IDs not given properly and " << totalHits - count
773  << " hits not passing cuts\n EmeanEM= " << eEM << " ErmsEM= " << eEM2
774  << "\n EmeanHAD= " << eHAD << " ErmsHAD= " << eHAD2 << " TimeMean= " << tt
775  << " E0mean= " << ee << " Zglob= " << zglob << " Zloc= " << zloc << " ";
776 #endif
777  tkMap.erase(tkMap.begin(), tkMap.end());
778  std::vector<std::unique_ptr<CaloG4Hit>>().swap(reusehit);
779  if (useMap)
780  hitMap.erase(hitMap.begin(), hitMap.end());
782 }
Int_t getEntry(TBranch *branch, EntryNumber entryNumber)
Definition: RootTree.cc:527
Log< level::Info, true > LogVerbatim
int totalHits
Definition: CaloSD.h:177
bool useMap
Definition: CaloSD.h:171
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
std::unordered_map< unsigned int, unsigned int > boundaryCrossingParentMap_
Definition: CaloSD.h:189
Definition: TTTypes.h:54
std::unique_ptr< CaloSlaveSD > slave
Definition: CaloSD.h:163
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::map< CaloHitID, CaloG4Hit * > hitMap
Definition: CaloSD.h:187
virtual void endEvent()
Definition: CaloSD.cc:805
CaloG4HitCollection * theHC
Definition: CaloSD.h:166
std::map< int, TrackWithHistory * > tkMap
Definition: CaloSD.h:188
std::vector< std::unique_ptr< CaloG4Hit > > reusehit
Definition: CaloSD.h:190
bool saveHit(CaloG4Hit *)
Definition: CaloSD.cc:881

◆ update() [3/6]

void CaloSD::update
overrideprotected

Definition at line 944 of file CaloSD.cc.

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

944  {
945  int primary = -1;
946  TrackInformation* trkInfo = cmsTrackInformation((*trk)());
947  if (trkInfo->isPrimary())
948  primary = (*trk)()->GetTrackID();
949 
950 #ifdef EDM_ML_DEBUG
951  edm::LogVerbatim("CaloSim") << "New track: isPrimary " << trkInfo->isPrimary() << " primary ID = " << primary
952  << " primary ancestor ID " << primAncestor;
953 #endif
954 
955  // update the information if a different primary track ID
956 
957  if (primary > 0 && primary != primAncestor) {
958  primAncestor = primary;
959 
960  // clean the hits information
961 
962  if (theHC->entries() > 0)
964  }
965 }
Log< level::Info, true > LogVerbatim
bool isPrimary() const
int primAncestor
Definition: CaloSD.h:175
void cleanHitCollection()
Definition: CaloSD.cc:967
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
CaloG4HitCollection * theHC
Definition: CaloSD.h:166

◆ update() [4/6]

void CaloSD::update
overrideprotected

Definition at line 697 of file CaloSD.cc.

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

697  {
698  int id = (*trk)()->GetTrackID();
699  TrackInformation* trkI = cmsTrackInformation((*trk)());
700  int lastTrackID = -1;
701  if (trkI)
702  lastTrackID = trkI->getIDonCaloSurface();
703  if (id == lastTrackID) {
704  auto trksForThisEvent = m_trackManager->trackContainer();
705  if (!trksForThisEvent->empty()) {
706  TrackWithHistory* trkH = trksForThisEvent->back();
707  if (trkH->trackID() == id) {
708  tkMap[id] = trkH;
709 #ifdef EDM_ML_DEBUG
710  edm::LogVerbatim("CaloSim") << "CaloSD: get track " << id << " from Container of size "
711  << trksForThisEvent->size() << " with ID " << trkH->trackID();
712 #endif
713  }
714  }
715  }
716 }
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:188
const SimTrackManager * m_trackManager
Definition: CaloSD.h:161

◆ update() [5/6]

void CaloSD::update
overrideprotected

Definition at line 687 of file CaloSD.cc.

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

687 { 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().