CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
TotemRPIncludeAlignments Class Reference

A class adding (mis)alignments to geometry (both real and misaligned). More...

Inheritance diagram for TotemRPIncludeAlignments:
edm::ESProducer edm::EventSetupRecordIntervalFinder edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Member Functions

std::unique_ptr< RPAlignmentCorrectionsDataproduceMeasured (const RPMeasuredAlignmentRecord &)
 
std::unique_ptr< RPAlignmentCorrectionsDataproduceMisaligned (const RPMisalignedAlignmentRecord &)
 
std::unique_ptr< RPAlignmentCorrectionsDataproduceReal (const RPRealAlignmentRecord &)
 
 TotemRPIncludeAlignments (const edm::ParameterSet &p)
 
virtual ~TotemRPIncludeAlignments ()
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()(false)
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer () noexcept(false)
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () noexcept(false)
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
const eventsetup::ComponentDescriptiondescriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
std::set< eventsetup::EventSetupRecordKeyfindingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder () noexcept(false)
 

Protected Member Functions

RPAlignmentCorrectionsDataSequence Merge (const std::vector< RPAlignmentCorrectionsDataSequence >) const
 merges an array of sequences to one More...
 
void PrepareSequence (const std::string &label, RPAlignmentCorrectionsDataSequence &seq, const std::vector< std::string > &files) const
 builds a sequence of corrections from provided sources and runs a few checks More...
 
virtual void setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &)
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
void setWhatProduced (T *iThis, const es::Label &iLabel=es::Label())
 
template<typename T >
void setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
void setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
void setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel=es::Label())
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
virtual void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList)
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 
- Protected Member Functions inherited from edm::EventSetupRecordIntervalFinder
template<class T >
void findingRecord ()
 
void findingRecordWithKey (const eventsetup::EventSetupRecordKey &)
 

Protected Attributes

RPAlignmentCorrectionsData acMeasured
 
RPAlignmentCorrectionsData acMisaligned
 
RPAlignmentCorrectionsData acReal
 
RPAlignmentCorrectionsDataSequence acsMeasured
 
RPAlignmentCorrectionsDataSequence acsMisaligned
 
RPAlignmentCorrectionsDataSequence acsReal
 
unsigned int verbosity
 

Additional Inherited Members

- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
 
typedef std::vector< EventSetupRecordKeyKeys
 
typedef std::map< EventSetupRecordKey, KeyedProxiesRecordProxies
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

A class adding (mis)alignments to geometry (both real and misaligned).

See schema of TOTEM RP geometry classes

Definition at line 34 of file TotemRPIncludeAlignments.cc.

Constructor & Destructor Documentation

TotemRPIncludeAlignments::TotemRPIncludeAlignments ( const edm::ParameterSet p)

Definition at line 66 of file TotemRPIncludeAlignments.cc.

References acsMeasured, acsMisaligned, acsReal, edm::ParameterSet::getParameter(), PrepareSequence(), produceMeasured(), produceMisaligned(), produceReal(), and edm::ESProducer::setWhatProduced().

66  :
67  verbosity(pSet.getUntrackedParameter<unsigned int>("verbosity", 1))
68 {
69  PrepareSequence("Measured", acsMeasured, pSet.getParameter< vector<string> >("MeasuredFiles"));
70  PrepareSequence("Real", acsReal, pSet.getParameter< vector<string> >("RealFiles"));
71  PrepareSequence("Misaligned", acsMisaligned, pSet.getParameter< vector<string> >("MisalignedFiles"));
72 
76 
77  findingRecord<RPMeasuredAlignmentRecord>();
78  findingRecord<RPRealAlignmentRecord>();
79  findingRecord<RPMisalignedAlignmentRecord>();
80 }
std::unique_ptr< RPAlignmentCorrectionsData > produceMisaligned(const RPMisalignedAlignmentRecord &)
RPAlignmentCorrectionsDataSequence acsReal
std::unique_ptr< RPAlignmentCorrectionsData > produceReal(const RPRealAlignmentRecord &)
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
RPAlignmentCorrectionsDataSequence acsMeasured
void PrepareSequence(const std::string &label, RPAlignmentCorrectionsDataSequence &seq, const std::vector< std::string > &files) const
builds a sequence of corrections from provided sources and runs a few checks
RPAlignmentCorrectionsDataSequence acsMisaligned
std::unique_ptr< RPAlignmentCorrectionsData > produceMeasured(const RPMeasuredAlignmentRecord &)
TotemRPIncludeAlignments::~TotemRPIncludeAlignments ( )
virtual

