Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-11 23:32:53

0001 #include "Validation/Geometry/interface/MaterialBudgetCategorizer.h"
0002 
0003 #include "G4LogicalVolumeStore.hh"
0004 #include "G4Material.hh"
0005 #include "G4UnitsTable.hh"
0006 #include "G4EmCalculator.hh"
0007 #include "G4UnitsTable.hh"
0008 
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 
0012 #include <fstream>
0013 #include <vector>
0014 
0015 MaterialBudgetCategorizer::MaterialBudgetCategorizer(std::string mode) {
0016   //----- Build map volume name - volume index
0017   G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
0018   G4LogicalVolumeStore::iterator ite;
0019   int ii = 0;
0020   for (ite = lvs->begin(); ite != lvs->end(); ite++) {
0021     theVolumeMap[(*ite)->GetName()] = ii++;
0022   }
0023 
0024   if (mode.compare("Tracker") == 0) {
0025     std::string theMaterialX0FileName = edm::FileInPath("Validation/Geometry/data/trackerMaterials.x0").fullPath();
0026     buildCategoryMap(theMaterialX0FileName, theX0Map);
0027     std::string theMaterialL0FileName = edm::FileInPath("Validation/Geometry/data/trackerMaterials.l0").fullPath();
0028     buildCategoryMap(theMaterialL0FileName, theL0Map);
0029   } else if (mode.compare("Mtd") == 0) {
0030     std::string theMaterialX0FileName = edm::FileInPath("Validation/Geometry/data/mtdMaterials.x0").fullPath();
0031     buildCategoryMap(theMaterialX0FileName, theX0Map);
0032     std::string theMaterialL0FileName = edm::FileInPath("Validation/Geometry/data/mtdMaterials.l0").fullPath();
0033     buildCategoryMap(theMaterialL0FileName, theL0Map);
0034   } else if (mode.compare("HGCal") == 0) {
0035     std::string thehgcalMaterialX0FileName = edm::FileInPath("Validation/Geometry/data/hgcalMaterials.x0").fullPath();
0036     buildHGCalCategoryMap(thehgcalMaterialX0FileName, theHGCalX0Map);
0037     std::string thehgcalMaterialL0FileName = edm::FileInPath("Validation/Geometry/data/hgcalMaterials.l0").fullPath();
0038     buildHGCalCategoryMap(thehgcalMaterialL0FileName, theHGCalL0Map);
0039   }
0040 }
0041 
0042 void MaterialBudgetCategorizer::buildCategoryMap(std::string theMaterialFileName,
0043                                                  std::map<std::string, std::vector<float> >& theMap) {
0044   std::ifstream theMaterialFile(theMaterialFileName);
0045 
0046   if (!theMaterialFile)
0047     cms::Exception("LogicError") << " File not found " << theMaterialFileName;
0048 
0049   float sup, sen, cab, col, ele, oth, air;
0050   sup = sen = cab = col = ele = 0.;
0051 
0052   std::string materialName;
0053 
0054   while (theMaterialFile) {
0055     theMaterialFile >> materialName;
0056     theMaterialFile >> sup >> sen >> cab >> col >> ele;
0057 
0058     if (materialName[0] == '#')  //Ignore comments
0059       continue;
0060 
0061     oth = 0.000;
0062     air = 0.000;
0063     theMap[materialName].clear();         // clear before re-filling
0064     theMap[materialName].push_back(sup);  // sup
0065     theMap[materialName].push_back(sen);  // sen
0066     theMap[materialName].push_back(cab);  // cab
0067     theMap[materialName].push_back(col);  // col
0068     theMap[materialName].push_back(ele);  // ele
0069     theMap[materialName].push_back(oth);  // oth
0070     theMap[materialName].push_back(air);  // air
0071     edm::LogInfo("MaterialBudget") << "MaterialBudgetCategorizer: Material " << materialName << " filled: "
0072                                    << "\n\tSUP " << sup << "\n\tSEN " << sen << "\n\tCAB " << cab << "\n\tCOL " << col
0073                                    << "\n\tELE " << ele << "\n\tOTH " << oth << "\n\tAIR " << air
0074                                    << "\n\tAdd up to: " << sup + sen + cab + col + ele + oth + air;
0075   }
0076 }
0077 
0078 void MaterialBudgetCategorizer::buildHGCalCategoryMap(std::string theMaterialFileName,
0079                                                       std::map<std::string, std::vector<float> >& theMap) {
0080   std::ifstream theMaterialFile(theMaterialFileName);
0081   if (!theMaterialFile)
0082     cms::Exception("LogicError") << " File not found " << theMaterialFileName;
0083 
0084   // fill everything as "other"
0085   float air, cables, copper, h_scintillator, lead, hgc_g10_fr4, silicon, stainlesssteel, wcu, oth, epoxy, kapton,
0086       aluminium, polystyrene, hgc_eeconnector, hgc_heconnector;
0087   air = cables = copper = h_scintillator = lead = hgc_g10_fr4 = silicon = stainlesssteel = wcu = epoxy = kapton =
0088       aluminium = polystyrene = hgc_eeconnector = hgc_heconnector = 0.;
0089 
0090   std::string materialName;
0091   while (theMaterialFile) {
0092     theMaterialFile >> materialName;
0093     theMaterialFile >> air >> cables >> copper >> h_scintillator >> lead >> hgc_g10_fr4 >> silicon >> stainlesssteel >>
0094         wcu >> epoxy >> kapton >> aluminium >> polystyrene >> hgc_eeconnector >> hgc_heconnector;
0095     // Skip comments
0096     if (materialName[0] == '#')
0097       continue;
0098     // Substitute '*' with spaces
0099     std::replace(materialName.begin(), materialName.end(), '*', ' ');
0100     oth = 0.000;
0101     theMap[materialName].clear();                     // clear before re-filling
0102     theMap[materialName].push_back(air);              // air
0103     theMap[materialName].push_back(cables);           // cables
0104     theMap[materialName].push_back(copper);           // copper
0105     theMap[materialName].push_back(h_scintillator);   // h_scintillator
0106     theMap[materialName].push_back(lead);             // lead
0107     theMap[materialName].push_back(hgc_g10_fr4);      // hgc_g10_fr4
0108     theMap[materialName].push_back(silicon);          // silicon
0109     theMap[materialName].push_back(stainlesssteel);   // stainlesssteel
0110     theMap[materialName].push_back(wcu);              // wcu
0111     theMap[materialName].push_back(oth);              // oth
0112     theMap[materialName].push_back(epoxy);            // epoxy
0113     theMap[materialName].push_back(kapton);           // kapton
0114     theMap[materialName].push_back(aluminium);        // aluminium
0115     theMap[materialName].push_back(polystyrene);      // polystyrene
0116     theMap[materialName].push_back(hgc_eeconnector);  // hgc_eeconnector
0117     theMap[materialName].push_back(hgc_heconnector);  // hgc_heconnector
0118     edm::LogInfo("MaterialBudget") << "MaterialBudgetCategorizer: material " << materialName << " filled " << std::endl
0119                                    << "\tair              " << air << std::endl
0120                                    << "\tcables           " << cables << std::endl
0121                                    << "\tcopper           " << copper << std::endl
0122                                    << "\th_scintillator   " << h_scintillator << std::endl
0123                                    << "\tlead             " << lead << std::endl
0124                                    << "\thgc_g10_fr4      " << hgc_g10_fr4 << std::endl
0125                                    << "\tsilicon          " << silicon << std::endl
0126                                    << "\tstainlesssteel   " << stainlesssteel << std::endl
0127                                    << "\twcu              " << wcu << std::endl
0128                                    << "\tepoxy            " << epoxy << std::endl
0129                                    << "\tkapton           " << kapton << std::endl
0130                                    << "\taluminium        " << aluminium << std::endl
0131                                    << "\tpolystyrene      " << polystyrene << std::endl
0132                                    << "\thgc_eeconnector  " << hgc_eeconnector << std::endl
0133                                    << "\thgc_heconnector  " << hgc_heconnector << std::endl
0134                                    << "\tOTH              " << oth;
0135   }
0136 }