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 using namespace cms;
19 using namespace std;
20 
22  edm::LogInfo("SiPixelDetInfoFileWriter::SiPixelDetInfoFileWriter");
23 
24  filePath_ = iConfig.getUntrackedParameter<std::string>("FilePath", std::string("SiPixelDetInfo.dat"));
25 }
26 
28  edm::LogInfo("SiPixelDetInfoFileWriter::~SiPixelDetInfoFileWriter");
29 }
30 
32  outputFile_.open(filePath_.c_str());
33 
34  if (outputFile_.is_open()) {
36 
37  iSetup.get<TrackerDigiGeometryRecord>().get(pDD);
38 
39  edm::LogInfo("SiPixelDetInfoFileWriter::beginJob - got geometry ") << std::endl;
40  edm::LogInfo("SiPixelDetInfoFileWriter") << " There are " << pDD->detUnits().size() << " detectors" << std::endl;
41 
42  int nPixelDets = 0;
43 
44  for (const auto &it : pDD->detUnits()) {
45  const PixelGeomDetUnit *mit = dynamic_cast<PixelGeomDetUnit const *>(it);
46 
47  if (mit != nullptr) {
48  nPixelDets++;
49  const PixelTopology &topol = mit->specificTopology();
50  // Get the module sizes.
51  int nrows = topol.nrows(); // rows in x
52  int ncols = topol.ncolumns(); // cols in y
53  uint32_t detid = (mit->geographicalId()).rawId();
54 
55  outputFile_ << detid << " " << ncols << " " << nrows << "\n";
56  }
57  }
58  outputFile_.close();
59  edm::LogInfo("SiPixelDetInfoFileWriter::beginJob - Loop finished. ")
60  << nPixelDets << " Pixel DetUnits found " << std::endl;
61  }
62 
63  else {
64  edm::LogError("SiPixelDetInfoFileWriter::beginJob - Unable to open file") << endl;
65  return;
66  }
67 }
68 
70 
T getUntrackedParameter(std::string const &, T const &) const
virtual int nrows() const =0
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
void analyze(const edm::Event &, const edm::EventSetup &) override
Namespace of DDCMS conversion namespace.
void beginRun(const edm::Run &, const edm::EventSetup &) override
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
SiPixelDetInfoFileWriter(const edm::ParameterSet &)
virtual int ncolumns() const =0
T get() const
Definition: EventSetup.h:73
Definition: Run.h:45