CMS 3D CMS Logo

DTConfigTrivialProducer.cc
Go to the documentation of this file.
5 #include <ostream>
6 
7 using std::cout;
8 using std::endl;
9 using std::unique_ptr;
10 using std::vector;
11 
12 //
13 // constructors and destructor
14 //
16 
17  setWhatProduced(this);
18 
19  // get and store parameter set
20  m_ps = ps;
21  m_manager = new DTConfigManager();
23 
24  // set debug
25  edm::ParameterSet conf_ps =
26  m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");
27  m_debug = conf_ps.getUntrackedParameter<bool>("Debug");
28 
29  if (m_debug)
30  cout << "DTConfigTrivialProducer::DTConfigTrivialProducer()" << endl;
31 
32  m_manager->setDTTPGDebug(m_debug);
33 
34  // DB specific requests
35  bool tracoLutsFromDB = m_ps.getParameter<bool>("TracoLutsFromDB");
36  bool useBtiAcceptParam = m_ps.getParameter<bool>("UseBtiAcceptParam");
37 
38  // set specific DB requests
39  m_manager->setLutFromDB(tracoLutsFromDB);
41  useBtiAcceptParam); // CB Are these needed here???
42 }
43 
45 
46  if (m_debug)
47  cout << "DTConfigTrivialProducer::~DTConfigTrivialProducer()" << endl;
48 }
49 
50 //
51 // member functions
52 //
53 
54 std::unique_ptr<DTConfigManager>
56 
57  if (m_debug)
58  cout << "DTConfigTrivialProducer::produce()" << endl;
59 
60  using namespace edm::es;
61  buildManager();
62 
63  // m_manager->getDTConfigPedestals()->print();
64 
65  std::unique_ptr<DTConfigManager> dtConfig =
66  std::unique_ptr<DTConfigManager>(m_manager);
67 
68  return dtConfig;
69 }
70 
72 
73  if (m_debug)
74  cout << "DTConfigTrivialProducer::buildManager()" << endl;
75 
76  // create config classes&C.
77  edm::ParameterSet conf_ps =
78  m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");
79  edm::ParameterSet conf_map =
81  DTConfigSectColl sectcollconf(
82  conf_ps.getParameter<edm::ParameterSet>("SectCollParameters"));
83  edm::ParameterSet tups =
84  conf_ps.getParameter<edm::ParameterSet>("TUParameters");
85  DTConfigBti bticonf(tups.getParameter<edm::ParameterSet>("BtiParameters"));
86  DTConfigTraco tracoconf(
87  tups.getParameter<edm::ParameterSet>("TracoParameters"));
88  DTConfigLUTs lutconf(tups.getParameter<edm::ParameterSet>("LutParameters"));
89  DTConfigTSTheta tsthetaconf(
90  tups.getParameter<edm::ParameterSet>("TSThetaParameters"));
91  DTConfigTSPhi tsphiconf(
92  tups.getParameter<edm::ParameterSet>("TSPhiParameters"));
93  DTConfigTrigUnit trigunitconf(tups);
94 
95  for (int iwh = -2; iwh <= 2; ++iwh) {
96  for (int ist = 1; ist <= 4; ++ist) {
97  for (int ise = 1; ise <= 12; ++ise) {
98  DTChamberId chambid(iwh, ist, ise);
99  vector<int> nmap = conf_map.getUntrackedParameter<vector<int>>(
100  mapEntryName(chambid).c_str());
101 
102  if (m_debug) {
103  std::cout << " Filling configuration for chamber : wh "
104  << chambid.wheel() << ", st " << chambid.station()
105  << ", se " << chambid.sector() << endl;
106  }
107 
108  // fill the bti map
109  for (int isl = 1; isl <= 3; isl++) {
110  int ncell = nmap[isl - 1];
111  // std::cout << ncell <<" , ";
112  for (int ibti = 0; ibti < ncell; ibti++) {
113  m_manager->setDTConfigBti(DTBtiId(chambid, isl, ibti + 1), bticonf);
114  if (m_debug)
115  std::cout << "Filling BTI config for chamber : wh "
116  << chambid.wheel() << ", st " << chambid.station()
117  << ", se " << chambid.sector() << "... sl " << isl
118  << ", bti " << ibti + 1 << endl;
119  }
120  }
121 
122  // fill the traco map
123  int ntraco = nmap[3];
124  // std::cout << ntraco << " }" << std::endl;
125  for (int itraco = 0; itraco < ntraco; itraco++) {
126  m_manager->setDTConfigTraco(DTTracoId(chambid, itraco + 1),
127  tracoconf);
128  if (m_debug)
129  std::cout << "Filling TRACO config for chamber : wh "
130  << chambid.wheel() << ", st " << chambid.station()
131  << ", se " << chambid.sector() << ", traco " << itraco + 1
132  << endl;
133  }
134 
135  // fill TS & TrigUnit
136  m_manager->setDTConfigTSTheta(chambid, tsthetaconf);
137  m_manager->setDTConfigTSPhi(chambid, tsphiconf);
138  m_manager->setDTConfigTrigUnit(chambid, trigunitconf);
139 
140  // fill LUTs
141  m_manager->setDTConfigLUTs(chambid, lutconf);
143  false); // 110204 SV to be sure to compute luts from geometry
144  }
145  }
146  }
147 
148  for (int iwh = -2; iwh <= 2; ++iwh) {
149  for (int ise = 13; ise <= 14; ++ise) {
150  int ist = 4;
151  DTChamberId chambid(iwh, ist, ise);
152  vector<int> nmap = conf_map.getUntrackedParameter<vector<int>>(
153  mapEntryName(chambid).c_str());
154 
155  if (m_debug) {
156  std::cout << " Filling configuration for chamber : wh "
157  << chambid.wheel() << ", st " << chambid.station() << ", se "
158  << chambid.sector() << endl;
159  }
160 
161  // fill the bti map
162  for (int isl = 1; isl <= 3; isl++) {
163  int ncell = nmap[isl - 1];
164  // std::cout << ncell <<" , ";
165  for (int ibti = 0; ibti < ncell; ibti++) {
166  m_manager->setDTConfigBti(DTBtiId(chambid, isl, ibti + 1), bticonf);
167  if (m_debug)
168  std::cout << "Filling BTI config for chamber : wh "
169  << chambid.wheel() << ", st " << chambid.station()
170  << ", se " << chambid.sector() << "... sl " << isl
171  << ", bti " << ibti + 1 << endl;
172  }
173  }
174 
175  // fill the traco map
176  int ntraco = nmap[3];
177  // std::cout << ntraco << " }" << std::endl;
178  for (int itraco = 0; itraco < ntraco; itraco++) {
179  m_manager->setDTConfigTraco(DTTracoId(chambid, itraco + 1), tracoconf);
180  if (m_debug)
181  std::cout << "Filling TRACO config for chamber : wh "
182  << chambid.wheel() << ", st " << chambid.station()
183  << ", se " << chambid.sector() << ", traco " << itraco + 1
184  << endl;
185  }
186 
187  // fill TS & TrigUnit
188  m_manager->setDTConfigTSTheta(chambid, tsthetaconf);
189  m_manager->setDTConfigTSPhi(chambid, tsphiconf);
190  m_manager->setDTConfigTrigUnit(chambid, trigunitconf);
191 
192  // fill LUTs
193  m_manager->setDTConfigLUTs(chambid, lutconf);
195  false); // 110204 SV to be sure to compute luts from geometry
196  }
197  }
198 
199  // loop on Sector Collectors
200  for (int wh = -2; wh <= 2; wh++)
201  for (int se = 1; se <= 12; se++)
202  m_manager->setDTConfigSectColl(DTSectCollId(wh, se), sectcollconf);
203 
204  // fake collection of pedestals
206 }
207 
209 
210  int counts = m_ps.getParameter<int>("bxOffset");
211  float fine = m_ps.getParameter<double>("finePhase");
212 
213  if (m_debug)
214  cout << "DTConfigTrivialProducer::buildPedestals()" << endl;
215 
216  // DTTPGParameters tpgParams;
217  for (int iwh = -2; iwh <= 2; ++iwh) {
218  for (int ist = 1; ist <= 4; ++ist) {
219  for (int ise = 1; ise <= 14; ++ise) {
220  if (ise > 12 && ist != 4)
221  continue;
222 
223  DTChamberId chId(iwh, ist, ise);
224  m_tpgParams->set(chId, counts, fine, DTTimeUnits::ns);
225  }
226  }
227  }
228 
229  DTConfigPedestals tpgPedestals;
230  tpgPedestals.setUseT0(false);
231  tpgPedestals.setES(m_tpgParams);
232 
233  return tpgPedestals;
234 }
235 
238  int iwh = chambid.wheel();
239  std::ostringstream os;
240  os << "wh";
241  if (iwh < 0) {
242  os << 'm' << -iwh;
243  } else {
244  os << iwh;
245  }
246  os << "st" << chambid.station() << "se" << chambid.sector();
247  return os.str();
248 }
void setLutFromDB(bool lutFromDB)
Set lut from DB flag.
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:124
T getUntrackedParameter(std::string const &, T const &) const
void setDTTPGDebug(bool debug)
SetGlobalDebug flag.
void setDTConfigTSTheta(DTChamberId chambid, DTConfigTSTheta conf)
Set DTConfigTSTheta for desired chip.
void buildManager()
Build Config Manager.
void setUseAcceptParam(bool acceptparam)
Set the use of Bti acceptance parameters (LL,LH,CL,CH,RL,RH)
int set(int wheelId, int stationId, int sectorId, int nc, float ph, DTTimeUnits::type unit)
void setES(DTTPGParameters const *tpgParams, DTT0 const *t0Params=nullptr)
Set parameters from ES.
std::string mapEntryName(const DTChamberId &chambid) const
void setDTConfigTraco(DTTracoId, DTConfigTraco)
Set DTConfigTraco for desired chip.
DTConfigPedestals buildTrivialPedestals()
Build Config Pedestals.
~DTConfigTrivialProducer() override
destructor
void setDTConfigBti(DTBtiId, DTConfigBti)
Set DTConfigBti for desired chip.
void setDTConfigTSPhi(DTChamberId chambid, DTConfigTSPhi conf)
Set DTConfigTSPhi for desired chip.
void setUseT0(bool useT0)
Set t0i subtraction.
DTConfigTrivialProducer(const edm::ParameterSet &)
Constructor.
void setDTConfigLUTs(DTChamberId chambid, DTConfigLUTs conf)
Set DTConfigLUTs for desired chamber.
void setDTConfigPedestals(DTConfigPedestals pedestals)
Set DTConfigPedestals configuration.
void setDTConfigSectColl(DTSectCollId sectcollid, DTConfigSectColl conf)
Set DTConfigSectColl for desired chip.
std::unique_ptr< DTConfigManager > produce(const DTConfigManagerRcd &)
ES produce method.
int sector() const
Definition: DTChamberId.h:61
int station() const
Return the station number.
Definition: DTChamberId.h:51
void setDTConfigTrigUnit(DTChamberId chambid, DTConfigTrigUnit conf)
Set DTConfigTrigUnit for desired chamber.
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45