Import Geant4 10.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2019-12-06 15:12:28 +01:00
parent b2a62ae692
commit 5baee230e9
2997 changed files with 141580 additions and 98673 deletions
@@ -30,22 +30,22 @@
///////////////////////////////////////////////////////////////////////////////
#include "CCalAMaterial.hh"
CCalAMaterial::CCalAMaterial(G4String mat, G4double dens, int nconst,
CCalAMaterial** constituents, G4double* weights) {
CCalAMaterial::CCalAMaterial(G4String mat, G4double dens, G4int nconst,
CCalAMaterial** constituents, G4double* weights) {
name=mat;
nElem=0;
int i=0;
G4int i=0;
for (i=0; i<nconst; i++)
nElem += (constituents[i]->NElements());
theElements = new G4String[nElem];
theWeights = new double[nElem];
theWeights = new G4double[nElem];
double factor;
int nelem=0;
G4double factor;
G4int nelem=0;
for (i=0; i<nconst; i++) {
factor=constituents[i]->Aeff();
for (int j=0; j<constituents[i]->NElements(); j++) {
for (G4int j=0; j<constituents[i]->NElements(); j++) {
theElements[nelem] = constituents[i]->Element(j);
theWeights[nelem] = constituents[i]->Weight(j)* weights[i] * factor;
nelem++;
@@ -61,12 +61,12 @@ CCalAMaterial::CCalAMaterial(G4String mat, G4double dens, int nconst,
closeMaterial();
}
CCalAMaterial::CCalAMaterial(G4String elemat, double eff, double dens) {
CCalAMaterial::CCalAMaterial(G4String elemat, G4double eff, G4double dens) {
name=elemat;
density=dens;
nElem=1;
theElements = new G4String[nElem];
theWeights = new double[nElem];
theWeights = new G4double[nElem];
theElements[0] = elemat;
theWeights[0] = 1;
@@ -84,8 +84,8 @@ CCalAMaterial::CCalAMaterial(const CCalAMaterial& mat)
density = mat.density;
nElem = mat.nElem;
theElements = new G4String[nElem];
theWeights = new double[nElem];
for (int i=0; i<nElem; i++){
theWeights = new G4double[nElem];
for (G4int i=0; i<nElem; i++){
theElements[i]=mat.theElements[i];
theWeights[i]=mat.theWeights[i];
}
@@ -103,19 +103,19 @@ CCalAMaterial& CCalAMaterial::operator=(const CCalAMaterial& mat){
aEff=mat.aEff;
theElements = new G4String[nElem];
theWeights = new double[nElem];
for (int i=0; i<nElem; i++){
theWeights = new G4double[nElem];
for (G4int i=0; i<nElem; i++){
theElements[i]=mat.theElements[i];
theWeights[i]=mat.theWeights[i];
}
return *this;
}
void CCalAMaterial::computeAeff(int nconst,
CCalAMaterial** constituents,
double* weights){
void CCalAMaterial::computeAeff(G4int nconst,
CCalAMaterial** constituents,
G4double* weights){
aEff=0;
for (int i=0; i<nconst; i++)
for (G4int i=0; i<nconst; i++)
aEff += weights[i] * constituents[i]->Aeff();
}
@@ -124,7 +124,7 @@ std::ostream& operator<<(std::ostream& os, const CCalAMaterial& mat) {
os << "Density= " << mat.density << " g/cm3. Number of Elements: "
<< mat.nElem
<< ". Aeff= " << mat.aEff << G4endl;
for (int i=0; i<mat.nElem; i++)
for (G4int i=0; i<mat.nElem; i++)
os << '\t' << mat.theElements[i] << '\t' << mat.theWeights[i] << G4endl;
return os;
}
@@ -39,18 +39,16 @@
//Comment/Uncomment to hide/show some more debug information
//#define ddebug
CCalDetector::CCalDetector(const G4String &name): detectorName(name)
{
if (getenv("CCAL_GEOMPATH"))
pathName = getenv("CCAL_GEOMPATH");
if (std::getenv("CCAL_GEOMPATH"))
pathName = std::getenv("CCAL_GEOMPATH");
else
G4Exception("CCalDetector::CCalDetector","ccal001",
FatalException,
"Environment variable CCAL_GEOMPATH not defined");
FatalException,
"Environment variable CCAL_GEOMPATH not defined");
#ifdef ddebug
#ifdef debug
G4cout << "CCAL_GEOMPATH=" << pathName << G4endl;
#endif
fileName =
@@ -60,8 +58,7 @@ CCalDetector::CCalDetector(const G4String &name): detectorName(name)
}
CCalDetector::~CCalDetector() {
CCalDetectorTable::iterator ite;
for (ite=theDetectorsInside.begin(); ite !=theDetectorsInside.end(); ite++) {
for (auto ite=theDetectorsInside.begin(); ite !=theDetectorsInside.end(); ++ite) {
delete *ite;
}
theDetectorsInside.clear();
@@ -71,7 +68,7 @@ void CCalDetector::construct() {
#ifdef debug
G4cout << "===> Entering CCalDetector::construct() for " << Name() << G4endl;
#endif
int isgood = 0;
G4int isgood = 0;
//If constructFlag is unset we don't go into all this bussines
if (constructFlag!=0) {
@@ -81,8 +78,8 @@ void CCalDetector::construct() {
if (isgood) {
constructDaughters();
for (unsigned int i=0; i < theDetectorsInside.size(); i++) {
theDetectorsInside[i]->constructHierarchy();
for (std::size_t i=0; i < theDetectorsInside.size(); ++i) {
theDetectorsInside[i]->constructHierarchy();
}
}
}
@@ -91,21 +88,16 @@ void CCalDetector::construct() {
#endif
}
void CCalDetector::addDetector(CCalDetector* det) {
theDetectorsInside.push_back(det);
}
//========================================================================
//Protected and private methods.
int CCalDetector::buildFromFile() {
G4int CCalDetector::buildFromFile() {
return readFile();
}
//========================================================================
//Global operators
std::ostream& operator<<(std::ostream& os, const CCalDetector& det) {
@@ -115,17 +107,10 @@ std::ostream& operator<<(std::ostream& os, const CCalDetector& det) {
os << "With " << det.theDetectorsInside.size()
<< " detectors inside { "<< G4endl;
for (unsigned int i=0; i<det.theDetectorsInside.size(); i++)
for (std::size_t i=0; i<det.theDetectorsInside.size(); ++i)
os << det.theDetectorsInside[i] << G4endl;
os << "}" << G4endl;
return os;
}
@@ -96,17 +96,17 @@ G4VPhysicalVolume* CCalDetectorConstruction::Construct() {
if (field == 0) {
ccalField = NULL;
G4cout << "***************************" << G4endl
<< "* *" << G4endl
<< "* Magnetic Field is off *" << G4endl
<< "* *" << G4endl
<< "***************************" << G4endl;
<< "* *" << G4endl
<< "* Magnetic Field is off *" << G4endl
<< "* *" << G4endl
<< "***************************" << G4endl;
} else {
G4cout << "***************************" << G4endl
<< "* *" << G4endl
<< "* Magnetic Field is on *" << G4endl
<< "* *" << G4endl
<< "***************************" << G4endl << G4endl
<< " Field Value " << tab << field << G4endl;
<< "* *" << G4endl
<< "* Magnetic Field is on *" << G4endl
<< "* *" << G4endl
<< "***************************" << G4endl << G4endl
<< " Field Value " << tab << field << G4endl;
}
G4FieldManager* fieldMgr
= G4TransportationManager::GetTransportationManager()->GetFieldManager();
@@ -161,11 +161,11 @@ G4VPhysicalVolume* CCalDetectorConstruction::Construct() {
sensitive = CCalSensitiveConfiguration::getInstance()->
getSensitiveFlag("HadronCalorimeter");
if (sensitive>0) /*result =*/ CCalSensAssign::getInstance()->
addCaloSD("HadronCalorimeter", new CCalHcalOrganization);
addCaloSD("HadronCalorimeter", new CCalHcalOrganization);
sensitive = CCalSensitiveConfiguration::getInstance()->
getSensitiveFlag("CrystalMatrixModule");
if (sensitive>0) /*result =*/ CCalSensAssign::getInstance()->
addCaloSD("CrystalMatrix", new CCalEcalOrganization);
addCaloSD("CrystalMatrix", new CCalEcalOrganization);
//Assign the sensitive detectors
/*result =*/ CCalSensAssign::getInstance()->assign();
@@ -31,19 +31,20 @@
#include <fstream>
#include "CCalutils.hh"
#include "G4SystemOfUnits.hh"
//#define debug
CCalEcal::~CCalEcal() {}
int CCalEcal::readFile() {
G4int CCalEcal::readFile() {
///////////////////////////////////////////////////////////////
//Let's open the file
G4cout << " ==> Opening file " << File() << " to read elements..."
<< G4endl;
std::ifstream is;
bool ok = openGeomFile(is, pathName, File());
G4bool ok = openGeomFile(is, pathName, File());
if (!ok)
return 0;
@@ -63,7 +64,7 @@ int CCalEcal::readFile() {
#endif
//Then the layer positions
int i=0;
G4int i=0;
readName(is,layMat);
is >> layNum >> layRadius >> layAngle >> lengFront;
for (i=0; i<5; i++)
@@ -43,9 +43,9 @@ unsigned int CCalEcalOrganization::GetUnitID(const G4Step* aStep) const {
G4TouchableHistory* theTouchable =
(G4TouchableHistory*)( aStep->GetPreStepPoint()->GetTouchable() );
int idl=0, idn=0;
int level = theTouchable->GetHistoryDepth();
int idx = theTouchable->GetReplicaNumber( 0 ) - 1;
G4int idl=0, idn=0;
G4int level = theTouchable->GetHistoryDepth();
G4int idx = theTouchable->GetReplicaNumber( 0 ) - 1;
if ( level > 0 ) {
idl = theTouchable->GetReplicaNumber( 1 ) - 1;
if ( level > 1 ) {
@@ -58,7 +58,7 @@
CCalEventAction::CCalEventAction(CCalPrimaryGeneratorAction* pg,
CCalSteppingAction* sa):
CCalSteppingAction* sa):
isInitialized(false),fPrimaryGenerator(pg),
fSteppingAction(sa),SDnames(nullptr),numberOfSD(0)
{
@@ -88,11 +88,11 @@ void CCalEventAction::initialize() {
n = std::min(n, 2);
SDnames = new nameType[n];
}
for (int i=0; i<numberOfSD; ++i) {
for (G4int i=0; i<numberOfSD; ++i) {
SDnames[i] = G4String(CCalSDList::getInstance()->getCaloSDName(i));
#ifdef debug
G4cout << "CCalEndOfEventAction: found SD " << i << " name "
<< SDnames[i] << G4endl;
<< SDnames[i] << G4endl;
#endif
}
}
@@ -119,79 +119,79 @@ void CCalEventAction::EndOfEventAction(const G4Event* evt){
if (allHC == 0) {
#ifdef debug
G4cout << "CCalEndOfEventAction: No Hit Collection in this event"
<< G4endl;
<< G4endl;
#endif
return;
}
//
// hits info
//
//Now make summary
float hcalE[28], ecalE[49], fullE=0., edec=0, edhc=0;
int i = 0;
G4float hcalE[28], ecalE[49], fullE=0., edec=0, edhc=0;
G4int i = 0;
for (i = 0; i < 28; i++) {hcalE[i]=0.;}
for (i = 0; i < 49; i++) {ecalE[i]=0.;}
float* edep = new float[numberOfSD];
int nhit=0;
G4float* edep = new G4float[numberOfSD];
G4int nhit=0;
for (i = 0; i < numberOfSD; ++i){
//
// Look for the Hit Collection
//
edep[i] = 0;
int caloHCid = G4SDManager::GetSDMpointer()->GetCollectionID(SDnames[i]);
G4int caloHCid = G4SDManager::GetSDMpointer()->GetCollectionID(SDnames[i]);
if (caloHCid >= 0) {
CCalG4HitCollection* theHC =
(CCalG4HitCollection*) allHC->GetHC(caloHCid);
(CCalG4HitCollection*) allHC->GetHC(caloHCid);
if (theHC != 0) {
G4int nentries = theHC->entries();
G4int nentries = theHC->entries();
#ifdef debug
G4cout << " There are " << nentries << " hits in " << SDnames[i]
<< " :" << G4endl;
G4cout << " There are " << nentries << " hits in " << SDnames[i]
<< " :" << G4endl;
#endif
if (nentries > 0) {
if (nentries > 0) {
int j;
for (j=0; j<nentries; j++){
G4int j;
for (j=0; j<nentries; j++){
#ifdef ddebug
G4cout << "Hit " << j;
G4cout << "Hit " << j;
#endif
CCalG4Hit* aHit = (*theHC)[j];
float En = aHit->getEnergyDeposit();
int unitID = aHit->getUnitID();
int id=-1;
if (unitID > 0 && unitID < 29) {
id = unitID - 1; // HCal
hcalE[id] += En/GeV;
} else {
int i0 = unitID/4096;
int i1 = (unitID/64)%64;
int i2 = unitID%64;
if (i0 == 1 && i1 < 8 && i2 < 8) {
id = i1*7 + i2; // ECal
ecalE[id] += En/GeV;
}
}
CCalG4Hit* aHit = (*theHC)[j];
G4float En = aHit->getEnergyDeposit();
G4int unitID = aHit->getUnitID();
G4int id=-1;
if (unitID > 0 && unitID < 29) {
id = unitID - 1; // HCal
hcalE[id] += En/GeV;
} else {
G4int i0 = unitID/4096;
G4int i1 = (unitID/64)%64;
G4int i2 = unitID%64;
if (i0 == 1 && i1 < 8 && i2 < 8) {
id = i1*7 + i2; // ECal
ecalE[id] += En/GeV;
}
}
#ifdef ddebug
G4cout << " with Energy = " << En/MeV << " MeV in Unit " << unitID
<< " " << id << G4endl;
G4cout << " with Energy = " << En/MeV << " MeV in Unit " << unitID
<< " " << id << G4endl;
#endif
fullE += En/GeV;
edep[i] += En/GeV;
nhit++;
}
fullE += En/GeV;
edep[i] += En/GeV;
nhit++;
}
#ifdef ddebug
G4cout << " ===> Total Energy Deposit in this Calorimeter = "
<< edep[i]*1000.0 << " MeV " << G4endl;
G4cout << " ===> Total Energy Deposit in this Calorimeter = "
<< edep[i]*1000.0 << " MeV " << G4endl;
#endif
}
}
}
}
if (SDnames[i] == "HadronCalorimeter") {
@@ -204,10 +204,10 @@ void CCalEventAction::EndOfEventAction(const G4Event* evt){
delete[] edep;
G4ThreeVector pos = fPrimaryGenerator->GetParticlePosition();
float ener = fPrimaryGenerator->GetParticleEnergy()/GeV;
float x = pos.x()/mm;
float y = pos.y()/mm;
float z = pos.z()/mm;
G4float ener = fPrimaryGenerator->GetParticleEnergy()/GeV;
G4float x = pos.x()/mm;
G4float y = pos.y()/mm;
G4float z = pos.z()/mm;
//Save results
G4AnalysisManager* man = G4AnalysisManager::Instance();
@@ -221,17 +221,17 @@ void CCalEventAction::EndOfEventAction(const G4Event* evt){
static G4int IDhcalE = -1;
if (IDhcalE < 0)
IDhcalE = man->GetH1Id("h100");
for (int j=0; j<28; j++) {
for (G4int j=0; j<28; j++) {
man->FillH1(IDhcalE+j,hcalE[j]);
#ifdef debug
G4cout << "Fill Hcal histo " << j << " with " << hCalE[j] << G4endl;
G4cout << "Fill Hcal histo " << j << " with " << hcalE[j] << G4endl;
#endif
totalFilledEnergyHcal += hcalE[j];
}
#ifdef debug
G4cout <<
"CCalAnalysis::InsertEnergyHcal: Total filled Energy Hcal histo "
<< totalFilledEnergyHcal << G4endl;
<< totalFilledEnergyHcal << G4endl;
#endif
//3)
@@ -239,7 +239,7 @@ void CCalEventAction::EndOfEventAction(const G4Event* evt){
if (IDecalE < 0)
IDecalE = man->GetH1Id("h200");
G4double totalFilledEnergyEcal = 0.0;
for (int j=0; j<49; j++) {
for (G4int j=0; j<49; j++) {
man->FillH1(IDecalE+j,ecalE[j]);
#ifdef debug
G4cout << "Fill Ecal histo " << j << " with " << ecalE[j] << G4endl;
@@ -249,16 +249,16 @@ void CCalEventAction::EndOfEventAction(const G4Event* evt){
#ifdef debug
G4cout <<
"CCalAnalysis::InsertEnergyEal: Total filled Energy Ecal histo "
<< totalFilledEnergyEcal << G4endl;
<< totalFilledEnergyEcal << G4endl;
#endif
// 4)
G4int counter=0;
for (int j=0; j<28; j++)
for (G4int j=0; j<28; j++)
{
man->FillNtupleFColumn(counter,hcalE[j]);
counter++;
}
for (int j=0; j<49; j++)
for (G4int j=0; j<49; j++)
{
man->FillNtupleFColumn(counter,ecalE[j]);
counter++;
@@ -280,23 +280,23 @@ void CCalEventAction::EndOfEventAction(const G4Event* evt){
if (IDtimeProfile < 0)
IDtimeProfile = man->GetH1Id("h901");
for (i = 0; i < numberOfSD; i++){
int caloHCid = G4SDManager::GetSDMpointer()->GetCollectionID(SDnames[i]);
G4int caloHCid = G4SDManager::GetSDMpointer()->GetCollectionID(SDnames[i]);
if (caloHCid >= 0) {
CCalG4HitCollection* theHC =
(CCalG4HitCollection*) allHC->GetHC(caloHCid);
(CCalG4HitCollection*) allHC->GetHC(caloHCid);
if (theHC != 0) {
G4int nentries = theHC->entries();
if (nentries > 0) {
for (G4int k=0; k<nentries; k++) {
CCalG4Hit* aHit = (*theHC)[k];
man->FillH1(IDtimeProfile,aHit->getTimeSlice(),aHit->getEnergyDeposit()/GeV);
G4int nentries = theHC->entries();
if (nentries > 0) {
for (G4int k=0; k<nentries; k++) {
CCalG4Hit* aHit = (*theHC)[k];
man->FillH1(IDtimeProfile,aHit->getTimeSlice(),aHit->getEnergyDeposit()/GeV);
#ifdef debug
G4cout << "CCalAnalysis:: Fill Time Profile with Hit " << k
<< " Edeposit " << edep << " Gev at " << time << " ns" << G4endl;
G4cout << "CCalAnalysis:: Fill Time Profile with Hit " << k
<< " Edeposit " << edep << " Gev" << G4endl;
#endif
}
}
}
}
}
}
}
@@ -50,7 +50,7 @@ CCalG4Able::CCalG4Able(G4String name):
detPhysicalVolume(0), g4ableName(name), sensitivity(false),
visProperties(CCalSensitiveConfiguration::getInstance()->getFileName(name)+".vis") {
//Initialize g4VisAtt pointers
for (int i=0; i<CCalVisualisable::TotalVisTypes; i++) {
for (G4int i=0; i<CCalVisualisable::TotalVisTypes; ++i) {
g4VisAtt[i]=0;
}
sensitivity =
@@ -74,25 +74,25 @@ G4VPhysicalVolume* CCalG4Able::PhysicalVolume(G4VPhysicalVolume* pv) {
if (!detPhysicalVolume) {
detPhysicalVolume = constructIn(pv);
for (unsigned int i = 0; i < theG4DetectorsInside.size(); i++) {
theG4DetectorsInside[i]->PhysicalVolume(detPhysicalVolume);
theG4DetectorsInside[i]->PhysicalVolume(detPhysicalVolume);
}
if (sensitivity) {
#ifdef debug
G4cout << "==> Making " << detPhysicalVolume->GetName() << " sensitive..."
<< G4endl;
G4cout << "==> Making " << detPhysicalVolume->GetName() << " sensitive..."
<< G4endl;
#endif
constructSensitive();
constructSensitive();
} //if sensitivity
} //if sensitive
} //if construct
else {
G4cout << "NOTE: You decided to skip the construction of "
<< G4Name() << G4endl;
<< G4Name() << G4endl;
}
#ifdef ddebug
timer.Stop();
G4cout << tab << "CCalG4Able::PhysicalVolume(...) --> time spent: "
<< timer << G4endl;
<< timer << G4endl;
#endif
return detPhysicalVolume;
}
@@ -105,21 +105,21 @@ void CCalG4Able::setVisType(CCalVisualisable::visType vt, G4LogicalVolume* log)
if (!g4VisAtt[vt]) {
#ifdef debug
G4cout << "CCalG4Able::setVisType: Constructing G4VisAttributes for "
<< log->GetName() << " as " << vt << G4endl;
<< log->GetName() << " as " << vt << G4endl;
#endif
G4Color col(visProperties.colorRed(vt),
visProperties.colorGreen(vt),
visProperties.colorBlue(vt));
visProperties.colorGreen(vt),
visProperties.colorBlue(vt));
G4bool wf = visProperties.isWireFrame(vt);
G4bool visible = visProperties.isVisible(vt);
#ifdef debug
G4cout << "Color: "
<< visProperties.colorRed(vt) << ", "
<< visProperties.colorGreen(vt) << ", "
<< visProperties.colorBlue(vt) << tab
<< "Wireframe: " << wf << tab
<< "Visible: " << visible << G4endl;
<< visProperties.colorRed(vt) << ", "
<< visProperties.colorGreen(vt) << ", "
<< visProperties.colorBlue(vt) << tab
<< "Wireframe: " << wf << tab
<< "Visible: " << visible << G4endl;
#endif
g4VisAtt[vt] = new G4VisAttributes(col);
g4VisAtt[vt]->SetForceWireframe(wf);
@@ -111,18 +111,18 @@ G4VPhysicalVolume* CCalG4Ecal::constructIn(G4VPhysicalVolume* mother) {
if (!cmrot) {
#ifdef ddebug
G4cout << "Creating a new rotation: " << rotstr << tab
<< getThetaX()*deg << "," << getPhiX()*deg << ","
<< getThetaY()*deg << "," << getPhiY()*deg << ","
<< getThetaZ()*deg << "," << getPhiZ()*deg << G4endl;
<< getThetaX()*deg << "," << getPhiX()*deg << ","
<< getThetaY()*deg << "," << getPhiY()*deg << ","
<< getThetaZ()*deg << "," << getPhiZ()*deg << G4endl;
#endif
cmrot = rotfact->AddMatrix(rotstr, getThetaX()*deg, getPhiX()*deg,
getThetaY()*deg, getPhiY()*deg,
getThetaZ()*deg, getPhiZ()*deg);
getThetaY()*deg, getPhiY()*deg,
getThetaZ()*deg, getPhiZ()*deg);
} // if !cmrot
#ifdef pdebug
G4cout << " rotation by (" << getThetaX() << ", " << getPhiX() << ", "
<< getThetaY() << "," << getPhiY() << ", " << getThetaZ() << ", "
<< getPhiZ() << ")" << G4endl;
<< getThetaY() << "," << getPhiY() << ", " << getThetaZ() << ", "
<< getPhiZ() << ")" << G4endl;
#endif
} else {
#ifdef pdebug
@@ -133,12 +133,12 @@ G4VPhysicalVolume* CCalG4Ecal::constructIn(G4VPhysicalVolume* mother) {
G4PVPlacement* crystalmatrix;
if (mother != 0) {
crystalmatrix = new G4PVPlacement(cmrot, G4ThreeVector(x,y,z),
crystalmatrixLog, idName,
mother->GetLogicalVolume(), false, num);
crystalmatrixLog, idName,
mother->GetLogicalVolume(), false, num);
} else {
crystalmatrix = new G4PVPlacement(cmrot, G4ThreeVector(x,y,z),
idName, crystalmatrixLog,
mother, false, num);
idName, crystalmatrixLog,
mother, false, num);
}
G4cout << "<<== End of CCalG4Ecal construction ..." << G4endl;
@@ -154,7 +154,7 @@ G4LogicalVolume* CCalG4Ecal::constructGlobal() {
G4Material* matter = matfact->findMaterial(getGenMat());
G4VSolid* solid = new G4Box (idName, 0.5*getWidBox()*mm, 0.5*getWidBox()*mm,
0.5*getLengBox()*mm);
0.5*getLengBox()*mm);
#ifdef debug
G4cout << tab << idName << " Box made of " << getGenMat() << " of dimension "
<< 0.5*getWidBox()*mm << ", " << 0.5*getWidBox()*mm << ", "
@@ -167,7 +167,7 @@ G4LogicalVolume* CCalG4Ecal::constructGlobal() {
G4String name = idName + "Layer";
matter = matfact->findMaterial(getLayMat());
solid = new G4Trd(name, getLayPar(0)*mm, getLayPar(1)*mm, getLayPar(2)*mm,
getLayPar(3)*mm, getLayPar(4)*mm);
getLayPar(3)*mm, getLayPar(4)*mm);
#ifdef debug
G4cout << tab << name << " Trd made of " << getLayMat() << " of dimension "
<< getLayPar(0)*mm << ", " << getLayPar(1)*mm << ", " << getLayPar(2)*mm
@@ -190,18 +190,18 @@ G4LogicalVolume* CCalG4Ecal::constructGlobal() {
if (!rot) {
#ifdef ddebug
G4cout << "Creating a new rotation: " << rotstr << tab
<< (90.0*deg+angle) << "," << 0.0*deg << "," << 90.0*deg << ","
<< 90.0*deg << "," << angle << "," << 0.0*deg << G4endl;
<< (90.0*deg+angle) << "," << 0.0*deg << "," << 90.0*deg << ","
<< 90.0*deg << "," << angle << "," << 0.0*deg << G4endl;
#endif
rot = rotfact->AddMatrix(rotstr, (90.0*deg+angle), 0.0*deg, 90.0*deg,
90.0*deg, angle, 0.0*deg);
90.0*deg, angle, 0.0*deg);
}
new G4PVPlacement(rot, G4ThreeVector(xp,0.,zp), laylog, name, glog,
false, i+1);
false, i+1);
#ifdef pdebug
G4cout << laylog->GetName() << " number " << i+1 << " positioned in "
<< glog->GetName() << " at (" << xp << ", 0," << zp
<< ") with rotation angle " << angle/deg << G4endl;
<< ") with rotation angle " << angle/deg << G4endl;
#endif
}
@@ -209,7 +209,7 @@ G4LogicalVolume* CCalG4Ecal::constructGlobal() {
name = idName + "Crystal";
matter = matfact->findMaterial(getCrystMat());
solid = new G4Trd(name, getCrystPar(0)*mm, getCrystPar(1)*mm,
getCrystPar(2)*mm, getCrystPar(3)*mm, getCrystPar(4)*mm);
getCrystPar(2)*mm, getCrystPar(3)*mm, getCrystPar(4)*mm);
#ifdef debug
G4cout << tab << name << " Trd made of " << getCrystMat() << " of dimension "
<< getCrystPar(0)*mm << ", " << getCrystPar(1)*mm << ", "
@@ -229,18 +229,18 @@ G4LogicalVolume* CCalG4Ecal::constructGlobal() {
if (!rot) {
#ifdef ddebug
G4cout << "Creating a new rotation: " << rotstr << tab << 90.0*deg << ","
<< 0.0*deg << "," << (90.0*deg+angle) << "," << 0.0*deg << ","
<< angle << "," << 90.0*deg << G4endl;
<< 0.0*deg << "," << (90.0*deg+angle) << "," << 0.0*deg << ","
<< angle << "," << 90.0*deg << G4endl;
#endif
rot = rotfact->AddMatrix(rotstr, 90.0*deg, 0.0*deg, (90.0*deg+angle),
90.0*deg, angle, 90.0*deg);
90.0*deg, angle, 90.0*deg);
}
new G4PVPlacement(rot, G4ThreeVector(0,yp,zp), detLog, name, laylog,
false, i+1);
false, i+1);
#ifdef pdebug
G4cout << detLog->GetName() << " number " << i+1 << " positioned in "
<< laylog->GetName() << " at (0," << yp << "," << zp
<< ") with rotation angle " << angle/deg << G4endl;
<< ") with rotation angle " << angle/deg << G4endl;
#endif
}
@@ -248,7 +248,7 @@ G4LogicalVolume* CCalG4Ecal::constructGlobal() {
name = idName + "Support";
matter = matfact->findMaterial(getSuppMat());
solid = new G4Box (name, 0.5*getDxSupp()*mm, 0.5*getDySupp()*mm,
0.5*getDzSupp()*mm);
0.5*getDzSupp()*mm);
#ifdef debug
G4cout << tab << name << " Box made of " << getSuppMat() << " of dimension "
<< 0.5*getDxSupp()*mm << ", " << 0.5*getDySupp()*mm << ", "
@@ -258,15 +258,15 @@ G4LogicalVolume* CCalG4Ecal::constructGlobal() {
setVisType(CCalVisualisable::Support,slog);
zp = (-0.5 * getLengBox() + getCrystLength() + getLengFront() +
0.5 * getDzSupp() + getDistSupp()) * mm;
0.5 * getDzSupp() + getDistSupp()) * mm;
for (i = 0; i < getCrystNum(); i++) {
yp = getLayPar(1) * (2*i + 1 - getCrystNum()) * mm;
new G4PVPlacement(0, G4ThreeVector(0,yp,zp), slog, name, glog,
false, i+1);
false, i+1);
#ifdef pdebug
G4cout << slog->GetName() << " number " << i+1 << " positioned in "
<< glog->GetName() << " at (0," << yp << "," << zp
<< ") with no rotation" << G4endl;
<< ") with no rotation" << G4endl;
#endif
}
@@ -282,15 +282,14 @@ void CCalG4Ecal::constructSensitive() {
CCalSensitiveDetectors* sensDets = CCalSensitiveDetectors::getInstance();
G4String SDname = idName;
for(std::vector<ptrG4Log>::iterator iter=sensitiveLogs.begin();
iter<sensitiveLogs.end(); iter++) {
iter<sensitiveLogs.end(); iter++) {
sensDets->registerVolume(SDname, (*iter));
#ifdef sdebug
G4cout << "Register volume " << (*iter)->GetName() << " for" << SDname
<< G4endl;
<< G4endl;
#endif
}
}
}
@@ -73,7 +73,7 @@ G4VPhysicalVolume* CCalG4Hall::constructIn(G4VPhysicalVolume* mother) {
#endif
G4Box* solid = new G4Box(Name(), getDx_2Hall()*mm, getDy_2Hall()*mm,
getDy_2Hall()*mm);
getDy_2Hall()*mm);
#ifdef debug
G4cout << solid->GetName() << " made of " << getMaterial() << " of dimension "
<< getDx_2Hall()*mm << " " << getDy_2Hall()*mm << " "
@@ -91,7 +91,7 @@ G4VPhysicalVolume* CCalG4Hcal::constructIn(G4VPhysicalVolume* mother) {
//Mother volume
G4Material* matter = matfact->findMaterial(getGenMat());
G4VSolid* solid = new G4Box (Name(), getDx_2Cal()*mm, getDy_2Cal()*mm,
getDy_2Cal()*mm);
getDy_2Cal()*mm);
G4LogicalVolume* logh = new G4LogicalVolume(solid, matter, Name());
setVisType(CCalVisualisable::PseudoVolumes,logh);
#ifdef debug
@@ -101,7 +101,7 @@ G4VPhysicalVolume* CCalG4Hcal::constructIn(G4VPhysicalVolume* mother) {
#endif
G4PVPlacement* hcal = new G4PVPlacement(0,G4ThreeVector(getXposCal()*mm,0,0),
Name(), logh, mother, false, 1);
Name(), logh, mother, false, 1);
G4String name("Null");
#ifdef pdebug
if (mother != 0) name = mother->GetName();
@@ -111,7 +111,7 @@ G4VPhysicalVolume* CCalG4Hcal::constructIn(G4VPhysicalVolume* mother) {
//Wall of the Boxes
solid = new G4Box (name, 0.5*getWallThickBox()*mm, getDy_2Box()*mm,
getDy_2Box()*mm);
getDy_2Box()*mm);
matter = matfact->findMaterial(getBoxMat());
name = Name() + "Wall";
G4LogicalVolume* logw = new G4LogicalVolume(solid, matter, name);
@@ -128,35 +128,35 @@ G4VPhysicalVolume* CCalG4Hcal::constructIn(G4VPhysicalVolume* mother) {
for (i=0; i<getNBox(); i++) {
name = Name() + "Box" + i;
solid = new G4Box (name, getDx_2Box()*mm, getDy_2Box()*mm,
getDy_2Box()*mm);
getDy_2Box()*mm);
logb[i]= new G4LogicalVolume(solid, matter, name);
setVisType(CCalVisualisable::PseudoVolumes,logb[i]);
#ifdef debug
G4cout << tab << name << " Box made of " << getGenMat()
<< " of dimension " << getDx_2Box()*mm << " " << getDy_2Box()*mm
<< " of dimension " << getDx_2Box()*mm << " " << getDy_2Box()*mm
<< " " << getDy_2Box()*mm << G4endl;
#endif
G4double xpos = -(getDx_2Box() - 0.5*getWallThickBox());
new G4PVPlacement (0, G4ThreeVector(xpos*mm,0,0), logw, logw->GetName(),
logb[i], false, 1);
logb[i], false, 1);
#ifdef pdebug
G4cout << logw->GetName() << " Number 1 positioned in " << name
<< " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
<< " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
#endif
xpos = (getDx_2Box() - 0.5*getWallThickBox());
new G4PVPlacement (0, G4ThreeVector(xpos*mm,0,0), logw, logw->GetName(),
logb[i], false, 2);
logb[i], false, 2);
#ifdef pdebug
G4cout << logw->GetName() << " Number 2 positioned in " << name
<< " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
<< " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
#endif
new G4PVPlacement (0, G4ThreeVector(getXposBox(i)*mm,0,0), logb[i], name,
logh, false, i+1);
logh, false, i+1);
#ifdef pdebug
G4cout << name << " Number " << i+1 << " positioned in " << logh->GetName()
<< " at (" << getXposBox(i)*mm << ",0,0) with no rotation" << G4endl;
<< " at (" << getXposBox(i)*mm << ",0,0) with no rotation" << G4endl;
#endif
}
@@ -172,11 +172,11 @@ G4VPhysicalVolume* CCalG4Hcal::constructIn(G4VPhysicalVolume* mother) {
}
G4double xpos = getXposScnt(i);
new G4PVPlacement (0, G4ThreeVector(xpos*mm,0,0), sclLog[lay],
sclLog[lay]->GetName(), logw, false, i+1);
sclLog[lay]->GetName(), logw, false, i+1);
#ifdef pdebug
G4cout << sclLog[lay]->GetName() << " Number " << i+1 << " positioned in "
<< logw->GetName() << " at (" << xpos*mm << ",0,0) with no rotation"
<< G4endl;
<< logw->GetName() << " at (" << xpos*mm << ",0,0) with no rotation"
<< G4endl;
#endif
}
@@ -192,11 +192,11 @@ G4VPhysicalVolume* CCalG4Hcal::constructIn(G4VPhysicalVolume* mother) {
}
G4double xpos = getXposAbs(i);
new G4PVPlacement (0, G4ThreeVector(xpos*mm,0,0), absLog[lay],
absLog[lay]->GetName(), logw, false, i+1);
absLog[lay]->GetName(), logw, false, i+1);
#ifdef pdebug
G4cout << absLog[lay]->GetName() << " Number " << i+1 << " positioned in "
<< logw->GetName() << " at (" << xpos*mm << ",0,0) with no rotation"
<< G4endl;
<< logw->GetName() << " at (" << xpos*mm << ",0,0) with no rotation"
<< G4endl;
#endif
}
@@ -217,8 +217,8 @@ G4LogicalVolume* CCalG4Hcal::constructScintillatorLayer(G4int lay) {
G4Material* matter = matfact->findMaterial(getGenMat());
G4String name = Name() + "ScntLayer" + lay;
G4VSolid* solid = new G4Box (name, getDx_2ScntLay(lay)*mm,
getDy_2ScntLay(lay)*mm,
getDy_2ScntLay(lay)*mm);
getDy_2ScntLay(lay)*mm,
getDy_2ScntLay(lay)*mm);
G4LogicalVolume* log = new G4LogicalVolume(solid, matter, name);
setVisType(CCalVisualisable::PseudoVolumes,log);
#ifdef debug
@@ -234,25 +234,25 @@ G4LogicalVolume* CCalG4Hcal::constructScintillatorLayer(G4int lay) {
name = Name() + "ScntWrapper" + lay;
matter = matfact->findMaterial(getWrapMat());
solid = new G4Box (name, getDx_2Wrap(lay)*mm,
getDy_2ScntLay(lay)*mm, getDy_2ScntLay(lay)*mm);
getDy_2ScntLay(lay)*mm, getDy_2ScntLay(lay)*mm);
logd = new G4LogicalVolume(solid, matter, name);
setVisType(CCalVisualisable::Support,logd);
#ifdef debug
G4cout << tab << name << " Box made of " << getWrapMat() << " of dimension "
<< getDx_2Wrap(lay)*mm << " " << getDy_2ScntLay(lay)*mm << " "
<< getDy_2ScntLay(lay)*mm << G4endl;
<< getDx_2Wrap(lay)*mm << " " << getDy_2ScntLay(lay)*mm << " "
<< getDy_2ScntLay(lay)*mm << G4endl;
#endif
xpos =-(getDx_2ScntLay(lay)-getDx_2Wrap(lay));
new G4PVPlacement(0, G4ThreeVector(xpos*mm,0,0), logd, name, log, false,1);
#ifdef pdebug
G4cout << logd->GetName() << " Number 1 positioned in " << log->GetName()
<< " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
<< " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
#endif
xpos = (getDx_2ScntLay(lay)-getDx_2Wrap(lay));
new G4PVPlacement(0, G4ThreeVector(xpos*mm,0,0), logd, name, log, false,2);
#ifdef pdebug
G4cout << logd->GetName() << " Number 2 positioned in " << log->GetName()
<< " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
<< " at (" << xpos*mm << ",0,0) with no rotation" << G4endl;
#endif
}
@@ -260,7 +260,7 @@ G4LogicalVolume* CCalG4Hcal::constructScintillatorLayer(G4int lay) {
matter = matfact->findMaterial(getPlasMat());
name = Name() + "FrontPlastic" + lay;
solid = new G4Box (name, getDx_2FrontP(lay)*mm, getDy_2ScntLay(lay)*mm,
getDy_2ScntLay(lay)*mm);
getDy_2ScntLay(lay)*mm);
logd = new G4LogicalVolume(solid, matter, name);
setVisType(CCalVisualisable::Cable,logd);
#ifdef debug
@@ -276,7 +276,7 @@ G4LogicalVolume* CCalG4Hcal::constructScintillatorLayer(G4int lay) {
#endif
name = Name() + "BackPlastic" + lay;
solid = new G4Box (name, getDx_2BackP(lay)*mm, getDy_2ScntLay(lay)*mm,
getDy_2ScntLay(lay)*mm);
getDy_2ScntLay(lay)*mm);
logd = new G4LogicalVolume(solid, matter, name);
setVisType(CCalVisualisable::Cable,logd);
#ifdef debug
@@ -296,7 +296,7 @@ G4LogicalVolume* CCalG4Hcal::constructScintillatorLayer(G4int lay) {
matter = matfact->findMaterial(getScntMat());
name = Name() + "Scintillator" + lay;
solid = new G4Box (name, getDx_2Scnt(lay)*mm, getDy_2ScntLay(lay)*mm,
getDy_2ScntLay(lay)*mm);
getDy_2ScntLay(lay)*mm);
logd = new G4LogicalVolume(solid, matter, name);
setVisType(CCalVisualisable::Sensitive,logd);
allSensitiveLogs.push_back(logd);
@@ -306,7 +306,7 @@ G4LogicalVolume* CCalG4Hcal::constructScintillatorLayer(G4int lay) {
<< getDy_2ScntLay(lay)*mm << G4endl;
#endif
xpos =(-getDx_2ScntLay(lay)+2.*getDx_2Wrap(lay)+2.*getDx_2FrontP(lay)+
getDx_2Scnt(lay));
getDx_2Scnt(lay));
new G4PVPlacement(0, G4ThreeVector(xpos*mm,0,0), logd, name, log, false,1);
#ifdef pdebug
G4cout << logd->GetName() << " Number 1 positioned in " << log->GetName()
@@ -326,7 +326,7 @@ G4LogicalVolume* CCalG4Hcal::constructAbsorberLayer(G4int lay) {
G4Material* matter = matfact->findMaterial(getAbsMat());
G4String name = Name() + "Absorber" + lay;
G4VSolid* solid = new G4Box (name, getDx_2Abs(lay)*mm, getDy_2Abs()*mm,
getDy_2Abs()*mm);
getDy_2Abs()*mm);
G4LogicalVolume* log = new G4LogicalVolume(solid, matter, name);
setVisType(CCalVisualisable::Absorber,log);
#ifdef debug
@@ -349,12 +349,12 @@ void CCalG4Hcal::constructSensitive(){
sensDets->registerVolume(SDname, (*iter));
#ifdef sdebug
G4cout << "Register volume " << (*iter)->GetName() << " for" << SDname
<< G4endl;
<< G4endl;
#endif
}
} else {
G4cerr << "CCalG4Hcal ERROR: Could not construct Sensitive Detector"
<< G4endl;
<< G4endl;
}
}
@@ -54,17 +54,17 @@ const CCalG4Hit& CCalG4Hit::operator=(const CCalG4Hit &right) {
}
double CCalG4Hit::getEM() const { return elem; }
void CCalG4Hit::setEM (double e) { elem = e; }
G4double CCalG4Hit::getEM() const { return elem; }
void CCalG4Hit::setEM (G4double e) { elem = e; }
double CCalG4Hit::getHadr() const { return hadr; }
void CCalG4Hit::setHadr (double e) { hadr = e; }
G4double CCalG4Hit::getHadr() const { return hadr; }
void CCalG4Hit::setHadr (G4double e) { hadr = e; }
void CCalG4Hit::addEnergyDeposit(const CCalG4Hit& aHit) {
addEnergyDeposit( aHit.getEM(), aHit.getHadr() );
}
void CCalG4Hit::addEnergyDeposit(double em, double hd) {
void CCalG4Hit::addEnergyDeposit(G4double em, G4double hd) {
elem += em;
hadr += hd;
CCalHit::addEnergyDeposit(em+hd);
@@ -45,16 +45,16 @@ CCalGeometryConfiguration* CCalGeometryConfiguration::getInstance(){
}
int CCalGeometryConfiguration::getConstructFlag(const G4String& n) /*const*/ {
int flag = -1;
CCalGeometryConfIterator it = theConfiguration.find(n);
G4int CCalGeometryConfiguration::getConstructFlag(const G4String& n) /*const*/ {
G4int flag = -1;
auto it = theConfiguration.find(n);
if (it != theConfiguration.end())
if (it != theConfiguration.cend())
flag = (*it).second.ConstructFlag;
else {
G4cerr << "ERROR: In CCalGeometryConfiguration::getConstructFlag(const G4String& n)"
<< G4endl
<< " " << n << " not found in configuration file" << G4endl;
<< G4endl
<< " " << n << " not found in configuration file" << G4endl;
}
return flag;
@@ -62,14 +62,14 @@ int CCalGeometryConfiguration::getConstructFlag(const G4String& n) /*const*/ {
G4String CCalGeometryConfiguration::getFileName(const G4String& n) /*const*/ {
G4String fn;
CCalGeometryConfIterator it = theConfiguration.find(n);
auto it = theConfiguration.find(n);
if (it != theConfiguration.end())
if (it != theConfiguration.cend())
fn = (*it).second.FileName;
else {
G4cerr << "ERROR: In CCalGeometryConfiguration::getConstructFlag(const G4String& n)"
<< G4endl
<< " " << n << " not found in configuration file" << G4endl;
G4cerr << "ERROR: In CCalGeometryConfiguration::getFileName(const G4String& n)"
<< G4endl
<< " " << n << " not found in configuration file" << G4endl;
}
return fn;
@@ -80,25 +80,25 @@ CCalGeometryConfiguration::CCalGeometryConfiguration():
///////////////////////////////////////////////////////////////
// Open the file
G4String pathName = getenv("CCAL_CONFPATH");
G4String fileenv = getenv("CCAL_GEOMETRYCONF");
G4String pathName = std::getenv("CCAL_CONFPATH");
G4String fileenv = std::getenv("CCAL_GEOMETRYCONF");
if (!pathName || !fileenv) {
G4ExceptionDescription ed;
ed << "ERROR: CCAL_GEOMETRYCONF and/or CCAL_CONFPATH not set" << G4endl
<< " Set them to the geometry configuration file/path" << G4endl;
<< " Set them to the geometry configuration file/path" << G4endl;
G4Exception("CCalGeometryConfiguration::CCalGeometryConfiguration()",
"ccal003",
FatalException,ed);
"ccal003",
FatalException,ed);
}
G4cout << " ==> Opening file " << fileenv << "..." << G4endl;
std::ifstream is;
bool ok = openGeomFile(is, pathName, fileenv);
G4bool ok = openGeomFile(is, pathName, fileenv);
if (!ok)
{
G4Exception("CCalGeometryConfiguration::CCalGeometryConfiguration()",
"ccal004",
FatalException,"Unable to open input data file");
"ccal004",
FatalException,"Unable to open input data file");
}
@@ -111,8 +111,8 @@ CCalGeometryConfiguration::CCalGeometryConfiguration():
is >> gcinfo.ConstructFlag >> jump;
#ifdef debug
G4cout << "CCalGeometryConfiguration constructor: Read \"" << name
<< "\" \"" << gcinfo.FileName << "\"" << tab << gcinfo.ConstructFlag
<< G4endl;
<< " \"" << gcinfo.FileName << "\"" << tab << gcinfo.ConstructFlag
<< G4endl;
#endif
theConfiguration[name] = gcinfo;
}
@@ -41,14 +41,14 @@ CCalHall::CCalHall(const G4String &name): CCalDetector(name) {}
CCalHall::~CCalHall() {}
int CCalHall::readFile() {
G4int CCalHall::readFile() {
///////////////////////////////////////////////////////////////
//Let's open the file
G4cout << " ==> Opening file " << File() << " to read elements..."
<< G4endl;
std::ifstream is;
bool ok = openGeomFile(is, pathName, File());
G4bool ok = openGeomFile(is, pathName, File());
if (!ok)
return 0;
@@ -71,7 +71,7 @@ CCalHcal::~CCalHcal() {
delete[] dx_2Scintillator;
}
int CCalHcal::readFile() {
G4int CCalHcal::readFile() {
///////////////////////////////////////////////////////////////
//Let's open the file
G4cout << " ==> Opening file " << File() << " to read elements..."
@@ -96,8 +96,8 @@ int CCalHcal::readFile() {
// Boxes
readName(is,boxMaterial);
is >> nBox >> dy_2Box >> dx_2Box >> wallThickBox;
int i = 0;
xposBox = new double[nBox];
G4int i = 0;
xposBox = new G4double[nBox];
for (i=0; i<nBox; i++)
is >> xposBox[i];
#ifdef debug
@@ -113,9 +113,9 @@ int CCalHcal::readFile() {
G4String rubbish;
readName(is,rubbish);
is >> nLayerScnt;
typeLayerScnt = new int[nLayerScnt];
mothLayerScnt = new int[nLayerScnt];
xposLayerScnt = new double[nLayerScnt];
typeLayerScnt = new G4int[nLayerScnt];
mothLayerScnt = new G4int[nLayerScnt];
xposLayerScnt = new G4double[nLayerScnt];
for (i=0; i<nLayerScnt; i++)
is >> typeLayerScnt[i] >> mothLayerScnt[i] >> xposLayerScnt[i];
#ifdef debug
@@ -123,15 +123,15 @@ int CCalHcal::readFile() {
<< "position" << G4endl;
for (i=0; i<nLayerScnt; i++)
G4cout << tab << i << " " << typeLayerScnt[i] << " " << mothLayerScnt[i]
<< " " << xposLayerScnt[i] << G4endl;
<< " " << xposLayerScnt[i] << G4endl;
#endif
// Layers of absorbers
readName(is,rubbish);
is >> nLayerAbs;
typeLayerAbs = new int[nLayerAbs];
mothLayerAbs = new int[nLayerAbs];
xposLayerAbs = new double[nLayerAbs];
typeLayerAbs = new G4int[nLayerAbs];
mothLayerAbs = new G4int[nLayerAbs];
xposLayerAbs = new G4double[nLayerAbs];
for (i=0; i<nLayerAbs; i++)
is >> typeLayerAbs[i] >> mothLayerAbs[i] >> xposLayerAbs[i];
#ifdef debug
@@ -139,13 +139,13 @@ int CCalHcal::readFile() {
<< "position" << G4endl;
for (i=0; i<nLayerAbs; i++)
G4cout << tab << i << " " << typeLayerAbs[i] << " " << mothLayerAbs[i]
<< " " << xposLayerAbs[i] << G4endl;
<< " " << xposLayerAbs[i] << G4endl;
#endif
// Absorber parameters
readName(is,absMaterial);
is >> nAbsorber >> dy_2Absorber;
dx_2Absorber = new double[nAbsorber];
dx_2Absorber = new G4double[nAbsorber];
for (i=0; i<nAbsorber; i++)
is >> dx_2Absorber[i];
#ifdef debug
@@ -161,12 +161,12 @@ int CCalHcal::readFile() {
readName(is,wrapMaterial);
readName(is,plasMaterial);
is >> nScintillator;
dy_2ScntLayer = new double[nScintillator];
dx_2ScntLayer = new double[nScintillator];
dx_2Wrapper = new double[nScintillator];
dx_2FrontPlastic = new double[nScintillator];
dx_2BackPlastic = new double[nScintillator];
dx_2Scintillator = new double[nScintillator];
dy_2ScntLayer = new G4double[nScintillator];
dx_2ScntLayer = new G4double[nScintillator];
dx_2Wrapper = new G4double[nScintillator];
dx_2FrontPlastic = new G4double[nScintillator];
dx_2BackPlastic = new G4double[nScintillator];
dx_2Scintillator = new G4double[nScintillator];
for (i=0; i<nScintillator; i++)
is >> dy_2ScntLayer[i] >> dx_2ScntLayer[i] >> dx_2Wrapper[i]
>> dx_2FrontPlastic[i] >> dx_2BackPlastic[i] >> dx_2Scintillator[i];
@@ -176,8 +176,8 @@ int CCalHcal::readFile() {
<< " of sizes " << G4endl;
for (i=0; i<nScintillator; i++)
G4cout << tab << i << " " << dy_2ScntLayer[i] << " " << dx_2ScntLayer[i]
<< " " << dx_2Wrapper[i] << " " << dx_2FrontPlastic[i] << " "
<< dx_2BackPlastic[i] << " " << dx_2Scintillator[i] << G4endl;
<< " " << dx_2Wrapper[i] << " " << dx_2FrontPlastic[i] << " "
<< dx_2BackPlastic[i] << " " << dx_2Scintillator[i] << G4endl;
#endif
///////////////////////////////////////////////////////////////
@@ -65,25 +65,25 @@ const CCalHit& CCalHit::operator=(const CCalHit &right) {
CLHEP::Hep3Vector CCalHit::getEntry() const {return entry;}
void CCalHit::setEntry(CLHEP::Hep3Vector xyz) { entry = xyz; }
double CCalHit::getIncidentEnergy() const {return theIncidentEnergy; }
void CCalHit::setIncidentEnergy (double e){theIncidentEnergy = e; }
G4double CCalHit::getIncidentEnergy() const {return theIncidentEnergy; }
void CCalHit::setIncidentEnergy (G4double e){theIncidentEnergy = e; }
int CCalHit::getTrackID() const {return theTrackID; }
void CCalHit::setTrackID (int i) { theTrackID = i; }
G4int CCalHit::getTrackID() const {return theTrackID; }
void CCalHit::setTrackID (G4int i) { theTrackID = i; }
unsigned int CCalHit::getUnitID() const {return theUnitID; }
void CCalHit::setUnitID (unsigned int i) { theUnitID = i; }
double CCalHit::getTimeSlice() const {return theTimeSlice; }
void CCalHit::setTimeSlice (double d) { theTimeSlice = d; }
int CCalHit::getTimeSliceID() const { if ( theTimeSlice > 1.0E9 ) return 999999999;
return (int)theTimeSlice;}
G4double CCalHit::getTimeSlice() const {return theTimeSlice; }
void CCalHit::setTimeSlice (G4double d) { theTimeSlice = d; }
G4int CCalHit::getTimeSliceID() const { if ( theTimeSlice > 1.0E9 ) return 999999999;
return (G4int)theTimeSlice;}
void CCalHit::setEnergyDeposit(const double e) {
void CCalHit::setEnergyDeposit(const G4double e) {
theEnergyDeposit = e;
}
double CCalHit::getEnergyDeposit() const {
G4double CCalHit::getEnergyDeposit() const {
return theEnergyDeposit;
}
@@ -91,7 +91,7 @@ void CCalHit::addEnergyDeposit(const CCalHit& aHit) {
addEnergyDeposit( aHit.getEnergyDeposit() );
}
void CCalHit::addEnergyDeposit(const double e) {
void CCalHit::addEnergyDeposit(const G4double e) {
theEnergyDeposit += e;
}
@@ -50,10 +50,10 @@ CCalMagneticField::CCalMagneticField(const G4String &filename) :
//Let's open the file
G4cout << " ==> Opening file " << filename << " to read magnetic field..."
<< G4endl;
G4String pathName = getenv("CCAL_GLOBALPATH");
<< G4endl;
G4String pathName = std::getenv("CCAL_GLOBALPATH");
std::ifstream is;
bool ok = openGeomFile(is, pathName, filename);
G4bool ok = openGeomFile(is, pathName, filename);
if (ok) {
findDO(is, G4String("FLDM"));
@@ -61,8 +61,8 @@ CCalMagneticField::CCalMagneticField(const G4String &filename) :
if (fVerbosity)
G4cout << "Field value " << fval << " # points " << npts <<
" offset in x "
<< xoff*mm << G4endl;
" offset in x "
<< xoff*mm << G4endl;
if (npts > 0) {
pos = new G4double[npts];
@@ -70,10 +70,10 @@ CCalMagneticField::CCalMagneticField(const G4String &filename) :
intercept = new G4double[npts];
for (G4int i = 0; i < npts; i++) {
is >> pos[i] >> slope[i] >> intercept[i];
if (fVerbosity)
G4cout << tab << "Position " << i << " " << pos[i] << " Slope "
<< slope[i] << " Intercept " << intercept[i] << G4endl;
is >> pos[i] >> slope[i] >> intercept[i];
if (fVerbosity)
G4cout << tab << "Position " << i << " " << pos[i] << " Slope "
<< slope[i] << " Intercept " << intercept[i] << G4endl;
}
}
@@ -97,7 +97,7 @@ CCalMagneticField::~CCalMagneticField() {
// Member functions
void CCalMagneticField::MagneticField(const double x[3], double B[3]) const
void CCalMagneticField::MagneticField(const G4double x[3], G4double B[3]) const
{
G4int i=0;
for (i=0; i<2; i++) {
@@ -110,7 +110,7 @@ void CCalMagneticField::MagneticField(const double x[3], double B[3]) const
if (npts > 0) {
for (i=0; i<npts; i++) {
if (xnew > pos[i]*mm) {
m1 = slope[i];
m1 = slope[i];
c1 = intercept[i];
}
}
@@ -124,10 +124,10 @@ void CCalMagneticField::MagneticField(const double x[3], double B[3]) const
{
G4cout << "Field at x: " << x[0]/mm << "mm (" << xnew << ") = " <<
B[2]/tesla
<< "T (m = " << m1 << ", c = " <<
c1 << ", scale = " << scor << ")"
<< G4endl;
B[2]/tesla
<< "T (m = " << m1 << ", c = " <<
c1 << ", scale = " << scor << ")"
<< G4endl;
}
}
@@ -149,7 +149,7 @@ MagneticField(const CLHEP::Hep3Vector point) const {
}
void CCalMagneticField::GetFieldValue(const double x[3], double* B) const {
void CCalMagneticField::GetFieldValue(const G4double x[3], G4double* B) const {
CCalMagneticField::MagneticField(x, B);
}
@@ -32,26 +32,26 @@
//#define debug
CCalMaterial::CCalMaterial(G4String mat, double dens, int nconst,
CCalMaterial** constituents, double* weights,
FractionType ft): name(mat), density(dens) {
CCalMaterial::CCalMaterial(G4String mat, G4double dens, G4int nconst,
CCalMaterial** constituents, G4double* weights,
FractionType ft): name(mat), density(dens) {
nElem = 0;
int i=0;
G4int i=0;
for (i=0; i<nconst; i++)
nElem += constituents[i]->NElements();
theElements = new G4String[nElem];
theWeights = new double[nElem];
theWeights = new G4double[nElem];
double factor;
int nelem=0;
G4double factor;
G4int nelem=0;
for (i=0; i<nconst; i++) {
if (ft==FTWeight)
factor=1.0;
else
factor=constituents[i]->Density();
for (int j=0; j<constituents[i]->NElements(); j++) {
for (G4int j=0; j<constituents[i]->NElements(); j++) {
theElements[nelem] = constituents[i]->Element(j);
theWeights[nelem] = constituents[i]->Weight(j)* weights[i] * factor;
nelem++;
@@ -67,8 +67,8 @@ CCalMaterial::CCalMaterial(G4String mat, double dens, int nconst,
CCalMaterial::CCalMaterial(const CCalMaterial& mat):
name(mat.name), density(mat.density), nElem(mat.nElem) {
theElements = new G4String[nElem];
theWeights = new double[nElem];
for (int i=0; i<nElem; i++){
theWeights = new G4double[nElem];
for (G4int i=0; i<nElem; i++){
theElements[i]=mat.theElements[i];
theWeights[i]=mat.theWeights[i];
}
@@ -81,12 +81,12 @@ CCalMaterial::~CCalMaterial() {
delete[] theWeights;
}
void CCalMaterial::computeDensity(int nconst,
CCalMaterial** constituents,
double* weights, FractionType ft) {
double mass=0;
double volume=0;
for (int i=0; i<nconst; i++) {
void CCalMaterial::computeDensity(G4int nconst,
CCalMaterial** constituents,
G4double* weights, FractionType ft) {
G4double mass=0;
G4double volume=0;
for (G4int i=0; i<nconst; i++) {
if (ft==FTWeight) {
mass+=weights[i];
volume+=(weights[i]/constituents[i]->Density());
@@ -110,8 +110,8 @@ CCalMaterial& CCalMaterial::operator=(const CCalMaterial& mat){
nElem=mat.nElem;
theElements = new G4String[nElem];
theWeights = new double[nElem];
for (int i=0; i<nElem; i++){
theWeights = new G4double[nElem];
for (G4int i=0; i<nElem; i++){
theElements[i]=mat.theElements[i];
theWeights[i]=mat.theWeights[i];
}
@@ -127,33 +127,33 @@ G4bool CCalMaterial::operator!=(const CCalMaterial& mat) const{
}
void CCalMaterial::closeMaterial() {
int trueConst=0;
G4int trueConst=0;
double norm=0;
G4double norm=0;
for (int i=0; i<nElem; i++) {
for (G4int i=0; i<nElem; i++) {
norm+=theWeights[i];
if (theElements[i]!="") {
trueConst++;
for (int j=i+1; j<nElem; j++) {
if(theElements[i]==theElements[j]){
theWeights[i]+=theWeights[j];
theElements[j]="";
}
for (G4int j=i+1; j<nElem; j++) {
if(theElements[i]==theElements[j]){
theWeights[i]+=theWeights[j];
theElements[j]="";
}
}//for j
} //if
}//for i
if (trueConst != nElem) {
G4String* newConst = new G4String[trueConst];
double* newWeight = new double[trueConst];
G4double* newWeight = new G4double[trueConst];
int newi=0;
for(int i=0; i<nElem; i++){
G4int newi=0;
for(G4int i=0; i<nElem; i++){
if (theElements[i]!="") {
newConst[newi] = theElements[i];
newWeight[newi] = theWeights[i]/norm;
newi++;
newConst[newi] = theElements[i];
newWeight[newi] = theWeights[i]/norm;
newi++;
}
}
@@ -169,7 +169,7 @@ void CCalMaterial::closeMaterial() {
theWeights=newWeight;
}
else { //Let's normalize the weights
for (int i=0; i<nElem; i++)
for (G4int i=0; i<nElem; i++)
theWeights[i] = theWeights[i]/norm;
}
}
@@ -178,7 +178,7 @@ std::ostream& operator<<(std::ostream& os, const CCalMaterial& mat) {
os << mat.name << G4endl;
os << "Density= " << mat.density << " g/cm3. Number of Elements: "
<< mat.nElem << G4endl;
for (int i=0; i<mat.nElem; i++)
for (G4int i=0; i<mat.nElem; i++)
os << '\t' << mat.theElements[i] << '\t' << mat.theWeights[i] << G4endl;
return os;
}
@@ -51,7 +51,7 @@ G4String CCalMaterialFactory::mixturefile = "";
CCalMaterialFactory* CCalMaterialFactory::getInstance(const G4String& matfile,
const G4String& mixfile){
const G4String& mixfile){
if ((matfile=="" || matfile==elementfile) &&
(mixfile=="" || mixfile==mixturefile))
return getInstance();
@@ -79,8 +79,8 @@ CCalMaterialFactory* CCalMaterialFactory::getInstance(const G4String& matfile){
CCalMaterialFactory* CCalMaterialFactory::getInstance(){
if (elementfile=="" || mixturefile=="") {
G4cerr << "ERROR: You haven't defined files to be used for materials in "
<< "CCalMaterialFactory::getInstance(const G4String&,const G4String&)"
<< G4endl;
<< "CCalMaterialFactory::getInstance(const G4String&,const G4String&)"
<< G4endl;
return 0;
}
@@ -114,24 +114,24 @@ G4Material* CCalMaterialFactory::findMaterial(const G4String & mat) const {
if (theMat) {
#ifdef ddebug
G4cout << "Material " << mat << " already defined. Returning previous "
<< "instance." << G4endl;
<< "instance." << G4endl;
#endif
return theMat;
} else {
CCalMaterial* CCalmat=findCCalMaterial(mat);
if (CCalmat){
G4Material* G4Mat = new G4Material(CCalmat->Name(),
CCalmat->Density()*g/cm3,
CCalmat->NElements());
CCalmat->Density()*g/cm3,
CCalmat->NElements());
for(G4int i=0; i<CCalmat->NElements(); i++) {
G4Element* elem = findElement(CCalmat->Element(i));
if (!elem) {
G4ExceptionDescription ed;
ed << " Could not build material " << mat << "." << G4endl;
G4Exception("CCalMaterialFactory::findMaterial()","ccal001",
FatalException,ed);
}
G4Mat->AddElement(elem, CCalmat->Weight(i));
G4Element* elem = findElement(CCalmat->Element(i));
if (!elem) {
G4ExceptionDescription ed;
ed << " Could not build material " << mat << "." << G4endl;
G4Exception("CCalMaterialFactory::findMaterial()","ccal001",
FatalException,ed);
}
G4Mat->AddElement(elem, CCalmat->Weight(i));
}
#ifdef ddebug
G4cout << "Material " << mat << " has been built successfully." << G4endl;
@@ -139,7 +139,7 @@ G4Material* CCalMaterialFactory::findMaterial(const G4String & mat) const {
return G4Mat;
} else {
G4cerr << "ERROR: Material " << mat << " not found in CCal database!!!"
<< G4endl;
<< G4endl;
return 0;
}
}
@@ -160,9 +160,9 @@ G4Element* CCalMaterialFactory::findElement(const G4String & mat) const {
G4Element* CCalMaterialFactory::addElement(const G4String & name,
const G4String & symbol,
G4double Z, G4double A,
G4double density) {
const G4String & symbol,
G4double Z, G4double A,
G4double density) {
G4Element* theEl = new G4Element(name, symbol, Z, A*g/mole);
//Make it also as a material.
@@ -177,11 +177,11 @@ G4Element* CCalMaterialFactory::addElement(const G4String & name,
G4Material* CCalMaterialFactory::addMaterial(const G4String& name,
G4double density,
G4int nconst,
G4String mats[],
G4double prop[],
MatDescription md){
G4double density,
G4int nconst,
G4String mats[],
G4double prop[],
MatDescription md){
addCCalMaterial(name, density, nconst, mats, prop, md);
return findMaterial(name);
}
@@ -190,12 +190,12 @@ G4Material* CCalMaterialFactory::addMaterial(const G4String& name,
void CCalMaterialFactory::readElements(const G4String& matfile) {
G4String path = "NULL";
if (getenv("CCAL_GLOBALPATH"))
path = getenv("CCAL_GLOBALPATH");
if (std::getenv("CCAL_GLOBALPATH"))
path = std::getenv("CCAL_GLOBALPATH");
G4cout << " ==> Opening file " << matfile << " to read elements..." << G4endl;
std::ifstream is;
bool ok = openGeomFile(is, path, matfile);
G4bool ok = openGeomFile(is, path, matfile);
if (!ok) {
G4cerr << "ERROR: Could not open file " << matfile << G4endl;
return;
@@ -213,8 +213,8 @@ void CCalMaterialFactory::readElements(const G4String& matfile) {
void CCalMaterialFactory::readMaterials(const G4String& matfile) {
G4String path = "NULL";
if (getenv("CCAL_GLOBALPATH"))
path = getenv("CCAL_GLOBALPATH");
if (std::getenv("CCAL_GLOBALPATH"))
path = std::getenv("CCAL_GLOBALPATH");
G4cout << " ==> Opening file " << matfile << " to read materials..." << G4endl;
std::ifstream is;
@@ -275,11 +275,11 @@ CCalAMaterial* CCalMaterialFactory::findCCalAMaterial(const G4String & mat)
CCalMaterial* CCalMaterialFactory::addCCalMaterial(const G4String& name,
G4double density,
G4int nconst,
G4String mats[],
G4double prop[],
MatDescription md){
G4double density,
G4int nconst,
G4String mats[],
G4double prop[],
MatDescription md){
ptrCCalMaterial* matcol=0;
ptrCCalAMaterial* amatcol=0;
@@ -292,25 +292,25 @@ CCalMaterial* CCalMaterialFactory::addCCalMaterial(const G4String& name,
if (md==byAtomic) {
CCalAMaterial* amat = findCCalAMaterial(mats[i]);
if (amat)
amatcol[i]=amat;
amatcol[i]=amat;
else {
G4cerr << "ERROR: Trying to build" << name << " out of unknown "
<< mats[i] << "." << G4endl
<< "Skiping this material!" << G4endl;
delete[] amatcol;
return 0;
G4cerr << "ERROR: Trying to build" << name << " out of unknown "
<< mats[i] << "." << G4endl
<< "Skiping this material!" << G4endl;
delete[] amatcol;
return 0;
}
} //by Atomic fractions
else {
CCalMaterial* mat = findCCalMaterial(mats[i]);
if (mat)
matcol[i]=mat;
matcol[i]=mat;
else {
G4cerr << "ERROR: Trying to build" <<name << " out of unknown "
<< mats[i] << "." << G4endl
<< "Skiping this material!" << G4endl;
delete[] matcol;
return 0;
G4cerr << "ERROR: Trying to build" <<name << " out of unknown "
<< mats[i] << "." << G4endl
<< "Skiping this material!" << G4endl;
delete[] matcol;
return 0;
}
}
} //for
@@ -318,7 +318,7 @@ CCalMaterial* CCalMaterialFactory::addCCalMaterial(const G4String& name,
//Let's do the CCalMaterial!
if (md==byAtomic) {
CCalAMaterial* amaterial = new CCalAMaterial(name, density, nconst,
amatcol, prop);
amatcol, prop);
delete[] amatcol;
theCCalAMaterials.push_back(amaterial);
#ifdef ddebug
@@ -332,7 +332,7 @@ CCalMaterial* CCalMaterialFactory::addCCalMaterial(const G4String& name,
else
ft=CCalMaterial::FTVolume;
CCalMaterial* material = new CCalMaterial(name, density, nconst,
matcol, prop, ft);
matcol, prop, ft);
delete[] matcol;
theCCalMaterials.push_back(material);
#ifdef ddebug
@@ -360,7 +360,7 @@ void CCalMaterialFactory::readElements(std::ifstream& is){
is >> symbol >> A >> Z >> density >> jump;
#ifdef debug
G4cout << " " << name << " \t" << symbol << "\t"
<< A << "\t" << Z << "\t" << density << G4endl;
<< A << "\t" << Z << "\t" << density << G4endl;
#endif
addElement(name, symbol, Z, A, density);
readName(is,name);
@@ -383,7 +383,7 @@ void CCalMaterialFactory::readMaterials(std::ifstream& is){
G4double pressure = 1.E-19*pascal;
G4double temperature = 0.1*kelvin;
new G4Material("Vacuum", /*Z=*/ 1., /*A=*/ 1.01*g/mole,
density, kStateGas, temperature, pressure);
density, kStateGas, temperature, pressure);
//There should come the list of materials. #. Defines a comment
//*ENDDO defines the block.
@@ -397,9 +397,9 @@ void CCalMaterialFactory::readMaterials(std::ifstream& is){
#ifdef debug
G4cout <<" " << matname
<< " made of " << nElem
<< " elements. Density=" << dens
<< G4endl;
<< " made of " << nElem
<< " elements. Density=" << dens
<< G4endl;
#endif
G4int absnelem = std::abs(nElem);
@@ -44,7 +44,7 @@
#include "G4HEPEvtInterface.hh"
#include "G4RunManager.hh"
#define debug
//#define debug
CCalPrimaryGeneratorAction::CCalPrimaryGeneratorAction(): particleGun(0),
generatorInput(singleFixed), verboseLevel(0), n_particle(1),
@@ -103,13 +103,11 @@ void CCalPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) {
particleDir = G4ThreeVector(randomX,randomY,randomZ);
particleGun->SetParticleMomentumDirection(particleDir);
#ifdef debug
if (verboseLevel >= 2 ) {
G4cout << "Energy " << particleEnergy/GeV << " GeV; Theta "
<< theta/deg << " degree; Phi " << phi/deg << " degree" << G4endl;
<< theta/deg << " degree; Phi " << phi/deg << " degree" << G4endl;
G4cout << "Shooting in " << particleDir << " direction "<< G4endl;
}
#endif
} else if (generatorInput == singleScan) {
G4double scanEtaStep, scanPhiStep;
if (scanSteps == 0) {
@@ -123,20 +121,20 @@ void CCalPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) {
#ifdef debug
if (verboseLevel > 2 ) {
G4cout << " scanEtaStep " << scanEtaStep << " # of Steps " << etaSteps
<< G4endl;
<< G4endl;
G4cout << " scanPhiStep " << scanPhiStep << " # of Steps " << phiSteps
<< G4endl;
<< G4endl;
}
#endif
//----- First scan in phi, then in eta
if (phiMax - phiValue < 1.E-6 * scanPhiStep) { // !only <= 1.E6 steps allowed
if (etaMax - etaValue < 1.E-6 * scanEtaStep) { // !only <= 1.E6 steps allowed
G4cout << " Scan completed!" << G4endl;
return;
G4cout << " Scan completed!" << G4endl;
return;
} else {
etaValue += scanEtaStep;
phiValue = phiMin;
etaValue += scanEtaStep;
phiValue = phiMin;
}
} else {
phiValue += scanPhiStep;
@@ -148,7 +146,7 @@ void CCalPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) {
G4double scanZ = std::cos(theta);
if (verboseLevel >= 2 ) {
G4cout << "Scan eta " << etaValue << " Phi " << phiValue/deg
<< " theta " << theta/deg << G4endl;
<< " theta " << theta/deg << G4endl;
}
particleDir = G4ThreeVector(scanX,scanY,scanZ);
particleGun->SetParticleMomentumDirection(particleDir);
@@ -199,14 +197,14 @@ void CCalPrimaryGeneratorAction::SetMinimumEnergy(G4double p){
if (p <= 0.) {
G4cerr << "CCalPrimaryGeneratorAction::SetMinimumEnergy: value " << p/GeV
<< "GeV is out of bounds, it will not be used" << G4endl;
<< "GeV is out of bounds, it will not be used" << G4endl;
G4cerr << " Should be >0. Please check" << G4endl;
} else {
energyMin = p;
#ifdef debug
if (verboseLevel >= 1 ) {
G4cout << " CCalPrimaryGeneratorAction: setting min. value of energy to "
<< energyMin/GeV << " GeV " << G4endl;
<< energyMin/GeV << " GeV " << G4endl;
}
#endif
}
@@ -217,14 +215,14 @@ void CCalPrimaryGeneratorAction::SetMaximumEnergy(G4double p){
if (p <= 0.) {
G4cerr << "CCalPrimaryGeneratorAction::SetMaximumEnergy: value " << p/GeV
<< "GeV is out of bounds, it will not be used" << G4endl;
<< "GeV is out of bounds, it will not be used" << G4endl;
G4cerr << " Should be >0. Please check" << G4endl;
} else {
energyMax = p;
#ifdef debug
if (verboseLevel >= 1 ) {
G4cout << " CCalPrimaryGeneratorAction: setting max. value of energy to "
<< energyMax/GeV << " GeV " << G4endl;
<< energyMax/GeV << " GeV " << G4endl;
}
#endif
}
@@ -235,14 +233,14 @@ void CCalPrimaryGeneratorAction::SetMinimumPhi(G4double p){
if (std::fabs(p)>2.*pi) {
G4cerr << "CCalPrimaryGeneratorAction::SetMinimumPhi: setting value quite "
<< "large" << G4endl;
<< "large" << G4endl;
G4cerr << " Should be given in radians - Please check" << G4endl;
} else {
phiMin = std::fabs(p);
#ifdef debug
if (verboseLevel >= 1 ) {
G4cout << " CCalPrimaryGeneratorAction: setting min. value of phi to "
<< phiMin << G4endl;
<< phiMin << G4endl;
}
#endif
}
@@ -253,14 +251,14 @@ void CCalPrimaryGeneratorAction::SetMaximumPhi(G4double p){
if (std::fabs(p)>2.*pi) {
G4cerr << "CCalPrimaryGeneratorAction::SetMaximumPhi: setting value quite "
<< "large" << G4endl;
<< "large" << G4endl;
G4cerr << " Should be given in radians - Please check" << G4endl;
} else {
phiMax = std::fabs(p);
#ifdef debug
if (verboseLevel >= 1 ) {
G4cout << " CCalPrimaryGeneratorAction: setting max. value of phi to "
<< phiMax << G4endl;
<< phiMax << G4endl;
}
#endif
}
@@ -271,14 +269,14 @@ void CCalPrimaryGeneratorAction::SetStepsPhi(G4int val){
if (val <= 0) {
G4cerr << "CCalPrimaryGeneratorAction::SetStepsPhi: value " << val
<< " is out of bounds, it will not be used" << G4endl;
<< " is out of bounds, it will not be used" << G4endl;
G4cerr << " Should be > 0 Please check" << G4endl;
} else {
phiSteps = val;
#ifdef debug
if (verboseLevel >= 1 ) {
G4cout << " CCalPrimaryGeneratorAction: setting no. of steps in phi to "
<< phiSteps << G4endl;
<< phiSteps << G4endl;
}
#endif
}
@@ -291,7 +289,7 @@ void CCalPrimaryGeneratorAction::SetMinimumEta(G4double p){
#ifdef debug
if (verboseLevel >= 1 ) {
G4cout << " CCalPrimaryGeneratorAction: setting min. value of eta to "
<< etaMin << G4endl;
<< etaMin << G4endl;
}
#endif
}
@@ -303,7 +301,7 @@ void CCalPrimaryGeneratorAction::SetMaximumEta(G4double p){
#ifdef debug
if (verboseLevel >= 1 ) {
G4cout << " CCalPrimaryGeneratorAction: setting max. value of eta to "
<< etaMax << G4endl;
<< etaMax << G4endl;
}
#endif
}
@@ -319,7 +317,7 @@ void CCalPrimaryGeneratorAction::SetStepsEta(G4int val){
#ifdef debug
if (verboseLevel >= 1 ) {
G4cout << " CCalPrimaryGeneratorAction: setting no. of steps in eta to "
<< etaSteps << G4endl;
<< etaSteps << G4endl;
}
#endif
}
@@ -344,53 +342,49 @@ void CCalPrimaryGeneratorAction::initialize(){
void CCalPrimaryGeneratorAction::print(G4int val){
#ifdef debug
if (verboseLevel >= val) {
if (generatorInput == singleRandom) {
G4cout << G4endl
<< "**********************************************************************" << G4endl
<< "* *" << G4endl
<< "* CCalPrimaryGeneratorAction DEFAULT Random Energy/Direction setting:*" << G4endl
<< "* *" << G4endl
<< "* *" << G4endl
<< "* Energy in [ "<< energyMin/GeV << " - " << energyMax/GeV << "] (GeV) "<< G4endl
<< "* Phi angle in [ "<< phiMin << " - " << phiMax << "] (rad) "<< G4endl
<< "* [ "<< phiMin/degree << " - " << phiMax/degree << "] (deg) "<< G4endl
<< "* Eta in [ "<< etaMin << " - " << etaMax << "] "<< G4endl
<< "* *" << G4endl
<< "* *" << G4endl
<< "**********************************************************************" << G4endl;
<< "**********************************************************************" << G4endl
<< "* *" << G4endl
<< "* CCalPrimaryGeneratorAction DEFAULT Random Energy/Direction setting:*" << G4endl
<< "* *" << G4endl
<< "* *" << G4endl
<< "* Energy in [ "<< energyMin/GeV << " - " << energyMax/GeV << "] (GeV) "<< G4endl
<< "* Phi angle in [ "<< phiMin << " - " << phiMax << "] (rad) "<< G4endl
<< "* [ "<< phiMin/degree << " - " << phiMax/degree << "] (deg) "<< G4endl
<< "* Eta in [ "<< etaMin << " - " << etaMax << "] "<< G4endl
<< "* *" << G4endl
<< "* *" << G4endl
<< "**********************************************************************" << G4endl;
} else if (generatorInput == singleScan) {
G4cout << G4endl
<< "**********************************************************************" << G4endl
<< "* *" << G4endl
<< "* CCalPrimaryGeneratorAction DEFAULT Scan Direction settings : *" << G4endl
<< "* *" << G4endl
<< "* *" << G4endl
<< "* Phi angle in [ " << phiMin/degree << " - " << phiMax/degree << "] (deg) " << G4endl
<< "* Eta in [ " << etaMin << " - " << etaMax << "] " << G4endl
<< "* Steps along eta " << etaSteps << " and along phi " << phiSteps << G4endl
<< "* *" << G4endl
<< "* *" << G4endl
<< "**********************************************************************" << G4endl;
<< "**********************************************************************" << G4endl
<< "* *" << G4endl
<< "* CCalPrimaryGeneratorAction DEFAULT Scan Direction settings : *" << G4endl
<< "* *" << G4endl
<< "* *" << G4endl
<< "* Phi angle in [ " << phiMin/degree << " - " << phiMax/degree << "] (deg) " << G4endl
<< "* Eta in [ " << etaMin << " - " << etaMax << "] " << G4endl
<< "* Steps along eta " << etaSteps << " and along phi " << phiSteps << G4endl
<< "* *" << G4endl
<< "* *" << G4endl
<< "**********************************************************************" << G4endl;
} else if (generatorInput == singleFixed) {
G4cout << G4endl
<< "*******************************************************************" << G4endl
<< "* *" << G4endl
<< "* CCalPrimaryGeneratorAction: Current settings : *" << G4endl
<< "* *" << G4endl
<< "* " << particleGun->GetNumberOfParticles()
<< " " << particleGun->GetParticleDefinition()->GetParticleName()
<< " of " << particleGun->GetParticleEnergy()/GeV << " GeV" << G4endl
<< "* will be shot from " << particleGun->GetParticlePosition() << G4endl;
<< "*******************************************************************" << G4endl
<< "* *" << G4endl
<< "* CCalPrimaryGeneratorAction: Current settings : *" << G4endl
<< "* *" << G4endl
<< "* " << particleGun->GetNumberOfParticles()
<< " " << particleGun->GetParticleDefinition()->GetParticleName()
<< " of " << particleGun->GetParticleEnergy()/GeV << " GeV" << G4endl
<< "* will be shot from " << particleGun->GetParticlePosition() << G4endl;
G4cout << "* in direction " << particleGun->GetParticleMomentumDirection() << G4endl;
G4cout << "* *" << G4endl
<< "* *" << G4endl
<< "*******************************************************************" << G4endl;
G4cout << "* *" << G4endl
<< "* *" << G4endl
<< "*******************************************************************" << G4endl;
}
}
#endif
}
}
@@ -159,7 +159,7 @@ CCalPrimaryGeneratorMessenger::~CCalPrimaryGeneratorMessenger() {
}
void CCalPrimaryGeneratorMessenger::SetNewValue(G4UIcommand * command,
G4String newValues) {
G4String newValues) {
if (command == verboseCmd)
myAction->SetVerboseLevel(verboseCmd->GetNewIntValue(newValues));
else if (command == rndmCmd)
@@ -51,7 +51,7 @@ CCalRotationMatrixFactory* CCalRotationMatrixFactory::getInstance(const G4String
return getInstance();
} else {
G4cerr << "ERROR: Trying to get Rotation Matrices from " << rotfile
<< " when previously were retrieved from " << file <<"." << G4endl;
<< " when previously were retrieved from " << file <<"." << G4endl;
return 0;
}
}
@@ -60,7 +60,7 @@ CCalRotationMatrixFactory* CCalRotationMatrixFactory::getInstance(const G4String
CCalRotationMatrixFactory* CCalRotationMatrixFactory::getInstance(){
if (file=="") {
G4cerr << "ERROR: You haven't defined which file to use for materials in "
<< "CCalRotationMatrixFactory::getInstance(G4String)" << G4endl;
<< "CCalRotationMatrixFactory::getInstance(G4String)" << G4endl;
return 0;
}
@@ -75,7 +75,7 @@ CCalRotationMatrixFactory* CCalRotationMatrixFactory::getInstance(){
void CCalRotationMatrixFactory::setFileName(const G4String& rotfile) {
if (rotfile!=file && file!="") {
G4cerr << "ERROR: Trying to change Rotation Matrices file name to "
<< rotfile << "." << G4endl;
<< rotfile << "." << G4endl;
G4cerr << " Using previous file: " << file << G4endl;
}
file=rotfile;
@@ -103,17 +103,17 @@ G4RotationMatrix* CCalRotationMatrixFactory::findMatrix(const G4String & rot) {
}
G4RotationMatrix* CCalRotationMatrixFactory::AddMatrix(const G4String& name,
G4double th1,
G4double phi1,
G4double th2,
G4double phi2,
G4double th3,
G4double phi3){
G4double th1,
G4double phi1,
G4double th2,
G4double phi2,
G4double th3,
G4double phi3){
G4double sinth1, sinth2, sinth3, costh1, costh2, costh3;
G4double sinph1, sinph2, sinph3, cosph1, cosph2, cosph3;
G4double TH1 = th1/deg, TH2 = th2/deg, TH3 = th3/deg;
G4double PH1 = phi1/deg, PH2 = phi2/deg, PH3 = phi3/deg;
if (TH1 == 0.0 || TH1 == 360) {
sinth1 = 0.0; costh1 = 1.0;
} else if (TH1 == 90.0 || TH1 == -270) {
@@ -137,7 +137,7 @@ G4RotationMatrix* CCalRotationMatrixFactory::AddMatrix(const G4String& name,
} else {
sinth2 = std::sin(th2); costh2 = std::cos(th2);
}
if (TH3 == 0.0 || TH3 == 360) {
sinth3 = 0.0; costh3 = 1.0;
} else if (TH3 == 90.0 || TH2 == -270) {
@@ -173,7 +173,7 @@ G4RotationMatrix* CCalRotationMatrixFactory::AddMatrix(const G4String& name,
} else {
sinph2 = std::sin(phi2); cosph2 = std::cos(phi2);
}
if (PH3 == 0.0 || PH3 == 360) {
sinph3 = 0.0; cosph3 = 1.0;
} else if (PH3 == 90.0 || PH3 == -270) {
@@ -185,7 +185,7 @@ G4RotationMatrix* CCalRotationMatrixFactory::AddMatrix(const G4String& name,
} else {
sinph3 = std::sin(phi3); cosph3 = std::cos(phi3);
}
//xprime axis coordinates
CLHEP::Hep3Vector xprime(sinth1*cosph1,sinth1*sinph1,costh1);
//yprime axis coordinates
@@ -217,18 +217,18 @@ G4RotationMatrix* CCalRotationMatrixFactory::AddMatrix(const G4String& name,
CCalRotationMatrixFactory::CCalRotationMatrixFactory():theMatrices(){
G4String path = "NULL";
if (getenv("CCAL_GLOBALPATH"))
path = getenv("CCAL_GLOBALPATH");
if (std::getenv("CCAL_GLOBALPATH"))
path = std::getenv("CCAL_GLOBALPATH");
G4cout << " ==> Opening file " << file << "..." << G4endl;
std::ifstream is;
bool ok = openGeomFile(is, path, file);
G4bool ok = openGeomFile(is, path, file);
if (!ok) {
G4ExceptionDescription ed;
ed << "Could not open file " << file << " ... Exiting!" << G4endl;
G4Exception("CCalRotationMatrixFactory::CCalRotationMatrixFactory()",
"ccal002",
FatalException,ed);
"ccal002",
FatalException,ed);
}
//////////////////////////////////////////////////
@@ -48,7 +48,7 @@ void CCalRunAction::BeginOfRunAction(const G4Run* aRun)
G4AnalysisManager* analysis = G4AnalysisManager::Instance();
//cleanup
G4int timeHist = analysis->GetH1Id("h300");
for (int i=0; i<numberOfTimeSlices; i++) {
for (G4int i=0; i<numberOfTimeSlices; ++i) {
analysis->GetH1(timeHist+i)->reset();
}
}
@@ -69,19 +69,19 @@ void CCalRunAction::Book()
// Open an output file
analysisManager->OpenFile("ccal");
G4cout << "********************************************" << G4endl
<< "* o/p file ccal" << G4endl
<< "********************************************" << G4endl
<< G4endl;
<< "* o/p file ccal" << G4endl
<< "********************************************" << G4endl
<< G4endl;
// Create a tuple :
// Create ntuple
analysisManager->CreateNtuple("ntuple1", "Event info");
for (int i=0;i<28;i++) {
for (G4int i=0;i<28;++i) {
G4String tupleidString = "hcal" + std::to_string( i );
analysisManager->CreateNtupleFColumn( tupleidString.c_str() );
}
for (int i=0; i<49; i++) {
for (G4int i=0; i<49; ++i) {
G4String tupleidString = "ecal" + std::to_string( i );
analysisManager->CreateNtupleFColumn( tupleidString.c_str() );
}
@@ -98,13 +98,13 @@ void CCalRunAction::Book()
//Create histograms. Save the ID of the first histogram in each block
//
//Energy deposit in Hcal layers
for (int i = 0; i<28; i++) {
for (G4int i = 0; i<28; ++i) {
G4String idString = "h" + std::to_string( i+100 );
G4String ntupletagString = "Energy Deposit in Hcal Layer" + std::to_string( i ) + " in GeV";
analysisManager->CreateH1( idString.c_str(), ntupletagString.c_str(), 100, 0., 1.0 );
}
// Energy deposits in Ecal towers
for (int i = 0; i<49; i++) {
for (G4int i = 0; i<49; ++i) {
G4String idString = "h" + std::to_string( i+200 );
G4String ntupletagString = "Energy Deposit in Ecal Tower" + std::to_string( i ) + " in GeV";
analysisManager->CreateH1( idString.c_str(), ntupletagString.c_str(), 100, 0., 1.0 );
@@ -112,15 +112,15 @@ void CCalRunAction::Book()
// Total energy deposit
analysisManager->CreateH1( "h4000", "Total energy deposited in GeV", 100, 0., 100.0 );
// Time slices
for (int i=0; i<numberOfTimeSlices; i++){
// Time slices
for (G4int i=0; i<numberOfTimeSlices; ++i){
G4String idString = "h" + std::to_string( i+300 );
G4String ntupletagString = "Time slice " + std::to_string( i ) + " nsec energy profile in GeV";
analysisManager->CreateH1( idString.c_str(), ntupletagString.c_str(), 100, 0., 100.0 );
}
// Profile of lateral energy deposit in Hcal
for (int i = 0; i<70; i++) {
for (G4int i = 0; i<70; ++i) {
G4String idString = "h" + std::to_string( i+500 );
G4String ntupletagString = "Lateral energy profile at " + std::to_string( i ) + " cm in GeV";
analysisManager->CreateH1( idString.c_str(), ntupletagString.c_str(), 100, 0., 10.0 );
@@ -51,21 +51,21 @@ void CCalSDList::addTracker(nameType name){
theList->trackerSD.push_back(name);
}
nameType CCalSDList::getCaloSDName(int i){
nameType CCalSDList::getCaloSDName(G4int i){
if (i>=theList->getNumberOfCaloSD() || i<0) {
G4cout << "CCalSDList invalid calo SD no: " << i << " max is "
<< theList->getNumberOfCaloSD() << G4endl;
<< theList->getNumberOfCaloSD() << G4endl;
return " ";
} else
return theList->caloSD[i];
}
nameType CCalSDList::getTrackerSDName(int i){
nameType CCalSDList::getTrackerSDName(G4int i){
if (i>=theList->getNumberOfTrackerSD() || i<0) {
G4cout << "CCalSDList invalid tracker SD no: " << i << " max is "
<< theList->getNumberOfTrackerSD() << G4endl;
<< theList->getNumberOfTrackerSD() << G4endl;
return " ";
}
else
@@ -73,12 +73,12 @@ nameType CCalSDList::getTrackerSDName(int i){
}
int CCalSDList::getNumberOfCaloSD(){
G4int CCalSDList::getNumberOfCaloSD(){
return theList->caloSD.size();
}
int CCalSDList::getNumberOfTrackerSD(){
G4int CCalSDList::getNumberOfTrackerSD(){
return theList->trackerSD.size();
}
@@ -49,8 +49,8 @@ CCalSensAssign* CCalSensAssign::getInstance() {
CCalSensAssign::CCalSensAssign() {}
bool CCalSensAssign::assign() {
bool result = false;
G4bool CCalSensAssign::assign() {
G4bool result = false;
CCalSensitiveDetectors* sensDets = CCalSensitiveDetectors::getInstance();
for (std::map<G4String,G4VSensitiveDetector*>::const_iterator sens_it = sens_.begin();
@@ -61,7 +61,7 @@ bool CCalSensAssign::assign() {
G4SDManager::GetSDMpointer()->AddNewDetector(sens);
#ifdef debug
G4cout << "Add " << sens->GetName()
<< " to the list of Sensitive detetctors" << G4endl;
<< " to the list of Sensitive detetctors" << G4endl;
#endif
}
}
@@ -69,9 +69,9 @@ bool CCalSensAssign::assign() {
return result;
}
bool CCalSensAssign::stackingAction() {
G4bool CCalSensAssign::stackingAction() {
bool result = false;
G4bool result = false;
//Create the stacking manager required by Calorimeter
if (G4RunManager::GetRunManager()->GetUserStackingAction() == 0) {
G4cout << "***CCalSensAssign creating a CCalStackingAction ***" << G4endl;
@@ -79,14 +79,14 @@ bool CCalSensAssign::stackingAction() {
result = true;
} else {
G4cout << "***CCalSens: a StackingAction already exists. "
<< "Maybe not the one CCaloSD needs?" << G4endl;
<< "Maybe not the one CCaloSD needs?" << G4endl;
}
return result;
}
bool CCalSensAssign::addCaloSD(G4String name,
CCalVOrganization* numberingScheme) {
G4bool CCalSensAssign::addCaloSD(G4String name,
CCalVOrganization* numberingScheme) {
sens_[name] = new CCaloSD(name, numberingScheme);
return true;
@@ -40,67 +40,70 @@
CCalSensitiveConfiguration * CCalSensitiveConfiguration::instance = 0;
CCalSensitiveConfiguration* CCalSensitiveConfiguration::getInstance(){
CCalSensitiveConfiguration* CCalSensitiveConfiguration::getInstance()
{
if (!instance)
instance = new CCalSensitiveConfiguration;
return instance;
}
int CCalSensitiveConfiguration::getSensitiveFlag(const G4String& n) /*const*/ {
int flag = -1;
CCalSensitiveConfIterator it = theConfiguration.find(n);
G4int CCalSensitiveConfiguration::getSensitiveFlag(const G4String& n) /*const*/
{
G4int flag = -1;
auto it = theConfiguration.find(n);
if (it != theConfiguration.end())
if (it != theConfiguration.cend())
flag = (*it).second.SensitiveFlag;
else {
G4cerr << "ERROR: In CCalSensitiveConfiguration::getSensitiveFlag(const "
<< "G4String& n)" << G4endl
<< " " << n << " not found in configuration file" << G4endl;
<< "G4String& n)" << G4endl
<< " " << n << " not found in configuration file" << G4endl;
}
return flag;
}
G4String CCalSensitiveConfiguration::getFileName(const G4String& n) /*const*/ {
G4String CCalSensitiveConfiguration::getFileName(const G4String& n) /*const*/
{
G4String fn;
CCalSensitiveConfIterator it = theConfiguration.find(n);
auto it = theConfiguration.find(n);
if (it != theConfiguration.end())
if (it != theConfiguration.cend())
fn = (*it).second.FileName;
else {
G4cerr << "ERROR: In CCalSensitiveConfiguration::getFileName(const "
<< "G4String& n)" << G4endl
<< " " << n << " not found in configuration file" << G4endl;
<< "G4String& n)" << G4endl
<< " " << n << " not found in configuration file" << G4endl;
}
return fn;
}
CCalSensitiveConfiguration::CCalSensitiveConfiguration(): theConfiguration() {
CCalSensitiveConfiguration::CCalSensitiveConfiguration(): theConfiguration()
{
///////////////////////////////////////////////////////////////
// Open the file
G4String pathName = getenv("CCAL_CONFPATH");
G4String fileenv = getenv("CCAL_SENSITIVECONF");
G4String pathName = std::getenv("CCAL_CONFPATH");
G4String fileenv = std::getenv("CCAL_SENSITIVECONF");
if (!pathName || !fileenv) {
G4ExceptionDescription ed;
ed << "ERROR: CCAL_SENSITIVECONF and/or CCAL_CONFPATH not set" << G4endl
<< " Set them to the sensitive configuration file/path" << G4endl;
G4Exception("CCalSensitiveConfiguration::CCalSensitiveConfiguration()",
"ccal005",
FatalException,ed);
"ccal005",
FatalException,ed);
}
G4cout << " ==> Opening file " << fileenv << "..." << G4endl;
std::ifstream is;
bool ok = openGeomFile(is, pathName, fileenv);
G4bool ok = openGeomFile(is, pathName, fileenv);
if (!ok)
{
G4Exception("CCalSensitiveConfiguration::CCalSensitiveConfiguration()",
"ccal006",
FatalException,
"Unable to open sensitive input file");
"ccal006",
FatalException,
"Unable to open sensitive input file");
}
@@ -114,8 +117,8 @@ CCalSensitiveConfiguration::CCalSensitiveConfiguration(): theConfiguration() {
is >> gcinfo.SensitiveFlag >> jump;
#ifdef debug
G4cout << "CCalSensitiveConfiguration constructor: Read \"" << name
<< "\" \"" << gcinfo.FileName << "\"" << tab << gcinfo.SensitiveFlag
<< G4endl;
<< "\" \"" << gcinfo.FileName << "\"" << tab << gcinfo.SensitiveFlag
<< G4endl;
#endif
theConfiguration[name] = gcinfo;
}
@@ -35,15 +35,16 @@
CCalSensitiveDetectors* CCalSensitiveDetectors::theInstance = 0;
CCalSensitiveDetectors* CCalSensitiveDetectors::getInstance() {
CCalSensitiveDetectors* CCalSensitiveDetectors::getInstance()
{
if (!theInstance) theInstance = new CCalSensitiveDetectors;
return theInstance;
}
void CCalSensitiveDetectors::registerVolume (const G4String& string,
G4LogicalVolume* logv) {
G4LogicalVolume* logv)
{
theLVs.insert(mmslv::value_type(string, logv));
#ifdef debug
G4cout << "CCalSensitiveDetectors : Register " << logv->GetName()
@@ -51,9 +52,9 @@ void CCalSensitiveDetectors::registerVolume (const G4String& string,
#endif
}
std::vector<G4LogicalVolume*> CCalSensitiveDetectors::getVolumes (const G4String& string,
bool exist) {
std::vector<G4LogicalVolume*>
CCalSensitiveDetectors::getVolumes (const G4String& string, G4bool exist)
{
mmslv::const_iterator mmscite;
std::pair<mmslv::iterator, mmslv::iterator> mmsdi;
mmsdi = theLVs.equal_range(string);
@@ -63,16 +64,16 @@ std::vector<G4LogicalVolume*> CCalSensitiveDetectors::getVolumes (const G4String
}
if (exist) G4cout << "CCalSensitiveDetector : " << lvs.size()
<< " detectors for " << string << G4endl;
<< " detectors for " << string << G4endl;
return lvs;
}
bool CCalSensitiveDetectors::setSensitive(const G4String& string,
G4VSensitiveDetector* sens) {
bool result=false;
G4bool CCalSensitiveDetectors::setSensitive(const G4String& string,
G4VSensitiveDetector* sens)
{
G4bool result=false;
mmslv::const_iterator mmscite;
std::pair<mmslv::iterator, mmslv::iterator> mmsdi;
mmsdi = theLVs.equal_range(string);
@@ -82,9 +83,8 @@ bool CCalSensitiveDetectors::setSensitive(const G4String& string,
result = true;
#ifdef debug
G4cout << " Associate SD " << sens->GetName() << " to " << lv->GetName()
<< G4endl;
<< G4endl;
#endif
}
return result;
}
@@ -61,9 +61,9 @@ void CCalStackingAction::initialize(){
numberOfSD = CCalSDList::getInstance()->getNumberOfCaloSD();
#ifdef debug
G4cout << "CCalStackingAction look for " << numberOfSD
<< " calorimeter-like SD" << G4endl;
<< " calorimeter-like SD" << G4endl;
#endif
int i = 0;
G4int i = 0;
for (i=0; i<numberOfSD; i++) {
G4String theName(CCalSDList::getInstance()->getCaloSDName(i));
SDName[i] = theName;
@@ -81,17 +81,17 @@ void CCalStackingAction::initialize(){
G4VSensitiveDetector* aSD = sd->FindSensitiveDetector(SDName[i]);
if (aSD==0) {
#ifdef debug
G4cout << "CCalStackingAction::initialize: No SD with name " << SDName[i]
<< " in this Setup " << G4endl;
G4cout << "CCalStackingAction::initialize: No SD with name " << SDName[i]
<< " in this Setup " << G4endl;
#endif
} else {
theCaloSD[i] = dynamic_cast<CCaloSD*>(aSD);
theCaloSD[i]->SetPrimaryID(0);
}
theCaloSD[i] = dynamic_cast<CCaloSD*>(aSD);
theCaloSD[i]->SetPrimaryID(0);
}
}
#ifdef debug
G4cout << "CCalStackingAction::initialize: Could not get SD Manager !"
<< G4endl;
<< G4endl;
#endif
}
}
@@ -103,14 +103,14 @@ G4ClassificationOfNewTrack CCalStackingAction::ClassifyNewTrack(const G4Track* a
#ifdef ddebug
G4TrackStatus status = aTrack->GetTrackStatus();
G4cout << "Classifying track " << aTrack->GetTrackID()
<< " with status " << aTrack->GetTrackStatus() << G4endl;
<< " with status " << aTrack->GetTrackStatus() << G4endl;
#endif
if (aTrack->GetGlobalTime() > fTimeLimit) {
#ifdef debug
G4cout << "Kills particle " << aTrack->GetDefinition()->GetParticleName()
<< " of energy " << aTrack->GetKineticEnergy()/MeV << " MeV"
<< G4endl;
<< " of energy " << aTrack->GetKineticEnergy()/MeV << " MeV"
<< G4endl;
#endif
return classification = fKill;
}
@@ -121,9 +121,9 @@ G4ClassificationOfNewTrack CCalStackingAction::ClassifyNewTrack(const G4Track* a
/////////////////
if (parentID == 0 ) {
if ( nurgent == 0) {
nurgent++;
classification = fUrgent;
setPrimaryID(aTrack->GetTrackID());
nurgent++;
classification = fUrgent;
setPrimaryID(aTrack->GetTrackID());
}
else classification = fWaiting;
}
@@ -134,17 +134,17 @@ G4ClassificationOfNewTrack CCalStackingAction::ClassifyNewTrack(const G4Track* a
if (parentID > 0) {
if (acceptSecondaries == 1) {
if (trackStartsInCalo(const_cast<G4Track *>(aTrack))!=0 )
classification = fUrgent;
else
classification = fWaiting;
if (trackStartsInCalo(const_cast<G4Track *>(aTrack))!=0 )
classification = fUrgent;
else
classification = fWaiting;
} else {
if(nurgent == 0){
nurgent++;
classification = fUrgent;
setPrimaryID(aTrack->GetTrackID());
} else
classification = fWaiting;
if(nurgent == 0){
nurgent++;
classification = fUrgent;
setPrimaryID(aTrack->GetTrackID());
} else
classification = fWaiting;
}
}
@@ -154,7 +154,7 @@ G4ClassificationOfNewTrack CCalStackingAction::ClassifyNewTrack(const G4Track* a
#ifdef ddebug
G4cout << " returning classification= " << classification
<< " for track "<< aTrack->GetTrackID() << G4endl;
<< " for track "<< aTrack->GetTrackID() << G4endl;
#endif
return classification;
@@ -167,7 +167,7 @@ void CCalStackingAction::NewStage(){
G4cout << "In NewStage with stage = " << stage << G4endl;
#endif
if (stage <end) {
nurgent = 0;
nurgent = 0;
setPrimaryID(0);
acceptSecondaries = 0;
stackManager->ReClassify();
@@ -175,7 +175,7 @@ void CCalStackingAction::NewStage(){
if (stackManager->GetNUrgentTrack() == 0) {
stage = stageLevel(stage+1);
}
}
}
@@ -193,7 +193,7 @@ G4bool CCalStackingAction::trackStartsInCalo(const G4Track* ){
void CCalStackingAction::setPrimaryID(G4int id){
for (int i=0; i<numberOfSD; i++){
for (G4int i=0; i<numberOfSD; i++){
if(theCaloSD[i] != 0)theCaloSD[i]->SetPrimaryID(id);
}
@@ -72,7 +72,7 @@ void CCalSteppingAction::UserSteppingAction(const G4Step* aStep)
timeDeposit[TSliceID] += fde;
G4ThreeVector HitPoint = 0.5*(PostStepPoint->GetPosition()+
PreStepPoint->GetPosition());
PreStepPoint->GetPosition());
// Because the beam axis has been defined as the x-axis,
// the lateral displacement is given in terms of the y and z positions.
G4double perp =
@@ -103,7 +103,7 @@ void CCalSteppingAction::endOfEvent(){
#ifdef debug
G4cout << "CCalAnalysis::InsertLateralProfile: Total filled Profile Hcal"
<< " histo " << totalFilledProfileHcal << G4endl;
<< " histo " << totalFilledProfileHcal << G4endl;
#endif
static G4int IDTimeHist = -1;
@@ -125,12 +125,12 @@ void CCalSteppingAction::endOfEvent(){
G4double t = j + 0.5;
man->FillH1(IDTimeProfile+1,t,timeDeposit[j]);
#ifdef debug
G4cout << "Fill Time profile histo 1 with " << t << " " << x << G4endl;
G4cout << "Fill Time profile histo 1 with " << t << " " << timeDeposit[j] << G4endl;
#endif
}
#ifdef debug
G4cout << "CCalAnalysis::InsertTime: Total filled Time profile histo "
<< totalFilledTimeProfile << G4endl;
<< totalFilledTimeProfile << G4endl;
#endif
for (G4int i=0; i<70; i++){LateralProfile[i] = 0.f;}
@@ -31,7 +31,7 @@
#include "G4TouchableHistory.hh"
#include "globals.hh"
int CCalVOrganization::Levels(const G4Step* aStep) const {
G4int CCalVOrganization::Levels(const G4Step* aStep) const {
//Find number of levels
G4TouchableHistory* theTouchable =
@@ -40,13 +40,13 @@ int CCalVOrganization::Levels(const G4Step* aStep) const {
}
void CCalVOrganization::DetectorLevel(const G4Step* aStep, int& level,
int* copyno, G4String* name) const {
void CCalVOrganization::DetectorLevel(const G4Step* aStep, G4int& level,
G4int* copyno, G4String* name) const {
//Get name and copy numbers
G4TouchableHistory* theTouchable =
(G4TouchableHistory*)( aStep->GetPreStepPoint()->GetTouchable() );
for ( int ii = 0; ii < level; ii++ ) {
for ( G4int ii = 0; ii < level; ++ii ) {
name[ level - ii - 1 ] = theTouchable->GetVolume(ii)->GetName();
copyno[ level - ii - 1 ] = theTouchable->GetReplicaNumber(ii);
}
@@ -45,7 +45,7 @@ CCalVisualisable::CCalVisualisable(G4String file):visFile(file) {
readFile();
}
bool CCalVisualisable::readFile(G4String file) {
G4bool CCalVisualisable::readFile(G4String file) {
visFile=file;
return readFile();
}
@@ -59,28 +59,28 @@ void CCalVisualisable::setDefault(){
theParameters[PseudoVolumes] = visParameters(false);
}
void CCalVisualisable::setColor(visType v, double r, double g, double b){
void CCalVisualisable::setColor(visType v, G4double r, G4double g, G4double b){
theParameters[v].rColor=r;
theParameters[v].gColor=g;
theParameters[v].bColor=b;
}
void CCalVisualisable::setPath() {
pathName = getenv(visEnvName);
pathName = std::getenv(visEnvName);
if (!pathName) {
G4ExceptionDescription ed;
ed << "ERROR: " << visEnvName << " environmental variable not set!"
<< G4endl;
<< G4endl;
ed << " Set it and restart." << G4endl;
G4Exception("CCalVisualisable::setPath()","ccal007",
FatalException,ed);
FatalException,ed);
}
}
bool CCalVisualisable::readFile() {
G4bool CCalVisualisable::readFile() {
if (visFile=="") {
G4cerr << "ERROR: No file was specified from which to read Visualisation parameters"
<< G4endl;
<< G4endl;
return false;
}
@@ -95,7 +95,7 @@ bool CCalVisualisable::readFile() {
#ifdef debug
G4cout << "Viualisable : Path " << pathname << " FIle " << visFile << G4endl;
#endif
bool ok = openGeomFile(is, pathname, visFile);
G4bool ok = openGeomFile(is, pathname, visFile);
if (!ok) {
G4cout << "WARNING: Could not read " << visFile << G4endl;
G4cout << " Default visualization parameters will be used." << G4endl;
@@ -124,12 +124,12 @@ bool CCalVisualisable::readFile() {
else {
vt=Undefined;
G4cerr << "WARNING: Unknown type of visualisable object \"" << viewvol
<< "\"." << G4endl;
<< "\"." << G4endl;
}
int isvisible, wireframe;
double r, g, b;
G4int isvisible, wireframe;
G4double r, g, b;
is >> isvisible >> r >> g >> b >> wireframe >> jump;
@@ -140,8 +140,8 @@ bool CCalVisualisable::readFile() {
if (vt!=Undefined) {
#ifdef debug
G4cout << tab << viewvol << tab << isvisible << tab
<< r << " " << g << " "<< b << tab
<< wireframe << G4endl;
<< r << " " << g << " "<< b << tab
<< wireframe << G4endl;
#endif
theParameters[vt]=visParameters(isvisible, r, g, b, wireframe);
}
@@ -156,16 +156,16 @@ bool CCalVisualisable::readFile() {
return true;
}
double CCalVisualisable::checkColorRange(double cvalue, char ctype) const {
G4double CCalVisualisable::checkColorRange(G4double cvalue, char ctype) const {
if (cvalue>1) {
G4cerr << "ERROR: In " << visFile << ". Color " << ctype << "="
<< cvalue << " > 1" << G4endl;
<< cvalue << " > 1" << G4endl;
G4cerr << " It will be reset to 1." << G4endl;
return 1.;
}
if (cvalue<0) {
G4cerr << "ERROR: In " << visFile << ". Color " << ctype << "="
<< cvalue << " < 0" << G4endl;
<< cvalue << " < 0" << G4endl;
G4cerr << " It will be reset to 0." << G4endl;
return 0.;
}
@@ -32,8 +32,8 @@
//#define debug
unsigned int CCaloOrganization::packindex(int det, int z, int eta,
int phi) const {
unsigned int CCaloOrganization::packindex(G4int det, G4int z, G4int eta,
G4int phi) const {
//So this is the actual encoding of the index:
//top 4 bits encode Detector type
//
@@ -45,13 +45,13 @@ unsigned int CCaloOrganization::packindex(int det, int z, int eta,
idx+=(phi&1023); //bits 0-9
#ifdef debug
G4cout << " ECAL packing " << det << " " << z << " " << eta << " " << phi
<< " into " << idx << G4endl;
<< " into " << idx << G4endl;
#endif
return idx;
}
unsigned int CCaloOrganization::packindex(int det, int depth, int z, int eta,
int phi) const {
unsigned int CCaloOrganization::packindex(G4int det, G4int depth, G4int z, G4int eta,
G4int phi) const {
//So this is the actual encoding of the index:
//top 4 bits encode Detector type
//next 4 bits encode depth information
@@ -64,14 +64,14 @@ unsigned int CCaloOrganization::packindex(int det, int depth, int z, int eta,
idx+=(phi&1023); //bits 0-9
#ifdef debug
G4cout << " HCAL packing " << det << " " << depth << " " << z << " " << eta
<< " " << phi << " into " << idx << G4endl;
<< " " << phi << " into " << idx << G4endl;
#endif
return idx;
}
void CCaloOrganization::unpackindex(const unsigned int& idx, int& det, int& z,
int& eta, int& phi) const {
void CCaloOrganization::unpackindex(const unsigned int& idx, G4int& det, G4int& z,
G4int& eta, G4int& phi) const {
det = (idx>>28)&15;
z = (idx>>20)&1;
z = 2*z-1;
@@ -80,9 +80,9 @@ void CCaloOrganization::unpackindex(const unsigned int& idx, int& det, int& z,
}
void CCaloOrganization::unpackindex(const unsigned int& idx, int& det,
int& depth, int& z, int& eta,
int& phi) const {
void CCaloOrganization::unpackindex(const unsigned int& idx, G4int& det,
G4int& depth, G4int& z, G4int& eta,
G4int& phi) const {
det = (idx>>28)&15;
depth=(idx>>24)&15;
z = (idx>>20)&1;
@@ -91,65 +91,65 @@ void CCaloOrganization::unpackindex(const unsigned int& idx, int& det,
}
int CCaloOrganization::getUnitWithMaxEnergy(std::map<int,float,std::less<int> >& themap){
G4int CCaloOrganization::getUnitWithMaxEnergy(std::map<G4int,G4float,std::less<G4int> >& themap){
//look for max
int UnitWithMaxEnergy = 0;
float maxEnergy = 0.;
for(std::map<int,float,std::less<int> >::iterator iter = themap.begin();
G4int UnitWithMaxEnergy = 0;
G4float maxEnergy = 0.;
for(std::map<G4int,G4float,std::less<G4int> >::iterator iter = themap.begin();
iter != themap.end(); iter++){
if( maxEnergy < (*iter).second) {
maxEnergy = (*iter).second;
if( maxEnergy < (*iter).second) {
maxEnergy = (*iter).second;
UnitWithMaxEnergy = (*iter).first;
}
}
}
}
#ifdef debug
G4cout << " *** max energy of " << maxEnergy << " MeV was found in Unit id "
<< UnitWithMaxEnergy;
int det,z,eta,phi;
<< UnitWithMaxEnergy;
G4int det,z,eta,phi;
unpackindex(UnitWithMaxEnergy, det, z, eta, phi);
G4cout << " corresponding to z= " << z << " eta= " << eta << " phi = " << phi
<< G4endl;
<< G4endl;
#endif
return UnitWithMaxEnergy;
}
float CCaloOrganization::energyInMatrix(int nCellInEta, int nCellInPhi,
int crystalWithMaxEnergy,
std::map<int,float,std::less<int> >& themap){
G4float CCaloOrganization::energyInMatrix(G4int nCellInEta, G4int nCellInPhi,
G4int crystalWithMaxEnergy,
std::map<G4int,G4float,std::less<G4int> >& themap){
int det,z,eta,phi;
G4int det,z,eta,phi;
this->unpackindex(crystalWithMaxEnergy, det, z, eta, phi);
int ncristals=0;
int goBackInEta = nCellInEta/2;
int goBackInPhi = nCellInPhi/2;
int startEta = eta-goBackInEta;
int startPhi = phi-goBackInPhi;
G4int ncristals=0;
G4int goBackInEta = nCellInEta/2;
G4int goBackInPhi = nCellInPhi/2;
G4int startEta = eta-goBackInEta;
G4int startPhi = phi-goBackInPhi;
float totalEnergy = 0.;
G4float totalEnergy = 0.;
for(int ieta=startEta; ieta<startEta+nCellInEta; ieta++){
for(int iphi=startPhi; iphi<startPhi+nCellInPhi; iphi++){
for(G4int ieta=startEta; ieta<startEta+nCellInEta; ieta++){
for(G4int iphi=startPhi; iphi<startPhi+nCellInPhi; iphi++){
int index = this->packindex(det,z,ieta,iphi);
G4int index = this->packindex(det,z,ieta,iphi);
totalEnergy += themap[index];
ncristals+=1;
#ifdef debug
G4cout << "ieta - iphi - E = " << ieta << " " << iphi << " "
<< themap[index] << G4endl;
<< themap[index] << G4endl;
#endif
}
}
#ifdef debug
G4cout << "Energy in " << nCellInEta << " cells in eta times "
<< nCellInPhi << " cells in phi matrix = " << totalEnergy
<< " for " << ncristals << " crystals" << G4endl;
<< nCellInPhi << " cells in phi matrix = " << totalEnergy
<< " for " << ncristals << " crystals" << G4endl;
#endif
return totalEnergy;
@@ -94,7 +94,7 @@ void CCaloSD::getStepInfo(const G4Step* aStep) {
PreStepPoint = aStep->GetPreStepPoint();
PostStepPoint= aStep->GetPostStepPoint();
HitPoint = PreStepPoint->GetPosition();
HitPoint = PreStepPoint->GetPosition();
theTrack = aStep->GetTrack();
CurrentPV= PreStepPoint->GetPhysicalVolume();
@@ -102,7 +102,7 @@ void CCaloSD::getStepInfo(const G4Step* aStep) {
G4String pname = theTrack->GetDefinition()->GetParticleName();
G4double de = aStep->GetTotalEnergyDeposit();
//G4cout << "##### Process new step dE= " << de
// << " " << pname << " inside " << GetName() << G4endl;
// << " " << pname << " inside " << GetName() << G4endl;
const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
G4double weight = 1.;
@@ -141,12 +141,12 @@ G4bool CCaloSD::hitExists() {
// exists already:
G4bool found = false;
for (G4int j=0; j<theHC->entries(); ++j) {
for (std::size_t j=0; j<theHC->entries(); ++j) {
CCalG4Hit* aPreviousHit = (*theHC)[j];
if (aPreviousHit->getTrackID() == PrimaryID &&
aPreviousHit->getTimeSliceID() == TSliceID &&
aPreviousHit->getUnitID()== UnitID ) {
aPreviousHit->getTimeSliceID() == TSliceID &&
aPreviousHit->getUnitID()== UnitID ) {
CurrentHit = aPreviousHit;
found = true;
break;
@@ -201,7 +201,7 @@ void CCaloSD::createNewHit() {
<< " time slice " << TSliceID
<< " For Track " << theTrack->GetTrackID()
<< " which is a " << theTrack->GetDefinition()->GetParticleName();
if (theTrack->GetTrackID()==1) {
G4cout << " of energy " << theTrack->GetTotalEnergy();
} else {
@@ -226,14 +226,14 @@ void CCaloSD::createNewHit() {
StoreHit(CurrentHit);
}
}
void CCaloSD::updateHit() {
if (EdepositEM+EdepositEHAD != 0) {
CurrentHit->addEnergyDeposit(EdepositEM,EdepositEHAD);
#ifdef debug
G4cout << "Energy deposit in Unit " << UnitID << " em " << EdepositEM/MeV
<< " hadronic " << EdepositEHAD/MeV << " MeV" << G4endl;
<< " hadronic " << EdepositEHAD/MeV << " MeV" << G4endl;
#endif
}
@@ -289,15 +289,15 @@ G4double CCaloSD::curve_LY(const G4StepPoint* stepPoint) {
weight = 1.05 - dapd * 0.0005;
} else {
G4cout << "CCaloSD, light coll curve : wrong distance to APD " << dapd
<< " crlength = " << crlength
<< " z of localPoint = " << localPoint.z()
<< " take weight = " << weight << G4endl;
<< " crlength = " << crlength
<< " z of localPoint = " << localPoint.z()
<< " take weight = " << weight << G4endl;
}
#ifdef ddebug
G4cout << "CCaloSD, light coll curve : " << dapd
<< " crlength = " << crlength
<< " z of localPoint = " << localPoint.z()
<< " take weight = " << weight << G4endl;
<< " crlength = " << crlength
<< " z of localPoint = " << localPoint.z()
<< " take weight = " << weight << G4endl;
#endif
return weight;
}
@@ -34,7 +34,7 @@
#include <sstream>
G4String operator+(const G4String& str, const int i) {
G4String operator+(const G4String& str, const G4int i) {
std::ostringstream os;
os << str << i <<'\0';
G4String back = os.str();
@@ -42,7 +42,7 @@ G4String operator+(const G4String& str, const int i) {
}
G4String operator+(const G4String& str, const double i) {
G4String operator+(const G4String& str, const G4double i) {
std::ostringstream os;
os << str << i <<'\0';
G4String back = os.str();
@@ -113,8 +113,8 @@ std::istream& jump(std::istream& is) {
}
bool openGeomFile(std::ifstream& is,
const G4String& pathname, const G4String& filename) {
G4bool openGeomFile(std::ifstream& is,
const G4String& pathname, const G4String& filename) {
G4String fullname = pathname+"/"+filename;
is.open( fullname.c_str() );
if (!is) {