CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
CalibrationTask Class Reference

#include <CalibrationTask.h>

Inheritance diagram for CalibrationTask:
CommissioningTask

Public Member Functions

 CalibrationTask (DQMStore *, const FedChannelConnection &, const sistrip::RunType &, const char *filename, uint32_t run, const edm::EventSetup &setup)
 
virtual ~CalibrationTask ()
 
- Public Member Functions inherited from CommissioningTask
void bookHistograms ()
 
 CommissioningTask (DQMStore *, const FedChannelConnection &, const std::string &my_name)
 
void eventSetup (const edm::EventSetup *)
 
const uint32_t & fillCntr () const
 
void fillHistograms (const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &)
 
void fillHistograms (const SiStripEventSummary &, const uint16_t &fed_id, const std::map< uint16_t, float > &fed_ch)
 
const std::string & myName () const
 
const uint32_t & updateFreq () const
 
void updateFreq (const uint32_t &)
 
void updateHistograms ()
 
virtual ~CommissioningTask ()
 

Private Member Functions

virtual void book ()
 
void checkAndSave (const uint16_t &)
 
void directory (std::stringstream &, uint32_t run_number=0)
 
virtual void fill (const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &)
 
virtual void update ()
 

Private Attributes

MonitorElementcalchanElement_
 
std::vector< HistoSetcalib_
 
std::string filename_
 
uint16_t lastCalChan_
 
uint16_t nBins_
 
std::vector< uint16_t > ped
 
uint32_t run_
 
sistrip::RunType runType_
 

Additional Inherited Members

- Protected Member Functions inherited from CommissioningTask
const FedChannelConnectionconnection () const
 
DQMStore *const dqm () const
 
const edm::EventSetup *const eventSetup () const
 
const uint32_t & fecKey () const
 
const uint32_t & fedKey () const
 
void updateHistoSet (HistoSet &, const uint32_t &bin, const float &value)
 
void updateHistoSet (CompactHistoSet &, const uint32_t &bin, const short &value)
 
void updateHistoSet (HistoSet &, const uint32_t &bin)
 
void updateHistoSet (CompactHistoSet &, const uint32_t &bin)
 
void updateHistoSet (HistoSet &, const float &value)
 
void updateHistoSet (CompactHistoSet &)
 
void updateHistoSet (HistoSet &)
 

Detailed Description

Definition at line 10 of file CalibrationTask.h.

Constructor & Destructor Documentation

CalibrationTask::CalibrationTask ( DQMStore dqm,
const FedChannelConnection conn,
const sistrip::RunType rtype,
const char *  filename,
uint32_t  run,
const edm::EventSetup setup 
)

Definition at line 20 of file CalibrationTask.cc.

References FedChannelConnection::apvPairNumber(), FedChannelConnection::detId(), edm::EventSetup::get(), SiStripPedestals::getPed(), SiStripPedestals::getRange(), createfilelist::int, LogDebug, ped, and digi_MixPreMix_cfi::strip.

25  :
26  CommissioningTask( dqm, conn, "CalibrationTask" ),
27  runType_(rtype),
28  nBins_(65),lastCalChan_(8),
30  run_(run)
31 {
32  LogDebug("Commissioning") << "[CalibrationTask::CalibrationTask] Constructing object...";
33  // load the pedestals
34  edm::ESHandle<SiStripPedestals> pedestalsHandle;
35  setup.get<SiStripPedestalsRcd>().get(pedestalsHandle);
36  SiStripPedestals::Range detPedRange = pedestalsHandle->getRange(conn.detId());
37  int start = conn.apvPairNumber()*256;
38  int stop = start + 256;
39  int value = 0;
40  ped.reserve(256);
41  for(int strip = start; strip < stop; ++strip) {
42  value = int(pedestalsHandle->getPed(strip,detPedRange));
43  if(value>895) value -= 1024;
44  ped.push_back(value);
45  }
46 }
#define LogDebug(id)
Definition: start.py:1
uint16_t apvPairNumber() const
std::pair< ContainerIterator, ContainerIterator > Range
float getPed(const uint16_t &strip, const Range &range) const
const uint32_t & detId() const
uint16_t lastCalChan_
sistrip::RunType runType_
Definition: value.py:1
std::string filename_
std::vector< uint16_t > ped
const T & get() const
Definition: EventSetup.h:55
const Range getRange(const uint32_t &detID) const
CalibrationTask::~CalibrationTask ( )
virtual

Definition at line 50 of file CalibrationTask.cc.

References LogDebug.

50  {
51  LogDebug("Commissioning") << "[CalibrationTask::CalibrationTask] Destructing object...";
52 }
#define LogDebug(id)

Member Function Documentation

void CalibrationTask::book ( )
privatevirtual

Reimplemented from CommissioningTask.

Definition at line 56 of file CalibrationTask.cc.

References sistrip::APV, DQMStore::bookInt(), calchanElement_, calib_, CommissioningTask::connection(), sistrip::DET_KEY, CommissioningTask::dqm(), sistrip::EXPERT_HISTO, spr::find(), DQMStore::get(), DQMStore::getMEs(), mps_fire::i, LogDebug, nBins_, alignCSCRings::pwd, DQMStore::pwd(), sistrip::root_, runType_, DQMStore::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, fftjetcommon_cfi::title, and SiStripHistoTitle::title().

56  {
57  LogDebug("Commissioning") << "[CalibrationTask::book]";
58 
59  // book 32 histograms, one for each strip in a calibration group on 2 APVs
60  calib_.resize(32);
61  for(int apv=0;apv<2;++apv) {
62  for(int i=0;i<16;++i) {
64  runType_,
66  connection().detId(),
67  sistrip::APV,
68  connection().i2cAddr(apv) ).title();
69  std::stringstream complement;
70  complement << "_" << i ;
71  title += complement.str();
72  calib_[apv*16+i].histo( dqm()->book1D( title, title, nBins_, 0, 203.125) );
73  calib_[apv*16+i].isProfile_=false;
74  calib_[apv*16+i].vNumOfEntries_.resize(nBins_,0);
75  }
76  }
77 
78  // book the calchan values
79  std::string pwd = dqm()->pwd();
80  std::string rootDir = pwd.substr(0,pwd.find(std::string(sistrip::root_) + "/")+(sizeof(sistrip::root_) - 1));
81  dqm()->setCurrentFolder( rootDir );
82  std::vector<std::string> existingMEs = dqm()->getMEs();
83  if(find(existingMEs.begin(),existingMEs.end(),"calchan")!=existingMEs.end()) {
84  calchanElement_ = dqm()->get(dqm()->pwd()+"/calchan");
85  } else {
86  calchanElement_ = dqm()->bookInt("calchan");
87  }
88  dqm()->setCurrentFolder(pwd);
89 
90  LogDebug("Commissioning") << "[CalibrationTask::book] done";
91 
92 }
#define LogDebug(id)
Utility class that holds histogram title.
const std::string & title() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
sistrip::RunType runType_
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
Definition: DQMStore.cc:1789
DQMStore *const dqm() const
std::vector< std::string > getMEs(void) const
get list of (non-dir) MEs of current directory
Definition: DQMStore.cc:1763
static const char root_[]
const FedChannelConnection & connection() const
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:942
MonitorElement * calchanElement_
std::vector< HistoSet > calib_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:741
const std::string & pwd(void) const
Definition: DQMStore.cc:713
void CalibrationTask::checkAndSave ( const uint16_t &  calchan)
private

Definition at line 127 of file CalibrationTask.cc.

References sistrip::APV, calchanElement_, calib_, CommissioningTask::connection(), sistrip::DET_KEY, dir, directory(), CommissioningTask::dqm(), sistrip::EXPERT_HISTO, cmsPerfPublish::fail(), filename_, MonitorElement::Fill(), mps_fire::i, recoMuon::in, lastCalChan_, LogTrace, dataset::name, nBins_, NULL, run_, runType_, DQMStore::save(), AlCaHLTBitMon_QueryRunRegistry::string, fftjetcommon_cfi::title, and update().

Referenced by fill().

