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

Definition at line 31 of file AlcaBeamSpotManager.h.

Constructor & Destructor Documentation

AlcaBeamSpotManager::AlcaBeamSpotManager ( void  )

Definition at line 20 of file AlcaBeamSpotManager.cc.

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

Definition at line 23 of file AlcaBeamSpotManager.cc.

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

24  : beamSpotOutputBase_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
25  .getUntrackedParameter<std::string>("BeamSpotOutputBase")),
26  beamSpotModuleName_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
27  .getUntrackedParameter<std::string>("BeamSpotModuleName")),
28  beamSpotLabel_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
29  .getUntrackedParameter<std::string>("BeamSpotLabel")),
30  sigmaZCut_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
31  .getUntrackedParameter<double>("SigmaZCut")) {
34  LogInfo("AlcaBeamSpotManager") << "Output base: " << beamSpotOutputBase_ << std::endl;
35  reset();
36 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::string beamSpotOutputBase_
edm::InputTag beamSpotTag_
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
std::string beamSpotModuleName_
AlcaBeamSpotManager::~AlcaBeamSpotManager ( void  )
virtual

Definition at line 39 of file AlcaBeamSpotManager.cc.

39 {}

Member Function Documentation

void AlcaBeamSpotManager::createWeightedPayloads ( void  )

Definition at line 62 of file AlcaBeamSpotManager.cc.

References beamSpotMap_, beamSpotOutputBase_, reco::BeamSpot::BeamWidthX(), reco::BeamSpot::BeamWidthXError(), reco::BeamSpot::BeamWidthY(), reco::BeamSpot::BeamWidthYError(), delta(), deltaSig(), reco::BeamSpot::dxdz(), reco::BeamSpot::dxdzError(), reco::BeamSpot::dydz(), reco::BeamSpot::dydzError(), align_cfg::iteration, MessageLogger_cfi::limit, reco::BeamSpot::sigmaZ(), reco::BeamSpot::sigmaZ0Error(), sigmaZCut_, ntuplemaker::tmprun, align::Tracker, 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().

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

Definition at line 405 of file AlcaBeamSpotManager.cc.

References funct::pow(), and mathSSE::sqrt().

Referenced by createWeightedPayloads().

408  {
409  return pair<float, float>(x - nextX, sqrt(pow(xError, 2) + pow(nextXError, 2)));
410 }
T sqrt(T t)
Definition: SSEVec.h:18
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
float AlcaBeamSpotManager::deltaSig ( const float &  num,
const float &  den 
)
private

Definition at line 413 of file AlcaBeamSpotManager.cc.

References objects.autophobj::float.

Referenced by createWeightedPayloads().

413  {
414  if (den != 0) {
415  return fabs(num / den);
416  } else {
417  return float(LONG_MAX);
418  }
419 }
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_
void AlcaBeamSpotManager::readLumi ( const edm::LuminosityBlock iLumi)

Definition at line 44 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().

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

Definition at line 42 of file AlcaBeamSpotManager.cc.

References beamSpotMap_.

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

42 { beamSpotMap_.clear(); }
std::map< edm::LuminosityBlockNumber_t, std::pair< edm::Timestamp, reco::BeamSpot > > beamSpotMap_
BeamSpot AlcaBeamSpotManager::weight ( const bsMap_iterator begin,
const bsMap_iterator end 
)
private

Definition at line 350 of file AlcaBeamSpotManager.cc.

References BeamSpotFakeParameters_cfi::dxdz, BeamSpotFakeParameters_cfi::dydz, end, relativeConstraints::error, reco::BeamSpot::setBeamWidthY(), fftjetvertexadder_cfi::sigmaZ, align::Tracker, reco::Unknown, ApeEstimator_cff::widthX, ApeEstimator_cff::widthY, x, y, and z.

Referenced by createWeightedPayloads().

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

Definition at line 391 of file AlcaBeamSpotManager.cc.

References MillePedeFileConverter_cfg::e, and mathSSE::sqrt().

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

Member Data Documentation

std::string AlcaBeamSpotManager::beamSpotLabel_
private

Definition at line 42 of file AlcaBeamSpotManager.h.

Referenced by AlcaBeamSpotManager().

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().

std::string AlcaBeamSpotManager::beamSpotModuleName_
private

Definition at line 41 of file AlcaBeamSpotManager.h.

Referenced by AlcaBeamSpotManager().

std::string AlcaBeamSpotManager::beamSpotOutputBase_
private

Definition at line 40 of file AlcaBeamSpotManager.h.

Referenced by AlcaBeamSpotManager(), and createWeightedPayloads().

edm::InputTag AlcaBeamSpotManager::beamSpotTag_
private

Definition at line 44 of file AlcaBeamSpotManager.h.

Referenced by AlcaBeamSpotManager().

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

Definition at line 45 of file AlcaBeamSpotManager.h.

Referenced by AlcaBeamSpotManager(), and readLumi().

double AlcaBeamSpotManager::sigmaZCut_
private

Definition at line 43 of file AlcaBeamSpotManager.h.

Referenced by createWeightedPayloads().