CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
10 
14 
15 using namespace cms;
16 using namespace std;
17 
19  edm::LogInfo("SiPixelDetInfoFileWriter::SiPixelDetInfoFileWriter");
20 
21  trackerGeomTokenBeginRun_ = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord, edm::Transition::BeginRun>();
22  filePath_ = iConfig.getUntrackedParameter<std::string>("FilePath", std::string("SiPixelDetInfo.dat"));
23 }
24 
26  edm::LogInfo("SiPixelDetInfoFileWriter::~SiPixelDetInfoFileWriter");
27 }
28 
30  outputFile_.open(filePath_.c_str());
31 
32  if (outputFile_.is_open()) {
33  edm::ESHandle<TrackerGeometry> pDD = iSetup.getHandle(trackerGeomTokenBeginRun_);
34 
35  edm::LogInfo("SiPixelDetInfoFileWriter::beginJob - got geometry ") << std::endl;
36  edm::LogInfo("SiPixelDetInfoFileWriter") << " There are " << pDD->detUnits().size() << " detectors" << std::endl;
37 
38  int nPixelDets = 0;
39 
40  for (const auto &it : pDD->detUnits()) {
41  const PixelGeomDetUnit *mit = dynamic_cast<PixelGeomDetUnit const *>(it);
42 
43  if (mit != nullptr) {
44  nPixelDets++;
45  const PixelTopology &topol = mit->specificTopology();
46  // Get the module sizes.
47  int nrows = topol.nrows(); // rows in x
48  int ncols = topol.ncolumns(); // cols in y
49  uint32_t detid = (mit->geographicalId()).rawId();
50 
51  outputFile_ << detid << " " << ncols << " " << nrows << "\n";
52  }
53  }
54  outputFile_.close();
55  edm::LogInfo("SiPixelDetInfoFileWriter::beginJob - Loop finished. ")
56  << nPixelDets << " Pixel DetUnits found " << std::endl;
57  }
58 
59  else {
60  edm::LogError("SiPixelDetInfoFileWriter::beginJob - Unable to open file") << endl;
61  return;
62  }
63 }
64 
66 
T getUntrackedParameter(std::string const &, T const &) const
virtual int ncolumns() const =0
virtual int nrows() const =0
Log< level::Error, false > LogError
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
void analyze(const edm::Event &, const edm::EventSetup &) override
void beginRun(const edm::Run &, const edm::EventSetup &) override
Log< level::Info, false > LogInfo
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
SiPixelDetInfoFileWriter(const edm::ParameterSet &)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
Definition: Run.h:45