CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
MaterialBudgetCategorizer Class Reference

#include <MaterialBudgetCategorizer.h>

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

21 {
22  buildMaps();
23 }

Member Function Documentation

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

Definition at line 131 of file MaterialBudgetCategorizer.cc.

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

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

Definition at line 25 of file MaterialBudgetCategorizer.cc.

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

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

Definition at line 32 of file MaterialBudgetCategorizer.h.

Referenced by l0fraction().

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

Definition at line 29 of file MaterialBudgetCategorizer.h.

Referenced by material().

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

Definition at line 29 of file MaterialBudgetCategorizer.h.

Referenced by volume().

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

Definition at line 31 of file MaterialBudgetCategorizer.h.

Referenced by x0fraction().