CMS 3D CMS Logo

CalibrationScanTask.cc
Go to the documentation of this file.
10 
11 #include <arpa/inet.h>
12 #include <sys/unistd.h>
13 #include <sys/socket.h>
14 #include <netdb.h>
15 #include <cstdio>
16 #include <fstream>
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_(64),
29  lastISHA_(1000),
30  lastVFS_(1000),
31  lastCalChan_(1000),
32  lastCalSel_(1000),
33  lastLatency_(1000),
34  extrainfo_(),
35  run_(run)
36 {
37 
39  else if(runType_ == sistrip::CALIBRATION_DECO) nBins_ = 80;
40 
41  LogDebug("Commissioning") << "[CalibrationScanTask::CalibrationScanTask] Constructing object...";
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  LogDebug("Commissioning") << "[CalibrationScanTask::CalibrationScanTask] Loading pedestal for " << conn.detId();
51  if(conn.detId()==0) return;
52  for(int strip = start; strip < stop; ++strip) {
53  value = int(pedestalsHandle->getPed(strip,detPedRange));
54  if(value>895) value -= 1024;
55  ped.push_back(value);
56  }
57 }
58 
59 // -----------------------------------------------------------------------------
60 //
62  LogDebug("Commissioning") << "[CalibrationScanTask::CalibrationScanTask] Destructing object...";
63 }
64 
65 // -----------------------------------------------------------------------------
66 //
68 
69  if(calib1_.find(extrainfo_) == calib1_.end()){
70 
71  // construct the histo titles and book two histograms: one per APV
73  runType_,
75  fedKey(),
76  sistrip::APV,
77  connection().i2cAddr(0),
78  extrainfo_).title();
79 
82  if(runType_ == sistrip::CALIBRATION_SCAN) // each latency point is 25ns, each calSel is 25/8 --> 64 points = 8 calsel + 8 latency
83  calib1_[extrainfo_].histo( dqm()->book1D( title, title, nBins_, 0, 200));
84  else if(runType_ == sistrip::CALIBRATION_SCAN_DECO) // each latency point is 25ns, each calSel is 25/8 --> 80 points = 8 calsel + 10 latency
85  calib1_[extrainfo_].histo( dqm()->book1D( title, title, nBins_, 0, 250));
86  calib1_[extrainfo_].isProfile_ = false;
87  calib1_[extrainfo_].vNumOfEntries_.resize(nBins_,0);
88  }
89 
90  if(calib2_.find(extrainfo_) == calib2_.end()){
91 
93  runType_,
95  fedKey(),
96  sistrip::APV,
97  connection().i2cAddr(1),
98  extrainfo_).title();
99 
102  if(runType_ == sistrip::CALIBRATION_SCAN) // each latency point is 25ns, each calSel is 25/8 --> 64 points = 8 calsel + 8 latency
103  calib2_[extrainfo_].histo( dqm()->book1D( title, title, nBins_, 0, 200));
104  else if(runType_ == sistrip::CALIBRATION_SCAN_DECO) // each latency point is 25ns, each calSel is 25/8 --> 80 points = 8 calsel + 10 latency
105  calib2_[extrainfo_].histo( dqm()->book1D( title, title, nBins_, 0, 250));
106  calib2_[extrainfo_].isProfile_=false;
107  calib2_[extrainfo_].vNumOfEntries_.resize(nBins_,0);
108  }
109 }
110 
111 // -----------------------------------------------------------------------------
112 //
114  const edm::DetSet<SiStripRawDigi>& digis ) {
115 
116 
117  if(lastISHA_ != summary.isha() or lastVFS_ != summary.vfs()){ // triggered only when there is a change in isha and vfs
118  lastISHA_ = summary.isha();
119  lastVFS_ = summary.vfs();
120  lastCalSel_ = summary.calSel();
121  lastLatency_ = summary.latency();
122  lastCalChan_ = summary.calChan();
123  extrainfo_ = "isha_"+std::to_string(lastISHA_)+"_vfs_"+std::to_string(lastVFS_);
124  book(); // book histograms and load the right one
125  }
126  else{
127  lastISHA_ = summary.isha();
128  lastVFS_ = summary.vfs();
129  lastCalSel_ = summary.calSel();
130  lastLatency_ = summary.latency();
131  lastCalChan_ = summary.calChan();
132  extrainfo_ = "isha_"+std::to_string(lastISHA_)+"_vfs_"+std::to_string(lastVFS_);
133  }
134 
135  // retrieve the delay from the EventSummary
136  int bin = 0;
137  if(runType_ == sistrip::CALIBRATION_SCAN) bin = (100-summary.latency())*8+(7-summary.calSel());
138  else if(runType_ == sistrip::CALIBRATION_SCAN_DECO) bin = (102-summary.latency())*8+(7-summary.calSel());
139  // digis are obtained for an APV pair.strips 0->127 : calib1_ strips 128->255: calib2_
140  // then, only some strips are fired at a time.
141  // We use calChan to know that
142  int isub = lastCalChan_<4 ? lastCalChan_+4 : lastCalChan_-4;
143  for (int k=0;k<16;++k) {
144  // all strips of the APV are merged in
145  updateHistoSet(calib1_[extrainfo_],bin,digis.data[lastCalChan_+k*8].adc()-ped[lastCalChan_+k*8]-(digis.data[isub+k*8].adc()-ped[isub+k*8]));
146  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]));
147  }
148  update(); //TODO: temporary: find a better solution later
149 }
150 
151 // -----------------------------------------------------------------------------
152 //
154 
155  LogDebug("Commissioning") << "[CalibrationScanTask::update]"; // huge output
156  for(auto element : calib1_)
157  updateHistoSet(element.second);
158  for(auto element : calib2_)
159  updateHistoSet(element.second);
160 }
161 
163  directory_ = dir;
164 }
165 
#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:1
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
DQMStore *const dqm() const
collection_type data
Definition: DetSet.h:78
T get() const
Definition: EventSetup.h:63
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)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:545