CMS 3D CMS Logo

SiPixelDetInfoFileWriter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // Package: SiPixelESProducers
3 // Class: SiPixelDetInfoFileWriter
4 // Original Author: V.Chiochia (adapted from the Strip version by G.Bruno)
5 // Created: Mon May 20 10:04:31 CET 2007
6 
11 
17 
18 
19 using namespace cms;
20 using namespace std;
21 
22 
24 
25 
26  edm::LogInfo("SiPixelDetInfoFileWriter::SiPixelDetInfoFileWriter");
27 
28  filePath_ = iConfig.getUntrackedParameter<std::string>("FilePath",std::string("SiPixelDetInfo.dat"));
29 
30 }
31 
32 
34 
35  edm::LogInfo("SiPixelDetInfoFileWriter::~SiPixelDetInfoFileWriter");
36 }
37 
38 
39 
41 
42  outputFile_.open(filePath_.c_str());
43 
44  if (outputFile_.is_open()){
45 
47 
48  iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
49 
50  edm::LogInfo("SiPixelDetInfoFileWriter::beginJob - got geometry ")<<std::endl;
51  edm::LogInfo("SiPixelDetInfoFileWriter") <<" There are "<<pDD->detUnits().size() <<" detectors"<<std::endl;
52 
53  int nPixelDets = 0;
54 
55  for(TrackerGeometry::DetUnitContainer::const_iterator it = pDD->detUnits().begin(); it != pDD->detUnits().end(); it++){
56 
57  const PixelGeomDetUnit* mit = dynamic_cast<PixelGeomDetUnit const *>(*it);
58 
59  if(mit!=0){
60  nPixelDets++;
61  const PixelTopology & topol = mit->specificTopology();
62  // Get the module sizes.
63  int nrows = topol.nrows(); // rows in x
64  int ncols = topol.ncolumns(); // cols in y
65  uint32_t detid=(mit->geographicalId()).rawId();
66 
67 
68  outputFile_ << detid << " "<< ncols << " " << nrows << "\n";
69 
70  }
71  }
72  outputFile_.close();
73  edm::LogInfo("SiPixelDetInfoFileWriter::beginJob - Loop finished. ")<< nPixelDets << " Pixel DetUnits found " << std::endl;
74  }
75 
76  else {
77 
78  edm::LogError("SiPixelDetInfoFileWriter::beginJob - Unable to open file")<<endl;
79  return;
80 
81  }
82 
83 }
84 
85 
87 
88 }
89 
91 
92 }
T getUntrackedParameter(std::string const &, T const &) const
virtual int nrows() const =0
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:79
void analyze(const edm::Event &, const edm::EventSetup &)
const T & get() const
Definition: EventSetup.h:55
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
SiPixelDetInfoFileWriter(const edm::ParameterSet &)
virtual int ncolumns() const =0
void beginRun(const edm::Run &, const edm::EventSetup &)
const DetUnitContainer & detUnits() const override
Returm a vector of all GeomDetUnit.
Definition: Run.h:42