CMS 3D CMS Logo

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::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

virtual void beginRun (edm::Run const &run, edm::EventSetup const &isetup)
 
virtual void endRun (edm::Run const &run, edm::EventSetup const &isetup)
 
 SiStripGainsPCLHarvester (const edm::ParameterSet &ps)
 
- Public Member Functions inherited from DQMEDHarvester
virtual void analyze (edm::Event const &, edm::EventSetup const &) final
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
 DQMEDHarvester (void)
 
virtual void dqmEndLuminosityBlock (DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void endJob () final
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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 & itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, 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 updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
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)
 
virtual void dqmEndJob (DQMStore::IBooker &ibooker_, DQMStore::IGetter &igetter_)
 
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_
 
int CalibrationLevel
 
bool doStoreOnDB
 
std::vector< std::string > dqm_tag_
 
unsigned int GOOD
 
std::string m_calibrationMode
 
std::string m_DQMdir
 
std::string m_Record
 
unsigned int MASKED
 
double MinNrEntries
 
int NPixelDets
 
int NStripAPVs
 
double tagCondition_GoodFrac
 
double tagCondition_NClusters
 
edm::ESHandle< TrackerGeometrytkGeom_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 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)
 

Detailed Description

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

Definition at line 44 of file SiStripGainsPCLHarvester.h.

Constructor & Destructor Documentation

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

Definition at line 36 of file SiStripGainsPCLHarvester.cc.

References CalibrationLevel, dqm_tag_, edm::ParameterSet::getUntrackedParameter(), m_calibrationMode, m_DQMdir, m_Record, MinNrEntries, AlCaHLTBitMon_QueryRunRegistry::string, tagCondition_GoodFrac, and tagCondition_NClusters.

36  :
37  doStoreOnDB(false),
38  GOOD(0),
39  BAD(0),
40  MASKED(0),
41  NStripAPVs(0),
42  NPixelDets(0),
43  bareTkGeomPtr_(nullptr)
44 {
45 
46  m_Record = ps.getUntrackedParameter<std::string> ("Record" , "SiStripApvGainRcd");
47  CalibrationLevel = ps.getUntrackedParameter<int> ("CalibrationLevel" , 0);
48  MinNrEntries = ps.getUntrackedParameter<double> ("minNrEntries" , 20);
49  m_DQMdir = ps.getUntrackedParameter<std::string> ("DQMdir" , "AlCaReco/SiStripGains");
50  m_calibrationMode = ps.getUntrackedParameter<std::string> ("calibrationMode" , "StdBunch");
51  tagCondition_NClusters = ps.getUntrackedParameter<double> ("NClustersForTagProd", 2E8);
52  tagCondition_GoodFrac = ps.getUntrackedParameter<double> ("GoodFracForTagProd" , 0.95);
53 
54  //Set the monitoring element tag and store
55  dqm_tag_.reserve(7);
56  dqm_tag_.clear();
57  dqm_tag_.push_back( "StdBunch" ); // statistic collection from Standard Collision Bunch @ 3.8 T
58  dqm_tag_.push_back( "StdBunch0T" ); // statistic collection from Standard Collision Bunch @ 0 T
59  dqm_tag_.push_back( "AagBunch" ); // statistic collection from First Collision After Abort Gap @ 3.8 T
60  dqm_tag_.push_back( "AagBunch0T" ); // statistic collection from First Collision After Abort Gap @ 0 T
61  dqm_tag_.push_back( "IsoMuon" ); // statistic collection from Isolated Muon @ 3.8 T
62  dqm_tag_.push_back( "IsoMuon0T" ); // statistic collection from Isolated Muon @ 0 T
63  dqm_tag_.push_back( "Harvest" ); // statistic collection: Harvest
64 
65 }
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > dqm_tag_
const TrackerGeometry * bareTkGeomPtr_

Member Function Documentation

void SiStripGainsPCLHarvester::algoComputeMPVandGain ( const MonitorElement Charge_Vs_Index)
private

Definition at line 146 of file SiStripGainsPCLHarvester.cc.

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

Referenced by dqmEndJob().

