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 19 of file MaterialBudgetCategorizer.cc.

Member Function Documentation

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

Definition at line 136 of file MaterialBudgetCategorizer.cc.

References cuy::col, gather_cfg::cout, Exception, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by HGCall0fraction().

136  {
137  // const G4MaterialTable* matTable = G4Material::GetMaterialTable();
138  // G4int matSize = matTable->size();
139 
140  std::ifstream theMaterialFile(theMaterialFileName);
141  if (!theMaterialFile)
142  cms::Exception("LogicError") <<" File not found " << theMaterialFileName;
143 
144  // fill everything as "other"
145  float sup,sen,cab,col,ele,oth,air;
146  sup=sen=cab=col=ele=0.;
147 
148  std::string materialName;
149  while(theMaterialFile) {
150  theMaterialFile >> materialName;
151  theMaterialFile >> sup >> sen >> cab >> col >> ele;
152  oth = 0.000;
153  air = 0.000;
154  theMap[materialName].clear(); // clear before re-filling
155  theMap[materialName].push_back(sup); // sup
156  theMap[materialName].push_back(sen); // sen
157  theMap[materialName].push_back(cab); // cab
158  theMap[materialName].push_back(col); // col
159  theMap[materialName].push_back(ele); // ele
160  theMap[materialName].push_back(oth); // oth
161  theMap[materialName].push_back(air); // air
162  cout << " material " << materialName << " filled "
163  << " SUP " << sup
164  << " SEN " << sen
165  << " CAB " << cab
166  << " COL " << col
167  << " ELE " << ele
168  << " OTH " << oth
169  << " AIR " << air
170  << endl;
171  }
172 
173 }
col
Definition: cuy.py:1010
void MaterialBudgetCategorizer::buildHGCalCategoryMap ( std::string  theMaterialFileName,
std::map< std::string, std::vector< float > > &  theMap 
)
private

Definition at line 175 of file MaterialBudgetCategorizer.cc.

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

Referenced by HGCall0fraction().

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

Definition at line 24 of file MaterialBudgetCategorizer.cc.

References cuy::col, gather_cfg::cout, edm::FileInPath::fullPath(), cuy::ii, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by HGCall0fraction().

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

Referenced by MaterialBudgetData::dataPerStep().

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.

Referenced by MaterialBudgetData::dataPerStep().

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.

Referenced by MaterialBudgetData::dataPerStep().

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.

Referenced by MaterialBudgetData::dataPerStep().

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.

Referenced by MaterialBudgetData::dataPerStep().

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 HGCall0fraction().

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

Definition at line 40 of file MaterialBudgetCategorizer.h.

Referenced by HGCalx0fraction().

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

Definition at line 37 of file MaterialBudgetCategorizer.h.

Referenced by l0fraction().

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

Definition at line 34 of file MaterialBudgetCategorizer.h.

Referenced by material().

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

Definition at line 34 of file MaterialBudgetCategorizer.h.

Referenced by volume().

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

Definition at line 36 of file MaterialBudgetCategorizer.h.

Referenced by x0fraction().