CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MaterialForOnline.cc
Go to the documentation of this file.
1 // Original Author: Jie Chen
2 // Created: Thu Apr 5 10:36:22 CDT 2007
3 //
4 //
5 
6 
7 // system include files
8 #include <memory>
9 
10 // user include files
16 
21 
22 #include "CLHEP/Units/GlobalSystemOfUnits.h"
23 
24 #include <iostream>
25 #include <istream>
26 #include <fstream>
27 #include <string>
28 
29 
30 
31 //
32 // class decleration
33 //
34 
36  public:
37  explicit MaterialForOnline(const edm::ParameterSet&);
39  virtual void beginRun(const edm::Run&, const edm::EventSetup&) override ;
40  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
41  virtual void endJob() override ;
42 
43  private:
44 
45  // ----------member data ---------------------------
46 };
47 
48 //
49 // constants, enums and typedefs
50 //
51 
52 //
53 // static data member definitions
54 //
55 
56 //
57 // constructors and destructor
58 //
60 {
61  //now do what ever initialization is needed
62 
63 }
64 
65 
67 {
68 
69  // do anything here that needs to be done at desctruction time
70  // (e.g. close files, deallocate resources etc.)
71 
72 }
73 
74 
75 //
76 // member functions
77 //
78 
79 // ------------ method called to for each event ------------
80 void
82 {
83  std::cout << "analyze does nothing" << std::endl;
84 
85 }
86 
87 
88 // ------------ method called once each job just before starting event loop ------------
89 void
91 {
92  std::string materialFileName("MATERIALS.dat");
93  std::string elementaryMaterialFileName("ELEMENTARYMATERIALS.dat");
94  std::string compositeMaterialFileName("COMPOSITEMATERIALS.dat");
95  std::string materialFractionFileName("MATERIALFRACTIONS.dat");
96 
97  std::ofstream materialOS(materialFileName.c_str());
98  std::ofstream elementaryMaterialOS(elementaryMaterialFileName.c_str());
99  std::ofstream compositeMaterialOS(compositeMaterialFileName.c_str());
100  std::ofstream materialFractionOS(materialFractionFileName.c_str());
101 
102 
103  std::cout << "MaterialForOnline Analyzer..." << std::endl;
105 
106  iSetup.get<IdealGeometryRecord>().get( "", pDD );
107 
108  // const DDCompactView & cpv = *pDD;
109  //DDCompactView::graph_type gra = cpv.graph();
110  DDMaterial::iterator<DDMaterial> mit(DDMaterial::begin()),
111  med(DDMaterial::end());
112  // PMaterial* pm;
113  for (; mit != med; ++mit) {
114  if (! mit->isDefined().second) continue;
115  const DDMaterial& material = *mit;
116  materialOS<<material.name()<<","<<material.density()/g*cm3
117  << std::endl;
118 
119  if(material.noOfConstituents()==0){//0 for elementary materials
120  elementaryMaterialOS<<material.name()<<","<<material.z()
121  <<","<<material.a()/g*mole
122  << std::endl;
123  }
124  else{//compound materials.
125  compositeMaterialOS<<material.name()
126  << std::endl;
127  for (int i=0; i<material.noOfConstituents(); ++i) {
129  materialFractionOS<<material.name()<<","<<f.first.name()
130  <<","<< f.second
131  << std::endl;
132  }
133 
134  }
135 
136  }
137  elementaryMaterialOS.close();
138  compositeMaterialOS.close();
139  materialFractionOS.close();
140  materialOS.close();
141 }
142 
143 // ------------ method called once each job just after ending the event loop ------------
144 void
146 }
147 
148 //define this as a plug-in
virtual void endJob() override
double a() const
returns the atomic mass
Definition: DDMaterial.cc:97
int i
Definition: DBlmapReader.cc:9
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
const N & name() const
Definition: DDBase.h:82
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
double z() const
retruns the atomic number
Definition: DDMaterial.cc:103
int iEvent
Definition: GenABIO.cc:230
FractionV::value_type constituent(int i) const
returns the i-th compound material and its fraction-mass
Definition: DDMaterial.cc:89
double f[11][100]
MaterialForOnline(const edm::ParameterSet &)
Container::value_type value_type
double density() const
returns the density
Definition: DDMaterial.cc:109
const T & get() const
Definition: EventSetup.h:55
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
Definition: DDMaterial.cc:83
static DDI::Store< DDName, DDI::Material * >::iterator begin()
Definition: DDBase.h:70
tuple cout
Definition: gather_cfg.py:121
static DDI::Store< DDName, DDI::Material * >::iterator end()
Definition: DDBase.h:69
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
Definition: Run.h:41