CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
PhysicalPartsTree Class Reference
Inheritance diagram for PhysicalPartsTree:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void beginRun (const edm::Run &, const edm::EventSetup &) override
 
 PhysicalPartsTree (const edm::ParameterSet &)
 
 ~PhysicalPartsTree ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 26 of file PhysicalPartsTree.cc.

Constructor & Destructor Documentation

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

Definition at line 41 of file PhysicalPartsTree.cc.

42 {
43 
44 }
PhysicalPartsTree::~PhysicalPartsTree ( )

Definition at line 47 of file PhysicalPartsTree.cc.

48 {
49 }

Member Function Documentation

void PhysicalPartsTree::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDAnalyzer.

Definition at line 51 of file PhysicalPartsTree.cc.

References gather_cfg::cout.

51  {
52  std::cout << "analyze does nothing" << std::endl;
53 }
tuple cout
Definition: gather_cfg.py:121
void PhysicalPartsTree::beginRun ( const edm::Run ,
const edm::EventSetup iSetup 
)
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 55 of file PhysicalPartsTree.cc.

References DDLogicalPart::category(), python.rootplot.argparse::category, DDEnums::categoryName(), class-composition::child, DDExpandedView::copyno(), gather_cfg::cout, spr::find(), DDExpandedView::geoHistory(), edm::EventSetup::get(), estimatePileup::hist, DDExpandedView::logicalPart(), DDLogicalPart::material(), DDBase< N, C >::name(), DDExpandedView::next(), dbtoconf::parent, DDExpandedView::rotation(), DDLogicalPart::solid(), AlCaHLTBitMon_QueryRunRegistry::string, DDBase< N, C >::toString(), DDExpandedView::translation(), x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

