CMS 3D CMS Logo

PPSPixelDigiAnalyzer.cc
Go to the documentation of this file.
1 #ifndef SimPPS_RPIXDigiAnalyzer_h
2 #define SimPPS_RPIXDigiAnalyzer_h
3 
14 
24 
25 #include <iostream>
26 #include <string>
27 
28 #include "TH2D.h"
29 
30 #define SELECTED_PIXEL_ROW 89
31 #define SELECTED_PIXEL_COLUMN 23
32 #define SELECTED_UNITID 2014314496
33 #define TG184 0.332655724
34 
35 #define USE_MIDDLE_OF_PIXEL_2
36 #define CENTERX 1.05
37 #define CENTERY -8.475
38 
39 using namespace edm;
40 using namespace std;
41 
42 class PSimHit;
43 
44 namespace edm {
45  class ParameterSet;
46  class Event;
47  class EventSetup;
48 } // namespace edm
49 
50 class PPSPixelDigiAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
51 public:
53  ~PPSPixelDigiAnalyzer() override;
54  void endJob() override;
55  void beginJob() override;
56  void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override;
57 
58 private:
59  TH2D *hAllHits;
64  //TFile *file;
66 
70 
73  unsigned int cumulative_cluster_size_[3];
74 };
75 
77  : hAllHits(nullptr),
78  hOneHitperEvent(nullptr),
79  hOneHitperEvent2(nullptr),
80  hOneHitperEventCenter(nullptr),
81  hOneHitperEvent2Center(nullptr),
82  theRPixDetTopology_() {
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 }
103 
105 
108  for (int a = 0; a < 3; a++)
110 }
112  edm::LogInfo("PPSPixelDigiAnalyzer") << "found_corresponding_digi_count_: " << found_corresponding_digi_count_;
113  edm::LogInfo("PPSPixelDigiAnalyzer") << "Cumulative cluster size (1,2,>2) = " << cumulative_cluster_size_[0] << ", "
115 }
116 
117 void PPSPixelDigiAnalyzer::analyze(const Event &event, const EventSetup &eventSetup) {
118  if (verbosity_ > 0)
119  edm::LogInfo("PPSPixelDigiAnalyzer") << "--- Run: " << event.id().run() << " Event: " << event.id().event();
120 
121  edm::LogInfo("PPSPixelDigiAnalyzer")
122  << " I do love Pixels ";
124  event.getByToken(psim_token, simHits);
125 
127  event.getByToken(pixel_token, CTPPSPixelDigis);
128 
129  if (verbosity_ > 0)
130  edm::LogInfo("PPSPixelDigiAnalyzer") << "\n=================== RPDA Starting SimHit access"
131  << " ===================";
132 
133  if (verbosity_ > 1)
134  edm::LogInfo("PPSPixelDigiAnalyzer") << simHits->size();
135 
136  double selected_pixel_lower_x;
137  double selected_pixel_lower_y;
138  double selected_pixel_upper_x;
139  double selected_pixel_upper_y;
140  double myX = 0;
141  double myY = 0;
142 
145  selected_pixel_lower_x,
146  selected_pixel_upper_x,
147  selected_pixel_lower_y,
148  selected_pixel_upper_y);
149 
150  double hit_inside_selected_pixel[2];
151  bool found_hit_inside_selected_pixel = false;
152 
153  for (vector<PSimHit>::const_iterator hit = simHits->begin(); hit != simHits->end(); hit++) {
154  LocalPoint entryP = hit->entryPoint();
155  LocalPoint exitP = hit->exitPoint();
156  LocalPoint midP((entryP.x() + exitP.x()) / 2., (entryP.y() + exitP.y()) / 2.);
157 
158 #ifdef USE_MIDDLE_OF_PIXEL
159  if (entryP.x() > selected_pixel_lower_x && entryP.x() < selected_pixel_upper_x &&
160  entryP.y() > (selected_pixel_lower_y + 0.115 * TG184) && entryP.y() < (selected_pixel_upper_y + 0.115 * TG184)
161 #else
163  if (midP.x() > selected_pixel_lower_x && midP.x() < selected_pixel_upper_x && midP.y() > selected_pixel_lower_y &&
164  midP.y() < selected_pixel_upper_y
165 #else
166  if (entryP.x() > selected_pixel_lower_x && entryP.x() < selected_pixel_upper_x &&
167  entryP.y() > selected_pixel_lower_y && entryP.y() < selected_pixel_upper_y
168 #endif
169 #endif
170  && hit->detUnitId() == SELECTED_UNITID) {
171  hit_inside_selected_pixel[0] = entryP.x();
172  hit_inside_selected_pixel[1] = entryP.y();
173  found_hit_inside_selected_pixel = true;
174 #ifdef USE_MIDDLE_OF_PIXEL_2
175  hAllHits->Fill(midP.x(), midP.y());
176  myX = midP.x();
177  myY = midP.y();
178 #else
179  hAllHits->Fill(entryP.x(), entryP.y());
180  myX = entryP.x();
181  myY = entryP.y();
182 #endif
183  if (verbosity_ > 2)
184  edm::LogInfo("PPSPixelDigiAnalyzer") << hit_inside_selected_pixel[0] << " " << hit_inside_selected_pixel[1];
185  }
186 
187  //--------------
188 
189  if (verbosity_ > 1)
190  if (hit->timeOfFlight() > 0) {
191  edm::LogInfo("PPSPixelDigiAnalyzer")
192  << "DetId: " << hit->detUnitId() << "PID: " << hit->particleType() << " TOF: " << hit->timeOfFlight()
193  << " Proc Type: " << hit->processType() << " p: " << hit->pabs() << " x = " << entryP.x()
194  << " y = " << entryP.y() << " z = " << entryP.z();
195  }
196  }
197 
198  if (verbosity_ > 0)
199  edm::LogInfo("PPSPixelDigiAnalyzer") << "\n=================== RPDA Starting Digi access"
200  << " ===================";
201  int numberOfDetUnits = 0;
202 
203  // Iterate on detector units
204  edm::DetSetVector<CTPPSPixelDigi>::const_iterator DSViter = CTPPSPixelDigis->begin();
205 
206  for (; DSViter != CTPPSPixelDigis->end(); DSViter++) {
207  ++numberOfDetUnits;
208 
209  DetId detIdObject(DSViter->detId());
210  if (verbosity_ > 1)
211  edm::LogInfo("PPSPixelDigiAnalyzer") << "DetId: " << DSViter->detId();
212 
213  bool found_corresponding_digi = false;
214  unsigned int corresponding_digi_cluster_size = 0;
215 
216  // looping over digis in a unit id
219 
220  if (verbosity_ > 2) {
221  edm::LogInfo("PPSPixelDigiAnalyzer") << "FF " << DSViter->detId();
222  for (edm::DetSet<CTPPSPixelDigi>::const_iterator di = begin; di != end; di++) {
223  edm::LogInfo("PPSPixelDigiAnalyzer") << " Digi row " << di->row() << ", col " << di->column();
224 
225  // reconvert the digi to local coordinates
226  double lx;
227  double ly;
228  double ux;
229  double uy;
230  unsigned int rr = di->row();
231  unsigned int cc = di->column();
232  theRPixDetTopology_.pixelRange(rr, cc, lx, ux, ly, uy);
233 
234  edm::LogInfo("PPSPixelDigiAnalyzer")
235  << " pixel boundaries x low up, y low up " << lx << " " << ux << " " << ly << " " << uy;
236  }
237  }
238  if (DSViter->detId() == SELECTED_UNITID && found_hit_inside_selected_pixel) {
239  for (edm::DetSet<CTPPSPixelDigi>::const_iterator di = begin; di != end; di++) {
240  if (verbosity_ > 1)
241  edm::LogInfo("PPSPixelDigiAnalyzer") << " Digi row " << di->row() << ", col " << di->column();
242 
243  if (di->row() == SELECTED_PIXEL_ROW && di->column() == SELECTED_PIXEL_COLUMN) {
245  found_corresponding_digi = true;
246  corresponding_digi_cluster_size = 1;
247  }
248  }
249  //if coresponding digi found, re-loop to look for adjacent pixels
250  if (found_corresponding_digi) {
251  for (edm::DetSet<CTPPSPixelDigi>::const_iterator di = begin; di != end; di++) {
252  if (verbosity_ > 1)
253  edm::LogInfo("PPSPixelDigiAnalyzer") << " Digi row " << di->row() << ", col " << di->column();
254 
255  if ((di->row() == SELECTED_PIXEL_ROW + 1 && di->column() == SELECTED_PIXEL_COLUMN) ||
256  (di->row() == SELECTED_PIXEL_ROW - 1 && di->column() == SELECTED_PIXEL_COLUMN) ||
257  (di->row() == SELECTED_PIXEL_ROW && di->column() == SELECTED_PIXEL_COLUMN + 1) ||
258  (di->row() == SELECTED_PIXEL_ROW && di->column() == SELECTED_PIXEL_COLUMN - 1)) {
259  corresponding_digi_cluster_size++;
260  edm::LogInfo("PPSPixelDigiAnalyzer") << " Digi row " << di->row() << ", col " << di->column();
261  }
262  }
263  }
264  }
265  if (corresponding_digi_cluster_size > 0) {
266  edm::LogInfo("PPSPixelDigiAnalyzer")
267  << "corresponding_digi_cluster_size in the event: " << corresponding_digi_cluster_size;
268  hOneHitperEvent->Fill(myY, myX);
269  hOneHitperEventCenter->Fill(myY - CENTERY, myX - CENTERX);
270  if (corresponding_digi_cluster_size < 3) {
271  cumulative_cluster_size_[corresponding_digi_cluster_size - 1]++;
272  if (corresponding_digi_cluster_size > 1) {
273  hOneHitperEvent2->Fill(myY, myX);
274  hOneHitperEvent2Center->Fill(myY - CENTERY, myX - CENTERX);
275  }
276  } else {
278  hOneHitperEvent2->Fill(myY, myX);
279  hOneHitperEvent2Center->Fill(myY - CENTERY, myX - CENTERX);
280  }
281  }
282  }
283 
284  if (verbosity_ > 1)
285  edm::LogInfo("PPSPixelDigiAnalyzer") << "numberOfDetUnits in the event: " << numberOfDetUnits;
286 }
287 
290 
292 
293 #endif
bk::beginJob
void beginJob()
Definition: Breakpoints.cc:14
PPSPixelDigiAnalyzer
Definition: PPSPixelDigiAnalyzer.cc:50
Handle.h
PPSPixelDigiAnalyzer::hOneHitperEvent2
TH2D * hOneHitperEvent2
Definition: PPSPixelDigiAnalyzer.cc:61
EDAnalyzer.h
PPSPixelDigiAnalyzer::PPSPixelDigiAnalyzer
PPSPixelDigiAnalyzer(const edm::ParameterSet &pset)
Definition: PPSPixelDigiAnalyzer.cc:76
SELECTED_PIXEL_ROW
#define SELECTED_PIXEL_ROW
Definition: PPSPixelDigiAnalyzer.cc:30
USE_MIDDLE_OF_PIXEL_2
#define USE_MIDDLE_OF_PIXEL_2
Definition: PPSPixelDigiAnalyzer.cc:35
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:89353
CTPPSPixelSimTopology.h
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:31
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:32
edm::Handle
Definition: AssociativeIterator.h:50
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
Point3DBase< float, LocalTag >
PPSPixelDigiAnalyzer::hOneHitperEventCenter
TH2D * hOneHitperEventCenter
Definition: PPSPixelDigiAnalyzer.cc:62
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TFileService.h
PPSPixelDigiAnalyzer::beginJob
void beginJob() override
Definition: PPSPixelDigiAnalyzer.cc:106
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:69
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:72
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
PPSPixelDigiAnalyzer::verbosity_
int verbosity_
Definition: PPSPixelDigiAnalyzer.cc:67
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EventSetup
Definition: EventSetup.h:57
DetSetVector.h
CTPPSPixelSimTopology::pixelRange
void pixelRange(unsigned int arow, unsigned int acol, double &lower_x, double &higher_x, double &lower_y, double &higher_y) const
Definition: CTPPSPixelSimTopology.h:61
CTPPSPixelDigi.h
PPSPixelDigiAnalyzer::~PPSPixelDigiAnalyzer
~PPSPixelDigiAnalyzer() override
Definition: PPSPixelDigiAnalyzer.cc:104
std
Definition: JetResolutionObject.h:76
CTPPSPixelSimTopology
Definition: CTPPSPixelSimTopology.h:7
PPSPixelDigiAnalyzer::label_
std::string label_
Definition: PPSPixelDigiAnalyzer.cc:65
PPSPixelDigiAnalyzer::hOneHitperEvent
TH2D * hOneHitperEvent
Definition: PPSPixelDigiAnalyzer.cc:60
LocalPoint.h
EventSetup.h
PPSPixelDigiAnalyzer::hAllHits
TH2D * hAllHits
Definition: PPSPixelDigiAnalyzer.cc:59
PPSPixelDigiAnalyzer::cumulative_cluster_size_
unsigned int cumulative_cluster_size_[3]
Definition: PPSPixelDigiAnalyzer.cc:73
ConsumesCollector.h
PPSPixelDigiAnalyzer::psim_token
edm::EDGetTokenT< edm::PSimHitContainer > psim_token
Definition: PPSPixelDigiAnalyzer.cc:68
PPSPixelDigiAnalyzer::endJob
void endJob() override
Definition: PPSPixelDigiAnalyzer.cc:111
ParameterSet.h
CENTERY
#define CENTERY
Definition: PPSPixelDigiAnalyzer.cc:37
PSimHit
Definition: PSimHit.h:15
event
Definition: event.py:1
CENTERX
#define CENTERX
Definition: PPSPixelDigiAnalyzer.cc:36
edm::Event
Definition: Event.h:73
TG184
#define TG184
Definition: PPSPixelDigiAnalyzer.cc:33
CTPPSPixelDigiCollection.h
edm::InputTag
Definition: InputTag.h:15
PPSPixelDigiAnalyzer::analyze
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
Definition: PPSPixelDigiAnalyzer.cc:117
hit
Definition: SiStripHitEffFromCalibTree.cc:88
PPSPixelDigiAnalyzer::theRPixDetTopology_
CTPPSPixelSimTopology theRPixDetTopology_
Definition: PPSPixelDigiAnalyzer.cc:71
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
PPSPixelDigiAnalyzer::hOneHitperEvent2Center
TH2D * hOneHitperEvent2Center
Definition: PPSPixelDigiAnalyzer.cc:63
edm::DetSet::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSet.h:31