Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 23:29:36

0001 // -*- C++ -*-
0002 // Package:    SiPixelESProducers
0003 // Class:      SiPixelDetInfoFileWriter
0004 // Original Author:  V.Chiochia (adapted from the Strip version by G.Bruno)
0005 //         Created:  Mon May 20 10:04:31 CET 2007
0006 
0007 #include "CalibTracker/SiPixelESProducers/interface/SiPixelDetInfoFileWriter.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 
0011 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0012 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
0013 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0014 
0015 using namespace cms;
0016 using namespace std;
0017 
0018 SiPixelDetInfoFileWriter::SiPixelDetInfoFileWriter(const edm::ParameterSet &iConfig) {
0019   edm::LogInfo("SiPixelDetInfoFileWriter::SiPixelDetInfoFileWriter");
0020 
0021   trackerGeomTokenBeginRun_ = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord, edm::Transition::BeginRun>();
0022   filePath_ = iConfig.getUntrackedParameter<std::string>("FilePath", std::string("SiPixelDetInfo.dat"));
0023 }
0024 
0025 SiPixelDetInfoFileWriter::~SiPixelDetInfoFileWriter() {
0026   edm::LogInfo("SiPixelDetInfoFileWriter::~SiPixelDetInfoFileWriter");
0027 }
0028 
0029 void SiPixelDetInfoFileWriter::beginRun(const edm::Run &run, const edm::EventSetup &iSetup) {
0030   outputFile_.open(filePath_.c_str());
0031 
0032   if (outputFile_.is_open()) {
0033     edm::ESHandle<TrackerGeometry> pDD = iSetup.getHandle(trackerGeomTokenBeginRun_);
0034 
0035     edm::LogInfo("SiPixelDetInfoFileWriter::beginJob - got geometry  ") << std::endl;
0036     edm::LogInfo("SiPixelDetInfoFileWriter") << " There are " << pDD->detUnits().size() << " detectors" << std::endl;
0037 
0038     int nPixelDets = 0;
0039 
0040     for (const auto &it : pDD->detUnits()) {
0041       const PixelGeomDetUnit *mit = dynamic_cast<PixelGeomDetUnit const *>(it);
0042 
0043       if (mit != nullptr) {
0044         nPixelDets++;
0045         const PixelTopology &topol = mit->specificTopology();
0046         // Get the module sizes.
0047         int nrows = topol.nrows();     // rows in x
0048         int ncols = topol.ncolumns();  // cols in y
0049         uint32_t detid = (mit->geographicalId()).rawId();
0050 
0051         outputFile_ << detid << " " << ncols << " " << nrows << "\n";
0052       }
0053     }
0054     outputFile_.close();
0055     edm::LogInfo("SiPixelDetInfoFileWriter::beginJob - Loop finished. ")
0056         << nPixelDets << " Pixel DetUnits found " << std::endl;
0057   }
0058 
0059   else {
0060     edm::LogError("SiPixelDetInfoFileWriter::beginJob - Unable to open file") << endl;
0061     return;
0062   }
0063 }
0064 
0065 void SiPixelDetInfoFileWriter::beginJob() {}
0066 
0067 void SiPixelDetInfoFileWriter::analyze(const edm::Event &, const edm::EventSetup &) {}