55 pedsPSet_(iConfig.getParameter<edm::
ParameterSet>(
"PedestalsPSet")),
69 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals "
70 <<
" Constructing....... ";
82 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals "
83 <<
" Destructing...... ";
102 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::bookHistograms: "
103 <<
" Creating MEs for new Cabling ";
121 std::vector<uint32_t> SelectedDetIds;
127 detcabling->addActiveDetectorsRawIds(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();idetid!=iEnd;++idetid){
139 uint32_t
detid = *idetid;
142 if (detid == 0 || detid == 0xFFFFFFFF){
143 edm::LogError(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::createMEs: "
144 <<
"Wrong DetId !!!!!! " << detid <<
" Neglecting !!!!!! ";
148 unsigned int apv_pairs =
detcabling->nApvPairs(detid);
151 if (apv_pairs < 1 || apv_pairs > 3) {
152 edm::LogError(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::createMEs: Wrong APV Pairs => detId "
153 << detid <<
" APV pairs " << apv_pairs <<
" Neglecting !!!!!! ";
156 unsigned int napvs = apv_pairs * 2;
157 unsigned int nStrip = napvs * 128;
187 hid = hidmanager.
createHistoId(
"PedestalFromCondDB",
"det", detid);
190 (local_modmes.
PedsPerStripDB)->setAxisTitle(
"Pedestal from CondDB(ADC) vs Strip Number",1);
192 hid = hidmanager.
createHistoId(
"NoiseFromCondDB",
"det", detid);
195 (local_modmes.
CMSubNoisePerStripDB)->setAxisTitle(
"CMSubNoise from CondDB(ADC) vs Strip Number",1);
197 hid = hidmanager.
createHistoId(
"BadStripFlagCondDB",
"det", detid);
198 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);
207 (local_modmes.
PedsPerStrip)->setAxisTitle(
"Pedestal (ADC) vs Strip Number ",1);
209 hid = hidmanager.
createHistoId(
"PedsDistribution",
"det", detid);
213 (local_modmes.
PedsDistribution)->setAxisTitle(
"Mean Pedestal Value (ADC)",2);
215 hid = hidmanager.
createHistoId(
"PedsEvolution",
"det", detid);
219 (local_modmes.
PedsEvolution)->setAxisTitle(
"Iteration Number",2);
222 hid = hidmanager.
createHistoId(
"CMSubNoisePerStrip",
"det", detid);
225 (local_modmes.
CMSubNoisePerStrip)->setAxisTitle(
"CMSubNoise (ADC) vs Strip Number",1);
227 hid = hidmanager.
createHistoId(
"RawNoisePerStrip",
"det", detid);
230 (local_modmes.
RawNoisePerStrip)->setAxisTitle(
"RawNoise(ADC) vs Strip Number",1);
232 hid = hidmanager.
createHistoId(
"CMSubNoiseProfile",
"det", detid);
235 (local_modmes.
CMSubNoiseProfile)->setAxisTitle(
"Mean of CMSubNoise (ADC) vs Strip Number",1);
237 hid = hidmanager.
createHistoId(
"RawNoiseProfile",
"det", detid);
240 (local_modmes.
RawNoiseProfile)->setAxisTitle(
"Mean of RawNoise (ADC) vs Strip Number",1);
243 local_modmes.
NoisyStrips = ibooker.
book2D(hid, hid, nStrip,0.5,nStrip+0.5,6,-0.5,5.5);
245 (local_modmes.
NoisyStrips)->setAxisTitle(
"Strip Number",1);
246 (local_modmes.
NoisyStrips)->setAxisTitle(
"Flag Value",2);
248 hid = hidmanager.
createHistoId(
"NoisyStripDistribution",
"det", detid);
254 hid = hidmanager.
createHistoId(
"CMDistribution",
"det", detid);
257 (local_modmes.
CMDistribution)->setAxisTitle(
"Common Mode (ADC) vs APV Number",1);
259 hid = hidmanager.
createHistoId(
"CMSlopeDistribution",
"det", detid);
267 PedMEs.insert( std::make_pair(detid, local_modmes));
271 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::createMEs: Number of DETS used "
279 "SiStripMonitorPedestals::analyze: Run " <<
299 for (std::map<uint32_t, ModMEs >::const_iterator
i =
PedMEs.begin() ;
i!=
PedMEs.end() ;
i++) {
302 std::vector< edm::DetSet<SiStripRawDigi> >::const_iterator digis = digi_collection->find( detid );
303 if (digis == digi_collection->end() ||
304 digis->data.size() == 0 ||
305 digis->data.size() > 768) {
306 if (digis == digi_collection->end()) {
307 edm::LogError(
"SiStripMonitorPedestals") <<
" SiStripMonitorPedestals::analyze: Event " <<
nEvTot_
308 <<
" DetId " << detid <<
" at the end of Digi Collection!!!";
310 edm::LogError(
"SiStripMonitorPedestals") <<
" [SiStripMonitorPedestals::analyze: Event " <<
nEvTot_
311 <<
" DetId " << detid <<
" # of Digis " << digis->data.size() ;
313 std::vector<const FedChannelConnection *> fed_conns =
detcabling->getConnections(detid);
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();
322 else edm::LogError(
"SiStripMonitorPedestals") <<
" SiStripMonitorPedestals::analyze: Channel " <<
323 fed_conns[
k]->fedCh();
330 if ( digis->data.empty() ) {
331 edm::LogError(
"MonitorDigi_tmp") <<
"[SiStripRawDigiToRaw::createFedBuffers] Zero digis found!";
339 std::vector<float>
tmp;
345 for (std::vector<float>::const_iterator iped=tmp.begin(); iped!=tmp.end();iped++) {
346 int iapv = int (ibin/numberCMBlocks);
353 std::vector<float>
tmp;
357 for (std::vector<float>::const_iterator it=tmp.begin(); it!=tmp.end();it++) {
368 std::vector<float>
tmp;
372 int numberOfApvs = int(tmp.size()/128.);
373 for(
int i=0;
i<numberOfApvs;
i++){
374 std::vector<float> myPedPerApv;
377 avarage = accumulate(myPedPerApv.begin(), myPedPerApv.end(), avarage);
378 avarage = avarage/128.;
384 for (std::vector<float>::const_iterator iped=tmp.begin(); iped!=tmp.end();iped++) {
385 int napv = int(ibin / 128.);
387 float last_value = (local_modmes.
PedsPerStrip)->getBinContent(ibin);
388 if(last_value != 0.){
389 (local_modmes.
PedsPerStrip)->setBinContent(ibin,(static_cast<float>(*iped) + last_value)/2.);
391 (local_modmes.
PedsPerStrip)->setBinContent(ibin,static_cast<float>(*iped));
401 for (std::vector<float>::const_iterator iped=tmp.begin(); iped!=tmp.end();iped++) {
406 if(last_value != 0.){
407 (local_modmes.
CMSubNoisePerStrip)->setBinContent(ibin,(static_cast<float>(*iped)+last_value)/2.);
419 for (std::vector<float>::const_iterator iped=tmp.begin(); iped!=tmp.end();iped++) {
421 (local_modmes.
RawNoiseProfile)->
Fill(static_cast<double>(ibin*1.),
static_cast<float>(*iped));
423 if(last_value != 0.){
424 (local_modmes.
RawNoisePerStrip)->setBinContent(ibin,(static_cast<float>(*iped)+last_value)/2.);
426 (local_modmes.
RawNoisePerStrip)->setBinContent(ibin,static_cast<float>(*iped));
435 for (TkApvMask::MaskType::const_iterator iped=temp.begin(); iped!=temp.end();iped++) {
462 if (outputMEsInRootFile) {
472 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::EndJob: "
479 std::map<uint32_t, ModMEs >::iterator pos =
PedMEs.find(idet);
480 if (pos !=
PedMEs.end()) {
481 ModMEs mod_me = pos->second;
516 for (std::map<uint32_t, ModMEs >::const_iterator
i =
PedMEs.begin() ;
i!=
PedMEs.end() ;
i++) {
517 uint32_t
detid =
i->first;
518 ModMEs local_modmes =
i->second;
519 edm::LogInfo(
"SiStripMonitorPedestals") <<
" SiStripMonitorPedestals::analyze: " <<
520 " Get Ped/Noise/Bad Strips from CondDb for DetId " <<
detid;
521 int nStrip =
detcabling->nApvPairs(detid) * 256;
527 for(
int istrip=0;istrip<nStrip;++istrip){
530 (local_modmes.
PedsPerStripDB)->
Fill(istrip+1,pedestalHandle->getPed(istrip,pedRange));
533 edm::LogError(
"SiStripMonitorPedestals") <<
"[SiStripMonitorPedestals::analyze] cms::Exception accessing SiStripPedestalsService_.getPedestal("<<detid<<
","<<istrip<<
") : " <<
" " << e.
what() ;
541 edm::LogError(
"SiStripMonitorPedestals") <<
"[SiStripMonitorPedestals::analyze] cms::Exception accessing SiStripNoiseService_.getNoise("<<detid<<
","<<istrip<<
") : " <<
" " << e.
what() ;
545 (local_modmes.
BadStripsDB)->
Fill(istrip+1,qualityHandle->IsStripBad(qualityRange,istrip)?1.:0.);
550 edm::LogError(
"SiStripMonitorPedestals") <<
"[SiStripMonitorPedestals::analyze] cms::Exception accessing SiStripNoiseService_.getDisable("<<detid<<
","<<istrip<<
") : " <<
" " << e.
what() ;
std::vector< StripMaskType > MaskType
virtual void endRun(edm::Run const &run, edm::EventSetup const &eSetup)
virtual char const * what() const
T getParameter(std::string const &) const
EventNumber_t event() const
void fillCondDBMEs(edm::EventSetup const &eSetup)
edm::ESHandle< SiStripDetCabling > detcabling
MonitorElement * RawNoiseProfile
virtual void analyze(const edm::Event &, const edm::EventSetup &)
MonitorElement * CMDistribution
MonitorElement * bookProfile(Args &&...args)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void getPedestal(uint32_t det_id, int apvNumber, ApvAnalysis::PedestalType &peds)
#define DEFINE_FWK_MODULE(type)
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)
std::pair< ContainerIterator, ContainerIterator > Range
MonitorElement * CMSubNoisePerStrip
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_
MonitorElement * RawNoisePerStrip
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiToken_
MonitorElement * PedsEvolution
MonitorElement * PedsPerStrip
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
static const std::string RunMode3
bool instantiateApvs(uint32_t det_id, int numberOfApvs)
SiStripMonitorPedestals(const edm::ParameterSet &)
MonitorElement * book1D(Args &&...args)
~SiStripMonitorPedestals()
void tag(MonitorElement *, unsigned int)
ApvAnalysisFactory * apvFactory_
MonitorElement * PedsDistribution
MonitorElement * CMSubNoiseProfile
void getCommonMode(uint32_t det_id, ApvAnalysis::PedestalType &tmp)
MonitorElement * CMSlopeDistribution
MonitorElement * PedsPerStripDB
PixelRecoRange< float > Range
MonitorElement * NoisyStripDistribution
MonitorElement * book2D(Args &&...args)
std::string createHistoId(std::string description, std::string id_type, uint32_t component_id)
T const * product() const
MonitorElement * CMSubNoisePerStripDB
std::vector< std::vector< double > > tmp
unsigned long long m_cacheID_
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
static const std::string RunMode2
MonitorElement * BadStripsDB
std::string outPutFileName
volatile std::atomic< bool > shutdown_flag false
std::pair< ContainerIterator, ContainerIterator > Range
void createMEs(DQMStore::IBooker &, edm::EventSetup const &eSetup)
void Reset(void)
reset ME (ie. contents, errors, etc)
void resetMEs(uint32_t idet)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
std::map< uint32_t, ModMEs > PedMEs
MonitorElement * NoisyStrips