CMS 3D CMS Logo

RPCTriggerConfig.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: RPCTriggerConfig
4 // Class: RPCTriggerConfig
5 //
13 //
14 // Original Author: Tomasz Maciej Frueboes
15 // Created: Tue Mar 20 12:30:19 CET 2007
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
30 
31 
34 #include <string>
35 
36 
38 //
39 // class decleration
40 //
41 
43  public:
45  ~RPCTriggerConfig() override;
46 
47  typedef std::unique_ptr<L1RPCConfig> ReturnType;
48 
49  ReturnType produce(const L1RPCConfigRcd&);
50  private:
51  // ----------member data ---------------------------
52 
53  int m_ppt;
55 };
56 
57 //
58 // constants, enums and typedefs
59 //
60 
61 //
62 // static data member definitions
63 //
64 
65 //
66 // constructors and destructor
67 //
69 {
70  //the following line is needed to tell the framework what
71  // data is being produced
72  setWhatProduced(this);
73 
74  //now do what ever other initialization is needed
75 
76 
77  m_ppt = iConfig.getUntrackedParameter<int>("PACsPerTower");
78  std::string dataDir = iConfig.getUntrackedParameter<std::string>("filedir");
79 
80  edm::FileInPath fp(dataDir+"pacPat_t0sc0sg0.xml");
81  std::string patternsDirNameUnstriped = fp.fullPath();
82  m_patternsDir = patternsDirNameUnstriped.substr(0,patternsDirNameUnstriped.find_last_of("/")+1);
83 
84 
85 
86 
87 }
88 
89 
91 {
92 
93  // do anything here that needs to be done at desctruction time
94  // (e.g. close files, deallocate resources etc.)
95 
96 }
97 
98 
99 //
100 // member functions
101 //
102 
103 // ------------ method called to produce the data ------------
106 {
107  using namespace edm::es;
108  auto pL1RPCConfig = std::make_unique<L1RPCConfig>();
109 
110  pL1RPCConfig->setPPT(m_ppt);
111 
112  // parse and isert patterns
113  int scCnt = 0, sgCnt = 0;
114  if(m_ppt == 1) {
115  scCnt = 1;
116  sgCnt = 1;
117  }
118  else if(m_ppt == 12) {
119  scCnt = 1;
120  sgCnt = 12;
121  }
122  else if(m_ppt == 144) {
123  scCnt = 12;
124  sgCnt = 12;
125  }
126  else {
127  throw cms::Exception("BadConfig") << "Bad number of ppt requested: " << m_ppt << "\n";
128  }
129 
130 
131  for (int tower = 0; tower < RPCConst::m_TOWER_COUNT; ++tower) {
132  for (int logSector = 0; logSector < scCnt; ++logSector) {
133  for (int logSegment = 0; logSegment < sgCnt; ++logSegment) {
134 
135  std::stringstream fname;
136  fname << m_patternsDir
137  << "pacPat_t" << tower
138  << "sc" << logSector
139  << "sg" <<logSegment
140  << ".xml";
141 
142  // TODO: this should go to logSth
143  LogDebug("RPCTriggerConfig") << "Parsing: " << fname.str() <<std::endl;
144 
146  parser.parse(fname.str());
147 
148  RPCPattern::RPCPatVec npats = parser.getPatternsVec(tower, logSector, logSegment);
149  for (unsigned int ip=0; ip<npats.size(); ip++) {
150  npats[ip].setCoords(tower,logSector,logSegment);
151  pL1RPCConfig->m_pats.push_back(npats[ip]);
152  }
153 
154  RPCPattern::TQualityVec nquals = parser.getQualityVec();
155  for (unsigned int iq=0; iq<nquals.size(); iq++) {
156  nquals[iq].m_tower=tower;
157  nquals[iq].m_logsector=logSector;
158  nquals[iq].m_logsegment=logSegment;
159  pL1RPCConfig->m_quals.push_back(nquals[iq]);
160  }
161 
162  LogDebug("RPCTriggerConfig")
163  << " RPCPatterns: " << npats.size()
164  << " qualities: "<< nquals.size()
165  << std::endl;
166 
167 
168  } // segments
169  } // sectors
170  } // towers
171 
172 
173 
174  return pL1RPCConfig ;
175 }
176 
177 //define this as a plug-in
#define LogDebug(id)
T getUntrackedParameter(std::string const &, T const &) const
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
std::vector< RPCPattern > RPCPatVec
Definition: RPCPattern.h:36
const RPCPattern::RPCPatVec & getPatternsVec(const RPCConst::l1RpcConeCrdnts &coneCrds) const
static const int m_TOWER_COUNT
Only half of the detector.
Definition: RPCConst.h:43
~RPCTriggerConfig() override
std::vector< TQuality > TQualityVec
Definition: RPCPattern.h:49
std::string m_patternsDir
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
const RPCPattern::TQualityVec & getQualityVec() const
RPCTriggerConfig(const edm::ParameterSet &)
string fname
main script
std::unique_ptr< L1RPCConfig > ReturnType
void parse(std::string fileName)
ReturnType produce(const L1RPCConfigRcd &)