CMS 3D CMS Logo

PixelCalibConfiguration.h
Go to the documentation of this file.
1 #ifndef PixelCalibConfiguration_h
2 #define PixelCalibConfiguration_h
3 
9 #include <vector>
10 #include <set>
11 #include <map>
12 #include <string>
13 #include <sstream>
14 #include <utility>
34 
35 namespace pos {
36  class PixelHdwAddress;
37 
38  //This class contains info about a ROC
39  class PixelROCInfo {
40  public:
41  bool use_;
43  //FIXME these should be const but it has ripple effects...
46  std::vector<std::pair<unsigned int, unsigned int> > defaultDACs_;
48  };
49 
63  std::ostream& operator<<(std::ostream& s, const PixelCalibConfiguration& calib);
64 
66  public:
68  PixelCalibConfiguration(std::vector<std::vector<std::string> >&);
69 
70  ~PixelCalibConfiguration() override;
71 
72  // This must be run before using commands that require the ROC list.
73  void buildROCAndModuleLists(const PixelNameTranslation* translation, const PixelDetectorConfig* detconfig);
74 
75  void nextFECState(std::map<unsigned int, PixelFECConfigInterface*>& pixelFECs,
76  PixelDetectorConfig* detconfig,
77  PixelNameTranslation* trans,
78  std::map<pos::PixelModuleName, pos::PixelMaskBase*>* masks,
79  std::map<pos::PixelModuleName, pos::PixelTrimBase*>* trims,
80  std::map<pos::PixelModuleName, pos::PixelDACSettings*>* dacss,
81  unsigned int state) const;
82 
83  //return vector of fed# and channels controlled by this fed supervisor
84  std::vector<std::pair<unsigned int, std::vector<unsigned int> > >& fedCardsAndChannels(
85  unsigned int crate,
86  PixelNameTranslation* translation,
87  PixelFEDConfig* fedconfig,
88  PixelDetectorConfig* detconfig) const;
89 
90  std::map<unsigned int, std::set<unsigned int> > getFEDsAndChannels(PixelNameTranslation* translation);
91 
92  // Returns a std::set of FED crates that are used by this Calib object
93  std::set<unsigned int> getFEDCrates(const PixelNameTranslation* translation, const PixelFEDConfig* fedconfig) const;
94 
95  // Returns a std::set of FEC crates that are used by this Calib object
96  std::set<unsigned int> getFECCrates(const PixelNameTranslation* translation, const PixelFECConfig* fecconfig) const;
97 
98  // Returns a std::set of TKFEC crates that are used by this Calib object
99  std::set<unsigned int> getTKFECCrates(const PixelPortcardMap* portcardmap,
100  const std::map<std::string, PixelPortCardConfig*>& mapNamePortCard,
101  const PixelTKFECConfig* tkfecconfig) const;
102 
103  unsigned int nROC() const {
105  return nROC_;
106  }
107  unsigned int nPixelPatterns() const { return rows_.size() * cols_.size(); }
108  unsigned int nTriggersPerPattern() const { return ntrigger_; }
109  unsigned int nScanPoints(std::string dac) const { return nScanPoints(iScan(dac)); }
110 
111  unsigned int nScanPoints() const {
112  unsigned int points = 1;
113  for (unsigned int i = 0; i < dacs_.size(); i++) {
114  points *= nScanPoints(i);
115  }
116  return points;
117  }
118  unsigned int nConfigurations() const { return nPixelPatterns() * nScanPoints() * nROC(); }
119  unsigned int nTriggersTotal() const { return nConfigurations() * nTriggersPerPattern(); }
120 
121  bool noHits() const { return (maxNumHitsPerROC() == 0); } // returns true if no hits will be produced
122  unsigned int maxNumHitsPerROC()
123  const; // returns the maximum number of hits that will be produced in any pixel pattern
124 
125  // Return all the pixels that are enabled for this state.
126  std::set<std::pair<unsigned int, unsigned int> > pixelsWithHits(unsigned int state) const;
127  // column # row #
128 
129  // Whether this ROC is currently being scanned. (Always true when not in SingleROC mode.)
130  bool scanningROCForState(PixelROCName roc, unsigned int state) const;
131 
132  unsigned int scanCounter(std::string dac, unsigned int state) const { return scanCounter(iScan(dac), state); }
133 
134  unsigned int scanValue(std::string dac, unsigned int state, PixelROCName roc) const {
135  return scanValue(iScan(dac), state, roc);
136  }
137 
138  // This function should not be used -- provided for backwards compatibility only. It asserts if the scan values for this dac are mixed across different ROCs.
139  unsigned int scanValue(std::string dac, unsigned int state) const {
140  assert(!(dacs_[iScan(dac)].mixValuesAcrossROCs()));
141  return scanValue(iScan(dac), state, 0, 1);
142  }
143 
144  unsigned int numberOfScanVariables() const { return dacs_.size(); }
145 
146  bool containsScan(std::string name) const;
147 
148  std::string scanName(unsigned int iscan) const { return dacs_[iscan].name(); }
149  std::vector<unsigned int> scanValues(std::string dac) const { return scanValues(iScan(dac)); }
150 
151  double scanValueMin(std::string dac) const { return scanValueMin(iScan(dac)); }
152  double scanValueMax(std::string dac) const { return scanValueMax(iScan(dac)); }
153  double scanValueStep(std::string dac) const { return scanValueStep(iScan(dac)); }
155 
156  unsigned int iScan(std::string dac) const;
157 
158  const std::vector<std::vector<unsigned int> >& columnList() const { return cols_; }
159  const std::vector<std::vector<unsigned int> >& rowList() const { return rows_; }
160  const std::vector<PixelROCName>& rocList() const {
162  return rocs_;
163  }
164  const std::set<PixelModuleName>& moduleList() const {
166  return modules_;
167  }
168  const std::set<PixelChannel>& channelList() const {
170  return channels_;
171  }
172 
173  std::string mode() const override { return mode_; }
174 
175  bool singleROC() const { return singleROC_; }
176 
177  unsigned int nParameters() const { return parameters_.size(); }
178 
179  // Added by Dario Apr 24th, 2008
180  std::map<std::string, std::string> parametersList() const { return parameters_; }
181  // get the value of parameter parameterName, or "" if parameterName is not in the list
182  std::string parameterValue(std::string parameterName) const;
183 
184  // Added by Dario May 8th, 2008
186 
187  friend std::ostream& pos::operator<<(std::ostream& s, const PixelCalibConfiguration& calib);
188 
189  void writeASCII(std::string dir = "") const override;
190  void writeXML(pos::PixelConfigKey key, int version, std::string path) const override { ; }
192  int version,
194  std::ofstream* out,
195  std::ofstream* out1 = nullptr,
196  std::ofstream* out2 = nullptr) const override;
197  void writeXML(std::ofstream* out, std::ofstream* out1 = nullptr, std::ofstream* out2 = nullptr) const override;
198  void writeXMLTrailer(std::ofstream* out,
199  std::ofstream* out1 = nullptr,
200  std::ofstream* out2 = nullptr) const override;
201 
202  private:
203  // Which set of rows we're on.
204  unsigned int rowCounter(unsigned int state) const;
205 
206  // Which set of columns we're on.
207  unsigned int colCounter(unsigned int state) const;
208 
209  // In SingleROC mode, which ROC we're on. In normal mode, this equals 1.
210  unsigned int scanROC(unsigned int state) const;
211 
212  unsigned int nScanPoints(unsigned int iscan) const { return dacs_[iscan].getNPoints(); }
213 
214  unsigned int scanCounter(unsigned int iscan, unsigned int state) const;
215 
216  unsigned int scanValue(unsigned int iscan,
217  unsigned int state,
218  unsigned int ROCNumber,
219  unsigned int ROCsOnChannel) const;
220  unsigned int scanValue(unsigned int iscan, unsigned int state, PixelROCName roc) const;
221 
222  std::vector<unsigned int> scanValues(unsigned int iscan) const { return dacs_[iscan].values(); }
223 
224  double scanValueMin(unsigned int iscan) const { return dacs_[iscan].first(); }
225  double scanValueMax(unsigned int iscan) const {
226  return dacs_[iscan].first() + dacs_[iscan].step() * (nScanPoints(iscan) - 1);
227  }
228  double scanValueStep(unsigned int iscan) const { return dacs_[iscan].step(); }
229  bool scanValuesMixedAcrossROCs(unsigned int iscan) const { return dacs_[iscan].mixValuesAcrossROCs(); }
230 
231  // Used in constructor or in buildROCAndModuleLists()
232  void buildROCAndModuleListsFromROCSet(const std::set<PixelROCName>& rocSet);
233 
235 
237  unsigned int numROCsCalibratedOnChannel(PixelROCName roc) const;
238 
240 
241  std::vector<std::vector<unsigned int> > rows_;
242  std::vector<std::vector<unsigned int> > cols_;
243 
244  mutable std::vector<PixelROCName> rocs_;
245  mutable std::vector<PixelROCInfo> rocInfo_;
246  std::set<PixelModuleName> modules_;
248  std::vector<std::string> rocListInstructions_;
249 
250  // Objects built using the name translation.
251  std::set<PixelChannel> channels_;
252  std::map<PixelROCName, unsigned int> ROCNumberOnChannelAmongThoseCalibrated_;
253  std::map<PixelROCName, unsigned int> numROCsCalibratedOnChannel_;
255 
256  mutable std::vector<std::pair<unsigned int, std::vector<unsigned int> > > fedCardsAndChannels_;
257 
258  //unsigned int vcal_;
259 
260  std::vector<PixelDACScanRange> dacs_;
261 
262  //std::vector<std::string> dacname_;
263  //std::vector<unsigned int> dacchannel_;
264  //std::vector<unsigned int> dac_first_;
265  //std::vector<unsigned int> dac_last_;
266  //std::vector<unsigned int> dac_step_;
267 
268  unsigned int ntrigger_;
269  unsigned int nROC_; //This is the maximal #ROCs on a given TBM
270 
272 
273  void enablePixels(PixelFECConfigInterface* pixelFEC,
274  unsigned int irows,
275  unsigned int icols,
276  pos::PixelROCMaskBits* masks,
277  pos::PixelROCTrimBits* trims,
278  const PixelHdwAddress& theROC) const;
279 
280  void disablePixels(PixelFECConfigInterface* pixelFEC,
281  unsigned int irows,
282  unsigned int icols,
283  pos::PixelROCTrimBits* trims,
284  const PixelHdwAddress& theROC) const;
285 
286  void disablePixels(PixelFECConfigInterface* pixelFEC,
287  pos::PixelROCTrimBits* trims,
288  const PixelHdwAddress& theROC) const;
289 
290  mutable std::vector<int> old_irows;
291  mutable std::vector<int> old_icols;
292 
293  std::map<std::string, std::string> parameters_;
294  // name value
295 
297 
299 
300  // Added by Dario May 8th, 2008
302  };
303 } // namespace pos
304 /* @} */
305 #endif
void enablePixels(PixelFECConfigInterface *pixelFEC, unsigned int irows, unsigned int icols, pos::PixelROCMaskBits *masks, pos::PixelROCTrimBits *trims, const PixelHdwAddress &theROC) const
unsigned int ROCNumberOnChannelAmongThoseCalibrated(PixelROCName roc) const
This class specifies which TKFEC boards are used and how they are addressed.
This class specifies which detector components are used in the configuration (and eventually should s...
std::vector< std::vector< unsigned int > > rows_
This class specifies which FEC boards are used and how they are addressed.
This file contains the base class for "pixel configuration data" management.
double scanValueMax(unsigned int iscan) const
std::set< unsigned int > getTKFECCrates(const PixelPortcardMap *portcardmap, const std::map< std::string, PixelPortCardConfig *> &mapNamePortCard, const PixelTKFECConfig *tkfecconfig) const
std::set< PixelChannel > channels_
void nextFECState(std::map< unsigned int, PixelFECConfigInterface *> &pixelFECs, PixelDetectorConfig *detconfig, PixelNameTranslation *trans, std::map< pos::PixelModuleName, pos::PixelMaskBase *> *masks, std::map< pos::PixelModuleName, pos::PixelTrimBase *> *trims, std::map< pos::PixelModuleName, pos::PixelDACSettings *> *dacss, unsigned int state) const
std::string parameterValue(std::string parameterName) const
std::vector< unsigned int > scanValues(std::string dac) const
std::vector< std::pair< unsigned int, std::vector< unsigned int > > > fedCardsAndChannels_
std::string scanName(unsigned int iscan) const
PixelROCTrimBits * trims_
unsigned int scanROC(unsigned int state) const
This class provides the mapping between portcards and the modules controlled by the card...
std::set< unsigned int > getFECCrates(const PixelNameTranslation *translation, const PixelFECConfig *fecconfig) const
bool scanValuesMixedAcrossROCs(unsigned int iscan) const
const std::set< PixelChannel > & channelList() const
std::string mode() const override
void buildROCAndModuleLists(const PixelNameTranslation *translation, const PixelDetectorConfig *detconfig)
std::vector< PixelROCInfo > rocInfo_
bool containsScan(std::string name) const
This class specifies which FEC boards are used and how they are addressed.
void buildROCAndModuleListsFromROCSet(const std::set< PixelROCName > &rocSet)
unsigned int scanCounter(std::string dac, unsigned int state) const
std::ostream & operator<<(std::ostream &s, const PixelCalibConfiguration &calib)
assert(be >=bs)
std::vector< PixelDACScanRange > dacs_
unsigned int nScanPoints(unsigned int iscan) const
const std::set< PixelModuleName > & moduleList() const
void writeXML(pos::PixelConfigKey key, int version, std::string path) const override
This class provides a translation from the naming documents standard to specify the ROC to the corres...
This class implements..
std::vector< unsigned int > scanValues(unsigned int iscan) const
std::string getStreamedContent(void) const
unsigned int colCounter(unsigned int state) const
const PixelHdwAddress * hdwadd_
double scanValueStep(std::string dac) const
void disablePixels(PixelFECConfigInterface *pixelFEC, unsigned int irows, unsigned int icols, pos::PixelROCTrimBits *trims, const PixelHdwAddress &theROC) const
double scanValueMax(std::string dac) const
bool scanningROCForState(PixelROCName roc, unsigned int state) const
PixelCalibConfiguration(std::string filename="")
unsigned int iScan(std::string dac) const
This file contains the base class for "pixel configuration data" management.
std::vector< std::pair< unsigned int, unsigned int > > defaultDACs_
Base class for pixel calibration procedures.
void writeXMLTrailer(std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
This class intends to define an abstract interface for the commands to talk to the PixelFEC...
unsigned int numberOfScanVariables() const
This class specifies which TKFEC boards are used and how they are addressed.
unsigned int nScanPoints(std::string dac) const
std::map< unsigned int, std::set< unsigned int > > getFEDsAndChannels(PixelNameTranslation *translation)
unsigned int nTriggersPerPattern() const
This class implements the steps that are used in a scan over Threshold and CalDelay.
This class implements..
This is the documentation about PixelDetectorConfig...
const std::vector< std::vector< unsigned int > > & columnList() const
std::vector< std::pair< unsigned int, std::vector< unsigned int > > > & fedCardsAndChannels(unsigned int crate, PixelNameTranslation *translation, PixelFEDConfig *fedconfig, PixelDetectorConfig *detconfig) const
Store mfec, mfecchannel etc.
std::vector< std::string > rocListInstructions_
key
prepare the HTCondor submission files and eventually submit them
bool scanValuesMixedAcrossROCs(std::string dac) const
This class implements..
This class provide a base class for the pixel ROC dac data for the pixel FEC configuration.
This class implements..
PixelROCMaskBits * masks_
double scanValueMin(unsigned int iscan) const
double scanValueStep(unsigned int iscan) const
This class implements..
std::map< PixelROCName, unsigned int > ROCNumberOnChannelAmongThoseCalibrated_
void writeXMLHeader(pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
std::set< PixelModuleName > modules_
unsigned int rowCounter(unsigned int state) const
void writeASCII(std::string dir="") const override
This class provides a base class for the pixel trim data for the pixel FEC configuration.
const std::vector< PixelROCName > & rocList() const
This class implements..
std::map< std::string, std::string > parameters_
This is the documentation about PixelNameTranslation...
unsigned int scanValue(std::string dac, unsigned int state, PixelROCName roc) const
unsigned int numROCsCalibratedOnChannel(PixelROCName roc) const
This class implements..
Definition: PixelROCName.h:23
This class implements..
double scanValueMin(std::string dac) const
This is the documentation about PixelFEDConfig...
std::vector< PixelROCName > rocs_
void buildObjectsDependingOnTheNameTranslation(const PixelNameTranslation *aNameTranslation)
unsigned int scanValue(std::string dac, unsigned int state) const
std::map< PixelROCName, unsigned int > numROCsCalibratedOnChannel_
std::map< std::string, std::string > parametersList() const
This class specifies the settings on the TKPCIFEC and the settings on the portcard.
std::vector< std::vector< unsigned int > > cols_
std::set< unsigned int > getFEDCrates(const PixelNameTranslation *translation, const PixelFEDConfig *fedconfig) const
std::set< std::pair< unsigned int, unsigned int > > pixelsWithHits(unsigned int state) const
This class stores the name and related hardware mappings for a ROC.
const std::vector< std::vector< unsigned int > > & rowList() const