CMS 3D CMS Logo

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

#include <FiberSD.h>

Inheritance diagram for FiberSD:
SensitiveCaloDetector Observer< const BeginOfJob * > Observer< const BeginOfRun * > Observer< const BeginOfEvent * > Observer< const EndOfEvent * > SensitiveDetector

Public Member Functions

void clear () override
 
void DrawAll () override
 
void EndOfEvent (G4HCofThisEvent *HCE) override
 
 FiberSD (std::string, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
 
void Initialize (G4HCofThisEvent *HCE) override
 
void PrintAll () override
 
G4bool ProcessHits (G4Step *aStep, G4TouchableHistory *ROhist) override
 
 ~FiberSD () override
 
- Public Member Functions inherited from SensitiveCaloDetector
 SensitiveCaloDetector (std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
 
- Public Member Functions inherited from SensitiveDetector
virtual void AssignSD (const std::string &vname)
 
Local3DPoint ConvertToLocal3DPoint (const G4ThreeVector &point)
 
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
Local3DPoint FinalStepPosition (G4Step *s, coordinates)
 
virtual std::vector< std::string > getNames ()
 
void Initialize (G4HCofThisEvent *eventHC) override
 
Local3DPoint InitialStepPosition (G4Step *s, coordinates)
 
std::string nameOfSD ()
 
void NaNTrap (G4Step *step)
 
void Register ()
 
 SensitiveDetector (std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &, edm::ParameterSet const &p)
 
 ~SensitiveDetector () override
 
- Public Member Functions inherited from Observer< const BeginOfJob * >
 Observer ()
 
void slotForUpdate (const BeginOfJob * iT)
 
virtual ~Observer ()
 
- 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 EndOfEvent * >
 Observer ()
 
void slotForUpdate (const EndOfEvent * iT)
 
virtual ~Observer ()
 

Protected Member Functions

void clearHits () override
 
void fillHits (edm::PCaloHitContainer &, std::string) override
 
uint32_t setDetUnitId (G4Step *) override
 
void update (const BeginOfJob *) override
 This routine will be called when the appropriate signal arrives. More...
 
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 ::EndOfEvent *) override
 
- 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 Attributes

const SimTrackManagerm_trackManager
 
FiberG4HitsCollectiontheHC
 
G4int theHCID
 
std::string theName
 
HFShowertheShower
 

Additional Inherited Members

- Public Types inherited from SensitiveDetector
enum  coordinates { WorldCoordinates, LocalCoordinates }
 

Detailed Description

Definition at line 26 of file FiberSD.h.

Constructor & Destructor Documentation

FiberSD::FiberSD ( std::string  name,
const DDCompactView cpv,
const SensitiveDetectorCatalog clg,
edm::ParameterSet const &  p,
const SimTrackManager manager 
)

Definition at line 21 of file FiberSD.cc.

References SensitiveDetector::AssignSD(), ecaldqm::collectionName, g4SimHits_cfi::HFShower, LogDebug, SensitiveDetectorCatalog::logicalNames(), SensitiveDetector::Register(), and theShower.

23  :
24  SensitiveCaloDetector(name, cpv, clg, p), theName(name),
25  m_trackManager(manager), theHCID(-1), theHC(nullptr) {
26 
27  collectionName.insert(name);
28  LogDebug("FiberSim") << "***************************************************"
29  << "\n"
30  << "* *"
31  << "\n"
32  << "* Constructing a FiberSD with name " << GetName()
33  << "\n"
34  << "* *"
35  << "\n"
36  << "***************************************************";
37  theShower = new HFShower(name, cpv, p, 1);
38 
39  //
40  // Now attach the right detectors (LogicalVolumes) to me
41  //
42  const std::vector<std::string>& lvNames = clg.logicalNames(name);
43  this->Register();
44  for (std::vector<std::string>::const_iterator it=lvNames.begin();
45  it !=lvNames.end(); it++){
46  this->AssignSD(*it);
47  LogDebug("FiberSim") << "FiberSD : Assigns SD to LV " << (*it);
48  }
49 }
#define LogDebug(id)
const SimTrackManager * m_trackManager
Definition: FiberSD.h:59
std::string theName
Definition: FiberSD.h:58
SensitiveCaloDetector(std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
const std::vector< std::string > & logicalNames(const std::string &readoutName) const
virtual void AssignSD(const std::string &vname)
std::string const collectionName[nCollections]
Definition: Collections.h:47
HFShower * theShower
Definition: FiberSD.h:60
FiberG4HitsCollection * theHC
Definition: FiberSD.h:63
G4int theHCID
Definition: FiberSD.h:62
FiberSD::~FiberSD ( )
override

Definition at line 51 of file FiberSD.cc.

References theHC, and theShower.

51  {
52 
53  if (theShower) delete theShower;
54  if (theHC) delete theHC;
55 }
HFShower * theShower
Definition: FiberSD.h:60
FiberG4HitsCollection * theHC
Definition: FiberSD.h:63

Member Function Documentation

void FiberSD::clear ( void  )
override

Definition at line 125 of file FiberSD.cc.

Referenced by EndOfEvent().

125 {}
void FiberSD::clearHits ( )
overrideprotectedvirtual

Implements SensitiveDetector.

Definition at line 152 of file FiberSD.cc.

152 {}
void FiberSD::DrawAll ( )
override

Definition at line 127 of file FiberSD.cc.

127 {}
void FiberSD::EndOfEvent ( G4HCofThisEvent *  HCE)
override

Definition at line 118 of file FiberSD.cc.

References clear(), gather_cfg::cout, LogDebug, and theHC.

118  {
119 
120  LogDebug("FiberSim") << "FiberSD: Sees" << theHC->entries() << " hits";
121  clear();
122  std::cout<<"theHC entries = "<<theHC->entries()<<std::endl;
123 }
#define LogDebug(id)
FiberG4HitsCollection * theHC
Definition: FiberSD.h:63
void clear() override
Definition: FiberSD.cc:125
void FiberSD::fillHits ( edm::PCaloHitContainer ,
std::string   
)
overrideprotectedvirtual

Implements SensitiveCaloDetector.

Definition at line 162 of file FiberSD.cc.

162 {}
void FiberSD::Initialize ( G4HCofThisEvent *  HCE)
override

Definition at line 57 of file FiberSD.cc.

References ecaldqm::collectionName, LogDebug, theHC, and theHCID.

57  {
58 
59  LogDebug("FiberSim") << "FiberSD : Initialize called for " << GetName();
60  theHC = new FiberG4HitsCollection(GetName(), collectionName[0]);
61  if (theHCID<0)
62  theHCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
63  HCE->AddHitsCollection(theHCID, theHC);
64 
65 }
#define LogDebug(id)
std::string const collectionName[nCollections]
Definition: Collections.h:47
FiberG4HitsCollection * theHC
Definition: FiberSD.h:63
G4THitsCollection< FiberG4Hit > FiberG4HitsCollection
Definition: FiberG4Hit.h:58
G4int theHCID
Definition: FiberSD.h:62
void FiberSD::PrintAll ( )
override

Definition at line 129 of file FiberSD.cc.

129 {}
G4bool FiberSD::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *  ROhist 
)
overridevirtual

Implements SensitiveDetector.

Definition at line 67 of file FiberSD.cc.

References gather_cfg::cout, particleFlowClusterECALTimeSelected_cfi::depth, HFShower::getHits(), hfClusterShapes_cfi::hits, mps_fire::i, LogDebug, position, setDetUnitId(), theHC, and theShower.

67  {
68 
69  //std::vector<HFShower::Hit> hits = theShower->getHits(aStep);
70  double zoffset = 1000;
71  std::vector<HFShower::Hit> hits = theShower->getHits(aStep,true,zoffset);
72 
73 
74  if (!hits.empty()) {
75  std::vector<HFShowerPhoton> thePE;
76  for (unsigned int i=0; i<hits.size(); i++) {
77  //std::cout<<"hit position z "<<hits[i].position.z()<<std::endl;
78  HFShowerPhoton pe = HFShowerPhoton(hits[i].position.x(),
79  hits[i].position.y(),
80  hits[i].position.z(),
81  hits[i].wavelength, hits[i].time);
82  thePE.push_back(pe);
83  }
84  int trackID = aStep->GetTrack()->GetTrackID();
85  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
86  const G4VTouchable* touch = preStepPoint->GetTouchable();
87  G4LogicalVolume* lv = touch->GetVolume(0)->GetLogicalVolume();
88  int depth = (touch->GetReplicaNumber(0))%10;
89  int detID = setDetUnitId(aStep);
90  math::XYZPoint theHitPos(preStepPoint->GetPosition().x(),
91  preStepPoint->GetPosition().y(),
92  preStepPoint->GetPosition().z());
93  //std::cout<<"presteppoint position z "<<preStepPoint->GetPosition().z()<<std::endl;
94 
95  FiberG4Hit *aHit = new FiberG4Hit(lv, detID, depth, trackID);
96  std::cout<<"hit size "<<hits.size()<<" npe"<<aHit->npe()<<std::endl;
97  std::cout<<"pre hit position "<<aHit->hitPos()<<std::endl;
98  aHit->setNpe(hits.size());
99  aHit->setPos(theHitPos);
100  aHit->setTime(preStepPoint->GetGlobalTime());
101  aHit->setPhoton(thePE);
102  std::cout<<"ShowerPhoton position "<<thePE[0].x()<<" "<<thePE[0].y()<<" "<<thePE[0].z()<<std::endl;
103 
104  LogDebug("FiberSim") << "FiberSD: Hit created at " << lv->GetName()
105  << " DetID: " << aHit->towerId() << " Depth: "
106  << aHit->depth() << " Track ID: " << aHit->trackId()
107  << " Nb. of Cerenkov Photons: " << aHit->npe()
108  << " Time: " << aHit->time() << " at "
109  << aHit->hitPos();
110  for (unsigned int i=0; i<thePE.size(); i++)
111  LogDebug("FiberSim") << "FiberSD: PE[" << i << "] " << thePE[i];
112 
113  theHC->insert(aHit);
114  }
115  return true;
116 }
#define LogDebug(id)
std::vector< Hit > getHits(G4Step *aStep, double weight)
Definition: HFShower.cc:47
HFShower * theShower
Definition: FiberSD.h:60
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
FiberG4HitsCollection * theHC
Definition: FiberSD.h:63
static int position[264][3]
Definition: ReadPGInfo.cc:509
uint32_t setDetUnitId(G4Step *) override
Definition: FiberSD.cc:154
uint32_t FiberSD::setDetUnitId ( G4Step *  aStep)
overrideprotectedvirtual

Implements SensitiveDetector.

Definition at line 154 of file FiberSD.cc.

Referenced by ProcessHits().

154  {
155  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
156  int fibre = (touch->GetReplicaNumber(1))%10;
157  int cell = (touch->GetReplicaNumber(2));
158  int tower = (touch->GetReplicaNumber(3));
159  return ((tower*1000+cell)*10+fibre);
160 }
void FiberSD::update ( const BeginOfJob )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfJob * >.

Definition at line 131 of file FiberSD.cc.

References Exception, edm::EventSetup::get(), HFShower::initRun(), and theShower.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

131  {
132 
133  const edm::EventSetup* es = (*job)();
135  es->get<HcalSimNumberingRecord>().get(hdc);
136  if (hdc.isValid()) {
137  HcalDDDSimConstants *hcalConstants = (HcalDDDSimConstants*)(&(*hdc));
138  theShower->initRun(nullptr, hcalConstants);
139  } else {
140  edm::LogError("HcalSim") << "HCalSD : Cannot find HcalDDDSimConstant";
141  throw cms::Exception("Unknown", "HCalSD") << "Cannot find HcalDDDSimConstant" << "\n";
142  }
143 
144 }
void initRun(G4ParticleTable *, HcalDDDSimConstants *)
Definition: HFShower.cc:454
HFShower * theShower
Definition: FiberSD.h:60
const T & get() const
Definition: EventSetup.h:55
void FiberSD::update ( const BeginOfRun )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 146 of file FiberSD.cc.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

146 {}
void FiberSD::update ( const BeginOfEvent )
overrideprotectedvirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 148 of file FiberSD.cc.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

148 {}
void FiberSD::update ( const ::EndOfEvent )
overrideprotected

Member Data Documentation

const SimTrackManager* FiberSD::m_trackManager
private

Definition at line 59 of file FiberSD.h.

FiberG4HitsCollection* FiberSD::theHC
private

Definition at line 63 of file FiberSD.h.

Referenced by EndOfEvent(), Initialize(), ProcessHits(), and ~FiberSD().

G4int FiberSD::theHCID
private

Definition at line 62 of file FiberSD.h.

Referenced by Initialize().

std::string FiberSD::theName
private

Definition at line 58 of file FiberSD.h.

HFShower* FiberSD::theShower
private

Definition at line 60 of file FiberSD.h.

Referenced by FiberSD(), ProcessHits(), update(), and ~FiberSD().