CMS 3D CMS Logo

Public Member Functions

MaterialForOnline Class Reference

Inheritance diagram for MaterialForOnline:
edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginRun (const edm::Run &, const edm::EventSetup &)
virtual void endJob ()
 MaterialForOnline (const edm::ParameterSet &)
 ~MaterialForOnline ()

Detailed Description

Definition at line 36 of file MaterialForOnline.cc.


Constructor & Destructor Documentation

MaterialForOnline::MaterialForOnline ( const edm::ParameterSet iConfig) [explicit]

Definition at line 60 of file MaterialForOnline.cc.

{
   //now do what ever initialization is needed

}
MaterialForOnline::~MaterialForOnline ( )

Definition at line 67 of file MaterialForOnline.cc.

{
 
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)

}

Member Function Documentation

void MaterialForOnline::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 82 of file MaterialForOnline.cc.

References gather_cfg::cout.

{
  std::cout << "analyze does nothing" << std::endl;

}
void MaterialForOnline::beginRun ( const edm::Run ,
const edm::EventSetup iSetup 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 91 of file MaterialForOnline.cc.

References DDMaterial::a(), DDBase< DDName, DDI::Material * >::begin(), DDMaterial::constituent(), gather_cfg::cout, DDMaterial::density(), DDBase< DDName, DDI::Material * >::end(), f, g, edm::EventSetup::get(), i, DDName::name(), DDBase< N, C >::name(), DDMaterial::noOfConstituents(), and DDMaterial::z().

{
  std::string materialFileName("MATERIALS.dat");
  std::string elementaryMaterialFileName("ELEMENTARYMATERIALS.dat");
  std::string compositeMaterialFileName("COMPOSITEMATERIALS.dat");
  std::string materialFractionFileName("MATERIALFRACTIONS.dat");

  std::ofstream materialOS(materialFileName.c_str());
  std::ofstream elementaryMaterialOS(elementaryMaterialFileName.c_str());
  std::ofstream compositeMaterialOS(compositeMaterialFileName.c_str());
  std::ofstream materialFractionOS(materialFractionFileName.c_str());


  std::cout << "MaterialForOnline Analyzer..." << std::endl;
  edm::ESTransientHandle<DDCompactView> pDD;

  iSetup.get<IdealGeometryRecord>().get( "", pDD );

  //  const DDCompactView & cpv = *pDD;
  //DDCompactView::graph_type gra = cpv.graph();
  DDMaterial::iterator<DDMaterial> mit(DDMaterial::begin()), 
    med(DDMaterial::end());
  // PMaterial* pm;
  for (; mit != med; ++mit) {
    if (! mit->isDefined().second) continue;
    const DDMaterial& material = *mit;
    materialOS<<material.name()<<","<<material.density()/g*cm3
              << std::endl;
    
    if(material.noOfConstituents()==0){//0 for elementary materials 
     elementaryMaterialOS<<material.name()<<","<<material.z()
                         <<","<<material.a()/g*mole
                         << std::endl;
    }
    else{//compound materials.  
      compositeMaterialOS<<material.name()
                         << std::endl;
      for (int i=0; i<material.noOfConstituents(); ++i) {
        DDMaterial::FractionV::value_type f = material.constituent(i);
        materialFractionOS<<material.name()<<","<<f.first.name()
                          <<","<< f.second
                          << std::endl;
      }                

    }

  }
  elementaryMaterialOS.close();
  compositeMaterialOS.close();
  materialFractionOS.close();
  materialOS.close();
}
void MaterialForOnline::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 146 of file MaterialForOnline.cc.

                          {
}