CMS 3D CMS Logo

FiberSD.cc
Go to the documentation of this file.
9 
10 #include "G4VPhysicalVolume.hh"
11 #include "G4PVPlacement.hh"
12 #include "G4HCofThisEvent.hh"
13 #include "G4TouchableHistory.hh"
14 #include "G4Track.hh"
15 #include "G4Step.hh"
16 #include "G4VSolid.hh"
17 #include "G4DynamicParticle.hh"
18 #include "G4ParticleDefinition.hh"
19 #include "G4SDManager.hh"
20 #include "G4ios.hh"
21 
23  const edm::EventSetup& es,
24  const SensitiveDetectorCatalog& clg,
25  edm::ParameterSet const& p,
26  const SimTrackManager* manager)
27  : SensitiveCaloDetector(iname, es, clg, p),
28  m_trackManager(manager),
29  theShower(nullptr),
30  theHCID(-1),
31  theHC(nullptr) {
32  // Get pointer to HcalDDDConstant and HcalSimulationConstants
34  es.get<HcalSimNumberingRecord>().get(hdsc);
35  if (!hdsc.isValid()) {
36  edm::LogError("FiberSim") << "FiberSD : Cannot find HcalDDDSimulationConstant";
37  throw cms::Exception("Unknown", "FiberSD") << "Cannot find HcalDDDSimulationConstant\n";
38  }
39  const HcalSimulationConstants* hsps = hdsc.product();
41  es.get<HcalSimNumberingRecord>().get(hdc);
42  if (hdc.isValid()) {
43  const HcalDDDSimConstants* hcalConstants = hdc.product();
44  theShower = new HFShower(iname, hcalConstants, hsps->hcalsimpar(), p, 1);
45  } else {
46  edm::LogError("FiberSim") << "FiberSD : Cannot find HcalDDDSimConstant";
47  throw cms::Exception("Unknown", "FiberSD") << "Cannot find HcalDDDSimConstant\n";
48  }
49 }
50 
52  delete theShower;
53  delete theHC;
54 }
55 
56 void FiberSD::Initialize(G4HCofThisEvent* HCE) {
57  LogDebug("FiberSim") << "FiberSD : Initialize called for " << GetName();
58  theHC = new FiberG4HitsCollection(GetName(), collectionName[0]);
59  if (theHCID < 0)
60  theHCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
61  HCE->AddHitsCollection(theHCID, theHC);
62 }
63 
64 G4bool FiberSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) {
65  //std::vector<HFShower::Hit> hits = theShower->getHits(aStep);
66  double zoffset = 1000;
67  std::vector<HFShower::Hit> hits = theShower->getHits(aStep, true, zoffset);
68 
69  if (!hits.empty()) {
70  std::vector<HFShowerPhoton> thePE;
71  for (unsigned int i = 0; i < hits.size(); i++) {
72  //std::cout<<"hit position z "<<hits[i].position.z()<<std::endl;
74  hits[i].position.x(), hits[i].position.y(), hits[i].position.z(), hits[i].wavelength, hits[i].time);
75  thePE.push_back(pe);
76  }
77  int trackID = aStep->GetTrack()->GetTrackID();
78  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
79  const G4VTouchable* touch = preStepPoint->GetTouchable();
80  G4LogicalVolume* lv = touch->GetVolume(0)->GetLogicalVolume();
81  int depth = (touch->GetReplicaNumber(0)) % 10;
82  int detID = setDetUnitId(aStep);
83  math::XYZPoint theHitPos(
84  preStepPoint->GetPosition().x(), preStepPoint->GetPosition().y(), preStepPoint->GetPosition().z());
85  //std::cout<<"presteppoint position z "<<preStepPoint->GetPosition().z()<<std::endl;
86 
87  FiberG4Hit* aHit = new FiberG4Hit(lv, detID, depth, trackID);
88  std::cout << "hit size " << hits.size() << " npe" << aHit->npe() << std::endl;
89  std::cout << "pre hit position " << aHit->hitPos() << std::endl;
90  aHit->setNpe(hits.size());
91  aHit->setPos(theHitPos);
92  aHit->setTime(preStepPoint->GetGlobalTime());
93  aHit->setPhoton(thePE);
94  std::cout << "ShowerPhoton position " << thePE[0].x() << " " << thePE[0].y() << " " << thePE[0].z() << std::endl;
95 
96  LogDebug("FiberSim") << "FiberSD: Hit created at " << lv->GetName() << " DetID: " << aHit->towerId()
97  << " Depth: " << aHit->depth() << " Track ID: " << aHit->trackId()
98  << " Nb. of Cerenkov Photons: " << aHit->npe() << " Time: " << aHit->time() << " at "
99  << aHit->hitPos();
100  for (unsigned int i = 0; i < thePE.size(); i++)
101  LogDebug("FiberSim") << "FiberSD: PE[" << i << "] " << thePE[i];
102 
103  theHC->insert(aHit);
104  }
105  return true;
106 }
107 
108 void FiberSD::EndOfEvent(G4HCofThisEvent* HCE) {
109  LogDebug("FiberSim") << "FiberSD: Sees" << theHC->entries() << " hits";
110  clear();
111  std::cout << "theHC entries = " << theHC->entries() << std::endl;
112 }
113 
114 void FiberSD::clear() {}
115 
117 
119 
120 void FiberSD::update(const BeginOfJob* job) {}
121 
123 
125 
126 void FiberSD::update(const ::EndOfEvent*) {}
127 
129 
130 uint32_t FiberSD::setDetUnitId(const G4Step* aStep) {
131  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
132  int fibre = (touch->GetReplicaNumber(1)) % 10;
133  int cell = (touch->GetReplicaNumber(2));
134  int tower = (touch->GetReplicaNumber(3));
135  return ((tower * 1000 + cell) * 10 + fibre);
136 }
137 
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
SimTrackManager
Definition: SimTrackManager.h:35
mps_fire.i
i
Definition: mps_fire.py:428
FiberSD::FiberSD
FiberSD(const std::string &, const edm::EventSetup &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
Definition: FiberSD.cc:22
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
ESHandle.h
HcalSimNumberingRecord.h
FiberSD::update
void update(const BeginOfJob *) override
This routine will be called when the appropriate signal arrives.
Definition: FiberSD.cc:120
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
FiberSD::theHC
FiberG4HitsCollection * theHC
Definition: FiberSD.h:61
gather_cfg.cout
cout
Definition: gather_cfg.py:144
FiberSD::~FiberSD
~FiberSD() override
Definition: FiberSD.cc:51
hgcalTowerProducer_cfi.tower
tower
Definition: hgcalTowerProducer_cfi.py:4
FiberSD::EndOfEvent
void EndOfEvent(G4HCofThisEvent *HCE) override
Definition: FiberSD.cc:108
FiberSD::fillHits
void fillHits(edm::PCaloHitContainer &, const std::string &) override
Definition: FiberSD.cc:138
FiberSD::clear
void clear() override
Definition: FiberSD.cc:114
FiberG4Hit
Definition: FiberG4Hit.h:14
HcalDDDSimConstants
Definition: HcalDDDSimConstants.h:24
HcalSimulationConstants::hcalsimpar
const HcalSimulationParameters * hcalsimpar() const
Definition: HcalSimulationConstants.h:20
SensitiveCaloDetector
Definition: SensitiveCaloDetector.h:10
Calorimetry_cff.HFShower
HFShower
Definition: Calorimetry_cff.py:264
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
FiberSD::DrawAll
void DrawAll() override
Definition: FiberSD.cc:116
FiberSD::theHCID
G4int theHCID
Definition: FiberSD.h:60
HcalSimulationConstants
Definition: HcalSimulationConstants.h:15
edm::ESHandle
Definition: DTSurvey.h:22
SensitiveDetectorCatalog
Definition: SensitiveDetectorCatalog.h:10
BeginOfJob
Definition: BeginOfJob.h:8
bysipixelclustmulteventfilter_cfi.collectionName
collectionName
Definition: bysipixelclustmulteventfilter_cfi.py:5
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
FiberSD::ProcessHits
G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist) override
Definition: FiberSD.cc:64
FiberSD::clearHits
void clearHits() override
Definition: FiberSD.cc:128
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
BeginOfEvent
Definition: BeginOfEvent.h:6
BeginOfRun
Definition: BeginOfRun.h:6
edm::EventSetup
Definition: EventSetup.h:57
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
edm::ESHandleBase::isValid
bool isValid() const
Definition: ESHandle.h:44
FiberSD::theShower
HFShower * theShower
Definition: FiberSD.h:58
FiberSD.h
Exception
Definition: hltDiff.cc:246
HFShowerPhoton
Definition: HFShowerPhoton.h:13
Point3D.h
HcalSimulationConstants.h
edm::PCaloHitContainer
std::vector< PCaloHit > PCaloHitContainer
Definition: PCaloHitContainer.h:8
EventSetup.h
FiberSD::PrintAll
void PrintAll() override
Definition: FiberSD.cc:118
HFShowerPhoton.h
HFShower::getHits
std::vector< Hit > getHits(const G4Step *aStep, double weight)
Definition: HFShower.cc:42
HcalSimNumberingRecord
Definition: HcalSimNumberingRecord.h:25
FiberG4HitsCollection
G4THitsCollection< FiberG4Hit > FiberG4HitsCollection
Definition: FiberG4Hit.h:54
FiberSD::setDetUnitId
uint32_t setDetUnitId(const G4Step *) override
Definition: FiberSD.cc:130
FiberSD::Initialize
void Initialize(G4HCofThisEvent *HCE) override
Definition: FiberSD.cc:56
HcalDDDSimConstants.h