CMS 3D CMS Logo

Public Member Functions | Private Attributes

SolidsForOnline Class Reference

Inheritance diagram for SolidsForOnline:
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 &)
 SolidsForOnline (const edm::ParameterSet &)
 ~SolidsForOnline ()

Private Attributes

std::string filename_

Detailed Description

Definition at line 22 of file SolidsForOnline.cc.


Constructor & Destructor Documentation

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

Definition at line 37 of file SolidsForOnline.cc.

{ }
SolidsForOnline::~SolidsForOnline ( )

Definition at line 40 of file SolidsForOnline.cc.

{ }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 42 of file SolidsForOnline.cc.

References gather_cfg::cout.

                                                                                    { 
  std::cout << "analyze does nothing" << std::endl;
}
void SolidsForOnline::beginRun ( const edm::Run ,
const edm::EventSetup iSetup 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 46 of file SolidsForOnline.cc.

References DDTrap::alpha1(), DDTrap::alpha2(), DDPseudoTrap::atMinusZ(), DDBase< DDName, DDI::Solid * >::begin(), gather_cfg::cout, DDTruncTubs::cutAtDelta(), DDTruncTubs::cutAtStart(), DDTruncTubs::cutInside(), dd_not_init, ddbox, ddcons, ddintersection, ddpolycone_rrz, ddpolycone_rz, ddpolyhedra_rrz, ddpolyhedra_rz, ddpseudotrap, ddreflected, ddshapeless, ddsubtraction, ddtorus, ddtrap, ddtrunctubs, ddtubs, ddunion, DDTorus::deltaPhi(), DDPolyhedra::deltaPhi(), DDTruncTubs::deltaPhi(), DDTubs::deltaPhi(), DDCons::deltaPhi(), DDPolycone::deltaPhi(), DDBase< DDName, DDI::Solid * >::end(), Exception, edm::EventSetup::get(), DDCompactView::graph(), DDBox::halfX(), DDBox::halfY(), DDTrap::halfZ(), DDBox::halfZ(), DDPseudoTrap::halfZ(), DDBase< N, C >::name(), mergeVDriftHistosByStation::name, DDTrap::phi(), DDCons::phiFrom(), DDPseudoTrap::radius(), DDTubs::rIn(), DDTruncTubs::rIn(), DDCons::rInMinusZ(), DDCons::rInPlusZ(), DDTorus::rMax(), DDTorus::rMin(), DDBooleanSolid::rotation(), DDTruncTubs::rOut(), DDTubs::rOut(), DDCons::rOutMinusZ(), DDCons::rOutPlusZ(), DDTorus::rTorus(), DDSolid::shape(), DDPolyhedra::sides(), DDBooleanSolid::solidA(), DDBooleanSolid::solidB(), DDPolycone::startPhi(), DDTruncTubs::startPhi(), DDTubs::startPhi(), DDPolyhedra::startPhi(), DDTorus::startPhi(), DDTrap::theta(), DDBooleanSolid::translation(), DDReflectionSolid::unreflected(), DDTrap::x1(), DDPseudoTrap::x1(), DDTrap::x2(), DDPseudoTrap::x2(), DDTrap::x3(), DDTrap::x4(), DDPseudoTrap::y1(), DDTrap::y1(), DDPseudoTrap::y2(), DDTrap::y2(), DDTubs::zhalf(), DDCons::zhalf(), and DDTruncTubs::zHalf().

                                                                           {

// TRD1 and Trapezoid can be in the same files.

  std::string solidsFileName("SOLIDS.dat"); //added by Jie Chen
  std::string boxFileName("BOXES.dat");

  std::string tubesFileName("TUBES.dat");
  std::string polyHedraFileName("POLYHEDRAS.dat");
  std::string polyConeFileName("POLYCONES.dat");
  std::string conesFileName("CONES.dat");
  std::string pseudoTrapFileName("PSEUDOTRAPEZOIDS.dat");
  std::string trapFileName("TRAPEZOIDS.dat");
  std::string boolSolidsFileName("BOOLEANSOLIDS.dat");
  std::string reflectionSolidsFileName("REFLECTIONSOLIDS.dat");
  std::string torusFileName("TORUS.dat");

  std::ofstream solidsOS(solidsFileName.c_str());
  std::ofstream boxOS(boxFileName.c_str());
  std::ofstream tubeOS(tubesFileName.c_str());
  std::ofstream polyHOS(polyHedraFileName.c_str());
  std::ofstream polyCOS(polyConeFileName.c_str());
  std::ofstream coneOS(conesFileName.c_str());
  std::ofstream ptrapOS(pseudoTrapFileName.c_str());
  std::ofstream trapOS(trapFileName.c_str());
  std::ofstream boolOS(boolSolidsFileName.c_str());
  std::ofstream reflectionOS(reflectionSolidsFileName.c_str());
  std::ofstream torusOS(torusFileName.c_str());

  std::cout << "SolidsForOnline Analyzer..." << std::endl;

  edm::ESTransientHandle<DDCompactView> pDD;

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

  const DDCompactView & cpv = *pDD;
  DDCompactView::graph_type gra = cpv.graph();

  DDSolid::iterator<DDSolid> sit(DDSolid::begin()), sed(DDSolid::end());
  for (; sit != sed; ++sit) {
    if (! sit->isDefined().second) continue;  
    const DDSolid& solid = *sit;
    solidsOS<<solid.name()<<","<<DDSolidShapesName::name(solid.shape())
            << std::endl;
    

    switch (solid.shape()) 
      {
      case ddunion:
        {
          //for bool solid
          DDBooleanSolid boolSolid(solid);
          boolOS << boolSolid.name() << "," ;
          boolOS << "U";
          boolOS << "," << boolSolid.translation().x()
                 << "," << boolSolid.translation().y()
                 << "," << boolSolid.translation().z()
                 << "," << boolSolid.solidA().name() 
                 << "," << boolSolid.solidB().name()
                 << "," << boolSolid.rotation().name()
                 << std::endl;

          break;
        }
      case ddsubtraction:
        {
          DDBooleanSolid boolSolid(solid);
          boolOS << boolSolid.name() << "," ;
          boolOS << "S";
          boolOS << "," << boolSolid.translation().x()
                 << "," << boolSolid.translation().y()
                 << "," << boolSolid.translation().z()
                 << "," << boolSolid.solidA().name() 
                 << "," << boolSolid.solidB().name()
                 << "," << boolSolid.rotation().name()
                 << std::endl;
          break;
        }
      case ddintersection: 
        {         

          //for bool solid
          DDBooleanSolid boolSolid(solid);
          // if translation is == identity there are no parameters.
          // if there is no rotation the name will be ":"
          //std::string rotName = boolSolid.rotation().toString();
          //if (rotName == ":") {
          //  rotName = "rotations:UNIT";
          //}
          boolOS << boolSolid.name() << "," ;
          boolOS << "I";
          boolOS << "," << boolSolid.translation().x()
                 << "," << boolSolid.translation().y()
                 << "," << boolSolid.translation().z()
                 << "," << boolSolid.solidA().name() 
                 << "," << boolSolid.solidB().name()
                 << "," << boolSolid.rotation().name()
                 << std::endl;
          
          break;
          
        }
      case ddreflected:
        { 
          DDReflectionSolid reflection(solid);
          reflectionOS<<reflection.name()<<","
                      <<reflection.unreflected().name()
                      <<std::endl;
          break;
        }
      case ddbox:
        {
          DDBox box(solid);
          //std::cout<<"box shape is"<<solid.shape()<<std::endl;
          boxOS<<box.name()<<",";
          boxOS<<2.0*box.halfX()<<","<<2.0*box.halfY()<<","<<2.0*box.halfZ()<<std::endl;
          break;
        }
        
      case ddpseudotrap:
        {
          DDPseudoTrap pseudoTrap(solid);
          
          ptrapOS<<pseudoTrap.name() <<",";
          ptrapOS<<pseudoTrap.x1() <<","<<pseudoTrap.x2() <<","
                 <<pseudoTrap.halfZ()*2. <<","<<pseudoTrap.y1() <<","
                 <<pseudoTrap.y2() <<","<<pseudoTrap.radius()<<","
                 <<pseudoTrap.atMinusZ()
                 << std::endl;
          
          break;
        }
        
      case ddtubs:
        {
          //same as ddtrunctubs, Tube element is simply a Tube Section 
          //with the angle going from zero to 360 degrees. 
          //cutAtStart, cutAtDelta,  and  cutInside. are all zero 
          //then they are tubes
          DDTubs tubs(solid);
          tubeOS<<tubs.name()<<","<<tubs.rIn()<<","
                <<tubs.rOut()<<","<<tubs.zhalf()*2.0<<","
                <<tubs.startPhi()<<","<<tubs.deltaPhi()<<"," 
                <<"0"<<","<<"0"<<","
                <<"0"
                <<std::endl;

          break;
        }
      case ddtrap: // trd1s is included into this case
        {    
          DDTrap trap(solid);     
          trapOS<<trap.name()<<",";
          trapOS<<trap.alpha1()<<","<<trap.alpha2()<<","
                <<trap.x1()<<","<<trap.x2()<<","
                <<trap.halfZ()*2.0<<","<<trap.y1()<<","
                <<trap.y2()<<","
                <<trap.phi()<<","<<trap.theta()<<","
                <<trap.x3()<<","<<trap.x4()
                <<std::endl;
          break;
        }
      case ddcons:
        {
          DDCons cons(solid);
          coneOS<<cons.name()<<","<<cons.zhalf()*2.0<<","
                <<cons.rInMinusZ()<<","
                <<cons.rOutMinusZ()<<","<<cons.rInPlusZ()<<","
                <<cons.rOutPlusZ()<<","<<cons.phiFrom()<<","
                <<cons.deltaPhi()
                <<std::endl;
          
          break;
        }

      case ddpolycone_rz:
        {
          //rz_zs=rz if it's ddpolycone_rz
          DDPolycone polyCone(solid);
          polyCOS<<polyCone.name()<<","<<polyCone.startPhi()
                 <<","<<polyCone.deltaPhi()<<","<<"RZ"
                 <<std::endl;
          break;
        }
      case ddpolyhedra_rz:
        {
          DDPolyhedra  polyHedra(solid);
          polyHOS<<polyHedra.name()<<",";
          polyHOS<<polyHedra.sides()<<","<<polyHedra.startPhi()
                 <<","<<polyHedra.deltaPhi()<<","<<"RZ"
                 <<std::endl;
          break;
        }
      case ddpolycone_rrz:{
          //rz_zs=zs if it's ddpolycone_rrz
          DDPolycone polyCone(solid);
          polyCOS<<polyCone.name()<<","<<polyCone.startPhi()
                 <<","<<polyCone.deltaPhi()<<","<<"ZS"
                 <<std::endl;   
        break;
      }
      case ddpolyhedra_rrz:
        {

          DDPolyhedra  polyHedra(solid);
          polyHOS<<polyHedra.name()<<",";
          polyHOS<<polyHedra.sides()<<","<<polyHedra.startPhi()
                 <<","<<polyHedra.deltaPhi()<<","<<"ZS"
                 <<std::endl;
          break;
        }
       
      case ddtrunctubs:{

          DDTruncTubs tubs(solid);
          tubeOS<<tubs.name()<<","<<tubs.rIn()<<","
                <<tubs.rOut()<<","<<tubs.zHalf()*2.0<<","
                <<tubs.startPhi()<<","<<tubs.deltaPhi()<<"," 
                <<tubs.cutAtStart()<<","<<tubs.cutAtDelta()<<","
                <<tubs.cutInside()
                <<std::endl;
          break;
      }

      case ddtorus: {
        DDTorus torus(solid);
        torusOS<<torus.name()<<","<<torus.rMin()<<","
               <<torus.rMax()<<","<<torus.rTorus()<<","
               <<torus.startPhi()<<","<<torus.deltaPhi()
               <<std::endl;
        break;
      }

      case ddshapeless:{
        //      DDShapelessSolid shapeless(solid);
        //shapelessOS<<shapeless.name()
        // <<std::endl;

//      return new PSolid( solid.toString(), solid.parameters()
//                         , solid.shape() );
        break;
      }      
      case dd_not_init:
      default:
        throw cms::Exception("DDException") << "DDDToPersFactory::solid(...) either not inited or no such solid.";
        break;
      }
  

  }
  solidsOS.close();
  boxOS.close();

  tubeOS.close();
  polyHOS.close();
  polyCOS.close();
  coneOS.close();
  ptrapOS.close();
  trapOS.close();
  boolOS.close();
  reflectionOS.close();
}

Member Data Documentation

std::string SolidsForOnline::filename_ [private]

Definition at line 34 of file SolidsForOnline.cc.