class EcalDigiCollection : public edm::DataFrameContainer {      <= EcalDigiCollection class declaration, from parent class DataFrameContainer
public:
  typedef edm::DataFrameContainer::size_type size_type;            <= defining a a variable, 'size_type' to be of type 'edm::DataFrameContainer::size_type'
  static const size_type MAXSAMPLES = 10;                               <= declaring MAXSAMPLES as type 'size_type' and initialised to 10
  explicit EcalDigiCollection(size_type istride=MAXSAMPLES, int isubdet=0)  : 
    edm::DataFrameContainer(istride, isubdet){}
  void swap(DataFrameContainer& other) {this->DataFrameContainer::swap(other);}       <= function declaration 'swap'
};

// make edm (and ecal client) happy
class EBDigiCollection : public  EcalDigiCollection {                    <= EBDigiCollection class declaration, from parent class EcalDigiCollection !!!!
public:
  typedef edm::DataFrameContainer::size_type size_type;
  typedef EBDataFrame Digi;
  typedef Digi::key_type DetId;
  EBDigiCollection(size_type istride=MAXSAMPLES) : 
    EcalDigiCollection(istride, EcalBarrel){}
  void swap(EBDigiCollection& other) {this->EcalDigiCollection::swap(other);}
};
class EEDigiCollection : public  EcalDigiCollection {      <=   EEDigiCollection class declaration, from parent class EcalDigiCollection !!!!
public:  
  typedef edm::DataFrameContainer::size_type size_type;
  typedef EEDataFrame Digi;
  typedef Digi::key_type DetId;

  EEDigiCollection(size_type istride=MAXSAMPLES) : 
    EcalDigiCollection(istride, EcalEndcap){}
  void swap(EEDigiCollection& other) {this->EcalDigiCollection::swap(other);}
};

// Free swap functions
inline
void swap(EcalDigiCollection& lhs, EcalDigiCollection& rhs) {
  lhs.swap(rhs);
}

inline
void swap(EBDigiCollection& lhs, EBDigiCollection& rhs) {
  lhs.swap(rhs);
}

inline
void swap(EEDigiCollection& lhs, EEDigiCollection& rhs) {
  lhs.swap(rhs);
}

//typedef  EcalDigiCollection EBDigiCollection;
//typedef  EcalDigiCollection EEDigiCollection;

typedef edm::SortedCollection<ESDataFrame> ESDigiCollection;
typedef edm::SortedCollection<EcalTriggerPrimitiveDigi> EcalTrigPrimDigiCollection;
typedef edm::SortedCollection<EcalPseudoStripInputDigi> EcalPSInputDigiCollection;
typedef edm::SortedCollection<EBSrFlag> EBSrFlagCollection;
typedef edm::SortedCollection<EESrFlag> EESrFlagCollection;
typedef edm::SortedCollection<EcalPnDiodeDigi> EcalPnDiodeDigiCollection;
typedef edm::SortedCollection<EcalMatacqDigi> EcalMatacqDigiCollection;

#endif

The EcalContainer template !!!!!!!!!!*************!!!!!!!!!!!!!!!!!!!! /CMSSW/DataFormats/EcalDetId/interface/EcalContainer.h

#ifndef ECALDETID_ECALCONTAINER_H
#define ECALDETID_ECALCONTAINER_H
#include "DataFormats/DetId/interface/DetId.h"
#include <vector>
#include <utility>
#include <algorithm>
#include <iostream>
/* a generic container for ecal items
 * provides access by hashedIndex and by DetId...
 */
template<typename DetId, typename T>                <= TEMPLATE DEFINITION !!!!!!!!!!!!!!!!!!!!!! FOR class EcalContainer
class EcalContainer {
        public:
                typedef EcalContainer<DetId, T> self;
                typedef T Item;
                typedef Item value_type;
                typedef typename std::vector<Item> Items; 
                typedef typename std::vector<Item>::const_iterator const_iterator;
                typedef typename std::vector<Item>::iterator iterator;
                void insert(std::pair<uint32_t, Item> const &a) {
                        (*this)[a.first] = a.second;
                }
                inline const Item & item(size_t hashid) const {
                        return m_items[hashid];
                }
                inline const Items & items() const {
                        return m_items;
                }
                inline Item & operator[](uint32_t rawId) {
        checkAndResize();
        static Item dummy;
        DetId id(rawId);
        if ( !isValidId(id) ) return dummy;
        return m_items[id.hashedIndex()];
                }
      void checkAndResize() {
        if (m_items.size()==0) {
          //          std::cout << "resizing to " << DetId::kSizeForDenseIndexing << std::endl;
          m_items.resize(DetId::kSizeForDenseIndexing);
        }
      }
      void checkAndResize( size_t priv_size ) {
        // this method allows to resize the vector to a specific size forcing a specific value
        if (m_items.size()==0) {
          //          std::cout << "resizing to " << priv_size << std::endl;
          m_items.resize(priv_size);
        }
      }
                inline Item const & operator[](uint32_t rawId) const {
        //                        if (m_items.size()==0) {
        //     std::cout << "resizing to " << DetId::kSizeForDenseIndexing << std::endl;
                  //              m_items.resize((size_t) DetId::kSizeForDenseIndexing);
                  //      }
                        static Item dummy;
                        DetId id(rawId);
                        if ( !isValidId(id) ) return dummy;
                        return m_items[id.hashedIndex()];
                }
                inline const_iterator find(uint32_t rawId) const {
                        DetId ib(rawId);
                        if ( !isValidId(ib) ) return m_items.end();
                        return m_items.begin() + ib.hashedIndex();
                }
                inline const_iterator begin() const {         <= ITERATOR BEGIN STATEMENT
                        return m_items.begin();
                }
                inline const_iterator end() const {
                        return m_items.end();
                }
                inline size_t size() const {
                        return m_items.size();
                }
        private:
                // not protected on EB <--> EE swap -- FIXME?
                inline bool isValidId(const DetId id) const {
                        return id.det() == ::DetId::Ecal;
                };
                std::vector<Item> m_items;
};
#endif // ECALCONTAINER

-- DavidCockerill - 23-Aug-2010

Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2010-08-23 - DavidCockerill
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback