CMS 3D CMS Logo

CSCValidation.h
Go to the documentation of this file.
1 #ifndef RecoLocalMuon_CSCValidation_H
2 #define RecoLocalMuon_CSCValidation_H
3 
34 
54 //FEDRawData
58 
61 
66 
69 
74 
77 
84 
93 
95 
97 #include "TVector3.h"
98 #include "TH1F.h"
99 #include "TH2F.h"
100 #include "TFile.h"
101 #include "TString.h"
102 #include "TTree.h"
103 #include "TProfile2D.h"
104 
105 namespace {
106  class CSCValidation : public edm::one::EDAnalyzer<> {
107  public:
109  CSCValidation(const edm::ParameterSet &pset);
110 
112  ~CSCValidation() override;
113 
115  void analyze(edm::Event const &event, edm::EventSetup const &eventSetup) override;
116  void beginJob() override;
117  void endJob() override;
118 
119  // for noise module
120  struct ltrh {
121  bool operator()(const CSCRecHit2D &rh1, const CSCRecHit2D &rh2) const {
122  return ((rh1.localPosition()).x() - (rh2.localPosition()).x()) < 0;
123  }
124  };
125 
126  protected:
127  private:
128  // these are the "modules"
129  // if you would like to add code to CSCValidation, please do so by adding an
130  // extra module in the form of an additional private member function
131  void doOccupancies(edm::Handle<CSCStripDigiCollection> strips,
135  void doStripDigis(edm::Handle<CSCStripDigiCollection> strips);
136  void doWireDigis(edm::Handle<CSCWireDigiCollection> wires);
139  void doPedestalNoise(edm::Handle<CSCStripDigiCollection> strips);
142  void doEfficiencies(edm::Handle<CSCWireDigiCollection> wires,
147  void doGasGain(const CSCWireDigiCollection &, const CSCStripDigiCollection &, const CSCRecHit2DCollection &);
148  void doCalibrations(const edm::EventSetup &eventSetup);
149  void doAFEBTiming(const CSCWireDigiCollection &);
150  void doCompTiming(const CSCComparatorDigiCollection &);
151  void doADCTiming(const CSCRecHit2DCollection &);
156  bool doTrigger(edm::Handle<L1MuGMTReadoutCollection> pCollection);
157  void doStandalone(edm::Handle<reco::TrackCollection> saMuons);
158  void doTimeMonitoring(edm::Handle<CSCRecHit2DCollection> recHits,
166  const edm::Event &event);
168 
169  // some useful functions
173  float fitX(const CLHEP::HepMatrix &sp, const CLHEP::HepMatrix &ep);
174  float getSignal(const CSCStripDigiCollection &stripdigis, CSCDetId idRH, int centerStrip);
175  float getthisSignal(const CSCStripDigiCollection &stripdigis, CSCDetId idRH, int centerStrip);
176  int getWidth(const CSCStripDigiCollection &stripdigis, CSCDetId idRH, int centerStrip);
177  void findNonAssociatedRecHits(edm::ESHandle<CSCGeometry> cscGeom, edm::Handle<CSCStripDigiCollection> strips);
178  int chamberSerial(CSCDetId id);
179  int ringSerial(CSCDetId id);
180 
181  // these functions handle Stoyan's efficiency code
182  void fillEfficiencyHistos(int bin, int flag);
183  void getEfficiency(float bin, float Norm, std::vector<float> &eff);
184  void histoEfficiency(TH1F *readHisto, TH1F *writeHisto);
185  double lineParametrization(double z1Position, double z2Position, double z1Direction) {
186  double parameterLine = (z2Position - z1Position) / z1Direction;
187  return parameterLine;
188  }
189  double extrapolate1D(double initPosition, double initDirection, double parameterOfTheLine) {
190  double extrapolatedPosition = initPosition + initDirection * parameterOfTheLine;
191  return extrapolatedPosition;
192  }
193  bool withinSensitiveRegion(LocalPoint localPos,
194  const std::array<const float, 4> &layerBounds,
195  int station,
196  int ring,
197  float shiftFromEdge,
198  float shiftFromDeadZone);
199 
200  // counters
201  int nEventsAnalyzed;
202  int rhTreeCount;
203  int segTreeCount;
204  bool firstEvent;
205  bool cleanEvent;
206 
207  //
208  //
209  // The root file for the histograms.
210  TFile *theFile;
211 
212  //
213  //
214  // input parameters for this module
215  bool makePlots;
216  bool makeComparisonPlots;
217  std::string refRootFile;
218  bool writeTreeToFile;
219  bool isSimulation;
221  bool detailedAnalysis;
222  bool useDigis;
223  bool makeHLTPlots;
224 
225  // filters
226  bool useQualityFilter;
227  bool useTriggerFilter;
228 
229  // quality filter parameters
230  double pMin;
231  double chisqMax;
232  int nCSCHitsMin, nCSCHitsMax;
233  double lengthMin, lengthMax;
234  double deltaPhiMax;
235  double polarMin, polarMax;
236 
250  // geometry
253  // conditions data
258 
259  // module on/off switches
260  bool makeOccupancyPlots;
261  bool makeTriggerPlots;
262  bool makeStripPlots;
263  bool makeWirePlots;
264  bool makeRecHitPlots;
265  bool makeSimHitPlots;
266  bool makeSegmentPlots;
267  bool makeResolutionPlots;
268  bool makePedNoisePlots;
269  bool makeEfficiencyPlots;
270  bool makeGasGainPlots;
271  bool makeAFEBTimingPlots;
272  bool makeCompTimingPlots;
273  bool makeADCTimingPlots;
274  bool makeRHNoisePlots;
275  bool makeCalibPlots;
276  bool makeStandalonePlots;
277  bool makeTimeMonitorPlots;
278 
279  // The histo managing object
281 
282  // tmp histos for Efficiency
283  TH1F *hSSTE;
284  TH1F *hRHSTE;
285  TH1F *hSEff;
286  TH1F *hRHEff;
287  TH2F *hSSTE2;
288  TH2F *hRHSTE2;
289  TH2F *hStripSTE2;
290  TH2F *hWireSTE2;
291  TH2F *hSEff2;
292  TH2F *hRHEff2;
293  TH2F *hStripEff2;
294  TH2F *hWireEff2;
295  TH2F *hEffDenominator;
296  TH2F *hSensitiveAreaEvt;
297 
298  TH1F *hSSTETight;
299  TH1F *hRHSTETight;
300  TH2F *hSSTE2Tight;
301  TH2F *hRHSTE2Tight;
302  TH2F *hStripSTE2Tight;
303  TH2F *hWireSTE2Tight;
304  TH2F *hEffDenominatorTight;
305 
306  // occupancy
307  TH2I *hOWires;
308  TH2I *hOStrips;
309  TH2I *hORecHits;
310  TH2I *hOSegments;
311 
313  std::vector<int> nmbhvsegm;
314  std::map<int, std::vector<int> > m_wire_hvsegm;
315  std::map<int, int> m_single_wire_layer;
316 
317  //maps to store the DetId and associated RecHits
318  std::multimap<CSCDetId, CSCRecHit2D> AllRechits;
319  std::multimap<CSCDetId, CSCRecHit2D> SegRechits;
320  std::multimap<CSCDetId, CSCRecHit2D> NonAssociatedRechits;
321  std::map<CSCRecHit2D, float, ltrh> distRHmap;
322 
323  int typeIndex(CSCDetId id) {
324  // linearlized index bases on endcap, station, and ring
325  int index = 0;
326  if (id.station() == 1) {
327  index = id.ring() + 1;
328  if (id.ring() == 4)
329  index = 1;
330  } else
331  index = id.station() * 2 + id.ring();
332  if (id.endcap() == 1)
333  index = index + 10;
334  if (id.endcap() == 2)
335  index = 11 - index;
336  return index;
337  }
338  };
339 } // namespace
340 #endif
virtual void analyze(Event const &, EventSetup const &)=0
LocalPoint localPosition() const override
Definition: CSCRecHit2D.h:56
constexpr std::size_t typeIndex
histos
Definition: combine.py:4
strips
#turn off noise in all subdetectors simHcalUnsuppressedDigis.doNoise = False mix.digitizers.hcal.doNoise = False simEcalUnsuppressedDigis.doNoise = False mix.digitizers.ecal.doNoise = False simEcalUnsuppressedDigis.doESNoise = False simSiPixelDigis.AddNoise = False mix.digitizers.pixel.AddNoise = False simSiStripDigis.Noise = False mix.digitizers.strip.AddNoise = False
Definition: DigiDM_cff.py:32
void makePlots(Int_t nFiles, TString *files, TString *names, TString misalignment, Double_t *values, Double_t *phases, TString directory, Bool_t matrix[xsize][ysize])
Definition: event.py:1