CMS 3D CMS Logo

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

#include <AlcaBeamSpotManager.h>

Public Types

typedef std::map< edm::LuminosityBlockNumber_t, std::pair< edm::Timestamp, reco::BeamSpot > >::iterator bsMap_iterator
 

Public Member Functions

 AlcaBeamSpotManager (void)
 
 AlcaBeamSpotManager (const edm::ParameterSet &, edm::ConsumesCollector &&)
 
void createWeightedPayloads (void)
 
const std::map< edm::LuminosityBlockNumber_t, std::pair< edm::Timestamp, reco::BeamSpot > > & getPayloads (void)
 
void readLumi (const edm::LuminosityBlock &)
 
void reset (void)
 
virtual ~AlcaBeamSpotManager (void)
 

Private Member Functions

std::pair< float, float > delta (const float &x, const float &xError, const float &nextX, const float &nextXError)
 
float deltaSig (const float &num, const float &den)
 
reco::BeamSpot weight (const bsMap_iterator &begin, const bsMap_iterator &end)
 
void weight (double &mean, double &meanError, const double &val, const double &valError)
 

Private Attributes

std::string beamSpotLabel_
 
std::map< edm::LuminosityBlockNumber_t, std::pair< edm::Timestamp, reco::BeamSpot > > beamSpotMap_
 
std::string beamSpotModuleName_
 
std::string beamSpotOutputBase_
 
edm::InputTag beamSpotTag_
 
edm::EDGetTokenT< reco::BeamSpotbeamSpotToken_
 
double sigmaZCut_
 

Detailed Description

No description available.

Author
L. Uplegger F. Yumiceva - Fermilab

Definition at line 18 of file AlcaBeamSpotManager.h.

Member Typedef Documentation

◆ bsMap_iterator

Definition at line 31 of file AlcaBeamSpotManager.h.

Constructor & Destructor Documentation

◆ AlcaBeamSpotManager() [1/2]

AlcaBeamSpotManager::AlcaBeamSpotManager ( void  )

Definition at line 19 of file AlcaBeamSpotManager.cc.

19 {}

◆ AlcaBeamSpotManager() [2/2]

AlcaBeamSpotManager::AlcaBeamSpotManager ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)

Definition at line 22 of file AlcaBeamSpotManager.cc.

References align::BeamSpot, beamSpotLabel_, beamSpotModuleName_, beamSpotOutputBase_, beamSpotTag_, beamSpotToken_, edm::InLumi, and reset().

