CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MaterialBudgetCategorizer Class Reference

#include <MaterialBudgetCategorizer.h>

Public Member Functions

const std::vector< float > & HGCall0fraction (std::string s)
 
const std::vector< float > & HGCalx0fraction (std::string s)
 
const std::vector< float > & l0fraction (std::string s)
 
int material (std::string s)
 
 MaterialBudgetCategorizer ()
 
int volume (std::string s)
 
const std::vector< float > & x0fraction (std::string s)
 

Private Member Functions

void buildCategoryMap (std::string theMaterialFileName, std::map< std::string, std::vector< float > > &theMap)
 
void buildHGCalCategoryMap (std::string theMaterialFileName, std::map< std::string, std::vector< float > > &theMap)
 
void buildMaps ()
 

Private Attributes

std::map< std::string, std::vector< float > > theHGCalL0Map
 
std::map< std::string, std::vector< float > > theHGCalX0Map
 
std::map< std::string, std::vector< float > > theL0Map
 
std::map< std::string, int > theMaterialMap
 
std::map< std::string, int > theVolumeMap
 
std::map< std::string, std::vector< float > > theX0Map
 

Detailed Description

Definition at line 15 of file MaterialBudgetCategorizer.h.

Constructor & Destructor Documentation

MaterialBudgetCategorizer::MaterialBudgetCategorizer ( )

Definition at line 15 of file MaterialBudgetCategorizer.cc.

References buildMaps().

Member Function Documentation

void MaterialBudgetCategorizer::buildCategoryMap ( std::string  theMaterialFileName,
std::map< std::string, std::vector< float > > &  theMap 
)
private

Definition at line 126 of file MaterialBudgetCategorizer.cc.

References cuy::col, Exception, LogDebug, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by buildMaps(), and HGCall0fraction().

126  {
127 
128  std::ifstream theMaterialFile(theMaterialFileName);
129  if (!theMaterialFile)
130  cms::Exception("LogicError") << " File not found " << theMaterialFileName;
131 
132  // fill everything as "other"
133  float sup,sen,cab,col,ele,oth,air;
134  sup=sen=cab=col=ele=0.;
135 
136  std::string materialName;
137 
138  while(theMaterialFile) {
139  theMaterialFile >> materialName;
140  theMaterialFile >> sup >> sen >> cab >> col >> ele;
141  oth = 0.000;
142  air = 0.000;
143  theMap[materialName].clear(); // clear before re-filling
144  theMap[materialName].push_back(sup); // sup
145  theMap[materialName].push_back(sen); // sen
146  theMap[materialName].push_back(cab); // cab
147  theMap[materialName].push_back(col); // col
148  theMap[materialName].push_back(ele); // ele
149  theMap[materialName].push_back(oth); // oth
150  theMap[materialName].push_back(air); // air
151  LogDebug("MaterialBudget")
152  << "MaterialBudgetCategorizer: Material " << materialName << " filled "
153  << " SUP " << sup
154  << " SEN " << sen
155  << " CAB " << cab
156  << " COL " << col
157  << " ELE " << ele
158  << " OTH " << oth
159  << " AIR " << air;
160  }
161 }
#define LogDebug(id)
col
Definition: cuy.py:1010
void MaterialBudgetCategorizer::buildHGCalCategoryMap ( std::string  theMaterialFileName,
std::map< std::string, std::vector< float > > &  theMap 
)
private

Definition at line 163 of file MaterialBudgetCategorizer.cc.

