CMS 3D CMS Logo

CalibrationScanTask.cc
Go to the documentation of this file.
10 
11 #include <arpa/inet.h>
12 #include <cstdio>
13 #include <fstream>
14 #include <netdb.h>
15 #include <sys/socket.h>
16 #include <sys/unistd.h>
17 
18 // -----------------------------------------------------------------------------
19 //
21  const FedChannelConnection& conn,
22  const sistrip::RunType& rtype,
23  const char* filename,
24  uint32_t run,
25  const edm::EventSetup& setup ) :
26  CommissioningTask( dqm, conn, "CalibrationScanTask" ),
27  runType_(rtype),
28  nBins_(0),
29  lastISHA_(1000),
30  lastVFS_(1000),
31  lastCalChan_(1000),
32  lastCalSel_(1000),
33  lastLatency_(1000),
34  extrainfo_(),
35  run_(run)
36 {
37 
38  // each latency point is 25ns, each calSel is 25/8 --> 64 points = 8 calsel + 8 latency --> as set in the DAQ configuration
40  // each latency point is 25ns, each calSel is 25/8 --> 80 points = 8 calsel + 10 latency --> as set in the DAQ configuration
42 
43  LogDebug("Commissioning") << "[CalibrationScanTask::CalibrationScanTask] Constructing object...";
44  // load the pedestals
45  edm::ESHandle<SiStripPedestals> pedestalsHandle;
46  setup.get<SiStripPedestalsRcd>().get(pedestalsHandle);
47  SiStripPedestals::Range detPedRange = pedestalsHandle->getRange(conn.detId());
48  int start = conn.apvPairNumber()*256;
49  int stop = start + 256;
50  int value = 0;
51  ped.reserve(256);
52  LogDebug("Commissioning") << "[CalibrationScanTask::CalibrationScanTask] Loading pedestal for " << conn.detId();
53  if(conn.detId()==0) return;
54  for(int strip = start; strip < stop; ++strip) {
55  value = int(pedestalsHandle->getPed(strip,detPedRange));
56  if(value>895) value -= 1024;
57  ped.push_back(value);
58  }
59 }
60 
61 // -----------------------------------------------------------------------------
62 //
64  LogDebug("Commissioning") << "[CalibrationScanTask::CalibrationScanTask] Destructing object...";
65 }
66 
67 // -----------------------------------------------------------------------------
68 //
70 
71  if(calib1_.find(extrainfo_) == calib1_.end()){
72 
73  // construct the histo titles and book two histograms: one per APV --> all strip in one APV are considered to fill histogram
75  runType_,
77  fedKey(),
78  sistrip::APV,
79  connection().i2cAddr(0),
80  extrainfo_).title();
81 
85  calib1_[extrainfo_].histo( dqm()->book1D( title, title, nBins_, 0, 200));
87  calib1_[extrainfo_].histo( dqm()->book1D( title, title, nBins_, 0, 250));
88  calib1_[extrainfo_].isProfile_ = false;
89  calib1_[extrainfo_].vNumOfEntries_.resize(nBins_,0);
90  }
91 
92  if(calib2_.find(extrainfo_) == calib2_.end()){
93 
95  runType_,
97  fedKey(),
98  sistrip::APV,
99  connection().i2cAddr(1),
100  extrainfo_).title();
101 
105  calib2_[extrainfo_].histo( dqm()->book1D( title, title, nBins_, 0, 200));
107  calib2_[extrainfo_].histo( dqm()->book1D( title, title, nBins_, 0, 250));
108  calib2_[extrainfo_].isProfile_=false;
109  calib2_[extrainfo_].vNumOfEntries_.resize(nBins_,0);
110  }
111 }
112 
113 // -----------------------------------------------------------------------------
114 //
116  const edm::DetSet<SiStripRawDigi>& digis ) {
117 
118 
119  if(lastISHA_ != summary.isha() or lastVFS_ != summary.vfs()){ // triggered only when there is a change in isha and vfs
120  lastISHA_ = summary.isha();
121  lastVFS_ = summary.vfs();
122  lastCalSel_ = summary.calSel();
123  lastLatency_ = summary.latency();
124  lastCalChan_ = summary.calChan();
125  extrainfo_ = "isha_"+std::to_string(lastISHA_)+"_vfs_"+std::to_string(lastVFS_);
126  book(); // book histograms and load the right one
127  }
128  else{
129  lastISHA_ = summary.isha();
130  lastVFS_ = summary.vfs();
131  lastCalSel_ = summary.calSel();
132  lastLatency_ = summary.latency();
133  lastCalChan_ = summary.calChan();
134  extrainfo_ = "isha_"+std::to_string(lastISHA_)+"_vfs_"+std::to_string(lastVFS_);
135  }
136 
137  // retrieve the delay from the EventSummary
138  int bin = 0;
139  if(runType_ == sistrip::CALIBRATION_SCAN) bin = (100-summary.latency())*8+(7-summary.calSel());
140  else if(runType_ == sistrip::CALIBRATION_SCAN_DECO) bin = (102-summary.latency())*8+(7-summary.calSel());
141 
142  // Digis are obtained for an APV pair.strips 0->127 : calib1_ strips 128->255: calib2_
143  // then, only some strips are fired at a time, we use calChan to know that
144  int isub = lastCalChan_<4 ? lastCalChan_+4 : lastCalChan_-4;
145  for (int k=0;k<16;++k) {
146  // all strips of the APV are merged in
147  updateHistoSet(calib1_[extrainfo_],bin,digis.data[lastCalChan_+k*8].adc()-ped[lastCalChan_+k*8]-(digis.data[isub+k*8].adc()-ped[isub+k*8]));
148  updateHistoSet(calib2_[extrainfo_],bin,digis.data[128+lastCalChan_+k*8].adc()-ped[128+lastCalChan_+k*8]-(digis.data[128+isub+k*8].adc()-ped[128+isub+k*8]));
149  }
150  update(); //TODO: temporary: find a better solution later
151 }
152 
153 // -----------------------------------------------------------------------------
154 //
156 
157  LogDebug("Commissioning") << "[CalibrationScanTask::update]"; // huge output
158  for(auto element : calib1_)
159  updateHistoSet(element.second);
160  for(auto element : calib2_)
161  updateHistoSet(element.second);
162 }
163 
165  directory_ = dir;
166 }
167 
#define LogDebug(id)
Definition: start.py:1
const uint32_t & vfs() const
Utility class that holds histogram title.
void setCurrentFolder(const std::string &)
const std::string & title() const
const uint32_t & latency() const
sistrip::RunType runType_
uint16_t apvPairNumber() const
std::map< std::string, HistoSet > calib1_
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
std::pair< ContainerIterator, ContainerIterator > Range
std::vector< uint16_t > ped
void fill(const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &) override
float getPed(const uint16_t &strip, const Range &range) const
const uint32_t & isha() const
void updateHistoSet(HistoSet &, const uint32_t &bin, const float &value)
const uint32_t & detId() const
Class containning control, module, detector and connection information, at the level of a FED channel...
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
std::map< std::string, HistoSet > calib2_
Definition: value.py:1
int k[5][pyjets_maxn]
bin
set the eta bin as selection string.
const uint32_t & calSel() const
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:571
DQMStore *const dqm() const
collection_type data
Definition: DetSet.h:80
T get() const
Definition: EventSetup.h:71
const uint32_t & calChan() const
const uint32_t & fedKey() const
const Range getRange(const uint32_t &detID) const
const FedChannelConnection & connection() const
dbl *** dir
Definition: mlp_gen.cc:35
CalibrationScanTask(DQMStore *, const FedChannelConnection &, const sistrip::RunType &, const char *filename, uint32_t run, const edm::EventSetup &setup)