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_;
49  };
50 
51 
65  std::ostream& operator<<(std::ostream& s, const PixelCalibConfiguration& calib);
66 
68 
69  public:
70 
72  PixelCalibConfiguration(std::vector<std::vector<std::string> > &);
73 
74  virtual ~PixelCalibConfiguration();
75 
76  // This must be run before using commands that require the ROC list.
77  void buildROCAndModuleLists(const PixelNameTranslation* translation, const PixelDetectorConfig* detconfig);
78 
79  void nextFECState(std::map<unsigned int, PixelFECConfigInterface*>& pixelFECs,
80  PixelDetectorConfig* detconfig,
81  PixelNameTranslation* trans,
82  std::map<pos::PixelModuleName,pos::PixelMaskBase*>* masks,
83  std::map<pos::PixelModuleName,pos::PixelTrimBase*>* trims,
84  std::map<pos::PixelModuleName,pos::PixelDACSettings*>* dacss,
85  unsigned int state) const;
86 
87  //return vector of fed# and channels controlled by this fed supervisor
88  std::vector<std::pair<unsigned int,std::vector<unsigned int> > >& fedCardsAndChannels(unsigned int crate, PixelNameTranslation* translation, PixelFEDConfig* fedconfig,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, const std::map<std::string,PixelPortCardConfig*>& mapNamePortCard, const PixelTKFECConfig* tkfecconfig) const;
100 
101  unsigned int nROC() const { assert(rocAndModuleListsBuilt_); return nROC_; }
102  unsigned int nPixelPatterns() const { return rows_.size()*cols_.size(); }
103  unsigned int nTriggersPerPattern() const { return ntrigger_; }
104  unsigned int nScanPoints(std::string dac) const { return nScanPoints(iScan(dac)); }
105 
106  unsigned int nScanPoints() const {unsigned int points=1;
107  for(unsigned int i=0;i<dacs_.size();i++) {
108  points*=nScanPoints(i);
109  }
110  return points;
111  }
112  unsigned int nConfigurations() const { return nPixelPatterns()*nScanPoints()*nROC();}
113  unsigned int nTriggersTotal() const {return nConfigurations()*nTriggersPerPattern();}
114 
115  bool noHits() const {return (maxNumHitsPerROC()==0);} // returns true if no hits will be produced
116  unsigned int maxNumHitsPerROC() const; // returns the maximum number of hits that will be produced in any pixel pattern
117 
118  // Return all the pixels that are enabled for this state.
119  std::set< std::pair<unsigned int, unsigned int> > pixelsWithHits(unsigned int state) const;
120  // column # row #
121 
122  // Whether this ROC is currently being scanned. (Always true when not in SingleROC mode.)
123  bool scanningROCForState(PixelROCName roc, unsigned int state) const;
124 
125  unsigned int scanCounter(std::string dac, unsigned int state) const{
126  return scanCounter(iScan(dac),state);
127  }
128 
129  unsigned int scanValue(std::string dac, unsigned int state, PixelROCName roc) const {
130  return scanValue(iScan(dac), state, roc);
131  }
132 
133  // 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.
134  unsigned int scanValue(std::string dac, unsigned int state) const {
135  assert( !(dacs_[iScan(dac)].mixValuesAcrossROCs()) );
136  return scanValue(iScan(dac), state, 0, 1);
137  }
138 
139  unsigned int numberOfScanVariables() const {return dacs_.size();}
140 
141  bool containsScan(std::string name) const;
142 
143  std::string scanName(unsigned int iscan) const {return dacs_[iscan].name();}
144  std::vector<unsigned int> scanValues(std::string dac) const {return scanValues(iScan(dac));}
145 
146  double scanValueMin(std::string dac) const {return scanValueMin(iScan(dac));}
147  double scanValueMax(std::string dac) const {return scanValueMax(iScan(dac));}
148  double scanValueStep(std::string dac) const {return scanValueStep(iScan(dac));}
150 
151  unsigned int iScan(std::string dac) const;
152 
153  const std::vector<std::vector<unsigned int> > &columnList() const {return cols_;}
154  const std::vector<std::vector<unsigned int> > &rowList() const {return rows_;}
155  const std::vector<PixelROCName>& rocList() const {assert(rocAndModuleListsBuilt_); return rocs_;}
156  const std::set <PixelModuleName>& moduleList() const {assert(rocAndModuleListsBuilt_); return modules_;}
157  const std::set <PixelChannel>& channelList() const {assert( objectsDependingOnTheNameTranslationBuilt_ ); return channels_;}
158 
159  std::string mode() const {return mode_;}
160 
161  bool singleROC() const {return singleROC_;}
162 
163  unsigned int nParameters() const {return parameters_.size();}
164 
165  // Added by Dario Apr 24th, 2008
166  std::map<std::string, std::string> parametersList() const {return parameters_;}
167  // get the value of parameter parameterName, or "" if parameterName is not in the list
168  std::string parameterValue(std::string parameterName) const;
169 
170  // Added by Dario May 8th, 2008
172 
173  friend std::ostream& pos::operator<<(std::ostream& s, const PixelCalibConfiguration& calib);
174 
175  virtual void writeASCII(std::string dir="") const;
177  virtual void writeXMLHeader( pos::PixelConfigKey key,
178  int version,
179  std::string path,
180  std::ofstream *out,
181  std::ofstream *out1 = NULL,
182  std::ofstream *out2 = NULL
183  ) const ;
184  virtual void writeXML( std::ofstream *out,
185  std::ofstream *out1 = NULL ,
186  std::ofstream *out2 = NULL ) const ;
187  virtual void writeXMLTrailer( std::ofstream *out,
188  std::ofstream *out1 = NULL,
189  std::ofstream *out2 = NULL
190  ) const ;
191 
192 
193  private:
194 
195  // Which set of rows we're on.
196  unsigned int rowCounter(unsigned int state) const;
197 
198  // Which set of columns we're on.
199  unsigned int colCounter(unsigned int state) const;
200 
201  // In SingleROC mode, which ROC we're on. In normal mode, this equals 1.
202  unsigned int scanROC(unsigned int state) const;
203 
204  unsigned int nScanPoints(unsigned int iscan) const { return dacs_[iscan].getNPoints(); }
205 
206  unsigned int scanCounter(unsigned int iscan, unsigned int state) const;
207 
208  unsigned int scanValue(unsigned int iscan, unsigned int state, unsigned int ROCNumber, unsigned int ROCsOnChannel) const;
209  unsigned int scanValue(unsigned int iscan, unsigned int state, PixelROCName roc) const;
210 
211  std::vector<unsigned int> scanValues(unsigned int iscan) const {return dacs_[iscan].values();}
212 
213  double scanValueMin(unsigned int iscan) const {return dacs_[iscan].first();}
214  double scanValueMax(unsigned int iscan) const {return dacs_[iscan].first()+
215  dacs_[iscan].step()*(nScanPoints(iscan)-1);}
216  double scanValueStep(unsigned int iscan) const {return dacs_[iscan].step();}
217  bool scanValuesMixedAcrossROCs(unsigned int iscan) const {return dacs_[iscan].mixValuesAcrossROCs();}
218 
219  // Used in constructor or in buildROCAndModuleLists()
220  void buildROCAndModuleListsFromROCSet(const std::set<PixelROCName>& rocSet);
221 
223 
225  unsigned int numROCsCalibratedOnChannel(PixelROCName roc) const;
226 
228 
229  std::vector<std::vector<unsigned int> > rows_;
230  std::vector<std::vector<unsigned int> > cols_;
231 
232  mutable std::vector<PixelROCName> rocs_;
233  mutable std::vector<PixelROCInfo> rocInfo_;
234  std::set <PixelModuleName> modules_;
236  std::vector<std::string> rocListInstructions_;
237 
238  // Objects built using the name translation.
239  std::set <PixelChannel> channels_;
240  std::map <PixelROCName, unsigned int> ROCNumberOnChannelAmongThoseCalibrated_;
241  std::map <PixelROCName, unsigned int> numROCsCalibratedOnChannel_;
243 
244  mutable std::vector<std::pair<unsigned int, std::vector<unsigned int> > > fedCardsAndChannels_;
245 
246 
247  //unsigned int vcal_;
248 
249  std::vector<PixelDACScanRange> dacs_;
250 
251  //std::vector<std::string> dacname_;
252  //std::vector<unsigned int> dacchannel_;
253  //std::vector<unsigned int> dac_first_;
254  //std::vector<unsigned int> dac_last_;
255  //std::vector<unsigned int> dac_step_;
256 
257  unsigned int ntrigger_;
258  unsigned int nROC_; //This is the maximal #ROCs on a given TBM
259 
261 
262  void enablePixels(PixelFECConfigInterface* pixelFEC,
263  unsigned int irows, unsigned int icols,
264  pos::PixelROCMaskBits* masks,
265  pos::PixelROCTrimBits* trims,
266  const PixelHdwAddress& theROC) const;
267 
268  void disablePixels(PixelFECConfigInterface* pixelFEC,
269  unsigned int irows, unsigned int icols,
270  pos::PixelROCTrimBits* trims,
271  const PixelHdwAddress& theROC) const;
272 
273  void disablePixels(PixelFECConfigInterface* pixelFEC,
274  pos::PixelROCTrimBits* trims,
275  const PixelHdwAddress& theROC) const;
276 
277  mutable std::vector<int> old_irows;
278  mutable std::vector<int> old_icols;
279 
280  std::map<std::string, std::string> parameters_;
281  // name value
282 
284 
286 
287  // Added by Dario May 8th, 2008
289  };
290 }
291 /* @} */
292 #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.
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
void disablePixels(PixelFECConfigInterface *pixelFEC, unsigned int irows, unsigned int icols, pos::PixelROCTrimBits *trims, const PixelHdwAddress &theROC) 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_
assert(m_qm.get())
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::ostream & operator<<(std::ostream &s, const PixelCalibConfiguration &calib)
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..
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
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..
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
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
void enablePixels(PixelFECConfigInterface *pixelFEC, unsigned int irows, unsigned int icols, pos::PixelROCMaskBits *masks, pos::PixelROCTrimBits *trims, const PixelHdwAddress &theROC) 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...
bool scanValuesMixedAcrossROCs(unsigned int iscan) const
const std::vector< std::vector< unsigned int > > & rowList() const
This class implements..
Definition: PixelROCName.h:23
This class implements..
unsigned int nTriggersPerPattern() const
unsigned int scanROC(unsigned int state) const
This is the documentation about PixelFEDConfig...
std::vector< PixelROCName > rocs_
std::string scanName(unsigned int iscan) const
tuple filename
Definition: lut2db_cfg.py:20
std::string getStreamedContent(void) const
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:12