CMS 3D CMS Logo

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

#include <HGCalSD.h>

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

Public Member Functions

 HGCalSD (const std::string &, const HGCalDDDConstants *, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
 
uint32_t setDetUnitId (const G4Step *step) override
 
 ~HGCalSD () 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 processSecondHit (const G4Step *, const G4Track *) override
 
void update (const BeginOfEvent *) override
 
void update (const BeginOfRun *) override
 
void update (const ::EndOfEvent *) override
 
void update (const BeginOfTrack *trk) override
 
void update (const EndOfTrack *trk) 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)
 
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 calibCell (const uint32_t &id)
 
bool isItinFidVolume (const G4ThreeVector &)
 
uint32_t setDetUnitId (int, int, int, int, G4ThreeVector &)
 

Private Attributes

std::vector< double > angles_
 
bool calibCell_
 
std::vector< int > calibCellFullHD_
 
std::vector< int > calibCellFullLD_
 
std::vector< int > calibCellPartHD_
 
std::vector< int > calibCellPartLD_
 
double calibCellRHD_
 
double calibCellRLD_
 
bool calibCells_
 
std::unique_ptr< HGCalCellOffsetcellOffset_
 
bool checkID_
 
int cornerMinMask_
 
const double cos30deg_
 
bool dd4hep_
 
double distanceFromEdge_
 
double eminHit_
 
bool fiducialCut_
 
double fraction_
 
HGCalGeometryMode::GeometryMode geom_mode_
 
std::unique_ptr< HGCGuardRingguardRing_
 
double guardRingOffset_
 
std::unique_ptr< HGCGuardRingPartialguardRingPartial_
 
const HGCalDDDConstantshgcons_
 
int levelT1_
 
int levelT2_
 
std::string missingFile_
 
std::unique_ptr< HGCMouseBitemouseBite_
 
double mouseBiteCut_
 
DetId::Detector mydet_
 
std::string myName_
 
std::string nameX_
 
std::unique_ptr< HGCalNumberingSchemenumberingScheme_
 
edm::ParameterSet const & ps_
 
bool rejectMB_
 
double slopeMin_
 
bool storeAllG4Hits_
 
const double tan30deg_
 
int useSimWt_
 
int verbose_
 
bool waferRot_
 
double waferSize_
 
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 22 of file HGCalSD.h.

Constructor & Destructor Documentation

◆ HGCalSD()

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

Definition at line 33 of file HGCalSD.cc.

References angles_, cellOffset_, checkID_, cornerMinMask_, dd4hep_, distanceFromEdge_, eminHit_, fiducialCut_, DetId::Forward, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), guardRing_, guardRingPartial_, DetId::HGCalEE, DetId::HGCalHSi, missingFile_, mouseBite_, mydet_, myName_, Skims_PA_cff::name, nameX_, CaloSD::nHC_, numberingScheme_, AlCaHLTBitMon_ParallelJobs::p, rejectMB_, CaloSD::setNumberCheckedHits(), CaloSD::setUseMap(), storeAllG4Hits_, AlCaHLTBitMon_QueryRunRegistry::string, verbose_, and waferRot_.

38  : CaloSD(name,
39  clg,
40  p,
41  manager,
42  static_cast<float>(p.getParameter<edm::ParameterSet>("HGCSD").getParameter<double>("TimeSliceUnit")),
43  p.getParameter<edm::ParameterSet>("HGCSD").getParameter<bool>("IgnoreTrackID"),
44  ("Calibration" + name)),
45  myName_(name),
46  hgcons_(hgc),
47  ps_(p),
48  slopeMin_(0),
49  levelT1_(99),
50  levelT2_(99),
51  useSimWt_(0),
52  calibCells_(false),
53  tan30deg_(std::tan(30.0 * CLHEP::deg)),
54  cos30deg_(std::cos(30.0 * CLHEP::deg)) {
55  numberingScheme_.reset(nullptr);
56  guardRing_.reset(nullptr);
57  guardRingPartial_.reset(nullptr);
58  mouseBite_.reset(nullptr);
59  cellOffset_.reset(nullptr);
60 
61  edm::ParameterSet m_HGC = p.getParameter<edm::ParameterSet>("HGCSD");
62  eminHit_ = m_HGC.getParameter<double>("EminHit") * CLHEP::MeV;
63  fiducialCut_ = m_HGC.getParameter<bool>("FiducialCut");
64  storeAllG4Hits_ = m_HGC.getParameter<bool>("StoreAllG4Hits");
65  rejectMB_ = m_HGC.getParameter<bool>("RejectMouseBite");
66  waferRot_ = m_HGC.getParameter<bool>("RotatedWafer");
67  cornerMinMask_ = m_HGC.getParameter<int>("CornerMinMask");
68  nHC_ = m_HGC.getParameter<int>("HitCollection");
69  angles_ = m_HGC.getUntrackedParameter<std::vector<double>>("WaferAngles");
70  missingFile_ = m_HGC.getUntrackedParameter<std::string>("MissingWaferFile");
71  checkID_ = m_HGC.getUntrackedParameter<bool>("CheckID");
72  verbose_ = m_HGC.getUntrackedParameter<int>("Verbosity");
73  dd4hep_ = p.getParameter<bool>("g4GeometryDD4hepSource");
74 
75  if (storeAllG4Hits_) {
76  setUseMap(false);
78  }
79 
80  //this is defined in the hgcsens.xml
82  nameX_ = "HGCal";
83  if (myName_.find("HitsEE") != std::string::npos) {
85  nameX_ = "HGCalEESensitive";
86  } else if (myName_.find("HitsHEfront") != std::string::npos) {
88  nameX_ = "HGCalHESiliconSensitive";
89  }
90 
91 #ifdef EDM_ML_DEBUG
92  edm::LogVerbatim("HGCSim") << "**************************************************"
93  << "\n"
94  << "* *"
95  << "\n"
96  << "* Constructing a HGCalSD with name " << name << "\n"
97  << "* *"
98  << "\n"
99  << "**************************************************";
100 #endif
101  edm::LogVerbatim("HGCSim") << "HGCalSD:: Threshold for storing hits: " << eminHit_ << " for " << nameX_
102  << " detector " << mydet_ << " with " << nHC_ << " hit collections";
103  edm::LogVerbatim("HGCSim") << "Flag for storing individual Geant4 Hits " << storeAllG4Hits_;
104  edm::LogVerbatim("HGCSim") << "Fiducial volume cut with cut from eta/phi "
105  << "boundary " << fiducialCut_ << " at " << distanceFromEdge_;
106  edm::LogVerbatim("HGCSim") << "Reject MosueBite Flag: " << rejectMB_ << " cuts along " << angles_.size()
107  << " axes: " << angles_[0] << ", " << angles_[1];
108 }
Log< level::Info, true > LogVerbatim
int verbose_
Definition: HGCalSD.h:62
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
double distanceFromEdge_
Definition: HGCalSD.h:57
int levelT2_
Definition: HGCalSD.h:59
edm::ParameterSet const & ps_
Definition: HGCalSD.h:48
double slopeMin_
Definition: HGCalSD.h:57
void setNumberCheckedHits(int val, int k=0)
Definition: CaloSD.h:126
std::string myName_
Definition: HGCalSD.h:46
std::unique_ptr< HGCalNumberingScheme > numberingScheme_
Definition: HGCalSD.h:49
std::string nameX_
Definition: HGCalSD.h:55
void setUseMap(bool val)
Definition: CaloSD.h:115
T getUntrackedParameter(std::string const &, T const &) const
int nHC_
Definition: CaloSD.h:158
bool calibCells_
Definition: HGCalSD.h:63
bool rejectMB_
Definition: HGCalSD.h:61
DetId::Detector mydet_
Definition: HGCalSD.h:54
const double cos30deg_
Definition: HGCalSD.h:67
std::string missingFile_
Definition: HGCalSD.h:69
bool storeAllG4Hits_
Definition: HGCalSD.h:60
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::vector< double > angles_
Definition: HGCalSD.h:68
const HGCalDDDConstants * hgcons_
Definition: HGCalSD.h:47
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
const double tan30deg_
Definition: HGCalSD.h:67
bool waferRot_
Definition: HGCalSD.h:61
bool dd4hep_
Definition: HGCalSD.h:63
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:33
bool checkID_
Definition: HGCalSD.h:61
int cornerMinMask_
Definition: HGCalSD.h:59
std::unique_ptr< HGCalCellOffset > cellOffset_
Definition: HGCalSD.h:53
bool fiducialCut_
Definition: HGCalSD.h:61
std::unique_ptr< HGCGuardRingPartial > guardRingPartial_
Definition: HGCalSD.h:51
int useSimWt_
Definition: HGCalSD.h:62
std::unique_ptr< HGCGuardRing > guardRing_
Definition: HGCalSD.h:50
int levelT1_
Definition: HGCalSD.h:59
std::unique_ptr< HGCMouseBite > mouseBite_
Definition: HGCalSD.h:52
double eminHit_
Definition: HGCalSD.h:57

