CMS 3D CMS Logo

CalibrationTask.cc
Go to the documentation of this file.
9 
10 #include <arpa/inet.h>
11 #include <cstdio>
12 #include <fstream>
13 #include <netdb.h>
14 #include <sys/socket.h>
15 #include <sys/unistd.h>
16 
17 // -----------------------------------------------------------------------------
18 //
21  const sistrip::RunType& rtype,
22  const char* filename,
23  uint32_t run,
24  const edm::EventSetup& setup)
25  : CommissioningTask(dqm, conn, "CalibrationTask"),
26  runType_(rtype),
27  nBins_(0),
28  lastCalChan_(1000),
29  lastCalSel_(1000),
30  lastLatency_(1000),
31  extrainfo_(),
32  run_(run) {
33  // each latency point is 25ns, each calSel is 25/8 --> 64 points = 8 calsel + 8 latency --> as set in the DAQ configuration
35  nBins_ = 64;
36  // each latency point is 25ns, each calSel is 25/8 --> 80 points = 8 calsel + 10 latency --> as set in the DAQ configuration
38  nBins_ = 80;
39 
40  LogDebug("Commissioning") << "[CalibrationTask::CalibrationTask] Constructing object...";
41 
42  // load the pedestals
43  edm::ESHandle<SiStripPedestals> pedestalsHandle;
44  setup.get<SiStripPedestalsRcd>().get(pedestalsHandle);
45  SiStripPedestals::Range detPedRange = pedestalsHandle->getRange(conn.detId());
46  int start = conn.apvPairNumber() * 256;
47  int stop = start + 256;
48  int value = 0;
49  ped.reserve(256);
50  for (int strip = start; strip < stop; ++strip) {
51  value = int(pedestalsHandle->getPed(strip, detPedRange));
52  if (value > 895)
53  value -= 1024;
54  ped.push_back(value);
55  }
56 }
57 
58 // -----------------------------------------------------------------------------
59 //
61  LogDebug("Commissioning") << "[CalibrationTask::CalibrationTask] Destructing object...";
62 }
63 
64 // -----------------------------------------------------------------------------
65 //
67  LogDebug("Commissioning") << "[CalibrationTask::book]";
68 
69  // book 16 histograms, one for each strip in a calibration group --> APV1 --> 16 = dimension of one calChan
70  if (calib1_.find(extrainfo_) == calib1_.end()) {
72  calib1_[extrainfo_].resize(16);
73  for (int i = 0; i < 16; ++i) {
74  std::string postfix = extrainfo_ + "_istrip_" + std::to_string(i);
76  runType_,
78  fedKey(),
80  connection().i2cAddr(0),
81  postfix)
82  .title();
83 
85  calib1_[extrainfo_][i].histo(dqm()->book1D(title, title, nBins_, 0, 200));
87  calib1_[extrainfo_][i].histo(dqm()->book1D(title, title, nBins_, 0, 250));
88  calib1_[extrainfo_][i].isProfile_ = false;
89  calib1_[extrainfo_][i].vNumOfEntries_.resize(nBins_, 0);
90  }
91  }
92 
93  // book 16 histograms, one for each strip in a calibration group --> APV2 --> 16 = dimension of one calChan
94  if (calib2_.find(extrainfo_) == calib2_.end()) {
96  calib2_[extrainfo_].resize(16);
97  for (int i = 0; i < 16; ++i) {
98  std::string postfix = extrainfo_ + "_istrip_" + std::to_string(i);
100  runType_,
102  fedKey(),
103  sistrip::APV,
104  connection().i2cAddr(1),
105  postfix)
106  .title();
107 
109  calib2_[extrainfo_][i].histo(dqm()->book1D(title, title, nBins_, 0, 200));
111  calib2_[extrainfo_][i].histo(dqm()->book1D(title, title, nBins_, 0, 250));
112 
113  calib2_[extrainfo_][i].isProfile_ = false;
114  calib2_[extrainfo_][i].vNumOfEntries_.resize(nBins_, 0);
115  }
116  }
117 }
118 
119 // -----------------------------------------------------------------------------
120 //
122  LogDebug("Commissioning") << "[CalibrationTask::fill]";
123 
124  if (lastCalChan_ != summary.calChan()) { // change in the calChan value
125  lastCalChan_ = summary.calChan();
126  lastLatency_ = summary.latency();
127  lastCalSel_ = summary.calSel();
128  extrainfo_ = "calChan_" + std::to_string(lastCalChan_);
129  book(); // book histograms and load the right one
130  } else {
131  lastCalChan_ = summary.calChan();
132  lastLatency_ = summary.latency();
133  lastCalSel_ = summary.calSel();
134  extrainfo_ = "calChan_" + std::to_string(lastCalChan_);
135  }
136 
137  // Check if CalChan changed. In that case, save, reset histo, change title, and continue
138  int isub = lastCalChan_ < 4 ? lastCalChan_ + 4 : lastCalChan_ - 4;
139  int bin = 0;
140 
142  bin = (100 - summary.latency()) * 8 + (7 - summary.calSel());
144  bin = (102 - summary.latency()) * 8 + (7 - summary.calSel());
145 
146  // Fill the histograms data-ped -(data-ped)_isub, the second term corresponds to the common mode substraction, looking at a strip far away.
147  for (int k = 0; k < 16; ++k) {
149  bin,
150  digis.data[lastCalChan_ + k * 8].adc() - ped[lastCalChan_ + k * 8] -
151  (digis.data[isub + k * 8].adc() - ped[isub + k * 8]));
153  bin,
154  digis.data[128 + lastCalChan_ + k * 8].adc() - ped[128 + lastCalChan_ + k * 8] -
155  (digis.data[128 + isub + k * 8].adc() - ped[128 + isub + k * 8]));
156  }
157  update(); //TODO: temporary: find a better solution later
158 }
159 
160 // -----------------------------------------------------------------------------
161 //
163  LogDebug("Commissioning") << "[CalibrationTask::update]"; // huge output
164 
165  for (const auto& element : calib1_) { // all pulse for different calChan
166  for (auto vecelement : element.second) // all strips in a calCan
167  updateHistoSet(vecelement);
168  }
169 
170  for (const auto& element : calib2_) { // all pulse for different calChan
171  for (auto vecelement : element.second) // all strips in a calCan
172  updateHistoSet(vecelement);
173  }
174 }
175 
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
mps_fire.i
i
Definition: mps_fire.py:428
start
Definition: start.py:1
sistrip::CALIBRATION
Definition: ConstantsForRunType.h:73
MessageLogger.h
CalibrationTask::update
void update() override
Definition: CalibrationTask.cc:162
ESHandle.h
CalibrationTask::extrainfo_
std::string extrainfo_
Definition: CalibrationTask.h:32
SiStripPedestals::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripPedestals.h:51
edm::DetSet
Definition: DetSet.h:23
CalibrationTask::calib2_
std::map< std::string, std::vector< HistoSet > > calib2_
Definition: CalibrationTask.h:28
CommissioningTask::connection
const FedChannelConnection & connection() const
Definition: CommissioningTask.h:189
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
SiStripCommissioningClient_cfg.conn
conn
Definition: SiStripCommissioningClient_cfg.py:5
DQMStore.h
CommissioningTask
Definition: CommissioningTask.h:24
sistrip::RunType
RunType
Definition: ConstantsForRunType.h:70
CalibrationTask::lastLatency_
uint16_t lastLatency_
Definition: CalibrationTask.h:31
SiStripPedestalsRcd
Definition: SiStripCondDataRecords.h:43
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
CalibrationTask::lastCalSel_
uint16_t lastCalSel_
Definition: CalibrationTask.h:31
CalibrationTask::book
void book() override
Definition: CalibrationTask.cc:66
CommissioningTask::fedKey
const uint32_t & fedKey() const
Definition: CommissioningTask.h:192
CalibrationTask::~CalibrationTask
~CalibrationTask() override
Definition: CalibrationTask.cc:60
dqm::legacy::DQMStore
Definition: DQMStore.h:727
CalibrationTask::nBins_
uint16_t nBins_
Definition: CalibrationTask.h:30
sistrip::EXPERT_HISTO
Definition: ConstantsForHistoType.h:29
edm::ESHandle< SiStripPedestals >
SiStripPedestalsRcd.h
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
dqm::implementation::DQMStore::setCurrentFolder
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiStripPedestals::getRange
const Range getRange(const uint32_t &detID) const
Definition: SiStripPedestals.cc:28
FedChannelConnection
Class containning control, module, detector and connection information, at the level of a FED channel...
Definition: FedChannelConnection.h:26
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
sistrip::CALIBRATION_DECO
Definition: ConstantsForRunType.h:93
sistrip::APV
Definition: ConstantsForGranularity.h:79
createfilelist.int
int
Definition: createfilelist.py:10
edmLumisInFiles.summary
summary
Definition: edmLumisInFiles.py:39
CommissioningTask::updateHistoSet
void updateHistoSet(HistoSet &, const uint32_t &bin, const float &value)
Definition: CommissioningTask.cc:274
value
Definition: value.py:1
CalibrationTask::setCurrentFolder
void setCurrentFolder(const std::string &)
Definition: CalibrationTask.cc:176
CalibrationTask::calib1_
std::map< std::string, std::vector< HistoSet > > calib1_
Definition: CalibrationTask.h:27
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
CalibrationTask.h
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
writedatasetfile.run
run
Definition: writedatasetfile.py:27
CommissioningTask::dqm
DQMStore *const dqm() const
Definition: CommissioningTask.h:188
CalibrationTask::runType_
sistrip::RunType runType_
Definition: CalibrationTask.h:26
CalibrationTask::directory_
std::string directory_
Definition: CalibrationTask.h:33
CalibrationTask::CalibrationTask
CalibrationTask(DQMStore *, const FedChannelConnection &, const sistrip::RunType &, const char *filename, uint32_t run, const edm::EventSetup &setup)
Definition: CalibrationTask.cc:19
SiStripHistoTitle.h
SiStripPedestals.h
SiStripHistoTitle::title
const std::string & title() const
Definition: SiStripHistoTitle.h:109
edm::DetSet::data
collection_type data
Definition: DetSet.h:80
EventSetup.h
SiStripHistoTitle
Utility class that holds histogram title.
Definition: SiStripHistoTitle.h:20
CalibrationTask::fill
void fill(const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &) override
Definition: CalibrationTask.cc:121
dqm
Definition: DQMStore.h:18
SiStripPedestals::getPed
float getPed(const uint16_t &strip, const Range &range) const
Definition: SiStripPedestals.cc:51
sistrip::FED_KEY
Definition: ConstantsForKeyType.h:30
SiStripEventSummary
Definition: SiStripEventSummary.h:22
CalibrationTask::lastCalChan_
uint16_t lastCalChan_
Definition: CalibrationTask.h:31
CalibrationTask::ped
std::vector< uint16_t > ped
Definition: CalibrationTask.h:34
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23