146  {
147 
148  unsigned int I=0;
149  TH1F* Proj = NULL;
150  double FitResults[6];
151  double MPVmean = 300;
152 
153  if ( Charge_Vs_Index==0 ) {
154  edm::LogError("SiStripGainsPCLHarvester") << "Harvesting: could not execute algoComputeMPVandGain method because "
155  << m_calibrationMode <<" statistics cannot be retrieved.\n"
156  << "Please check if input contains "
157  << m_calibrationMode <<" data." << std::endl;
158  return;
159  }
160 
161  TH2S *chvsidx = (Charge_Vs_Index)->getTH2S();
162 
163  printf("Progressing Bar :0%% 20%% 40%% 60%% 80%% 100%%\n");
164  printf("Fitting Charge Distribution :");
165  int TreeStep = APVsColl.size()/50;
166 
167  for(auto it = APVsColl.begin();it!=APVsColl.end();it++,I++){
168 
169  if(I%TreeStep==0){printf(".");fflush(stdout);}
170  std::shared_ptr<stAPVGain> APV = it->second;
171  if(APV->Bin<0) APV->Bin = chvsidx->GetXaxis()->FindBin(APV->Index);
172 
173  if(APV->isMasked){APV->Gain=APV->PreviousGain; MASKED++; continue;}
174 
175  Proj = (TH1F*)(chvsidx->ProjectionY("",chvsidx->GetXaxis()->FindBin(APV->Index),chvsidx->GetXaxis()->FindBin(APV->Index),"e"));
176  if(!Proj)continue;
177 
178  if(CalibrationLevel==0){
179  }else if(CalibrationLevel==1){
180  int SecondAPVId = APV->APVId;
181  if(SecondAPVId%2==0){ SecondAPVId = SecondAPVId+1; }else{ SecondAPVId = SecondAPVId-1; }
182  std::shared_ptr<stAPVGain> APV2 = APVsColl[(APV->DetId<<4) | SecondAPVId];
183  if(APV2->Bin<0) APV2->Bin = chvsidx->GetXaxis()->FindBin(APV2->Index);
184  TH1F* Proj2 = (TH1F*)(chvsidx->ProjectionY("",APV2->Bin,APV2->Bin,"e"));
185  if(Proj2){Proj->Add(Proj2,1);delete Proj2;}
186  }else if(CalibrationLevel==2){
187  for(unsigned int i=0;i<16;i++){ //loop up to 6APV for Strip and up to 16 for Pixels
188  auto tmpit = APVsColl.find((APV->DetId<<4) | i);
189  if(tmpit==APVsColl.end())continue;
190  std::shared_ptr<stAPVGain> APV2 = tmpit->second;
191  if(APV2->DetId != APV->DetId || APV2->APVId == APV->APVId)continue;
192  if(APV2->Bin<0) APV2->Bin = chvsidx->GetXaxis()->FindBin(APV2->Index);
193  TH1F* Proj2 = (TH1F*)(chvsidx->ProjectionY("",APV2->Bin,APV2->Bin,"e"));
194  if(Proj2){Proj->Add(Proj2,1);delete Proj2;}
195  }
196  } else {
197  CalibrationLevel = 0;
198  printf("Unknown Calibration Level, will assume %i\n",CalibrationLevel);
199  }
200 
201  getPeakOfLandau(Proj,FitResults);
202  APV->FitMPV = FitResults[0];
203  APV->FitMPVErr = FitResults[1];
204  APV->FitWidth = FitResults[2];
205  APV->FitWidthErr = FitResults[3];
206  APV->FitChi2 = FitResults[4];
207  APV->FitNorm = FitResults[5];
208  APV->NEntries = Proj->GetEntries();
209 
210  if(IsGoodLandauFit(FitResults)){
211  APV->Gain = APV->FitMPV / MPVmean;
212  if(APV->SubDet>2)GOOD++;
213  }else{
214  APV->Gain = APV->PreviousGain;
215  if(APV->SubDet>2)BAD++;
216  }
217  if(APV->Gain<=0) APV->Gain = 1;
218 
219  delete Proj;
220  }printf("\n");
221 }
#define NULL
Definition: scimark2.h:8
void getPeakOfLandau(TH1 *InputHisto, double *FitResults, double LowRange=50, double HighRange=5400)
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 
)
virtual

Reimplemented from DQMEDHarvester.