127  {
128  //for the first time
129  if(lastCalChan_==8) {
130  // set new parameter value
131  lastCalChan_ = calchan;
133  return;
134  }
135 
136  //check if CDRV register (ical) has changed
137  // in that case, save the histograms, reset them, change the title and continue
138  if(calchan!=lastCalChan_) {
139 
140  // set histograms before saving
141  update(); //TODO: we must do this for all tasks, otherwise only the first is updated.
142 
143  // change the title
144  for(int apv=0;apv<2;++apv) {
145  for(int i=0;i<16;++i) {
146  std::stringstream complement;
147  complement << "STRIP_" << (apv*128+lastCalChan_+i*8) ;
149  runType_,
151  connection().detId(),
152  sistrip::APV,
153  connection().i2cAddr(apv),
154  complement.str() ).title();
155  calib_[apv*16+i].histo()->setTitle(title);
156  calib_[apv*16+i].histo()->setAxisTitle(title);
157  }
158  }
159 
160  // Strip filename of ".root" extension
162  if ( filename_.find(".root",0) == std::string::npos ) { name = filename_; }
163  else { name = filename_.substr( 0, filename_.find(".root",0) ); }
164 
165  // Retrieve SCRATCH directory
166  std::string scratch = "SCRATCH"; //@@ remove trailing slash!!!
167  std::string dir = "";
168  if ( getenv(scratch.c_str()) != NULL ) {
169  dir = getenv(scratch.c_str());
170  }
171 
172  // Save file with appropriate filename
173  std::stringstream ss;
174  if ( !dir.empty() ) { ss << dir << "/"; }
175  else { ss << "/tmp/"; }
176  ss << name << "_";
177  directory(ss,run_); // Add filename with run number, host ip, pid and .root extension
178  ss << "_CALCHAN" << lastCalChan_; // Add CalChan value
179  ss << "_000"; // Add FU instance number (fake)
180  ss << ".root"; // Append ".root" extension
181  if ( !filename_.empty() ) {
182  if(std::ifstream(ss.str().c_str(),std::ifstream::in).fail()) { //save only once. Skip if the file already exist
183  dqm()->save( ss.str() );
184  LogTrace("DQMsource")
185  << "[SiStripCommissioningSource::" << __func__ << "]"
186  << " Saved all histograms to file \""
187  << ss.str() << "\"";
188  } else {
189  LogTrace("DQMsource")
190  << "[SiStripCommissioningSource::" << __func__ << "]"
191  << " Skipping creation of file \""
192  << ss.str() << "\" that already exists" ;
193  }
194  } else {
195  edm::LogWarning("DQMsource")
196  << "[SiStripCommissioningSource::" << __func__ << "]"
197  << " NULL value for filename! No root file saved!";
198  }
199 
200  // reset
201  for(std::vector<HistoSet>::iterator it=calib_.begin();it<calib_.end();++it) {
202  it->vNumOfEntries_.clear();
203  it->vNumOfEntries_.resize(nBins_,0);
204  }
205  // set new parameter values
206  lastCalChan_ = calchan;
207  calchanElement_->Fill(lastCalChan_);
208  }
209 }
virtual void update()
Utility class that holds histogram title.
#define NULL
Definition: scimark2.h:8
void directory(std::stringstream &, uint32_t run_number=0)
void Fill(long long x)
uint16_t lastCalChan_
sistrip::RunType runType_
#define LogTrace(id)
std::string filename_
DQMStore *const dqm() const
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
Definition: DQMStore.cc:2650
const FedChannelConnection & connection() const
dbl *** dir
Definition: mlp_gen.cc:35
def fail(errstr="")
MonitorElement * calchanElement_
std::vector< HistoSet > calib_
void CalibrationTask::directory ( std::stringstream &  dir,
uint32_t  run_number = 0 
)
private

Definition at line 213 of file CalibrationTask.cc.

References hcalSimParameters_cfi::he, sysUtil::pid, AlCaHLTBitMon_QueryRunRegistry::string, and tmp.

Referenced by checkAndSave().

214  {
215 
216  // Get details about host
217  char hn[256];
218  gethostname( hn, sizeof(hn) );
219  struct hostent* he;
220  he = gethostbyname(hn);
221 
222  // Extract host name and ip
223  std::string host_name;
224  std::string host_ip;
225  if ( he ) {
226  host_name = std::string(he->h_name);
227  host_ip = std::string( inet_ntoa( *(struct in_addr*)(he->h_addr) ) );
228  } else {
229  host_name = "unknown.cern.ch";
230  host_ip = "255.255.255.255";
231  }
232 
233  // Reformat IP address
235  std::stringstream ip;
236  //for ( uint16_t ii = 0; ii < 4; ++ii ) {
237  while ( pos != std::string::npos ) {
238  std::string::size_type tmp = host_ip.find(".",pos);
239  if ( tmp != std::string::npos ) {
240  ip << std::setw(3)
241  << std::setfill('0')
242  << host_ip.substr( pos, tmp-pos )
243  << ".";
244  pos = tmp+1; // skip the delimiter "."
245  } else {
246  ip << std::setw(3)
247  << std::setfill('0')
248  << host_ip.substr( pos );
249  pos = std::string::npos;
250  }
251  }
252 
253  // Get pid
254  pid_t pid = getpid();
255 
256  // Construct string
257  dir << std::setw(8)
258  << std::setfill('0')
259  << run_number
260  << "_"
261  << ip.str()
262  << "_"
263  << std::setw(5)
264  << std::setfill('0')
265  << pid;
266 }
uint16_t size_type
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
dbl *** dir
Definition: mlp_gen.cc:35
void CalibrationTask::fill ( const SiStripEventSummary summary,
const edm::DetSet< SiStripRawDigi > &  digis 
)
privatevirtual

