Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:29:33

0001 #include "SimG4Core/Application/interface/CMSGDMLWriteStructure.h"
0002 
0003 #include "G4LogicalVolume.hh"
0004 #include "G4ProductionCuts.hh"
0005 #include "G4GDMLParser.hh"
0006 #include "G4VRangeToEnergyConverter.hh"
0007 #include "G4RToEConvForGamma.hh"
0008 #include "G4RToEConvForElectron.hh"
0009 #include "G4RToEConvForPositron.hh"
0010 #include "G4RToEConvForProton.hh"
0011 #include "G4SystemOfUnits.hh"
0012 
0013 CMSGDMLWriteStructure::CMSGDMLWriteStructure() {
0014   converter[0] = new G4RToEConvForGamma();
0015   converter[1] = new G4RToEConvForElectron();
0016   converter[2] = new G4RToEConvForPositron();
0017   converter[3] = new G4RToEConvForProton();
0018 }
0019 
0020 CMSGDMLWriteStructure::~CMSGDMLWriteStructure() {}
0021 
0022 void CMSGDMLWriteStructure::AddExtension(xercesc::DOMElement* volumeElement, const G4LogicalVolume* const glv) {
0023   xercesc::DOMElement* auxiliaryElement = nullptr;
0024   std::stringstream ss;
0025   const char* cutnames[4] = {"pcutg", "pcutem", "pcutep", "pcutp"};
0026 
0027   auxiliaryElement = NewElement("auxiliary");
0028   auxiliaryElement->setAttributeNode(NewAttribute("auxtype", "G4Region"));
0029   auxiliaryElement->setAttributeNode(NewAttribute("auxvalue", glv->GetRegion()->GetName()));
0030   volumeElement->appendChild(auxiliaryElement);
0031 
0032   auxiliaryElement = NewElement("auxiliary");
0033   auxiliaryElement->setAttributeNode(NewAttribute("auxtype", "pcutunit"));
0034   auxiliaryElement->setAttributeNode(NewAttribute("auxvalue", "GeV"));
0035   volumeElement->appendChild(auxiliaryElement);
0036 
0037   //     G4cout << "I have been called " << glv->GetName() << " in region "
0038   // << glv->GetRegion()->GetName() << G4endl;
0039   G4ProductionCuts* cuts = glv->GetRegion()->GetProductionCuts();
0040 
0041   for (G4int ic = 0; ic < 4; ++ic) {
0042     G4cout << ic << ". " << cutnames[ic] << " converter: " << converter[ic] << " cuts: " << cuts << " glv: " << glv
0043            << G4endl;
0044     ss.clear();
0045     ss.str("");
0046     ss << converter[ic]->Convert(cuts->GetProductionCut(ic), glv->GetMaterial()) / CLHEP::GeV;
0047     //   G4cout << cutnames[ic] << " = " << ss.str() << G4endl;
0048     auxiliaryElement = NewElement("auxiliary");
0049     auxiliaryElement->setAttributeNode(NewAttribute("auxtype", cutnames[ic]));
0050     auxiliaryElement->setAttributeNode(NewAttribute("auxvalue", ss.str()));
0051     volumeElement->appendChild(auxiliaryElement);
0052   }
0053 }