HGCal Test Beam  03a93d6239a951948e06fb3ef8dae4cbdebfad30
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TestRecHit.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package:
4 // Class: TestRecHit
5 //
6 /**\class TestRecHit TestRecHit.cc
7  HGCal/TBStandaloneSimulatpr/plugins/TestRecHit.cc
8 
9  Description: [one line class summary]
10 
11  Implementation:
12  [Notes on implementation]
13 */
14 //
15 // Original Author: Harrison B. Prosper
16 // Created: Sat, 09 Apr 2016 13:37:51 GMT
17 
18 
19 // system include files
20 #include <memory>
21 #include <iostream>
22 #include "TH1F.h"
23 // user include files
24 #include "FWCore/Framework/interface/Frameworkfwd.h"
25 #include "FWCore/Framework/interface/EDAnalyzer.h"
26 #include "FWCore/Framework/interface/Event.h"
27 #include "FWCore/Framework/interface/MakerMacros.h"
28 #include "FWCore/ParameterSet/interface/ParameterSet.h"
29 
30 #include "FWCore/ServiceRegistry/interface/Service.h"
31 #include "HGCal/DataFormats/interface/HGCalTBRecHitCollections.h"
32 #include "HGCal/DataFormats/interface/HGCalTBDetId.h"
33 #include "HGCal/DataFormats/interface/HGCalTBRecHit.h"
34 #include "HGCal/Geometry/interface/HGCalTBCellVertices.h"
35 #include "HGCal/Geometry/interface/HGCalTBTopology.h"
36 #include "CommonTools/UtilAlgos/interface/TFileService.h"
37 //
38 // class declaration
39 //
40 
41 // If the analyzer does not use TFileService, please remove
42 // the template argument to the base class so the class inherits
43 // from edm::one::EDAnalyzer<> and also remove the line from
44 // constructor "usesResource("TFileService");"
45 // This will improve performance in multithreaded jobs.
46 
47 
48 class TestRecHit : public edm::EDAnalyzer
49 {
50 public:
51  explicit TestRecHit(const edm::ParameterSet&);
52  ~TestRecHit();
53  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
54 
55 private:
56  virtual void beginJob();
57  void analyze(const edm::Event& , const edm::EventSetup&);
58  virtual void endJob();
59 
60  // ----------member data ---------------------------
61  int sensor_size;
62  edm::EDGetToken token;
63  HGCalTBTopology check;
64 };
65 
66 TestRecHit::TestRecHit(const edm::ParameterSet& config)
67  : sensor_size(128),
68  token(consumes<HGCalTBRecHitCollection>
69  (config.getParameter<edm::InputTag>("HGCALTBRECHITS"))),
70  check(HGCalTBTopology())
71 {
72 }
73 
74 
75 TestRecHit::~TestRecHit()
76 {
77 }
78 
79 
80 //
81 // member functions
82 //
83 
84 // ------------ method called for each event ------------
85 void
86 TestRecHit::analyze(const edm::Event& event, const edm::EventSetup& setup)
87 {
88  using namespace edm;
89  using namespace std;
90 
91  Handle<HGCalTBRecHitCollection> Rechits;
92  event.getByToken(token, Rechits);
93 
94  for(auto RecHit : *Rechits) {
95  int layer = RecHit.id().layer();
96  int sensor_u = RecHit.id().sensorIU();
97  int sensor_v = RecHit.id().sensorIV();
98  int u = RecHit.id().iu();
99  int v = RecHit.id().iv();
100  bool good = check.iu_iv_valid(layer,
101  sensor_u, sensor_v,
102  u, v,
103  sensor_size);
104  if ( !good ) {
105  char record[1024];
106  sprintf(record,
107  "bad cell:\n"
108  "\tlayer=%4d, sensor_u=%4d, sensor_v=%4d, u=%4d, v=%4d",
109  layer, sensor_u, sensor_v, u, v);
110  cout << record << endl;
111  continue;
112  }
113  }
114 }
115 
116 
117 void
118 TestRecHit::beginJob()
119 {
120 }
121 
122 void
123 TestRecHit::endJob()
124 {
125 }
126 
127 void
128 TestRecHit::fillDescriptions(edm::ConfigurationDescriptions& descriptions)
129 {
130  edm::ParameterSetDescription desc;
131  desc.setUnknown();
132  descriptions.addDefault(desc);
133 }
134 
135 
136 DEFINE_FWK_MODULE(TestRecHit);
DEFINE_FWK_MODULE(Pedestals)
edm::SortedCollection< HGCalTBRecHit > HGCalTBRecHitCollection