CMS 3D CMS Logo

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

#include <CalibrationScanTask.h>

Inheritance diagram for CalibrationScanTask:
CommissioningTask

Public Member Functions

 CalibrationScanTask (DQMStore *, const FedChannelConnection &, const sistrip::RunType &, const char *filename, uint32_t run, const edm::EventSetup &setup)
 
virtual ~CalibrationScanTask ()
 
- 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 &isha, const uint16_t &vfs)
 
void directory (std::stringstream &, uint32_t run_number=0)
 
virtual void fill (const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &)
 
virtual void update ()
 

Private Attributes

MonitorElementcalchanElement_
 
HistoSet calib1_
 
HistoSet calib2_
 
std::string filename_
 
MonitorElementishaElement_
 
uint16_t lastCalchan_
 
uint16_t lastISHA_
 
uint16_t lastVFS_
 
uint16_t nBins_
 
std::vector< uint16_t > ped
 
uint32_t run_
 
sistrip::RunType runType_
 
MonitorElementvfsElement_
 

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 CalibrationScanTask.h.

Constructor & Destructor Documentation

CalibrationScanTask::CalibrationScanTask ( 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 CalibrationScanTask.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, "CalibrationScanTask" ),
27  runType_(rtype),
28  calib1_(),calib2_(),
29  nBins_(65),lastISHA_(1000),lastVFS_(1000),lastCalchan_(1000),
31  run_(run)
32 {
33  LogDebug("Commissioning") << "[CalibrationScanTask::CalibrationScanTask] Constructing object...";
34  // load the pedestals
35  edm::ESHandle<SiStripPedestals> pedestalsHandle;
36  setup.get<SiStripPedestalsRcd>().get(pedestalsHandle);
37  SiStripPedestals::Range detPedRange = pedestalsHandle->getRange(conn.detId());
38  int start = conn.apvPairNumber()*256;
39  int stop = start + 256;
40  int value = 0;
41  ped.reserve(256);
42  LogDebug("Commissioning") << "[CalibrationScanTask::CalibrationScanTask] Loading pedestal for " << conn.detId();
43  if(conn.detId()==0) return;
44  for(int strip = start; strip < stop; ++strip) {
45  value = int(pedestalsHandle->getPed(strip,detPedRange));
46  if(value>895) value -= 1024;
47  ped.push_back(value);
48  }
49 }
#define LogDebug(id)
Definition: start.py:1
sistrip::RunType runType_
uint16_t apvPairNumber() const
std::pair< ContainerIterator, ContainerIterator > Range
std::vector< uint16_t > ped
float getPed(const uint16_t &strip, const Range &range) const
const uint32_t & detId() const
Definition: value.py:1
const T & get() const
Definition: EventSetup.h:56
const Range getRange(const uint32_t &detID) const
CalibrationScanTask::~CalibrationScanTask ( )
virtual

Definition at line 53 of file CalibrationScanTask.cc.

References LogDebug.

53  {
54  LogDebug("Commissioning") << "[CalibrationScanTask::CalibrationScanTask] Destructing object...";
55 }
#define LogDebug(id)

Member Function Documentation

void CalibrationScanTask::book ( )
privatevirtual

Reimplemented from CommissioningTask.

Definition at line 59 of file CalibrationScanTask.cc.

References sistrip::APV, DQMStore::bookInt(), calchanElement_, calib1_, calib2_, CommissioningTask::connection(), sistrip::DET_KEY, CommissioningTask::dqm(), sistrip::EXPERT_HISTO, spr::find(), DQMStore::get(), DQMStore::getMEs(), CommissioningTask::HistoSet::histo(), ishaElement_, CommissioningTask::HistoSet::isProfile_, LogDebug, nBins_, alignCSCRings::pwd, DQMStore::pwd(), sistrip::root_, runType_, DQMStore::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, SiStripHistoTitle::title(), vfsElement_, and CommissioningTask::HistoSet::vNumOfEntries_.

