18 #include "G4AffineTransform.hh"
19 #include "G4NavigationHistory.hh"
21 #include "G4ThreeVector.hh"
22 #include "G4StepPoint.hh"
31 #include "GaudiKernel/ISvcLocator.h"
32 #include "GaudiKernel/Bootstrap.h"
43 , m_geometry(
"LArBarrelPresamplerGeometry",
name)
47 , m_detectorName(
"LArMgr")
49 , m_volname(
"LArMgr::LAr::Barrel::Presampler")
51 declareProperty(
"GeometryCalculator",
m_geometry);
59 ATH_MSG_DEBUG(
"LArBarrelPresamplerCalculator: Beginning initialization ");
70 ATH_MSG_DEBUG(
" LArBarrelPresamplerCalculator: start reading current maps");
79 const double Birks_LAr_density = 1.396;
81 ATH_MSG_DEBUG(
" LArBarrelPresamplerCalculator: Birks' law ON ");
86 ATH_MSG_DEBUG(
" LArBarrelPresamplerCalculator: Birks' law OFF");
92 ATH_MSG_DEBUG(
"End of LArBarrelPresamplerCalculator initialization ");
94 return StatusCode::SUCCESS;
101 return StatusCode::SUCCESS;
111 G4double thisStepEnergyDeposit = a_step->GetTotalEnergyDeposit() * a_step->GetTrack()->GetWeight();
112 G4double thisStepLength = a_step->GetStepLength() /
Units::mm;
116 ATH_MSG_DEBUG(
"****** LArBarrelPresamplerCalculator: Step energy,length "
117 << thisStepEnergyDeposit <<
" " << thisStepLength);
119 if(thisStepEnergyDeposit <= 0. || thisStepLength <= 0.)
125 G4StepPoint *thisStepPoint = a_step->GetPreStepPoint();
126 G4StepPoint *thisStepBackPoint = a_step->GetPostStepPoint();
127 G4ThreeVector startPoint = thisStepPoint->GetPosition();
128 G4ThreeVector endPoint = thisStepBackPoint->GetPosition();
132 << startPoint.x() <<
" " << startPoint.y() <<
" "
135 << endPoint.x() <<
" " << endPoint.y() <<
" "
142 const G4NavigationHistory* g4navigation = thisStepPoint->GetTouchable()->GetHistory();
143 G4int ndep = g4navigation->GetDepth();
150 const G4String presamplerName((
m_detectorName.empty()) ?
"LAr::Barrel::Presampler" :
152 for (G4int ii=0;ii<=ndep;ii++) {
153 G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii);
155 ATH_MSG_DEBUG(
" Level,VolumeName " << ii <<
" " << v1->GetName());
158 if (v1->GetName()==presamplerName) idep=ii;
166 ATH_MSG_WARNING(
" LArBarrelPresamplerCalculator::Process Presampler volume not found !!");
171 const G4AffineTransform transformation = g4navigation->GetTransform(idep);
174 G4ThreeVector startPointinLocal =
175 transformation.TransformPoint(startPoint);
176 G4ThreeVector endPointinLocal =
177 transformation.TransformPoint (endPoint);
181 << startPointinLocal.x() <<
" " << startPointinLocal.y() <<
" "
182 << startPointinLocal.z());
184 << endPointinLocal.x() <<
" " << endPointinLocal.y() <<
" "
185 << endPointinLocal.z());
193 if (
m_IflCur) nsub_step=(
int) (thisStepLength*(1./dstep)) + 1;
195 G4double delta=1./((
double) nsub_step);
197 ATH_MSG_DEBUG(
" nsub_step,delta " << nsub_step <<
" " << delta);
200 G4double
energy = a_step->GetTotalEnergyDeposit() * a_step->GetTrack()->GetWeight();
202 const double EField = 10. ;
203 const double wholeStepLengthCm = a_step->GetStepLength() /
CLHEP::cm;
204 energy = (*m_birksLaw)(
energy, wholeStepLengthCm, EField);
212 for (G4int
i=0;
i<nsub_step;
i++) {
219 G4double fraction=(((G4double)
i)+0.5)*delta;
220 G4ThreeVector subinLocal=startPointinLocal*(1-fraction) + endPointinLocal*fraction;
221 G4double xloc = subinLocal.x();
222 G4double yloc = subinLocal.y();
223 G4double zloc = subinLocal.z();
238 zSide = ( startPoint.z() > 0.) ? 1 : -1;
240 G4int region = currentCellData.
region;
243 G4int sampling = currentCellData.
sampling;
253 if (sampling !=0 || region != 0 ||
254 etaBin <0 || etaBin > 60 || phiBin <0 || phiBin>63)
continue;
275 tof = thisStepPoint->GetGlobalTime() /
Units::ns;
286 G4int imodule = currentCellData.
module;
287 G4double x0 = currentCellData.
distElec;
288 G4double y0 = currentCellData.
xElec;
295 if (imodule==0 || imodule ==1) {
306 ATH_MSG_WARNING(
" LArBarrelPresamplerCalculator: cannot get map for module " << imodule);
309 double current0,current1,current2,
gap;
312 cm->GetAll(x0,y0,&
gap,¤t0,¤t1,¤t2);
314 ATH_MSG_DEBUG(
" module,x0,y0,current0 from map " << imodule <<
" " << x0 <<
" " << y0 <<
" " << current0);
318 Current =
energy*current0;
325 for (
unsigned int j=0; j<hdata.size(); j++) {
326 if (hdata[j].
id==identifier2) {
327 hdata[j].energy += Current;
328 hdata[j].time +=
time*Current;
335 hdata.push_back(newdata);
343 ATH_MSG_DEBUG(
"Number of hits for this step " << m_nhits <<
" " << hdata.size());
347 for (
unsigned int i=0;
i<hdata.size();
i++) {
348 if (std::fabs(hdata[
i].
energy)>1
e-6) hdata[
i].time=hdata[
i].time/hdata[
i].energy;
349 else hdata[
i].time=0.;
355 if (!hdata.empty())
return true;