Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef PRESCALESVETOSHELPERS_H__
0002 #define PRESCALESVETOSHELPERS_H__
0003 
0004 #include <cassert>
0005 #include "CondFormats/L1TObjects/interface/L1TGlobalPrescalesVetos.h"
0006 
0007 // If you want to create a new object that you can read and write, use this constructor:
0008 //
0009 //   l1t::PrescalesVetosHelper x(new L1TPrescalesVetors());
0010 //
0011 // If you wish to read the table from the EventSetup, and will only read, use this:
0012 //
0013 //   const PrescalesVetosHelper * x = PrescalesVetosHelper::readFromEventSetup(...)
0014 //   //...
0015 //   delete x;
0016 //
0017 // If you wish to read the table from the EventSetup, but then be able to edit the values locally, use this:
0018 //
0019 //   PrescalesVetorsHelper * x = PrescalesVetosHelper::readAndWriteFromEventSetup(...)
0020 //   //...
0021 ///  delete x;
0022 //
0023 // but there's a performance penalty as a copy is made.
0024 
0025 //
0026 // This class does not take over responsibility for deleting the pointers it is
0027 // initialized with.  That is responsibility of the calling code.
0028 //
0029 
0030 namespace l1t {
0031 
0032   class PrescalesVetosHelper {
0033   public:
0034     enum { VERSION_ = 1 };
0035 
0036     ~PrescalesVetosHelper();
0037 
0038     //ctor if creating a new table (e.g. from XML or python file)
0039     PrescalesVetosHelper(L1TGlobalPrescalesVetos* w);
0040     //create for reading only, from the EventSetup:
0041     static const PrescalesVetosHelper* readFromEventSetup(const L1TGlobalPrescalesVetos* es);
0042     // create for reading and writing, starting from the EventSetup:
0043     static PrescalesVetosHelper* readAndWriteFromEventSetup(const L1TGlobalPrescalesVetos* es);
0044 
0045     int bxMaskDefault() const { return read_->bxmask_default_; };
0046     void setBxMaskDefault(int value) {
0047       check_write();
0048       write_->bxmask_default_ = value;
0049     };
0050 
0051     inline const std::vector<std::vector<int> >& prescaleTable() const { return read_->prescale_table_; };
0052     void setPrescaleFactorTable(std::vector<std::vector<int> > value) {
0053       check_write();
0054       write_->prescale_table_ = value;
0055     };
0056     inline const std::vector<int>& triggerMaskVeto() const { return read_->veto_; };
0057     void setTriggerMaskVeto(std::vector<int> value) {
0058       check_write();
0059       write_->veto_ = value;
0060     };
0061 
0062     inline const std::map<int, std::vector<int> >& triggerAlgoBxMask() const { return read_->bxmask_map_; };
0063     void setTriggerAlgoBxMask(std::map<int, std::vector<int> > value) {
0064       check_write();
0065       write_->bxmask_map_ = value;
0066     };
0067 
0068     // access to underlying pointers, mainly for ESProducer:
0069     const L1TGlobalPrescalesVetos* getReadInstance() const { return read_; }
0070     L1TGlobalPrescalesVetos* getWriteInstance() { return write_; }
0071 
0072   private:
0073     PrescalesVetosHelper(const L1TGlobalPrescalesVetos* es);
0074     void useCopy();
0075     void check_write() { assert(write_); }
0076     // separating read from write allows for a high-performance read-only mode (as no copy is made):
0077     const L1TGlobalPrescalesVetos* read_;  // when reading/getting, use this.
0078     L1TGlobalPrescalesVetos* write_;       // when writing/setting, use this.
0079     bool we_own_write_;
0080   };
0081 
0082 }  // namespace l1t
0083 #endif