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  auto pL1RPCConfig = std::make_unique<L1RPCConfig>();
108 
109  pL1RPCConfig->setPPT(m_ppt);
110 
111  // parse and isert patterns
112  int scCnt = 0, sgCnt = 0;
113  if(m_ppt == 1) {
114  scCnt = 1;
115  sgCnt = 1;
116  }
117  else if(m_ppt == 12) {
118  scCnt = 1;
119  sgCnt = 12;
120  }
121  else if(m_ppt == 144) {
122  scCnt = 12;
123  sgCnt = 12;
124  }
125  else {
126  throw cms::Exception("BadConfig") << "Bad number of ppt requested: " << m_ppt << "\n";
127  }
128 
129 
130  for (int tower = 0; tower < RPCConst::m_TOWER_COUNT; ++tower) {
131  for (int logSector = 0; logSector < scCnt; ++logSector) {
132  for (int logSegment = 0; logSegment < sgCnt; ++logSegment) {
133 
134  std::stringstream fname;
135  fname << m_patternsDir
136  << "pacPat_t" << tower
137  << "sc" << logSector
138  << "sg" <<logSegment
139  << ".xml";
140 
141  // TODO: this should go to logSth
142  LogDebug("RPCTriggerConfig") << "Parsing: " << fname.str() <<std::endl;
143 
145  parser.parse(fname.str());
146 
147  RPCPattern::RPCPatVec npats = parser.getPatternsVec(tower, logSector, logSegment);
148  for (unsigned int ip=0; ip<npats.size(); ip++) {
149  npats[ip].setCoords(tower,logSector,logSegment);
150  pL1RPCConfig->m_pats.push_back(npats[ip]);
151  }
152 
153  RPCPattern::TQualityVec nquals = parser.getQualityVec();
154  for (unsigned int iq=0; iq<nquals.size(); iq++) {
155  nquals[iq].m_tower=tower;
156  nquals[iq].m_logsector=logSector;
157  nquals[iq].m_logsegment=logSegment;
158  pL1RPCConfig->m_quals.push_back(nquals[iq]);
159  }
160 
161  LogDebug("RPCTriggerConfig")
162  << " RPCPatterns: " << npats.size()
163  << " qualities: "<< nquals.size()
164  << std::endl;
165 
166 
167  } // segments
168  } // sectors
169  } // towers
170 
171 
172 
173  return pL1RPCConfig ;
174 }
175 
176 //define this as a plug-in
#define LogDebug(id)
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:116
T getUntrackedParameter(std::string const &, T const &) const
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 &)