CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Types | Private Attributes
AlcaBeamMonitor Class Reference

#include <AlcaBeamMonitor.h>

Inheritance diagram for AlcaBeamMonitor:
DQMEDAnalyzer edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > > edm::stream::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 AlcaBeamMonitor (const edm::ParameterSet &)
 
 ~AlcaBeamMonitor () override
 
- Public Member Functions inherited from DQMEDAnalyzer
void beginRun (edm::Run const &, edm::EventSetup const &) final
 
void beginStream (edm::StreamID id) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer ()
 
void endLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
void endRunSummary (edm::Run const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
uint32_t streamId () const
 
- Public Member Functions inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDAnalyzerBase () 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
 
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::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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Member Functions

void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
void beginLuminosityBlock (const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) override
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 
void endLuminosityBlock (const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) override
 
- 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)
 

Private Types

typedef std::map< std::string, reco::BeamSpotBeamSpotContainer
 
typedef std::map< std::string, std::map< std::string, std::map< std::string, MonitorElement * > > > HistosContainer
 
typedef std::map< std::string, std::map< std::string, std::map< std::string, int > > > PositionContainer
 

Private Attributes

edm::InputTag beamSpotLabel_
 
BeamSpotContainer beamSpotsMap_
 
MonitorElementhD0Phi0_
 
MonitorElementhDxyBS_
 
std::multimap< std::string, std::string > histoByCategoryNames_
 
HistosContainer histosMap_
 
std::string monitorName_
 
int numberOfValuesToSave_
 
edm::ParameterSet parameters_
 
PositionContainer positionsMap_
 
edm::EDGetTokenT< reco::VertexCollectionprimaryVertexLabel_
 
edm::EDGetTokenT< reco::BeamSpotscalerLabel_
 
BeamFittertheBeamFitter_
 
PVFitterthePVFitter_
 
MonitorElementtheValuesContainer_
 
edm::EDGetTokenT< reco::TrackCollectiontrackLabel_
 
std::vector< std::string > varNamesV_
 
std::vector< reco::VertexCollectionvertices_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDAnalyzerBase
typedef EDAnalyzerAdaptorBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static std::shared_ptr< dqmDetails::NoCacheglobalBeginLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
 
static std::shared_ptr< dqmDetails::NoCacheglobalBeginRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *)
 
static void globalEndLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, dqmDetails::NoCache *)
 
static void globalEndRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *, dqmDetails::NoCache *)
 
- Static Public Member Functions inherited from edm::stream::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Detailed Description

Definition at line 28 of file AlcaBeamMonitor.h.

Member Typedef Documentation

typedef std::map<std::string,reco::BeamSpot> AlcaBeamMonitor::BeamSpotContainer
private

Definition at line 43 of file AlcaBeamMonitor.h.

typedef std::map<std::string,std::map<std::string,std::map<std::string,MonitorElement*> > > AlcaBeamMonitor::HistosContainer
private

Definition at line 45 of file AlcaBeamMonitor.h.

typedef std::map<std::string,std::map<std::string,std::map<std::string,int> > > AlcaBeamMonitor::PositionContainer
private

Definition at line 47 of file AlcaBeamMonitor.h.

Constructor & Destructor Documentation

AlcaBeamMonitor::AlcaBeamMonitor ( const edm::ParameterSet ps)

Definition at line 32 of file AlcaBeamMonitor.cc.

References d0_phi_analyzer_cff::BeamFitter, edm::EDConsumerBase::consumesCollector(), histoByCategoryNames_, histosMap_, monitorName_, numberOfValuesToSave_, parameters_, positionsMap_, d0_phi_analyzer_cff::PVFitter, BeamFitter::resetLSRange(), BeamFitter::resetPVFitter(), BeamFitter::resetRefTime(), BeamFitter::resetTrkVector(), theBeamFitter_, thePVFitter_, and varNamesV_.

