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_
 
int cornerMinMask_
 
double distanceFromEdge_
 
double eminHit_
 
bool fiducialCut_
 
HGCalGeometryMode::GeometryMode geom_mode_
 
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_
 
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 20 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(), 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  tan30deg_(std::tan(30.0 * CLHEP::deg)) {
43  numberingScheme_.reset(nullptr);
44  mouseBite_.reset(nullptr);
45 
46  edm::ParameterSet m_HFN = p.getParameter<edm::ParameterSet>("HFNoseSD");
47  eminHit_ = m_HFN.getParameter<double>("EminHit") * CLHEP::MeV;
48  fiducialCut_ = m_HFN.getParameter<bool>("FiducialCut");
49  distanceFromEdge_ = m_HFN.getParameter<double>("DistanceFromEdge");
50  storeAllG4Hits_ = m_HFN.getParameter<bool>("StoreAllG4Hits");
51  rejectMB_ = m_HFN.getParameter<bool>("RejectMouseBite");
52  waferRot_ = m_HFN.getParameter<bool>("RotatedWafer");
53  cornerMinMask_ = m_HFN.getParameter<int>("CornerMinMask");
54  angles_ = m_HFN.getUntrackedParameter<std::vector<double>>("WaferAngles");
55 
56  nameX_ = ((name.find("HFNoseHits") != std::string::npos) ? "HGCalHFNoseSensitive" : "HFNoseSensitive");
57 
58  if (storeAllG4Hits_) {
59  setUseMap(false);
61  }
62 
63 #ifdef EDM_ML_DEBUG
64  edm::LogVerbatim("HFNSim") << "**************************************************"
65  << "\n"
66  << "* *"
67  << "\n"
68  << "* Constructing a HFNoseSD with name " << name << "\n"
69  << "* *"
70  << "\n"
71  << "**************************************************";
72 #endif
73  edm::LogVerbatim("HFNSim") << "HFNoseSD:: Threshold for storing hits: " << eminHit_ << " for " << name;
74  edm::LogVerbatim("HFNSim") << "Flag for storing individual Geant4 Hits " << storeAllG4Hits_;
75  edm::LogVerbatim("HFNSim") << "Fiducial volume cut with cut from eta/phi "
76  << "boundary " << fiducialCut_ << " at " << distanceFromEdge_;
77  edm::LogVerbatim("HFNSim") << "Reject MosueBite Flag: " << rejectMB_ << " cuts along " << angles_.size()
78  << " axes: " << angles_[0] << ", " << angles_[1];
79 }
Log< level::Info, true > LogVerbatim
double eminHit_
Definition: HFNoseSD.h:47
std::unique_ptr< HFNoseNumberingScheme > numberingScheme_
Definition: HFNoseSD.h:43
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void setNumberCheckedHits(int val)
Definition: CaloSD.h:122
int cornerMinMask_
Definition: HFNoseSD.h:49
bool storeAllG4Hits_
Definition: HFNoseSD.h:50
int levelT1_
Definition: HFNoseSD.h:49
bool fiducialCut_
Definition: HFNoseSD.h:51
double distanceFromEdge_
Definition: HFNoseSD.h:48
bool rejectMB_
Definition: HFNoseSD.h:51
void setUseMap(bool val)
Definition: CaloSD.h:111
bool waferRot_
Definition: HFNoseSD.h:51
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:52
int levelT2_
Definition: HFNoseSD.h:49
const HGCalDDDConstants * hgcons_
Definition: HFNoseSD.h:42
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:45
std::unique_ptr< HGCMouseBite > mouseBite_
Definition: HFNoseSD.h:44
std::vector< double > angles_
Definition: HFNoseSD.h:53
double slopeMin_
Definition: HFNoseSD.h:47

◆ ~HFNoseSD()

HFNoseSD::~HFNoseSD ( )
overridedefault

Member Function Documentation

◆ filterHit()

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

Reimplemented from CaloSD.

Definition at line 197 of file HFNoseSD.cc.

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

197  {
198  return ((time <= tmaxHit) && (aHit->getEnergyDeposit() > eminHit_));
199 }
double eminHit_
Definition: HFNoseSD.h:47
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 81 of file HFNoseSD.cc.

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

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

◆ initRun()

void HFNoseSD::initRun ( )
overrideprotectedvirtual

Reimplemented from CaloSD.

Definition at line 195 of file HFNoseSD.cc.

195 {}

◆ isItinFidVolume()

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

Definition at line 210 of file HFNoseSD.cc.

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