◆ ~HGCalSD()

HGCalSD::~HGCalSD ( )
overridedefault

Member Function Documentation

◆ calibCell()

bool HGCalSD::calibCell ( const uint32_t &  id)
private

Definition at line 378 of file HGCalSD.cc.

References calibCellFullHD_, calibCellFullLD_, calibCellPartHD_, calibCellPartLD_, calibCellRHD_, calibCellRLD_, cellOffset_, HGCalCell::cellPlacementIndex(), spr::find(), RemoveAddSevLevel::flag, fraction_, full, hgcons_, info(), nano_mu_digi_cff::layer, HGCalTypes::layerFrontBack(), HGCalDDDConstants::layerType(), M_PI, EgammaValidation_cff::num, HGCSiliconDetId::unpack(), HGCalTypes::waferFull(), HGCalTypes::waferHD(), HGCalDDDConstants::waferInfo(), HGCalWaferIndex::waferU(), HGCalWaferIndex::waferV(), and ecaldqm::zside().

Referenced by setDetUnitId().

378  {
379  bool flag(false);
380  int type, zside, layer, waferU, waferV, cellU, cellV;
381  HGCSiliconDetId(id).unpack(type, zside, layer, waferU, waferV, cellU, cellV);
383  bool hd = HGCalTypes::waferHD(info.type);
384  bool full = HGCalTypes::waferFull(info.part);
385  int indx = 100 * cellU + cellV;
386  if (hd) {
387  if (full)
388  flag = (std::find(calibCellFullHD_.begin(), calibCellFullHD_.end(), indx) != calibCellFullHD_.end());
389  else
390  flag = (std::find(calibCellPartHD_.begin(), calibCellPartHD_.end(), indx) != calibCellPartHD_.end());
391  } else {
392  if (full)
393  flag = (std::find(calibCellFullLD_.begin(), calibCellFullLD_.end(), indx) != calibCellFullLD_.end());
394  else
395  flag = (std::find(calibCellPartLD_.begin(), calibCellPartLD_.end(), indx) != calibCellPartLD_.end());
396  }
397  if (flag) {
398  int32_t place =
400  int32_t type = hd ? 0 : 1;
401  double num = hd ? (M_PI * calibCellRHD_ * calibCellRHD_) : (M_PI * calibCellRLD_ * calibCellRLD_);
402  double bot = cellOffset_->cellAreaUV(cellU, cellV, place, type, true);
403  fraction_ = (bot > 0 && bot > num) ? (num / bot) : 1.0;
404 #ifdef EDM_ML_DEBUG
405  edm::LogVerbatim("HGCSim") << HGCSiliconDetId(id) << " CalibrationCell flag " << flag << " and fraction " << num
406  << ":" << bot << ":" << fraction_;
407 #endif
408  } else {
409 #ifdef EDM_ML_DEBUG
410  edm::LogVerbatim("HGCSim") << HGCSiliconDetId(id) << " CalibrationCell flag " << flag;
411 #endif
412  }
413  return flag;
414 }
Log< level::Info, true > LogVerbatim
static int32_t cellPlacementIndex(int32_t iz, int32_t frontBack, int32_t orient)
Definition: HGCalCell.cc:237
static constexpr bool waferHD(int32_t type)
Definition: HGCalTypes.h:133
static const TGPicture * info(bool iBackgroundIsBlack)
std::vector< int > calibCellPartLD_
Definition: HGCalSD.h:66
int32_t waferU(const int32_t index)
std::vector< int > calibCellPartHD_
Definition: HGCalSD.h:65
HGCalParameters::waferInfo waferInfo(int lay, int waferU, int waferV) const
int zside(DetId const &)
static constexpr bool waferFull(int32_t type)
Definition: HGCalTypes.h:134
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
constexpr void unpack(int32_t &ty, int32_t &zs, int32_t &ly, int32_t &wU, int32_t &wV, int32_t &cU, int32_t &cV) const
std::vector< int > calibCellFullHD_
Definition: HGCalSD.h:65
double fraction_
Definition: HGCalSD.h:71
Definition: GenABIO.cc:168
const HGCalDDDConstants * hgcons_
Definition: HGCalSD.h:47
double calibCellRLD_
Definition: HGCalSD.h:64
#define M_PI
std::unique_ptr< HGCalCellOffset > cellOffset_
Definition: HGCalSD.h:53
std::vector< int > calibCellFullLD_
Definition: HGCalSD.h:66
int32_t waferV(const int32_t index)
double calibCellRHD_
Definition: HGCalSD.h:64
int layerType(int lay) const
static constexpr int32_t layerFrontBack(int32_t layerOrient)
Definition: HGCalTypes.h:130