32  :
33  parameters_ (ps),
34  monitorName_ (parameters_.getUntrackedParameter<string>("MonitorName","YourSubsystemName")),
35  primaryVertexLabel_ (consumes<VertexCollection>(
36  parameters_.getUntrackedParameter<InputTag>("PrimaryVertexLabel"))),
37  trackLabel_ (consumes<reco::TrackCollection>(
39  scalerLabel_ (consumes<BeamSpot>(
40  parameters_.getUntrackedParameter<InputTag>("ScalerLabel"))),
43 {
44 
45  if (monitorName_ != "" ) monitorName_ = monitorName_+"/" ;
46 
52 
54 
55 
56  varNamesV_.push_back("x");
57  varNamesV_.push_back("y");
58  varNamesV_.push_back("z");
59  varNamesV_.push_back("sigmaX");
60  varNamesV_.push_back("sigmaY");
61  varNamesV_.push_back("sigmaZ");
62 
63  histoByCategoryNames_.insert( pair<string,string>("run", "Coordinate"));
64  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex fit-DataBase"));
65  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex fit-BeamFit"));
66  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex fit-Scalers"));
67  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex-DataBase"));
68  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex-BeamFit"));
69  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex-Scalers"));
70 
71  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased BeamSpotFit"));
72  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased PrimaryVertex"));
73  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased DataBase"));
74  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased Scalers"));
75  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased PrimaryVertex-DataBase fit"));
76  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased PrimaryVertex-Scalers fit"));
77  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased Scalers-DataBase fit"));
78  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased PrimaryVertex-DataBase"));
79  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased PrimaryVertex-Scalers"));
80 
81 
82  for(vector<string>::iterator itV=varNamesV_.begin(); itV!=varNamesV_.end(); itV++){
83  for(multimap<string,string>::iterator itM=histoByCategoryNames_.begin(); itM!=histoByCategoryNames_.end(); itM++){
84  if(itM->first=="run"){
85  histosMap_[*itV][itM->first][itM->second] = nullptr;
86  }
87  else{
88  positionsMap_[*itV][itM->first][itM->second] = 3*numberOfValuesToSave_;//value, error, ok
90  }
91  }
92  }
93 
94 // beamSpotsMap_["BF"] = map<LuminosityBlockNumber_t,BeamSpot>();//For each lumi the beamfitter will have a result
95 // beamSpotsMap_["PV"] = map<LuminosityBlockNumber_t,BeamSpot>();//For each lumi the PVfitter will have a result
96 // beamSpotsMap_["DB"] = map<LuminosityBlockNumber_t,BeamSpot>();//For each lumi we take the values that are stored in the database, already collapsed then
97 // beamSpotsMap_["SC"] = map<LuminosityBlockNumber_t,BeamSpot>();//For each lumi we take the beamspot value in the file that is the same as the scaler for the alca reco stream
98 // beamSpotsMap_["BF"] = 0;//For each lumi the beamfitter will have a result
99 // beamSpotsMap_["PV"] = 0;//For each lumi the PVfitter will have a result
100 // beamSpotsMap_["DB"] = 0;//For each lumi we take the values that are stored in the database, already collapsed then
101 // beamSpotsMap_["SC"] = 0;//For each lumi we take the beamspot value in the file that is the same as the scaler for the alca reco stream
102 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::TrackCollection > trackLabel_
edm::EDGetTokenT< reco::VertexCollection > primaryVertexLabel_
void resetTrkVector()
Definition: BeamFitter.h:53
PositionContainer positionsMap_
edm::InputTag beamSpotLabel_
std::vector< std::string > varNamesV_
edm::EDGetTokenT< reco::BeamSpot > scalerLabel_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
BeamFitter * theBeamFitter_
void resetLSRange()
Definition: BeamFitter.h:55
PVFitter * thePVFitter_
std::multimap< std::string, std::string > histoByCategoryNames_
HistosContainer histosMap_
std::string monitorName_
void resetPVFitter()
Definition: BeamFitter.h:69
edm::ParameterSet parameters_
void resetRefTime()
Definition: BeamFitter.h:56
AlcaBeamMonitor::~AlcaBeamMonitor ( )
override

Definition at line 105 of file AlcaBeamMonitor.cc.

References theBeamFitter_, and thePVFitter_.

105  {
106  if(theBeamFitter_ != nullptr){
107  delete theBeamFitter_;
108  }
109 
110  if(thePVFitter_ != nullptr){
111  delete thePVFitter_;
112  }
113 }
BeamFitter * theBeamFitter_
PVFitter * thePVFitter_

Member Function Documentation

void AlcaBeamMonitor::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprotected

Definition at line 266 of file AlcaBeamMonitor.cc.

References beamSpotsMap_, cppFunctionSkipper::exception, reco::BeamSpot::Fake, MonitorElement::Fill(), edm::Event::getByToken(), hD0Phi0_, hDxyBS_, primaryVertexLabel_, edm::Handle< T >::product(), BeamFitter::readEvent(), PVFitter::readEvent(), scalerLabel_, theBeamFitter_, thePVFitter_, HiIsolationCommonParameters_cff::track, reco::BeamSpot::Tracker, trackLabel_, l1t::tracks, vertices_, and cms::Exception::what().

266  {
267 
268  //------ BeamFitter
269  theBeamFitter_->readEvent(iEvent);
270  //------ PVFitter
271  thePVFitter_->readEvent(iEvent);
272 
273  if(beamSpotsMap_.find("DB") != beamSpotsMap_.end()){
274  //------ Tracks
276  iEvent.getByToken(trackLabel_, TrackCollection);
277  const reco::TrackCollection *tracks = TrackCollection.product();
278  for ( reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track ) {
279  hD0Phi0_->Fill(track->phi(), -1*track->dxy());
280  hDxyBS_->Fill(-1*track->dxy(beamSpotsMap_["DB"].position()));
281  }
282  }
283 
284  //------ Primary Vertices
285  Handle<VertexCollection > PVCollection;
286  if (iEvent.getByToken(primaryVertexLabel_, PVCollection )) {
287  vertices_.push_back(*PVCollection.product());
288  }
289 
290  if(beamSpotsMap_.find("SC") == beamSpotsMap_.end()){
291  //BeamSpot from file for this stream is = to the scalar BeamSpot
292  Handle<BeamSpot> recoBeamSpotHandle;
293  try{
294  iEvent.getByToken(scalerLabel_,recoBeamSpotHandle);
295  }
296  catch( cms::Exception& exception ){
297  LogInfo("AlcaBeamMonitor")
298  << exception.what();
299  return;
300  }
301  beamSpotsMap_["SC"] = *recoBeamSpotHandle;
302  if ( beamSpotsMap_["SC"].BeamWidthX() != 0 ) {
303  beamSpotsMap_["SC"].setType( reco::BeamSpot::Tracker );
304  } else{
305  beamSpotsMap_["SC"].setType( reco::BeamSpot::Fake );
306  }
307  }
308 }
MonitorElement * hD0Phi0_
edm::EDGetTokenT< reco::TrackCollection > trackLabel_
MonitorElement * hDxyBS_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::EDGetTokenT< reco::VertexCollection > primaryVertexLabel_
char const * what() const override
Definition: Exception.cc:141
void readEvent(const edm::Event &iEvent)
Definition: BeamFitter.cc:216
void Fill(long long x)
void readEvent(const edm::Event &iEvent)
Definition: PVFitter.cc:99
edm::EDGetTokenT< reco::BeamSpot > scalerLabel_
BeamSpotContainer beamSpotsMap_
BeamFitter * theBeamFitter_
PVFitter * thePVFitter_
T const * product() const
Definition: Handle.h:81
std::vector< reco::VertexCollection > vertices_
void AlcaBeamMonitor::beginLuminosityBlock ( const edm::LuminosityBlock iLumi,
const edm::EventSetup iSetup 
)
overrideprotected

Definition at line 207 of file AlcaBeamMonitor.cc.

References align::BeamSpot, beamSpotsMap_, cppFunctionSkipper::exception, reco::BeamSpot::Fake, edm::EventSetup::get(), BeamSpotObjects::GetBeamType(), BeamSpotObjects::GetBeamWidthX(), BeamSpotObjects::GetBeamWidthY(), BeamSpotObjects::GetBetaStar(), BeamSpotObjects::GetCovariance(), BeamSpotObjects::Getdxdz(), BeamSpotObjects::Getdydz(), BeamSpotObjects::GetEmittanceX(), BeamSpotObjects::GetEmittanceY(), BeamSpotObjects::GetSigmaZ(), BeamSpotObjects::GetX(), BeamSpotObjects::GetY(), BeamSpotObjects::GetZ(), mps_fire::i, edm::LuminosityBlockBase::id(), edm::ESHandleBase::isValid(), edm::LuminosityBlockID::luminosityBlock(), makeMuonMisalignmentScenario::matrix, edm::ESHandle< T >::product(), MonitorElement::Reset(), reco::BeamSpot::setBeamWidthY(), theValuesContainer_, reco::BeamSpot::Tracker, vertices_, and cms::Exception::what().

207  {
208  // Always create a beamspot group for each lumi weather we have results or not! Each Beamspot will be of unknown type!
209 
210  vertices_.clear();
212  beamSpotsMap_.clear();
213 
214  //Read BeamSpot from DB
215  ESHandle<BeamSpotObjects> bsDBHandle;
216  try{
217  iSetup.get<BeamSpotObjectsRcd>().get(bsDBHandle);
218  }
219  catch( cms::Exception& exception ){
220  LogInfo("AlcaBeamMonitor")
221  << exception.what();
222  return;
223  }
224  if(bsDBHandle.isValid()) { // check the product
225  const BeamSpotObjects *spotDB = bsDBHandle.product();
226 
227  // translate from BeamSpotObjects to reco::BeamSpot
228  BeamSpot::Point apoint( spotDB->GetX(), spotDB->GetY(), spotDB->GetZ() );
229 
231  for ( int i=0; i<7; ++i ) {
232  for ( int j=0; j<7; ++j ) {
233  matrix(i,j) = spotDB->GetCovariance(i,j);
234  }
235  }
236 
237  beamSpotsMap_["DB"] = BeamSpot( apoint,
238  spotDB->GetSigmaZ(),
239  spotDB->Getdxdz(),
240  spotDB->Getdydz(),
241  spotDB->GetBeamWidthX(),
242  matrix );
243 
244  BeamSpot* aSpot = &(beamSpotsMap_["DB"]);
245 
246  aSpot->setBeamWidthY( spotDB->GetBeamWidthY() );
247  aSpot->setEmittanceX( spotDB->GetEmittanceX() );
248  aSpot->setEmittanceY( spotDB->GetEmittanceY() );
249  aSpot->setbetaStar( spotDB->GetBetaStar() );
250 
251  if ( spotDB->GetBeamType() == 2 ) {
252  aSpot->setType( reco::BeamSpot::Tracker );
253  } else{
254  aSpot->setType( reco::BeamSpot::Fake );
255  }
256  //LogInfo("AlcaBeamMonitor")
257  // << *aSpot << std::endl;
258  }
259  else {
260  LogInfo("AlcaBeamMonitor")
261  << "Database BeamSpot is not valid at lumi: " << iLumi.id().luminosityBlock();
262  }
263 }
double Getdydz() const
get dydz slope, crossing angle in YZ
LuminosityBlockID id() const
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:31
double GetY() const
get Y beam position
double GetSigmaZ() const
get sigma Z, RMS bunch length
double GetBeamWidthX() const
get average transverse beam width
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:29
char const * what() const override
Definition: Exception.cc:141
double GetBeamWidthY() const
get average transverse beam width
double GetEmittanceX() const
get emittance
void setBeamWidthY(double v)
Definition: BeamSpot.h:109
int GetBeamType() const
get beam type
BeamSpotContainer beamSpotsMap_
double GetZ() const
get Z beam position
void Reset()
reset ME (ie. contents, errors, etc)
double Getdxdz() const
get dxdz slope, crossing angle in XZ
double GetX() const
get X beam position
const T & get() const
Definition: EventSetup.h:58
LuminosityBlockNumber_t luminosityBlock() const
double GetBetaStar() const
get beta star
double GetCovariance(int i, int j) const
get i,j element of the full covariance matrix 7x7
double GetEmittanceY() const
get emittance
bool isValid() const
Definition: ESHandle.h:47
T const * product() const
Definition: ESHandle.h:86
MonitorElement * theValuesContainer_
std::vector< reco::VertexCollection > vertices_
void AlcaBeamMonitor::bookHistograms ( DQMStore::IBooker ibooker,
edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
overrideprotectedvirtual

Implements DQMEDAnalyzer.

Definition at line 117 of file AlcaBeamMonitor.cc.

References DQMStore::IBooker::book1D(), DQMStore::IBooker::bookProfile(), hD0Phi0_, hDxyBS_, histosMap_, monitorName_, dataset::name, numberOfValuesToSave_, MonitorElement::setAxisTitle(), DQMStore::IBooker::setCurrentFolder(), MonitorElement::setLumiFlag(), AlCaHLTBitMon_QueryRunRegistry::string, theValuesContainer_, and fftjetcommon_cfi::title.

117  {
118  string name;
119  string title;
120  ibooker.setCurrentFolder(monitorName_+"Debug");
121  for(HistosContainer::iterator itM=histosMap_.begin(); itM!=histosMap_.end(); itM++){
122  for(map<string,MonitorElement*>::iterator itMM=itM->second["run"].begin(); itMM!=itM->second["run"].end(); itMM++){
123  name = string("h") + itM->first + itMM->first;
124  title = itM->first + "_{0} " + itMM->first;
125  if(itM->first == "x" || itM->first == "y"){
126  if(itMM->first == "Coordinate"){
127  itMM->second = ibooker.book1D(name,title,1001,-0.2525,0.2525);
128  }
129  else if(itMM->first == "PrimaryVertex fit-DataBase" || itMM->first == "PrimaryVertex fit-BeamFit" || itMM->first == "PrimaryVertex fit-Scalers"
130  || itMM->first == "PrimaryVertex-DataBase" || itMM->first == "PrimaryVertex-BeamFit" || itMM->first == "PrimaryVertex-Scalers"){
131  itMM->second = ibooker.book1D(name,title,1001,-0.02525,0.02525);
132  }
133  else{
134  //assert(0);
135  }
136  }
137  else if(itM->first == "z"){
138  if(itMM->first == "Coordinate"){
139  itMM->second = ibooker.book1D(name,title,101,-5.05,5.05);
140  }
141  else if(itMM->first == "PrimaryVertex fit-DataBase" || itMM->first == "PrimaryVertex fit-BeamFit" || itMM->first == "PrimaryVertex fit-Scalers"){
142  itMM->second = ibooker.book1D(name,title,101,-0.505,0.505);
143  }
144  else if(itMM->first == "PrimaryVertex-DataBase" || itMM->first == "PrimaryVertex-BeamFit" || itMM->first == "PrimaryVertex-Scalers"){
145  itMM->second = ibooker.book1D(name,title,1001,-5.005,5.005);
146  }
147  else{
148  //assert(0);
149  }
150  }
151  else if(itM->first == "sigmaX" || itM->first == "sigmaY"){
152  if(itMM->first == "Coordinate"){
153  itMM->second = ibooker.book1D(name,title,100,0,0.015);
154  }
155  else if(itMM->first == "PrimaryVertex fit-DataBase" || itMM->first == "PrimaryVertex fit-BeamFit" || itMM->first == "PrimaryVertex fit-Scalers"
156  || itMM->first == "PrimaryVertex-DataBase" || itMM->first == "PrimaryVertex-BeamFit" || itMM->first == "PrimaryVertex-Scalers"){
157  itMM->second = nullptr;
158  }
159  else{
160  //assert(0);
161  }
162  }
163  else if(itM->first == "sigmaZ"){
164  if(itMM->first == "Coordinate"){
165  itMM->second = ibooker.book1D(name,title,110,0,11);
166  }
167  else if(itMM->first == "PrimaryVertex fit-DataBase" || itMM->first == "PrimaryVertex fit-BeamFit" || itMM->first == "PrimaryVertex fit-Scalers"
168  || itMM->first == "PrimaryVertex-DataBase" || itMM->first == "PrimaryVertex-BeamFit" || itMM->first == "PrimaryVertex-Scalers"){
169  itMM->second = ibooker.book1D(name,title,101,-5.05,5.05);
170  }
171  else{
172  //assert(0);
173  }
174  }
175  else{
176  //assert(0);
177  }
178  if(itMM->second != nullptr){
179  if(itMM->first == "Coordinate"){
180  itMM->second->setAxisTitle(itM->first + "_{0} (cm)",1);
181  }
182  else if(itMM->first == "PrimaryVertex fit-DataBase" || itMM->first == "PrimaryVertex fit-BeamFit" || itMM->first == "PrimaryVertex fit-Scalers"
183  || itMM->first == "PrimaryVertex-DataBase" || itMM->first == "PrimaryVertex-BeamFit" || itMM->first == "PrimaryVertex-Scalers"){
184  itMM->second->setAxisTitle(itMM->first + " " + itM->first + "_{0} (cm)",1);
185  }
186  itMM->second->setAxisTitle("Entries",2);
187  }
188  }
189  }
190  ibooker.setCurrentFolder(monitorName_+"Service");
191  theValuesContainer_ = ibooker.bookProfile("hHistoLumiValues","Histo Lumi Values", 3*numberOfValuesToSave_, 0., 3*numberOfValuesToSave_, 100., -100., 9000., " ");
193 
194  // create and cd into new folder
195  ibooker.setCurrentFolder(monitorName_+"Validation");
196  //Book histograms
197  hD0Phi0_ = ibooker.bookProfile("hD0Phi0","d_{0} vs. #phi_{0} (All Tracks)",63,-3.15,3.15,100,-0.5,0.5,"");
198  hD0Phi0_->setAxisTitle("#phi_{0} (rad)",1);
199  hD0Phi0_->setAxisTitle("d_{0} (cm)",2);
200 
201  ibooker.setCurrentFolder(monitorName_+"Debug");
202  hDxyBS_ = ibooker.book1D("hDxyBS","dxy_{0} w.r.t. Beam spot (All Tracks)",100,-0.1,0.1);
203  hDxyBS_->setAxisTitle("dxy_{0} w.r.t. Beam spot (cm)",1);
204 }
MonitorElement * hD0Phi0_
MonitorElement * hDxyBS_
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:160
void setLumiFlag()
this ME is meant to be stored for each luminosity section
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
HistosContainer histosMap_
std::string monitorName_
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
MonitorElement * theValuesContainer_
void AlcaBeamMonitor::endLuminosityBlock ( const edm::LuminosityBlock iLumi,
const edm::EventSetup iSetup 
)
overrideprotected

Definition at line 312 of file AlcaBeamMonitor.cc.

References beamSpotsMap_, DEFINE_FWK_MODULE, MonitorElement::Fill(), plotBeamSpotDB::first, PVFitter::getBeamSpot(), BeamFitter::getBeamSpot(), MonitorElement::getTProfile(), trackerHits::histo, histoByCategoryNames_, histosMap_, position, positionsMap_, funct::pow(), MetAnalyzer::pv(), PVFitter::resetAll(), BeamFitter::resetLSRange(), BeamFitter::resetPVFitter(), BeamFitter::resetRefTime(), BeamFitter::resetTrkVector(), PVFitter::runFitter(), BeamFitter::runPVandTrkFitter(), edm::second(), mathSSE::sqrt(), theBeamFitter_, thePVFitter_, theValuesContainer_, align::Tracker, varNamesV_, and vertices_.

312  {
315  }
320 
321  if ( thePVFitter_->runFitter() ) {
323  }
325 
326  // "PV,BF..." Value,Error
327  map<std::string,pair<double,double> > resultsMap;
328  vector<pair<double,double> > vertexResults;
329  MonitorElement* histo=nullptr;
330  int position = 0;
331  for(vector<string>::iterator itV=varNamesV_.begin(); itV!=varNamesV_.end(); itV++){
332  resultsMap.clear();
333  for(BeamSpotContainer::iterator itBS = beamSpotsMap_.begin(); itBS != beamSpotsMap_.end(); itBS++){
334  if(itBS->second.type() == BeamSpot::Tracker){
335  if(*itV == "x"){
336  resultsMap[itBS->first] = pair<double,double>(itBS->second.x0(),itBS->second.x0Error());
337  }
338  else if(*itV == "y"){
339  resultsMap[itBS->first] = pair<double,double>(itBS->second.y0(),itBS->second.y0Error());
340  }
341  else if(*itV == "z"){
342  resultsMap[itBS->first] = pair<double,double>(itBS->second.z0(),itBS->second.z0Error());
343  }
344  else if(*itV == "sigmaX"){
345  resultsMap[itBS->first] = pair<double,double>(itBS->second.BeamWidthX(),itBS->second.BeamWidthXError());
346  }
347  else if(*itV == "sigmaY"){
348  resultsMap[itBS->first] = pair<double,double>(itBS->second.BeamWidthY(),itBS->second.BeamWidthYError());
349  }
350  else if(*itV == "sigmaZ"){
351  resultsMap[itBS->first] = pair<double,double>(itBS->second.sigmaZ(),itBS->second.sigmaZ0Error());
352  }
353  else{
354  LogInfo("AlcaBeamMonitor")
355  << "The histosMap_ has been built with the name " << *itV << " that I can't recognize!";
356  //assert(0);
357  }
358  }
359  }
360  vertexResults.clear();
361  for(vector<VertexCollection>::iterator itPV = vertices_.begin(); itPV != vertices_.end(); itPV++){
362  if(!itPV->empty()){
363  for(VertexCollection::const_iterator pv = itPV->begin(); pv != itPV->end(); pv++) {
364  if (pv->isFake() || pv->tracksSize()<10) continue;
365  if(*itV == "x"){
366  vertexResults.push_back(pair<double,double>(pv->x(),pv->xError()));
367  }
368  else if(*itV == "y"){
369  vertexResults.push_back(pair<double,double>(pv->y(),pv->yError()));
370  }
371  else if(*itV == "z"){
372  vertexResults.push_back(pair<double,double>(pv->z(),pv->zError()));
373  }
374  else if(*itV != "sigmaX" && *itV != "sigmaY" && *itV != "sigmaZ"){
375  LogInfo("AlcaBeamMonitor")
376  << "The histosMap_ has been built with the name " << *itV << " that I can't recognize!";
377  //assert(0);
378  }
379  }
380  }
381  }
382 /*
383  histoByCategoryNames_.insert( pair<string,string>("run", "Coordinate"));
384  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex fit-DataBase"));
385  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex fit-BeamFit"));
386  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex fit-Scalers"));
387  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex-DataBase"));
388  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex-BeamFit"));
389  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex-Scalers"));
390 
391  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased BeamSpotFit"));
392  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased PrimaryVertex"));
393  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased DataBase"));
394  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased Scalers"));
395  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased PrimaryVertex-DataBase fit"));
396  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased PrimaryVertex-Scalers fit"));
397  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased Scalers-DataBase fit"));
398  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased PrimaryVertex-DataBase"));
399  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased PrimaryVertex-Scalers"));
400 */
401  for(multimap<string,string>::iterator itM=histoByCategoryNames_.begin(); itM!=histoByCategoryNames_.end(); itM++){
402  if(itM->first == "run" && (histo = histosMap_[*itV][itM->first][itM->second]) == nullptr){
403  continue;
404  }
405  else if(itM->first != "run"){
406  position = positionsMap_[*itV][itM->first][itM->second];
407  }
408  if(itM->second == "Coordinate"){
409  if(beamSpotsMap_.find("DB") != beamSpotsMap_.end()){
410  histo->Fill(resultsMap["DB"].first);
411  }
412  }
413  else if(itM->second == "PrimaryVertex fit-DataBase"){
414  if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()){
415  histo->Fill(resultsMap["PV"].first-resultsMap["DB"].first);
416  }
417  }
418  else if(itM->second == "PrimaryVertex fit-BeamFit"){
419  if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("BF") != resultsMap.end()){
420  histo->Fill(resultsMap["PV"].first-resultsMap["BF"].first);
421  }
422  }
423  else if(itM->second == "PrimaryVertex fit-Scalers"){
424  if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("SC") != resultsMap.end()){
425  histo->Fill(resultsMap["PV"].first-resultsMap["SC"].first);
426  }
427  }
428  else if(itM->second == "PrimaryVertex-DataBase"){
429  if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()){
430  for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
431  histo->Fill(itPV->first-resultsMap["DB"].first);
432  }
433  }
434  }
435  else if(itM->second == "PrimaryVertex-BeamFit"){
436  if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("BF") != resultsMap.end()){
437  for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
438  histo->Fill(itPV->first-resultsMap["BF"].first);
439  }
440  }
441  }
442  else if(itM->second == "PrimaryVertex-Scalers"){
443  if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("SC") != resultsMap.end()){
444  for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
445  histo->Fill(itPV->first-resultsMap["SC"].first);
446  }
447  }
448  }
449  else if(itM->second == "Lumibased BeamSpotFit"){
450  if(resultsMap.find("BF") != resultsMap.end()){
451  theValuesContainer_->Fill(position ,resultsMap["BF"].first);//Value
452  theValuesContainer_->Fill(position+1,resultsMap["BF"].second);//Error
453  theValuesContainer_->Fill(position+2,1);//ok
454  }
455  }
456  else if(itM->second == "Lumibased PrimaryVertex"){
457  if(resultsMap.find("PV") != resultsMap.end()){
458  theValuesContainer_->Fill(position ,resultsMap["PV"].first);//Value
459  theValuesContainer_->Fill(position+1,resultsMap["PV"].second);//Error
460  theValuesContainer_->Fill(position+2,1);//ok
461  }
462  }
463  else if(itM->second == "Lumibased DataBase"){
464  if(resultsMap.find("DB") != resultsMap.end()){
465  theValuesContainer_->Fill(position ,resultsMap["DB"].first);//Value
466  theValuesContainer_->Fill(position+1,resultsMap["DB"].second);//Error
467  theValuesContainer_->Fill(position+2,1);//ok
468  }
469  }
470  else if(itM->second == "Lumibased Scalers"){
471  if(resultsMap.find("SC") != resultsMap.end()){
472  theValuesContainer_->Fill(position ,resultsMap["SC"].first);//Value
473  theValuesContainer_->Fill(position+1,resultsMap["SC"].second);//Error
474  theValuesContainer_->Fill(position+2,1);//ok
475  }
476  }
477  else if(itM->second == "Lumibased PrimaryVertex-DataBase fit"){
478  if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()){
479  theValuesContainer_->Fill(position ,resultsMap["PV"].first-resultsMap["DB"].first);//Value
480  theValuesContainer_->Fill(position+1,std::sqrt(std::pow(resultsMap["PV"].second,2)+std::pow(resultsMap["DB"].second,2)));//Error
481  theValuesContainer_->Fill(position+2,1);//ok
482  }
483  }
484  else if(itM->second == "Lumibased PrimaryVertex-Scalers fit"){
485  if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("SC") != resultsMap.end()){
486  theValuesContainer_->Fill(position ,resultsMap["PV"].first-resultsMap["SC"].first);//Value
487  theValuesContainer_->Fill(position+1,std::sqrt(std::pow(resultsMap["PV"].second,2)+std::pow(resultsMap["SC"].second,2)));//Error
488  theValuesContainer_->Fill(position+2,1);//ok
489  }
490  }
491  else if(itM->second == "Lumibased Scalers-DataBase fit"){
492  if(resultsMap.find("SC") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()){
493  theValuesContainer_->Fill(position ,resultsMap["SC"].first-resultsMap["DB"].first);//Value
494  theValuesContainer_->Fill(position+1,std::sqrt(std::pow(resultsMap["SC"].second,2)+std::pow(resultsMap["DB"].second,2)));//Error
495  theValuesContainer_->Fill(position+2,1);//ok
496  }
497  }
498  else if(itM->second == "Lumibased PrimaryVertex-DataBase"){
499  if(resultsMap.find("DB") != resultsMap.end() && !vertexResults.empty()){
500  for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
501  theValuesContainer_->Fill(position ,(*itPV).first-resultsMap["DB"].first);//Value
502  }
503 /*
504  double error = 0;
505  if(vertexResults.size() != 0){
506  for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
507  error += std::pow((*itPV).first-resultsMap["DB"].first-theValuesContainer_->getTProfile()->GetBinContent(position+1),2.);
508  }
509  error = std::sqrt(error)/vertexResults.size();
510  }
511 // theValuesContainer_->Fill(position+1,std::sqrt(std::pow((*itPV).second,2)+std::pow(resultsMap["DB"].second,2)));//Error
512  theValuesContainer_->Fill(position+1,error);//Error
513 */
514  theValuesContainer_->Fill(position+1,theValuesContainer_->getTProfile()->GetBinError(position+1));//Error
515  theValuesContainer_->Fill(position+2,1);//ok
516  }
517  }
518  else if(itM->second == "Lumibased PrimaryVertex-Scalers"){
519  if(resultsMap.find("SC") != resultsMap.end() && !vertexResults.empty()){
520  for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
521  theValuesContainer_->Fill(position ,(*itPV).first-resultsMap["SC"].first);//Value
522  }
523 /*
524  double error = 0;
525  if(vertexResults.size() != 0){
526  for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
527  error += std::pow((*itPV).first-resultsMap["SC"].first-theValuesContainer_->getTProfile()->GetBinContent(position+1),2.);
528  }
529  error = std::sqrt(error)/vertexResults.size();
530  }
531 // theValuesContainer_->Fill(position+1,std::sqrt(std::pow((*itPV).second,2)+std::pow(resultsMap["SC"].second,2)));//Error
532  theValuesContainer_->Fill(position+1,error);//Error
533 */
534  theValuesContainer_->Fill(position+1,theValuesContainer_->getTProfile()->GetBinError(position+1));//Error
535  theValuesContainer_->Fill(position+2,1);//ok
536  }
537  }
538 // else if(itM->second == "Lumibased Scalers-DataBase"){
539 // if(resultsMap.find("SC") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()){
540 // itHHH->second->Fill(bin,resultsMap["SC"].first-resultsMap["DB"].first);
541 // }
542 // }
543  else{
544  LogInfo("AlcaBeamMonitor")
545  << "The histosMap_ have a histogram named " << itM->second << " that I can't recognize in this loop!";
546  //assert(0);
547 
548  }
549  }
550  }
551 }
TProfile * getTProfile() const
bool runPVandTrkFitter()
Definition: BeamFitter.cc:398
void resetTrkVector()
Definition: BeamFitter.h:53
PositionContainer positionsMap_
void Fill(long long x)
U second(std::pair< T, U > const &p)
std::vector< std::string > varNamesV_
T sqrt(T t)
Definition: SSEVec.h:18
BeamSpotContainer beamSpotsMap_
BeamFitter * theBeamFitter_
def pv(vc)
Definition: MetAnalyzer.py:6
void resetLSRange()
Definition: BeamFitter.h:55
PVFitter * thePVFitter_
std::multimap< std::string, std::string > histoByCategoryNames_
bool runFitter()
Definition: PVFitter.cc:316
HistosContainer histosMap_
void resetAll()
Definition: PVFitter.h:80
void resetPVFitter()
Definition: BeamFitter.h:69
static int position[264][3]
Definition: ReadPGInfo.cc:509
reco::BeamSpot getBeamSpot()
Definition: PVFitter.h:91
MonitorElement * theValuesContainer_
reco::BeamSpot getBeamSpot()
Definition: BeamFitter.h:94
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
std::vector< reco::VertexCollection > vertices_
void resetRefTime()
Definition: BeamFitter.h:56

