Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:16

0001 #ifndef DIGIECAL_ECALDIGICOLLECTION_H
0002 #define DIGIECAL_ECALDIGICOLLECTION_H
0003 
0004 #include "DataFormats/EcalDigi/interface/EBDataFrame.h"
0005 #include "DataFormats/EcalDigi/interface/EcalDataFrame_Ph2.h"
0006 #include "DataFormats/EcalDigi/interface/EEDataFrame.h"
0007 #include "DataFormats/EcalDigi/interface/ESDataFrame.h"
0008 #include "DataFormats/EcalDigi/interface/EcalTimeDigi.h"
0009 #include "DataFormats/EcalDigi/interface/EcalTriggerPrimitiveDigi.h"
0010 #include "DataFormats/EcalDigi/interface/EcalEBTriggerPrimitiveDigi.h"
0011 #include "DataFormats/EcalDigi/interface/EcalTrigPrimCompactColl.h"
0012 #include "DataFormats/EcalDigi/interface/EcalPseudoStripInputDigi.h"
0013 #include "DataFormats/EcalDigi/interface/EBSrFlag.h"
0014 #include "DataFormats/EcalDigi/interface/EESrFlag.h"
0015 #include "DataFormats/EcalDigi/interface/EcalPnDiodeDigi.h"
0016 #include "DataFormats/EcalDigi/interface/EcalMatacqDigi.h"
0017 #include "DataFormats/Common/interface/SortedCollection.h"
0018 
0019 #include "DataFormats/DetId/interface/DetId.h"
0020 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
0021 #include "DataFormats/Common/interface/DataFrameContainer.h"
0022 #include "DataFormats/EcalDigi/interface/EcalConstants.h"
0023 
0024 class EcalDigiCollectionPh2 : public edm::DataFrameContainer {
0025 public:
0026   typedef edm::DataFrameContainer::size_type size_type;
0027   static const size_type MAXSAMPLES = ecalPh2::sampleSize;
0028   explicit EcalDigiCollectionPh2(size_type istride = MAXSAMPLES, int isubdet = 0)
0029       : edm::DataFrameContainer(istride, isubdet) {}
0030   void swap(DataFrameContainer& other) { this->DataFrameContainer::swap(other); }
0031 };
0032 
0033 class EBDigiCollectionPh2 : public EcalDigiCollectionPh2 {
0034 public:
0035   typedef edm::DataFrameContainer::size_type size_type;
0036   typedef EcalDataFrame_Ph2 Digi;
0037   typedef Digi::key_type DetId;
0038 
0039   EBDigiCollectionPh2(size_type istride = MAXSAMPLES) : EcalDigiCollectionPh2(istride, EcalBarrel) {}
0040   void swap(EBDigiCollectionPh2& other) { this->EcalDigiCollectionPh2::swap(other); }
0041   void push_back(const Digi& digi) { DataFrameContainer::push_back(digi.id(), digi.frame().begin()); }
0042   void push_back(id_type iid) { DataFrameContainer::push_back(iid); }
0043   void push_back(id_type iid, data_type const* idata) { DataFrameContainer::push_back(iid, idata); }
0044 };
0045 
0046 class EcalDigiCollection : public edm::DataFrameContainer {
0047 public:
0048   typedef edm::DataFrameContainer::size_type size_type;
0049   static const size_type MAXSAMPLES = 10;
0050   explicit EcalDigiCollection(size_type istride = MAXSAMPLES, int isubdet = 0)
0051       : edm::DataFrameContainer(istride, isubdet) {}
0052   void swap(DataFrameContainer& other) { this->DataFrameContainer::swap(other); }
0053 };
0054 
0055 // make edm (and ecal client) happy
0056 class EBDigiCollection : public EcalDigiCollection {
0057 public:
0058   typedef edm::DataFrameContainer::size_type size_type;
0059   typedef EBDataFrame Digi;
0060   typedef Digi::key_type DetId;
0061 
0062   EBDigiCollection(size_type istride = MAXSAMPLES) : EcalDigiCollection(istride, EcalBarrel) {}
0063   void swap(EBDigiCollection& other) { this->EcalDigiCollection::swap(other); }
0064   void push_back(const Digi& digi) { DataFrameContainer::push_back(digi.id(), digi.frame().begin()); }
0065   void push_back(id_type iid) { DataFrameContainer::push_back(iid); }
0066   void push_back(id_type iid, data_type const* idata) { DataFrameContainer::push_back(iid, idata); }
0067 };
0068 
0069 class EEDigiCollection : public EcalDigiCollection {
0070 public:
0071   typedef edm::DataFrameContainer::size_type size_type;
0072   typedef EEDataFrame Digi;
0073   typedef Digi::key_type DetId;
0074 
0075   EEDigiCollection(size_type istride = MAXSAMPLES) : EcalDigiCollection(istride, EcalEndcap) {}
0076   void swap(EEDigiCollection& other) { this->EcalDigiCollection::swap(other); }
0077   void push_back(const Digi& digi) { edm::DataFrameContainer::push_back(digi.id(), digi.frame().begin()); }
0078   void push_back(id_type iid) { DataFrameContainer::push_back(iid); }
0079   void push_back(id_type iid, data_type const* idata) { DataFrameContainer::push_back(iid, idata); }
0080 };
0081 
0082 class ESDigiCollection : public EcalDigiCollection {
0083 public:
0084   typedef edm::DataFrameContainer::size_type size_type;
0085   typedef ESDataFrame Digi;
0086   typedef Digi::key_type DetId;
0087 
0088   static const size_type NSAMPLE = ESDataFrame::MAXSAMPLES;
0089   ESDigiCollection(size_type istride = NSAMPLE) : EcalDigiCollection(istride, EcalPreshower) {}
0090   void swap(ESDigiCollection& other) { this->EcalDigiCollection::swap(other); }
0091 
0092   void push_back(unsigned int i) { DataFrameContainer::push_back(i); }
0093 
0094   void push_back(const Digi& digi) {
0095     uint16_t esdata[NSAMPLE];
0096     for (unsigned int i(0); i != NSAMPLE; ++i) {
0097       static const int offset(65536);  // for int16 to uint16
0098       const int16_t dshort(digi[i].raw());
0099       const int dint((int)dshort +  // add offset for uint16 conversion
0100                      ((int16_t)0 > dshort ? offset : (int)0));
0101       esdata[i] = dint;
0102     }
0103     EcalDigiCollection::push_back(digi.id()(), esdata);
0104   }
0105 };
0106 
0107 // Free swap functions
0108 inline void swap(EcalDigiCollection& lhs, EcalDigiCollection& rhs) { lhs.swap(rhs); }
0109 
0110 inline void swap(EBDigiCollection& lhs, EBDigiCollection& rhs) { lhs.swap(rhs); }
0111 
0112 inline void swap(EEDigiCollection& lhs, EEDigiCollection& rhs) { lhs.swap(rhs); }
0113 
0114 inline void swap(ESDigiCollection& lhs, ESDigiCollection& rhs) { lhs.swap(rhs); }
0115 
0116 inline void swap(EcalDigiCollectionPh2& lhs, EcalDigiCollectionPh2& rhs) { lhs.swap(rhs); }
0117 
0118 inline void swap(EBDigiCollectionPh2& lhs, EBDigiCollectionPh2& rhs) { lhs.swap(rhs); }
0119 
0120 typedef edm::SortedCollection<EcalTimeDigi> EcalTimeDigiCollection;
0121 typedef edm::SortedCollection<EcalTriggerPrimitiveDigi> EcalTrigPrimDigiCollection;
0122 typedef edm::SortedCollection<EcalEBTriggerPrimitiveDigi> EcalEBTrigPrimDigiCollection;
0123 
0124 typedef edm::SortedCollection<EcalPseudoStripInputDigi> EcalPSInputDigiCollection;
0125 typedef edm::SortedCollection<EBSrFlag> EBSrFlagCollection;
0126 typedef edm::SortedCollection<EESrFlag> EESrFlagCollection;
0127 typedef edm::SortedCollection<EcalPnDiodeDigi> EcalPnDiodeDigiCollection;
0128 typedef edm::SortedCollection<EcalMatacqDigi> EcalMatacqDigiCollection;
0129 
0130 #endif