◆ filterHit()

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

Reimplemented from CaloSD.

Definition at line 346 of file HGCalSD.cc.

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

346  {
347  return ((time <= tmaxHit) && (aHit->getEnergyDeposit() > eminHit_));
348 }
double tmaxHit
Definition: CaloSD.h:148
double getEnergyDeposit() const
Definition: CaloG4Hit.h:79
double eminHit_
Definition: HGCalSD.h:57

◆ getEnergyDeposit()

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

Reimplemented from CaloSD.

Definition at line 110 of file HGCalSD.cc.

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

110  {
111  double r = aStep->GetPreStepPoint()->GetPosition().perp();
112  double z = std::abs(aStep->GetPreStepPoint()->GetPosition().z());
113 #ifdef EDM_ML_DEBUG
114  G4int parCode = aStep->GetTrack()->GetDefinition()->GetPDGEncoding();
115  G4String parName = aStep->GetTrack()->GetDefinition()->GetParticleName();
116  G4LogicalVolume* lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
117  edm::LogVerbatim("HGCSim") << "HGCalSD: Hit from standard path from " << lv->GetName() << " for Track "
118  << aStep->GetTrack()->GetTrackID() << " (" << parCode << ":" << parName << ") R = " << r
119  << " Z = " << z << " slope = " << r / z << ":" << slopeMin_;
120 #endif
121  // Apply fiducial cut
122  if (r < z * slopeMin_) {
123 #ifdef EDM_ML_DEBUG
124  edm::LogVerbatim("HGCSim") << "HGCalSD: Fiducial Volume cut";
125 #endif
126  return 0.0;
127  }
128 
129  double wt1 = getResponseWt(aStep->GetTrack());
130  double wt2 = aStep->GetTrack()->GetWeight();
131  double destep = weight_ * wt1 * (aStep->GetTotalEnergyDeposit());
132  if (wt2 > 0)
133  destep *= wt2;
134 #ifdef EDM_ML_DEBUG
135  edm::LogVerbatim("HGCSim") << "HGCalSD: weights= " << weight_ << ":" << wt1 << ":" << wt2 << " Total weight "
136  << weight_ * wt1 * wt2 << " deStep: " << aStep->GetTotalEnergyDeposit() << ":" << destep;
137 #endif
138  return destep;
139 }
Log< level::Info, true > LogVerbatim
double slopeMin_
Definition: HGCalSD.h:57
double getResponseWt(const G4Track *, int k=0)
Definition: CaloSD.cc:927
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double weight_
Definition: HGCalSD.h:58

◆ initRun()

void HGCalSD::initRun ( )
overrideprotectedvirtual

Reimplemented from CaloSD.

Definition at line 344 of file HGCalSD.cc.

344 {}

◆ isItinFidVolume()

bool HGCalSD::isItinFidVolume ( const G4ThreeVector &  )
private

◆ processSecondHit()

void HGCalSD::processSecondHit ( const G4Step *  aStep,
const G4Track *  theTrack 
)
overrideprotectedvirtual

Reimplemented from CaloSD.

Definition at line 350 of file HGCalSD.cc.

References calibCell_, CaloSD::createNewHit(), CaloSD::currentHit, CaloSD::currentID, CaloSD::edepositEM, CaloSD::edepositHAD, fraction_, and CaloSD::hitExists().

350  {
351  if (calibCell_) {
352  float edEM(edepositEM), edHad(edepositHAD);
353  currentID[1] = currentID[0];
356  if (!hitExists(aStep, 1)) {
357  currentHit[1] = createNewHit(aStep, theTrack, 1);
358  }
359  edepositEM = edEM;
360  edepositHAD = edHad;
361  }
362 }
CaloG4Hit * currentHit[2]
Definition: CaloSD.h:152
float edepositEM
Definition: CaloSD.h:144
bool calibCell_
Definition: HGCalSD.h:70
CaloG4Hit * createNewHit(const G4Step *, const G4Track *, int k)
Definition: CaloSD.cc:623
float edepositHAD
Definition: CaloSD.h:144
double fraction_
Definition: HGCalSD.h:71
bool hitExists(const G4Step *, int k)
Definition: CaloSD.cc:462
CaloHitID currentID[2]
Definition: CaloSD.h:146

◆ setDetUnitId() [1/2]

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

Implements CaloSD.

Definition at line 141 of file HGCalSD.cc.

References calibCell(), calibCell_, calibCells_, HGCalDDDConstants::cassetteShiftSilicon(), HGCSiliconDetId::cellU(), HGCSiliconDetId::cellV(), checkID_, angle_units::operators::convertRadToDeg(), debug, TauDecayModes::dec, change_name::diff, PVValHelper::dx, PVValHelper::dy, fiducialCut_, fraction_, guardRing_, guardRingPartial_, hgcons_, l1ctLayer2EG_cff::id, HGCalDDDConstants::isValidHex8(), nano_mu_digi_cff::layer, HGCSiliconDetId::layer(), HGCalTypes::layerFrontBack(), HGCalDDDConstants::layerType(), levelT1_, levelT2_, DTRecHitClients_cfi::local, HGCalDDDConstants::locateCell(), mouseBite_, CaloSD::printDetectorLevels(), rejectMB_, mathSSE::sqrt(), useSimWt_, verbose_, HGCalDDDConstants::waferFileInfo(), HGCalWaferIndex::waferIndex(), HGCalDDDConstants::waferTypeRotation(), HGCSiliconDetId::waferU(), HGCSiliconDetId::waferUV(), HGCSiliconDetId::waferV(), geometryCSVtoXML::xx, geometryCSVtoXML::xy, and HGCSiliconDetId::zside().