Member Data Documentation

edm::InputTag AlcaBeamMonitor::beamSpotLabel_
private

Definition at line 55 of file AlcaBeamMonitor.h.

BeamSpotContainer AlcaBeamMonitor::beamSpotsMap_
private

Definition at line 68 of file AlcaBeamMonitor.h.

Referenced by analyze(), beginLuminosityBlock(), and endLuminosityBlock().

MonitorElement* AlcaBeamMonitor::hD0Phi0_
private

Definition at line 63 of file AlcaBeamMonitor.h.

Referenced by analyze(), and bookHistograms().

MonitorElement* AlcaBeamMonitor::hDxyBS_
private

Definition at line 64 of file AlcaBeamMonitor.h.

Referenced by analyze(), and bookHistograms().

std::multimap<std::string,std::string> AlcaBeamMonitor::histoByCategoryNames_
private

Definition at line 72 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor(), and endLuminosityBlock().

HistosContainer AlcaBeamMonitor::histosMap_
private

Definition at line 69 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor(), bookHistograms(), and endLuminosityBlock().

std::string AlcaBeamMonitor::monitorName_
private

Definition at line 51 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor(), and bookHistograms().

int AlcaBeamMonitor::numberOfValuesToSave_
private

Definition at line 58 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor(), and bookHistograms().

