00001 #ifndef EcalSelectiveReadoutValidation_H
00002 #define EcalSelectiveReadoutValidation_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "FWCore/Framework/interface/Frameworkfwd.h"
00013 #include "FWCore/Framework/interface/EDAnalyzer.h"
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015
00016 #include "DataFormats/Common/interface/Handle.h"
00017 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00018 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
00019
00020
00021 #include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h"
00022 #include "DataFormats/EcalDetId/interface/EcalScDetId.h"
00023 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
00024
00025 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00026
00027
00028 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00029 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00030 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00031
00032 #include "Validation/EcalDigis/src/CollHandle.h"
00033
00034 #include <string>
00035 #include <set>
00036 #include <utility>
00037 #include "DQMServices/Core/interface/DQMStore.h"
00038 #include "DQMServices/Core/interface/MonitorElement.h"
00039
00040 class DQMStore;
00041 class MonitorElement;
00042 class EBDetId;
00043 class EEDetId;
00044 class EcalTPParameters;
00045 class EcalElectronicsMapping;
00046
00047 class EcalSelectiveReadoutValidation: public edm::EDAnalyzer{
00048
00049 public:
00050
00052 EcalSelectiveReadoutValidation(const edm::ParameterSet& ps);
00053
00055 ~EcalSelectiveReadoutValidation();
00056
00057 protected:
00058
00060 void analyze(const edm::Event& e, const edm::EventSetup& c);
00061
00063 void beginJob(const edm::EventSetup& c);
00064
00066 void endJob(void);
00067
00068 private:
00070 enum subdet_t {EB, EE};
00071
00075 template<class T, class U>
00076 void anaDigi(const T& frame, const U& srFlagColl);
00077
00081 void anaDigiInit();
00082
00087 void analyzeDataVolume(const edm::Event& e, const edm::EventSetup& es);
00088
00093 void analyzeEB(const edm::Event& event, const edm::EventSetup& es);
00094
00099 void analyzeEE(const edm::Event& event, const edm::EventSetup& es);
00100
00105 void analyzeTP(const edm::Event& event, const edm::EventSetup& es);
00106
00110 double frame2Energy(const EcalDataFrame& frame) const;
00111
00118 template<class T>
00119 double frame2EnergyForTp(const T& frame, int offset = 0) const;
00120
00121
00122
00123
00124
00125
00126
00131 double getEbEventSize(double nReadXtals) const;
00132
00137 double getEeEventSize(double nReadXtals) const;
00138
00142 double getDccOverhead(subdet_t subdet) const{
00143
00144 return (subdet==EB?34:52)*8;
00145 }
00146
00151 double getBytesPerCrystal() const{
00152 return 3*8;
00153 }
00154
00160 double getDccEventSize(int iDcc0, double nReadXtals) const{
00161 subdet_t subdet;
00162 if(iDcc0<9 || iDcc0>=45){
00163 subdet = EE;
00164 } else{
00165 subdet = EB;
00166 }
00167 return getDccOverhead(subdet)+nReadXtals*getBytesPerCrystal()
00168 + getRuCount(iDcc0)*8;
00169 }
00170
00175 int getRuCount(int iDcc0) const;
00176
00181 void readAllCollections(const edm::Event& e);
00182
00191 void setTtEtSums(const edm::EventSetup& es,
00192 const EBDigiCollection& ebDigis,
00193 const EEDigiCollection& eeDigis);
00194
00199 unsigned dccNum(const DetId& xtalId) const;
00200
00204 int iEta2cIndex(int iEta) const{
00205 return (iEta<0)?iEta+85:iEta+84;
00206 }
00207
00211 int iPhi2cIndex(int iPhi) const{
00212 return iPhi-1;
00213 }
00214
00218 int iXY2cIndex(int iX) const{
00219 return iX-1;
00220 }
00221
00224 int cIndex2iXY(int iX0) const{
00225 return iX0+1;
00226 }
00227
00230 int cIndex2iEta(int i) const{
00231 return (i<85)?i-85:i-84;
00232 }
00233
00234
00237 int cIndex2iPhi(int i) const {
00238 return i+1;
00239 }
00240
00246 int iTTEta2cIndex(int iEta) const{
00247 return (iEta<0)?iEta+28:iEta+27;
00248 }
00249
00255 int iTTPhi2cIndex(int iPhi) const{
00256 return iPhi-1;
00257 }
00258
00263 EcalScDetId superCrystalOf(const EEDetId& xtalId) const;
00264
00266
00271 EcalTrigTowerDetId readOutUnitOf(const EBDetId& xtalId) const;
00272
00273 EcalScDetId readOutUnitOf(const EEDetId& xtalId) const;
00275
00277
00280 MonitorElement* book1D(const std::string& name,
00281 const std::string& title, int nbins,
00282 double xmin, double xmax);
00283
00284 MonitorElement* book2D(const std::string& name,
00285 const std::string& title,
00286 int nxbins, double xmin, double xmax,
00287 int nybins, double ymin, double ymax);
00288
00289 MonitorElement* bookProfile(const std::string& name,
00290 const std::string& title,
00291 int nbins, double xmin, double xmax);
00292
00293 MonitorElement* bookProfile2D(const std::string& name,
00294 const std::string& title,
00295 int nbinx, double xmin, double xmax,
00296 int nbiny, double ymin, double ymax,
00297 const char* option = "");
00299
00301
00303 void fill(MonitorElement* me, float x){
00304 if(me) me->Fill(x);
00305 }
00306 void fill(MonitorElement* me,float x, float yw){
00307 if(me) me->Fill(x, yw);
00308 }
00309 void fill(MonitorElement* me,float x, float y, float zw){
00310 if(me) me->Fill(x, y, zw);
00311 }
00312 void fill(MonitorElement* me,float x, float y, float z, float w){
00313 if(me) me->Fill(x, y, z, w);
00314 }
00316
00317 private:
00320 struct energiesEb_t{
00321 double simE;
00322 double noZsRecE;
00323 double recE;
00324
00325 int simHit;
00326 double phi;
00327 double eta;
00328 };
00329
00332 struct energiesEe_t{
00333 double simE;
00334 double noZsRecE;
00335 double recE;
00336
00337 int simHit;
00338 double phi;
00339 double eta;
00340 };
00341
00343 static const int kByte_ = 1024;
00344
00346 static const unsigned nDccs = 54;
00347
00349 static const int nEbDccs = 36;
00350
00352 static const int nEeDccs = 18;
00353
00355 static const int nEbRus = 36*68;
00356
00358 static const int nEeRus = 2*(34+32+33+33+32+34+33+34+33);
00359
00361 static const int nEndcaps = 2;
00362
00364 static const int nEbEta = 170;
00365
00367 static const int nEbPhi = 360;
00368
00370 static const int nEeX = 100;
00371
00373 static const int nEeY = 100;
00374
00376 static const int ebTtEdge = 5;
00377
00379 static const int scEdge = 5;
00380
00382 static const int nTtEta = 56;
00383
00385 static const int nTtPhi = 72;
00386
00388 static const double rad2deg;
00389
00391 bool verbose_;
00392
00394 DQMStore* dbe_;
00395
00397 std::string outputFile_;
00398
00400 bool collNotFoundWarn_;
00401
00403
00405 CollHandle<EBDigiCollection> ebDigis_;
00406 CollHandle<EEDigiCollection> eeDigis_;
00407 CollHandle<EBDigiCollection> ebNoZsDigis_;
00408 CollHandle<EEDigiCollection> eeNoZsDigis_;
00409 CollHandle<EBSrFlagCollection> ebSrFlags_;
00410 CollHandle<EESrFlagCollection> eeSrFlags_;
00411 CollHandle<std::vector<PCaloHit> > ebSimHits_;
00412 CollHandle<std::vector<PCaloHit> > eeSimHits_;
00413 CollHandle<EcalTrigPrimDigiCollection> tps_;
00414 CollHandle<EcalRecHitCollection> ebRecHits_;
00415 CollHandle<EcalRecHitCollection> eeRecHits_;
00416 CollHandle<FEDRawDataCollection> fedRaw_;
00418
00420
00422 MonitorElement* meDccVol_;
00423 MonitorElement* meDccVolFromData_;
00424 MonitorElement* meVol_;
00425 MonitorElement* meVolB_;
00426 MonitorElement* meVolE_;
00427 MonitorElement* meVolBLI_;
00428 MonitorElement* meVolELI_;
00429 MonitorElement* meVolLI_;
00430 MonitorElement* meVolBHI_;
00431 MonitorElement* meVolEHI_;
00432 MonitorElement* meVolHI_;
00433 MonitorElement* meChOcc_;
00434
00435 MonitorElement* meTp_;
00436 MonitorElement* meTtf_;
00437 MonitorElement* meTtfVsTp_;
00438 MonitorElement* meTtfVsEtSum_;
00439 MonitorElement* meTpVsEtSum_;
00440
00441 MonitorElement* meEbRecE_;
00442 MonitorElement* meEbEMean_;
00443 MonitorElement* meEbNoise_;
00444 MonitorElement* meEbSimE_;
00445 MonitorElement* meEbRecEHitXtal_;
00446 MonitorElement* meEbRecVsSimE_;
00447 MonitorElement* meEbNoZsRecVsSimE_;
00448
00449 MonitorElement* meEeRecE_;
00450 MonitorElement* meEeEMean_;
00451 MonitorElement* meEeNoise_;
00452 MonitorElement* meEeSimE_;
00453 MonitorElement* meEeRecEHitXtal_;
00454 MonitorElement* meEeRecVsSimE_;
00455 MonitorElement* meEeNoZsRecVsSimE_;
00456
00457 MonitorElement* meFullRoTt_;
00458 MonitorElement* meZs1Tt_;
00459 MonitorElement* meForcedTt_;
00460
00461 MonitorElement* meLiTtf_;
00462 MonitorElement* meHiTtf_;
00463
00464 MonitorElement* meTpMap_;
00465
00467
00470 const EcalTrigTowerConstituentsMap * triggerTowerMap_;
00471
00475 const EcalTPParameters* tpParam_;
00476
00479 const EcalElectronicsMapping* elecMap_;
00480
00484 bool localReco_;
00485
00488 std::vector<double> weights_;
00489
00492 bool tpInGeV_;
00493
00496 int nEb_;
00497
00500 int nEe_;
00501
00504 int nEeLI_;
00505
00508 int nEeHI_;
00509
00512 int nEbLI_;
00513
00516 int nEbHI_;
00517
00520 int nPerDcc_[nDccs];
00521
00524 int nRuPerDcc_[nDccs];
00525
00527
00529 bool ebRuActive_[nEbEta/ebTtEdge][nEbPhi/ebTtEdge];
00530 bool eeRuActive_[nEndcaps][nEeX/scEdge][nEeY/scEdge];
00532
00535 int ievt_;
00536
00541 double ttEtSums[nTtEta][nTtPhi];
00542
00546 energiesEb_t ebEnergies[nEbEta][nEbPhi];
00547
00552 energiesEe_t eeEnergies[nEndcaps][nEeX][nEeY];
00553
00557 std::set<std::string> histList_;
00558
00561 bool allHists_;
00562
00565 std::string histDir_;
00566
00570 std::map<std::string, std::string> availableHistList_;
00571
00576 bool registerHist(const std::string& name, const std::string& title);
00577
00581 void printAvailableHists();
00582
00583 private:
00586 class Sorter{
00587 EcalSelectiveReadoutValidation* validation;
00588 public:
00589 Sorter(EcalSelectiveReadoutValidation* v): validation(v){};
00590 bool operator()(std::pair<int,int>a, std::pair<int,int>b){
00591 return (validation->ebEnergies[a.first][a.second].simE
00592 > validation->ebEnergies[b.first][b.second].simE);
00593 }
00594 };
00595 };
00596
00597 #endif //EcalSelectiveReadoutValidation_H not defined
00598