141  {
142  const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
143  const G4VTouchable* touch = preStepPoint->GetTouchable();
144  fraction_ = 1.0;
145  calibCell_ = false;
146  int dn = touch->GetHistoryDepth();
147 
148 #ifdef EDM_ML_DEBUG
149  edm::LogVerbatim("HGCSim") << "DepthsTop: " << dn << ":" << levelT1_ << ":" << levelT2_;
150  printDetectorLevels(touch);
151 #endif
152  //determine the exact position in global coordinates in the mass geometry
153  G4ThreeVector hitPoint = preStepPoint->GetPosition();
154  float globalZ = touch->GetTranslation(0).z();
155  int iz(globalZ > 0 ? 1 : -1);
156 
157  int layer(0), moduleLev(-1), cell(-1);
158  if (useSimWt_ > 0) {
159  layer = touch->GetReplicaNumber(2);
160  moduleLev = 1;
161  } else if (touch->GetHistoryDepth() > levelT2_) {
162  layer = touch->GetReplicaNumber(4);
163  cell = touch->GetReplicaNumber(1);
164  moduleLev = 3;
165  } else {
166  layer = touch->GetReplicaNumber(3);
167  moduleLev = 2;
168  }
169  int module = touch->GetReplicaNumber(moduleLev);
170  if (verbose_ && (cell == -1))
171  edm::LogVerbatim("HGCSim") << "Top " << touch->GetVolume(0)->GetName() << " Module "
172  << touch->GetVolume(moduleLev)->GetName();
173 #ifdef EDM_ML_DEBUG
174  edm::LogVerbatim("HGCSim") << "DepthsTop: " << touch->GetHistoryDepth() << ":" << levelT1_ << ":" << levelT2_ << ":"
175  << useSimWt_ << " name " << touch->GetVolume(0)->GetName() << " layer:module:cell "
176  << layer << ":" << moduleLev << ":" << module << ":" << cell;
177  printDetectorLevels(touch);
178  G4Material* mat = aStep->GetPreStepPoint()->GetMaterial();
179  edm::LogVerbatim("HGCSim") << "Depths: " << touch->GetHistoryDepth() << " name " << touch->GetVolume(0)->GetName()
180  << ":" << touch->GetReplicaNumber(0) << " " << touch->GetVolume(1)->GetName() << ":"
181  << touch->GetReplicaNumber(1) << " " << touch->GetVolume(2)->GetName() << ":"
182  << touch->GetReplicaNumber(2) << " " << touch->GetVolume(3)->GetName() << ":"
183  << touch->GetReplicaNumber(3) << " " << touch->GetVolume(4)->GetName() << ":"
184  << touch->GetReplicaNumber(4) << " "
185  << " layer:module:cell " << layer << ":" << module << ":" << cell << " Material "
186  << mat->GetName() << ":" << mat->GetRadlen();
187 #endif
188  // The following statement should be examined later before elimination
189  if (aStep->GetPreStepPoint()->GetMaterial()->GetRadlen() > 100000.)
190  return 0;
191 
192  uint32_t id = setDetUnitId(layer, module, cell, iz, hitPoint);
193  if ((rejectMB_ || fiducialCut_) && id != 0) {
194  auto uv = HGCSiliconDetId(id).waferUV();
195 #ifdef EDM_ML_DEBUG
196  edm::LogVerbatim("HGCSim") << "ID " << std::hex << id << std::dec << " " << HGCSiliconDetId(id);
197 #endif
198  G4ThreeVector local = (touch->GetHistory()->GetTransform(dn - moduleLev).TransformPoint(hitPoint));
199 #ifdef EDM_ML_DEBUG
200  edm::LogVerbatim("HGCSim") << "Global Point " << hitPoint << " Down0 "
201  << touch->GetHistory()->GetTransform(dn).TransformPoint(hitPoint) << " Down1 "
202  << touch->GetHistory()->GetTransform(dn - 1).TransformPoint(hitPoint) << " Down2 "
203  << touch->GetHistory()->GetTransform(dn - 2).TransformPoint(hitPoint) << " Down3 "
204  << touch->GetHistory()->GetTransform(dn - 3).TransformPoint(hitPoint) << " Local "
205  << local;
206 #endif
207  if (fiducialCut_) {
208  int layertype = hgcons_->layerType(layer);
209  int frontBack = HGCalTypes::layerFrontBack(layertype);
210  if (guardRing_->exclude(local, iz, frontBack, layer, uv.first, uv.second) ||
211  guardRingPartial_->exclude(local, iz, frontBack, layer, uv.first, uv.second)) {
212  id = 0;
213 #ifdef EDM_ML_DEBUG
214  edm::LogVerbatim("HGCSim") << "Rejected by GuardRing cutoff *****";
215 #endif
216  }
217  }
218  if ((rejectMB_) && (mouseBite_->exclude(local, iz, layer, uv.first, uv.second))) {
219  id = 0;
220 #ifdef EDM_ML_DEBUG
221  edm::LogVerbatim("HGCSim") << "Rejected by MouseBite cutoff *****";
222 #endif
223  }
224  }
225 #ifdef EDM_ML_DEBUG
226  if (id != 0)
227  edm::LogVerbatim("HGCSim") << HGCSiliconDetId(id);
228 #endif
229  if ((id != 0) && checkID_) {
230  HGCSiliconDetId hid1(id);
231  bool cshift = (hgcons_->cassetteShiftSilicon(hid1.zside(), hid1.layer(), hid1.waferU(), hid1.waferV()));
232  std::string_view pid = (cshift ? "HGCSim" : "HGCalSim");
233  bool debug = (verbose_ > 0) ? true : false;
234  auto xy = hgcons_->locateCell(hid1, debug);
235  double xx = (hid1.zside() > 0) ? xy.first : -xy.first;
236  double dx = xx - (hitPoint.x() / CLHEP::cm);
237  double dy = xy.second - (hitPoint.y() / CLHEP::cm);
238  double diff = (dx * dx + dy * dy);
239  constexpr double tol = 2.0 * 2.0;
240  bool valid1 = hgcons_->isValidHex8(hid1.layer(), hid1.waferU(), hid1.waferV(), hid1.cellU(), hid1.cellV(), true);
241  if ((diff > tol) || (!valid1))
242  pid = "HGCalError";
243  auto partn = hgcons_->waferTypeRotation(hid1.layer(), hid1.waferU(), hid1.waferV(), false, false);
244  int indx = HGCalWaferIndex::waferIndex(layer, hid1.waferU(), hid1.waferV());
245  edm::LogVerbatim(pid) << "CheckID " << HGCSiliconDetId(id) << " Layer:Module:Cell:ModuleLev " << layer << ":"
246  << module << ":" << cell << ":" << moduleLev << " SimWt:history " << useSimWt_ << ":"
247  << touch->GetHistoryDepth() << ":" << levelT1_ << ":" << levelT2_ << " input position: ("
248  << hitPoint.x() / CLHEP::cm << ", " << hitPoint.y() / CLHEP::cm << ":"
249  << convertRadToDeg(std::atan2(hitPoint.y(), hitPoint.x())) << "); position from ID (" << xx
250  << ", " << xy.second << ") distance " << dx << ":" << dy << ":" << std::sqrt(diff)
251  << " Valid " << valid1 << " Wafer type|rotation " << partn.first << ":" << partn.second
252  << " Part:Orient:Cassette " << std::get<1>(hgcons_->waferFileInfo(indx)) << ":"
253  << std::get<2>(hgcons_->waferFileInfo(indx)) << ":"
254  << std::get<3>(hgcons_->waferFileInfo(indx)) << " CassetteShift " << cshift;
255  if ((diff > tol) || (!valid1)) {
256  printDetectorLevels(touch);
257  hgcons_->locateCell(hid1, true);
258  }
259  }
260 
261  if ((id != 0) && calibCells_)
262  calibCell_ = calibCell(id);
263 
264  return id;
265 }
int verbose_
Definition: HGCalSD.h:62
Log< level::Info, true > LogVerbatim
bool calibCell_
Definition: HGCalSD.h:70
int levelT2_
Definition: HGCalSD.h:59
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
std::pair< int, int > waferTypeRotation(int layer, int waferU, int waferV, bool fromFile, bool debug) const
bool isValidHex8(int lay, int waferU, int waferV, bool fullAndPart) const
bool calibCells_
Definition: HGCalSD.h:63
bool rejectMB_
Definition: HGCalSD.h:61
uint32_t setDetUnitId(const G4Step *step) override
Definition: HGCalSD.cc:141
std::tuple< int, int, int, int > waferFileInfo(unsigned int kk) const
T sqrt(T t)
Definition: SSEVec.h:19
double fraction_
Definition: HGCalSD.h:71
const HGCalDDDConstants * hgcons_
Definition: HGCalSD.h:47
int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old=false)
bool checkID_
Definition: HGCalSD.h:61
bool calibCell(const uint32_t &id)
Definition: HGCalSD.cc:378
#define debug
Definition: HDRShower.cc:19
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
bool fiducialCut_
Definition: HGCalSD.h:61
void printDetectorLevels(const G4VTouchable *) const
Definition: CaloSD.cc:1157
std::unique_ptr< HGCGuardRingPartial > guardRingPartial_
Definition: HGCalSD.h:51
bool cassetteShiftSilicon(int zside, int layer, int waferU, int waferV) const
int useSimWt_
Definition: HGCalSD.h:62
std::unique_ptr< HGCGuardRing > guardRing_
Definition: HGCalSD.h:50
int levelT1_
Definition: HGCalSD.h:59
std::unique_ptr< HGCMouseBite > mouseBite_
Definition: HGCalSD.h:52
constexpr std::pair< int32_t, int32_t > waferUV() const
int layerType(int lay) const
static constexpr int32_t layerFrontBack(int32_t layerOrient)
Definition: HGCalTypes.h:130

