Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:35

0001 //#include <memory>
0002 
0003 #include <string.h>
0004 
0005 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0006 
0007 #include "FWCore/Framework/interface/EventSetup.h"
0008 #include "FWCore/Framework/interface/ESHandle.h"
0009 #include "FWCore/Framework/interface/MakerMacros.h"
0010 
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 
0013 #include "CondFormats/SiPixelObjects/interface/SiPixelDetSummary.h"
0014 
0015 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0016 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0017 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0018 
0019 using std::string;
0020 using namespace std;
0021 
0022 // ----------------------------------------------------------------------
0023 class SiPixelTestSummary : public edm::one::EDAnalyzer<> {
0024 public:
0025   explicit SiPixelTestSummary(const edm::ParameterSet&) : geomToken_(esConsumes()) {}
0026   ~SiPixelTestSummary();
0027   virtual void analyze(const edm::Event&, const edm::EventSetup&);
0028 
0029 private:
0030   edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomToken_;
0031 };
0032 
0033 // ----------------------------------------------------------------------
0034 SiPixelTestSummary::~SiPixelTestSummary() = default;
0035 
0036 // ----------------------------------------------------------------------
0037 void SiPixelTestSummary::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0038   std::cout << "====== SiPixelTestSummary begin" << std::endl;
0039 
0040   SiPixelDetSummary a(1);
0041 
0042   const TrackerGeometry* pDD = &iSetup.getData(geomToken_);
0043 
0044   cout << "**********************************************************************" << endl;
0045   cout << " *** Geometry node for TrackerGeom is  " << &(*pDD) << std::endl;
0046   cout << " *** I have " << pDD->dets().size() << " detectors" << std::endl;
0047   cout << " *** I have " << pDD->detTypes().size() << " types" << std::endl;
0048 
0049   for (TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++) {
0050     if (dynamic_cast<PixelGeomDetUnit const*>((*it)) != 0) {
0051       DetId detId = (*it)->geographicalId();
0052       a.add(detId);
0053     }
0054   }
0055 
0056   bool toyExample(false);
0057   if (toyExample) {
0058     a.add(302055684, 2.3);  // BPix_BmI_SEC4_LYR1_LDR5_MOD4  302055684
0059     a.add(302125072, 2.4);  // BPix_BmO_SEC4_LYR2_LDR8_MOD1  302125072
0060     a.add(302188552, 2.1);  // BPix_BmI_SEC2_LYR3_LDR4_MOD3  302188552
0061     a.add(352388356, 1.5);  // FPix_BpI_D1_BLD6_PNL1_MOD1  352388356
0062     a.add(352390664, 2.2);  // FPix_BpI_D1_BLD4_PNL2_MOD2  352390664
0063     a.add(352453892, 2.5);  // FPix_BpI_D2_BLD6_PNL1_MOD1  352453892
0064     a.add(352457224, 2.1);  // FPix_BpI_D2_BLD3_PNL2_MOD2  352457224
0065     a.add(344005892, 2.6);  // FPix_BmO_D1_BLD1_PNL1_MOD1  344005892
0066     a.add(344008204, 2.0);  // FPix_BmO_D1_BLD3_PNL2_MOD3  344008204
0067     a.add(344071432, 2.4);  // FPix_BmO_D2_BLD1_PNL1_MOD2  344071432
0068     //  a.add(344073740);  // FPix_BmO_D2_BLD3_PNL2_MOD3  344073740
0069   }
0070 
0071   cout << endl;
0072   cout << "Testing printout" << endl;
0073   stringstream bla;
0074   a.print(bla, false);
0075   cout << bla.str() << endl;
0076 
0077   cout << endl;
0078   cout << "Testing map" << endl;
0079   map<int, int> b = a.getCounts();
0080   for (map<int, int>::const_iterator bIt = b.begin(); bIt != b.end(); ++bIt) {
0081     cout << bIt->first << " -> " << bIt->second << endl;
0082   }
0083 
0084   std::cout << "====== SiPixelTestSummary end" << std::endl;
0085 }
0086 
0087 //define this as a plug-in
0088 DEFINE_FWK_MODULE(SiPixelTestSummary);