59  {
60  LogDebug("Commissioning") << "[CalibrationScanTask::book]";
61 
62  // construct the histo titles and book two histograms: one per APV
64  runType_,
66  connection().detId(),
67  sistrip::APV,
68  connection().i2cAddr(0) ).title();
69  calib1_.histo( dqm()->book1D( title1, title1, nBins_, 0, 203.125) );
70  calib1_.isProfile_=false;
71  calib1_.vNumOfEntries_.resize(nBins_,0);
73  runType_,
75  connection().detId(),
76  sistrip::APV,
77  connection().i2cAddr(1) ).title();
78  calib2_.histo( dqm()->book1D( title2, title2, nBins_, 0, 203.125) );
79  calib2_.isProfile_=false;
80  calib2_.vNumOfEntries_.resize(nBins_,0);
81 
82  // book the isha, vfs values
83  std::string pwd = dqm()->pwd();
84  std::string rootDir = pwd.substr(0,pwd.find(std::string(sistrip::root_) + "/")+(sizeof(sistrip::root_) - 1));
85  dqm()->setCurrentFolder( rootDir );
86  std::vector<std::string> existingMEs = dqm()->getMEs();
87  if(find(existingMEs.begin(),existingMEs.end(),"isha")!=existingMEs.end()) {
88  ishaElement_ = dqm()->get(dqm()->pwd()+"/isha");
89  } else {
90  ishaElement_ = dqm()->bookInt("isha");
91  }
92  if(find(existingMEs.begin(),existingMEs.end(),"isha")!=existingMEs.end()) {
93  vfsElement_ = dqm()->get(dqm()->pwd()+"/vfs");
94  } else {
95  vfsElement_ = dqm()->bookInt("vfs");
96  }
97  if(find(existingMEs.begin(),existingMEs.end(),"calchan")!=existingMEs.end()) {
98  calchanElement_ = dqm()->get(dqm()->pwd()+"/calchan");
99  } else {
100  calchanElement_ = dqm()->bookInt("calchan");
101  }
102 
103  LogDebug("Commissioning") << "[CalibrationScanTask::book] done";
104 
105 }
#define LogDebug(id)
std::vector< float > vNumOfEntries_
Utility class that holds histogram title.
const std::string & title() const
sistrip::RunType runType_
MonitorElement * vfsElement_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
Definition: DQMStore.cc:1788
MonitorElement * ishaElement_
DQMStore *const dqm() const
std::vector< std::string > getMEs(void) const
get list of (non-dir) MEs of current directory
Definition: DQMStore.cc:1762
MonitorElement * calchanElement_
void histo(MonitorElement *)
static const char root_[]
const FedChannelConnection & connection() const
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:941
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:740
const std::string & pwd(void) const
Definition: DQMStore.cc:712
void CalibrationScanTask::checkAndSave ( const uint16_t &  isha,
const uint16_t &  vfs 
)
private

Definition at line 143 of file CalibrationScanTask.cc.

References sistrip::APV, calchanElement_, calib1_, calib2_, CommissioningTask::connection(), sistrip::DET_KEY, dir, directory(), CommissioningTask::dqm(), sistrip::EXPERT_HISTO, cmsPerfPublish::fail(), filename_, MonitorElement::Fill(), CommissioningTask::HistoSet::histo(), recoMuon::in, ishaElement_, lastCalchan_, lastISHA_, lastVFS_, LogTrace, dataset::name, nBins_, NULL, run_, runType_, DQMStore::save(), AlCaHLTBitMon_QueryRunRegistry::string, fftjetcommon_cfi::title, update(), vfsElement_, and CommissioningTask::HistoSet::vNumOfEntries_.

Referenced by fill().