Definition at line 84 of file TotemRPIncludeAlignments.cc.

85 {
86 }

Member Function Documentation

RPAlignmentCorrectionsDataSequence TotemRPIncludeAlignments::Merge ( const std::vector< RPAlignmentCorrectionsDataSequence files) const
protected

merges an array of sequences to one

Definition at line 90 of file TotemRPIncludeAlignments.cc.

References Clusterizer1DCommons::add(), corr, delta, TimeValidityInterval::EndOfTime(), TimeValidityInterval::first, trackingPlots::fit, TimeValidityInterval::last, genParticles_cff::map, mps_fire::result, TimeValidityInterval::ValueToUNIXString(), and verbosity.

Referenced by PrepareSequence().

91 {
92  // find interval boundaries
93  map< TimeValue_t, vector< pair<bool, const RPAlignmentCorrectionsData*> > > bounds;
94 
95  for (vector<RPAlignmentCorrectionsDataSequence>::const_iterator fit = files.begin(); fit != files.end(); ++fit)
96  {
97  for (RPAlignmentCorrectionsDataSequence::const_iterator iit = fit->begin(); iit != fit->end(); ++iit)
98  {
99  const TimeValidityInterval &tvi = iit->first;
100  const RPAlignmentCorrectionsData *corr = & iit->second;
101 
102  bounds[tvi.first].push_back( pair<bool, const RPAlignmentCorrectionsData*>(true, corr) );
103 
104  TimeValue_t delta = (tvi.last != TimeValidityInterval::EndOfTime()) ? (1ULL << 32) : 0; // input resolution is 1s
105  bounds[tvi.last + delta].push_back( pair<bool, const RPAlignmentCorrectionsData*>(false, corr) );
106  }
107  }
108 
109  // build correction sums per interval
110  set<const RPAlignmentCorrectionsData*> accumulator;
112  // bool gap_found = false;
113  for (map< TimeValue_t, vector< pair<bool, const RPAlignmentCorrectionsData*> > >::const_iterator tit = bounds.begin(); tit != bounds.end(); ++tit)
114  {
115  for (vector< pair<bool, const RPAlignmentCorrectionsData*> >::const_iterator cit = tit->second.begin(); cit != tit->second.end(); ++cit)
116  {
117  bool add = cit->first;
118  const RPAlignmentCorrectionsData *corr = cit->second;
119 
120  if (add)
121  accumulator.insert(corr);
122  else
123  accumulator.erase(corr);
124  }
125 
126  map< TimeValue_t, vector< pair<bool, const RPAlignmentCorrectionsData*> > >::const_iterator tit_next = tit;
127  tit_next++;
128  if (tit_next == bounds.end())
129  break;
130 
131  TimeValue_t delta = (tit_next->first != TimeValidityInterval::EndOfTime()) ? 1 : 0; // minimal step
132  TimeValidityInterval tvi(tit->first, tit_next->first - delta);
133 
134  if (verbosity)
135  {
136  printf("\tfirst=%10s, last=%10s: alignment blocks=%li\n",
139  accumulator.size()
140  );
141  }
142 
143  for (set<const RPAlignmentCorrectionsData*>::iterator sit = accumulator.begin(); sit != accumulator.end(); ++sit)
144  result[tvi].AddCorrections(*(*sit));
145  }
146 
147  return result;
148 }
dbl * delta
Definition: mlp_gen.cc:36
Time sequence of alignment corrections.
Validity interval in timestamps.
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
static std::string ValueToUNIXString(const edm::TimeValue_t &v)
unsigned long long TimeValue_t
Definition: Timestamp.h:28
JetCorrectorParameters corr
Definition: classes.h:5
edm::TimeValue_t first
the boundaries (included) of the interval expressed as UNIX timestamps
Container for RP alignment corrections. The corrections are stored on two levels - RP and sensor...
static const edm::TimeValue_t EndOfTime()
void TotemRPIncludeAlignments::PrepareSequence ( const std::string &  label,
RPAlignmentCorrectionsDataSequence seq,
const std::vector< std::string > &  files 
) const
protected

builds a sequence of corrections from provided sources and runs a few checks

Definition at line 152 of file TotemRPIncludeAlignments.cc.

References mps_fire::i, Merge(), and verbosity.

Referenced by TotemRPIncludeAlignments().