Definition at line 70 of file SiStripGainsPCLHarvester.cc.

References a, sistrip::APV, APVsCollOrdered, checkBookAPVColls(), cmsRelvalreport::exit, edm::EventSetup::get(), SiStripGain::getApvGain(), SiStripGain::getNumberOfTags(), SiStripGain::getRange(), SiStripQuality::IsApvBad(), edm::ESHandleBase::isValid(), PixelSubdetector::PixelBarrel, and PixelSubdetector::PixelEndcap.

71 {
72  using namespace edm;
73 
74  this->checkBookAPVColls(iSetup); // check whether APV colls are booked and do so if not yet done
75 
76  edm::ESHandle<SiStripGain> gainHandle;
77  iSetup.get<SiStripGainRcd>().get(gainHandle);
78  if(!gainHandle.isValid()){edm::LogError("SiStripGainPCLHarvester")<< "gainHandle is not valid\n"; exit(0);}
79 
80  edm::ESHandle<SiStripQuality> SiStripQuality_;
81  iSetup.get<SiStripQualityRcd>().get(SiStripQuality_);
82 
83  for(unsigned int a=0;a<APVsCollOrdered.size();a++){
84 
85  std::shared_ptr<stAPVGain> APV = APVsCollOrdered[a];
86 
87  if(APV->SubDet==PixelSubdetector::PixelBarrel || APV->SubDet==PixelSubdetector::PixelEndcap) continue;
88 
89  APV->isMasked = SiStripQuality_->IsApvBad(APV->DetId,APV->APVId);
90 
91  if(gainHandle->getNumberOfTags()!=2){edm::LogError("SiStripGainPCLHarvester")<< "NUMBER OF GAIN TAG IS EXPECTED TO BE 2\n";fflush(stdout);exit(0);};
92  float newPreviousGain = gainHandle->getApvGain(APV->APVId,gainHandle->getRange(APV->DetId, 1),1);
93  if(APV->PreviousGain!=1 and newPreviousGain!=APV->PreviousGain)edm::LogWarning("SiStripGainPCLHarvester")<< "WARNING: ParticleGain in the global tag changed\n";
94  APV->PreviousGain = newPreviousGain;
95 
96  float newPreviousGainTick = gainHandle->getApvGain(APV->APVId,gainHandle->getRange(APV->DetId, 0),0);
97  if(APV->PreviousGainTick!=1 and newPreviousGainTick!=APV->PreviousGainTick){
98  edm::LogWarning("SiStripGainPCLHarvester")<< "WARNING: TickMarkGain in the global tag changed\n"<< std::endl
99  <<" APV->SubDet: "<< APV->SubDet << " APV->APVId:" << APV->APVId << std::endl
100  <<" APV->PreviousGainTick: "<<APV->PreviousGainTick<<" newPreviousGainTick: "<<newPreviousGainTick<<std::endl;
101  }
102  APV->PreviousGainTick = newPreviousGainTick;
103  }
104 }
bool IsApvBad(const uint32_t &detid, const short &apvNb) const
size_t getNumberOfTags() const
Definition: SiStripGain.h:87
static float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range)
Definition: SiStripGain.h:69
virtual void checkBookAPVColls(const edm::EventSetup &setup)
std::vector< std::shared_ptr< stAPVGain > > APVsCollOrdered
HLT enums.
double a
Definition: hdecay.h:121
bool isValid() const
Definition: ESHandle.h:47
const SiStripApvGain::Range getRange(uint32_t detID) const
Definition: SiStripGain.h:66
void SiStripGainsPCLHarvester::checkBookAPVColls ( const edm::EventSetup setup)
privatevirtual

Definition at line 264 of file SiStripGainsPCLHarvester.cc.

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

Referenced by beginRun().

