CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Attributes
HFChamberSD Class Reference

#include <HFChamberSD.h>

Inheritance diagram for HFChamberSD:
SensitiveCaloDetector SensitiveDetector

Public Member Functions

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

Protected Member Functions

virtual void clearHits ()
 
virtual void fillHits (edm::PCaloHitContainer &, std::string)
 
virtual uint32_t setDetUnitId (G4Step *)
 

Private Attributes

const SimTrackManagerm_trackManager
 
HFShowerG4HitsCollectiontheHC
 
G4int theHCID
 
std::string theName
 
int theNSteps
 

Additional Inherited Members

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

Detailed Description

Definition at line 19 of file HFChamberSD.h.

Constructor & Destructor Documentation

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

Definition at line 19 of file HFChamberSD.cc.

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

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

Definition at line 47 of file HFChamberSD.cc.

References theHC.

47  {
48  if (theHC) delete theHC;
49 }
HFShowerG4HitsCollection * theHC
Definition: HFChamberSD.h:46

Member Function Documentation

void HFChamberSD::clear ( void  )
virtual

Definition at line 104 of file HFChamberSD.cc.

References theNSteps.

Referenced by EndOfEvent().

104  {
105  theNSteps = 0;
106 }
void HFChamberSD::clearHits ( )
protectedvirtual

Implements SensitiveDetector.

Definition at line 112 of file HFChamberSD.cc.

112 {}
void HFChamberSD::DrawAll ( )
virtual

Definition at line 108 of file HFChamberSD.cc.

108 {}
void HFChamberSD::EndOfEvent ( G4HCofThisEvent *  HCE)
virtual

Reimplemented from SensitiveDetector.

Definition at line 98 of file HFChamberSD.cc.

References clear(), LogDebug, and theHC.

98  {
99 
100  LogDebug("FiberSim") << "HFChamberSD: Sees" << theHC->entries() << " hits";
101  clear();
102 }
#define LogDebug(id)
HFShowerG4HitsCollection * theHC
Definition: HFChamberSD.h:46
virtual void clear()
Definition: HFChamberSD.cc:104
void HFChamberSD::fillHits ( edm::PCaloHitContainer ,
std::string   
)
protectedvirtual

Implements SensitiveCaloDetector.

Definition at line 119 of file HFChamberSD.cc.

119 {}
void HFChamberSD::Initialize ( G4HCofThisEvent *  HCE)
virtual

Reimplemented from SensitiveDetector.

Definition at line 51 of file HFChamberSD.cc.

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

51  {
52 
53  LogDebug("FiberSim") << "HFChamberSD : Initialize called for " << GetName();
54  theHC = new HFShowerG4HitsCollection(GetName(), collectionName[0]);
55  if (theHCID<0)
56  theHCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
57  HCE->AddHitsCollection(theHCID, theHC);
58 
59 }
#define LogDebug(id)
HFShowerG4HitsCollection * theHC
Definition: HFChamberSD.h:46
std::string const collectionName[nCollections]
Definition: Collections.h:45
G4int theHCID
Definition: HFChamberSD.h:45
G4THitsCollection< HFShowerG4Hit > HFShowerG4HitsCollection
Definition: HFShowerG4Hit.h:60
void HFChamberSD::PrintAll ( )
virtual

Definition at line 110 of file HFChamberSD.cc.

110 {}
G4bool HFChamberSD::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *  ROhist 
)
virtual

Implements SensitiveDetector.

Definition at line 61 of file HFChamberSD.cc.

References DeDxDiscriminatorTools::charge(), LogDebug, NULL, setDetUnitId(), HFShowerG4Hit::setGlobalPos(), HFShowerG4Hit::setLocalPos(), HFShowerG4Hit::setPrimMomDir(), theHC, theNSteps, and cond::rpcobgas::time.

61  {
62 
63  //do not process hits other than primary particle hits:
64  double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
65  int trackID = aStep->GetTrack()->GetTrackID();
66  if(charge == 0. || trackID != 1 ||aStep->GetTrack()->GetParentID() != 0 || aStep->GetTrack()->GetCreatorProcess() != NULL) return false;
67  ++theNSteps;
68  //if(theNSteps>1)return false;
69 
70  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
71  const G4VTouchable* touch = preStepPoint->GetTouchable();
72  int detID = setDetUnitId(aStep);
73 
74  double edep = aStep->GetTotalEnergyDeposit();
75  double time = (preStepPoint->GetGlobalTime())/ns;
76 
77  G4ThreeVector globalPos = preStepPoint->GetPosition();
78  G4ThreeVector localPos = touch->GetHistory()->GetTopTransform().TransformPoint(globalPos);
79  const G4DynamicParticle* particle = aStep->GetTrack()->GetDynamicParticle();
80  G4ThreeVector momDir = particle->GetMomentumDirection();
81 
82  HFShowerG4Hit *aHit = new HFShowerG4Hit(detID, trackID, edep, time);
83  aHit->setLocalPos(localPos);
84  aHit->setGlobalPos(globalPos);
85  aHit->setPrimMomDir(momDir);
86 
87  LogDebug("FiberSim") << "HFChamberSD: Hit created in ("
88  << touch->GetVolume(0)->GetLogicalVolume()->GetName()
89  << ") " << " ID " << detID << " Track " << trackID
90  << " Edep: " << edep/MeV << " MeV; Time: " << time
91  << " ns; Position (local) " << localPos << " (global ) "
92  << globalPos << " direction " << momDir;
93 
94  theHC->insert(aHit);
95  return true;
96 }
#define LogDebug(id)
void setLocalPos(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:47
#define NULL
Definition: scimark2.h:8
virtual uint32_t setDetUnitId(G4Step *)
Definition: HFChamberSD.cc:114
double charge(const std::vector< uint8_t > &Ampls)
HFShowerG4HitsCollection * theHC
Definition: HFChamberSD.h:46
void setPrimMomDir(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:49
void setGlobalPos(const G4ThreeVector &xyz)
Definition: HFShowerG4Hit.h:48
uint32_t HFChamberSD::setDetUnitId ( G4Step *  aStep)
protectedvirtual

Implements SensitiveDetector.

Definition at line 114 of file HFChamberSD.cc.

Referenced by ProcessHits().

114  {
115  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
116  return (touch->GetReplicaNumber(0));
117 }

Member Data Documentation

const SimTrackManager* HFChamberSD::m_trackManager
private

Definition at line 43 of file HFChamberSD.h.

HFShowerG4HitsCollection* HFChamberSD::theHC
private

Definition at line 46 of file HFChamberSD.h.

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

G4int HFChamberSD::theHCID
private

Definition at line 45 of file HFChamberSD.h.

Referenced by Initialize().

std::string HFChamberSD::theName
private

Definition at line 42 of file HFChamberSD.h.

int HFChamberSD::theNSteps
private

Definition at line 47 of file HFChamberSD.h.

Referenced by clear(), and ProcessHits().