210  {
211  if (fiducialCut_) {
212  return (hgcons_->distFromEdgeHex(pos.x(), pos.y(), pos.z()) > distanceFromEdge_);
213  } else {
214  return true;
215  }
216 }
bool fiducialCut_
Definition: HFNoseSD.h:51
double distanceFromEdge_
Definition: HFNoseSD.h:48
const HGCalDDDConstants * hgcons_
Definition: HFNoseSD.h:42
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 112 of file HFNoseSD.cc.

References TauDecayModes::dec, l1ctLayer2EG_cff::id, pixelTopology::layer, levelT1_, levelT2_, callgraph::module, mouseBite_, rejectMB_, and HFNoseDetId::waferUV().

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

◆ setDetUnitId() [2/2]

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

Definition at line 201 of file HFNoseSD.cc.

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

201  {
202  uint32_t id = numberingScheme_ ? numberingScheme_->getUnitID(layer, module, cell, iz, pos, weight_) : 0;
203  if (cornerMinMask_ > 2) {
205  id = 0;
206  }
207  return id;
208 }
bool maskCell(const DetId &id, int corners) const
std::unique_ptr< HFNoseNumberingScheme > numberingScheme_
Definition: HFNoseSD.h:43
int cornerMinMask_
Definition: HFNoseSD.h:49
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
double weight_
Definition: HFNoseSD.h:47
Definition: DetId.h:17
const HGCalDDDConstants * hgcons_
Definition: HFNoseSD.h:42

◆ update() [1/6]

void CaloSD::update
overrideprotected

Definition at line 690 of file CaloSD.cc.

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

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

◆ update() [2/6]

void CaloSD::update
overrideprotected

Definition at line 724 of file CaloSD.cc.

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

724  {
725  endEvent();
726  slave.get()->ReserveMemory(theHC->entries());
727 
728  int count(0);
729  int wrong(0);
730  double eEM(0.0);
731  double eHAD(0.0);
732  double eEM2(0.0);
733  double eHAD2(0.0);
734 #ifdef EDM_ML_DEBUG
735  double tt(0.0);
736  double zloc(0.0);
737  double zglob(0.0);
738  double ee(0.0);
739 #endif
740  int hc_entries = theHC->entries();
741  for (int i = 0; i < hc_entries; ++i) {
742  if (!saveHit((*theHC)[i])) {
743  ++wrong;
744  }
745  ++count;
746  double x = (*theHC)[i]->getEM();
747  eEM += x;
748  eEM2 += x * x;
749  x = (*theHC)[i]->getHadr();
750  eHAD += x;
751  eHAD2 += x * x;
752 #ifdef EDM_ML_DEBUG
753  tt += (*theHC)[i]->getTimeSlice();
754  ee += (*theHC)[i]->getIncidentEnergy();
755  zglob += std::abs((*theHC)[i]->getEntry().z());
756  zloc += std::abs((*theHC)[i]->getEntryLocal().z());
757 #endif
758  }
759 
760  double norm = (count > 0) ? 1.0 / count : 0.0;
761  eEM *= norm;
762  eEM2 *= norm;
763  eHAD *= norm;
764  eHAD2 *= norm;
765  eEM2 = std::sqrt(eEM2 - eEM * eEM);
766  eHAD2 = std::sqrt(eHAD2 - eHAD * eHAD);
767 #ifdef EDM_ML_DEBUG
768  tt *= norm;
769  ee *= norm;
770  zglob *= norm;
771  zloc *= norm;
772  edm::LogVerbatim("CaloSim") << "CaloSD: " << GetName() << " store " << count << " hits; " << wrong
773  << " track IDs not given properly and " << totalHits - count
774  << " hits not passing cuts\n EmeanEM= " << eEM << " ErmsEM= " << eEM2
775  << "\n EmeanHAD= " << eHAD << " ErmsHAD= " << eHAD2 << " TimeMean= " << tt
776  << " E0mean= " << ee << " Zglob= " << zglob << " Zloc= " << zloc << " ";
777 #endif
778  tkMap.erase(tkMap.begin(), tkMap.end());
779  std::vector<std::unique_ptr<CaloG4Hit>>().swap(reusehit);
780  if (useMap)
781  hitMap.erase(hitMap.begin(), hitMap.end());
783 }
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:806
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:882

◆ update() [3/6]

void CaloSD::update
overrideprotected

Definition at line 945 of file CaloSD.cc.

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

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

◆ update() [4/6]

void CaloSD::update
overrideprotected

Definition at line 698 of file CaloSD.cc.

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

