File indexing completed on 2024-04-06 12:02:35
0001
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);
0059 a.add(302125072, 2.4);
0060 a.add(302188552, 2.1);
0061 a.add(352388356, 1.5);
0062 a.add(352390664, 2.2);
0063 a.add(352453892, 2.5);
0064 a.add(352457224, 2.1);
0065 a.add(344005892, 2.6);
0066 a.add(344008204, 2.0);
0067 a.add(344071432, 2.4);
0068
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
0088 DEFINE_FWK_MODULE(SiPixelTestSummary);