BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
BesMucDigitizer.cc
Go to the documentation of this file.
1//---------------------------------------------------------------------------//
2// BOOST --- BESIII Object_Oriented Simulation Tool //
3//---------------------------------------------------------------------------//
4//Description:
5//Author: Youzy
6//Created: Mar, 2004
7//Modified:
8//Comment:
9//---------------------------------------------------------------------------//
10//$Id: BesMucDigitizer.cc
11
12#include "BesMucDigitizer.hh"
13#include "BesMucDigit.hh"
14#include "BesMucDigi.hh"
15#include "BesMucHit.hh"
16#include "G4DigiManager.hh"
17#include "Randomize.hh"
18
19#include "GaudiKernel/ISvcLocator.h"
20#include "GaudiKernel/Bootstrap.h"
21#include "GaudiKernel/IDataProviderSvc.h"
22#include "G4Svc/IG4Svc.h"
23#include "G4Svc/G4Svc.h"
24
25
26const G4int BesMucDigitizer::m_nPartMax;
27const G4int BesMucDigitizer::m_nSegMax;
28const G4int BesMucDigitizer::m_nGapMax;
29const G4int BesMucDigitizer::m_nStripMax;
30
32:G4VDigitizerModule(modName)
33{
34 collectionName.push_back("BesMucDigisCollection");
35 m_besMucDigisCollection=0;
36
37 //Standard unit: length in mm; time in ns; energy in MeV; att in mm;
38 //Here: att in mm; vel in m/s; threshold in MeV; mucRes in ps;
39
40
41 //retrieve G4Svc
42 ISvcLocator* svcLocator = Gaudi::svcLocator();
43 IG4Svc* tmpSvc;
44 StatusCode sc=svcLocator->service("G4Svc", tmpSvc);
45 m_G4Svc=dynamic_cast<G4Svc *>(tmpSvc);
46
47 //get Muc Ntuple from G4Svc
48 if(m_G4Svc->MucRootFlag())
49 {
50 m_tupleMuc = m_G4Svc->GetTupleMuc();
51 sc = m_tupleMuc->addItem("part",m_part);
52 sc = m_tupleMuc->addItem("seg",m_seg);
53 sc = m_tupleMuc->addItem("gap",m_gap);
54 sc = m_tupleMuc->addItem("strip",m_strip);
55
56 }
57
58
59
60
61 Initialize();
62}
63
65{
66}
67
68void BesMucDigitizer::Initialize()
69{
70 for(G4int i = 0; i < m_nPartMax; i++) {
71 for(G4int j = 0; j < m_nSegMax; j++) {
72 for(G4int k = 0; k < m_nGapMax; k++) {
73 for(G4int l = 0; l < m_nStripMax; l++) {
74 m_stripID[i][j][k][l] = 0;
75 }
76 }
77 }
78 }
79}
80
81
83{
84 Initialize();
85
86 m_besMucDigisCollection = new BesMucDigisCollection(moduleName, collectionName[0]);
87 G4DigiManager* DigiMan = G4DigiManager::GetDMpointer();
88
89 //hits collection ID
90 G4int THCID;
91 THCID = DigiMan->GetHitsCollectionID("BesMucHitsCollection");
92
93 //hits collection
94 BesMucHitsCollection* THC = 0;
95 THC = (BesMucHitsCollection*) (DigiMan->GetHitsCollection(THCID));
96
97 if(THC) {
98 G4int trackIndex, part, seg, gap, strip;
99 BesMucDigit *aDigit = new BesMucDigit();
100
101 G4int n_hit = THC->entries();
102 for(G4int i = 0; i < n_hit; i++) {
103 aDigit->SetHit((*THC)[i]);
104 trackIndex = aDigit->GetTrackIndex();
105 part = aDigit->GetPart();
106 seg = aDigit->GetSeg();
107 gap = aDigit->GetGap();
108 strip = aDigit->GetNearestStripNo();
109
110 //fill muc Ntuple
111 if(m_G4Svc->MucRootFlag())
112 {
113 m_part = part;
114 m_seg = seg;
115 m_gap = gap;
116 m_strip = strip;
117
118 m_tupleMuc->write();
119 }
120
121 (*THC)[i]->SetPart(part);
122 (*THC)[i]->SetSeg(seg);
123 (*THC)[i]->SetGap(gap);
124 (*THC)[i]->SetStrip(strip);
125 if(m_stripID[part][seg][gap][strip] == 0) {
126 NewDigi(trackIndex, part, seg, gap, strip);
127 }
128 else {
129 OldDigi();
130 }
131 }
132 //Smear();
133 StoreDigiCollection(m_besMucDigisCollection);
134 delete aDigit;
135 }
136}
137
138void BesMucDigitizer::NewDigi(G4int trackIndex, G4int part, G4int seg, G4int gap, G4int strip)
139{
140 BesMucDigi *digi = new BesMucDigi();
141 digi->SetTrackIndex(trackIndex);
142 digi->SetPartId(part);
143 digi->SetSegId(seg);
144 digi->SetGapId(gap);
145 digi->SetStripId(strip);
146 m_besMucDigisCollection->insert(digi);
147
148 m_stripID[part][seg][gap][strip] = 1;
149}
150
151void BesMucDigitizer::OldDigi()
152{ }
153
154void BesMucDigitizer::Smear()
155{ }
G4TDigiCollection< BesMucDigi > BesMucDigisCollection
Definition: BesMucDigi.hh:56
G4THitsCollection< BesMucHit > BesMucHitsCollection
Definition: BesMucHit.hh:104
void SetPartId(G4int partId)
Definition: BesMucDigi.hh:37
void SetTrackIndex(G4int index)
Definition: BesMucDigi.hh:36
void SetSegId(G4int segId)
Definition: BesMucDigi.hh:38
void SetGapId(G4int gapId)
Definition: BesMucDigi.hh:39
void SetStripId(G4int stripId)
Definition: BesMucDigi.hh:40
G4int GetGap()
Definition: BesMucDigit.hh:40
G4int GetPart()
Definition: BesMucDigit.hh:38
G4int GetTrackIndex()
Definition: BesMucDigit.hh:37
G4int GetNearestStripNo()
Definition: BesMucDigit.cc:63
G4int GetSeg()
Definition: BesMucDigit.hh:39
void SetHit(BesMucHit *hit)
Definition: BesMucDigit.cc:29
BesMucDigitizer(G4String modName)
virtual void Digitize()
Definition: G4Svc.h:32
bool MucRootFlag()
Definition: G4Svc.h:120
NTuple::Tuple * GetTupleMuc()
Definition: G4Svc.h:114
Definition: IG4Svc.h:30