698  {
699  int id = (*trk)()->GetTrackID();
700  TrackInformation* trkI = cmsTrackInformation((*trk)());
701  int lastTrackID = -1;
702  if (trkI)
703  lastTrackID = trkI->getIDonCaloSurface();
704  if (id == lastTrackID) {
705  const TrackContainer* trksForThisEvent = m_trackManager->trackContainer();
706  if (trksForThisEvent != nullptr) {
707  int it = (int)(trksForThisEvent->size()) - 1;
708  if (it >= 0) {
709  TrackWithHistory* trkH = (*trksForThisEvent)[it];
710  if (trkH->trackID() == (unsigned int)(id))
711  tkMap[id] = trkH;
712 #ifdef EDM_ML_DEBUG
713  edm::LogVerbatim("CaloSim") << "CaloSD: get track " << it << " from Container of size "
714  << trksForThisEvent->size() << " with ID " << trkH->trackID();
715  } else {
716  edm::LogVerbatim("CaloSim") << "CaloSD: get track " << it << " from Container of size "
717  << trksForThisEvent->size() << " with no ID";
718 #endif
719  }
720  }
721  }
722 }
Log< level::Info, true > LogVerbatim
std::vector< TrackWithHistory * > TrackContainer
Definition: TrackContainer.h:8
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
int getIDonCaloSurface() const
const TrackContainer * trackContainer() const
std::map< int, TrackWithHistory * > tkMap
Definition: CaloSD.h:188
const SimTrackManager * m_trackManager
Definition: CaloSD.h:161
unsigned int trackID() const

◆ update() [5/6]

void CaloSD::update
overrideprotected

Definition at line 688 of file CaloSD.cc.

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

688 { initRun(); }
void initRun() override
Definition: HFNoseSD.cc:195

◆ 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 172 of file HFNoseSD.cc.

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

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

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

Member Data Documentation

◆ angles_

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

Definition at line 53 of file HFNoseSD.h.

Referenced by HFNoseSD(), and update().

◆ cornerMinMask_

int HFNoseSD::cornerMinMask_
private

Definition at line 49 of file HFNoseSD.h.

Referenced by HFNoseSD(), and setDetUnitId().

◆ distanceFromEdge_

double HFNoseSD::distanceFromEdge_
private

Definition at line 48 of file HFNoseSD.h.

Referenced by HFNoseSD(), and isItinFidVolume().

◆ eminHit_

double HFNoseSD::eminHit_
private

Definition at line 47 of file HFNoseSD.h.

Referenced by filterHit(), and HFNoseSD().

◆ fiducialCut_

bool HFNoseSD::fiducialCut_
private

Definition at line 51 of file HFNoseSD.h.

Referenced by HFNoseSD(), and isItinFidVolume().

◆ geom_mode_

HGCalGeometryMode::GeometryMode HFNoseSD::geom_mode_
private

Definition at line 46 of file HFNoseSD.h.

Referenced by update().

◆ hgcons_

const HGCalDDDConstants* HFNoseSD::hgcons_
private

Definition at line 42 of file HFNoseSD.h.

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

◆ levelT1_

int HFNoseSD::levelT1_
private

Definition at line 49 of file HFNoseSD.h.

Referenced by setDetUnitId(), and update().

◆ levelT2_

int HFNoseSD::levelT2_
private

Definition at line 49 of file HFNoseSD.h.

Referenced by setDetUnitId(), and update().

◆ mouseBite_

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

Definition at line 44 of file HFNoseSD.h.

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

◆ mouseBiteCut_

double HFNoseSD::mouseBiteCut_
private

Definition at line 48 of file HFNoseSD.h.

Referenced by update().

◆ nameX_

std::string HFNoseSD::nameX_
private

Definition at line 45 of file HFNoseSD.h.

Referenced by HFNoseSD(), and update().

◆ numberingScheme_

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

Definition at line 43 of file HFNoseSD.h.

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

◆ rejectMB_

bool HFNoseSD::rejectMB_
private

Definition at line 51 of file HFNoseSD.h.

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

◆ slopeMin_

double HFNoseSD::slopeMin_
private

Definition at line 47 of file HFNoseSD.h.

Referenced by getEnergyDeposit(), and update().

◆ storeAllG4Hits_

bool HFNoseSD::storeAllG4Hits_
private

Definition at line 50 of file HFNoseSD.h.

Referenced by HFNoseSD().

◆ tan30deg_

const double HFNoseSD::tan30deg_
private

Definition at line 52 of file HFNoseSD.h.

Referenced by update().

◆ waferRot_

bool HFNoseSD::waferRot_
private

Definition at line 51 of file HFNoseSD.h.

Referenced by HFNoseSD(), and update().

◆ weight_

double HFNoseSD::weight_
private

Definition at line 47 of file HFNoseSD.h.

Referenced by getEnergyDeposit(), and setDetUnitId().