Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef PCROSSING_FRAME_H
0002 #define PCROSSING_FRAME_H
0003 
0004 /** \class PCrossingFrame
0005  *
0006  * PCrossingFrame allow the write the transient CrossingFrame
0007  *
0008  * \author EmiliaBecheva, Claude Charlot,  LLR Palaiseau
0009  *
0010  * \version   1st Version April 2009
0011  *
0012  ************************************************************/
0013 
0014 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
0015 
0016 template <class T>
0017 class PCrossingFrame {
0018 public:
0019   PCrossingFrame() {}
0020   PCrossingFrame(const CrossingFrame<T>& cf);
0021 
0022   ~PCrossingFrame() { ; }
0023 
0024   void setAllExceptSignalFrom(const PCrossingFrame<T>& cf);
0025 
0026   // getters for data members of PCrossingFrame
0027   edm::EventID getEventID() const { return Pid_; }
0028   const std::vector<T>& getSignals() const { return PCFsignals_; }
0029   const std::vector<T>& getPileupRefs() const { return PCFpileups_; }
0030   std::vector<const T*> getPileups() const {
0031     std::vector<const T*> ret;
0032     ret.reserve(PCFpileups_.size());
0033     for (const auto& p : PCFpileups_)
0034       ret.emplace_back(&p);
0035     return ret;
0036   }
0037   int getBunchSpace() const { return PbunchSpace_; }
0038   unsigned int getMaxNbSources() const { return PmaxNbSources_; }
0039   std::string getSubDet() const { return PCFsubdet_; }
0040   unsigned int getPileupFileNr() const { return PCFpileupFileNr_; }
0041   edm::EventID getIdFirstPileup() const { return PCFidFirstPileup_; }
0042   const std::vector<unsigned int>& getPileupOffsetsBcr() const { return PCFpileupOffsetsBcr_; }
0043   const std::vector<std::vector<unsigned int> >& getPileupOffsetsSource() const {
0044     return PCFpileupOffsetsSource_;
0045   }  //one per source
0046   std::pair<int, int> getBunchRange() const { return std::pair<int, int>(firstPCrossing_, lastPCrossing_); }
0047 
0048 private:
0049   unsigned int PmaxNbSources_;
0050   int PbunchSpace_;
0051   edm::EventID Pid_;
0052   int firstPCrossing_;
0053   int lastPCrossing_;
0054   std::vector<T> PCFpileups_;
0055   std::vector<T> PCFsignals_;
0056   std::string PCFsubdet_;
0057   unsigned int PCFpileupFileNr_;
0058   edm::EventID PCFidFirstPileup_;
0059   std::vector<unsigned int> PCFpileupOffsetsBcr_;
0060   std::vector<std::vector<unsigned int> > PCFpileupOffsetsSource_;
0061 };
0062 
0063 template <class T>
0064 PCrossingFrame<T>::PCrossingFrame(const CrossingFrame<T>& cf) {
0065   //get data members from CrossingFrame
0066   PmaxNbSources_ = cf.getMaxNbSources();
0067   PbunchSpace_ = cf.getBunchSpace();
0068   Pid_ = cf.getEventID();
0069   firstPCrossing_ = cf.getBunchRange().first;
0070   lastPCrossing_ = cf.getBunchRange().second;
0071 
0072   const auto& pileups = cf.getPileups();
0073   PCFpileups_.reserve(pileups.size());
0074   for (const auto& ptr : pileups) {
0075     PCFpileups_.emplace_back(*ptr);
0076   }
0077   const auto& signal = cf.getSignal();
0078   PCFsignals_.reserve(signal.size());
0079   for (const auto& ptr : signal) {
0080     PCFsignals_.emplace_back(*ptr);
0081   }
0082 
0083   PCFsubdet_ = cf.getSubDet();
0084   PCFpileupFileNr_ = cf.getPileupFileNr();
0085   PCFidFirstPileup_ = cf.getIdFirstPileup();
0086   PCFpileupOffsetsBcr_ = cf.getPileupOffsetsBcr();
0087   PCFpileupOffsetsSource_ = cf.getPileupOffsetsSource();
0088 }
0089 
0090 template <typename T>
0091 void PCrossingFrame<T>::setAllExceptSignalFrom(const PCrossingFrame<T>& cf) {
0092   // TODO: reduce copy-paste
0093   PmaxNbSources_ = cf.getMaxNbSources();
0094   PbunchSpace_ = cf.getBunchSpace();
0095   firstPCrossing_ = cf.getBunchRange().first;
0096   lastPCrossing_ = cf.getBunchRange().second;
0097 
0098   PCFpileups_ = cf.getPileupRefs();
0099 
0100   PCFsubdet_ = cf.getSubDet();
0101   PCFpileupFileNr_ = cf.getPileupFileNr();
0102   PCFidFirstPileup_ = cf.getIdFirstPileup();
0103   PCFpileupOffsetsBcr_ = cf.getPileupOffsetsBcr();
0104   PCFpileupOffsetsSource_ = cf.getPileupOffsetsSource();
0105 }
0106 
0107 #endif