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