153 {
154  if (verbosity)
155  printf(">> TotemRPIncludeAlignments::PrepareSequence(%s)\n", label.c_str());
156 
157  vector<RPAlignmentCorrectionsDataSequence> sequences;
158  for (unsigned int i = 0; i < files.size(); i++)
159  sequences.push_back(RPAlignmentCorrectionsDataSequence(files[i]));
160 
161  seq = Merge(sequences);
162 }
Time sequence of alignment corrections.
RPAlignmentCorrectionsDataSequence Merge(const std::vector< RPAlignmentCorrectionsDataSequence >) const
merges an array of sequences to one
std::unique_ptr< RPAlignmentCorrectionsData > TotemRPIncludeAlignments::produceMeasured ( const RPMeasuredAlignmentRecord iRecord)

Definition at line 166 of file TotemRPIncludeAlignments.cc.

References acMeasured.

Referenced by TotemRPIncludeAlignments().

167 {
168  return std::make_unique<RPAlignmentCorrectionsData>(acMeasured);
169 }
RPAlignmentCorrectionsData acMeasured
std::unique_ptr< RPAlignmentCorrectionsData > TotemRPIncludeAlignments::produceMisaligned ( const RPMisalignedAlignmentRecord iRecord)

Definition at line 180 of file TotemRPIncludeAlignments.cc.

References acMisaligned.

Referenced by TotemRPIncludeAlignments().

181 {
182  return std::make_unique<RPAlignmentCorrectionsData>(acMisaligned);
183 }
RPAlignmentCorrectionsData acMisaligned
std::unique_ptr< RPAlignmentCorrectionsData > TotemRPIncludeAlignments::produceReal ( const RPRealAlignmentRecord iRecord)

Definition at line 173 of file TotemRPIncludeAlignments.cc.

References acReal.

Referenced by TotemRPIncludeAlignments().

174 {
175  return std::make_unique<RPAlignmentCorrectionsData>(acReal);
176 }
RPAlignmentCorrectionsData acReal
void TotemRPIncludeAlignments::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey key,
const edm::IOVSyncValue iosv,
edm::ValidityInterval valInt 
)
protectedvirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 187 of file TotemRPIncludeAlignments.cc.

References acMeasured, acMisaligned, acReal, acsMeasured, acsMisaligned, acsReal, corr, DEFINE_FWK_EVENTSETUP_SOURCE, TimeValidityInterval::EndOfTime(), edm::IOVSyncValue::endOfTime(), edm::EventID::event(), edm::IOVSyncValue::eventID(), Exception, edm::ValidityInterval::first(), plotBeamSpotDB::first, edm::ValidityInterval::last(), min(), edm::eventsetup::EventSetupRecordKey::name(), NULL, edm::EventID::run(), lumiQTWidget::t, edm::IOVSyncValue::time(), edm::Timestamp::unixTime(), edm::Timestamp::value(), TimeValidityInterval::ValueToUNIXString(), and verbosity.