Reimplemented from CommissioningTask.

Definition at line 96 of file CalibrationTask.cc.

References stringResolutionProvider_cfi::bin, SiStripEventSummary::calChan(), calib_, SiStripEventSummary::calSel(), checkAndSave(), edm::DetSet< T >::data, gen::k, SiStripEventSummary::latency(), LogDebug, ped, update(), and CommissioningTask::updateHistoSet().

97  {
98  LogDebug("Commissioning") << "[CalibrationTask::fill]";
99  // Check if CalChan changed. In that case, save, reset histo, change title, and continue
100  int isub,ical = summary.calChan();
101  isub = ical<4 ? ical+4 : ical-4;
102  checkAndSave(ical);
103  // retrieve the delay from the EventSummary
104  int bin = (100-summary.latency())*8+(7-summary.calSel());
105  // Fill the histograms.
106  // data-ped -(data-ped)_isub
107  // the second term corresponds to the common mode substraction, looking at a strip far away.
108  for (int apv=0; apv<2; ++apv) {
109  for (int k=0;k<16;++k) {
110  updateHistoSet( calib_[apv*16+k],bin,digis.data[apv*128+ical+k*8].adc()-ped[apv*128+ical+k*8]-(digis.data[apv*128+isub+k*8].adc()-ped[apv*128+isub+k*8]));
111  }
112  }
113  update(); //TODO: temporary: find a better solution later
114 }
#define LogDebug(id)
virtual void update()
const uint32_t & latency() const
void updateHistoSet(HistoSet &, const uint32_t &bin, const float &value)
int k[5][pyjets_maxn]
bin
set the eta bin as selection string.
const uint32_t & calSel() const
std::vector< uint16_t > ped
collection_type data
Definition: DetSet.h:78
const uint32_t & calChan() const
std::vector< HistoSet > calib_
void checkAndSave(const uint16_t &)
void CalibrationTask::update ( )
privatevirtual

Reimplemented from CommissioningTask.

Definition at line 118 of file CalibrationTask.cc.

References calib_, and CommissioningTask::updateHistoSet().

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), checkAndSave(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), fill(), dqm-mbProfile.Profile::finish(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

118  {
119  // LogDebug("Commissioning") << "[CalibrationTask::update]"; // huge output
120  for(std::vector<HistoSet>::iterator it=calib_.begin();it<calib_.end();++it) {
121  updateHistoSet( *it );
122  }
123 }
void updateHistoSet(HistoSet &, const uint32_t &bin, const float &value)
std::vector< HistoSet > calib_

Member Data Documentation

MonitorElement* CalibrationTask::calchanElement_
private

Definition at line 37 of file CalibrationTask.h.

Referenced by book(), and checkAndSave().

std::vector<HistoSet> CalibrationTask::calib_
private

Definition at line 30 of file CalibrationTask.h.

Referenced by book(), checkAndSave(), fill(), and update().

std::string CalibrationTask::filename_
private

Definition at line 34 of file CalibrationTask.h.

Referenced by checkAndSave().

uint16_t CalibrationTask::lastCalChan_
private

Definition at line 33 of file CalibrationTask.h.

Referenced by checkAndSave().

uint16_t CalibrationTask::nBins_
private

Definition at line 32 of file CalibrationTask.h.

Referenced by book(), and checkAndSave().

std::vector<uint16_t> CalibrationTask::ped
private

Definition at line 35 of file CalibrationTask.h.

Referenced by CalibrationTask(), and fill().

uint32_t CalibrationTask::run_
private

Definition at line 36 of file CalibrationTask.h.

Referenced by checkAndSave().

sistrip::RunType CalibrationTask::runType_
private

Definition at line 28 of file CalibrationTask.h.

Referenced by book(), and checkAndSave().