143  {
144  //for the first time
145  if(lastISHA_==1000 && lastVFS_==1000) {
146  lastISHA_ = isha;
147  lastVFS_ = vfs;
148  }
149 
150  // set the calchan value in the correspond string
154 
155  // check if ISHA/VFS has changed
156  // in that case, save the histograms, reset them, change the title and continue
157  if(lastISHA_!=isha || lastVFS_!=vfs) {
158 
159  // set histograms before saving
160  update(); //TODO: we must do this for all tasks, otherwise only the first is updated.
161 
162  // change the title
163  std::stringstream complement;
164  complement << "ISHA" << isha << "_VFS" << vfs;
166  runType_,
168  connection().detId(),
169  sistrip::APV,
170  connection().i2cAddr(0),
171  complement.str() ).title();
172  calib1_.histo()->setTitle(title1);
173 
175  runType_,
177  connection().detId(),
178  sistrip::APV,
179  connection().i2cAddr(1),
180  complement.str() ).title();
181  calib2_.histo()->setTitle(title2);
182 
183  // Strip filename of ".root" extension
185  if ( filename_.find(".root",0) == std::string::npos ) { name = filename_; }
186  else { name = filename_.substr( 0, filename_.find(".root",0) ); }
187 
188  // Retrieve SCRATCH directory
189  std::string scratch = "SCRATCH"; //@@ remove trailing slash!!!
190  std::string dir = "";
191  if ( getenv(scratch.c_str()) != NULL ) {
192  dir = getenv(scratch.c_str());
193  }
194 
195  // Save file with appropriate filename
196  std::stringstream ss;
197  if ( !dir.empty() ) { ss << dir << "/"; }
198  else { ss << "/tmp/"; }
199  ss << name << "_";
200  directory(ss,run_); // Add filename with run number, host ip, pid and .root extension
201  ss << "_ISHA" << lastISHA_ << "_VFS" << lastVFS_; // Add ISHA and VFS values
202  ss << "_000"; // Add FU instance number (fake)
203  ss << ".root"; // Append ".root" extension
204  if ( !filename_.empty() ) {
205  if(std::ifstream(ss.str().c_str(),std::ifstream::in).fail()) { //save only once. Skip if the file already exist
206  dqm()->save( ss.str() );
207  LogTrace("DQMsource")
208  << "[SiStripCommissioningSource::" << __func__ << "]"
209  << " Saved all histograms to file \""
210  << ss.str() << "\"";
211  } else {
212  LogTrace("DQMsource")
213  << "[SiStripCommissioningSource::" << __func__ << "]"
214  << " Skipping creation of file \""
215  << ss.str() << "\" that already exists" ;
216  }
217  } else {
218  edm::LogWarning("DQMsource")
219  << "[SiStripCommissioningSource::" << __func__ << "]"
220  << " NULL value for filename! No root file saved!";
221  }
222 
223  // reset
224  calib1_.vNumOfEntries_.clear();
225  calib1_.vNumOfEntries_.resize(nBins_,0);
226  calib2_.vNumOfEntries_.clear();
227  calib2_.vNumOfEntries_.resize(nBins_,0);
228 
229  // set new parameter values
230  lastISHA_=isha;
231  lastVFS_=vfs;
232  // set the calchan value in the correspond string
234  vfsElement_->Fill(lastVFS_);
236  }
237 }
std::vector< float > vNumOfEntries_
Utility class that holds histogram title.
sistrip::RunType runType_
MonitorElement * vfsElement_
#define NULL
Definition: scimark2.h:8
void Fill(long long x)
void directory(std::stringstream &, uint32_t run_number=0)
#define LogTrace(id)
MonitorElement * ishaElement_
DQMStore *const dqm() const
MonitorElement * calchanElement_
void histo(MonitorElement *)
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:2649
const FedChannelConnection & connection() const
dbl *** dir
Definition: mlp_gen.cc:35
def fail(errstr="")
void CalibrationScanTask::directory ( std::stringstream &  dir,
uint32_t  run_number = 0 
)
private

Definition at line 241 of file CalibrationScanTask.cc.

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

Referenced by checkAndSave().

242  {
243 
244  // Get details about host
245  char hn[256];
246  gethostname( hn, sizeof(hn) );
247  struct hostent* he;
248  he = gethostbyname(hn);
249 
250  // Extract host name and ip
251  std::string host_name;
252  std::string host_ip;
253  if ( he ) {
254  host_name = std::string(he->h_name);
255  host_ip = std::string( inet_ntoa( *(struct in_addr*)(he->h_addr) ) );
256  } else {
257  host_name = "unknown.cern.ch";
258  host_ip = "255.255.255.255";
259  }
260 
261  // Reformat IP address
263  std::stringstream ip;
264  //for ( uint16_t ii = 0; ii < 4; ++ii ) {
265  while ( pos != std::string::npos ) {
266  std::string::size_type tmp = host_ip.find(".",pos);
267  if ( tmp != std::string::npos ) {
268  ip << std::setw(3)
269  << std::setfill('0')
270  << host_ip.substr( pos, tmp-pos )
271  << ".";
272  pos = tmp+1; // skip the delimiter "."
273  } else {
274  ip << std::setw(3)
275  << std::setfill('0')
276  << host_ip.substr( pos );
277  pos = std::string::npos;
278  }
279  }
280 
281  // Get pid
282  pid_t pid = getpid();
283 
284  // Construct string
285  dir << std::setw(8)
286  << std::setfill('0')
287  << run_number
288  << "_"
289  << ip.str()
290  << "_"
291  << std::setw(5)
292  << std::setfill('0')
293  << pid;
294 
295 }
uint16_t size_type
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
dbl *** dir
Definition: mlp_gen.cc:35
void CalibrationScanTask::fill ( const SiStripEventSummary summary,
const edm::DetSet< SiStripRawDigi > &  digis 
)
privatevirtual

Reimplemented from CommissioningTask.

Definition at line 109 of file CalibrationScanTask.cc.

