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 // $Id: MaterialForOnline.cc,v 1.7 2009/12/21 23:29:28 case Exp $
4 //
5 //
6 
7 
8 // system include files
9 #include <memory>
10 
11 // user include files
17 
22 
23 #include "CLHEP/Units/GlobalSystemOfUnits.h"
24 
25 #include <iostream>
26 #include <istream>
27 #include <fstream>
28 #include <string>
29 
30 
31 
32 //
33 // class decleration
34 //
35 
37  public:
38  explicit MaterialForOnline(const edm::ParameterSet&);
40  virtual void beginRun(const edm::Run&, const edm::EventSetup&) ;
41  virtual void analyze(const edm::Event&, const edm::EventSetup&);
42  virtual void endJob() ;
43 
44  private:
45 
46  // ----------member data ---------------------------
47 };
48 
49 //
50 // constants, enums and typedefs
51 //
52 
53 //
54 // static data member definitions
55 //
56 
57 //
58 // constructors and destructor
59 //
61 {
62  //now do what ever initialization is needed
63 
64 }
65 
66 
68 {
69 
70  // do anything here that needs to be done at desctruction time
71  // (e.g. close files, deallocate resources etc.)
72 
73 }
74 
75 
76 //
77 // member functions
78 //
79 
80 // ------------ method called to for each event ------------
81 void
83 {
84  std::cout << "analyze does nothing" << std::endl;
85 
86 }
87 
88 
89 // ------------ method called once each job just before starting event loop ------------
90 void
92 {
93  std::string materialFileName("MATERIALS.dat");
94  std::string elementaryMaterialFileName("ELEMENTARYMATERIALS.dat");
95  std::string compositeMaterialFileName("COMPOSITEMATERIALS.dat");
96  std::string materialFractionFileName("MATERIALFRACTIONS.dat");
97 
98  std::ofstream materialOS(materialFileName.c_str());
99  std::ofstream elementaryMaterialOS(elementaryMaterialFileName.c_str());
100  std::ofstream compositeMaterialOS(compositeMaterialFileName.c_str());
101  std::ofstream materialFractionOS(materialFractionFileName.c_str());
102 
103 
104  std::cout << "MaterialForOnline Analyzer..." << std::endl;
106 
107  iSetup.get<IdealGeometryRecord>().get( "", pDD );
108 
109  // const DDCompactView & cpv = *pDD;
110  //DDCompactView::graph_type gra = cpv.graph();
111  DDMaterial::iterator<DDMaterial> mit(DDMaterial::begin()),
112  med(DDMaterial::end());
113  // PMaterial* pm;
114  for (; mit != med; ++mit) {
115  if (! mit->isDefined().second) continue;
116  const DDMaterial& material = *mit;
117  materialOS<<material.name()<<","<<material.density()/g*cm3
118  << std::endl;
119 
120  if(material.noOfConstituents()==0){//0 for elementary materials
121  elementaryMaterialOS<<material.name()<<","<<material.z()
122  <<","<<material.a()/g*mole
123  << std::endl;
124  }
125  else{//compound materials.
126  compositeMaterialOS<<material.name()
127  << std::endl;
128  for (int i=0; i<material.noOfConstituents(); ++i) {
130  materialFractionOS<<material.name()<<","<<f.first.name()
131  <<","<< f.second
132  << std::endl;
133  }
134 
135  }
136 
137  }
138  elementaryMaterialOS.close();
139  compositeMaterialOS.close();
140  materialFractionOS.close();
141  materialOS.close();
142 }
143 
144 // ------------ method called once each job just after ending the event loop ------------
145 void
147 }
148 
149 //define this as a plug-in
double a() const
returns the atomic mass
Definition: DDMaterial.cc:103
int i
Definition: DBlmapReader.cc:9
const N & name() const
Definition: DDBase.h:88
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
Container::value_type value_type
virtual void analyze(const edm::Event &, const edm::EventSetup &)
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:109
int iEvent
Definition: GenABIO.cc:243
virtual void endJob()
FractionV::value_type constituent(int i) const
returns the i-th compound material and its fraction-mass
Definition: DDMaterial.cc:95
double f[11][100]
MaterialForOnline(const edm::ParameterSet &)
double density() const
returns the density
Definition: DDMaterial.cc:115
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:89
static DDI::Store< DDName, DDI::Material * >::iterator begin()
Definition: DDBase.h:76
tuple cout
Definition: gather_cfg.py:41
static DDI::Store< DDName, DDI::Material * >::iterator end()
Definition: DDBase.h:75
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
Definition: Run.h:31