Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef l1t_EndCapParamsHelper_h_
0002 #define l1t_EndCapParamsHelper_h_
0003 
0004 #include <cassert>
0005 #include <vector>
0006 #include <map>
0007 
0008 #include "CondFormats/L1TObjects/interface/L1TMuonEndCapParams.h"
0009 #include "CondFormats/DataRecord/interface/L1TMuonEndCapParamsRcd.h"
0010 
0011 // If you want to create a new object that you can read and write, use this constructor:
0012 //
0013 //   l1t::EndCapParamsHelper x(new L1TPrescalesVetors());
0014 //
0015 // If you wish to read the table from the EventSetup, and will only read, use this:
0016 //
0017 //   const EndCapParamsHelper * x = EndCapParamsHelper::readFromEventSetup(...)
0018 //   //...
0019 //   delete x;
0020 //
0021 // If you wish to read the table from the EventSetup, but then be able to edit the values locally, use this:
0022 //
0023 //   EndCapParamsHelper * x = EndCapParamsHelper::readAndWriteFromEventSetup(...)
0024 //   //...
0025 ///  delete x;
0026 //
0027 // but there's a performance penalty as a copy is made.
0028 
0029 //
0030 // This class does not take over responsibility for deleting the pointers it is
0031 // initialized with.  That is responsibility of the calling code.
0032 //
0033 
0034 namespace l1t {
0035 
0036   class EndCapParamsHelper {
0037   public:
0038     enum { VERSION = 1 };
0039 
0040     ~EndCapParamsHelper();
0041 
0042     //ctor if creating a new table (e.g. from XML or python file)
0043     EndCapParamsHelper(L1TMuonEndCapParams* w);
0044     //create for reading only, from the EventSetup:
0045     static const EndCapParamsHelper* readFromEventSetup(const L1TMuonEndCapParams* es);
0046     // create for reading and writing, starting from the EventSetup:
0047     static EndCapParamsHelper* readAndWriteFromEventSetup(const L1TMuonEndCapParams* es);
0048 
0049     void SetPtAssignVersion(unsigned version) { write_->PtAssignVersion_ = version; }
0050     void SetFirmwareVersion(unsigned version) { write_->firmwareVersion_ = version; }
0051     // "PhiMatchWindowSt1" arbitrarily re-mapped to Primitive conversion (PC LUT) version
0052     // because of rigid CondFormats naming conventions - AWB 02.06.17
0053     void SetPrimConvVersion(unsigned version) { write_->PhiMatchWindowSt1_ = version; }
0054 
0055     unsigned GetPtAssignVersion() const { return read_->PtAssignVersion_; }
0056     unsigned GetFirmwareVersion() const { return read_->firmwareVersion_; }
0057     unsigned GetPrimConvVersion() const { return read_->PhiMatchWindowSt1_; }
0058 
0059     // print all the parameters
0060     void print(std::ostream&) const;
0061 
0062     // access to underlying pointers, mainly for ESProducer:
0063     const L1TMuonEndCapParams* getReadInstance() const { return read_; }
0064     L1TMuonEndCapParams* getWriteInstance() { return write_; }
0065 
0066   private:
0067     EndCapParamsHelper(const L1TMuonEndCapParams* es);
0068     void useCopy();
0069     void check_write() { assert(write_); }
0070     // separating read from write allows for a high-performance read-only mode (as no copy is made):
0071     const L1TMuonEndCapParams* read_;  // when reading/getting, use this.
0072     L1TMuonEndCapParams* write_;       // when writing/setting, use this.
0073     bool we_own_write_;
0074   };
0075 
0076 }  // namespace l1t
0077 #endif