◆ setDetUnitId() [2/2]

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

Definition at line 364 of file HGCalSD.cc.

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

364  {
365  uint32_t id = numberingScheme_ ? numberingScheme_->getUnitID(layer, module, cell, iz, pos, weight_) : 0;
366  if (cornerMinMask_ > 2) {
367  if (hgcons_->maskCell(DetId(id), cornerMinMask_)) {
368  id = 0;
369  ignoreRejection();
370  }
371  }
372  if (hgcons_->waferHexagon8File() || (id == 0))
373  ignoreRejection();
374 
375  return id;
376 }
bool maskCell(const DetId &id, int corners) const
std::unique_ptr< HGCalNumberingScheme > numberingScheme_
Definition: HGCalSD.h:49
void ignoreRejection()
Definition: CaloSD.h:112
const HGCalDDDConstants * hgcons_
Definition: HGCalSD.h:47
Definition: DetId.h:17
int cornerMinMask_
Definition: HGCalSD.h:59
bool waferHexagon8File() const
double weight_
Definition: HGCalSD.h:58

◆ update() [1/6]

void CaloSD::update
overrideprotected

Definition at line 748 of file CaloSD.cc.

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

748 { initRun(); }
void initRun() override
Definition: HGCalSD.cc:344

◆ update() [2/6]

void CaloSD::update
overrideprotected

Definition at line 779 of file CaloSD.cc.

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

