CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/CalibTracker/SiPixelESProducers/plugins/SiPixelDetInfoFileWriter.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // Package:    SiPixelESProducers
00003 // Class:      SiPixelDetInfoFileWriter
00004 // Original Author:  V.Chiochia (adapted from the Strip version by G.Bruno)
00005 //         Created:  Mon May 20 10:04:31 CET 2007
00006 // $Id: SiPixelDetInfoFileWriter.cc,v 1.4 2010/01/14 09:36:57 ursl Exp $
00007 
00008 #include "CalibTracker/SiPixelESProducers/interface/SiPixelDetInfoFileWriter.h"
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010 #include "FWCore/Framework/interface/ESHandle.h"
00011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00012 
00013 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" 
00014 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00015 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00016 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
00017 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
00018 
00019 
00020 using namespace cms;
00021 using namespace std;
00022 
00023 
00024 SiPixelDetInfoFileWriter::SiPixelDetInfoFileWriter(const edm::ParameterSet& iConfig) {
00025 
00026   
00027   edm::LogInfo("SiPixelDetInfoFileWriter::SiPixelDetInfoFileWriter");
00028 
00029   filePath_ = iConfig.getUntrackedParameter<std::string>("FilePath",std::string("SiPixelDetInfo.dat"));
00030 
00031 }
00032 
00033 
00034 SiPixelDetInfoFileWriter::~SiPixelDetInfoFileWriter(){
00035 
00036    edm::LogInfo("SiPixelDetInfoFileWriter::~SiPixelDetInfoFileWriter");
00037 }
00038 
00039 
00040 
00041 void SiPixelDetInfoFileWriter::beginRun(const edm::Run &run , const edm::EventSetup &iSetup){
00042 
00043   outputFile_.open(filePath_.c_str());
00044 
00045   if (outputFile_.is_open()){
00046 
00047     edm::ESHandle<TrackerGeometry> pDD;
00048 
00049     iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
00050 
00051     edm::LogInfo("SiPixelDetInfoFileWriter::beginJob - got geometry  ")<<std::endl;    
00052     edm::LogInfo("SiPixelDetInfoFileWriter") <<" There are "<<pDD->detUnits().size() <<" detectors"<<std::endl;
00053     
00054     int nPixelDets = 0;
00055 
00056     for(TrackerGeometry::DetUnitContainer::const_iterator it = pDD->detUnits().begin(); it != pDD->detUnits().end(); it++){
00057   
00058       const PixelGeomDetUnit* mit = dynamic_cast<PixelGeomDetUnit*>(*it);
00059 
00060       if(mit!=0){
00061         nPixelDets++;
00062       const PixelTopology & topol = mit->specificTopology();       
00063       // Get the module sizes.
00064       int nrows = topol.nrows();      // rows in x
00065       int ncols = topol.ncolumns();   // cols in y      
00066       uint32_t detid=(mit->geographicalId()).rawId();
00067       
00068       
00069       outputFile_ << detid << " "<< ncols << " " << nrows << "\n";
00070       
00071       }
00072     }    
00073     outputFile_.close();
00074     edm::LogInfo("SiPixelDetInfoFileWriter::beginJob - Loop finished. ")<< nPixelDets << " Pixel DetUnits found " << std::endl;
00075   }
00076   
00077   else {
00078 
00079     edm::LogError("SiPixelDetInfoFileWriter::beginJob - Unable to open file")<<endl;
00080     return;
00081   
00082   }
00083 
00084 }
00085 
00086 
00087 void SiPixelDetInfoFileWriter::beginJob() {
00088 
00089 }
00090 
00091 void SiPixelDetInfoFileWriter::analyze(const edm::Event &, const edm::EventSetup &) {
00092 
00093 }