References stringResolutionProvider_cfi::bin, SiStripEventSummary::calChan(), calib1_, calib2_, SiStripEventSummary::calSel(), checkAndSave(), edm::DetSet< T >::data, SiStripEventSummary::isha(), gen::k, lastCalchan_, SiStripEventSummary::latency(), ped, update(), CommissioningTask::updateHistoSet(), and SiStripEventSummary::vfs().

110  {
111 // LogDebug("Commissioning") << "[CalibrationScanTask::fill]: isha/vfs = " << summary.isha() << "/" << summary.vfs();
112  // Check if ISHA/VFS changed. In that case, save, reset histo, change title, and continue
113  checkAndSave(summary.isha(),summary.vfs());
114  // retrieve the delay from the EventSummary
115  int bin = (100-summary.latency())*8+(7-summary.calSel());
116  // loop on the strips to fill the histogram
117  // digis are obtained for an APV pair.
118  // strips 0->127 : calib1_
119  // strips 128->255: calib2_
120  // then, only some strips are fired at a time.
121  // We use calChan to know that
122  int isub,ical = summary.calChan();
123  isub = ical<4 ? ical+4 : ical-4;
124  lastCalchan_ = ical;
125  for (int k=0;k<16;++k) {
126  // all strips of the APV are merged in
127  updateHistoSet( calib1_,bin,digis.data[ical+k*8].adc()-ped[ical+k*8]-(digis.data[isub+k*8].adc()-ped[isub+k*8]));
128  updateHistoSet( calib2_,bin,digis.data[128+ical+k*8].adc()-ped[128+ical+k*8]-(digis.data[128+isub+k*8].adc()-ped[128+isub+k*8]));
129  }
130  update(); //TODO: temporary: find a better solution later
131 }
const uint32_t & vfs() const
const uint32_t & latency() const
std::vector< uint16_t > ped
const uint32_t & isha() const
void updateHistoSet(HistoSet &, const uint32_t &bin, const float &value)
int k[5][pyjets_maxn]
bin
set the eta bin as selection string.
void checkAndSave(const uint16_t &isha, const uint16_t &vfs)
const uint32_t & calSel() const
collection_type data
Definition: DetSet.h:78
const uint32_t & calChan() const
void CalibrationScanTask::update ( )
privatevirtual

Reimplemented from CommissioningTask.

Definition at line 135 of file CalibrationScanTask.cc.

References calib1_, calib2_, 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().

135  {
136  // LogDebug("Commissioning") << "[CalibrationScanTask::update]"; // huge output
139 }
void updateHistoSet(HistoSet &, const uint32_t &bin, const float &value)

Member Data Documentation

MonitorElement * CalibrationScanTask::calchanElement_
private

Definition at line 36 of file CalibrationScanTask.h.

Referenced by book(), and checkAndSave().

HistoSet CalibrationScanTask::calib1_
private

Definition at line 29 of file CalibrationScanTask.h.

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

HistoSet CalibrationScanTask::calib2_
private

Definition at line 29 of file CalibrationScanTask.h.

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

std::string CalibrationScanTask::filename_
private

Definition at line 33 of file CalibrationScanTask.h.

Referenced by checkAndSave().

MonitorElement* CalibrationScanTask::ishaElement_
private

Definition at line 36 of file CalibrationScanTask.h.

Referenced by book(), and checkAndSave().

uint16_t CalibrationScanTask::lastCalchan_
private

Definition at line 32 of file CalibrationScanTask.h.

Referenced by checkAndSave(), and fill().

uint16_t CalibrationScanTask::lastISHA_
private

Definition at line 32 of file CalibrationScanTask.h.

Referenced by checkAndSave().

uint16_t CalibrationScanTask::lastVFS_
private

Definition at line 32 of file CalibrationScanTask.h.

Referenced by checkAndSave().

uint16_t CalibrationScanTask::nBins_
private

Definition at line 31 of file CalibrationScanTask.h.

Referenced by book(), and checkAndSave().

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

Definition at line 34 of file CalibrationScanTask.h.

Referenced by CalibrationScanTask(), and fill().

uint32_t CalibrationScanTask::run_
private

Definition at line 35 of file CalibrationScanTask.h.

Referenced by checkAndSave().

sistrip::RunType CalibrationScanTask::runType_
private

Definition at line 27 of file CalibrationScanTask.h.

Referenced by book(), and checkAndSave().

MonitorElement * CalibrationScanTask::vfsElement_
private

Definition at line 36 of file CalibrationScanTask.h.

Referenced by book(), and checkAndSave().