CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SiStripGainsPCLHarvester Class Reference

#include <SiStripGainsPCLHarvester.h>

Inheritance diagram for SiStripGainsPCLHarvester:
DQMEDHarvester edm::one::EDProducer< T > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void beginRun (edm::Run const &run, edm::EventSetup const &isetup) override
 
void endRun (edm::Run const &run, edm::EventSetup const &isetup) override
 
 SiStripGainsPCLHarvester (const edm::ParameterSet &ps)
 
- Public Member Functions inherited from DQMEDHarvester
void accumulate (edm::Event const &ev, edm::EventSetup const &es) final
 
void beginJob () override
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &) final
 
void beginRun (edm::Run const &run, edm::EventSetup const &) override
 
virtual void dqmAnalyze (DQMStore::IBooker &, DQMStore::IGetter &, edm::Event const &, edm::EventSetup const &)
 
 DQMEDHarvester (edm::ParameterSet const &iConfig)
 
 DQMEDHarvester ()
 
virtual void dqmEndLuminosityBlock (DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void dqmEndRun (DQMStore::IBooker &, DQMStore::IGetter &, edm::Run const &, edm::EventSetup const &)
 
void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
void endLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &es) final
 
void endProcessBlockProduce (edm::ProcessBlock &) final
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
void endRunProduce (edm::Run &run, edm::EventSetup const &es) final
 
 ~DQMEDHarvester () override=default
 
- Public Member Functions inherited from edm::one::EDProducer< T >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector
< edm::ProductResolverIndex >
const & 
indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector
< edm::ProductResolverIndex >
const & 
putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector
< ProductResolverIndexAndSkipBit >
const & 
itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void algoComputeMPVandGain (const MonitorElement *Charge_Vs_Index)
 
virtual void checkBookAPVColls (const edm::EventSetup &setup)
 
void dqmEndJob (DQMStore::IBooker &ibooker_, DQMStore::IGetter &igetter_) override
 
void gainQualityMonitor (DQMStore::IBooker &ibooker_, const MonitorElement *Charge_Vs_Index) const
 
std::unique_ptr< SiStripApvGaingetNewObject (const MonitorElement *Charge_Vs_Index)
 
void getPeakOfLandau (TH1 *InputHisto, double *FitResults, double LowRange=50, double HighRange=5400)
 
bool IsGoodLandauFit (double *FitResults)
 
bool produceTagFilter (const MonitorElement *Charge_Vs_Index)
 
int statCollectionFromMode (const char *tag) const
 

Private Attributes

std::unordered_map< unsigned
int, std::shared_ptr
< stAPVGain > > 
APVsColl
 
std::vector< std::shared_ptr
< stAPVGain > > 
APVsCollOrdered
 
unsigned int BAD
 
const TrackerGeometrybareTkGeomPtr_ = nullptr
 
int CalibrationLevel
 
bool doChargeMonitorPerPlane
 
bool doStoreOnDB
 
std::vector< std::string > dqm_tag_
 
edm::ESGetToken< SiStripGain,
SiStripGainRcd
gainToken_
 
unsigned int GOOD
 
std::string m_calibrationMode
 
std::string m_DQMdir
 
std::string m_Record
 
unsigned int MASKED
 
double MinNrEntries
 
int NPixelDets
 
int NStripAPVs
 
edm::ESGetToken
< SiStripQuality,
SiStripQualityRcd
qualityToken_
 
double tagCondition_GoodFrac
 
double tagCondition_NClusters
 
edm::ESGetToken
< TrackerGeometry,
TrackerDigiGeometryRecord
tkGeomToken_
 
std::unique_ptr< TrackerTopologytTopo_
 
edm::ESGetToken
< TrackerTopology,
TrackerTopologyRcd
tTopoToken_
 
std::vector< std::string > VChargeHisto
 

Additional Inherited Members

- Public Types inherited from DQMEDHarvester
typedef dqm::harvesting::DQMStore DQMStore
 
typedef
dqm::harvesting::MonitorElement 
MonitorElement
 
- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 
- Protected Attributes inherited from DQMEDHarvester
DQMStoredqmstore_
 
edm::GetterOfProducts< DQMTokenjobmegetter_
 
edm::EDPutTokenT< DQMTokenjobToken_
 
edm::GetterOfProducts< DQMTokenlumimegetter_
 
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::GetterOfProducts< DQMTokenrunmegetter_
 
edm::EDPutTokenT< DQMTokenrunToken_
 

Detailed Description

Description: Harvests output of SiStripGainsPCLWorker and creates histograms and Gains Payload

Definition at line 50 of file SiStripGainsPCLHarvester.h.

Constructor & Destructor Documentation

SiStripGainsPCLHarvester::SiStripGainsPCLHarvester ( const edm::ParameterSet ps)
explicit

Definition at line 29 of file SiStripGainsPCLHarvester.cc.

References CalibrationLevel, doChargeMonitorPerPlane, dqm_tag_, gainToken_, edm::ParameterSet::getUntrackedParameter(), m_calibrationMode, m_DQMdir, m_Record, MinNrEntries, qualityToken_, AlCaHLTBitMon_QueryRunRegistry::string, tagCondition_GoodFrac, tagCondition_NClusters, tkGeomToken_, tTopoToken_, and VChargeHisto.

30  : doStoreOnDB(false), GOOD(0), BAD(0), MASKED(0), NStripAPVs(0), NPixelDets(0) {
31  m_Record = ps.getUntrackedParameter<std::string>("Record", "SiStripApvGainRcd");
32  CalibrationLevel = ps.getUntrackedParameter<int>("CalibrationLevel", 0);
33  MinNrEntries = ps.getUntrackedParameter<double>("minNrEntries", 20);
34  m_DQMdir = ps.getUntrackedParameter<std::string>("DQMdir", "AlCaReco/SiStripGains");
35  m_calibrationMode = ps.getUntrackedParameter<std::string>("calibrationMode", "StdBunch");
36  tagCondition_NClusters = ps.getUntrackedParameter<double>("NClustersForTagProd", 2E8);
37  tagCondition_GoodFrac = ps.getUntrackedParameter<double>("GoodFracForTagProd", 0.95);
38  doChargeMonitorPerPlane = ps.getUntrackedParameter<bool>("doChargeMonitorPerPlane", false);
39  VChargeHisto = ps.getUntrackedParameter<std::vector<std::string>>("ChargeHisto");
40 
41  //Set the monitoring element tag and store
42  dqm_tag_.reserve(7);
43  dqm_tag_.clear();
44  dqm_tag_.push_back("StdBunch"); // statistic collection from Standard Collision Bunch @ 3.8 T
45  dqm_tag_.push_back("StdBunch0T"); // statistic collection from Standard Collision Bunch @ 0 T
46  dqm_tag_.push_back("AagBunch"); // statistic collection from First Collision After Abort Gap @ 3.8 T
47  dqm_tag_.push_back("AagBunch0T"); // statistic collection from First Collision After Abort Gap @ 0 T
48  dqm_tag_.push_back("IsoMuon"); // statistic collection from Isolated Muon @ 3.8 T
49  dqm_tag_.push_back("IsoMuon0T"); // statistic collection from Isolated Muon @ 0 T
50  dqm_tag_.push_back("Harvest"); // statistic collection: Harvest
51 
52  tTopoToken_ = esConsumes<edm::Transition::EndRun>();
53  tkGeomToken_ = esConsumes<edm::Transition::BeginRun>();
54  gainToken_ = esConsumes<edm::Transition::BeginRun>();
55  qualityToken_ = esConsumes<edm::Transition::BeginRun>();
56 }
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > dqm_tag_
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > qualityToken_
std::vector< std::string > VChargeHisto
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
edm::ESGetToken< SiStripGain, SiStripGainRcd > gainToken_
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_

