CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
BesTofDigitizer.cc
Go to the documentation of this file.
1//---------------------------------------------------------------------------//
2// BOOST --- BESIII Object_Oriented Simulation Tool //
3//---------------------------------------------------------------------------//
4//Description: Chief control center for digitizing modes.Also define 'group hits'.
5//Author: Dengzy
6//Created: Mar, 2004
7//Modified: Add new digitizer module for endcap TOF. Liu Yong @ Dec,2008
8//Comment:
9//---------------------------------------------------------------------------//
10//$Id: BesTofDigitizer.cc
11
12#include "BesTofDigitizer.hh"
18
20
21
22
23
24#include "ScintSingle.hh"
25#include "G4DigiManager.hh"
26//#include "BesTofDigitizerMessenger.hh"
27
28#include "GaudiKernel/ISvcLocator.h"
29#include "GaudiKernel/Bootstrap.h"
30#include "GaudiKernel/IDataProviderSvc.h"
31#include "G4Svc/IG4Svc.h"
32#include "G4Svc/G4Svc.h"
33#include "ReadBoostRoot.hh"
34
35#include "GaudiKernel/MsgStream.h"
36
37
38
40 :G4VDigitizerModule(modName)
41{
42 collectionName.push_back("BesTofDigitsCollection");
43 m_besTofDigitsCollection=0;
44 //m_digiMessenger = new BesTofDigitizerMessenger(this);
45
46 tofDMBr1 = new BesTofDigitizerBrV1();
47 tofDMEc1 = new BesTofDigitizerEcV1();
48 tofDMBr2 = new BesTofDigitizerBrV2();
49 tofDMEc2 = new BesTofDigitizerEcV2();
50 tofDMEc3 = new BesTofDigitizerEcV3();
51
52 tofDMEc4 = new BesTofDigitizerEcV4();//MRPC Digitizer
53
54 //retrieve G4Svc
55 /*ISvcLocator* svcLocator = Gaudi::svcLocator();
56 IG4Svc* tmpSvc;
57 StatusCode sc=svcLocator->service("G4Svc", tmpSvc);
58 G4Svc* g4Svc=dynamic_cast<G4Svc *>(tmpSvc);*/
59
60
61 m_versionBr=2;
62
64 {
65 m_versionEc=4;
66 std::cout << std::endl << "BesTofDigitizer You are using the new EC Tof (MRPC) Digitizer!" << std::endl;
67 }
68 else
69 {
70 m_versionEc=3;
71 std::cout << std::endl << "BesTofDigitizer You are using the old EC Tof Digitizer!" << std::endl;
72 }
73
74
75
76}
77
79{
80 //delete m_digiMessenger;
81 delete tofDMEc4;
82}
83
85{
86 m_besTofDigitsCollection=new BesTofDigitsCollection (moduleName, collectionName[0]);
87 G4DigiManager* digiManager = G4DigiManager::GetDMpointer();
88 G4int THCID = digiManager->GetHitsCollectionID("BesTofHitsCollection");
89 m_THC = (BesTofHitsCollection*) (digiManager->GetHitsCollection(THCID));
90
91
92
93
94
95
96 if(m_THC) //Haben wir eine Hit-Collection?
97 {
98
99
100 m_scintGroup = new vector<ScintSingle*>;//ScintSingle contains: partId, scintnb, edep <--only the basics
101 GroupHits(); //If one finds more hits in one scintillator, they are grouped together
102 G4int size=m_scintGroup->size();
103
104 //std::cout << "BesTofDigitizer m_scintGroup->size(): " << size << std::endl;
105
106
107 ScintSingle* scint;
108 G4int partId;
109 for (G4int i=0;i<size;i++)
110 {
111 scint = (*m_scintGroup)[i];
112 partId = scint->GetPartId();
113
114
115
116 if (partId==1) // for barrel part
117 {
118 if (m_versionBr==1)
119 tofDMBr1->Digitize(scint,m_besTofDigitsCollection);
120 else if (m_versionBr==2){
121 //std::cout << " tofDMBr2->Digitize" << std::endl;
122 tofDMBr2->Digitize(scint,m_besTofDigitsCollection);
123 }
124 else
125 tofDMBr2->Digitize(scint,m_besTofDigitsCollection);
126 }
127 else // for endcap part
128 {
129 if (m_versionEc==1)
130 tofDMEc1->Digitize(scint,m_besTofDigitsCollection);
131 else if (m_versionEc==2)
132 tofDMEc2->Digitize(scint,m_besTofDigitsCollection);
133 else if (m_versionEc==3){
134 tofDMEc3->Digitize(scint,m_besTofDigitsCollection);}
135 else if (m_versionEc==4)
136 tofDMEc4->Digitize(scint,m_besTofDigitsCollection);
137 else
138 {
139 cout << "Warning: BesTofDigitizerEcV2 is utilized otherwise!" << endl;
140 tofDMEc2->Digitize(scint,m_besTofDigitsCollection);
141 }
142 }//Close endcappart
143 }//close for
144 if (m_scintGroup)
145 {
146 for (size_t i=0;i<m_scintGroup->size();i++)
147 {
148 delete (*m_scintGroup)[i];
149 //std::cout << "i: " << i << std::endl;
150 //std::cout << "delete m_scintGroup[i] successfully " << std::endl;
151 }
152 m_scintGroup->clear();
153 delete m_scintGroup;
154 }
155
156 }//close if(m_THC)
157
158 StoreDigiCollection(m_besTofDigitsCollection);
159}
160
162{
163 G4int partId, scinNb,size,flag;
164 G4double edep;
165 BesTofHit* hit;
166 G4int nHits = m_THC->entries();
167
168 //group the hits which are in the same scintillator
169 for (G4int i=0;i<nHits;i++)
170 {
171 hit=(*m_THC)[i];
172 partId=hit->GetPartId();
173 scinNb=hit->GetScinNb();
174 edep = hit->GetEdep();
175 size=m_scintGroup->size();
176 flag=0;
177 if (size>0)
178 {
179 ScintSingle* oldScint;
180 for (G4int j=0; j<size;j++)
181 {
182 oldScint = (*m_scintGroup)[j];
183 if (oldScint->GetPartId()==partId &&oldScint->GetScinNb()==scinNb)
184 {
185
186 //std::cout << "BesTodDigitizer: GroupHits: 'Oldhit:' partID | scinnb : " << partId << " | " << scinNb << std::endl;
187
188 oldScint->GetHitIndexes()->push_back(i);
189 oldScint->AddEdep(edep);
190 flag=1;
191 break;
192 }
193 }
194 }
195 if (flag==0)
196 {
197 ScintSingle* newScint = new ScintSingle;
198 newScint->SetPartId(partId);
199 newScint->SetScinNb(scinNb);
200 newScint->SetEdep(edep);
201 newScint->GetHitIndexes()->push_back(i);
202 m_scintGroup->push_back(newScint);
203
204 //std::cout << "BesTodDigitizer: GroupHits: NewHitGroup: " << partId << " " << scinNb << std::endl;
205
206 }
207 }
208}
209
210
211
212
G4TDigiCollection< BesTofDigi > BesTofDigitsCollection
Definition: BesTofDigi.hh:83
G4THitsCollection< BesTofHit > BesTofHitsCollection
Definition: BesTofHit.hh:108
virtual void Digitize(ScintSingle *, BesTofDigitsCollection *)
virtual void Digitize(ScintSingle *, BesTofDigitsCollection *)
virtual void Digitize(ScintSingle *, BesTofDigitsCollection *)
virtual void Digitize(ScintSingle *, BesTofDigitsCollection *)
virtual void Digitize(ScintSingle *, BesTofDigitsCollection *)
virtual void Digitize(ScintSingle *, BesTofDigitsCollection *)
virtual void Digitize()
BesTofDigitizer(G4String modName)
G4double GetEdep()
Definition: BesTofHit.hh:62
G4int GetScinNb()
Definition: BesTofHit.hh:61
G4int GetPartId()
Definition: BesTofHit.hh:60
static G4int GetTof()
void SetEdep(G4double e)
Definition: ScintSingle.hh:53
G4int GetPartId()
Definition: ScintSingle.hh:44
void SetScinNb(G4int nb)
Definition: ScintSingle.hh:52
vector< G4int > * GetHitIndexes()
Definition: ScintSingle.hh:47
G4int GetScinNb()
Definition: ScintSingle.hh:45
void SetPartId(G4int id)
Definition: ScintSingle.hh:51
void AddEdep(G4double e)
Definition: ScintSingle.hh:54