CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/DataFormats/EcalDigi/interface/EcalDigiCollections.h

Go to the documentation of this file.
00001 #ifndef DIGIECAL_ECALDIGICOLLECTION_H
00002 #define DIGIECAL_ECALDIGICOLLECTION_H
00003 
00004 #include "DataFormats/EcalDigi/interface/EBDataFrame.h"
00005 #include "DataFormats/EcalDigi/interface/EEDataFrame.h"
00006 #include "DataFormats/EcalDigi/interface/ESDataFrame.h"
00007 #include "DataFormats/EcalDigi/interface/EcalTriggerPrimitiveDigi.h"
00008 #include "DataFormats/EcalDigi/interface/EcalTrigPrimCompactColl.h"
00009 #include "DataFormats/EcalDigi/interface/EcalPseudoStripInputDigi.h"
00010 #include "DataFormats/EcalDigi/interface/EBSrFlag.h"
00011 #include "DataFormats/EcalDigi/interface/EESrFlag.h"
00012 #include "DataFormats/EcalDigi/interface/EcalPnDiodeDigi.h"
00013 #include "DataFormats/EcalDigi/interface/EcalMatacqDigi.h"
00014 #include "DataFormats/Common/interface/SortedCollection.h"
00015 
00016 #include "DataFormats/DetId/interface/DetId.h"
00017 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00018 #include "DataFormats/Common/interface/DataFrameContainer.h"
00019 
00020 class EcalDigiCollection : public edm::DataFrameContainer {
00021 public:
00022   typedef edm::DataFrameContainer::size_type size_type;
00023   static const size_type MAXSAMPLES = 10;
00024   explicit EcalDigiCollection(size_type istride=MAXSAMPLES, int isubdet=0)  : 
00025     edm::DataFrameContainer(istride, isubdet){}
00026   void swap(DataFrameContainer& other) {this->DataFrameContainer::swap(other);}
00027 };
00028 
00029 // make edm (and ecal client) happy
00030 class EBDigiCollection : public  EcalDigiCollection {
00031 public:
00032   typedef edm::DataFrameContainer::size_type size_type;
00033   typedef EBDataFrame Digi;
00034   typedef Digi::key_type DetId;
00035 
00036   EBDigiCollection(size_type istride=MAXSAMPLES) : 
00037     EcalDigiCollection(istride, EcalBarrel){}
00038   void swap(EBDigiCollection& other) {this->EcalDigiCollection::swap(other);}
00039 };
00040 
00041 class EEDigiCollection : public  EcalDigiCollection {
00042 public:  
00043   typedef edm::DataFrameContainer::size_type size_type;
00044   typedef EEDataFrame Digi;
00045   typedef Digi::key_type DetId;
00046 
00047   EEDigiCollection(size_type istride=MAXSAMPLES) : 
00048     EcalDigiCollection(istride, EcalEndcap){}
00049   void swap(EEDigiCollection& other) {this->EcalDigiCollection::swap(other);}
00050 };
00051 
00052 class ESDigiCollection : public EcalDigiCollection 
00053 {
00054    public:  
00055       typedef edm::DataFrameContainer::size_type size_type;
00056       typedef ESDataFrame Digi;
00057       typedef Digi::key_type DetId;
00058 
00059       static const size_type NSAMPLE = ESDataFrame::MAXSAMPLES ;
00060       ESDigiCollection(size_type istride=NSAMPLE) : 
00061          EcalDigiCollection(istride, EcalPreshower){}
00062       void swap(ESDigiCollection& other) {this->EcalDigiCollection::swap(other);}
00063 
00064       void push_back( unsigned int i ) 
00065       {
00066          DataFrameContainer::push_back( i ) ;
00067       }
00068 
00069       void push_back( const Digi& digi ) 
00070       {
00071          uint16_t esdata[NSAMPLE] ;
00072          for( unsigned int i ( 0 ) ; i != NSAMPLE; ++i )
00073          {
00074             static const int offset ( 65536 ) ; // for int16 to uint16
00075             const int16_t dshort ( digi[i].raw() ) ;
00076             const int     dint   ( (int) dshort + // add offset for uint16 conversion
00077                                    ( (int16_t) 0 > dshort ? 
00078                                      offset : (int) 0 ) ) ;
00079             esdata[i] = dint ;
00080          }
00081          EcalDigiCollection::push_back( digi.id()(), esdata ) ;
00082       }
00083 };
00084 
00085 
00086 // Free swap functions
00087 inline
00088 void swap(EcalDigiCollection& lhs, EcalDigiCollection& rhs) {
00089   lhs.swap(rhs);
00090 }
00091 
00092 inline
00093 void swap(EBDigiCollection& lhs, EBDigiCollection& rhs) {
00094   lhs.swap(rhs);
00095 }
00096 
00097 inline
00098 void swap(EEDigiCollection& lhs, EEDigiCollection& rhs) {
00099   lhs.swap(rhs);
00100 }
00101 
00102 inline
00103 void swap(ESDigiCollection& lhs, ESDigiCollection& rhs) {
00104   lhs.swap(rhs);
00105 }
00106 
00107 typedef edm::SortedCollection<EcalTriggerPrimitiveDigi> EcalTrigPrimDigiCollection;
00108 
00109 typedef edm::SortedCollection<EcalPseudoStripInputDigi> EcalPSInputDigiCollection;
00110 typedef edm::SortedCollection<EBSrFlag> EBSrFlagCollection;
00111 typedef edm::SortedCollection<EESrFlag> EESrFlagCollection;
00112 typedef edm::SortedCollection<EcalPnDiodeDigi> EcalPnDiodeDigiCollection;
00113 typedef edm::SortedCollection<EcalMatacqDigi> EcalMatacqDigiCollection;
00114 
00115 #endif