779  {
780  endEvent();
781  for (int k = 0; k < nHC_; ++k) {
782  slave[k].get()->ReserveMemory(theHC[k]->entries());
783 
784  int count(0);
785  double eEM(0.0);
786  double eHAD(0.0);
787  double eEM2(0.0);
788  double eHAD2(0.0);
789 #ifdef EDM_ML_DEBUG
790  int wrong(0);
791  double tt(0.0);
792  double zloc(0.0);
793  double zglob(0.0);
794  double ee(0.0);
795 #endif
796  int hc_entries = theHC[k]->entries();
797  for (int i = 0; i < hc_entries; ++i) {
798 #ifdef EDM_ML_DEBUG
799  if (!saveHit((*theHC[k])[i], k)) {
800  ++wrong;
801  }
802 #else
803  saveHit((*theHC[k])[i], k);
804 #endif
805 
806  ++count;
807  double x = (*theHC[k])[i]->getEM();
808  eEM += x;
809  eEM2 += x * x;
810  x = (*theHC[k])[i]->getHadr();
811  eHAD += x;
812  eHAD2 += x * x;
813 #ifdef EDM_ML_DEBUG
814  tt += (*theHC[k])[i]->getTimeSlice();
815  ee += (*theHC[k])[i]->getIncidentEnergy();
816  zglob += std::abs((*theHC[k])[i]->getEntry().z());
817  zloc += std::abs((*theHC[k])[i]->getEntryLocal().z());
818 #endif
819  }
820 
821  double norm = (count > 0) ? 1.0 / count : 0.0;
822  eEM *= norm;
823  eEM2 *= norm;
824  eHAD *= norm;
825  eHAD2 *= norm;
826  eEM2 = std::sqrt(eEM2 - eEM * eEM);
827  eHAD2 = std::sqrt(eHAD2 - eHAD * eHAD);
828 #ifdef EDM_ML_DEBUG
829  tt *= norm;
830  ee *= norm;
831  zglob *= norm;
832  zloc *= norm;
833  edm::LogVerbatim("CaloSim") << "CaloSD: " << GetName() << " store " << count << " hits; " << wrong
834  << " track IDs not given properly and " << totalHits - count
835  << " hits not passing cuts\n EmeanEM= " << eEM << " ErmsEM= " << eEM2
836  << "\n EmeanHAD= " << eHAD << " ErmsHAD= " << eHAD2 << " TimeMean= " << tt
837  << " E0mean= " << ee << " Zglob= " << zglob << " Zloc= " << zloc << " ";
838 #endif
839  std::vector<std::unique_ptr<CaloG4Hit>>().swap(reusehit[k]);
840  if (useMap)
841  hitMap[k].erase(hitMap[k].begin(), hitMap[k].end());
842  }
843  tkMap.erase(tkMap.begin(), tkMap.end());
845 }
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:948
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:19
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:870
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 758 of file CaloSD.cc.

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