55  {
56  //set a tolerance for "near zero"
57  double tolerance = 1.0e-3;
58 
59  std::string physicalPartsTreeFileName("PHYSICALPARTSTREE.dat");
60  std::string logicalPartTypesFileName("LOGICALPARTTYPES.dat");
61  std::string nominalPlacementsFileName("NOMINALPLACEMENTS.dat");
62  std::string detectorPartsFileName("DETECTORPARTS.dat");
63  std::string pospartsGraphFileName("POSPARTSGRAPH.dat");
64 
65  std::ofstream physicalPartsTreeOS(physicalPartsTreeFileName.c_str());
66  std::ofstream logicalPartTypesOS(logicalPartTypesFileName.c_str());
67  std::ofstream nominalPlacementsOS(nominalPlacementsFileName.c_str());
68  std::ofstream detectorPartsOS(detectorPartsFileName.c_str());
69  std::ofstream pospartsGraphOS(pospartsGraphFileName.c_str());
70 
71 
72  std::string slpname;
73  std::string scategory;
74  std::vector<std::string> lpname_vec;
75 
76 
77  std::cout << "PhysicalPartsTree Analyzer..." << std::endl;
79 
80  iSetup.get<IdealGeometryRecord>().get( "", pDD );
81 
82  const DDCompactView & cpv = *pDD;
83  DDExpandedView epv(cpv);
84  int pospartid=0;
85  size_t lastfound;
86  std::string lgname;
87  while(epv.next()){
88 
89  //for table physicalpartstree
90  std::ostringstream parent, child,logicalpartid,parentid;
91  child << epv.logicalPart().name();
92  const DDGeoHistory & hist = epv.geoHistory();
93  parent << hist[hist.size()-2].logicalPart().name();
94  logicalpartid << epv.geoHistory();
95  parentid<<hist[hist.size()-2];
96  lgname=logicalpartid.str();
97  lastfound=lgname.find_last_of("/\\");
98  lgname=lgname.substr(lastfound+1,lgname.size());
99  physicalPartsTreeOS<<lgname<<","<< parentid.str() << "," << child.str()<<std::endl;
100 // std::cout << "Logical Part Name= "<<logicalpartid.str() << std::endl;
101 
102  //for table nominalPlacements
103  bool reflection = false;
104 
105  DD3Vector x, y, z;
106  epv.rotation().GetComponents(x, y, z);
107  //Hep3Vector xv = epv.rotation().colX();
108  //Hep3Vector yv = epv.rotation().colY();
109  //Hep3Vector zv = epv.rotation().colZ();
110  //if ( xv.cross(yv) * zv < 0) {
111  // reflection = true;
112  // }
113  if ( (1.0 + (x.Cross(y)).Dot(z)) <= tolerance ) {
114  reflection = true;
115  }
116  std::vector<double> comps(9);
117  epv.rotation().GetComponents(comps.begin(), comps.end());
118  nominalPlacementsOS<< logicalpartid.str()<<","
119  << epv.translation().X() << ","
120  << epv.translation().Y() << ","
121  << epv.translation().Z()<< ","
122 // << epv.rotation().xx()<< ","
123 // << epv.rotation().xy()<< ","
124 // << epv.rotation().xz()<< ","
125 // << epv.rotation().yx()<< ","
126 // << epv.rotation().yy()<< ","
127 // << epv.rotation().yz()<< ","
128 // << epv.rotation().zx()<< ","
129 // << epv.rotation().zy()<< ","
130 // << epv.rotation().zz()<< ","
131  << comps[0]<<","
132  << comps[1]<<","
133  << comps[2]<<","
134  << comps[3]<<","
135  << comps[4]<<","
136  << comps[5]<<","
137  << comps[6]<<","
138  << comps[7]<<","
139  << comps[8]<<","
140  << (int)reflection
141  <<std::endl;
142 
143 
144  //for table DetectorParts
145  detectorPartsOS <<epv.logicalPart().solid().toString() << ","
146  <<epv.logicalPart().material().toString() << ","
147  <<logicalpartid.str()
148  <<std::endl;
149 
150  //for table PosPartsGraph
151 
152  pospartsGraphOS<<++pospartid<< ","<<epv.copyno()<< ","
153  <<parent.str() << "," << child.str()<<std::endl;
154 
155 
156  //for table logicalPartTypes
157  //this table is special because the DPNAMEs are subset of Physicalpart_id
158  //while we're looping all the Physicalpart_ids in epv, so we just
159  //keep the unique DPNAMEs into a vector and save them in looping epv.
160  // if there's no lpname in lpname_vec
161  //>> the OS file.
162 
163  slpname=epv.logicalPart().toString();
164 
165  std::vector<std::string>::iterator it = find(lpname_vec.begin(), lpname_vec.end(), slpname);
166 
167  if (it==lpname_vec.end()){
168  if(DDEnums::categoryName(epv.logicalPart().category())){
169  std::ostringstream category;
170  category<<DDEnums::categoryName(epv.logicalPart().category());
171  scategory=category.str();
172  std::string unspec="unspecified";
173  if(scategory==unspec){
174  lpname_vec.push_back(slpname);
175  logicalPartTypesOS <<slpname<< ","
176  <<"DETECTORPARTS"<<std::endl;
177  }
178  else{
179  lpname_vec.push_back(slpname);
180  logicalPartTypesOS <<slpname<< ","<<scategory<<std::endl;
181 
182  }
183  }
184  else{
185  lpname_vec.push_back(slpname);
186  logicalPartTypesOS <<slpname<< ","
187  <<"DETECTORPARTS"<<std::endl;
188 
189  }
190  }
191 
192 
193 
194  } //finish looping through expanded view.
195 
196 
197  physicalPartsTreeOS.close();
198  logicalPartTypesOS.close();
199  nominalPlacementsOS.close();
200  detectorPartsOS.close();
201  pospartsGraphOS.close();
202 }
list parent
Definition: dbtoconf.py:74
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
type of data representation of DDCompactView
Definition: DDCompactView.h:77
float float float z
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
std::vector< DDExpandedNode > DDGeoHistory
Geometrical &#39;path&#39; of the current node up to the root-node.
const T & get() const
Definition: EventSetup.h:55
tuple cout
Definition: gather_cfg.py:121
Definition: DDAxes.h:10
Provides an exploded view of the detector (tree-view)
static const char *const categoryName(Category s)
Definition: DDEnums.h:17