14 if (aName ==
std::string(
"HornAConceptDesignJan2017")) {
17 if (aName ==
std::string(
"HornBConceptDesignJan2017")) {
42 for (
size_t kr=0; kr != 9; kr++) {
46 std::ostringstream mNameStrStr; mNameStrStr << kr;
55 fMap.emplace(tag, aCell);
75 for (
size_t kz=0; kz != 59; kz++) {
78 std::ostringstream mNameStrStr; mNameStrStr << kz;
88 fMap.emplace(tag, aCell);
95 fMap.emplace(tag, aCellW);
119 size_t nTapered = 50;
126 for (
size_t kz=0; kz != nTapered; kz++) {
130 std::ostringstream mNameStrStr; mNameStrStr << kz;
139 fMap.emplace(tag, aCell);
147 fMap.emplace(tag, aCellW);
171 for (
size_t kr=0; kr != 9; kr++) {
174 std::ostringstream mNameStrStr; mNameStrStr << kr;
182 fMap.emplace(tag, aCell);
203 fMap.emplace(tag, aCell);
224 fMap.emplace(tag, aCell);
233 std::cerr <<
" LBNFDeDxMap::defineInnerCHornA with " <<
fMap.size() <<
" cells, keep going " <<
std::endl;
240 if (aStep->GetStepLength() < 1.0e-6)
return;
241 G4StepPoint* prePtr = aStep->GetPreStepPoint();
242 G4StepPoint* postPtr = aStep->GetPostStepPoint();
243 if (prePtr == 0)
return;
244 if (postPtr == 0)
return;
245 G4LogicalVolume *volPre = prePtr->GetPhysicalVolume()->GetLogicalVolume();
246 if (volPre == 0)
return;
248 double zStart = std::nan(
"");
249 double rStart = std::nan(
"");
250 double zWidth = std::nan(
"");
251 double rWidth = std::nan(
"");
252 bool isRelevantRTag =
false;
257 if (volNamePre.find(volR.c_str()) != std::string::npos) {
258 isRelevantRTag =
true;
264 bool isRelevantZTag =
false;
269 if (volNamePre.find(volZ.c_str()) != std::string::npos) {
270 isRelevantZTag =
true;
276 if ((!isRelevantRTag) && (!isRelevantZTag))
return;
282 const double x = 0.5*(prePtr->GetPosition()[0] + postPtr->GetPosition()[0]);
283 const double y = 0.5*(prePtr->GetPosition()[1] + postPtr->GetPosition()[1]);
284 const double z = 0.5*(prePtr->GetPosition()[2] + postPtr->GetPosition()[2]);
285 const double r = std::sqrt(x*x + y*y);
286 double phi = std::atan2(y,x);
287 if (phi < 0.) phi += 2.0*M_PI;
288 unsigned int tag = 0;
289 if (isRelevantRTag) tag =
getTagFromR(r, rStart, rWidth, phi);
290 if (isRelevantZTag) tag =
getTagFromZ(z, zStart, zWidth, phi);
292 if (volNamePre.find(
"Water") != std::string::npos) tag += 1000000;
293 if (volNamePre.find(
"RingSuppIC") != std::string::npos) tag += 2000000;
294 if (volNamePre.find(
"WeldIC0toIC1") != std::string::npos) tag += 3000000;
296 if (it ==
fMap.end()) {
306 const double edd = aStep->GetTotalEnergyDeposit();
307 const G4Track *aTr = aStep->GetTrack();
308 it->second.eDep += edd;
309 it->second.eDepSq += edd*edd;
310 const int pid= aTr->GetParticleDefinition()->GetPDGEncoding();
311 const double zPre = prePtr->GetPosition()[2];
312 const double zPost = postPtr->GetPosition()[2];
313 const double rPre = std::sqrt(prePtr->GetPosition()[0]*prePtr->GetPosition()[0] +
314 prePtr->GetPosition()[1]*prePtr->GetPosition()[1]);
315 const double rPost = std::sqrt(postPtr->GetPosition()[0]*postPtr->GetPosition()[0] +
316 postPtr->GetPosition()[1]*postPtr->GetPosition()[1]);
320 if (
std::abs(aTr->GetParticleDefinition()->GetPDGCharge()) > 1.0e-30) it->second.nEntries += 1;
321 if ((tag == 2072) || (tag == 102072) || (tag == 202072) || (tag == 302072) ||
322 (tag == 402072) || (tag == 402072)) {
324 (
std::abs(aTr->GetParticleDefinition()->GetPDGCharge()) > 1.0e-30)) {
328 aa.
length = aStep->GetStepLength();
334 aa.
eKin = aTr->GetKineticEnergy();
347 std::ofstream fOut(aNameOut.c_str());
348 fOut <<
" tag ZOrR G4Name MARSName zC zW rC rW phiC phiW nEnt eDep sigEDep " <<
std::endl;
350 it !=
fMap.end(); it++) {
351 const double sEdd = it->second.eDep/nEvts;
352 double sigEDep = 1.412*it->second.eDep/nEvts;
353 if (it->second.nEntries > 1) {
354 const double mEdd = it->second.eDep/it->second.nEntries;
355 const double w = ((it->second.eDepSq) -
356 (it->second.nEntries) * mEdd * mEdd)/(it->second.nEntries -1);
357 sigEDep = std::sqrt(
std::abs(w)) * it->second.nEntries/(nEvts*std::sqrt(it->second.nEntries));
359 fOut <<
" " << it->first <<
" " <<it->second.keyedByZ
360 <<
" " << it->second.G4Name <<
" " << it->second.MARSName
361 <<
" " << it->second.zCenter <<
" " << it->second.zWidth
362 <<
" " << it->second.rCenter <<
" " << it->second.rWidth
363 <<
" " << it->second.phiCenter <<
" " << it->second.phiWidth
364 <<
" " << it->second.nEntries <<
" " << sEdd <<
" " << sigEDep <<
std::endl;
367 std::string aNameOut2(aNameDir);
369 std::ofstream fOut2(aNameOut2.c_str());
370 fOut2 <<
" k tag pid l rPre zPre rPos zPos eDep eKin " <<
std::endl;
374 fOut2 <<
" " << kk <<
" " << it->tag <<
" " << it->pid
375 <<
" " << it->length <<
" " << it->rPre
376 <<
" " << it->zPre <<
" " << it->rPost
377 <<
" " << it->zPost <<
" " << it->eDep
void fill(const G4Step *aStep)
std::vector< std::string > G4NamesInMapZTag
std::vector< double > rStarts
void dumpASCII(const std::string &aDirectory, int nEvt)
std::vector< LBNFDeDxEntryInCell > fVectSpecialCell
unsigned int fNumPhiSlices
std::vector< double > rWidths
unsigned int getTagFromZ(double z, double zStart, double zWidth, double f) const
std::vector< double > zStarts
std::vector< double > zWidths
std::map< unsigned int, LBNFDeDxCell > fMap
std::vector< std::string > G4NamesInMapRTag
LBNFDeDxMap(const std::string &aName)
unsigned int getTagFromR(double r, double rStart, double rWidth, double f) const
QTextStream & endl(QTextStream &s)