edm::ParameterSet AlcaBeamMonitor::parameters_
private
PositionContainer AlcaBeamMonitor::positionsMap_
private

Definition at line 70 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor(), and endLuminosityBlock().

edm::EDGetTokenT<reco::VertexCollection> AlcaBeamMonitor::primaryVertexLabel_
private

Definition at line 52 of file AlcaBeamMonitor.h.

Referenced by analyze().

edm::EDGetTokenT<reco::BeamSpot> AlcaBeamMonitor::scalerLabel_
private

Definition at line 54 of file AlcaBeamMonitor.h.

Referenced by analyze().

BeamFitter* AlcaBeamMonitor::theBeamFitter_
private

Definition at line 59 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor(), analyze(), endLuminosityBlock(), and ~AlcaBeamMonitor().

PVFitter* AlcaBeamMonitor::thePVFitter_
private

Definition at line 60 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor(), analyze(), endLuminosityBlock(), and ~AlcaBeamMonitor().

MonitorElement* AlcaBeamMonitor::theValuesContainer_
private

Definition at line 65 of file AlcaBeamMonitor.h.

Referenced by beginLuminosityBlock(), bookHistograms(), and endLuminosityBlock().

edm::EDGetTokenT<reco::TrackCollection> AlcaBeamMonitor::trackLabel_
private

Definition at line 53 of file AlcaBeamMonitor.h.

Referenced by analyze().

std::vector<std::string> AlcaBeamMonitor::varNamesV_
private

Definition at line 71 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor(), and endLuminosityBlock().

std::vector<reco::VertexCollection> AlcaBeamMonitor::vertices_
private

Definition at line 73 of file AlcaBeamMonitor.h.

Referenced by analyze(), beginLuminosityBlock(), and endLuminosityBlock().