References Air, Exception, python.rootplot.root2matplotlib::replace(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by buildMaps(), and HGCall0fraction().

165 {
166 
167  std::ifstream theMaterialFile(theMaterialFileName);
168  if (!theMaterialFile)
169  cms::Exception("LogicError") <<" File not found " << theMaterialFileName;
170 
171  // fill everything as "other"
172  float Air,Cables,Copper,H_Scintillator,Lead,M_NEMA_FR4_plate,Silicon,StainlessSteel,WCu, oth;
173  Air=Cables=Copper=H_Scintillator=Lead=M_NEMA_FR4_plate=Silicon=StainlessSteel=WCu=0.;
174 
175  std::string materialName;
176  while(theMaterialFile) {
177  theMaterialFile >> materialName;
178  theMaterialFile >> Air >> Cables >> Copper >> H_Scintillator >> Lead >> M_NEMA_FR4_plate >> Silicon >> StainlessSteel >> WCu;
179  // Skip comments
180  if (materialName[0] == '#')
181  continue;
182  // Substitute '*' with spaces
183  std::replace(materialName.begin(), materialName.end(), '*', ' ');
184  oth = 0.000;
185  theMap[materialName].clear(); // clear before re-filling
186  theMap[materialName].push_back(Air ); // Air
187  theMap[materialName].push_back(Cables ); // Cables
188  theMap[materialName].push_back(Copper ); // Copper
189  theMap[materialName].push_back(H_Scintillator ); // H_Scintillator
190  theMap[materialName].push_back(Lead ); // Lead
191  theMap[materialName].push_back(M_NEMA_FR4_plate); // M_NEMA_FR4_plate
192  theMap[materialName].push_back(Silicon ); // Silicon
193  theMap[materialName].push_back(StainlessSteel ); // StainlessSteel
194  theMap[materialName].push_back(WCu ); // WCu
195  theMap[materialName].push_back(oth ); // oth
196  edm::LogInfo("MaterialBudget")
197  << "MaterialBudgetCategorizer: material " << materialName << " filled "
198  << std::endl
199  << "\tAir " << Air << std::endl
200  << "\tCables " << Cables << std::endl
201  << "\tCopper " << Copper << std::endl
202  << "\tH_Scintillator " << H_Scintillator << std::endl
203  << "\tLead " << Lead << std::endl
204  << "\tM_NEMA_FR4_plate " << M_NEMA_FR4_plate << std::endl
205  << "\tSilicon " << Silicon << std::endl
206  << "\tStainlessSteel " << StainlessSteel << std::endl
207  << "\tWCu " << WCu << std::endl
208  << "\tOTH " << oth;
209  }
210 
211 }
def replace(string, replacements)
void MaterialBudgetCategorizer::buildMaps ( )
private

Definition at line 20 of file MaterialBudgetCategorizer.cc.

References buildCategoryMap(), buildHGCalCategoryMap(), cuy::col, edm::FileInPath::fullPath(), cuy::ii, AlCaHLTBitMon_QueryRunRegistry::string, theHGCalL0Map, theHGCalX0Map, theL0Map, theMaterialMap, theVolumeMap, and theX0Map.

Referenced by HGCall0fraction(), and MaterialBudgetCategorizer().

21 {
22  //----- Build map volume name - volume index
23  G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
24  G4LogicalVolumeStore::iterator ite;
25  int ii = 0;
26  for (ite = lvs->begin(); ite != lvs->end(); ite++) {
27  theVolumeMap[(*ite)->GetName()] = ii++;
28  }
29 
30  //----- Build map material name - volume index
31  const G4MaterialTable* matTable = G4Material::GetMaterialTable();
32  G4int matSize = matTable->size();
33  for( ii = 0; ii < matSize; ii++ ) {
34  theMaterialMap[ (*matTable)[ii]->GetName()] = ii+1;
35  }
36 
37  //----- Build map material name
38  for( int ii = 0; ii < matSize; ii++ ) {
39  float sup,sen,cab,col,ele,oth,air;
40  sup=sen=cab=col=ele=0.;
41  oth=1.;
42  air=0;
43  edm::LogInfo("MaterialBudget") << "MaterialBudgetCategorizer: Material " << (*matTable)[ii]->GetName() << " prepared";
44  if((*matTable)[ii]->GetName()=="Air"
45  ||
46  (*matTable)[ii]->GetName()=="Vacuum"
47  ) {
48  air=1.000;
49  oth=0.000;
50  }
51  // actually this class does not work if there are spaces into material names --> Recover material properties
52  if((*matTable)[ii]->GetName()=="Carbon fibre str.") {
53  sup=1.000;
54  oth=0.000;
55  }
56  // X0
57  theX0Map[ (*matTable)[ii]->GetName() ].push_back(sup); // sup
58  theX0Map[ (*matTable)[ii]->GetName() ].push_back(sen); // sen
59  theX0Map[ (*matTable)[ii]->GetName() ].push_back(cab); // cab
60  theX0Map[ (*matTable)[ii]->GetName() ].push_back(col); // col
61  theX0Map[ (*matTable)[ii]->GetName() ].push_back(ele); // ele
62  theX0Map[ (*matTable)[ii]->GetName() ].push_back(oth); // oth
63  theX0Map[ (*matTable)[ii]->GetName() ].push_back(air); // air
64  // L0
65  theL0Map[ (*matTable)[ii]->GetName() ].push_back(sup); // sup
66  theL0Map[ (*matTable)[ii]->GetName() ].push_back(sen); // sen
67  theL0Map[ (*matTable)[ii]->GetName() ].push_back(cab); // cab
68  theL0Map[ (*matTable)[ii]->GetName() ].push_back(col); // col
69  theL0Map[ (*matTable)[ii]->GetName() ].push_back(ele); // ele
70  theL0Map[ (*matTable)[ii]->GetName() ].push_back(oth); // oth
71  theL0Map[ (*matTable)[ii]->GetName() ].push_back(air); // air
72  }
73 
74  //----- Build map material name - X0 contributes
75  edm::LogInfo("MaterialBudget") << "MaterialBudgetCategorizer: Fill X0 Map";
76  std::string theMaterialX0FileName = edm::FileInPath("Validation/Geometry/data/trackerMaterials.x0").fullPath();
77  buildCategoryMap(theMaterialX0FileName, theX0Map);
78  //For the HGCal
79  std::string thehgcalMaterialX0FileName = edm::FileInPath("Validation/Geometry/data/hgcalMaterials.x0").fullPath();
80  buildHGCalCategoryMap(thehgcalMaterialX0FileName, theHGCalX0Map);
81  //----- Build map material name - L0 contributes
82  edm::LogInfo("MaterialBudget") << "MaterialBudgetCategorizer: Fill L0 Map";
83  std::string theMaterialL0FileName = edm::FileInPath("Validation/Geometry/data/trackerMaterials.l0").fullPath();
84  buildCategoryMap(theMaterialL0FileName, theL0Map);
85  //For the HGCal
86  std::string thehgcalMaterialL0FileName = edm::FileInPath("Validation/Geometry/data/hgcalMaterials.l0").fullPath();
87  buildHGCalCategoryMap(thehgcalMaterialL0FileName, theHGCalL0Map);
88  // summary of all the materials loaded
89  edm::LogInfo("MaterialBudget") << "MaterialBudgetCategorizer: Material Summary Starts";
90  G4EmCalculator calc;
91  for( ii = 0; ii < matSize; ii++ ) {
92  edm::LogInfo("MaterialBudget")
93  << "MaterialBudgetCateogorizer: Material " << (*matTable)[ii]->GetName()
94  << std::endl
95  << "\t density = " << G4BestUnit((*matTable)[ii]->GetDensity(),"Volumic Mass")
96  << std::endl
97  << "\t X0 = " << (*matTable)[ii]->GetRadlen() << " mm"
98  << std::endl
99  << "\t Energy threshold for photons for 100 mm range = "
100  << G4BestUnit(calc.ComputeEnergyCutFromRangeCut(100, G4String("gamma"), (*matTable)[ii]->GetName()) , "Energy")
101  << std::endl
102  << " SUP " << theX0Map[ (*matTable)[ii]->GetName() ][0]
103  << " SEN " << theX0Map[ (*matTable)[ii]->GetName() ][1]
104  << " CAB " << theX0Map[ (*matTable)[ii]->GetName() ][2]
105  << " COL " << theX0Map[ (*matTable)[ii]->GetName() ][3]
106  << " ELE " << theX0Map[ (*matTable)[ii]->GetName() ][4]
107  << " OTH " << theX0Map[ (*matTable)[ii]->GetName() ][5]
108  << " AIR " << theX0Map[ (*matTable)[ii]->GetName() ][6]
109  << std::endl
110  << "\t Lambda0 = " << (*matTable)[ii]->GetNuclearInterLength() << " mm"
111  << std::endl
112  << " SUP " << theL0Map[ (*matTable)[ii]->GetName() ][0]
113  << " SEN " << theL0Map[ (*matTable)[ii]->GetName() ][1]
114  << " CAB " << theL0Map[ (*matTable)[ii]->GetName() ][2]
115  << " COL " << theL0Map[ (*matTable)[ii]->GetName() ][3]
116  << " ELE " << theL0Map[ (*matTable)[ii]->GetName() ][4]
117  << " OTH " << theL0Map[ (*matTable)[ii]->GetName() ][5]
118  << " AIR " << theL0Map[ (*matTable)[ii]->GetName() ][6]
119  << std::endl;
120  if( theX0Map[ (*matTable)[ii]->GetName() ][5] == 1 || theL0Map[ (*matTable)[ii]->GetName() ][5] == 1 )
121  edm::LogWarning("MaterialBudget")
122  << "MaterialBudgetCategorizer Material with no category: " << (*matTable)[ii]->GetName();
123  }
124 }
std::map< std::string, int > theVolumeMap
std::map< std::string, std::vector< float > > theX0Map
std::map< std::string, std::vector< float > > theHGCalL0Map
void buildCategoryMap(std::string theMaterialFileName, std::map< std::string, std::vector< float > > &theMap)
ii
Definition: cuy.py:590
std::map< std::string, std::vector< float > > theL0Map
std::map< std::string, std::vector< float > > theHGCalX0Map
col
Definition: cuy.py:1010
std::string fullPath() const
Definition: FileInPath.cc:197
std::map< std::string, int > theMaterialMap
void buildHGCalCategoryMap(std::string theMaterialFileName, std::map< std::string, std::vector< float > > &theMap)
const std::vector<float>& MaterialBudgetCategorizer::HGCall0fraction ( std::string  s)
inline
const std::vector<float>& MaterialBudgetCategorizer::HGCalx0fraction ( std::string  s)
inline

Definition at line 27 of file MaterialBudgetCategorizer.h.

References alignCSCRings::s, and theHGCalX0Map.

27 {return theHGCalX0Map[s];}
std::map< std::string, std::vector< float > > theHGCalX0Map
const std::vector<float>& MaterialBudgetCategorizer::l0fraction ( std::string  s)
inline

Definition at line 24 of file MaterialBudgetCategorizer.h.

References alignCSCRings::s, and theL0Map.

24 {return theL0Map[s];}
std::map< std::string, std::vector< float > > theL0Map
int MaterialBudgetCategorizer::material ( std::string  s)
inline

Definition at line 21 of file MaterialBudgetCategorizer.h.

References alignCSCRings::s, and theMaterialMap.

21 {return theMaterialMap[s];}
std::map< std::string, int > theMaterialMap
int MaterialBudgetCategorizer::volume ( std::string  s)
inline

Definition at line 20 of file MaterialBudgetCategorizer.h.

References alignCSCRings::s, and theVolumeMap.

20 {return theVolumeMap[s];}
std::map< std::string, int > theVolumeMap
const std::vector<float>& MaterialBudgetCategorizer::x0fraction ( std::string  s)
inline

Definition at line 23 of file MaterialBudgetCategorizer.h.

References alignCSCRings::s, and theX0Map.

23 {return theX0Map[s];}
std::map< std::string, std::vector< float > > theX0Map

Member Data Documentation

std::map<std::string,std::vector<float> > MaterialBudgetCategorizer::theHGCalL0Map
private

Definition at line 41 of file MaterialBudgetCategorizer.h.

Referenced by buildMaps(), and HGCall0fraction().

std::map<std::string,std::vector<float> > MaterialBudgetCategorizer::theHGCalX0Map
private

Definition at line 40 of file MaterialBudgetCategorizer.h.

Referenced by buildMaps(), and HGCalx0fraction().

std::map<std::string,std::vector<float> > MaterialBudgetCategorizer::theL0Map
private

Definition at line 37 of file MaterialBudgetCategorizer.h.

Referenced by buildMaps(), and l0fraction().

std::map<std::string,int> MaterialBudgetCategorizer::theMaterialMap
private

Definition at line 34 of file MaterialBudgetCategorizer.h.

Referenced by buildMaps(), and material().

std::map<std::string,int> MaterialBudgetCategorizer::theVolumeMap
private

Definition at line 34 of file MaterialBudgetCategorizer.h.

Referenced by buildMaps(), and volume().

std::map<std::string,std::vector<float> > MaterialBudgetCategorizer::theX0Map
private

Definition at line 36 of file MaterialBudgetCategorizer.h.

Referenced by buildMaps(), and x0fraction().