264  {
265 
266  es.get<TrackerDigiGeometryRecord>().get( tkGeom_ );
267  const TrackerGeometry *newBareTkGeomPtr = &(*tkGeom_);
268  if (newBareTkGeomPtr == bareTkGeomPtr_) return; // already filled APVColls, nothing changed
269 
270  if (!bareTkGeomPtr_) { // pointer not yet set: called the first time => fill the APVColls
271  auto const & Det = newBareTkGeomPtr->dets();
272 
273  unsigned int Index=0;
274 
275  for(unsigned int i=0;i<Det.size();i++){
276 
277  DetId Detid = Det[i]->geographicalId();
278  int SubDet = Detid.subdetId();
279 
280  if( SubDet == StripSubdetector::TIB || SubDet == StripSubdetector::TID ||
281  SubDet == StripSubdetector::TOB || SubDet == StripSubdetector::TEC ){
282 
283  auto DetUnit = dynamic_cast<const StripGeomDetUnit*> (Det[i]);
284  if(!DetUnit)continue;
285 
286  const StripTopology& Topo = DetUnit->specificTopology();
287  unsigned int NAPV = Topo.nstrips()/128;
288 
289  for(unsigned int j=0;j<NAPV;j++){
290  auto APV = std::make_shared<stAPVGain>();
291  APV->Index = Index;
292  APV->Bin = -1;
293  APV->DetId = Detid.rawId();
294  APV->APVId = j;
295  APV->SubDet = SubDet;
296  APV->FitMPV = -1;
297  APV->FitMPVErr = -1;
298  APV->FitWidth = -1;
299  APV->FitWidthErr = -1;
300  APV->FitChi2 = -1;
301  APV->FitNorm = -1;
302  APV->Gain = -1;
303  APV->PreviousGain = 1;
304  APV->PreviousGainTick = 1;
305  APV->x = DetUnit->position().basicVector().x();
306  APV->y = DetUnit->position().basicVector().y();
307  APV->z = DetUnit->position().basicVector().z();
308  APV->Eta = DetUnit->position().basicVector().eta();
309  APV->Phi = DetUnit->position().basicVector().phi();
310  APV->R = DetUnit->position().basicVector().transverse();
311  APV->Thickness = DetUnit->surface().bounds().thickness();
312  APV->NEntries = 0;
313  APV->isMasked = false;
314 
315  APVsCollOrdered.push_back(APV);
316  APVsColl[(APV->DetId<<4) | APV->APVId] = APV;
317  Index++;
318  NStripAPVs++;
319  } // loop on APVs
320  } // if is Strips
321  } // loop on dets
322 
323  for(unsigned int i=0;i<Det.size();i++){ //Make two loop such that the Pixel information is added at the end --> make transition simpler
324  DetId Detid = Det[i]->geographicalId();
325  int SubDet = Detid.subdetId();
327  auto DetUnit = dynamic_cast<const PixelGeomDetUnit*> (Det[i]);
328  if(!DetUnit) continue;
329 
330  const PixelTopology& Topo = DetUnit->specificTopology();
331  unsigned int NROCRow = Topo.nrows()/(80.);
332  unsigned int NROCCol = Topo.ncolumns()/(52.);
333 
334  for(unsigned int j=0;j<NROCRow;j++){
335  for(unsigned int i=0;i<NROCCol;i++){
336  auto APV = std::make_shared<stAPVGain>();
337  APV->Index = Index;
338  APV->Bin = -1;
339  APV->DetId = Detid.rawId();
340  APV->APVId = (j<<3 | i);
341  APV->SubDet = SubDet;
342  APV->FitMPV = -1;
343  APV->FitMPVErr = -1;
344  APV->FitWidth = -1;
345  APV->FitWidthErr = -1;
346  APV->FitChi2 = -1;
347  APV->Gain = -1;
348  APV->PreviousGain = 1;
349  APV->PreviousGainTick = 1;
350  APV->x = DetUnit->position().basicVector().x();
351  APV->y = DetUnit->position().basicVector().y();
352  APV->z = DetUnit->position().basicVector().z();
353  APV->Eta = DetUnit->position().basicVector().eta();
354  APV->Phi = DetUnit->position().basicVector().phi();
355  APV->R = DetUnit->position().basicVector().transverse();
356  APV->Thickness = DetUnit->surface().bounds().thickness();
357  APV->isMasked = false; //SiPixelQuality_->IsModuleBad(Detid.rawId());
358  APV->NEntries = 0;
359 
360  APVsCollOrdered.push_back(APV);
361  APVsColl[(APV->DetId<<4) | APV->APVId] = APV;
362  Index++;
363  NPixelDets++;
364 
365  } // loop on ROC cols
366  } // loop on ROC rows
367  } // if Pixel
368  } // loop on Dets
369  } //if (!bareTkGeomPtr_) ...
370  bareTkGeomPtr_ = newBareTkGeomPtr;
371 }
virtual int nrows() const =0
edm::ESHandle< TrackerGeometry > tkGeom_
const DetContainer & dets() const
Returm a vector of all GeomDet (including all GeomDetUnits)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
virtual int nstrips() const =0
const TrackerGeometry * bareTkGeomPtr_
std::vector< std::shared_ptr< stAPVGain > > APVsCollOrdered
virtual int ncolumns() const =0
std::unordered_map< unsigned int, std::shared_ptr< stAPVGain > > APVsColl
void SiStripGainsPCLHarvester::dqmEndJob ( DQMStore::IBooker ibooker_,
DQMStore::IGetter igetter_ 
)
privatevirtual

