Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:04

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