56 pedsPSet_(iConfig.getParameter<edm::
ParameterSet>(
"PedestalsPSet")),
70 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals "
71 <<
" Constructing....... ";
80 noiseToken_ = esConsumes<edm::Transition::BeginRun>();
89 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals "
90 <<
" Destructing...... ";
104 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::bookHistograms: "
105 <<
" Creating MEs for new Cabling ";
119 std::vector<uint32_t> SelectedDetIds;
134 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::createMEs: "
135 <<
"Number of Detector Present in cabling " << SelectedDetIds.size();
137 for (std::vector<uint32_t>::const_iterator idetid = SelectedDetIds.begin(), iEnd = SelectedDetIds.end();
140 uint32_t detid = *idetid;
143 if (detid == 0 || detid == 0xFFFFFFFF) {
144 edm::LogError(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::createMEs: "
145 <<
"Wrong DetId !!!!!! " << detid <<
" Neglecting !!!!!! ";
152 if (apv_pairs < 1 || apv_pairs > 3) {
153 edm::LogError(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::createMEs: Wrong APV Pairs => detId "
154 << detid <<
" APV pairs " << apv_pairs <<
" Neglecting !!!!!! ";
157 unsigned int napvs = apv_pairs * 2;
158 unsigned int nStrip = napvs * 128;
189 hid = hidmanager.
createHistoId(
"PedestalFromCondDB",
"det", detid);
191 ibooker.
book1D(hid, hid, nStrip, 0.5, nStrip + 0.5);
192 (local_modmes.
PedsPerStripDB)->setAxisTitle(
"Pedestal from CondDB(ADC) vs Strip Number", 1);
194 hid = hidmanager.
createHistoId(
"NoiseFromCondDB",
"det", detid);
196 (local_modmes.
CMSubNoisePerStripDB)->setAxisTitle(
"CMSubNoise from CondDB(ADC) vs Strip Number", 1);
198 hid = hidmanager.
createHistoId(
"BadStripFlagCondDB",
"det", detid);
199 local_modmes.
BadStripsDB = ibooker.
book2D(hid, hid, nStrip, 0.5, nStrip + 0.5, 6, -0.5, 5.5);
200 (local_modmes.
BadStripsDB)->setAxisTitle(
"Strip Flag from CondDB(ADC) vs Strip Number", 1);
204 hid = hidmanager.
createHistoId(
"PedsPerStrip",
"det", detid);
206 (local_modmes.
PedsPerStrip)->setAxisTitle(
"Pedestal (ADC) vs Strip Number ", 1);
208 hid = hidmanager.
createHistoId(
"PedsDistribution",
"det", detid);
218 (local_modmes.
PedsDistribution)->setAxisTitle(
"Mean Pedestal Value (ADC)", 2);
220 hid = hidmanager.
createHistoId(
"PedsEvolution",
"det", detid);
230 (local_modmes.
PedsEvolution)->setAxisTitle(
"Iteration Number", 2);
233 hid = hidmanager.
createHistoId(
"CMSubNoisePerStrip",
"det", detid);
235 (local_modmes.
CMSubNoisePerStrip)->setAxisTitle(
"CMSubNoise (ADC) vs Strip Number", 1);
237 hid = hidmanager.
createHistoId(
"RawNoisePerStrip",
"det", detid);
239 (local_modmes.
RawNoisePerStrip)->setAxisTitle(
"RawNoise(ADC) vs Strip Number", 1);
241 hid = hidmanager.
createHistoId(
"CMSubNoiseProfile",
"det", detid);
243 (local_modmes.
CMSubNoiseProfile)->setAxisTitle(
"Mean of CMSubNoise (ADC) vs Strip Number", 1);
245 hid = hidmanager.
createHistoId(
"RawNoiseProfile",
"det", detid);
247 (local_modmes.
RawNoiseProfile)->setAxisTitle(
"Mean of RawNoise (ADC) vs Strip Number", 1);
250 local_modmes.
NoisyStrips = ibooker.
book2D(hid, hid, nStrip, 0.5, nStrip + 0.5, 6, -0.5, 5.5);
251 (local_modmes.
NoisyStrips)->setAxisTitle(
"Strip Number", 1);
252 (local_modmes.
NoisyStrips)->setAxisTitle(
"Flag Value", 2);
254 hid = hidmanager.
createHistoId(
"NoisyStripDistribution",
"det", detid);
259 hid = hidmanager.
createHistoId(
"CMDistribution",
"det", detid);
260 local_modmes.
CMDistribution = ibooker.
book2D(hid, hid, napvs, -0.5, napvs - 0.5, 150, -15., 15.);
261 (local_modmes.
CMDistribution)->setAxisTitle(
"Common Mode (ADC) vs APV Number", 1);
263 hid = hidmanager.
createHistoId(
"CMSlopeDistribution",
"det", detid);
269 PedMEs.insert(std::make_pair(detid, local_modmes));
273 <<
"SiStripMonitorPedestals::createMEs: Number of DETS used " <<
PedMEs.size();
278 <<
"SiStripMonitorPedestals::analyze: Run " << iEvent.
id().
run() <<
" Event " << iEvent.
id().
event();
299 for (std::map<uint32_t, ModMEs>::const_iterator
i =
PedMEs.begin();
i !=
PedMEs.end();
i++) {
300 uint32_t detid =
i->first;
301 ModMEs local_modmes =
i->second;
304 std::vector<edm::DetSet<SiStripRawDigi>>::const_iterator digis = digi_collection->find(detid);
305 if (digis == digi_collection->end() || digis->data.empty() || digis->data.size() > 768) {
306 if (digis == digi_collection->end()) {
307 edm::LogError(
"SiStripMonitorPedestals") <<
" SiStripMonitorPedestals::analyze: Event " <<
nEvTot_ <<
" DetId "
308 << detid <<
" at the end of Digi Collection!!!";
310 edm::LogError(
"SiStripMonitorPedestals") <<
" [SiStripMonitorPedestals::analyze: Event " <<
nEvTot_ <<
" DetId "
311 << detid <<
" # of Digis " << digis->data.size();
314 bool firstchannel(
true);
315 for (
unsigned int k = 0;
k < fed_conns.size();
k++) {
316 if (fed_conns[
k] && fed_conns[
k]->isConnected()) {
318 edm::LogError(
"SiStripMonitorPedestals") <<
" SiStripMonitorPedestals::analyze: Fed Id "
319 << fed_conns[
k]->fedId() <<
" Channel " << fed_conns[
k]->fedCh();
320 firstchannel =
false;
323 <<
" SiStripMonitorPedestals::analyze: Channel " << fed_conns[
k]->fedCh();
330 if (digis->data.empty()) {
331 edm::LogError(
"MonitorDigi_tmp") <<
"[SiStripRawDigiToRaw::createFedBuffers] Zero digis found!";
339 std::vector<float>
tmp;
343 int numberCMBlocks = int(128. / NumCMstripsInGroup_);
345 for (std::vector<float>::const_iterator iped = tmp.begin(); iped != tmp.end(); iped++) {
346 int iapv = int(ibin / numberCMBlocks);
352 std::vector<float>
tmp;
356 for (std::vector<float>::const_iterator it = tmp.begin(); it != tmp.end(); it++) {
365 std::vector<float>
tmp;
369 int numberOfApvs = int(tmp.size() / 128.);
370 for (
int i = 0;
i < numberOfApvs;
i++) {
371 std::vector<float> myPedPerApv;
374 avarage = std::accumulate(myPedPerApv.begin(), myPedPerApv.end(), avarage);
375 avarage = avarage / 128.;
380 for (std::vector<float>::const_iterator iped = tmp.begin(); iped != tmp.end(); iped++) {
381 int napv = int(ibin / 128.);
383 float last_value = (local_modmes.
PedsPerStrip)->getBinContent(ibin);
384 if (last_value != 0.) {
385 (local_modmes.
PedsPerStrip)->setBinContent(ibin, (static_cast<float>(*iped) + last_value) / 2.);
387 (local_modmes.
PedsPerStrip)->setBinContent(ibin, static_cast<float>(*iped));
397 for (std::vector<float>::const_iterator iped = tmp.begin(); iped != tmp.end(); iped++) {
402 if (last_value != 0.) {
403 (local_modmes.
CMSubNoisePerStrip)->setBinContent(ibin, (static_cast<float>(*iped) + last_value) / 2.);
414 for (std::vector<float>::const_iterator iped = tmp.begin(); iped != tmp.end(); iped++) {
416 (local_modmes.
RawNoiseProfile)->
Fill(static_cast<double>(ibin * 1.),
static_cast<float>(*iped));
418 if (last_value != 0.) {
419 (local_modmes.
RawNoisePerStrip)->setBinContent(ibin, (static_cast<float>(*iped) + last_value) / 2.);
421 (local_modmes.
RawNoisePerStrip)->setBinContent(ibin, static_cast<float>(*iped));
430 for (TkApvMask::MaskType::const_iterator iped = temp.begin(); iped != temp.end(); iped++) {
456 if (outputMEsInRootFile) {
465 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::EndJob: "
472 std::map<uint32_t, ModMEs>::iterator pos =
PedMEs.find(idet);
473 if (pos !=
PedMEs.end()) {
474 ModMEs mod_me = pos->second;
503 for (std::map<uint32_t, ModMEs>::const_iterator
i =
PedMEs.begin();
i !=
PedMEs.end();
i++) {
504 uint32_t detid =
i->first;
505 ModMEs local_modmes =
i->second;
506 edm::LogInfo(
"SiStripMonitorPedestals") <<
" SiStripMonitorPedestals::analyze: "
507 <<
" Get Ped/Noise/Bad Strips from CondDb for DetId " << detid;
514 for (
int istrip = 0; istrip < nStrip; ++istrip) {
519 edm::LogError(
"SiStripMonitorPedestals") <<
"[SiStripMonitorPedestals::analyze] cms::Exception accessing "
520 "SiStripPedestalsService_.getPedestal("
521 << detid <<
"," << istrip <<
") : "
529 edm::LogError(
"SiStripMonitorPedestals") <<
"[SiStripMonitorPedestals::analyze] cms::Exception accessing "
530 "SiStripNoiseService_.getNoise("
531 << detid <<
"," << istrip <<
") : "
539 edm::LogError(
"SiStripMonitorPedestals") <<
"[SiStripMonitorPedestals::analyze] cms::Exception accessing "
540 "SiStripNoiseService_.getDisable("
541 << detid <<
"," << istrip <<
") : "
std::vector< StripMaskType > MaskType
EventNumber_t event() const
void fillCondDBMEs(edm::EventSetup const &eSetup)
void addActiveDetectorsRawIds(std::vector< uint32_t > &) const
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > qualityToken_
MonitorElement * RawNoiseProfile
MonitorElement * CMDistribution
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void getPedestal(uint32_t det_id, int apvNumber, ApvAnalysis::PedestalType &peds)
#define DEFINE_FWK_MODULE(type)
uint32_t const *__restrict__ Quality * quality
void getCommonModeSlope(uint32_t det_id, ApvAnalysis::PedestalType &tmp)
void getNoise(uint32_t det_id, int apvNumber, ApvAnalysis::PedestalType &noise)
void update(uint32_t det_id, const edm::DetSet< SiStripRawDigi > &in)
void getMask(uint32_t det_id, TkApvMask::MaskType &tmp)
const SiStripDetCabling * detcabling
std::pair< ContainerIterator, ContainerIterator > Range
MonitorElement * CMSubNoisePerStrip
Log< level::Error, false > LogError
edm::ESGetToken< SiStripNoises, SiStripNoisesRcd > noiseToken_
static const std::string RunMode1
void getRawNoise(uint32_t det_id, int apvNumber, ApvAnalysis::PedestalType &noise)
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
edm::ParameterSet pedsPSet_
bool getData(T &iHolder) const
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
~SiStripMonitorPedestals() override
MonitorElement * RawNoisePerStrip
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiToken_
MonitorElement * PedsEvolution
MonitorElement * PedsPerStrip
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
void analyze(const edm::Event &, const edm::EventSetup &) override
static const std::string RunMode3
bool instantiateApvs(uint32_t det_id, int numberOfApvs)
SiStripMonitorPedestals(const edm::ParameterSet &)
edm::ESGetToken< SiStripPedestals, SiStripPedestalsRcd > pedestalToken_
char const * what() const noexceptoverride
ApvAnalysisFactory * apvFactory_
MonitorElement * PedsDistribution
MonitorElement * CMSubNoiseProfile
edm::ESGetToken< SiStripDetCabling, SiStripDetCablingRcd > detCablingToken_
void getCommonMode(uint32_t det_id, ApvAnalysis::PedestalType &tmp)
MonitorElement * CMSlopeDistribution
MonitorElement * PedsPerStripDB
SiStripHistoId hidmanager
Log< level::Info, false > LogInfo
MonitorElement * NoisyStripDistribution
std::string createHistoId(std::string description, std::string id_type, uint32_t component_id)
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
T getParameter(std::string const &) const
SiStripFolderOrganizer folder_organizer
MonitorElement * CMSubNoisePerStripDB
bool check(const edm::EventSetup &iSetup)
const uint16_t nApvPairs(uint32_t det_id) const
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
std::pair< ContainerIterator, ContainerIterator > Range
static const std::string RunMode2
MonitorElement * BadStripsDB
std::string outPutFileName
std::pair< ContainerIterator, ContainerIterator > Range
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
void createMEs(DQMStore::IBooker &, edm::EventSetup const &eSetup)
void dqmEndRun(edm::Run const &run, edm::EventSetup const &eSetup) override
void resetMEs(uint32_t idet)
edm::ESWatcher< SiStripDetCablingRcd > detCablingWatcher_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
std::map< uint32_t, ModMEs > PedMEs
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
MonitorElement * NoisyStrips