#include <DQM/SiStripCommissioningSources/interface/CalibrationScanTask.h>
Public Member Functions | |
CalibrationScanTask (DQMStore *, const FedChannelConnection &, const sistrip::RunType &, const char *filename, uint32_t run, const edm::EventSetup &setup) | |
virtual | ~CalibrationScanTask () |
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 | |
MonitorElement * | calchanElement_ |
HistoSet | calib1_ |
HistoSet | calib2_ |
std::string | filename_ |
MonitorElement * | ishaElement_ |
uint16_t | lastCalchan_ |
uint16_t | lastISHA_ |
uint16_t | lastVFS_ |
uint16_t | nBins_ |
std::vector< uint16_t > | ped |
uint32_t | run_ |
sistrip::RunType | runType_ |
MonitorElement * | vfsElement_ |
Definition at line 10 of file CalibrationScanTask.h.
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(), int, LogDebug, ped, strip(), and value.
00025 : 00026 CommissioningTask( dqm, conn, "CalibrationScanTask" ), 00027 runType_(rtype), 00028 calib1_(),calib2_(), 00029 nBins_(65),lastISHA_(1000),lastVFS_(1000),lastCalchan_(1000), 00030 filename_(filename), 00031 run_(run) 00032 { 00033 LogDebug("Commissioning") << "[CalibrationScanTask::CalibrationScanTask] Constructing object..."; 00034 // load the pedestals 00035 edm::ESHandle<SiStripPedestals> pedestalsHandle; 00036 setup.get<SiStripPedestalsRcd>().get(pedestalsHandle); 00037 SiStripPedestals::Range detPedRange = pedestalsHandle->getRange(conn.detId()); 00038 int start = conn.apvPairNumber()*256; 00039 int stop = start + 256; 00040 int value = 0; 00041 ped.reserve(256); 00042 LogDebug("Commissioning") << "[CalibrationScanTask::CalibrationScanTask] Loading pedestal for " << conn.detId(); 00043 if(conn.detId()==0) return; 00044 for(int strip = start; strip < stop; ++strip) { 00045 value = int(pedestalsHandle->getPed(strip,detPedRange)); 00046 if(value>895) value -= 1024; 00047 ped.push_back(value); 00048 } 00049 }
CalibrationScanTask::~CalibrationScanTask | ( | ) | [virtual] |
Definition at line 53 of file CalibrationScanTask.cc.
References LogDebug.
00053 { 00054 LogDebug("Commissioning") << "[CalibrationScanTask::CalibrationScanTask] Destructing object..."; 00055 }
void CalibrationScanTask::book | ( | ) | [private, virtual] |
Reimplemented from CommissioningTask.
Definition at line 59 of file CalibrationScanTask.cc.
References sistrip::APV, DQMStore::bookInt(), calchanElement_, calib1_, calib2_, CommissioningTask::connection(), sistrip::DET_KEY, detId, CommissioningTask::dqm(), sistrip::EXPERT_HISTO, find(), DQMStore::get(), DQMStore::getMEs(), CommissioningTask::HistoSet::histo(), ishaElement_, CommissioningTask::HistoSet::isProfile_, LogDebug, nBins_, DQMStore::pwd(), sistrip::root_, runType_, DQMStore::setCurrentFolder(), vfsElement_, and CommissioningTask::HistoSet::vNumOfEntries_.
00059 { 00060 LogDebug("Commissioning") << "[CalibrationScanTask::book]"; 00061 00062 // construct the histo titles and book two histograms: one per APV 00063 std::string title1 = SiStripHistoTitle( sistrip::EXPERT_HISTO, 00064 runType_, 00065 sistrip::DET_KEY, 00066 connection().detId(), 00067 sistrip::APV, 00068 connection().i2cAddr(0) ).title(); 00069 calib1_.histo( dqm()->book1D( title1, title1, nBins_, 0, 203.125) ); 00070 calib1_.isProfile_=false; 00071 calib1_.vNumOfEntries_.resize(nBins_,0); 00072 std::string title2 = SiStripHistoTitle( sistrip::EXPERT_HISTO, 00073 runType_, 00074 sistrip::DET_KEY, 00075 connection().detId(), 00076 sistrip::APV, 00077 connection().i2cAddr(1) ).title(); 00078 calib2_.histo( dqm()->book1D( title2, title2, nBins_, 0, 203.125) ); 00079 calib2_.isProfile_=false; 00080 calib2_.vNumOfEntries_.resize(nBins_,0); 00081 00082 // book the isha, vfs values 00083 std::string pwd = dqm()->pwd(); 00084 std::string rootDir = pwd.substr(0,pwd.find(sistrip::root_ + "/")+sistrip::root_.size()); 00085 dqm()->setCurrentFolder( rootDir ); 00086 std::vector<std::string> existingMEs = dqm()->getMEs(); 00087 if(find(existingMEs.begin(),existingMEs.end(),"isha")!=existingMEs.end()) { 00088 ishaElement_ = dqm()->get(dqm()->pwd()+"/isha"); 00089 } else { 00090 ishaElement_ = dqm()->bookInt("isha"); 00091 } 00092 if(find(existingMEs.begin(),existingMEs.end(),"isha")!=existingMEs.end()) { 00093 vfsElement_ = dqm()->get(dqm()->pwd()+"/vfs"); 00094 } else { 00095 vfsElement_ = dqm()->bookInt("vfs"); 00096 } 00097 if(find(existingMEs.begin(),existingMEs.end(),"calchan")!=existingMEs.end()) { 00098 calchanElement_ = dqm()->get(dqm()->pwd()+"/calchan"); 00099 } else { 00100 calchanElement_ = dqm()->bookInt("calchan"); 00101 } 00102 00103 LogDebug("Commissioning") << "[CalibrationScanTask::book] done"; 00104 00105 }
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, detId, dir, directory(), CommissioningTask::dqm(), sistrip::EXPERT_HISTO, cmsPerfPublish::fail(), filename_, MonitorElement::Fill(), CommissioningTask::HistoSet::histo(), in, ishaElement_, lastCalchan_, lastISHA_, lastVFS_, LogTrace, name, nBins_, NULL, run_, runType_, DQMStore::save(), ss, indexGen::title, update(), vfsElement_, and CommissioningTask::HistoSet::vNumOfEntries_.
Referenced by fill().
00143 { 00144 //for the first time 00145 if(lastISHA_==1000 && lastVFS_==1000) { 00146 lastISHA_ = isha; 00147 lastVFS_ = vfs; 00148 } 00149 00150 // set the calchan value in the correspond string 00151 ishaElement_->Fill(lastISHA_); 00152 vfsElement_->Fill(lastVFS_); 00153 calchanElement_->Fill(lastCalchan_); 00154 00155 // check if ISHA/VFS has changed 00156 // in that case, save the histograms, reset them, change the title and continue 00157 if(lastISHA_!=isha || lastVFS_!=vfs) { 00158 00159 // set histograms before saving 00160 update(); //TODO: we must do this for all tasks, otherwise only the first is updated. 00161 00162 // change the title 00163 std::stringstream complement; 00164 complement << "ISHA" << isha << "_VFS" << vfs; 00165 std::string title1 = SiStripHistoTitle( sistrip::EXPERT_HISTO, 00166 runType_, 00167 sistrip::DET_KEY, 00168 connection().detId(), 00169 sistrip::APV, 00170 connection().i2cAddr(0), 00171 complement.str() ).title(); 00172 calib1_.histo()->setTitle(title1); 00173 00174 std::string title2 = SiStripHistoTitle( sistrip::EXPERT_HISTO, 00175 runType_, 00176 sistrip::DET_KEY, 00177 connection().detId(), 00178 sistrip::APV, 00179 connection().i2cAddr(1), 00180 complement.str() ).title(); 00181 calib2_.histo()->setTitle(title2); 00182 00183 // Strip filename of ".root" extension 00184 std::string name; 00185 if ( filename_.find(".root",0) == std::string::npos ) { name = filename_; } 00186 else { name = filename_.substr( 0, filename_.find(".root",0) ); } 00187 00188 // Retrieve SCRATCH directory 00189 std::string scratch = "SCRATCH"; //@@ remove trailing slash!!! 00190 std::string dir = ""; 00191 if ( getenv(scratch.c_str()) != NULL ) { 00192 dir = getenv(scratch.c_str()); 00193 } 00194 00195 // Save file with appropriate filename 00196 std::stringstream ss; 00197 if ( !dir.empty() ) { ss << dir << "/"; } 00198 else { ss << "/tmp/"; } 00199 ss << name << "_"; 00200 directory(ss,run_); // Add filename with run number, host ip, pid and .root extension 00201 ss << "_ISHA" << lastISHA_ << "_VFS" << lastVFS_; // Add ISHA and VFS values 00202 ss << "_000"; // Add FU instance number (fake) 00203 ss << ".root"; // Append ".root" extension 00204 if ( !filename_.empty() ) { 00205 if(ifstream(ss.str().c_str(),ifstream::in).fail()) { //save only once. Skip if the file already exist 00206 dqm()->save( ss.str() ); 00207 LogTrace("DQMsource") 00208 << "[SiStripCommissioningSource::" << __func__ << "]" 00209 << " Saved all histograms to file \"" 00210 << ss.str() << "\""; 00211 } else { 00212 LogTrace("DQMsource") 00213 << "[SiStripCommissioningSource::" << __func__ << "]" 00214 << " Skipping creation of file \"" 00215 << ss.str() << "\" that already exists" ; 00216 } 00217 } else { 00218 edm::LogWarning("DQMsource") 00219 << "[SiStripCommissioningSource::" << __func__ << "]" 00220 << " NULL value for filename! No root file saved!"; 00221 } 00222 00223 // reset 00224 calib1_.vNumOfEntries_.clear(); 00225 calib1_.vNumOfEntries_.resize(nBins_,0); 00226 calib2_.vNumOfEntries_.clear(); 00227 calib2_.vNumOfEntries_.resize(nBins_,0); 00228 00229 // set new parameter values 00230 lastISHA_=isha; 00231 lastVFS_=vfs; 00232 // set the calchan value in the correspond string 00233 ishaElement_->Fill(lastISHA_); 00234 vfsElement_->Fill(lastVFS_); 00235 calchanElement_->Fill(lastCalchan_); 00236 } 00237 }
void CalibrationScanTask::directory | ( | std::stringstream & | dir, | |
uint32_t | run_number = 0 | |||
) | [private] |
Definition at line 241 of file CalibrationScanTask.cc.
References gethostname(), and tmp.
Referenced by checkAndSave().
00242 { 00243 00244 // Get details about host 00245 char hn[256]; 00246 gethostname( hn, sizeof(hn) ); 00247 struct hostent* he; 00248 he = gethostbyname(hn); 00249 00250 // Extract host name and ip 00251 std::string host_name; 00252 std::string host_ip; 00253 if ( he ) { 00254 host_name = std::string(he->h_name); 00255 host_ip = std::string( inet_ntoa( *(struct in_addr*)(he->h_addr) ) ); 00256 } else { 00257 host_name = "unknown.cern.ch"; 00258 host_ip = "255.255.255.255"; 00259 } 00260 00261 // Reformat IP address 00262 std::string::size_type pos = 0; 00263 std::stringstream ip; 00264 //for ( uint16_t ii = 0; ii < 4; ++ii ) { 00265 while ( pos != std::string::npos ) { 00266 std::string::size_type tmp = host_ip.find(".",pos); 00267 if ( tmp != std::string::npos ) { 00268 ip << std::setw(3) 00269 << std::setfill('0') 00270 << host_ip.substr( pos, tmp-pos ) 00271 << "."; 00272 pos = tmp+1; // skip the delimiter "." 00273 } else { 00274 ip << std::setw(3) 00275 << std::setfill('0') 00276 << host_ip.substr( pos ); 00277 pos = std::string::npos; 00278 } 00279 } 00280 00281 // Get pid 00282 pid_t pid = getpid(); 00283 00284 // Construct string 00285 dir << std::setw(8) 00286 << std::setfill('0') 00287 << run_number 00288 << "_" 00289 << ip.str() 00290 << "_" 00291 << std::setw(5) 00292 << std::setfill('0') 00293 << pid; 00294 00295 }
void CalibrationScanTask::fill | ( | const SiStripEventSummary & | summary, | |
const edm::DetSet< SiStripRawDigi > & | digis | |||
) | [private, virtual] |
Reimplemented from CommissioningTask.
Definition at line 109 of file CalibrationScanTask.cc.
References SiStripEventSummary::calChan(), calib1_, calib2_, SiStripEventSummary::calSel(), checkAndSave(), edm::DetSet< T >::data, SiStripEventSummary::isha(), k, lastCalchan_, SiStripEventSummary::latency(), LogDebug, ped, update(), CommissioningTask::updateHistoSet(), and SiStripEventSummary::vfs().
00110 { 00111 LogDebug("Commissioning") << "[CalibrationScanTask::fill]: isha/vfs = " << summary.isha() << "/" << summary.vfs(); 00112 // Check if ISHA/VFS changed. In that case, save, reset histo, change title, and continue 00113 checkAndSave(summary.isha(),summary.vfs()); 00114 // retrieve the delay from the EventSummary 00115 int bin = (100-summary.latency())*8+(7-summary.calSel()); 00116 // loop on the strips to fill the histogram 00117 // digis are obtained for an APV pair. 00118 // strips 0->127 : calib1_ 00119 // strips 128->255: calib2_ 00120 // then, only some strips are fired at a time. 00121 // We use calChan to know that 00122 int isub,ical = summary.calChan(); 00123 isub = ical<4 ? ical+4 : ical-4; 00124 lastCalchan_ = ical; 00125 for (int k=0;k<16;++k) { 00126 // all strips of the APV are merged in 00127 updateHistoSet( calib1_,bin,digis.data[ical+k*8].adc()-ped[ical+k*8]-(digis.data[isub+k*8].adc()-ped[isub+k*8])); 00128 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])); 00129 } 00130 if(bin>=62) update(); //TODO: temporary: find a better solution later 00131 }
void CalibrationScanTask::update | ( | ) | [private, virtual] |
Reimplemented from CommissioningTask.
Definition at line 135 of file CalibrationScanTask.cc.
References calib1_, calib2_, LogDebug, and CommissioningTask::updateHistoSet().
Referenced by checkAndSave(), and fill().
00135 { 00136 LogDebug("Commissioning") << "[CalibrationScanTask::update]"; 00137 updateHistoSet( calib1_ ); 00138 updateHistoSet( calib2_ ); 00139 }
MonitorElement * CalibrationScanTask::calchanElement_ [private] |
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] |
MonitorElement* CalibrationScanTask::ishaElement_ [private] |
uint16_t CalibrationScanTask::lastCalchan_ [private] |
uint16_t CalibrationScanTask::lastISHA_ [private] |
uint16_t CalibrationScanTask::lastVFS_ [private] |
uint16_t CalibrationScanTask::nBins_ [private] |
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] |
MonitorElement * CalibrationScanTask::vfsElement_ [private] |