23  : beamSpotOutputBase_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
24  .getUntrackedParameter<std::string>("BeamSpotOutputBase")),
25  beamSpotModuleName_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
26  .getUntrackedParameter<std::string>("BeamSpotModuleName")),
27  beamSpotLabel_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
28  .getUntrackedParameter<std::string>("BeamSpotLabel")),
29  sigmaZCut_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
30  .getUntrackedParameter<double>("SigmaZCut")) {
33  LogInfo("AlcaBeamSpotManager") << "Output base: " << beamSpotOutputBase_ << std::endl;
34  reset();
35 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::string beamSpotOutputBase_
edm::InputTag beamSpotTag_
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
T getUntrackedParameter(std::string const &, T const &) const
std::string beamSpotModuleName_
Log< level::Info, false > LogInfo

◆ ~AlcaBeamSpotManager()

AlcaBeamSpotManager::~AlcaBeamSpotManager ( void  )
virtual

Definition at line 38 of file AlcaBeamSpotManager.cc.

38 {}

Member Function Documentation

◆ createWeightedPayloads()

void AlcaBeamSpotManager::createWeightedPayloads ( void  )

Definition at line 61 of file AlcaBeamSpotManager.cc.

References beamSpotMap_, beamSpotOutputBase_, reco::BeamSpot::BeamWidthX(), reco::BeamSpot::BeamWidthXError(), reco::BeamSpot::BeamWidthY(), reco::BeamSpot::BeamWidthYError(), delta(), deltaSig(), l1tTrackerHTMiss_cfi::deltaZ, reco::BeamSpot::dxdz(), reco::BeamSpot::dxdzError(), reco::BeamSpot::dydz(), reco::BeamSpot::dydzError(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, align_cfg::iteration, remoteMonitoring_LASER_era2018_cfg::limit, reco::BeamSpot::sigmaZ(), reco::BeamSpot::sigmaZ0Error(), sigmaZCut_, ntuplemaker::tmprun, align::Tracker, funct::true, reco::Unknown, weight(), reco::BeamSpot::x0(), reco::BeamSpot::x0Error(), reco::BeamSpot::y0(), reco::BeamSpot::y0Error(), reco::BeamSpot::z0(), and reco::BeamSpot::z0Error().

Referenced by AlcaBeamSpotHarvester::endRun().

61  {
62  vector<bsMap_iterator> listToErase;
63  for (bsMap_iterator it = beamSpotMap_.begin(); it != beamSpotMap_.end(); it++) {
64  if (it->second.second.type() != BeamSpot::Tracker || it->second.second.sigmaZ() < sigmaZCut_) {
65  listToErase.push_back(it);
66  }
67  }
68  for (vector<bsMap_iterator>::iterator it = listToErase.begin(); it != listToErase.end(); it++) {
69  beamSpotMap_.erase(*it);
70  }
71  if (beamSpotMap_.size() <= 1) {
72  return;
73  }
74  // Return only if lumibased since the collapsing alghorithm requires the next
75  // and next to next lumi sections
76  else if (beamSpotMap_.size() == 2 && beamSpotOutputBase_ == "lumibased") {
77  return;
78  }
79  if (beamSpotOutputBase_ == "lumibased") {
80  // bsMap_iterator referenceBS = beamSpotMap_.begin();
81  bsMap_iterator firstBS = beamSpotMap_.begin();
82  // bsMap_iterator lastBS = beamSpotMap_.begin();
83  bsMap_iterator currentBS = beamSpotMap_.begin();
84  bsMap_iterator nextBS = ++beamSpotMap_.begin();
85  bsMap_iterator nextNextBS = ++(++(beamSpotMap_.begin()));
86 
87  reco::BeamSpot currentBSObj;
88  reco::BeamSpot nextBSObj;
89 
90  map<LuminosityBlockNumber_t, std::pair<edm::Timestamp, BeamSpot>> tmpBeamSpotMap_;
91  bool docreate = true;
92  bool endOfRun = false; // Added
93  bool docheck = true; // Added
94  bool foundShift = false;
95  long countlumi = 0; // Added
96  string tmprun = ""; // Added
97  long maxNlumis = 20; // Added
98  // if weighted:
99  // maxNlumis = 999999999
100 
101  unsigned int iteration = 0;
102  // while(nextNextBS!=beamSpotMap_.end()){
103  while (nextBS != beamSpotMap_.end()) {
104  LogInfo("AlcaBeamSpotManager") << "Iteration: " << iteration << " size: " << beamSpotMap_.size() << "\n"
105  << "Lumi: " << currentBS->first << "\n"
106  << currentBS->second.second << "\n"
107  << nextBS->first << "\n"
108  << nextBS->second.second << endl;
109  if (nextNextBS != beamSpotMap_.end())
110  LogInfo("AlcaBeamSpotManager") << nextNextBS->first << "\n" << nextNextBS->second.second << endl;
111 
112  if (docreate) {
113  firstBS = currentBS;
114  docreate = false; // Added
115  }
116  // if(iteration >= beamSpotMap_.size()-3){
117  if (iteration >= beamSpotMap_.size() - 2) {
118  LogInfo("AlcaBeamSpotManager") << "Reached lumi " << currentBS->first
119  << " now close payload because end of data has been reached.";
120  docreate = true;
121  endOfRun = true;
122  }
123  // check we run over the same run
124  // if (ibeam->first.Run() != inextbeam->first.Run()){
125  // LogInfo("AlcaBeamSpotManager")
126  // << "close payload because end of run.";
127  // docreate = true;
128  // }
129  // check maximum lumi counts
130  if (countlumi == maxNlumis - 1) {
131  LogInfo("AlcaBeamSpotManager") << "close payload because maximum lumi "
132  "sections accumulated within run ";
133  docreate = true;
134  countlumi = 0;
135  }
136  // if weighted:
137  // docheck = False
138  // check offsets
139  if (docheck) {
140  foundShift = false;
141  LogInfo("AlcaBeamSpotManager") << "Checking checking!" << endl;
142  float limit = 0;
143  pair<float, float> adelta1;
144  pair<float, float> adelta2;
145  pair<float, float> adelta;
146  pair<float, float> adelta1dxdz;
147  pair<float, float> adelta2dxdz;
148  pair<float, float> adelta1dydz;
149  pair<float, float> adelta2dydz;
150  pair<float, float> adelta1widthX;
151  pair<float, float> adelta2widthX;
152  pair<float, float> adelta1widthY;
153  pair<float, float> adelta2widthY;
154  pair<float, float> adelta1z0;
155  pair<float, float> adelta1sigmaZ;
156 
157  // define minimum limit
158  float min_limit = 0.0025;
159 
160  // limit for x and y
161  limit = currentBS->second.second.BeamWidthX() / 2.;
162  if (limit < min_limit) {
163  limit = min_limit;
164  }
165 
166  currentBSObj = currentBS->second.second;
167  nextBSObj = nextBS->second.second;
168 
169  // check movements in X
170  adelta1 = delta(currentBSObj.x0(), currentBSObj.x0Error(), nextBSObj.x0(), nextBSObj.x0Error());
171  adelta2 = pair<float, float>(0., 1.e9);
172  if (nextNextBS->second.second.type() != -1) {
173  adelta2 = delta(nextBS->second.second.x0(),
174  nextBSObj.x0Error(),
175  nextNextBS->second.second.x0(),
176  nextNextBS->second.second.x0Error());
177  }
178  bool deltaX = (deltaSig(adelta1.first, adelta1.second) > 3.5 && adelta1.first >= limit) ? true : false;
179  if (iteration < beamSpotMap_.size() - 2) {
180  if (!deltaX && adelta1.first * adelta2.first > 0. && fabs(adelta1.first + adelta2.first) >= limit) {
181  LogInfo("AlcaBeamSpotManager")
182  << " positive, " << (adelta1.first + adelta2.first) << " limit=" << limit << endl;
183  deltaX = true;
184  } else if (deltaX && adelta1.first * adelta2.first < 0 && adelta2.first != 0 &&
185  fabs(adelta1.first / adelta2.first) > 0.33 && fabs(adelta1.first / adelta2.first) < 3) {
186  LogInfo("AlcaBeamSpotManager") << " negative, " << adelta1.first / adelta2.first << endl;
187  deltaX = false;
188  }
189  }
190 
191  // calculating all deltas
192  adelta1dxdz = delta(currentBSObj.dxdz(), currentBSObj.dxdzError(), nextBSObj.dxdz(), nextBSObj.dxdzError());
193  adelta2dxdz = pair<float, float>(0., 1.e9);
194  adelta1dydz = delta(currentBSObj.dydz(), currentBSObj.dydzError(), nextBSObj.dydz(), nextBSObj.dydzError());
195  adelta2dydz = pair<float, float>(0., 1.e9);
196  adelta1widthX = delta(currentBSObj.BeamWidthX(),
197  currentBSObj.BeamWidthXError(),
198  nextBSObj.BeamWidthX(),
199  nextBSObj.BeamWidthXError());
200  adelta2widthX = pair<float, float>(0., 1.e9);
201  adelta1widthY = delta(currentBSObj.BeamWidthY(),
202  currentBSObj.BeamWidthYError(),
203  nextBSObj.BeamWidthY(),
204  nextBSObj.BeamWidthYError());
205  adelta2widthY = pair<float, float>(0., 1.e9);
206  adelta1z0 = delta(currentBSObj.z0(), currentBSObj.z0Error(), nextBSObj.z0(), nextBSObj.z0Error());
207  adelta1sigmaZ =
208  delta(currentBSObj.sigmaZ(), currentBSObj.sigmaZ0Error(), nextBSObj.sigmaZ(), nextBSObj.sigmaZ0Error());
209 
210  // check movements in Y
211  adelta1 = delta(currentBSObj.y0(), currentBSObj.y0Error(), nextBSObj.y0(), nextBSObj.y0Error());
212  adelta2 = pair<float, float>(0., 1.e9);
213  if (nextNextBS->second.second.type() != BeamSpot::Unknown) {
214  adelta2 = delta(
215  nextBSObj.y0(), nextBSObj.y0Error(), nextNextBS->second.second.y0(), nextNextBS->second.second.y0Error());
216  adelta2dxdz = delta(nextBSObj.dxdz(),
217  nextBSObj.dxdzError(),
218  nextNextBS->second.second.dxdz(),
219  nextNextBS->second.second.dxdzError());
220  adelta2dydz = delta(nextBSObj.dydz(),
221  nextBSObj.dydzError(),
222  nextNextBS->second.second.dydz(),
223  nextNextBS->second.second.dydzError());
224  adelta2widthX = delta(nextBSObj.BeamWidthX(),
225  nextBSObj.BeamWidthXError(),
226  nextNextBS->second.second.BeamWidthX(),
227  nextNextBS->second.second.BeamWidthXError());
228  adelta2widthY = delta(nextBSObj.BeamWidthY(),
229  nextBSObj.BeamWidthYError(),
230  nextNextBS->second.second.BeamWidthY(),
231  nextNextBS->second.second.BeamWidthYError());
232  }
233  bool deltaY = (deltaSig(adelta1.first, adelta1.second) > 3.5 && adelta1.first >= limit) ? true : false;
234  if (iteration < beamSpotMap_.size() - 2) {
235  if (!deltaY && adelta1.first * adelta2.first > 0. && fabs(adelta1.first + adelta2.first) >= limit) {
236  LogInfo("AlcaBeamSpotManager")
237  << " positive, " << (adelta1.first + adelta2.first) << " limit=" << limit << endl;
238  deltaY = true;
239  } else if (deltaY && adelta1.first * adelta2.first < 0 && adelta2.first != 0 &&
240  fabs(adelta1.first / adelta2.first) > 0.33 && fabs(adelta1.first / adelta2.first) < 3) {
241  LogInfo("AlcaBeamSpotManager") << " negative, " << adelta1.first / adelta2.first << endl;
242  deltaY = false;
243  }
244  }
245 
246  limit = currentBSObj.sigmaZ() / 2.;
247  bool deltaZ =
248  (deltaSig(adelta1z0.first, adelta1z0.second) > 3.5 && fabs(adelta1z0.first) >= limit) ? true : false;
249  adelta =
250  delta(currentBSObj.sigmaZ(), currentBSObj.sigmaZ0Error(), nextBSObj.sigmaZ(), nextBSObj.sigmaZ0Error());
251  bool deltasigmaZ = (deltaSig(adelta.first, adelta.second) > 5.0) ? true : false;
252  bool deltadxdz = false;
253  bool deltadydz = false;
254  bool deltawidthX = false;
255  bool deltawidthY = false;
256 
257  if (iteration < beamSpotMap_.size() - 2) {
258  adelta = delta(currentBSObj.dxdz(), currentBSObj.dxdzError(), nextBSObj.dxdz(), nextBSObj.dxdzError());
259  deltadxdz = (deltaSig(adelta.first, adelta.second) > 5.0) ? true : false;
260  if (deltadxdz && (adelta1dxdz.first * adelta2dxdz.first) < 0 && adelta2dxdz.first != 0 &&
261  fabs(adelta1dxdz.first / adelta2dxdz.first) > 0.33 && fabs(adelta1dxdz.first / adelta2dxdz.first) < 3) {
262  deltadxdz = false;
263  }
264 
265  adelta = delta(currentBSObj.dydz(), currentBSObj.dydzError(), nextBSObj.dydz(), nextBSObj.dydzError());
266  deltadydz = (deltaSig(adelta.first, adelta.second) > 5.0) ? true : false;
267  if (deltadydz && (adelta1dydz.first * adelta2dydz.first) < 0 && adelta2dydz.first != 0 &&
268  fabs(adelta1dydz.first / adelta2dydz.first) > 0.33 && fabs(adelta1dydz.first / adelta2dydz.first) < 3) {
269  deltadydz = false;
270  }
271 
272  adelta = delta(currentBSObj.BeamWidthX(),
273  currentBSObj.BeamWidthXError(),
274  nextBSObj.BeamWidthX(),
275  nextBSObj.BeamWidthXError());
276  deltawidthX = (deltaSig(adelta.first, adelta.second) > 5.0) ? true : false;
277  if (deltawidthX && (adelta1widthX.first * adelta2widthX.first) < 0 && adelta2widthX.first != 0 &&
278  fabs(adelta1widthX.first / adelta2widthX.first) > 0.33 &&
279  fabs(adelta1widthX.first / adelta2widthX.first) < 3) {
280  deltawidthX = false;
281  }
282 
283  adelta = delta(currentBSObj.BeamWidthY(),
284  currentBSObj.BeamWidthYError(),
285  nextBSObj.BeamWidthY(),
286  nextBSObj.BeamWidthYError());
287  deltawidthY = (deltaSig(adelta.first, adelta.second) > 5.0) ? true : false;
288  if (deltawidthY && (adelta1widthY.first * adelta2widthY.first) < 0 && adelta2widthY.first != 0 &&
289  fabs(adelta1widthY.first / adelta2widthY.first) > 0.33 &&
290  fabs(adelta1widthY.first / adelta2widthY.first) < 3) {
291  deltawidthY = false;
292  }
293  }
294  if (deltaX || deltaY || deltaZ || deltasigmaZ || deltadxdz || deltadydz || deltawidthX || deltawidthY) {
295  docreate = true;
296  foundShift = true;
297  LogInfo("AlcaBeamSpotManager") << "close payload because of movement in"
298  << " X=" << deltaX << ", Y=" << deltaY << ", Z=" << deltaZ
299  << ", sigmaZ=" << deltasigmaZ << ", dxdz=" << deltadxdz
300  << ", dydz=" << deltadydz << ", widthX=" << deltawidthX
301  << ", widthY=" << deltawidthY << endl;
302  }
303  }
304  if (docreate) {
305  std::pair<edm::Timestamp, reco::BeamSpot> thepair;
306  if (foundShift) {
307  thepair = std::make_pair(currentBS->second.first, weight(firstBS, nextBS));
308  tmpBeamSpotMap_[firstBS->first] = thepair;
309  if (endOfRun) {
310  // if we're here, then we need to found a shift in the last LS
311  // We already created a new IOV, now create one just for the last LS
312  thepair = std::make_pair(nextBS->second.first, nextBSObj);
313  tmpBeamSpotMap_[nextBS->first] = thepair;
314  }
315  } else if (!foundShift && !endOfRun) { // maxLS reached
316  thepair = std::make_pair(currentBS->second.first, weight(firstBS, nextBS));
317  tmpBeamSpotMap_[firstBS->first] = thepair;
318  } else { // end of run with no shift detectred in last LS
319  thepair = std::make_pair(currentBS->second.first, weight(firstBS, beamSpotMap_.end()));
320  tmpBeamSpotMap_[firstBS->first] = thepair;
321  }
322  firstBS = nextBS;
323  countlumi = 0;
324  }
325  // tmprun = currentBS->second.Run
326  // increase the counter by one only if the IOV hasn't been closed
327  if (!docreate)
328  ++countlumi;
329 
330  currentBS = nextBS;
331  nextBS = nextNextBS;
332  nextNextBS++;
333  ++iteration;
334  }
335  beamSpotMap_.clear();
336  beamSpotMap_ = tmpBeamSpotMap_;
337  } else if (beamSpotOutputBase_ == "runbased") {
338  LuminosityBlockNumber_t firstLumi = beamSpotMap_.begin()->first;
339  std::pair<edm::Timestamp, reco::BeamSpot> thepair(beamSpotMap_.begin()->second.first,
340  weight(beamSpotMap_.begin(), beamSpotMap_.end()));
341  beamSpotMap_.clear();
342  beamSpotMap_[firstLumi] = thepair;
343  } else {
344  LogInfo("AlcaBeamSpotManager") << "Unrecognized BeamSpotOutputBase parameter: " << beamSpotOutputBase_ << endl;
345  }
346 }
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:82
std::string beamSpotOutputBase_
std::map< edm::LuminosityBlockNumber_t, std::pair< edm::Timestamp, reco::BeamSpot > > beamSpotMap_
double BeamWidthYError() const
error on beam width Y, assume error in X = Y
Definition: BeamSpot.h:101
std::map< edm::LuminosityBlockNumber_t, std::pair< edm::Timestamp, reco::BeamSpot > >::iterator bsMap_iterator
Definition: weight.py:1
double x0Error() const
error on x
Definition: BeamSpot.h:86
double dydz() const
dydz slope
Definition: BeamSpot.h:80
double z0Error() const
error on z
Definition: BeamSpot.h:90
unsigned int LuminosityBlockNumber_t
double sigmaZ0Error() const
error on sigma z
Definition: BeamSpot.h:92
double x0() const
x coordinate
Definition: BeamSpot.h:61
reco::BeamSpot weight(const bsMap_iterator &begin, const bsMap_iterator &end)
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:84
double y0() const
y coordinate
Definition: BeamSpot.h:63
double BeamWidthXError() const
error on beam width X, assume error in X = Y
Definition: BeamSpot.h:99
Log< level::Info, false > LogInfo
double sigmaZ() const
sigma z
Definition: BeamSpot.h:76
double dxdz() const
dxdz slope
Definition: BeamSpot.h:78
double z0() const
z coordinate
Definition: BeamSpot.h:65
double dydzError() const
error on dydz
Definition: BeamSpot.h:96
double dxdzError() const
error on dxdz
Definition: BeamSpot.h:94
std::pair< float, float > delta(const float &x, const float &xError, const float &nextX, const float &nextXError)
double y0Error() const
error on y
Definition: BeamSpot.h:88
float deltaSig(const float &num, const float &den)

◆ delta()

pair< float, float > AlcaBeamSpotManager::delta ( const float &  x,
const float &  xError,
const float &  nextX,
const float &  nextXError 
)
private

Definition at line 404 of file AlcaBeamSpotManager.cc.

References funct::pow(), mathSSE::sqrt(), x, and run3scouting_cff::xError.

Referenced by createWeightedPayloads().

407  {
408  return pair<float, float>(x - nextX, sqrt(pow(xError, 2) + pow(nextXError, 2)));
409 }
T sqrt(T t)
Definition: SSEVec.h:19
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ deltaSig()

float AlcaBeamSpotManager::deltaSig ( const float &  num,
const float &  den 
)
private

Definition at line 412 of file AlcaBeamSpotManager.cc.

References nano_mu_digi_cff::float, and EgammaValidation_cff::num.

Referenced by createWeightedPayloads().

412  {
413  if (den != 0) {
414  return fabs(num / den);
415  } else {
416  return float(LONG_MAX);
417  }
418 }

◆ getPayloads()

const std::map<edm::LuminosityBlockNumber_t, std::pair<edm::Timestamp, reco::BeamSpot> >& AlcaBeamSpotManager::getPayloads ( void  )
inline

Definition at line 27 of file AlcaBeamSpotManager.h.

References beamSpotMap_.

Referenced by AlcaBeamSpotHarvester::endRun().

27  {
28  return beamSpotMap_;
29  }
std::map< edm::LuminosityBlockNumber_t, std::pair< edm::Timestamp, reco::BeamSpot > > beamSpotMap_

◆ readLumi()

void AlcaBeamSpotManager::readLumi ( const edm::LuminosityBlock iLumi)

Definition at line 43 of file AlcaBeamSpotManager.cc.

References beamSpotMap_, beamSpotToken_, edm::LuminosityBlockBase::beginTime(), edm::LuminosityBlock::getByToken(), edm::HandleBase::isValid(), edm::LuminosityBlockBase::luminosityBlock(), and edm::Handle< T >::product().

Referenced by AlcaBeamSpotHarvester::endLuminosityBlock().

43  {
44  Handle<BeamSpot> beamSpotHandle;
45  iLumi.getByToken(beamSpotToken_, beamSpotHandle);
46 
47  if (beamSpotHandle.isValid()) { // check the product
48  std::pair<edm::Timestamp, reco::BeamSpot> time_bs(iLumi.beginTime(), *beamSpotHandle);
49  beamSpotMap_[iLumi.luminosityBlock()] = time_bs;
50  const BeamSpot *aBeamSpot = &beamSpotMap_[iLumi.luminosityBlock()].second;
51  aBeamSpot = beamSpotHandle.product();
52  LogInfo("AlcaBeamSpotManager") << "Lumi: " << iLumi.luminosityBlock() << std::endl;
53  LogInfo("AlcaBeamSpotManager") << *aBeamSpot << std::endl;
54  } else {
55  LogInfo("AlcaBeamSpotManager") << "Lumi: " << iLumi.luminosityBlock() << std::endl;
56  LogInfo("AlcaBeamSpotManager") << " BS is not valid!" << std::endl;
57  }
58 }
std::map< edm::LuminosityBlockNumber_t, std::pair< edm::Timestamp, reco::BeamSpot > > beamSpotMap_
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
T const * product() const
Definition: Handle.h:70
Log< level::Info, false > LogInfo
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Timestamp const & beginTime() const
bool isValid() const
Definition: HandleBase.h:70
LuminosityBlockNumber_t luminosityBlock() const

◆ reset()

void AlcaBeamSpotManager::reset ( void  )

Definition at line 41 of file AlcaBeamSpotManager.cc.

References beamSpotMap_.

Referenced by MatrixReader.MatrixReader::__init__(), data_sources.json_list::__next__(), AlcaBeamSpotManager(), AlcaBeamSpotHarvester::beginRun(), and MatrixReader.MatrixReader::showRaw().

41 { beamSpotMap_.clear(); }
std::map< edm::LuminosityBlockNumber_t, std::pair< edm::Timestamp, reco::BeamSpot > > beamSpotMap_

◆ weight() [1/2]

BeamSpot AlcaBeamSpotManager::weight ( const bsMap_iterator begin,
const bsMap_iterator end 
)
private

Definition at line 349 of file AlcaBeamSpotManager.cc.

References dxdz, dydz, mps_fire::end, relativeConstraints::error, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, reco::BeamSpot::setBeamWidthY(), beamSpotPI::sigmaZ, globals_cff::sigmaZError, align::Tracker, reco::Unknown, ApeEstimator_cff::widthX, ApeEstimator_cff::widthY, x, run3scouting_cff::xError, y, run3scouting_cff::yError, z, and globals_cff::zError.

Referenced by createWeightedPayloads().

349  {
350  double x, xError = 0;
351  double y, yError = 0;
352  double z, zError = 0;
353  double sigmaZ, sigmaZError = 0;
354  double dxdz, dxdzError = 0;
355  double dydz, dydzError = 0;
356  double widthX, widthXError = 0;
357  double widthY, widthYError = 0;
358  LogInfo("AlcaBeamSpotManager") << "Weighted BeamSpot will span lumi " << begin->first << " to " << end->first << endl;
359 
361  for (bsMap_iterator it = begin; it != end; it++) {
362  weight(x, xError, it->second.second.x0(), it->second.second.x0Error());
363  weight(y, yError, it->second.second.y0(), it->second.second.y0Error());
364  weight(z, zError, it->second.second.z0(), it->second.second.z0Error());
365  weight(sigmaZ, sigmaZError, it->second.second.sigmaZ(), it->second.second.sigmaZ0Error());
366  weight(dxdz, dxdzError, it->second.second.dxdz(), it->second.second.dxdzError());
367  weight(dydz, dydzError, it->second.second.dydz(), it->second.second.dydzError());
368  weight(widthX, widthXError, it->second.second.BeamWidthX(), it->second.second.BeamWidthXError());
369  weight(widthY, widthYError, it->second.second.BeamWidthY(), it->second.second.BeamWidthYError());
370  if (it->second.second.type() == BeamSpot::Tracker) {
372  }
373  }
374  BeamSpot::Point bsPosition(x, y, z);
376  error(0, 0) = xError * xError;
377  error(1, 1) = yError * yError;
378  error(2, 2) = zError * zError;
379  error(3, 3) = sigmaZError * sigmaZError;
380  error(4, 4) = dxdzError * dxdzError;
381  error(5, 5) = dydzError * dydzError;
382  error(6, 6) = widthXError * widthXError;
383  BeamSpot weightedBeamSpot(bsPosition, sigmaZ, dxdz, dydz, widthX, error, type);
384  weightedBeamSpot.setBeamWidthY(widthY);
385  LogInfo("AlcaBeamSpotManager") << "Weighted BeamSpot will be:" << '\n' << weightedBeamSpot << endl;
386  return weightedBeamSpot;
387 }
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:29
BeamType
beam spot flags
Definition: BeamSpot.h:24
float dydz
float dxdz
std::map< edm::LuminosityBlockNumber_t, std::pair< edm::Timestamp, reco::BeamSpot > >::iterator bsMap_iterator
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:27
reco::BeamSpot weight(const bsMap_iterator &begin, const bsMap_iterator &end)
Log< level::Info, false > LogInfo

◆ weight() [2/2]

void AlcaBeamSpotManager::weight ( double &  mean,
double &  meanError,
const double &  val,
const double &  valError 
)
private

Definition at line 390 of file AlcaBeamSpotManager.cc.

References MillePedeFileConverter_cfg::e, SiStripPI::mean, mathSSE::sqrt(), and heppy_batch::val.

390  {
391  double tmpError = 0;
392  if (meanError < 1e-8) {
393  tmpError = 1 / (valError * valError);
394  mean = val * tmpError;
395  } else {
396  tmpError = 1 / (meanError * meanError) + 1 / (valError * valError);
397  mean = mean / (meanError * meanError) + val / (valError * valError);
398  }
399  mean = mean / tmpError;
400  meanError = sqrt(1 / tmpError);
401 }
T sqrt(T t)
Definition: SSEVec.h:19

Member Data Documentation

◆ beamSpotLabel_

std::string AlcaBeamSpotManager::beamSpotLabel_
private

Definition at line 42 of file AlcaBeamSpotManager.h.

Referenced by AlcaBeamSpotManager().

◆ beamSpotMap_

std::map<edm::LuminosityBlockNumber_t, std::pair<edm::Timestamp, reco::BeamSpot> > AlcaBeamSpotManager::beamSpotMap_
private

Definition at line 38 of file AlcaBeamSpotManager.h.

Referenced by createWeightedPayloads(), getPayloads(), readLumi(), and reset().

◆ beamSpotModuleName_

std::string AlcaBeamSpotManager::beamSpotModuleName_
private

Definition at line 41 of file AlcaBeamSpotManager.h.

Referenced by AlcaBeamSpotManager().

◆ beamSpotOutputBase_

std::string AlcaBeamSpotManager::beamSpotOutputBase_
private

Definition at line 40 of file AlcaBeamSpotManager.h.

Referenced by AlcaBeamSpotManager(), and createWeightedPayloads().

◆ beamSpotTag_

edm::InputTag AlcaBeamSpotManager::beamSpotTag_
private

Definition at line 44 of file AlcaBeamSpotManager.h.

Referenced by AlcaBeamSpotManager().

◆ beamSpotToken_

edm::EDGetTokenT<reco::BeamSpot> AlcaBeamSpotManager::beamSpotToken_
private

Definition at line 45 of file AlcaBeamSpotManager.h.

Referenced by AlcaBeamSpotManager(), and readLumi().

◆ sigmaZCut_

double AlcaBeamSpotManager::sigmaZCut_
private

Definition at line 43 of file AlcaBeamSpotManager.h.

Referenced by createWeightedPayloads().