Member Function Documentation

void SiStripGainsPCLHarvester::algoComputeMPVandGain ( const MonitorElement Charge_Vs_Index)
private

Definition at line 369 of file SiStripGainsPCLHarvester.cc.

References sistrip::APV, APVsColl, BAD, CalibrationLevel, getPeakOfLandau(), GOOD, Exhume::I, mps_fire::i, IsGoodLandauFit(), m_calibrationMode, MASKED, gpuVertexFinder::printf(), and submitPVResolutionJobs::stdout.

Referenced by dqmEndJob().

369  {
370  unsigned int I = 0;
371  TH1F* Proj = nullptr;
372  double FitResults[6];
373  double MPVmean = 300;
374 
375  if (Charge_Vs_Index == nullptr) {
376  edm::LogError("SiStripGainsPCLHarvester")
377  << "Harvesting: could not execute algoComputeMPVandGain method because " << m_calibrationMode
378  << " statistics cannot be retrieved.\n"
379  << "Please check if input contains " << m_calibrationMode << " data." << std::endl;
380  return;
381  }
382 
383  TH2S* chvsidx = (Charge_Vs_Index)->getTH2S();
384 
385  printf("Progressing Bar :0%% 20%% 40%% 60%% 80%% 100%%\n");
386  printf("Fitting Charge Distribution :");
387  int TreeStep = APVsColl.size() / 50;
388 
389  for (auto it = APVsColl.begin(); it != APVsColl.end(); it++, I++) {
390  if (I % TreeStep == 0) {
391  printf(".");
392  fflush(stdout);
393  }
394  std::shared_ptr<stAPVGain> APV = it->second;
395  if (APV->Bin < 0)
396  APV->Bin = chvsidx->GetXaxis()->FindBin(APV->Index);
397 
398  if (APV->isMasked) {
399  APV->Gain = APV->PreviousGain;
400  MASKED++;
401  continue;
402  }
403 
404  Proj = (TH1F*)(chvsidx->ProjectionY(
405  "", chvsidx->GetXaxis()->FindBin(APV->Index), chvsidx->GetXaxis()->FindBin(APV->Index), "e"));
406  if (!Proj)
407  continue;
408 
409  if (CalibrationLevel == 0) {
410  } else if (CalibrationLevel == 1) {
411  int SecondAPVId = APV->APVId;
412  if (SecondAPVId % 2 == 0) {
413  SecondAPVId = SecondAPVId + 1;
414  } else {
415  SecondAPVId = SecondAPVId - 1;
416  }
417  std::shared_ptr<stAPVGain> APV2 = APVsColl[(APV->DetId << 4) | SecondAPVId];
418  if (APV2->Bin < 0)
419  APV2->Bin = chvsidx->GetXaxis()->FindBin(APV2->Index);
420  TH1F* Proj2 = (TH1F*)(chvsidx->ProjectionY("", APV2->Bin, APV2->Bin, "e"));
421  if (Proj2) {
422  Proj->Add(Proj2, 1);
423  delete Proj2;
424  }
425  } else if (CalibrationLevel == 2) {
426  for (unsigned int i = 0; i < 16; i++) { //loop up to 6APV for Strip and up to 16 for Pixels
427  auto tmpit = APVsColl.find((APV->DetId << 4) | i);
428  if (tmpit == APVsColl.end())
429  continue;
430  std::shared_ptr<stAPVGain> APV2 = tmpit->second;
431  if (APV2->DetId != APV->DetId || APV2->APVId == APV->APVId)
432  continue;
433  if (APV2->Bin < 0)
434  APV2->Bin = chvsidx->GetXaxis()->FindBin(APV2->Index);
435  TH1F* Proj2 = (TH1F*)(chvsidx->ProjectionY("", APV2->Bin, APV2->Bin, "e"));
436  if (Proj2) {
437  Proj->Add(Proj2, 1);
438  delete Proj2;
439  }
440  }
441  } else {
442  CalibrationLevel = 0;
443  printf("Unknown Calibration Level, will assume %i\n", CalibrationLevel);
444  }
445 
446  getPeakOfLandau(Proj, FitResults);
447  APV->FitMPV = FitResults[0];
448  APV->FitMPVErr = FitResults[1];
449  APV->FitWidth = FitResults[2];
450  APV->FitWidthErr = FitResults[3];
451  APV->FitChi2 = FitResults[4];
452  APV->FitNorm = FitResults[5];
453  APV->NEntries = Proj->GetEntries();
454 
455  if (IsGoodLandauFit(FitResults)) {
456  APV->Gain = APV->FitMPV / MPVmean;
457  if (APV->SubDet > 2)
458  GOOD++;
459  } else {
460  APV->Gain = APV->PreviousGain;
461  if (APV->SubDet > 2)
462  BAD++;
463  }
464  if (APV->Gain <= 0)
465  APV->Gain = 1;
466 
467  delete Proj;
468  }
469  printf("\n");
470 }
Log< level::Error, false > LogError
void getPeakOfLandau(TH1 *InputHisto, double *FitResults, double LowRange=50, double HighRange=5400)
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
const std::complex< double > I
Definition: I.h:8
bool IsGoodLandauFit(double *FitResults)
std::unordered_map< unsigned int, std::shared_ptr< stAPVGain > > APVsColl
void SiStripGainsPCLHarvester::beginRun ( edm::Run const &  run,
edm::EventSetup const &  isetup 
)
override

Definition at line 60 of file SiStripGainsPCLHarvester.cc.

