CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // $Id: RPCTriggerConfig.cc,v 1.6 2009/03/26 12:06:38 fruboes Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 #include "boost/shared_ptr.hpp"
24 
25 // user include files
28 
32 
33 
36 #include <string>
37 
38 
40 //
41 // class decleration
42 //
43 
45  public:
48 
49  typedef std::auto_ptr<L1RPCConfig> ReturnType;
50 
52  private:
53  // ----------member data ---------------------------
54 
55  int m_ppt;
56  std::string m_patternsDir;
57 };
58 
59 //
60 // constants, enums and typedefs
61 //
62 
63 //
64 // static data member definitions
65 //
66 
67 //
68 // constructors and destructor
69 //
71 {
72  //the following line is needed to tell the framework what
73  // data is being produced
74  setWhatProduced(this);
75 
76  //now do what ever other initialization is needed
77 
78 
79  m_ppt = iConfig.getUntrackedParameter<int>("PACsPerTower");
80  std::string dataDir = iConfig.getUntrackedParameter<std::string>("filedir");
81 
82  edm::FileInPath fp(dataDir+"pacPat_t0sc0sg0.xml");
83  std::string patternsDirNameUnstriped = fp.fullPath();
84  m_patternsDir = patternsDirNameUnstriped.substr(0,patternsDirNameUnstriped.find_last_of("/")+1);
85 
86 
87 
88 
89 }
90 
91 
93 {
94 
95  // do anything here that needs to be done at desctruction time
96  // (e.g. close files, deallocate resources etc.)
97 
98 }
99 
100 
101 //
102 // member functions
103 //
104 
105 // ------------ method called to produce the data ------------
108 {
109  using namespace edm::es;
110  std::auto_ptr<L1RPCConfig> pL1RPCConfig = std::auto_ptr<L1RPCConfig>( new L1RPCConfig() );
111 
112  pL1RPCConfig->setPPT(m_ppt);
113 
114  // parse and isert patterns
115  int scCnt = 0, sgCnt = 0;
116  if(m_ppt == 1) {
117  scCnt = 1;
118  sgCnt = 1;
119  }
120  else if(m_ppt == 12) {
121  scCnt = 1;
122  sgCnt = 12;
123  }
124  else if(m_ppt == 144) {
125  scCnt = 12;
126  sgCnt = 12;
127  }
128  else {
129  throw cms::Exception("BadConfig") << "Bad number of ppt requested: " << m_ppt << "\n";
130  }
131 
132 
133  for (int tower = 0; tower < RPCConst::m_TOWER_COUNT; ++tower) {
134  for (int logSector = 0; logSector < scCnt; ++logSector) {
135  for (int logSegment = 0; logSegment < sgCnt; ++logSegment) {
136 
137  std::stringstream fname;
138  fname << m_patternsDir
139  << "pacPat_t" << tower
140  << "sc" << logSector
141  << "sg" <<logSegment
142  << ".xml";
143 
144  // TODO: this should go to logSth
145  LogDebug("RPCTriggerConfig") << "Parsing: " << fname.str() <<std::endl;
146 
148  parser.parse(fname.str());
149 
150  RPCPattern::RPCPatVec npats = parser.getPatternsVec(tower, logSector, logSegment);
151  for (unsigned int ip=0; ip<npats.size(); ip++) {
152  npats[ip].setCoords(tower,logSector,logSegment);
153  pL1RPCConfig->m_pats.push_back(npats[ip]);
154  }
155 
156  RPCPattern::TQualityVec nquals = parser.getQualityVec();
157  for (unsigned int iq=0; iq<nquals.size(); iq++) {
158  nquals[iq].m_tower=tower;
159  nquals[iq].m_logsector=logSector;
160  nquals[iq].m_logsegment=logSegment;
161  pL1RPCConfig->m_quals.push_back(nquals[iq]);
162  }
163 
164  LogDebug("RPCTriggerConfig")
165  << " RPCPatterns: " << npats.size()
166  << " qualities: "<< nquals.size()
167  << std::endl;
168 
169 
170  } // segments
171  } // sectors
172  } // towers
173 
174 
175 
176  return pL1RPCConfig ;
177 }
178 
179 //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:32
const RPCPattern::RPCPatVec & getPatternsVec(const RPCConst::l1RpcConeCrdnts &coneCrds) const
std::auto_ptr< L1RPCConfig > ReturnType
static const int m_TOWER_COUNT
Only half of the detector.
Definition: RPCConst.h:43
std::vector< TQuality > TQualityVec
Definition: RPCPattern.h:43
std::string m_patternsDir
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:56
const RPCPattern::TQualityVec & getQualityVec() const
RPCTriggerConfig(const edm::ParameterSet &)
string fname
main script
void parse(std::string fileName)
ReturnType produce(const L1RPCConfigRcd &)