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  setWhatProduced(this);
17 
18  // get and store parameter set
19  m_ps = ps;
20  m_manager = new DTConfigManager();
22 
23  // set debug
24  edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");
25  m_debug = conf_ps.getUntrackedParameter<bool>("Debug");
26 
27  if (m_debug)
28  cout << "DTConfigTrivialProducer::DTConfigTrivialProducer()" << endl;
29 
30  m_manager->setDTTPGDebug(m_debug);
31 
32  // DB specific requests
33  bool tracoLutsFromDB = m_ps.getParameter<bool>("TracoLutsFromDB");
34  bool useBtiAcceptParam = m_ps.getParameter<bool>("UseBtiAcceptParam");
35 
36  // set specific DB requests
37  m_manager->setLutFromDB(tracoLutsFromDB);
38  m_manager->setUseAcceptParam(useBtiAcceptParam); // CB Are these needed here???
39 }
40 
42  if (m_debug)
43  cout << "DTConfigTrivialProducer::~DTConfigTrivialProducer()" << endl;
44 }
45 
46 //
47 // member functions
48 //
49 
50 std::unique_ptr<DTConfigManager> DTConfigTrivialProducer::produce(const DTConfigManagerRcd &iRecord) {
51  if (m_debug)
52  cout << "DTConfigTrivialProducer::produce()" << endl;
53 
54  using namespace edm::es;
55  buildManager();
56 
57  // m_manager->getDTConfigPedestals()->print();
58 
59  std::unique_ptr<DTConfigManager> dtConfig = std::unique_ptr<DTConfigManager>(m_manager);
60 
61  return dtConfig;
62 }
63 
65  if (m_debug)
66  cout << "DTConfigTrivialProducer::buildManager()" << endl;
67 
68  // create config classes&C.
69  edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");
71  DTConfigSectColl sectcollconf(conf_ps.getParameter<edm::ParameterSet>("SectCollParameters"));
72  edm::ParameterSet tups = conf_ps.getParameter<edm::ParameterSet>("TUParameters");
73  DTConfigBti bticonf(tups.getParameter<edm::ParameterSet>("BtiParameters"));
74  DTConfigTraco tracoconf(tups.getParameter<edm::ParameterSet>("TracoParameters"));
75  DTConfigLUTs lutconf(tups.getParameter<edm::ParameterSet>("LutParameters"));
76  DTConfigTSTheta tsthetaconf(tups.getParameter<edm::ParameterSet>("TSThetaParameters"));
77  DTConfigTSPhi tsphiconf(tups.getParameter<edm::ParameterSet>("TSPhiParameters"));
78  DTConfigTrigUnit trigunitconf(tups);
79 
80  for (int iwh = -2; iwh <= 2; ++iwh) {
81  for (int ist = 1; ist <= 4; ++ist) {
82  for (int ise = 1; ise <= 12; ++ise) {
83  DTChamberId chambid(iwh, ist, ise);
84  vector<int> nmap = conf_map.getUntrackedParameter<vector<int>>(mapEntryName(chambid).c_str());
85 
86  if (m_debug) {
87  std::cout << " Filling configuration for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
88  << ", se " << chambid.sector() << endl;
89  }
90 
91  // fill the bti map
92  for (int isl = 1; isl <= 3; isl++) {
93  int ncell = nmap[isl - 1];
94  // std::cout << ncell <<" , ";
95  for (int ibti = 0; ibti < ncell; ibti++) {
96  m_manager->setDTConfigBti(DTBtiId(chambid, isl, ibti + 1), bticonf);
97  if (m_debug)
98  std::cout << "Filling BTI config for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
99  << ", se " << chambid.sector() << "... sl " << isl << ", bti " << ibti + 1 << endl;
100  }
101  }
102 
103  // fill the traco map
104  int ntraco = nmap[3];
105  // std::cout << ntraco << " }" << std::endl;
106  for (int itraco = 0; itraco < ntraco; itraco++) {
107  m_manager->setDTConfigTraco(DTTracoId(chambid, itraco + 1), tracoconf);
108  if (m_debug)
109  std::cout << "Filling TRACO config for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
110  << ", se " << chambid.sector() << ", traco " << itraco + 1 << endl;
111  }
112 
113  // fill TS & TrigUnit
114  m_manager->setDTConfigTSTheta(chambid, tsthetaconf);
115  m_manager->setDTConfigTSPhi(chambid, tsphiconf);
116  m_manager->setDTConfigTrigUnit(chambid, trigunitconf);
117 
118  // fill LUTs
119  m_manager->setDTConfigLUTs(chambid, lutconf);
120  m_manager->setLutFromDB(false); // 110204 SV to be sure to compute luts from geometry
121  }
122  }
123  }
124 
125  for (int iwh = -2; iwh <= 2; ++iwh) {
126  for (int ise = 13; ise <= 14; ++ise) {
127  int ist = 4;
128  DTChamberId chambid(iwh, ist, ise);
129  vector<int> nmap = conf_map.getUntrackedParameter<vector<int>>(mapEntryName(chambid).c_str());
130 
131  if (m_debug) {
132  std::cout << " Filling configuration for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
133  << ", se " << chambid.sector() << endl;
134  }
135 
136  // fill the bti map
137  for (int isl = 1; isl <= 3; isl++) {
138  int ncell = nmap[isl - 1];
139  // std::cout << ncell <<" , ";
140  for (int ibti = 0; ibti < ncell; ibti++) {
141  m_manager->setDTConfigBti(DTBtiId(chambid, isl, ibti + 1), bticonf);
142  if (m_debug)
143  std::cout << "Filling BTI config for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
144  << ", se " << chambid.sector() << "... sl " << isl << ", bti " << ibti + 1 << endl;
145  }
146  }
147 
148  // fill the traco map
149  int ntraco = nmap[3];
150  // std::cout << ntraco << " }" << std::endl;
151  for (int itraco = 0; itraco < ntraco; itraco++) {
152  m_manager->setDTConfigTraco(DTTracoId(chambid, itraco + 1), tracoconf);
153  if (m_debug)
154  std::cout << "Filling TRACO config for chamber : wh " << chambid.wheel() << ", st " << chambid.station()
155  << ", se " << chambid.sector() << ", traco " << itraco + 1 << endl;
156  }
157 
158  // fill TS & TrigUnit
159  m_manager->setDTConfigTSTheta(chambid, tsthetaconf);
160  m_manager->setDTConfigTSPhi(chambid, tsphiconf);
161  m_manager->setDTConfigTrigUnit(chambid, trigunitconf);
162 
163  // fill LUTs
164  m_manager->setDTConfigLUTs(chambid, lutconf);
165  m_manager->setLutFromDB(false); // 110204 SV to be sure to compute luts from geometry
166  }
167  }
168 
169  // loop on Sector Collectors
170  for (int wh = -2; wh <= 2; wh++)
171  for (int se = 1; se <= 12; se++)
172  m_manager->setDTConfigSectColl(DTSectCollId(wh, se), sectcollconf);
173 
174  // fake collection of pedestals
176 }
177 
179  int counts = m_ps.getParameter<int>("bxOffset");
180  float fine = m_ps.getParameter<double>("finePhase");
181 
182  if (m_debug)
183  cout << "DTConfigTrivialProducer::buildPedestals()" << endl;
184 
185  // DTTPGParameters tpgParams;
186  for (int iwh = -2; iwh <= 2; ++iwh) {
187  for (int ist = 1; ist <= 4; ++ist) {
188  for (int ise = 1; ise <= 14; ++ise) {
189  if (ise > 12 && ist != 4)
190  continue;
191 
192  DTChamberId chId(iwh, ist, ise);
193  m_tpgParams->set(chId, counts, fine, DTTimeUnits::ns);
194  }
195  }
196  }
197 
198  DTConfigPedestals tpgPedestals;
199  tpgPedestals.setUseT0(false);
200  tpgPedestals.setES(m_tpgParams);
201 
202  return tpgPedestals;
203 }
204 
206  int iwh = chambid.wheel();
207  std::ostringstream os;
208  os << "wh";
209  if (iwh < 0) {
210  os << 'm' << -iwh;
211  } else {
212  os << iwh;
213  }
214  os << "st" << chambid.station() << "se" << chambid.sector();
215  return os.str();
216 }
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:138
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:49
int station() const
Return the station number.
Definition: DTChamberId.h:42
void setDTConfigTrigUnit(DTChamberId chambid, DTConfigTrigUnit conf)
Set DTConfigTrigUnit for desired chamber.
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39