CMS 3D CMS Logo

PPSPixelDigiAnalyzer.cc
Go to the documentation of this file.
1 #ifndef SimPPS_RPIXDigiAnalyzer_h
2 #define SimPPS_RPIXDigiAnalyzer_h
3 
13 
25 
26 #include <iostream>
27 #include <string>
28 
29 #include "TH2D.h"
30 
31 #define SELECTED_PIXEL_ROW 89
32 #define SELECTED_PIXEL_COLUMN 23
33 #define SELECTED_UNITID 2014314496
34 #define TG184 0.332655724
35 
36 #define USE_MIDDLE_OF_PIXEL_2
37 #define CENTERX 1.05
38 #define CENTERY -8.475
39 
40 using namespace edm;
41 using namespace std;
42 
43 class PSimHit;
44 
45 namespace edm {
46  class ParameterSet;
47  class Event;
48  class EventSetup;
49 } // namespace edm
50 
51 class PPSPixelDigiAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
52 public:
54  ~PPSPixelDigiAnalyzer() override;
55  void endJob() override;
56  void beginJob() override;
57  void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override;
58 
59 private:
60  TH2D *hAllHits;
65  //TFile *file;
67 
72 
74  unsigned int cumulative_cluster_size_[3];
75 };
76 
78  : hAllHits(nullptr),
79  hOneHitperEvent(nullptr),
80  hOneHitperEvent2(nullptr),
81  hOneHitperEventCenter(nullptr),
82  hOneHitperEvent2Center(nullptr) {
83  label_ = pset.getUntrackedParameter<string>("label");
84  verbosity_ = pset.getParameter<int>("Verbosity");
86 #ifdef USE_MIDDLE_OF_PIXEL
87  hOneHitperEvent = file->make<TH2D>("OneHitperEvent", "One Hit per Event", 30, -8.511, -8.361, 20, 1, 1.1);
88  hOneHitperEvent2 = file->make<TH2D>("OneHitperEvent2", "One Hit per Event 2", 30, -8.511, -8.361, 20, 1, 1.1);
89 #else
90  hOneHitperEvent = file->make<TH2D>("OneHitperEvent", "One Hit per Event", 30, -8.55, -8.4, 20, 1, 1.1);
91  hOneHitperEvent2 = file->make<TH2D>("OneHitperEvent2", "One Hit per Event 2", 30, -8.55, -8.4, 20, 1, 1.1);
93  file->make<TH2D>("OneHitperEventCenter", "One Hit per Event Center", 30, -0.075, 0.075, 20, -0.05, 0.05);
95  file->make<TH2D>("OneHitperEvent2Center", "Cluster Size 2", 30, -0.075, 0.075, 20, -0.05, 0.05);
96 #endif
97  file->cd();
98  hAllHits = file->make<TH2D>("AllHits", "All Hits", 10, 1, 1.1, 10, -8.55, -8.4);
99 
100  psim_token = consumes<PSimHitContainer>(edm::InputTag("g4SimHits", "CTPPSPixelHits"));
101  pixel_token = consumes<edm::DetSetVector<CTPPSPixelDigi>>(edm::InputTag(label_, "")); //label=RPixDetDigitizer???
102  pixelTopologyToken_ = esConsumes<PPSPixelTopology, PPSPixelTopologyRcd>();
103 }
104 
106 
109  for (int a = 0; a < 3; a++)
111 }
113  edm::LogInfo("PPSPixelDigiAnalyzer") << "found_corresponding_digi_count_: " << found_corresponding_digi_count_;
114  edm::LogInfo("PPSPixelDigiAnalyzer") << "Cumulative cluster size (1,2,>2) = " << cumulative_cluster_size_[0] << ", "
116 }
117 
118 void PPSPixelDigiAnalyzer::analyze(const Event &event, const EventSetup &eventSetup) {
119  if (verbosity_ > 0)
120  edm::LogInfo("PPSPixelDigiAnalyzer") << "--- Run: " << event.id().run() << " Event: " << event.id().event();
121 
122  edm::LogInfo("PPSPixelDigiAnalyzer")
123  << " I do love Pixels ";
125  event.getByToken(psim_token, simHits);
126 
128  event.getByToken(pixel_token, CTPPSPixelDigis);
129 
130  edm::ESHandle<PPSPixelTopology> thePixelTopology = eventSetup.getHandle(pixelTopologyToken_);
131 
132  if (verbosity_ > 0)
133  edm::LogInfo("PPSPixelDigiAnalyzer") << "\n=================== RPDA Starting SimHit access"
134  << " ===================";
135 
136  if (verbosity_ > 1)
137  edm::LogInfo("PPSPixelDigiAnalyzer") << simHits->size();
138 
139  double selected_pixel_lower_x;
140  double selected_pixel_lower_y;
141  double selected_pixel_upper_x;
142  double selected_pixel_upper_y;
143  double myX = 0;
144  double myY = 0;
145 
146  thePixelTopology->pixelRange(SELECTED_PIXEL_ROW,
148  selected_pixel_lower_x,
149  selected_pixel_upper_x,
150  selected_pixel_lower_y,
151  selected_pixel_upper_y);
152 
153  double hit_inside_selected_pixel[2];
154  bool found_hit_inside_selected_pixel = false;
155 
156  for (vector<PSimHit>::const_iterator hit = simHits->begin(); hit != simHits->end(); hit++) {
157  LocalPoint entryP = hit->entryPoint();
158  LocalPoint exitP = hit->exitPoint();
159  LocalPoint midP((entryP.x() + exitP.x()) / 2., (entryP.y() + exitP.y()) / 2.);
160 
161 #ifdef USE_MIDDLE_OF_PIXEL
162  if (entryP.x() > selected_pixel_lower_x && entryP.x() < selected_pixel_upper_x &&
163  entryP.y() > (selected_pixel_lower_y + 0.115 * TG184) && entryP.y() < (selected_pixel_upper_y + 0.115 * TG184)
164 #else
166  if (midP.x() > selected_pixel_lower_x && midP.x() < selected_pixel_upper_x && midP.y() > selected_pixel_lower_y &&
167  midP.y() < selected_pixel_upper_y
168 #else
169  if (entryP.x() > selected_pixel_lower_x && entryP.x() < selected_pixel_upper_x &&
170  entryP.y() > selected_pixel_lower_y && entryP.y() < selected_pixel_upper_y
171 #endif
172 #endif
173  && hit->detUnitId() == SELECTED_UNITID) {
174  hit_inside_selected_pixel[0] = entryP.x();
175  hit_inside_selected_pixel[1] = entryP.y();
176  found_hit_inside_selected_pixel = true;
177 #ifdef USE_MIDDLE_OF_PIXEL_2
178  hAllHits->Fill(midP.x(), midP.y());
179  myX = midP.x();
180  myY = midP.y();
181 #else
182  hAllHits->Fill(entryP.x(), entryP.y());
183  myX = entryP.x();
184  myY = entryP.y();
185 #endif
186  if (verbosity_ > 2)
187  edm::LogInfo("PPSPixelDigiAnalyzer") << hit_inside_selected_pixel[0] << " " << hit_inside_selected_pixel[1];
188  }
189 
190  //--------------
191 
192  if (verbosity_ > 1)
193  if (hit->timeOfFlight() > 0) {
194  edm::LogInfo("PPSPixelDigiAnalyzer")
195  << "DetId: " << hit->detUnitId() << "PID: " << hit->particleType() << " TOF: " << hit->timeOfFlight()
196  << " Proc Type: " << hit->processType() << " p: " << hit->pabs() << " x = " << entryP.x()
197  << " y = " << entryP.y() << " z = " << entryP.z();
198  }
199  }
200 
201  if (verbosity_ > 0)
202  edm::LogInfo("PPSPixelDigiAnalyzer") << "\n=================== RPDA Starting Digi access"
203  << " ===================";
204  int numberOfDetUnits = 0;
205 
206  // Iterate on detector units
207  edm::DetSetVector<CTPPSPixelDigi>::const_iterator DSViter = CTPPSPixelDigis->begin();
208 
209  for (; DSViter != CTPPSPixelDigis->end(); DSViter++) {
210  ++numberOfDetUnits;
211 
212  DetId detIdObject(DSViter->detId());
213  if (verbosity_ > 1)
214  edm::LogInfo("PPSPixelDigiAnalyzer") << "DetId: " << DSViter->detId();
215 
216  bool found_corresponding_digi = false;
217  unsigned int corresponding_digi_cluster_size = 0;
218 
219  // looping over digis in a unit id
222 
223  if (verbosity_ > 2) {
224  edm::LogInfo("PPSPixelDigiAnalyzer") << "FF " << DSViter->detId();
225  for (edm::DetSet<CTPPSPixelDigi>::const_iterator di = begin; di != end; di++) {
226  edm::LogInfo("PPSPixelDigiAnalyzer") << " Digi row " << di->row() << ", col " << di->column();
227 
228  // reconvert the digi to local coordinates
229  double lx;
230  double ly;
231  double ux;
232  double uy;
233  unsigned int rr = di->row();
234  unsigned int cc = di->column();
235  thePixelTopology->pixelRange(rr, cc, lx, ux, ly, uy);
236 
237  edm::LogInfo("PPSPixelDigiAnalyzer")
238  << " pixel boundaries x low up, y low up " << lx << " " << ux << " " << ly << " " << uy;
239  }
240  }
241  if (DSViter->detId() == SELECTED_UNITID && found_hit_inside_selected_pixel) {
242  for (edm::DetSet<CTPPSPixelDigi>::const_iterator di = begin; di != end; di++) {
243  if (verbosity_ > 1)
244  edm::LogInfo("PPSPixelDigiAnalyzer") << " Digi row " << di->row() << ", col " << di->column();
245 
246  if (di->row() == SELECTED_PIXEL_ROW && di->column() == SELECTED_PIXEL_COLUMN) {
248  found_corresponding_digi = true;
249  corresponding_digi_cluster_size = 1;
250  }
251  }
252  //if coresponding digi found, re-loop to look for adjacent pixels
253  if (found_corresponding_digi) {
254  for (edm::DetSet<CTPPSPixelDigi>::const_iterator di = begin; di != end; di++) {
255  if (verbosity_ > 1)
256  edm::LogInfo("PPSPixelDigiAnalyzer") << " Digi row " << di->row() << ", col " << di->column();
257 
258  if ((di->row() == SELECTED_PIXEL_ROW + 1 && di->column() == SELECTED_PIXEL_COLUMN) ||
259  (di->row() == SELECTED_PIXEL_ROW - 1 && di->column() == SELECTED_PIXEL_COLUMN) ||
260  (di->row() == SELECTED_PIXEL_ROW && di->column() == SELECTED_PIXEL_COLUMN + 1) ||
261  (di->row() == SELECTED_PIXEL_ROW && di->column() == SELECTED_PIXEL_COLUMN - 1)) {
262  corresponding_digi_cluster_size++;
263  edm::LogInfo("PPSPixelDigiAnalyzer") << " Digi row " << di->row() << ", col " << di->column();
264  }
265  }
266  }
267  }
268  if (corresponding_digi_cluster_size > 0) {
269  edm::LogInfo("PPSPixelDigiAnalyzer")
270  << "corresponding_digi_cluster_size in the event: " << corresponding_digi_cluster_size;
271  hOneHitperEvent->Fill(myY, myX);
272  hOneHitperEventCenter->Fill(myY - CENTERY, myX - CENTERX);
273  if (corresponding_digi_cluster_size < 3) {
274  cumulative_cluster_size_[corresponding_digi_cluster_size - 1]++;
275  if (corresponding_digi_cluster_size > 1) {
276  hOneHitperEvent2->Fill(myY, myX);
277  hOneHitperEvent2Center->Fill(myY - CENTERY, myX - CENTERX);
278  }
279  } else {
281  hOneHitperEvent2->Fill(myY, myX);
282  hOneHitperEvent2Center->Fill(myY - CENTERY, myX - CENTERX);
283  }
284  }
285  }
286 
287  if (verbosity_ > 1)
288  edm::LogInfo("PPSPixelDigiAnalyzer") << "numberOfDetUnits in the event: " << numberOfDetUnits;
289 }
290 
293 
295 
296 #endif
PPSPixelTopology.h
bk::beginJob
void beginJob()
Definition: Breakpoints.cc:14
PPSPixelDigiAnalyzer
Definition: PPSPixelDigiAnalyzer.cc:51
Handle.h
PPSPixelDigiAnalyzer::hOneHitperEvent2
TH2D * hOneHitperEvent2
Definition: PPSPixelDigiAnalyzer.cc:62
EDAnalyzer.h
PPSPixelDigiAnalyzer::PPSPixelDigiAnalyzer
PPSPixelDigiAnalyzer(const edm::ParameterSet &pset)
Definition: PPSPixelDigiAnalyzer.cc:77
SELECTED_PIXEL_ROW
#define SELECTED_PIXEL_ROW
Definition: PPSPixelDigiAnalyzer.cc:31
USE_MIDDLE_OF_PIXEL_2
#define USE_MIDDLE_OF_PIXEL_2
Definition: PPSPixelDigiAnalyzer.cc:36
ESHandle.h
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
edm::EDGetTokenT< edm::PSimHitContainer >
findQualityFiles.rr
string rr
Definition: findQualityFiles.py:185
edm
HLT enums.
Definition: AlignableModifier.h:19
CrossingFrame.h
CTPPSPixelDetId.h
PSimHitContainer.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89281
FastTrackerRecHitCombiner_cfi.simHits
simHits
Definition: FastTrackerRecHitCombiner_cfi.py:5
edm::DetSetVector::begin
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:314
SELECTED_PIXEL_COLUMN
#define SELECTED_PIXEL_COLUMN
Definition: PPSPixelDigiAnalyzer.cc:32
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
SELECTED_UNITID
#define SELECTED_UNITID
Definition: PPSPixelDigiAnalyzer.cc:33
edm::Handle
Definition: AssociativeIterator.h:50
PPSPixelTopology::pixelRange
void pixelRange(unsigned int arow, unsigned int acol, double &lower_x, double &higher_x, double &lower_y, double &higher_y) const
Definition: PPSPixelTopology.cc:71
cc
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
DetId
Definition: DetId.h:17
MakerMacros.h
PSimHit.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MixCollection.h
Service.h
mps_fire.end
end
Definition: mps_fire.py:242
edm::ESHandle
Definition: DTSurvey.h:22
Point3DBase< float, LocalTag >
PPSPixelDigiAnalyzer::hOneHitperEventCenter
TH2D * hOneHitperEventCenter
Definition: PPSPixelDigiAnalyzer.cc:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TFileService.h
PPSPixelDigiAnalyzer::beginJob
void beginJob() override
Definition: PPSPixelDigiAnalyzer.cc:107
edm::ParameterSet
Definition: ParameterSet.h:47
a
double a
Definition: hdecay.h:119
Event.h
PPSPixelDigiAnalyzer::pixel_token
edm::EDGetTokenT< edm::DetSetVector< CTPPSPixelDigi > > pixel_token
Definition: PPSPixelDigiAnalyzer.cc:70
edm::DetSetVector::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:102
PPSPixelDigiAnalyzer::found_corresponding_digi_count_
unsigned int found_corresponding_digi_count_
Definition: PPSPixelDigiAnalyzer.cc:73
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
ModuleDef.h
edm::Service< TFileService >
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
PPSPixelDigiAnalyzer::verbosity_
int verbosity_
Definition: PPSPixelDigiAnalyzer.cc:68
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EventSetup
Definition: EventSetup.h:58
DetSetVector.h
edm::ESGetToken< PPSPixelTopology, PPSPixelTopologyRcd >
CTPPSPixelDigi.h
PPSPixelDigiAnalyzer::~PPSPixelDigiAnalyzer
~PPSPixelDigiAnalyzer() override
Definition: PPSPixelDigiAnalyzer.cc:105
std
Definition: JetResolutionObject.h:76
PPSPixelDigiAnalyzer::label_
std::string label_
Definition: PPSPixelDigiAnalyzer.cc:66
PPSPixelDigiAnalyzer::hOneHitperEvent
TH2D * hOneHitperEvent
Definition: PPSPixelDigiAnalyzer.cc:61
LocalPoint.h
EventSetup.h
PPSPixelDigiAnalyzer::hAllHits
TH2D * hAllHits
Definition: PPSPixelDigiAnalyzer.cc:60
PPSPixelDigiAnalyzer::pixelTopologyToken_
edm::ESGetToken< PPSPixelTopology, PPSPixelTopologyRcd > pixelTopologyToken_
Definition: PPSPixelDigiAnalyzer.cc:71
PPSPixelDigiAnalyzer::cumulative_cluster_size_
unsigned int cumulative_cluster_size_[3]
Definition: PPSPixelDigiAnalyzer.cc:74
ConsumesCollector.h
PPSPixelDigiAnalyzer::psim_token
edm::EDGetTokenT< edm::PSimHitContainer > psim_token
Definition: PPSPixelDigiAnalyzer.cc:69
PPSPixelDigiAnalyzer::endJob
void endJob() override
Definition: PPSPixelDigiAnalyzer.cc:112
ParameterSet.h
CENTERY
#define CENTERY
Definition: PPSPixelDigiAnalyzer.cc:38
PSimHit
Definition: PSimHit.h:15
event
Definition: event.py:1
CENTERX
#define CENTERX
Definition: PPSPixelDigiAnalyzer.cc:37
edm::Event
Definition: Event.h:73
TG184
#define TG184
Definition: PPSPixelDigiAnalyzer.cc:34
CTPPSPixelDigiCollection.h
PPSPixelTopologyRcd.h
edm::InputTag
Definition: InputTag.h:15
PPSPixelDigiAnalyzer::analyze
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
Definition: PPSPixelDigiAnalyzer.cc:118
hit
Definition: SiStripHitEffFromCalibTree.cc:88
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
PPSPixelDigiAnalyzer::hOneHitperEvent2Center
TH2D * hOneHitperEvent2Center
Definition: PPSPixelDigiAnalyzer.cc:64
edm::DetSet::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSet.h:31