189 {
190  if (verbosity)
191  {
192  LogVerbatim("TotemRPIncludeAlignments")
193  << ">> TotemRPIncludeAlignments::setIntervalFor(" << key.name() << ")";
194 
195  time_t unixTime = iosv.time().unixTime();
196  char timeStr[50];
197  strftime(timeStr, 50, "%F %T", localtime(&unixTime));
198 
199  LogVerbatim("TotemRPIncludeAlignments")
200  << " run=" << iosv.eventID().run() << ", event=" << iosv.eventID().event() << ", UNIX timestamp=" << unixTime << " (" << timeStr << ")";
201  }
202 
203  // determine what sequence and corrections should be used
206 
207  if (strcmp(key.name(), "RPMeasuredAlignmentRecord") == 0)
208  {
209  seq = &acsMeasured;
210  corr = &acMeasured;
211  }
212 
213  if (strcmp(key.name(), "RPRealAlignmentRecord") == 0)
214  {
215  seq = &acsReal;
216  corr = &acReal;
217  }
218 
219  if (strcmp(key.name(), "RPMisalignedAlignmentRecord") == 0)
220  {
221  seq = &acsMisaligned;
222  corr = &acMisaligned;
223  }
224 
225  if (seq == NULL)
226  throw cms::Exception("TotemRPIncludeAlignments::setIntervalFor") << "Unknown record " << key.name();
227 
228  // find the corresponding time interval
229  bool next_exists = false;
230  TimeValue_t t = iosv.time().value(), next_start = TimeValidityInterval::EndOfTime();
231 
232  for (RPAlignmentCorrectionsDataSequence::iterator it = seq->begin(); it != seq->end(); ++it)
233  {
234  if (it->first.first <= t && it->first.last >= t)
235  {
236  valInt = ValidityInterval(IOVSyncValue(Timestamp(it->first.first)), IOVSyncValue(Timestamp(it->first.last)));
237  *corr = it->second;
238 
239  if (verbosity)
240  {
241  LogVerbatim("TotemRPIncludeAlignments")
242  << " setting validity interval [" << TimeValidityInterval::ValueToUNIXString(valInt.first().time().value())
243  << ", " << TimeValidityInterval::ValueToUNIXString(valInt.last().time().value()) << "]";
244  }
245 
246  return;
247  }
248 
249  if (t <= it->first.first)
250  {
251  next_exists = true;
252  next_start = min(next_start, it->first.first);
253  }
254  }
255 
256  // no interval found, set empty corrections
257  *corr = RPAlignmentCorrectionsData();
258 
259  if (!next_exists)
260  valInt = ValidityInterval(iosv, iosv.endOfTime());
261  else
262  valInt = ValidityInterval(iosv, IOVSyncValue(Timestamp(next_start - 1)));
263 
264  if (verbosity)
265  {
266  LogVerbatim("TotemRPIncludeAlignments")
267  << " setting validity interval [" << TimeValidityInterval::ValueToUNIXString(valInt.first().time().value())
268  << ", " << TimeValidityInterval::ValueToUNIXString(valInt.last().time().value()) << "]";
269  }
270 }
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
Time sequence of alignment corrections.
const EventID & eventID() const
Definition: IOVSyncValue.h:42
RPAlignmentCorrectionsData acMisaligned
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
#define NULL
Definition: scimark2.h:8
RPAlignmentCorrectionsDataSequence acsReal
RPAlignmentCorrectionsDataSequence acsMeasured
const IOVSyncValue & last() const
RPAlignmentCorrectionsData acReal
RPAlignmentCorrectionsData acMeasured
static std::string ValueToUNIXString(const edm::TimeValue_t &v)
unsigned int unixTime() const
Time in seconds since January 1, 1970.
Definition: Timestamp.h:46
T min(T a, T b)
Definition: MathUtil.h:58
RPAlignmentCorrectionsDataSequence acsMisaligned
unsigned long long TimeValue_t
Definition: Timestamp.h:28
JetCorrectorParameters corr
Definition: classes.h:5
Container for RP alignment corrections. The corrections are stored on two levels - RP and sensor...
const Timestamp & time() const
Definition: IOVSyncValue.h:44
const IOVSyncValue & first() const
static const edm::TimeValue_t EndOfTime()
TimeValue_t value() const
Definition: Timestamp.h:56

Member Data Documentation

RPAlignmentCorrectionsData TotemRPIncludeAlignments::acMeasured
protected

Definition at line 47 of file TotemRPIncludeAlignments.cc.

Referenced by produceMeasured(), and setIntervalFor().

RPAlignmentCorrectionsData TotemRPIncludeAlignments::acMisaligned
protected

Definition at line 47 of file TotemRPIncludeAlignments.cc.

Referenced by produceMisaligned(), and setIntervalFor().

RPAlignmentCorrectionsData TotemRPIncludeAlignments::acReal
protected

Definition at line 47 of file TotemRPIncludeAlignments.cc.

Referenced by produceReal(), and setIntervalFor().

RPAlignmentCorrectionsDataSequence TotemRPIncludeAlignments::acsMeasured
protected

Definition at line 46 of file TotemRPIncludeAlignments.cc.

Referenced by setIntervalFor(), and TotemRPIncludeAlignments().

RPAlignmentCorrectionsDataSequence TotemRPIncludeAlignments::acsMisaligned
protected

Definition at line 46 of file TotemRPIncludeAlignments.cc.

Referenced by setIntervalFor(), and TotemRPIncludeAlignments().

RPAlignmentCorrectionsDataSequence TotemRPIncludeAlignments::acsReal
protected

Definition at line 46 of file TotemRPIncludeAlignments.cc.

Referenced by setIntervalFor(), and TotemRPIncludeAlignments().

unsigned int TotemRPIncludeAlignments::verbosity
protected

Definition at line 45 of file TotemRPIncludeAlignments.cc.

Referenced by Merge(), PrepareSequence(), and setIntervalFor().