CMS 3D CMS Logo

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