758  {
759  int id = (*trk)()->GetTrackID();
760  TrackInformation* trkI = cmsTrackInformation((*trk)());
761  int lastTrackID = -1;
762  if (trkI)
763  lastTrackID = trkI->getIDonCaloSurface();
764  if (id == lastTrackID) {
765  auto trksForThisEvent = m_trackManager->trackContainer();
766  if (!trksForThisEvent->empty()) {
767  TrackWithHistory* trkH = trksForThisEvent->back();
768  if (trkH->trackID() == id) {
769  tkMap[id] = trkH;
770 #ifdef EDM_ML_DEBUG
771  edm::LogVerbatim("CaloSim") << "CaloSD: get track " << id << " from Container of size "
772  << trksForThisEvent->size() << " with ID " << trkH->trackID();
773 #endif
774  }
775  }
776  }
777 }
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() [4/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  {
751 #ifdef EDM_ML_DEBUG
752  edm::LogVerbatim("CaloSim") << "CaloSD: Dispatched BeginOfEvent for " << GetName() << " !";
753 #endif
754  clearHits();
755  initEvent(g4Event);
756 }
Log< level::Info, true > LogVerbatim
virtual void initEvent(const BeginOfEvent *)
Definition: CaloSD.cc:868
void clearHits() override
Definition: CaloSD.cc:847

◆ update() [5/6]

void CaloSD::update
overrideprotected

Definition at line 1012 of file CaloSD.cc.

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

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

◆ update() [6/6]

void HGCalSD::update ( const BeginOfJob )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfJob *>.

Definition at line 267 of file HGCalSD.cc.

References angles_, calibCellFullHD_, calibCellFullLD_, calibCellPartHD_, calibCellPartLD_, HGCalDDDConstants::calibCellRad(), calibCellRHD_, calibCellRLD_, HGCalDDDConstants::calibCells(), calibCells_, cellOffset_, CaloSD::collName_, cos30deg_, dd4hep_, Exception, fiducialCut_, geom_mode_, HGCalDDDConstants::geomMode(), HGCalDDDConstants::getParameter(), HGCalDDDConstants::getUVMax(), guardRing_, HGCalDDDConstants::guardRingOffset(), guardRingOffset_, guardRingPartial_, hgcons_, levelT1_, levelT2_, HGCalDDDConstants::levelTop(), HGCalDDDConstants::minSlope(), missingFile_, HGCalDDDConstants::mouseBite(), mouseBite_, mouseBiteCut_, mydet_, nameX_, CaloSD::newCollection(), CaloSD::nHC_, numberingScheme_, ps_, rejectMB_, HGCalDDDConstants::sensorSizeOffset(), slopeMin_, tan30deg_, HGCalParameters::useOffset_, useSimWt_, HGCalParameters::useSimWt_, waferRot_, HGCalDDDConstants::waferSize(), and waferSize_.

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

267  {
268  if (hgcons_ != nullptr) {
271  levelT1_ = hgcons_->levelTop(0);
272  levelT2_ = hgcons_->levelTop(1);
273  if (dd4hep_) {
274  ++levelT1_;
275  ++levelT2_;
276  }
278  int useOffset = hgcons_->getParameter()->useOffset_;
279  waferSize_ = hgcons_->waferSize(false);
280  double mouseBite = hgcons_->mouseBite(false);
282  double sensorSizeOffset = hgcons_->sensorSizeOffset(false);
283  if (useOffset > 0) {
284  rejectMB_ = true;
285  fiducialCut_ = true;
286  }
287  double mouseBiteNew = (fiducialCut_) ? (mouseBite + guardRingOffset_ + sensorSizeOffset / cos30deg_) : mouseBite;
288  mouseBiteCut_ = waferSize_ * tan30deg_ - mouseBiteNew;
289 #ifdef EDM_ML_DEBUG
290  edm::LogVerbatim("HGCSim") << "HGCalSD::Initialized with mode " << geom_mode_ << " Slope cut " << slopeMin_
291  << " top Level " << levelT1_ << ":" << levelT2_ << " useSimWt " << useSimWt_ << " wafer "
292  << waferSize_ << ":" << mouseBite << ":" << guardRingOffset_ << ":" << sensorSizeOffset
293  << ":" << mouseBiteNew << ":" << mouseBiteCut_ << " useOffset " << useOffset
294  << " dd4hep " << dd4hep_;
295 #endif
296 
297  numberingScheme_ = std::make_unique<HGCalNumberingScheme>(*hgcons_, mydet_, nameX_, missingFile_);
298  if (rejectMB_)
299  mouseBite_ = std::make_unique<HGCMouseBite>(*hgcons_, angles_, mouseBiteCut_, waferRot_);
300  if (fiducialCut_) {
301  guardRing_ = std::make_unique<HGCGuardRing>(*hgcons_);
302  guardRingPartial_ = std::make_unique<HGCGuardRingPartial>(*hgcons_);
303  }
304 
305  //Now for calibration cells
308  calibCellFullHD_ = hgcons_->calibCells(true, true);
309  calibCellPartHD_ = hgcons_->calibCells(true, false);
310  calibCellFullLD_ = hgcons_->calibCells(false, true);
311  calibCellPartLD_ = hgcons_->calibCells(false, false);
312  calibCells_ = ((!calibCellFullHD_.empty()) || (!calibCellPartHD_.empty()));
313  calibCells_ |= ((!calibCellFullLD_.empty()) || (!calibCellPartLD_.empty()));
314 #ifdef EDM_ML_DEBUG
315  edm::LogVerbatim("HGCSim") << "HGCalSD::Calibration cells initialized with flag " << calibCells_;
316  edm::LogVerbatim("HGCSim") << " Radii " << calibCellRHD_ << ":" << calibCellRLD_;
317  std::ostringstream st1;
318  for (const auto& cell : calibCellFullHD_)
319  st1 << " " << cell;
320  edm::LogVerbatim("HGCSim") << calibCellFullHD_.size() << " cells for High Density full wafers: " << st1.str();
321  std::ostringstream st2;
322  for (const auto& cell : calibCellPartHD_)
323  st2 << " " << cell;
324  edm::LogVerbatim("HGCSim") << calibCellPartHD_.size() << " cells for High Density partial wafers: " << st2.str();
325  std::ostringstream st3;
326  for (const auto& cell : calibCellFullLD_)
327  st3 << " " << cell;
328  edm::LogVerbatim("HGCSim") << calibCellFullLD_.size() << " cells for Low Density full wafers: " << st3.str();
329  std::ostringstream st4;
330  for (const auto& cell : calibCellPartLD_)
331  st4 << " " << cell;
332  edm::LogVerbatim("HGCSim") << calibCellPartLD_.size() << " cells for Low Density partial wafers: " << st4.str();
333 #endif
334  } else {
335  throw cms::Exception("Unknown", "HGCalSD") << "Cannot find HGCalDDDConstants for " << nameX_ << "\n";
336  }
337  if ((nHC_ > 1) && calibCells_) {
339  cellOffset_ = std::make_unique<HGCalCellOffset>(
341  }
342 }
Log< level::Info, true > LogVerbatim
int levelT2_
Definition: HGCalSD.h:59
edm::ParameterSet const & ps_
Definition: HGCalSD.h:48
std::vector< int > calibCellPartLD_
Definition: HGCalSD.h:66
double slopeMin_
Definition: HGCalSD.h:57
const HGCalParameters * getParameter() const
std::vector< int > calibCellPartHD_
Definition: HGCalSD.h:65
void newCollection(const std::string &name, edm::ParameterSet const &p)
Definition: CaloSD.cc:176
std::unique_ptr< HGCalNumberingScheme > numberingScheme_
Definition: HGCalSD.h:49
std::string nameX_
Definition: HGCalSD.h:55
double mouseBiteCut_
Definition: HGCalSD.h:58
HGCalGeometryMode::GeometryMode geomMode() const
int nHC_
Definition: CaloSD.h:158
bool calibCells_
Definition: HGCalSD.h:63
bool rejectMB_
Definition: HGCalSD.h:61
DetId::Detector mydet_
Definition: HGCalSD.h:54
std::vector< int > calibCellFullHD_
Definition: HGCalSD.h:65
const double cos30deg_
Definition: HGCalSD.h:67
std::string missingFile_
Definition: HGCalSD.h:69
std::vector< double > angles_
Definition: HGCalSD.h:68
const HGCalDDDConstants * hgcons_
Definition: HGCalSD.h:47
int getUVMax(int type) const
const double tan30deg_
Definition: HGCalSD.h:67
double mouseBite(bool reco) const
bool waferRot_
Definition: HGCalSD.h:61
double waferSize_
Definition: HGCalSD.h:58
bool dd4hep_
Definition: HGCalSD.h:63
double calibCellRLD_
Definition: HGCalSD.h:64
double minSlope() const
HGCalGeometryMode::GeometryMode geom_mode_
Definition: HGCalSD.h:56
std::unique_ptr< HGCalCellOffset > cellOffset_
Definition: HGCalSD.h:53
bool fiducialCut_
Definition: HGCalSD.h:61
std::unique_ptr< HGCGuardRingPartial > guardRingPartial_
Definition: HGCalSD.h:51
std::vector< int > calibCellFullLD_
Definition: HGCalSD.h:66
std::vector< int > calibCells(bool hd, bool full) const
double guardRingOffset(bool reco) const
std::string collName_[2]
Definition: CaloSD.h:159
int useSimWt_
Definition: HGCalSD.h:62
std::unique_ptr< HGCGuardRing > guardRing_
Definition: HGCalSD.h:50
double sensorSizeOffset(bool reco) const
int levelT1_
Definition: HGCalSD.h:59
double calibCellRad(bool hd) const
double guardRingOffset_
Definition: HGCalSD.h:58
std::unique_ptr< HGCMouseBite > mouseBite_
Definition: HGCalSD.h:52
int levelTop(int ind=0) const
double calibCellRHD_
Definition: HGCalSD.h:64
double waferSize(bool reco) const

Member Data Documentation

◆ angles_

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

Definition at line 68 of file HGCalSD.h.

Referenced by HGCalSD(), and update().

◆ calibCell_

bool HGCalSD::calibCell_
private

Definition at line 70 of file HGCalSD.h.

Referenced by processSecondHit(), and setDetUnitId().

◆ calibCellFullHD_

std::vector<int> HGCalSD::calibCellFullHD_
private

Definition at line 65 of file HGCalSD.h.

Referenced by calibCell(), and update().

◆ calibCellFullLD_

std::vector<int> HGCalSD::calibCellFullLD_
private

Definition at line 66 of file HGCalSD.h.

Referenced by calibCell(), and update().

◆ calibCellPartHD_

std::vector<int> HGCalSD::calibCellPartHD_
private

Definition at line 65 of file HGCalSD.h.

Referenced by calibCell(), and update().

◆ calibCellPartLD_

std::vector<int> HGCalSD::calibCellPartLD_
private

Definition at line 66 of file HGCalSD.h.

Referenced by calibCell(), and update().

◆ calibCellRHD_

double HGCalSD::calibCellRHD_
private

Definition at line 64 of file HGCalSD.h.

Referenced by calibCell(), and update().

◆ calibCellRLD_

double HGCalSD::calibCellRLD_
private

Definition at line 64 of file HGCalSD.h.

Referenced by calibCell(), and update().

◆ calibCells_

bool HGCalSD::calibCells_
private

Definition at line 63 of file HGCalSD.h.

Referenced by setDetUnitId(), and update().

◆ cellOffset_

std::unique_ptr<HGCalCellOffset> HGCalSD::cellOffset_
private

Definition at line 53 of file HGCalSD.h.

Referenced by calibCell(), HGCalSD(), and update().

◆ checkID_

bool HGCalSD::checkID_
private

Definition at line 61 of file HGCalSD.h.

Referenced by HGCalSD(), and setDetUnitId().

◆ cornerMinMask_

int HGCalSD::cornerMinMask_
private

Definition at line 59 of file HGCalSD.h.

Referenced by HGCalSD(), and setDetUnitId().

◆ cos30deg_

const double HGCalSD::cos30deg_
private

Definition at line 67 of file HGCalSD.h.

Referenced by update().

◆ dd4hep_

bool HGCalSD::dd4hep_
private

Definition at line 63 of file HGCalSD.h.

Referenced by HGCalSD(), and update().

◆ distanceFromEdge_

double HGCalSD::distanceFromEdge_
private

Definition at line 57 of file HGCalSD.h.

Referenced by HGCalSD().

◆ eminHit_

double HGCalSD::eminHit_
private

Definition at line 57 of file HGCalSD.h.

Referenced by filterHit(), and HGCalSD().

◆ fiducialCut_

bool HGCalSD::fiducialCut_
private

Definition at line 61 of file HGCalSD.h.

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

◆ fraction_

double HGCalSD::fraction_
private

Definition at line 71 of file HGCalSD.h.

Referenced by calibCell(), processSecondHit(), and setDetUnitId().

◆ geom_mode_

HGCalGeometryMode::GeometryMode HGCalSD::geom_mode_
private

Definition at line 56 of file HGCalSD.h.

Referenced by update().

◆ guardRing_

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

Definition at line 50 of file HGCalSD.h.

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

◆ guardRingOffset_

double HGCalSD::guardRingOffset_
private

Definition at line 58 of file HGCalSD.h.

Referenced by update().

◆ guardRingPartial_

std::unique_ptr<HGCGuardRingPartial> HGCalSD::guardRingPartial_
private

Definition at line 51 of file HGCalSD.h.

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

◆ hgcons_

const HGCalDDDConstants* HGCalSD::hgcons_
private

Definition at line 47 of file HGCalSD.h.

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

◆ levelT1_

int HGCalSD::levelT1_
private

Definition at line 59 of file HGCalSD.h.

Referenced by setDetUnitId(), and update().

◆ levelT2_

int HGCalSD::levelT2_
private

Definition at line 59 of file HGCalSD.h.

Referenced by setDetUnitId(), and update().

◆ missingFile_

std::string HGCalSD::missingFile_
private

Definition at line 69 of file HGCalSD.h.

Referenced by HGCalSD(), and update().

◆ mouseBite_

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

Definition at line 52 of file HGCalSD.h.

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

◆ mouseBiteCut_

double HGCalSD::mouseBiteCut_
private

Definition at line 58 of file HGCalSD.h.

Referenced by update().

◆ mydet_

DetId::Detector HGCalSD::mydet_
private

Definition at line 54 of file HGCalSD.h.

Referenced by HGCalSD(), and update().

◆ myName_

std::string HGCalSD::myName_
private

Definition at line 46 of file HGCalSD.h.

Referenced by HGCalSD().

◆ nameX_

std::string HGCalSD::nameX_
private

Definition at line 55 of file HGCalSD.h.

Referenced by HGCalSD(), and update().

◆ numberingScheme_

std::unique_ptr<HGCalNumberingScheme> HGCalSD::numberingScheme_
private

Definition at line 49 of file HGCalSD.h.

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

◆ ps_

edm::ParameterSet const& HGCalSD::ps_
private

Definition at line 48 of file HGCalSD.h.

Referenced by update().

◆ rejectMB_

bool HGCalSD::rejectMB_
private

Definition at line 61 of file HGCalSD.h.

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

◆ slopeMin_

double HGCalSD::slopeMin_
private

Definition at line 57 of file HGCalSD.h.

Referenced by getEnergyDeposit(), and update().

◆ storeAllG4Hits_

bool HGCalSD::storeAllG4Hits_
private

Definition at line 60 of file HGCalSD.h.

Referenced by HGCalSD().

◆ tan30deg_

const double HGCalSD::tan30deg_
private

Definition at line 67 of file HGCalSD.h.

Referenced by update().

◆ useSimWt_

int HGCalSD::useSimWt_
private

Definition at line 62 of file HGCalSD.h.

Referenced by setDetUnitId(), and update().

◆ verbose_

int HGCalSD::verbose_
private

Definition at line 62 of file HGCalSD.h.

Referenced by HGCalSD(), and setDetUnitId().

◆ waferRot_

bool HGCalSD::waferRot_
private

Definition at line 61 of file HGCalSD.h.

Referenced by HGCalSD(), and update().

◆ waferSize_

double HGCalSD::waferSize_
private

Definition at line 58 of file HGCalSD.h.

Referenced by update().

◆ weight_

double HGCalSD::weight_
private

Definition at line 58 of file HGCalSD.h.

Referenced by getEnergyDeposit(), and setDetUnitId().