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 (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 16 of file HFChamberSD.cc.

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

18  :
19  SensitiveCaloDetector(name, cpv, clg, p), theName(name),
20  m_trackManager(manager), theHCID(-1), theHC(0), theNSteps(0) {
21 
22  collectionName.insert(name);
23  LogDebug("FiberSim") << "***************************************************"
24  << "\n"
25  << "* *"
26  << "\n"
27  << "* Constructing a HFChamberSD with name " << GetName()
28  << "\n"
29  << "* *"
30  << "\n"
31  << "***************************************************";
32  //
33  // Now attach the right detectors (LogicalVolumes) to me
34  //
35  std::vector<std::string> lvNames = clg.logicalNames(name);
36  this->Register();
37  for (std::vector<std::string>::iterator it=lvNames.begin();
38  it !=lvNames.end(); it++){
39  this->AssignSD(*it);
40  LogDebug("FiberSim") << "HFChamberSD : Assigns SD to LV " << (*it);
41  }
42 }
#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:39
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 44 of file HFChamberSD.cc.

References theHC.

44  {
45  if (theHC) delete theHC;
46 }
HFShowerG4HitsCollection * theHC
Definition: HFChamberSD.h:46

Member Function Documentation

void HFChamberSD::clear ( void  )
virtual

Definition at line 101 of file HFChamberSD.cc.

References theNSteps.

Referenced by EndOfEvent().

101  {
102  theNSteps = 0;
103 }
void HFChamberSD::clearHits ( )
protectedvirtual

Implements SensitiveDetector.

Definition at line 109 of file HFChamberSD.cc.

109 {}
void HFChamberSD::DrawAll ( )
virtual

Definition at line 105 of file HFChamberSD.cc.

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

Reimplemented from SensitiveDetector.

Definition at line 95 of file HFChamberSD.cc.

References clear(), LogDebug, and theHC.

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

Implements SensitiveCaloDetector.

Definition at line 116 of file HFChamberSD.cc.

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

Reimplemented from SensitiveDetector.

Definition at line 48 of file HFChamberSD.cc.

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

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

Definition at line 107 of file HFChamberSD.cc.

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

Implements SensitiveDetector.

Definition at line 58 of file HFChamberSD.cc.

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

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

Implements SensitiveDetector.

Definition at line 111 of file HFChamberSD.cc.

Referenced by ProcessHits().

111  {
112  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
113  return (touch->GetReplicaNumber(0));
114 }

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().