CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTConfigTrivialProducer.cc
Go to the documentation of this file.
5 #include <ostream>
6 
7 using std::cout;
8 using std::endl;
9 using std::vector;
10 using std::auto_ptr;
11 
12 //
13 // constructors and destructor
14 //
16 {
17 
18  setWhatProduced(this);
19 
20  //get and store parameter set
21  m_ps = ps;
22  m_manager = new DTConfigManager();
24 
25  // set debug
26  edm::ParameterSet conf_ps = 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);
40  m_manager->setUseAcceptParam(useBtiAcceptParam); // CB Are these needed here???
41 }
42 
43 
45 {
46 
47  if (m_debug)
48  cout << "DTConfigTrivialProducer::~DTConfigTrivialProducer()" << endl;
49 
50 
51 }
52 
53 
54 //
55 // member functions
56 //
57 
58 std::auto_ptr<DTConfigManager> DTConfigTrivialProducer::produce (const DTConfigManagerRcd& iRecord)
59 {
60 
61  if (m_debug)
62  cout << "DTConfigTrivialProducer::produce()" << endl;
63 
64  using namespace edm::es;
65  buildManager();
66 
67  //m_manager->getDTConfigPedestals()->print();
68 
69  std::auto_ptr<DTConfigManager> dtConfig = std::auto_ptr<DTConfigManager>( m_manager );
70 
71  return dtConfig ;
72 
73 }
74 
76 {
77 
78  if (m_debug)
79  cout << "DTConfigTrivialProducer::buildManager()" << endl;
80 
81  //create config classes&C.
82  edm::ParameterSet conf_ps = m_ps.getParameter<edm::ParameterSet>("DTTPGParameters");
84  DTConfigSectColl sectcollconf(conf_ps.getParameter<edm::ParameterSet>("SectCollParameters"));
85  edm::ParameterSet tups = conf_ps.getParameter<edm::ParameterSet>("TUParameters");
86  DTConfigBti bticonf(tups.getParameter<edm::ParameterSet>("BtiParameters"));
87  DTConfigTraco tracoconf(tups.getParameter<edm::ParameterSet>("TracoParameters"));
88  DTConfigLUTs lutconf(tups.getParameter<edm::ParameterSet>("LutParameters"));
89  DTConfigTSTheta tsthetaconf(tups.getParameter<edm::ParameterSet>("TSThetaParameters"));
90  DTConfigTSPhi tsphiconf(tups.getParameter<edm::ParameterSet>("TSPhiParameters"));
91  DTConfigTrigUnit trigunitconf(tups);
92 
93  for (int iwh=-2;iwh<=2;++iwh){
94  for (int ist=1;ist<=4;++ist){
95  for (int ise=1;ise<=12;++ise){
96  DTChamberId chambid(iwh,ist,ise);
97  vector<int> nmap = conf_map.getUntrackedParameter<vector<int> >(mapEntryName(chambid).c_str());
98 
99  if(m_debug)
100  {
101  std::cout << " Filling configuration for chamber : wh " << chambid.wheel() <<
102  ", st " << chambid.station() <<
103  ", se " << chambid.sector() << endl;
104  }
105 
106  //fill the bti map
107  for (int isl=1;isl<=3;isl++){
108  int ncell = nmap[isl-1];
109  // std::cout << ncell <<" , ";
110  for (int ibti=0;ibti<ncell;ibti++)
111  {
112  m_manager->setDTConfigBti(DTBtiId(chambid,isl,ibti+1),bticonf);
113  if(m_debug)
114  std::cout << "Filling BTI config for chamber : wh " << chambid.wheel() <<
115  ", st " << chambid.station() <<
116  ", se " << chambid.sector() <<
117  "... 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  {
127  m_manager->setDTConfigTraco(DTTracoId(chambid,itraco+1),tracoconf);
128  if(m_debug)
129  std::cout << "Filling TRACO config for chamber : wh " << chambid.wheel() <<
130  ", st " << chambid.station() <<
131  ", se " << chambid.sector() <<
132  ", traco " << itraco+1 << 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);
142  m_manager->setLutFromDB(false); // 110204 SV to be sure to compute luts from geometry
143  }
144  }
145  }
146 
147  for (int iwh=-2;iwh<=2;++iwh){
148  for (int ise=13;ise<=14;++ise){
149  int ist =4;
150  DTChamberId chambid(iwh,ist,ise);
151  vector<int> nmap = conf_map.getUntrackedParameter<vector<int> >(mapEntryName(chambid).c_str());
152 
153  if(m_debug)
154  {
155  std::cout << " Filling configuration for chamber : wh " << chambid.wheel() <<
156  ", st " << chambid.station() <<
157  ", se " << chambid.sector() << endl;
158  }
159 
160  //fill the bti map
161  for (int isl=1;isl<=3;isl++){
162  int ncell = nmap[isl-1];
163 // std::cout << ncell <<" , ";
164  for (int ibti=0;ibti<ncell;ibti++)
165  {
166  m_manager->setDTConfigBti(DTBtiId(chambid,isl,ibti+1),bticonf);
167  if(m_debug)
168  std::cout << "Filling BTI config for chamber : wh " << chambid.wheel() <<
169  ", st " << chambid.station() <<
170  ", se " << chambid.sector() <<
171  "... sl " << isl <<
172  ", bti " << ibti+1 << endl;
173  }
174  }
175 
176  // fill the traco map
177  int ntraco = nmap[3];
178 // std::cout << ntraco << " }" << std::endl;
179  for (int itraco=0;itraco<ntraco;itraco++)
180  {
181  m_manager->setDTConfigTraco(DTTracoId(chambid,itraco+1),tracoconf);
182  if(m_debug)
183  std::cout << "Filling TRACO config for chamber : wh " << chambid.wheel() <<
184  ", st " << chambid.station() <<
185  ", se " << chambid.sector() <<
186  ", traco " << itraco+1 << endl;
187  }
188 
189  // fill TS & TrigUnit
190  m_manager->setDTConfigTSTheta(chambid,tsthetaconf);
191  m_manager->setDTConfigTSPhi(chambid,tsphiconf);
192  m_manager->setDTConfigTrigUnit(chambid,trigunitconf);
193 
194  // fill LUTs
195  m_manager->setDTConfigLUTs(chambid,lutconf);
196  m_manager->setLutFromDB(false); // 110204 SV to be sure to compute luts from geometry
197  }
198  }
199 
200  //loop on Sector Collectors
201  for (int wh=-2;wh<=2;wh++)
202  for (int se=1;se<=12;se++)
203  m_manager->setDTConfigSectColl(DTSectCollId(wh,se),sectcollconf);
204 
205  //fake collection of pedestals
207 
208 }
209 
211 {
212 
213  int counts = m_ps.getParameter<int>("bxOffset");
214  float fine = m_ps.getParameter<double>("finePhase");
215 
216  if (m_debug)
217  cout << "DTConfigTrivialProducer::buildPedestals()" << endl;
218 
219  //DTTPGParameters tpgParams;
220  for (int iwh=-2;iwh<=2;++iwh){
221  for (int ist=1;ist<=4;++ist){
222  for (int ise=1;ise<=14;++ise){
223  if (ise>12 && ist!=4) continue;
224 
225  DTChamberId chId(iwh,ist,ise);
226  m_tpgParams->set(chId,counts,fine,DTTimeUnits::ns);
227  }
228  }
229  }
230 
231  DTConfigPedestals tpgPedestals;
232  tpgPedestals.setUseT0(false);
233  tpgPedestals.setES(m_tpgParams);
234 
235  return tpgPedestals;
236 
237 }
238 
239 
241 {
242  int iwh = chambid.wheel();
243  std::ostringstream os;
244  os << "wh";
245  if (iwh < 0) {
246  os << 'm' << -iwh;
247  } else {
248  os << iwh;
249  }
250  os << "st" << chambid.station() << "se" << chambid.sector();
251  return os.str();
252 }
void setLutFromDB(bool lutFromDB)
Set lut from DB flag.
T getParameter(std::string const &) const
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)
std::string mapEntryName(const DTChamberId &chambid) const
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
void setDTConfigTraco(DTTracoId, DTConfigTraco)
Set DTConfigTraco for desired chip.
DTConfigPedestals buildTrivialPedestals()
Build Config Pedestals.
void setES(DTTPGParameters const *tpgParams, DTT0 const *t0Params=0)
Set parameters from ES.
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::auto_ptr< DTConfigManager > produce(const DTConfigManagerRcd &)
ES produce method.
int sector() const
Definition: DTChamberId.h:61
tuple cout
Definition: gather_cfg.py:121
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