Implements DQMEDHarvester.

Definition at line 107 of file SiStripGainsPCLHarvester.cc.

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

107  {
108 
109  edm::LogInfo("SiStripGainsPCLHarvester") << "Starting harvesting statistics" << std::endl;
110 
111  std::string DQM_dir = m_DQMdir;
112 
113  std::string stag = *(std::find(dqm_tag_.begin(), dqm_tag_.end(),m_calibrationMode));
114  if(stag.size()!=0 && stag[0]!='_') 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.c_str());
119 
120  if (Charge_Vs_Index==0) {
121  edm::LogError("SiStripGainsPCLHarvester") << "Harvesting: could not retrieve " << cvi.c_str()
122  << ", statistics will not be summed!" << std::endl;
123  } else {
124  edm::LogInfo("SiStripGainsPCLHarvester") << "Harvesting "
125  << (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->writeOne(theAPVGains.get(), 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 }
std::unique_ptr< SiStripApvGain > getNewObject(const MonitorElement *Charge_Vs_Index)
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
std::vector< std::string > dqm_tag_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
void algoComputeMPVandGain(const MonitorElement *Charge_Vs_Index)
bool isAvailable() const
Definition: Service.h:46
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
void SiStripGainsPCLHarvester::endRun ( edm::Run const &  run,
edm::EventSetup const &  isetup 
)
virtual

Reimplemented from DQMEDHarvester.

Definition at line 460 of file SiStripGainsPCLHarvester.cc.

460  {
461 }
void SiStripGainsPCLHarvester::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 451 of file SiStripGainsPCLHarvester.cc.

References edm::ConfigurationDescriptions::addDefault(), and edm::ParameterSetDescription::setUnknown().

451  {
452 
454  desc.setUnknown();
455  descriptions.addDefault(desc);
456 
457 }
void addDefault(ParameterSetDescription const &psetDescription)
std::unique_ptr< SiStripApvGain > SiStripGainsPCLHarvester::getNewObject ( const MonitorElement Charge_Vs_Index)
private

Definition at line 406 of file SiStripGainsPCLHarvester.cc.

References a, sistrip::APV, APVsCollOrdered, doStoreOnDB, LogDebug, NULL, MuonAssociatorByHits_cfi::obj, and produceTagFilter().

Referenced by dqmEndJob().

407 {
408  std::unique_ptr<SiStripApvGain> obj = std::unique_ptr<SiStripApvGain>(new SiStripApvGain());
409 
410  if(!produceTagFilter(Charge_Vs_Index)){
411  edm::LogWarning("SiStripGainsPCLHarvester")<< "getNewObject -> will not produce a paylaod because produceTagFilter returned false " << std::endl;
412  return obj;
413  } else {
414  doStoreOnDB=true;
415  }
416 
417  std::vector<float> theSiStripVector;
418  unsigned int PreviousDetId = 0;
419  for(unsigned int a=0;a<APVsCollOrdered.size();a++){
420  std::shared_ptr<stAPVGain> APV = APVsCollOrdered[a];
421  if(APV==NULL){ printf("Bug\n"); continue; }
422  if(APV->SubDet<=2)continue;
423  if(APV->DetId != PreviousDetId){
424  if(!theSiStripVector.empty()){
425  SiStripApvGain::Range range(theSiStripVector.begin(),theSiStripVector.end());
426  if ( !obj->put(PreviousDetId,range) ) printf("Bug to put detId = %i\n",PreviousDetId);
427  }
428  theSiStripVector.clear();
429  PreviousDetId = APV->DetId;
430  }
431  theSiStripVector.push_back(APV->Gain);
432 
433  LogDebug("SiStripGainsPCLHarvester")<<" DetId: "<<APV->DetId
434  <<" APV: "<<APV->APVId
435  <<" Gain: "<<APV->Gain
436  <<std::endl;
437 
438  }
439  if(!theSiStripVector.empty()){
440  SiStripApvGain::Range range(theSiStripVector.begin(),theSiStripVector.end());
441  if ( !obj->put(PreviousDetId,range) ) printf("Bug to put detId = %i\n",PreviousDetId);
442  }
443 
444  return obj;
445 }
#define LogDebug(id)
#define NULL
Definition: scimark2.h:8
bool produceTagFilter(const MonitorElement *Charge_Vs_Index)
std::pair< ContainerIterator, ContainerIterator > Range
std::vector< std::shared_ptr< stAPVGain > > APVsCollOrdered
double a
Definition: hdecay.h:121
void SiStripGainsPCLHarvester::getPeakOfLandau ( TH1 *  InputHisto,
double *  FitResults,
double  LowRange = 50,
double  HighRange = 5400 
)
private

Definition at line 225 of file SiStripGainsPCLHarvester.cc.

References MinNrEntries.

Referenced by algoComputeMPVandGain().

226 {
227  FitResults[0] = -0.5; //MPV
228  FitResults[1] = 0; //MPV error
229  FitResults[2] = -0.5; //Width
230  FitResults[3] = 0; //Width error
231  FitResults[4] = -0.5; //Fit Chi2/NDF
232  FitResults[5] = 0; //Normalization
233 
234  if( InputHisto->GetEntries() < MinNrEntries)return;
235 
236  // perform fit with standard landau
237  TF1 MyLandau("MyLandau","landau",LowRange, HighRange);
238  MyLandau.SetParameter(1,300);
239  InputHisto->Fit(&MyLandau,"0QR WW");
240 
241  // MPV is parameter 1 (0=constant, 1=MPV, 2=Sigma)
242  FitResults[0] = MyLandau.GetParameter(1); //MPV
243  FitResults[1] = MyLandau.GetParError(1); //MPV error
244  FitResults[2] = MyLandau.GetParameter(2); //Width
245  FitResults[3] = MyLandau.GetParError(2); //Width error
246  FitResults[4] = MyLandau.GetChisquare() / MyLandau.GetNDF(); //Fit Chi2/NDF
247  FitResults[5] = MyLandau.GetParameter(0);
248 
249 }
bool SiStripGainsPCLHarvester::IsGoodLandauFit ( double *  FitResults)
private

Definition at line 253 of file SiStripGainsPCLHarvester.cc.

Referenced by algoComputeMPVandGain().

253  {
254  if(FitResults[0] <= 0 )return false;
255  // if(FitResults[1] > MaxMPVError )return false;
256  // if(FitResults[4] > MaxChi2OverNDF)return false;
257  return true;
258 }
bool SiStripGainsPCLHarvester::produceTagFilter ( const MonitorElement Charge_Vs_Index)
private

Definition at line 374 of file SiStripGainsPCLHarvester.cc.

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

Referenced by getNewObject().

374  {
375 
376  // The goal of this function is to check wether or not there is enough statistics
377  // to produce a meaningful tag for the DB
378 
379  if( Charge_Vs_Index==0 ) {
380  edm::LogError("SiStripGainsPCLHarvester") << "produceTagFilter -> Return false: could not retrieve the "
381  << m_calibrationMode <<" statistics.\n"
382  << "Please check if input contains "
383  << m_calibrationMode << " data." << std::endl;
384  return false;
385  }
386 
387 
388  float integral = (Charge_Vs_Index)->getTH2S()->Integral();
389  if( (Charge_Vs_Index)->getTH2S()->Integral(0,NStripAPVs+1, 0, 99999 ) < tagCondition_NClusters) {
390  edm::LogWarning("SiStripGainsPCLHarvester")
391  << "calibrationMode -> " << m_calibrationMode << "\n"
392  << "produceTagFilter -> Return false: Statistics is too low : " << integral << std::endl;
393  return false;
394  }
395  if((1.0 * GOOD) / (GOOD+BAD) < tagCondition_GoodFrac) {
396  edm::LogWarning("SiStripGainsPCLHarvester")
397  << "calibrationMode -> " << m_calibrationMode << "\n"
398  << "produceTagFilter -> Return false: ratio of GOOD/TOTAL is too low: " << (1.0 * GOOD) / (GOOD+BAD) << std::endl;
399  return false;
400  }
401  return true;
402 }
Integral< F, X >::type integral(const F &f)
Definition: Integral.h:69
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 88 of file SiStripGainsPCLHarvester.h.

Referenced by algoComputeMPVandGain(), and checkBookAPVColls().

std::vector<std::shared_ptr<stAPVGain> > SiStripGainsPCLHarvester::APVsCollOrdered
private

Definition at line 87 of file SiStripGainsPCLHarvester.h.

Referenced by beginRun(), checkBookAPVColls(), and getNewObject().

unsigned int SiStripGainsPCLHarvester::BAD
private

Definition at line 67 of file SiStripGainsPCLHarvester.h.

Referenced by algoComputeMPVandGain(), and produceTagFilter().

const TrackerGeometry* SiStripGainsPCLHarvester::bareTkGeomPtr_
private

Definition at line 85 of file SiStripGainsPCLHarvester.h.

Referenced by checkBookAPVColls().

int SiStripGainsPCLHarvester::CalibrationLevel
private

Definition at line 82 of file SiStripGainsPCLHarvester.h.

Referenced by algoComputeMPVandGain(), and SiStripGainsPCLHarvester().

bool SiStripGainsPCLHarvester::doStoreOnDB
private

Definition at line 65 of file SiStripGainsPCLHarvester.h.

Referenced by dqmEndJob(), and getNewObject().

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

Definition at line 80 of file SiStripGainsPCLHarvester.h.

Referenced by dqmEndJob(), and SiStripGainsPCLHarvester().

unsigned int SiStripGainsPCLHarvester::GOOD
private

Definition at line 66 of file SiStripGainsPCLHarvester.h.

Referenced by algoComputeMPVandGain(), and produceTagFilter().

std::string SiStripGainsPCLHarvester::m_calibrationMode
private
std::string SiStripGainsPCLHarvester::m_DQMdir
private

Definition at line 78 of file SiStripGainsPCLHarvester.h.

Referenced by dqmEndJob(), and SiStripGainsPCLHarvester().

std::string SiStripGainsPCLHarvester::m_Record
private

Definition at line 77 of file SiStripGainsPCLHarvester.h.

Referenced by dqmEndJob(), and SiStripGainsPCLHarvester().

unsigned int SiStripGainsPCLHarvester::MASKED
private

Definition at line 68 of file SiStripGainsPCLHarvester.h.

Referenced by algoComputeMPVandGain().

double SiStripGainsPCLHarvester::MinNrEntries
private

Definition at line 75 of file SiStripGainsPCLHarvester.h.

Referenced by getPeakOfLandau(), and SiStripGainsPCLHarvester().

int SiStripGainsPCLHarvester::NPixelDets
private

Definition at line 74 of file SiStripGainsPCLHarvester.h.

Referenced by checkBookAPVColls().

int SiStripGainsPCLHarvester::NStripAPVs
private

Definition at line 73 of file SiStripGainsPCLHarvester.h.

Referenced by checkBookAPVColls(), and produceTagFilter().

double SiStripGainsPCLHarvester::tagCondition_GoodFrac
private

Definition at line 71 of file SiStripGainsPCLHarvester.h.

Referenced by produceTagFilter(), and SiStripGainsPCLHarvester().

double SiStripGainsPCLHarvester::tagCondition_NClusters
private

Definition at line 70 of file SiStripGainsPCLHarvester.h.

Referenced by produceTagFilter(), and SiStripGainsPCLHarvester().

edm::ESHandle<TrackerGeometry> SiStripGainsPCLHarvester::tkGeom_
private

Definition at line 84 of file SiStripGainsPCLHarvester.h.

Referenced by checkBookAPVColls().