References a, sistrip::APV, APVsCollOrdered, checkBookAPVColls(), beamvalidation::exit(), gainToken_, edm::EventSetup::getData(), edm::EventSetup::getHandle(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, qualityToken_, and submitPVResolutionJobs::stdout.

60  {
61  using namespace edm;
62  static constexpr float defaultGainTick = 690. / 640.;
63 
64  this->checkBookAPVColls(iSetup); // check whether APV colls are booked and do so if not yet done
65 
66  const auto gainHandle = iSetup.getHandle(gainToken_);
67  if (!gainHandle.isValid()) {
68  edm::LogError("SiStripGainPCLHarvester") << "gainHandle is not valid\n";
69  exit(0);
70  }
71 
72  const auto& stripQuality = iSetup.getData(qualityToken_);
73 
74  for (unsigned int a = 0; a < APVsCollOrdered.size(); a++) {
75  std::shared_ptr<stAPVGain> APV = APVsCollOrdered[a];
76 
77  if (APV->SubDet == PixelSubdetector::PixelBarrel || APV->SubDet == PixelSubdetector::PixelEndcap)
78  continue;
79 
80  APV->isMasked = stripQuality.IsApvBad(APV->DetId, APV->APVId);
81 
82  if (gainHandle->getNumberOfTags() != 2) {
83  edm::LogError("SiStripGainPCLHarvester") << "NUMBER OF GAIN TAG IS EXPECTED TO BE 2\n";
84  fflush(stdout);
85  exit(0);
86  };
87  float newPreviousGain = gainHandle->getApvGain(APV->APVId, gainHandle->getRange(APV->DetId, 1), 1);
88  if (APV->PreviousGain != 1 and newPreviousGain != APV->PreviousGain)
89  edm::LogWarning("SiStripGainPCLHarvester") << "WARNING: ParticleGain in the global tag changed\n";
90  APV->PreviousGain = newPreviousGain;
91 
92  float newPreviousGainTick =
93  APV->isMasked ? defaultGainTick : gainHandle->getApvGain(APV->APVId, gainHandle->getRange(APV->DetId, 0), 0);
94  if (APV->PreviousGainTick != 1 and newPreviousGainTick != APV->PreviousGainTick) {
95  edm::LogWarning("SiStripGainPCLHarvester")
96  << "WARNING: TickMarkGain in the global tag changed\n"
97  << std::endl
98  << " APV->SubDet: " << APV->SubDet << " APV->APVId:" << APV->APVId << std::endl
99  << " APV->PreviousGainTick: " << APV->PreviousGainTick << " newPreviousGainTick: " << newPreviousGainTick
100  << std::endl;
101  }
102  APV->PreviousGainTick = newPreviousGainTick;
103  }
104 }
Log< level::Error, false > LogError
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > qualityToken_
virtual void checkBookAPVColls(const edm::EventSetup &setup)
std::vector< std::shared_ptr< stAPVGain > > APVsCollOrdered
double a
Definition: hdecay.h:119
edm::ESGetToken< SiStripGain, SiStripGainRcd > gainToken_
Log< level::Warning, false > LogWarning
void SiStripGainsPCLHarvester::checkBookAPVColls ( const edm::EventSetup setup)
privatevirtual

Definition at line 509 of file SiStripGainsPCLHarvester.cc.

References sistrip::APV, APVsColl, APVsCollOrdered, bareTkGeomPtr_, edm::EventSetup::getData(), mps_fire::i, dqmiolumiharvest::j, PixelTopology::ncolumns(), NPixelDets, PixelTopology::nrows(), NStripAPVs, StripTopology::nstrips(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, DetId::rawId(), ntupleEnum::SubDet, DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, tkGeomToken_, and StripSubdetector::TOB.

Referenced by beginRun().

509  {
510  auto newBareTkGeomPtr = &es.getData(tkGeomToken_);
511  if (newBareTkGeomPtr == bareTkGeomPtr_)
512  return; // already filled APVColls, nothing changed
513 
514  if (!bareTkGeomPtr_) { // pointer not yet set: called the first time => fill the APVColls
515  auto const& Det = newBareTkGeomPtr->dets();
516 
517  unsigned int Index = 0;
518 
519  for (unsigned int i = 0; i < Det.size(); i++) {
520  DetId Detid = Det[i]->geographicalId();
521  int SubDet = Detid.subdetId();
522 
523  if (SubDet == StripSubdetector::TIB || SubDet == StripSubdetector::TID || SubDet == StripSubdetector::TOB ||
524  SubDet == StripSubdetector::TEC) {
525  auto DetUnit = dynamic_cast<const StripGeomDetUnit*>(Det[i]);
526  if (!DetUnit)
527  continue;
528 
529  const StripTopology& Topo = DetUnit->specificTopology();
530  unsigned int NAPV = Topo.nstrips() / 128;
531 
532  for (unsigned int j = 0; j < NAPV; j++) {
533  auto APV = std::make_shared<stAPVGain>();
534  APV->Index = Index;
535  APV->Bin = -1;
536  APV->DetId = Detid.rawId();
537  APV->APVId = j;
538  APV->SubDet = SubDet;
539  APV->FitMPV = -1;
540  APV->FitMPVErr = -1;
541  APV->FitWidth = -1;
542  APV->FitWidthErr = -1;
543  APV->FitChi2 = -1;
544  APV->FitNorm = -1;
545  APV->Gain = -1;
546  APV->PreviousGain = 1;
547  APV->PreviousGainTick = 1;
548  APV->x = DetUnit->position().basicVector().x();
549  APV->y = DetUnit->position().basicVector().y();
550  APV->z = DetUnit->position().basicVector().z();
551  APV->Eta = DetUnit->position().basicVector().eta();
552  APV->Phi = DetUnit->position().basicVector().phi();
553  APV->R = DetUnit->position().basicVector().transverse();
554  APV->Thickness = DetUnit->surface().bounds().thickness();
555  APV->NEntries = 0;
556  APV->isMasked = false;
557 
558  APVsCollOrdered.push_back(APV);
559  APVsColl[(APV->DetId << 4) | APV->APVId] = APV;
560  Index++;
561  NStripAPVs++;
562  } // loop on APVs
563  } // if is Strips
564  } // loop on dets
565 
566  for (unsigned int i = 0; i < Det.size();
567  i++) { //Make two loop such that the Pixel information is added at the end --> make transition simpler
568  DetId Detid = Det[i]->geographicalId();
569  int SubDet = Detid.subdetId();
571  auto DetUnit = dynamic_cast<const PixelGeomDetUnit*>(Det[i]);
572  if (!DetUnit)
573  continue;
574 
575  const PixelTopology& Topo = DetUnit->specificTopology();
576  unsigned int NROCRow = Topo.nrows() / (80.);
577  unsigned int NROCCol = Topo.ncolumns() / (52.);
578 
579  for (unsigned int j = 0; j < NROCRow; j++) {
580  for (unsigned int i = 0; i < NROCCol; i++) {
581  auto APV = std::make_shared<stAPVGain>();
582  APV->Index = Index;
583  APV->Bin = -1;
584  APV->DetId = Detid.rawId();
585  APV->APVId = (j << 3 | i);
586  APV->SubDet = SubDet;
587  APV->FitMPV = -1;
588  APV->FitMPVErr = -1;
589  APV->FitWidth = -1;
590  APV->FitWidthErr = -1;
591  APV->FitChi2 = -1;
592  APV->Gain = -1;
593  APV->PreviousGain = 1;
594  APV->PreviousGainTick = 1;
595  APV->x = DetUnit->position().basicVector().x();
596  APV->y = DetUnit->position().basicVector().y();
597  APV->z = DetUnit->position().basicVector().z();
598  APV->Eta = DetUnit->position().basicVector().eta();
599  APV->Phi = DetUnit->position().basicVector().phi();
600  APV->R = DetUnit->position().basicVector().transverse();
601  APV->Thickness = DetUnit->surface().bounds().thickness();
602  APV->isMasked = false; //SiPixelQuality_->IsModuleBad(Detid.rawId());
603  APV->NEntries = 0;
604 
605  APVsCollOrdered.push_back(APV);
606  APVsColl[(APV->DetId << 4) | APV->APVId] = APV;
607  Index++;
608  NPixelDets++;
609 
610  } // loop on ROC cols
611  } // loop on ROC rows
612  } // if Pixel
613  } // loop on Dets
614  } //if (!bareTkGeomPtr_) ...
615  bareTkGeomPtr_ = newBareTkGeomPtr;
616 }
static constexpr auto TEC
virtual int nstrips() const =0
tuple SubDet
Definition: ntupleEnum.py:14
virtual int ncolumns() const =0
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
virtual int nrows() const =0
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
static constexpr auto TOB
Definition: DetId.h:17
static constexpr auto TIB
const TrackerGeometry * bareTkGeomPtr_
std::vector< std::shared_ptr< stAPVGain > > APVsCollOrdered
static constexpr auto TID
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
std::unordered_map< unsigned int, std::shared_ptr< stAPVGain > > APVsColl
void SiStripGainsPCLHarvester::dqmEndJob ( DQMStore::IBooker ibooker_,
DQMStore::IGetter igetter_ 
)
overrideprivatevirtual

Implements DQMEDHarvester.

Definition at line 107 of file SiStripGainsPCLHarvester.cc.

References algoComputeMPVandGain(), cond::service::PoolDBOutputService::currentTime(), doStoreOnDB, dqm_tag_, spr::find(), gainQualityMonitor(), dqm::implementation::IGetter::get(), getNewObject(), edm::Service< T >::isAvailable(), m_calibrationMode, m_DQMdir, m_Record, AlCaHLTBitMon_QueryRunRegistry::string, and cond::service::PoolDBOutputService::writeOneIOV().

107  {
108  edm::LogInfo("SiStripGainsPCLHarvester") << "Starting harvesting statistics" << std::endl;
109 
110  std::string DQM_dir = m_DQMdir;
111 
112  std::string stag = *(std::find(dqm_tag_.begin(), dqm_tag_.end(), m_calibrationMode));
113  if (!stag.empty() && stag[0] != '_')
114  stag.insert(0, 1, '_');
115 
116  std::string cvi = DQM_dir + std::string("/Charge_Vs_Index") + stag;
117 
118  MonitorElement* Charge_Vs_Index = igetter_.get(cvi);
119 
120  if (Charge_Vs_Index == nullptr) {
121  edm::LogError("SiStripGainsPCLHarvester")
122  << "Harvesting: could not retrieve " << cvi.c_str() << ", statistics will not be summed!" << std::endl;
123  } else {
124  edm::LogInfo("SiStripGainsPCLHarvester")
125  << "Harvesting " << (Charge_Vs_Index)->getTH2S()->GetEntries() << " more clusters" << std::endl;
126  }
127 
128  algoComputeMPVandGain(Charge_Vs_Index);
129  std::unique_ptr<SiStripApvGain> theAPVGains = this->getNewObject(Charge_Vs_Index);
130 
131  // write out the APVGains record
133 
134  if (doStoreOnDB) {
135  if (poolDbService.isAvailable())
136  poolDbService->writeOneIOV(*theAPVGains, poolDbService->currentTime(), m_Record);
137  else
138  throw std::runtime_error("PoolDBService required.");
139  } else {
140  edm::LogInfo("SiStripGainsPCLHarvester") << "Will not produce payload!" << std::endl;
141  }
142 
143  //Collect the statistics for monitoring and validation
144  gainQualityMonitor(ibooker_, Charge_Vs_Index);
145 }
std::unique_ptr< SiStripApvGain > getNewObject(const MonitorElement *Charge_Vs_Index)
std::vector< std::string > dqm_tag_
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void algoComputeMPVandGain(const MonitorElement *Charge_Vs_Index)
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
bool isAvailable() const
Definition: Service.h:40
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
Log< level::Info, false > LogInfo
void gainQualityMonitor(DQMStore::IBooker &ibooker_, const MonitorElement *Charge_Vs_Index) const
void SiStripGainsPCLHarvester::endRun ( edm::Run const &  run,
edm::EventSetup const &  isetup 
)
override

Definition at line 701 of file SiStripGainsPCLHarvester.cc.

References edm::EventSetup::getData(), tTopo_, and tTopoToken_.

701  {
702  if (!tTopo_) {
703  tTopo_ = std::make_unique<TrackerTopology>(isetup.getData(tTopoToken_));
704  }
705 }
std::unique_ptr< TrackerTopology > tTopo_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
void SiStripGainsPCLHarvester::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static
void SiStripGainsPCLHarvester::gainQualityMonitor ( DQMStore::IBooker ibooker_,
const MonitorElement Charge_Vs_Index 
) const
private

Definition at line 148 of file SiStripGainsPCLHarvester.cc.

References a, sistrip::APV, APVsCollOrdered, newFWLiteAna::bin, dqm::implementation::IBooker::book1DD(), dqm::implementation::IBooker::book2DD(), DetId::DetId(), doChargeMonitorPerPlane, alignCSCRings::e, APVGain::FetchMonitor(), dqm::impl::MonitorElement::Fill(), first, h, mps_fire::i, APVGain::monHnames(), colinearityKinematic::Phi, dttmaxenums::R, edm::second(), dqm::implementation::NavigatorBase::setCurrentFolder(), ntupleEnum::SubDet, APVGain::subdetectorId(), APVGain::subdetectorPlane(), APVGain::subdetectorSide(), APVGain::thickness(), tTopo_, VChargeHisto, and z.

Referenced by dqmEndJob().

149  {
150  ibooker_.setCurrentFolder("AlCaReco/SiStripGainsHarvesting/");
151 
152  std::vector<APVGain::APVmon> new_charge_histos;
153  std::vector<std::pair<std::string, std::string>> cnames =
155  for (unsigned int i = 0; i < cnames.size(); i++) {
156  MonitorElement* monitor = ibooker_.book1DD((cnames[i]).first, (cnames[i]).second.c_str(), 100, 0., 1000.);
157  int thick = APVGain::thickness((cnames[i]).first);
158  int id = APVGain::subdetectorId((cnames[i]).first);
159  int side = APVGain::subdetectorSide((cnames[i]).first);
160  int plane = APVGain::subdetectorPlane((cnames[i]).first);
161  new_charge_histos.push_back(APVGain::APVmon(thick, id, side, plane, monitor));
162  }
163 
164  int MPVbin = 300;
165  float MPVmin = 0.;
166  float MPVmax = 600.;
167 
168  MonitorElement* MPV_Vs_EtaTIB =
169  ibooker_.book2DD("MPVvsEtaTIB", "MPV vs Eta TIB", 50, -3.0, 3.0, MPVbin, MPVmin, MPVmax);
170  MonitorElement* MPV_Vs_EtaTID =
171  ibooker_.book2DD("MPVvsEtaTID", "MPV vs Eta TID", 50, -3.0, 3.0, MPVbin, MPVmin, MPVmax);
172  MonitorElement* MPV_Vs_EtaTOB =
173  ibooker_.book2DD("MPVvsEtaTOB", "MPV vs Eta TOB", 50, -3.0, 3.0, MPVbin, MPVmin, MPVmax);
174  MonitorElement* MPV_Vs_EtaTEC =
175  ibooker_.book2DD("MPVvsEtaTEC", "MPV vs Eta TEC", 50, -3.0, 3.0, MPVbin, MPVmin, MPVmax);
176  MonitorElement* MPV_Vs_EtaTECthin =
177  ibooker_.book2DD("MPVvsEtaTEC1", "MPV vs Eta TEC-thin", 50, -3.0, 3.0, MPVbin, MPVmin, MPVmax);
178  MonitorElement* MPV_Vs_EtaTECthick =
179  ibooker_.book2DD("MPVvsEtaTEC2", "MPV vs Eta TEC-thick", 50, -3.0, 3.0, MPVbin, MPVmin, MPVmax);
180 
181  MonitorElement* MPV_Vs_PhiTIB =
182  ibooker_.book2DD("MPVvsPhiTIB", "MPV vs Phi TIB", 50, -3.4, 3.4, MPVbin, MPVmin, MPVmax);
183  MonitorElement* MPV_Vs_PhiTID =
184  ibooker_.book2DD("MPVvsPhiTID", "MPV vs Phi TID", 50, -3.4, 3.4, MPVbin, MPVmin, MPVmax);
185  MonitorElement* MPV_Vs_PhiTOB =
186  ibooker_.book2DD("MPVvsPhiTOB", "MPV vs Phi TOB", 50, -3.4, 3.4, MPVbin, MPVmin, MPVmax);
187  MonitorElement* MPV_Vs_PhiTEC =
188  ibooker_.book2DD("MPVvsPhiTEC", "MPV vs Phi TEC", 50, -3.4, 3.4, MPVbin, MPVmin, MPVmax);
189  MonitorElement* MPV_Vs_PhiTECthin =
190  ibooker_.book2DD("MPVvsPhiTEC1", "MPV vs Phi TEC-thin ", 50, -3.4, 3.4, MPVbin, MPVmin, MPVmax);
191  MonitorElement* MPV_Vs_PhiTECthick =
192  ibooker_.book2DD("MPVvsPhiTEC2", "MPV vs Phi TEC-thick", 50, -3.4, 3.4, MPVbin, MPVmin, MPVmax);
193 
194  MonitorElement* NoMPVfit = ibooker_.book2DD("NoMPVfit", "Modules with bad Landau Fit", 350, -350, 350, 240, 0, 120);
195  MonitorElement* NoMPVmasked = ibooker_.book2DD("NoMPVmasked", "Masked Modules", 350, -350, 350, 240, 0, 120);
196 
197  MonitorElement* Gains = ibooker_.book1DD("Gains", "Gains", 300, 0, 2);
198  MonitorElement* MPVs = ibooker_.book1DD("MPVs", "MPVs", MPVbin, MPVmin, MPVmax);
199  MonitorElement* MPVs320 = ibooker_.book1DD("MPV_320", "MPV 320 thickness", MPVbin, MPVmin, MPVmax);
200  MonitorElement* MPVs500 = ibooker_.book1DD("MPV_500", "MPV 500 thickness", MPVbin, MPVmin, MPVmax);
201  MonitorElement* MPVsTIB = ibooker_.book1DD("MPV_TIB", "MPV TIB", MPVbin, MPVmin, MPVmax);
202  MonitorElement* MPVsTID = ibooker_.book1DD("MPV_TID", "MPV TID", MPVbin, MPVmin, MPVmax);
203  MonitorElement* MPVsTIDP = ibooker_.book1DD("MPV_TIDP", "MPV TIDP", MPVbin, MPVmin, MPVmax);
204  MonitorElement* MPVsTIDM = ibooker_.book1DD("MPV_TIDM", "MPV TIDM", MPVbin, MPVmin, MPVmax);
205  MonitorElement* MPVsTOB = ibooker_.book1DD("MPV_TOB", "MPV TOB", MPVbin, MPVmin, MPVmax);
206  MonitorElement* MPVsTEC = ibooker_.book1DD("MPV_TEC", "MPV TEC", MPVbin, MPVmin, MPVmax);
207  MonitorElement* MPVsTECP = ibooker_.book1DD("MPV_TECP", "MPV TECP", MPVbin, MPVmin, MPVmax);
208  MonitorElement* MPVsTECM = ibooker_.book1DD("MPV_TECM", "MPV TECM", MPVbin, MPVmin, MPVmax);
209  MonitorElement* MPVsTECthin = ibooker_.book1DD("MPV_TEC1", "MPV TEC thin", MPVbin, MPVmin, MPVmax);
210  MonitorElement* MPVsTECthick = ibooker_.book1DD("MPV_TEC2", "MPV TEC thick", MPVbin, MPVmin, MPVmax);
211  MonitorElement* MPVsTECP1 = ibooker_.book1DD("MPV_TECP1", "MPV TECP thin ", MPVbin, MPVmin, MPVmax);
212  MonitorElement* MPVsTECP2 = ibooker_.book1DD("MPV_TECP2", "MPV TECP thick", MPVbin, MPVmin, MPVmax);
213  MonitorElement* MPVsTECM1 = ibooker_.book1DD("MPV_TECM1", "MPV TECM thin", MPVbin, MPVmin, MPVmax);
214  MonitorElement* MPVsTECM2 = ibooker_.book1DD("MPV_TECM2", "MPV TECM thick", MPVbin, MPVmin, MPVmax);
215 
216  MonitorElement* MPVError = ibooker_.book1DD("MPVError", "MPV Error", 150, 0, 150);
217  MonitorElement* MPVErrorVsMPV = ibooker_.book2DD("MPVErrorVsMPV", "MPV Error vs MPV", 300, 0, 600, 150, 0, 150);
218  MonitorElement* MPVErrorVsEta = ibooker_.book2DD("MPVErrorVsEta", "MPV Error vs Eta", 50, -3.0, 3.0, 150, 0, 150);
219  MonitorElement* MPVErrorVsPhi = ibooker_.book2DD("MPVErrorVsPhi", "MPV Error vs Phi", 50, -3.4, 3.4, 150, 0, 150);
220  MonitorElement* MPVErrorVsN = ibooker_.book2DD("MPVErrorVsN", "MPV Error vs N", 500, 0, 1000, 150, 0, 150);
221 
222  MonitorElement* DiffWRTPrevGainTIB = ibooker_.book1DD("DiffWRTPrevGainTIB", "Diff w.r.t. PrevGain TIB", 250, 0, 2);
223  MonitorElement* DiffWRTPrevGainTID = ibooker_.book1DD("DiffWRTPrevGainTID", "Diff w.r.t. PrevGain TID", 250, 0, 2);
224  MonitorElement* DiffWRTPrevGainTOB = ibooker_.book1DD("DiffWRTPrevGainTOB", "Diff w.r.t. PrevGain TOB", 250, 0, 2);
225  MonitorElement* DiffWRTPrevGainTEC = ibooker_.book1DD("DiffWRTPrevGainTEC", "Diff w.r.t. PrevGain TEC", 250, 0, 2);
226 
227  MonitorElement* GainVsPrevGainTIB =
228  ibooker_.book2DD("GainVsPrevGainTIB", "Gain vs PrevGain TIB", 100, 0, 2, 100, 0, 2);
229  MonitorElement* GainVsPrevGainTID =
230  ibooker_.book2DD("GainVsPrevGainTID", "Gain vs PrevGain TID", 100, 0, 2, 100, 0, 2);
231  MonitorElement* GainVsPrevGainTOB =
232  ibooker_.book2DD("GainVsPrevGainTOB", "Gain vs PrevGain TOB", 100, 0, 2, 100, 0, 2);
233  MonitorElement* GainVsPrevGainTEC =
234  ibooker_.book2DD("GainVsPrevGainTEC", "Gain vs PrevGain TEC", 100, 0, 2, 100, 0, 2);
235 
236  for (unsigned int a = 0; a < APVsCollOrdered.size(); a++) {
237  std::shared_ptr<stAPVGain> APV = APVsCollOrdered[a];
238  if (APV == nullptr)
239  continue;
240 
241  unsigned int Index = APV->Index;
242  unsigned int SubDet = APV->SubDet;
243  unsigned int DetId = APV->DetId;
244  float z = APV->z;
245  float Eta = APV->Eta;
246  float R = APV->R;
247  float Phi = APV->Phi;
248  float Thickness = APV->Thickness;
249  double FitMPV = APV->FitMPV;
250  double FitMPVErr = APV->FitMPVErr;
251  double Gain = APV->Gain;
252  double NEntries = APV->NEntries;
253  double PreviousGain = APV->PreviousGain;
254 
255  if (SubDet < 3)
256  continue; // avoid to loop over Pixel det id
257 
258  if (Gain != 1.) {
259  std::vector<MonitorElement*> charge_histos = APVGain::FetchMonitor(new_charge_histos, DetId, tTopo_.get());
260 
261  if (!Charge_Vs_Index)
262  continue;
263  TH2S* chvsidx = (Charge_Vs_Index)->getTH2S();
264  int bin = chvsidx->GetXaxis()->FindBin(Index);
265  TH1D* Proj = chvsidx->ProjectionY("proj", bin, bin);
266  for (int binId = 0; binId < Proj->GetXaxis()->GetNbins(); binId++) {
267  double new_charge = Proj->GetXaxis()->GetBinCenter(binId) / Gain;
268  if (Proj->GetBinContent(binId) != 0.) {
269  for (unsigned int h = 0; h < charge_histos.size(); h++) {
270  TH1D* chisto = (charge_histos[h])->getTH1D();
271  for (int e = 0; e < Proj->GetBinContent(binId); e++)
272  chisto->Fill(new_charge);
273  }
274  }
275  }
276  }
277 
278  if (FitMPV <= 0.) { // No fit of MPV
279  if (APV->isMasked)
280  NoMPVmasked->Fill(z, R);
281  else
282  NoMPVfit->Fill(z, R);
283 
284  } else { // Fit of MPV
285  if (FitMPV > 0.)
286  Gains->Fill(Gain);
287 
288  MPVs->Fill(FitMPV);
289  if (Thickness < 0.04)
290  MPVs320->Fill(FitMPV);
291  if (Thickness > 0.04)
292  MPVs500->Fill(FitMPV);
293 
294  MPVError->Fill(FitMPVErr);
295  MPVErrorVsMPV->Fill(FitMPV, FitMPVErr);
296  MPVErrorVsEta->Fill(Eta, FitMPVErr);
297  MPVErrorVsPhi->Fill(Phi, FitMPVErr);
298  MPVErrorVsN->Fill(NEntries, FitMPVErr);
299 
300  if (SubDet == 3) {
301  MPV_Vs_EtaTIB->Fill(Eta, FitMPV);
302  MPV_Vs_PhiTIB->Fill(Phi, FitMPV);
303  MPVsTIB->Fill(FitMPV);
304 
305  } else if (SubDet == 4) {
306  MPV_Vs_EtaTID->Fill(Eta, FitMPV);
307  MPV_Vs_PhiTID->Fill(Phi, FitMPV);
308  MPVsTID->Fill(FitMPV);
309  if (Eta < 0.)
310  MPVsTIDM->Fill(FitMPV);
311  if (Eta > 0.)
312  MPVsTIDP->Fill(FitMPV);
313 
314  } else if (SubDet == 5) {
315  MPV_Vs_EtaTOB->Fill(Eta, FitMPV);
316  MPV_Vs_PhiTOB->Fill(Phi, FitMPV);
317  MPVsTOB->Fill(FitMPV);
318 
319  } else if (SubDet == 6) {
320  MPV_Vs_EtaTEC->Fill(Eta, FitMPV);
321  MPV_Vs_PhiTEC->Fill(Phi, FitMPV);
322  MPVsTEC->Fill(FitMPV);
323  if (Eta < 0.)
324  MPVsTECM->Fill(FitMPV);
325  if (Eta > 0.)
326  MPVsTECP->Fill(FitMPV);
327  if (Thickness < 0.04) {
328  MPV_Vs_EtaTECthin->Fill(Eta, FitMPV);
329  MPV_Vs_PhiTECthin->Fill(Phi, FitMPV);
330  MPVsTECthin->Fill(FitMPV);
331  if (Eta > 0.)
332  MPVsTECP1->Fill(FitMPV);
333  if (Eta < 0.)
334  MPVsTECM1->Fill(FitMPV);
335  }
336  if (Thickness > 0.04) {
337  MPV_Vs_EtaTECthick->Fill(Eta, FitMPV);
338  MPV_Vs_PhiTECthick->Fill(Phi, FitMPV);
339  MPVsTECthick->Fill(FitMPV);
340  if (Eta > 0.)
341  MPVsTECP2->Fill(FitMPV);
342  if (Eta < 0.)
343  MPVsTECM2->Fill(FitMPV);
344  }
345  }
346  }
347 
348  if (SubDet == 3 && PreviousGain != 0.)
349  DiffWRTPrevGainTIB->Fill(Gain / PreviousGain);
350  else if (SubDet == 4 && PreviousGain != 0.)
351  DiffWRTPrevGainTID->Fill(Gain / PreviousGain);
352  else if (SubDet == 5 && PreviousGain != 0.)
353  DiffWRTPrevGainTOB->Fill(Gain / PreviousGain);
354  else if (SubDet == 6 && PreviousGain != 0.)
355  DiffWRTPrevGainTEC->Fill(Gain / PreviousGain);
356 
357  if (SubDet == 3)
358  GainVsPrevGainTIB->Fill(PreviousGain, Gain);
359  else if (SubDet == 4)
360  GainVsPrevGainTID->Fill(PreviousGain, Gain);
361  else if (SubDet == 5)
362  GainVsPrevGainTOB->Fill(PreviousGain, Gain);
363  else if (SubDet == 6)
364  GainVsPrevGainTEC->Fill(PreviousGain, Gain);
365  }
366 }
tuple SubDet
Definition: ntupleEnum.py:14
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
int subdetectorPlane(uint32_t, const TrackerTopology *)
void Fill(long long x)
U second(std::pair< T, U > const &p)
MonitorElement * book1DD(TString const &name, TString const &title, int nchX, double lowX, double highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:155
std::vector< std::string > VChargeHisto
std::unique_ptr< TrackerTopology > tTopo_
Definition: DetId.h:17
std::vector< MonitorElement * > FetchMonitor(std::vector< APVmon >, uint32_t, const TrackerTopology *topo=nullptr)
int subdetectorSide(uint32_t, const TrackerTopology *)
int thickness(uint32_t)
MonitorElement * book2DD(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:261
std::vector< std::shared_ptr< stAPVGain > > APVsCollOrdered
double a
Definition: hdecay.h:119
std::vector< std::pair< std::string, std::string > > monHnames(std::vector< std::string >, bool, const char *tag)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
int subdetectorId(uint32_t)
constexpr DetId()
Create an empty or null id (also for persistence)
Definition: DetId.h:38
std::unique_ptr< SiStripApvGain > SiStripGainsPCLHarvester::getNewObject ( const MonitorElement Charge_Vs_Index)
private

Definition at line 648 of file SiStripGainsPCLHarvester.cc.

References a, sistrip::APV, APVsCollOrdered, doStoreOnDB, LogDebug, getGTfromDQMFile::obj, gpuVertexFinder::printf(), produceTagFilter(), and sistrip::SpyUtilities::range().

Referenced by dqmEndJob().

648  {
649  std::unique_ptr<SiStripApvGain> obj = std::make_unique<SiStripApvGain>();
650 
651  if (!produceTagFilter(Charge_Vs_Index)) {
652  edm::LogWarning("SiStripGainsPCLHarvester")
653  << "getNewObject -> will not produce a paylaod because produceTagFilter returned false " << std::endl;
654  return obj;
655  } else {
656  doStoreOnDB = true;
657  }
658 
659  std::vector<float> theSiStripVector;
660  unsigned int PreviousDetId = 0;
661  for (unsigned int a = 0; a < APVsCollOrdered.size(); a++) {
662  std::shared_ptr<stAPVGain> APV = APVsCollOrdered[a];
663  if (APV == nullptr) {
664  printf("Bug\n");
665  continue;
666  }
667  if (APV->SubDet <= 2)
668  continue;
669  if (APV->DetId != PreviousDetId) {
670  if (!theSiStripVector.empty()) {
671  SiStripApvGain::Range range(theSiStripVector.begin(), theSiStripVector.end());
672  if (!obj->put(PreviousDetId, range))
673  printf("Bug to put detId = %i\n", PreviousDetId);
674  }
675  theSiStripVector.clear();
676  PreviousDetId = APV->DetId;
677  }
678  theSiStripVector.push_back(APV->Gain);
679 
680  LogDebug("SiStripGainsPCLHarvester") << " DetId: " << APV->DetId << " APV: " << APV->APVId
681  << " Gain: " << APV->Gain << std::endl;
682  }
683  if (!theSiStripVector.empty()) {
684  SiStripApvGain::Range range(theSiStripVector.begin(), theSiStripVector.end());
685  if (!obj->put(PreviousDetId, range))
686  printf("Bug to put detId = %i\n", PreviousDetId);
687  }
688 
689  return obj;
690 }
bool produceTagFilter(const MonitorElement *Charge_Vs_Index)
const uint16_t range(const Frame &aFrame)
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
std::pair< ContainerIterator, ContainerIterator > Range
std::vector< std::shared_ptr< stAPVGain > > APVsCollOrdered
double a
Definition: hdecay.h:119
Log< level::Warning, false > LogWarning
#define LogDebug(id)
void SiStripGainsPCLHarvester::getPeakOfLandau ( TH1 *  InputHisto,
double *  FitResults,
double  LowRange = 50,
double  HighRange = 5400 
)
private

Definition at line 473 of file SiStripGainsPCLHarvester.cc.

References MinNrEntries.

Referenced by algoComputeMPVandGain().

473  {
474  FitResults[0] = -0.5; //MPV
475  FitResults[1] = 0; //MPV error
476  FitResults[2] = -0.5; //Width
477  FitResults[3] = 0; //Width error
478  FitResults[4] = -0.5; //Fit Chi2/NDF
479  FitResults[5] = 0; //Normalization
480 
481  if (InputHisto->GetEntries() < MinNrEntries)
482  return;
483 
484  // perform fit with standard landau
485  TF1 MyLandau("MyLandau", "landau", LowRange, HighRange);
486  MyLandau.SetParameter(1, 300);
487  InputHisto->Fit(&MyLandau, "0QR WW");
488 
489  // MPV is parameter 1 (0=constant, 1=MPV, 2=Sigma)
490  FitResults[0] = MyLandau.GetParameter(1); //MPV
491  FitResults[1] = MyLandau.GetParError(1); //MPV error
492  FitResults[2] = MyLandau.GetParameter(2); //Width
493  FitResults[3] = MyLandau.GetParError(2); //Width error
494  FitResults[4] = MyLandau.GetChisquare() / MyLandau.GetNDF(); //Fit Chi2/NDF
495  FitResults[5] = MyLandau.GetParameter(0);
496 }
bool SiStripGainsPCLHarvester::IsGoodLandauFit ( double *  FitResults)
private

Definition at line 499 of file SiStripGainsPCLHarvester.cc.

Referenced by algoComputeMPVandGain().

499  {
500  if (FitResults[0] <= 0)
501  return false;
502  // if(FitResults[1] > MaxMPVError )return false;
503  // if(FitResults[4] > MaxChi2OverNDF)return false;
504  return true;
505 }
bool SiStripGainsPCLHarvester::produceTagFilter ( const MonitorElement Charge_Vs_Index)
private

Definition at line 619 of file SiStripGainsPCLHarvester.cc.

References BAD, GOOD, funct::integral(), m_calibrationMode, NStripAPVs, tagCondition_GoodFrac, and tagCondition_NClusters.

Referenced by getNewObject().

619  {
620  // The goal of this function is to check wether or not there is enough statistics
621  // to produce a meaningful tag for the DB
622 
623  if (Charge_Vs_Index == nullptr) {
624  edm::LogError("SiStripGainsPCLHarvester")
625  << "produceTagFilter -> Return false: could not retrieve the " << m_calibrationMode << " statistics.\n"
626  << "Please check if input contains " << m_calibrationMode << " data." << std::endl;
627  return false;
628  }
629 
630  float integral = (Charge_Vs_Index)->getTH2S()->Integral();
631  if ((Charge_Vs_Index)->getTH2S()->Integral(0, NStripAPVs + 1, 0, 99999) < tagCondition_NClusters) {
632  edm::LogWarning("SiStripGainsPCLHarvester")
633  << "calibrationMode -> " << m_calibrationMode << "\n"
634  << "produceTagFilter -> Return false: Statistics is too low : " << integral << std::endl;
635  return false;
636  }
637  if ((1.0 * GOOD) / (GOOD + BAD) < tagCondition_GoodFrac) {
638  edm::LogWarning("SiStripGainsPCLHarvester")
639  << "calibrationMode -> " << m_calibrationMode << "\n"
640  << "produceTagFilter -> Return false: ratio of GOOD/TOTAL is too low: " << (1.0 * GOOD) / (GOOD + BAD)
641  << std::endl;
642  return false;
643  }
644  return true;
645 }
Log< level::Error, false > LogError
Integral< F, X >::type integral(const F &f)
Definition: Integral.h:70
Log< level::Warning, false > LogWarning
int SiStripGainsPCLHarvester::statCollectionFromMode ( const char *  tag) const
private

Member Data Documentation

std::unordered_map<unsigned int, std::shared_ptr<stAPVGain> > SiStripGainsPCLHarvester::APVsColl
private

Definition at line 99 of file SiStripGainsPCLHarvester.h.

Referenced by algoComputeMPVandGain(), and checkBookAPVColls().

std::vector<std::shared_ptr<stAPVGain> > SiStripGainsPCLHarvester::APVsCollOrdered
private
unsigned int SiStripGainsPCLHarvester::BAD
private

Definition at line 75 of file SiStripGainsPCLHarvester.h.

Referenced by algoComputeMPVandGain(), and produceTagFilter().

const TrackerGeometry* SiStripGainsPCLHarvester::bareTkGeomPtr_ = nullptr
private

Definition at line 95 of file SiStripGainsPCLHarvester.h.

Referenced by checkBookAPVColls().

int SiStripGainsPCLHarvester::CalibrationLevel
private

Definition at line 93 of file SiStripGainsPCLHarvester.h.

Referenced by algoComputeMPVandGain(), and SiStripGainsPCLHarvester().

bool SiStripGainsPCLHarvester::doChargeMonitorPerPlane
private

Charge monitor per detector plane

Definition at line 73 of file SiStripGainsPCLHarvester.h.

Referenced by gainQualityMonitor(), and SiStripGainsPCLHarvester().

bool SiStripGainsPCLHarvester::doStoreOnDB
private

Definition at line 72 of file SiStripGainsPCLHarvester.h.

Referenced by dqmEndJob(), and getNewObject().

std::vector<std::string> SiStripGainsPCLHarvester::dqm_tag_
private

Definition at line 91 of file SiStripGainsPCLHarvester.h.

Referenced by dqmEndJob(), and SiStripGainsPCLHarvester().

edm::ESGetToken<SiStripGain, SiStripGainRcd> SiStripGainsPCLHarvester::gainToken_
private

Definition at line 103 of file SiStripGainsPCLHarvester.h.

Referenced by beginRun(), and SiStripGainsPCLHarvester().

unsigned int SiStripGainsPCLHarvester::GOOD
private

Definition at line 74 of file SiStripGainsPCLHarvester.h.

Referenced by algoComputeMPVandGain(), and produceTagFilter().

std::string SiStripGainsPCLHarvester::m_calibrationMode
private

Type of statistics for the calibration

Definition at line 88 of file SiStripGainsPCLHarvester.h.

Referenced by algoComputeMPVandGain(), dqmEndJob(), produceTagFilter(), and SiStripGainsPCLHarvester().

std::string SiStripGainsPCLHarvester::m_DQMdir
private

DQM folder hosting the charge statistics and the monitor plots

Definition at line 87 of file SiStripGainsPCLHarvester.h.

Referenced by dqmEndJob(), and SiStripGainsPCLHarvester().

std::string SiStripGainsPCLHarvester::m_Record
private

Definition at line 85 of file SiStripGainsPCLHarvester.h.

Referenced by dqmEndJob(), and SiStripGainsPCLHarvester().

unsigned int SiStripGainsPCLHarvester::MASKED
private

Definition at line 76 of file SiStripGainsPCLHarvester.h.

Referenced by algoComputeMPVandGain().

double SiStripGainsPCLHarvester::MinNrEntries
private

Definition at line 83 of file SiStripGainsPCLHarvester.h.

Referenced by getPeakOfLandau(), and SiStripGainsPCLHarvester().

int SiStripGainsPCLHarvester::NPixelDets
private

Definition at line 82 of file SiStripGainsPCLHarvester.h.

Referenced by checkBookAPVColls().

int SiStripGainsPCLHarvester::NStripAPVs
private

Definition at line 81 of file SiStripGainsPCLHarvester.h.

Referenced by checkBookAPVColls(), and produceTagFilter().

edm::ESGetToken<SiStripQuality, SiStripQualityRcd> SiStripGainsPCLHarvester::qualityToken_
private

Definition at line 104 of file SiStripGainsPCLHarvester.h.

Referenced by beginRun(), and SiStripGainsPCLHarvester().

double SiStripGainsPCLHarvester::tagCondition_GoodFrac
private

Definition at line 79 of file SiStripGainsPCLHarvester.h.

Referenced by produceTagFilter(), and SiStripGainsPCLHarvester().

double SiStripGainsPCLHarvester::tagCondition_NClusters
private

Definition at line 78 of file SiStripGainsPCLHarvester.h.

Referenced by produceTagFilter(), and SiStripGainsPCLHarvester().

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> SiStripGainsPCLHarvester::tkGeomToken_
private

Definition at line 102 of file SiStripGainsPCLHarvester.h.

Referenced by checkBookAPVColls(), and SiStripGainsPCLHarvester().

std::unique_ptr<TrackerTopology> SiStripGainsPCLHarvester::tTopo_
private

Definition at line 96 of file SiStripGainsPCLHarvester.h.

Referenced by endRun(), and gainQualityMonitor().

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> SiStripGainsPCLHarvester::tTopoToken_
private

Definition at line 101 of file SiStripGainsPCLHarvester.h.

Referenced by endRun(), and SiStripGainsPCLHarvester().

std::vector<std::string> SiStripGainsPCLHarvester::VChargeHisto
private

Charge monitor plots to be output

Definition at line 89 of file SiStripGainsPCLHarvester.h.

Referenced by gainQualityMonitor(), and SiStripGainsPCLHarvester().