CMS 3D CMS Logo

PhysicalPartsTree Class Reference

Inheritance diagram for PhysicalPartsTree:

edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob (const edm::EventSetup &)
 PhysicalPartsTree (const edm::ParameterSet &)
 ~PhysicalPartsTree ()


Detailed Description

Definition at line 25 of file PhysicalPartsTree.cc.


Constructor & Destructor Documentation

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

Definition at line 40 of file PhysicalPartsTree.cc.

00041 {
00042 
00043 }

PhysicalPartsTree::~PhysicalPartsTree (  ) 

Definition at line 46 of file PhysicalPartsTree.cc.

00047 {
00048 }


Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 50 of file PhysicalPartsTree.cc.

References GenMuonPlsPt100GeV_cfg::cout, and lat::endl().

00050                                                                                      { 
00051   std::cout << "analyze does nothing" << std::endl;
00052 }

void PhysicalPartsTree::beginJob ( const edm::EventSetup iSetup  )  [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 54 of file PhysicalPartsTree.cc.

References DDLogicalPart::category(), category, DDEnums::categoryName(), DDExpandedView::copyno(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), find(), DDExpandedView::geoHistory(), edm::EventSetup::get(), int, it, DDExpandedView::logicalPart(), DDLogicalPart::material(), DDBase< N, C >::name(), DDExpandedView::next(), dbtoconf::parent, DDExpandedView::rotation(), DDLogicalPart::solid(), DDBase< N, C >::toString(), DDExpandedView::translation(), x, y, and z.

00054                                                               {
00055   //set a tolerance for "near zero"
00056   double tolerance = 1.0e-3;
00057 
00058   std::string physicalPartsTreeFileName("PHYSICALPARTSTREE.dat");
00059   std::string logicalPartTypesFileName("LOGICALPARTTYPES.dat");
00060   std::string nominalPlacementsFileName("NOMINALPLACEMENTS.dat");
00061   std::string detectorPartsFileName("DETECTORPARTS.dat");
00062   std::string pospartsGraphFileName("POSPARTSGRAPH.dat");
00063 
00064   std::ofstream physicalPartsTreeOS(physicalPartsTreeFileName.c_str());
00065   std::ofstream logicalPartTypesOS(logicalPartTypesFileName.c_str());
00066   std::ofstream nominalPlacementsOS(nominalPlacementsFileName.c_str());
00067   std::ofstream detectorPartsOS(detectorPartsFileName.c_str());
00068   std::ofstream pospartsGraphOS(pospartsGraphFileName.c_str());
00069 
00070 
00071   std::string slpname;
00072   std::string scategory;
00073   std::vector<std::string> lpname_vec;
00074 
00075 
00076   std::cout << "PhysicalPartsTree Analyzer..." << std::endl;
00077   edm::ESHandle<DDCompactView> pDD;
00078 
00079   iSetup.get<IdealGeometryRecord>().get( "", pDD );
00080   
00081   const DDCompactView & cpv = *pDD;
00082   DDExpandedView epv(cpv);
00083   int pospartid=0;
00084   size_t lastfound;
00085   std::string lgname;
00086    while(epv.next()){
00087  
00088     //for table physicalpartstree
00089     std::ostringstream parent, child,logicalpartid,parentid;
00090     child << epv.logicalPart().name();
00091     const DDGeoHistory & hist = epv.geoHistory();
00092     parent << hist[hist.size()-2].logicalPart().name();
00093     logicalpartid << epv.geoHistory();
00094     parentid<<hist[hist.size()-2];
00095     lgname=logicalpartid.str();
00096     lastfound=lgname.find_last_of("/\\");
00097     lgname=lgname.substr(lastfound+1,lgname.size());
00098     physicalPartsTreeOS<<lgname<<","<< parentid.str() << "," << child.str()<<std::endl;
00099 //    std::cout << "Logical Part Name= "<<logicalpartid.str() << std::endl;
00100      
00101     //for table nominalPlacements
00102     bool reflection = false;
00103 
00104     DD3Vector x, y, z;
00105     epv.rotation().GetComponents(x, y, z);
00106     //Hep3Vector xv = epv.rotation().colX();
00107     //Hep3Vector yv = epv.rotation().colY();
00108     //Hep3Vector zv = epv.rotation().colZ();
00109     //if ( xv.cross(yv) * zv  < 0) {
00110     //            reflection = true;
00111     //          }
00112     if ( (1.0 + (x.Cross(y)).Dot(z)) <= tolerance ) {
00113       reflection = true;
00114     }
00115     std::vector<double> comps(9);
00116     epv.rotation().GetComponents(comps.begin(), comps.end());
00117     nominalPlacementsOS<< logicalpartid.str()<<","
00118                        << epv.translation().X() << "," 
00119                        << epv.translation().Y() << ","  
00120                        << epv.translation().Z()<< "," 
00121 //                     << epv.rotation().xx()<< "," 
00122 //                     << epv.rotation().xy()<< "," 
00123 //                     << epv.rotation().xz()<< "," 
00124 //                     << epv.rotation().yx()<< "," 
00125 //                     << epv.rotation().yy()<< "," 
00126 //                     << epv.rotation().yz()<< "," 
00127 //                     << epv.rotation().zx()<< "," 
00128 //                     << epv.rotation().zy()<< "," 
00129 //                     << epv.rotation().zz()<< "," 
00130                        << comps[0]<<","
00131                        << comps[1]<<","
00132                        << comps[2]<<","
00133                        << comps[3]<<","
00134                        << comps[4]<<","
00135                        << comps[5]<<","
00136                        << comps[6]<<","
00137                        << comps[7]<<","
00138                        << comps[8]<<","
00139                        << (int)reflection
00140                        <<std::endl;
00141 
00142 
00143     //for table DetectorParts
00144     detectorPartsOS <<epv.logicalPart().solid().toString() << ","
00145                     <<epv.logicalPart().material().toString() << ","
00146                     <<logicalpartid.str()
00147                     <<std::endl;
00148    
00149     //for table PosPartsGraph 
00150 
00151     pospartsGraphOS<<++pospartid<< ","<<epv.copyno()<< ","
00152     <<parent.str() << "," << child.str()<<std::endl;
00153 
00154 
00155     //for table logicalPartTypes
00156     //this table is special because the DPNAMEs are subset of Physicalpart_id
00157     //while we're looping all the Physicalpart_ids in epv, so we just 
00158     //keep the unique DPNAMEs into a vector and save them in looping epv.
00159     // if there's no lpname in lpname_vec
00160     //>> the OS file.
00161  
00162     slpname=epv.logicalPart().toString();
00163 
00164     std::vector<std::string>::iterator it = find(lpname_vec.begin(), lpname_vec.end(), slpname);    
00165    
00166     if (it==lpname_vec.end()){
00167       if(DDEnums::categoryName(epv.logicalPart().category())){     
00168         std::ostringstream category;
00169         category<<DDEnums::categoryName(epv.logicalPart().category());
00170         scategory=category.str();
00171         std::string unspec="unspecified";
00172         if(scategory==unspec){
00173           lpname_vec.push_back(slpname);
00174           logicalPartTypesOS <<slpname<< ","
00175                              <<"DETECTORPARTS"<<std::endl;
00176         }
00177         else{
00178           lpname_vec.push_back(slpname);
00179           logicalPartTypesOS <<slpname<< ","<<scategory<<std::endl;
00180 
00181         }
00182       }
00183       else{
00184         lpname_vec.push_back(slpname);
00185         logicalPartTypesOS <<slpname<< ","
00186                            <<"DETECTORPARTS"<<std::endl;
00187 
00188       }
00189     }
00190 
00191 
00192 
00193   } //finish looping through expanded view.
00194  
00195 
00196   physicalPartsTreeOS.close();
00197   logicalPartTypesOS.close();
00198   nominalPlacementsOS.close();
00199   detectorPartsOS.close();
00200   pospartsGraphOS.close();
00201 }


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:29:56 2009 for CMSSW by  doxygen 1.5.4