File indexing completed on 2024-04-06 12:32:04
0001 #ifndef EcalSelectiveReadoutValidation_H
0002 #define EcalSelectiveReadoutValidation_H
0003
0004
0005
0006
0007
0008
0009
0010 #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
0011
0012 #include "DQMServices/Core/interface/DQMStore.h"
0013
0014 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
0015 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
0016
0017 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
0018 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0019 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0020 #include "DataFormats/EcalDetId/interface/EcalScDetId.h"
0021 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
0022 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0023 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0024 #include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h"
0025 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
0026 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
0027
0028 #include "CondFormats/EcalObjects/interface/EcalTPGLutIdMap.h"
0029 #include "CondFormats/EcalObjects/interface/EcalTPGLutGroup.h"
0030 #include "CondFormats/EcalObjects/interface/EcalTPGPhysicsConst.h"
0031 #include "CondFormats/DataRecord/interface/EcalTPGLutIdMapRcd.h"
0032 #include "CondFormats/DataRecord/interface/EcalTPGLutGroupRcd.h"
0033 #include "CondFormats/DataRecord/interface/EcalTPGPhysicsConstRcd.h"
0034
0035 #include "CollHandle.h"
0036
0037 #include <string>
0038 #include <set>
0039 #include <fstream>
0040
0041 class EBDetId;
0042 class EEDetId;
0043 class EcalElectronicsMapping;
0044 class EcalTrigTowerConstituentsMap;
0045
0046 class EcalSelectiveReadoutValidation : public DQMOneEDAnalyzer<> {
0047 typedef EcalRecHitCollection RecHitCollection;
0048 typedef EcalRecHit RecHit;
0049
0050 public:
0051
0052 EcalSelectiveReadoutValidation(const edm::ParameterSet& ps);
0053
0054
0055 ~EcalSelectiveReadoutValidation() override;
0056 void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override;
0057 void bookHistograms(DQMStore::IBooker& i, edm::Run const&, edm::EventSetup const&) override;
0058
0059 protected:
0060
0061 void analyze(edm::Event const& e, edm::EventSetup const& c) override;
0062
0063 void dqmEndRun(const edm::Run& r, const edm::EventSetup& c) override;
0064
0065 private:
0066
0067 enum subdet_t { EB, EE };
0068
0069
0070
0071
0072 template <class T, class U>
0073 void anaDigi(const T& frame, const U& srFlagColl);
0074
0075
0076
0077
0078 void anaDigiInit();
0079
0080
0081
0082
0083
0084 void analyzeDataVolume(const edm::Event& e, const edm::EventSetup& es);
0085
0086
0087
0088
0089
0090 void analyzeEB(const edm::Event& event, const edm::EventSetup& es);
0091
0092
0093
0094
0095
0096 void analyzeEE(const edm::Event& event, const edm::EventSetup& es);
0097
0098
0099
0100
0101
0102 void analyzeTP(const edm::Event& event, const edm::EventSetup& es);
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113 double frame2Energy(const EcalDataFrame& frame) const;
0114
0115
0116
0117
0118
0119
0120
0121 template <class T>
0122 double frame2EnergyForTp(const T& frame, int offset = 0) const;
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134 double getEbEventSize(double nReadXtals) const;
0135
0136
0137
0138
0139
0140 double getEeEventSize(double nReadXtals) const;
0141
0142
0143
0144
0145 double getDccOverhead(subdet_t subdet) const {
0146
0147 return (subdet == EB ? 34 : 52) * 8;
0148 }
0149
0150
0151
0152
0153
0154 double getBytesPerCrystal() const { return 3 * 8; }
0155
0156
0157
0158
0159
0160
0161 double getDccEventSize(int iDcc0, double nReadXtals) const {
0162 subdet_t subdet;
0163 if (iDcc0 < 9 || iDcc0 >= 45) {
0164 subdet = EE;
0165 } else {
0166 subdet = EB;
0167 }
0168
0169
0170 return getDccOverhead(subdet) + getDccSrDependentPayload(iDcc0, getRuCount(iDcc0), nReadXtals);
0171 }
0172
0173
0174
0175
0176
0177
0178
0179
0180 double getDccSrDependentPayload(int iDcc0, double nReadRus, double nReadXtals) const {
0181 return nReadXtals * getBytesPerCrystal() + nReadRus * 8;
0182 }
0183
0184
0185
0186
0187
0188 int getRuCount(int iDcc0) const;
0189
0190
0191
0192
0193
0194 void readAllCollections(const edm::Event& e);
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204 void setTtEtSums(const edm::EventSetup& es, const EBDigiCollection& ebDigis, const EEDigiCollection& eeDigis);
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219 std::pair<int, int> dccCh(const DetId& xtalId) const;
0220
0221
0222
0223
0224 int iEta2cIndex(int iEta) const { return (iEta < 0) ? iEta + 85 : iEta + 84; }
0225
0226
0227
0228
0229 int iPhi2cIndex(int iPhi) const {
0230
0231 int iPhi0 = iPhi - 11;
0232 if (iPhi0 < 0)
0233 iPhi0 += 360;
0234 return iPhi0;
0235 }
0236
0237
0238
0239
0240 int iXY2cIndex(int iX) const { return iX - 1; }
0241
0242
0243
0244 int cIndex2iXY(int iX0) const { return iX0 + 1; }
0245
0246
0247
0248 int cIndex2iEta(int i) const { return (i < 85) ? i - 85 : i - 84; }
0249
0250
0251
0252 int cIndex2iPhi(int i) const { return (i + 11) % 360; }
0253
0254
0255
0256
0257
0258
0259 int iTtEta2cIndex(int iEta) const { return (iEta < 0) ? iEta + 28 : iEta + 27; }
0260
0261
0262
0263
0264
0265
0266 int iTtPhi2cIndex(int iPhi) const {
0267 return iPhi - 1;
0268
0269
0270
0271 }
0272
0273
0274
0275 int cIndex2iTtEta(int i) const { return (i < 27) ? i - 28 : i - 27; }
0276
0277
0278
0279 int cIndex2iTtPhi(int i) const { return i + 1; }
0280
0281
0282
0283
0284
0285
0286
0287 EcalTrigTowerDetId readOutUnitOf(const EBDetId& xtalId) const;
0288
0289 EcalScDetId readOutUnitOf(const EEDetId& xtalId) const;
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302 static int dccZsFIR(const EcalDataFrame& frame,
0303 const std::vector<int>& firWeights,
0304 int firstFIRSample,
0305 bool* saturated = nullptr);
0306
0307
0308
0309
0310
0311 static std::vector<int> getFIRWeights(const std::vector<double>& normalizedWeights);
0312
0313
0314
0315
0316
0317 MonitorElement* bookFloat(DQMStore::IBooker&, const std::string& name);
0318
0319 MonitorElement* book1D(
0320 DQMStore::IBooker&, const std::string& name, const std::string& title, int nbins, double xmin, double xmax);
0321
0322 MonitorElement* book2D(DQMStore::IBooker&,
0323 const std::string& name,
0324 const std::string& title,
0325 int nxbins,
0326 double xmin,
0327 double xmax,
0328 int nybins,
0329 double ymin,
0330 double ymax);
0331
0332 MonitorElement* bookProfile(
0333 DQMStore::IBooker&, const std::string& name, const std::string& title, int nbins, double xmin, double xmax);
0334
0335 MonitorElement* bookProfile2D(DQMStore::IBooker&,
0336 const std::string& name,
0337 const std::string& title,
0338 int nbinx,
0339 double xmin,
0340 double xmax,
0341 int nbiny,
0342 double ymin,
0343 double ymax,
0344 const char* option = "");
0345
0346
0347
0348
0349
0350 void fill(MonitorElement* me, float x) {
0351 if (me)
0352 me->Fill(x);
0353 }
0354 void fill(MonitorElement* me, float x, float yw) {
0355 if (me)
0356 me->Fill(x, yw);
0357 }
0358 void fill(MonitorElement* me, float x, float y, float zw) {
0359 if (me)
0360 me->Fill(x, y, zw);
0361 }
0362 void fill(MonitorElement* me, float x, float y, float z, float w) {
0363 if (me)
0364 me->Fill(x, y, z, w);
0365 }
0366
0367
0368 void initAsciiFile();
0369
0370
0371
0372
0373 void updateL1aRate(const edm::Event& event);
0374
0375
0376
0377
0378
0379 double getL1aRate() const;
0380
0381 private:
0382
0383
0384 struct energiesEb_t {
0385 double simE;
0386 double noZsRecE;
0387 double recE;
0388
0389 int simHit;
0390 double phi;
0391 double eta;
0392 bool gain12;
0393 };
0394
0395
0396
0397 struct energiesEe_t {
0398 double simE;
0399 double noZsRecE;
0400 double recE;
0401
0402 int simHit;
0403 double phi;
0404 double eta;
0405 bool gain12;
0406 };
0407
0408 edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geoToken;
0409 edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> ecalmapping;
0410 edm::ESGetToken<EcalTrigTowerConstituentsMap, IdealGeometryRecord> hTriggerTowerMap;
0411 edm::ESGetToken<EcalTPGPhysicsConst, EcalTPGPhysicsConstRcd> physHandle;
0412 edm::ESGetToken<EcalTPGLutGroup, EcalTPGLutGroupRcd> lutGrpHandle;
0413 edm::ESGetToken<EcalTPGLutIdMap, EcalTPGLutIdMapRcd> lutMapHandle;
0414
0415
0416 static const int kByte_ = 1024;
0417
0418
0419 static const unsigned nDccs_ = 54;
0420
0421
0422
0423 static const unsigned nDccChs_ = 68;
0424
0425
0426 static const int minDccId_ = 1;
0427
0428
0429 static const int maxDccId_ = minDccId_ + nDccs_ - 1;
0430
0431
0432 static const int nEbDccs = 36;
0433
0434
0435 static const int nEeDccs = 18;
0436
0437
0438 static const int nEbRus = 36 * 68;
0439
0440
0441 static const int nEeRus = 2 * (34 + 32 + 33 + 33 + 32 + 34 + 33 + 34 + 33);
0442
0443
0444 static const int nDccRus_[nDccs_];
0445
0446
0447 static const int nEndcaps = 2;
0448
0449
0450 static const int nEbEta = 170;
0451
0452
0453 static const int nEbPhi = 360;
0454
0455
0456 static const int nEeX = 100;
0457
0458
0459 static const int nEeY = 100;
0460
0461
0462 static const int ebTtEdge = 5;
0463
0464
0465 static const int scEdge = 5;
0466
0467
0468 static const int nOneEeTtEta = 11;
0469
0470
0471 static const int nEbTtEta = 34;
0472
0473
0474 static const int nTtEta = 2 * nOneEeTtEta + nEbTtEta;
0475
0476
0477 static const int nTtPhi = 72;
0478
0479
0480 static const int nMaxXtalPerRu = 25;
0481
0482 static const double rad2deg;
0483
0484
0485 bool verbose_;
0486
0487
0488 std::string outputFile_;
0489
0490
0491 bool collNotFoundWarn_;
0492
0493
0494
0495 std::string srpAlgoErrorLogFileName_;
0496
0497
0498
0499 std::string srApplicationErrorLogFileName_;
0500
0501
0502 std::ofstream srpAlgoErrorLog_;
0503
0504
0505 std::ofstream srApplicationErrorLog_;
0506
0507
0508 std::ofstream zsErrorLog_;
0509
0510
0511
0512
0513 CollHandle<EBDigiCollection> ebDigis_;
0514 CollHandle<EEDigiCollection> eeDigis_;
0515 CollHandle<EBDigiCollection> ebNoZsDigis_;
0516 CollHandle<EEDigiCollection> eeNoZsDigis_;
0517 CollHandle<EBSrFlagCollection> ebSrFlags_;
0518 CollHandle<EESrFlagCollection> eeSrFlags_;
0519 CollHandle<EBSrFlagCollection> ebComputedSrFlags_;
0520 CollHandle<EESrFlagCollection> eeComputedSrFlags_;
0521 CollHandle<std::vector<PCaloHit>> ebSimHits_;
0522 CollHandle<std::vector<PCaloHit>> eeSimHits_;
0523 CollHandle<EcalTrigPrimDigiCollection> tps_;
0524 CollHandle<RecHitCollection> ebRecHits_;
0525 CollHandle<RecHitCollection> eeRecHits_;
0526 CollHandle<FEDRawDataCollection> fedRaw_;
0527
0528
0529
0530
0531
0532 int64_t tmax;
0533 int64_t tmin;
0534 int64_t l1aOfTmin;
0535 int64_t l1aOfTmax;
0536 bool l1aRateErr;
0537
0538
0539
0540
0541
0542 MonitorElement* meDccVol_;
0543 MonitorElement* meDccLiVol_;
0544 MonitorElement* meDccHiVol_;
0545 MonitorElement* meDccVolFromData_;
0546 MonitorElement* meVol_;
0547 MonitorElement* meVolB_;
0548 MonitorElement* meVolE_;
0549 MonitorElement* meVolBLI_;
0550 MonitorElement* meVolELI_;
0551 MonitorElement* meVolLI_;
0552 MonitorElement* meVolBHI_;
0553 MonitorElement* meVolEHI_;
0554 MonitorElement* meVolHI_;
0555 MonitorElement* meChOcc_;
0556
0557 MonitorElement* meTp_;
0558 MonitorElement* meTtf_;
0559 MonitorElement* meTtfVsTp_;
0560 MonitorElement* meTtfVsEtSum_;
0561 MonitorElement* meTpVsEtSum_;
0562
0563 MonitorElement* meEbRecE_;
0564 MonitorElement* meEbEMean_;
0565 MonitorElement* meEbNoise_;
0566 MonitorElement* meEbSimE_;
0567 MonitorElement* meEbRecEHitXtal_;
0568 MonitorElement* meEbRecVsSimE_;
0569 MonitorElement* meEbNoZsRecVsSimE_;
0570
0571 MonitorElement* meEeRecE_;
0572 MonitorElement* meEeEMean_;
0573 MonitorElement* meEeNoise_;
0574 MonitorElement* meEeSimE_;
0575 MonitorElement* meEeRecEHitXtal_;
0576 MonitorElement* meEeRecVsSimE_;
0577 MonitorElement* meEeNoZsRecVsSimE_;
0578
0579 MonitorElement* meFullRoRu_;
0580 MonitorElement* meZs1Ru_;
0581 MonitorElement* meForcedRu_;
0582
0583 MonitorElement* meLiTtf_;
0584 MonitorElement* meMiTtf_;
0585 MonitorElement* meHiTtf_;
0586 MonitorElement* meForcedTtf_;
0587
0588 MonitorElement* meTpMap_;
0589
0590 MonitorElement* meFullRoCnt_;
0591 MonitorElement* meEbFullRoCnt_;
0592 MonitorElement* meEeFullRoCnt_;
0593
0594 MonitorElement* meEbLiZsFir_;
0595 MonitorElement* meEbHiZsFir_;
0596 MonitorElement* meEbIncompleteRUZsFir_;
0597
0598 MonitorElement* meEeLiZsFir_;
0599 MonitorElement* meEeHiZsFir_;
0600 MonitorElement* meSRFlagsFromData_;
0601 MonitorElement* meSRFlagsComputed_;
0602 MonitorElement* meSRFlagsConsistency_;
0603
0604 MonitorElement* meIncompleteFRO_;
0605 MonitorElement* meDroppedFRO_;
0606 MonitorElement* meCompleteZS_;
0607
0608 MonitorElement* meIncompleteFROMap_;
0609 MonitorElement* meDroppedFROMap_;
0610 MonitorElement* meCompleteZSMap_;
0611
0612 MonitorElement* meIncompleteFRORateMap_;
0613 MonitorElement* meDroppedFRORateMap_;
0614 MonitorElement* meCompleteZSRateMap_;
0615
0616 MonitorElement* meIncompleteFROCnt_;
0617 MonitorElement* meDroppedFROCnt_;
0618 MonitorElement* meCompleteZSCnt_;
0619 MonitorElement* meEbZsErrCnt_;
0620 MonitorElement* meEeZsErrCnt_;
0621 MonitorElement* meZsErrCnt_;
0622 MonitorElement* meEbZsErrType1Cnt_;
0623 MonitorElement* meEeZsErrType1Cnt_;
0624 MonitorElement* meZsErrType1Cnt_;
0625
0626
0627
0628
0629
0630
0631 MonitorElement* meEbFixedPayload_;
0632 MonitorElement* meEeFixedPayload_;
0633 MonitorElement* meFixedPayload_;
0634
0635
0636
0637
0638 MonitorElement* meL1aRate_;
0639
0640
0641 int nDroppedFRO_;
0642
0643
0644 int nIncompleteFRO_;
0645
0646
0647 int nCompleteZS_;
0648
0649
0650 int nEbFROCnt_;
0651
0652
0653 int nEeFROCnt_;
0654
0655
0656 int nEbZsErrors_;
0657
0658
0659 int nEeZsErrors_;
0660
0661
0662
0663 int nEbZsErrorsType1_;
0664
0665
0666
0667 int nEeZsErrorsType1_;
0668
0669
0670
0671 const EcalTrigTowerConstituentsMap* triggerTowerMap_;
0672
0673
0674
0675 const EcalElectronicsMapping* elecMap_;
0676
0677
0678
0679
0680 bool localReco_;
0681
0682
0683
0684 std::vector<double> weights_;
0685
0686
0687
0688 std::vector<int> firWeights_;
0689
0690
0691
0692 int ebZsThr_;
0693
0694
0695
0696 int eeZsThr_;
0697
0698
0699
0700 bool tpInGeV_;
0701
0702
0703
0704
0705 int firstFIRSample_;
0706
0707
0708
0709
0710 bool useEventRate_;
0711
0712
0713
0714
0715
0716 std::vector<bool> logErrForDccs_;
0717
0718
0719
0720 int nEb_;
0721
0722
0723
0724 int nEe_;
0725
0726
0727
0728 int nEeLI_;
0729
0730
0731
0732 int nEeHI_;
0733
0734
0735
0736 int nEbLI_;
0737
0738
0739
0740 int nEbHI_;
0741
0742
0743
0744 int nPerDcc_[nDccs_];
0745
0746
0747
0748 int nLiPerDcc_[nDccs_];
0749
0750
0751
0752 int nHiPerDcc_[nDccs_];
0753
0754
0755
0756 int nRuPerDcc_[nDccs_];
0757
0758
0759
0760 int nLiRuPerDcc_[nDccs_];
0761
0762
0763
0764 int nHiRuPerDcc_[nDccs_];
0765
0766
0767
0768
0769 bool ebRuActive_[nEbEta / ebTtEdge][nEbPhi / ebTtEdge];
0770 bool eeRuActive_[nEndcaps][nEeX / scEdge][nEeY / scEdge];
0771
0772
0773 bool isRuComplete_[nDccs_][nDccChs_];
0774
0775
0776
0777 int nPerRu_[nDccs_][nDccChs_];
0778
0779
0780
0781 int ievt_;
0782
0783
0784
0785
0786
0787 double ttEtSums[nTtEta][nTtPhi];
0788
0789
0790
0791 bool SkipInnerSC_;
0792
0793
0794
0795
0796 std::set<std::string> histList_;
0797
0798
0799
0800 bool allHists_;
0801
0802
0803
0804 std::string histDir_;
0805
0806
0807
0808
0809 std::map<std::string, std::string> availableHistList_;
0810
0811
0812
0813 bool withEeSimHit_;
0814
0815
0816
0817 bool withEbSimHit_;
0818
0819
0820
0821
0822
0823 bool registerHist(const std::string& name, const std::string& title);
0824
0825
0826
0827
0828 void printAvailableHists();
0829
0830
0831
0832
0833
0834
0835 void configFirWeights(const std::vector<double>& weightsForZsFIR);
0836
0837
0838
0839
0840
0841 bool logSrpAlgoErrors_;
0842
0843
0844
0845
0846 bool logSrApplicationErrors_;
0847
0848
0849
0850
0851
0852
0853
0854
0855
0856 template <class T>
0857 void compareSrfColl(const edm::Event& event, T& srfFromData, T& computedSrf);
0858
0859
0860
0861
0862
0863 template <class T>
0864 void checkSrApplication(const edm::Event& event, T& srfs);
0865
0866
0867
0868
0869
0870 int ruGraphX(const EcalScDetId& id) const { return id.ix() + (id.zside() > 0 ? 20 : -40); }
0871
0872 int ruGraphY(const EcalScDetId& id) const { return id.iy(); }
0873
0874 int ruGraphX(const EcalTrigTowerDetId& id) const { return id.ieta(); }
0875
0876 int ruGraphY(const EcalTrigTowerDetId& id) const { return id.iphi(); }
0877
0878 int xtalGraphX(const EEDetId& id) const { return id.ix() + (id.zside() > 0 ? 100 : -200); }
0879
0880 int xtalGraphY(const EEDetId& id) const { return id.iy(); }
0881
0882 int xtalGraphX(const EBDetId& id) const { return id.ieta(); }
0883
0884 int xtalGraphY(const EBDetId& id) const { return id.iphi(); }
0885
0886
0887
0888
0889
0890
0891
0892 int dccId(const EcalScDetId& detId) const;
0893 int dccId(const EcalTrigTowerDetId& detId) const;
0894
0895
0896
0897
0898
0899
0900
0901 void selectFedsForLog();
0902
0903
0904
0905
0906
0907
0908 int getCrystalCount(int iDcc, int iDccCh);
0909 };
0910
0911 #endif