56 pedsPSet_(iConfig.getParameter<edm::
ParameterSet>(
"PedestalsPSet")),
65 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals "
66 <<
" Constructing....... ";
73 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals "
74 <<
" Destructing...... ";
95 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::beginRun: "
96 <<
" Creating MEs for new Cabling ";
99 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::beginRun: "
100 <<
" Resetting MEs ";
101 for (std::map<uint32_t, ModMEs >::const_iterator idet =
PedMEs.begin() ; idet!=
PedMEs.end() ; idet++) {
117 std::vector<uint32_t> SelectedDetIds;
123 detcabling->addActiveDetectorsRawIds(SelectedDetIds);
130 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::createMEs: "
131 <<
"Number of Detector Present in cabling " << SelectedDetIds.size();
133 for (std::vector<uint32_t>::const_iterator idetid=SelectedDetIds.begin(), iEnd=SelectedDetIds.end();idetid!=iEnd;++idetid){
135 uint32_t
detid = *idetid;
138 if (detid == 0 || detid == 0xFFFFFFFF){
139 edm::LogError(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::createMEs: "
140 <<
"Wrong DetId !!!!!! " << detid <<
" Neglecting !!!!!! ";
144 unsigned int apv_pairs =
detcabling->nApvPairs(detid);
147 if (apv_pairs < 1 || apv_pairs > 3) {
148 edm::LogError(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::createMEs: Wrong APV Pairs => detId "
149 << detid <<
" APV pairs " << apv_pairs <<
" Neglecting !!!!!! ";
152 unsigned int napvs = apv_pairs * 2;
153 unsigned int nStrip = napvs * 128;
183 hid = hidmanager.
createHistoId(
"PedestalFromCondDB",
"det", detid);
186 (local_modmes.
PedsPerStripDB)->setAxisTitle(
"Pedestal from CondDB(ADC) vs Strip Number",1);
188 hid = hidmanager.
createHistoId(
"NoiseFromCondDB",
"det", detid);
191 (local_modmes.
CMSubNoisePerStripDB)->setAxisTitle(
"CMSubNoise from CondDB(ADC) vs Strip Number",1);
193 hid = hidmanager.
createHistoId(
"BadStripFlagCondDB",
"det", detid);
196 (local_modmes.
BadStripsDB)->setAxisTitle(
"Strip Flag from CondDB(ADC) vs Strip Number",1);
203 (local_modmes.
PedsPerStrip)->setAxisTitle(
"Pedestal (ADC) vs Strip Number ",1);
205 hid = hidmanager.
createHistoId(
"PedsDistribution",
"det", detid);
209 (local_modmes.
PedsDistribution)->setAxisTitle(
"Mean Pedestal Value (ADC)",2);
211 hid = hidmanager.
createHistoId(
"PedsEvolution",
"det", detid);
215 (local_modmes.
PedsEvolution)->setAxisTitle(
"Iteration Number",2);
218 hid = hidmanager.
createHistoId(
"CMSubNoisePerStrip",
"det", detid);
221 (local_modmes.
CMSubNoisePerStrip)->setAxisTitle(
"CMSubNoise (ADC) vs Strip Number",1);
223 hid = hidmanager.
createHistoId(
"RawNoisePerStrip",
"det", detid);
226 (local_modmes.
RawNoisePerStrip)->setAxisTitle(
"RawNoise(ADC) vs Strip Number",1);
228 hid = hidmanager.
createHistoId(
"CMSubNoiseProfile",
"det", detid);
231 (local_modmes.
CMSubNoiseProfile)->setAxisTitle(
"Mean of CMSubNoise (ADC) vs Strip Number",1);
233 hid = hidmanager.
createHistoId(
"RawNoiseProfile",
"det", detid);
236 (local_modmes.
RawNoiseProfile)->setAxisTitle(
"Mean of RawNoise (ADC) vs Strip Number",1);
241 (local_modmes.
NoisyStrips)->setAxisTitle(
"Strip Number",1);
242 (local_modmes.
NoisyStrips)->setAxisTitle(
"Flag Value",2);
244 hid = hidmanager.
createHistoId(
"NoisyStripDistribution",
"det", detid);
250 hid = hidmanager.
createHistoId(
"CMDistribution",
"det", detid);
253 (local_modmes.
CMDistribution)->setAxisTitle(
"Common Mode (ADC) vs APV Number",1);
255 hid = hidmanager.
createHistoId(
"CMSlopeDistribution",
"det", detid);
263 PedMEs.insert( std::make_pair(detid, local_modmes));
267 edm::LogInfo(
"SiStripMonitorPedestals") <<
"SiStripMonitorPedestals::createMEs: Number of DETS used "
275 "SiStripMonitorPedestals::analyze: Run " <<
291 iEvent.
getByLabel(digiProducer, digiType, digi_collection);
298 for (std::map<uint32_t, ModMEs >::const_iterator
i =
PedMEs.begin() ;
i!=
PedMEs.end() ;
i++) {
301 std::vector< edm::DetSet<SiStripRawDigi> >::const_iterator digis = digi_collection->find( detid );
302 if (digis == digi_collection->end() ||
303 digis->data.size() == 0 ||
304 digis->data.size() > 768) {
305 if (digis == digi_collection->end()) {
306 edm::LogError(
"SiStripMonitorPedestals") <<
" SiStripMonitorPedestals::analyze: Event " <<
nEvTot_
307 <<
" DetId " << detid <<
" at the end of Digi Collection!!!";
309 edm::LogError(
"SiStripMonitorPedestals") <<
" [SiStripMonitorPedestals::analyze: Event " <<
nEvTot_
310 <<
" DetId " << detid <<
" # of Digis " << digis->data.size() ;
312 std::vector<const FedChannelConnection *> fed_conns =
detcabling->getConnections(detid);
313 for (
unsigned int k = 0;
k < fed_conns.size() ;
k++) {
314 if (
k==0)
edm::LogError(
"SiStripMonitorPedestals") <<
" SiStripMonitorPedestals::analyze: Fed Id " <<
315 fed_conns[
k]->fedId() <<
" Channel " << fed_conns[
k]->fedCh();
316 else edm::LogError(
"SiStripMonitorPedestals") <<
" SiStripMonitorPedestals::analyze: Channel " <<
317 fed_conns[
k]->fedCh();
323 if ( digis->data.empty() ) {
324 edm::LogError(
"MonitorDigi_tmp") <<
"[SiStripRawDigiToRaw::createFedBuffers] Zero digis found!";
332 std::vector<float>
tmp;
338 for (std::vector<float>::const_iterator iped=tmp.begin(); iped!=tmp.end();iped++) {
339 int iapv = int (ibin/numberCMBlocks);
346 std::vector<float>
tmp;
350 for (std::vector<float>::const_iterator it=tmp.begin(); it!=tmp.end();it++) {
361 std::vector<float>
tmp;
365 int numberOfApvs = int(tmp.size()/128.);
366 for(
int i=0;
i<numberOfApvs;
i++){
367 std::vector<float> myPedPerApv;
370 avarage = accumulate(myPedPerApv.begin(), myPedPerApv.end(), avarage);
371 avarage = avarage/128.;
377 for (std::vector<float>::const_iterator iped=tmp.begin(); iped!=tmp.end();iped++) {
378 int napv = int(ibin / 128.);
380 float last_value = (local_modmes.
PedsPerStrip)->getBinContent(ibin);
381 if(last_value != 0.){
382 (local_modmes.
PedsPerStrip)->setBinContent(ibin,(static_cast<float>(*iped) + last_value)/2.);
384 (local_modmes.
PedsPerStrip)->setBinContent(ibin,static_cast<float>(*iped));
394 for (std::vector<float>::const_iterator iped=tmp.begin(); iped!=tmp.end();iped++) {
399 if(last_value != 0.){
400 (local_modmes.
CMSubNoisePerStrip)->setBinContent(ibin,(static_cast<float>(*iped)+last_value)/2.);
412 for (std::vector<float>::const_iterator iped=tmp.begin(); iped!=tmp.end();iped++) {
414 (local_modmes.
RawNoiseProfile)->
Fill(static_cast<double>(ibin*1.),
static_cast<float>(*iped));
416 if(last_value != 0.){
417 (local_modmes.
RawNoisePerStrip)->setBinContent(ibin,(static_cast<float>(*iped)+last_value)/2.);
419 (local_modmes.
RawNoisePerStrip)->setBinContent(ibin,static_cast<float>(*iped));
428 for (TkApvMask::MaskType::const_iterator iped=temp.begin(); iped!=temp.end();iped++) {
455 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;
509 for (std::map<uint32_t, ModMEs >::const_iterator
i =
PedMEs.begin() ;
i!=
PedMEs.end() ;
i++) {
510 uint32_t
detid =
i->first;
511 ModMEs local_modmes =
i->second;
512 edm::LogInfo(
"SiStripMonitorPedestals") <<
" SiStripMonitorPedestals::analyze: " <<
513 " Get Ped/Noise/Bad Strips from CondDb for DetId " <<
detid;
514 int nStrip =
detcabling->nApvPairs(detid) * 256;
520 for(
int istrip=0;istrip<nStrip;++istrip){
523 (local_modmes.
PedsPerStripDB)->
Fill(istrip+1,pedestalHandle->getPed(istrip,pedRange));
526 edm::LogError(
"SiStripMonitorPedestals") <<
"[SiStripMonitorPedestals::analyze] cms::Exception accessing SiStripPedestalsService_.getPedestal("<<detid<<
","<<istrip<<
") : " <<
" " << e.
what() ;
534 edm::LogError(
"SiStripMonitorPedestals") <<
"[SiStripMonitorPedestals::analyze] cms::Exception accessing SiStripNoiseService_.getNoise("<<detid<<
","<<istrip<<
") : " <<
" " << e.
what() ;
538 (local_modmes.
BadStripsDB)->
Fill(istrip+1,qualityHandle->IsStripBad(qualityRange,istrip)?1.:0.);
543 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
void createMEs(edm::EventSetup const &eSetup)
MonitorElement * RawNoiseProfile
virtual void analyze(const edm::Event &, const edm::EventSetup &)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
MonitorElement * CMDistribution
void getPedestal(uint32_t det_id, int apvNumber, ApvAnalysis::PedestalType &peds)
#define DEFINE_FWK_MODULE(type)
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
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
virtual void beginRun(edm::Run const &run, edm::EventSetup const &eSetup)
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)
void tag(MonitorElement *me, unsigned int myTag)
edm::ParameterSet pedsPSet_
MonitorElement * RawNoisePerStrip
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 &)
~SiStripMonitorPedestals()
ApvAnalysisFactory * apvFactory_
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
MonitorElement * PedsDistribution
MonitorElement * CMSubNoiseProfile
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
void getCommonMode(uint32_t det_id, ApvAnalysis::PedestalType &tmp)
MonitorElement * CMSlopeDistribution
MonitorElement * PedsPerStripDB
MonitorElement * NoisyStripDistribution
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_
std::pair< ContainerIterator, ContainerIterator > Range
static const std::string RunMode2
MonitorElement * BadStripsDB
std::string outPutFileName
std::pair< ContainerIterator, ContainerIterator > Range
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
void Reset(void)
reset ME (ie. contents, errors, etc)
void resetMEs(uint32_t idet)
std::map< uint32_t, ModMEs > PedMEs
MonitorElement * NoisyStrips