CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
CTPPSIncludeAlignments Class Reference
Inheritance diagram for CTPPSIncludeAlignments:
edm::ESProducer edm::EventSetupRecordIntervalFinder edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Member Functions

 CTPPSIncludeAlignments (const edm::ParameterSet &p)
 
std::unique_ptr< RPAlignmentCorrectionsDataproduceMeasured (const RPMeasuredAlignmentRecord &)
 
std::unique_ptr< RPAlignmentCorrectionsDataproduceMisaligned (const RPMisalignedAlignmentRecord &)
 
std::unique_ptr< RPAlignmentCorrectionsDataproduceReal (const RPRealAlignmentRecord &)
 
 ~CTPPSIncludeAlignments () override
 
- 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...
 
void setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
 
- 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

Loads alignment corrections to EventSetup.

Definition at line 31 of file CTPPSIncludeAlignments.cc.

Constructor & Destructor Documentation

CTPPSIncludeAlignments::CTPPSIncludeAlignments ( const edm::ParameterSet p)

Definition at line 63 of file CTPPSIncludeAlignments.cc.

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

63  :
64  verbosity(pSet.getUntrackedParameter<unsigned int>("verbosity", 1))
65 {
66  PrepareSequence("Measured", acsMeasured, pSet.getParameter< vector<string> >("MeasuredFiles"));
67  PrepareSequence("Real", acsReal, pSet.getParameter< vector<string> >("RealFiles"));
68  PrepareSequence("Misaligned", acsMisaligned, pSet.getParameter< vector<string> >("MisalignedFiles"));
69 
73 
74  findingRecord<RPMeasuredAlignmentRecord>();
75  findingRecord<RPRealAlignmentRecord>();
76  findingRecord<RPMisalignedAlignmentRecord>();
77 }
RPAlignmentCorrectionsDataSequence acsMeasured
RPAlignmentCorrectionsDataSequence acsMisaligned
RPAlignmentCorrectionsDataSequence acsReal
std::unique_ptr< RPAlignmentCorrectionsData > produceReal(const RPRealAlignmentRecord &)
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
std::unique_ptr< RPAlignmentCorrectionsData > produceMeasured(const RPMeasuredAlignmentRecord &)
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
std::unique_ptr< RPAlignmentCorrectionsData > produceMisaligned(const RPMisalignedAlignmentRecord &)
CTPPSIncludeAlignments::~CTPPSIncludeAlignments ( )
override

Definition at line 81 of file CTPPSIncludeAlignments.cc.

82 {
83 }

Member Function Documentation

RPAlignmentCorrectionsDataSequence CTPPSIncludeAlignments::Merge ( const std::vector< RPAlignmentCorrectionsDataSequence > &  files) const
protected

merges an array of sequences to one

Definition at line 87 of file CTPPSIncludeAlignments.cc.

References PVValHelper::add(), corr, delta, TimeValidityInterval::EndOfTime(), FrontierConditions_GlobalTag_cff::file, TimeValidityInterval::first, TimeValidityInterval::last, genParticles_cff::map, mps_fire::result, TimeValidityInterval::ValueToUNIXString(), and verbosity.

Referenced by PrepareSequence().

88 {
89  // find interval boundaries
90  map< TimeValue_t, vector< pair<bool, const RPAlignmentCorrectionsData*> > > bounds;
91 
92  for (const auto & file : files)
93  {
94  for (RPAlignmentCorrectionsDataSequence::const_iterator iit = file.begin(); iit != file.end(); ++iit)
95  {
96  const TimeValidityInterval &tvi = iit->first;
97  const RPAlignmentCorrectionsData *corr = & iit->second;
98 
99  bounds[tvi.first].emplace_back( pair<bool, const RPAlignmentCorrectionsData*>(true, corr) );
100 
101  TimeValue_t delta = (tvi.last != TimeValidityInterval::EndOfTime()) ? (1ULL << 32) : 0; // input resolution is 1s
102  bounds[tvi.last + delta].emplace_back( pair<bool, const RPAlignmentCorrectionsData*>(false, corr) );
103  }
104  }
105 
106  // build correction sums per interval
107  set<const RPAlignmentCorrectionsData*> accumulator;
109  // bool gap_found = false;
110  for (map< TimeValue_t, vector< pair<bool, const RPAlignmentCorrectionsData*> > >::const_iterator tit = bounds.begin(); tit != bounds.end(); ++tit)
111  {
112  for (const auto & cit : tit->second)
113  {
114  bool add = cit.first;
115  const RPAlignmentCorrectionsData *corr = cit.second;
116 
117  if (add)
118  accumulator.insert(corr);
119  else
120  accumulator.erase(corr);
121  }
122 
123  map< TimeValue_t, vector< pair<bool, const RPAlignmentCorrectionsData*> > >::const_iterator tit_next = tit;
124  tit_next++;
125  if (tit_next == bounds.end())
126  break;
127 
128  TimeValue_t delta = (tit_next->first != TimeValidityInterval::EndOfTime()) ? 1 : 0; // minimal step
129  TimeValidityInterval tvi(tit->first, tit_next->first - delta);
130 
131  if (verbosity)
132  {
133  printf("\tfirst=%10s, last=%10s: alignment blocks=%li\n",
136  accumulator.size()
137  );
138  }
139 
140  for (auto sit : accumulator)
141  result[tvi].addCorrections(*sit);
142  }
143 
144  return result;
145 }
dbl * delta
Definition: mlp_gen.cc:36
Time sequence of alignment corrections.
Validity interval in timestamps.
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
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
Container for RP alignment corrections. The corrections are stored on two levels - RP and sensor...
static const edm::TimeValue_t EndOfTime()
void CTPPSIncludeAlignments::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 149 of file CTPPSIncludeAlignments.cc.

References FrontierConditions_GlobalTag_cff::file, Merge(), and verbosity.

Referenced by CTPPSIncludeAlignments().

150 {
151  if (verbosity)
152  printf(">> CTPPSIncludeAlignments::PrepareSequence(%s)\n", label.c_str());
153 
154  vector<RPAlignmentCorrectionsDataSequence> sequences;
155  for (const auto & file : files)
156  sequences.emplace_back(RPAlignmentCorrectionsDataSequence(file));
157 
158  seq = Merge(sequences);
159 }
RPAlignmentCorrectionsDataSequence Merge(const std::vector< RPAlignmentCorrectionsDataSequence > &) const
merges an array of sequences to one
Time sequence of alignment corrections.
std::unique_ptr< RPAlignmentCorrectionsData > CTPPSIncludeAlignments::produceMeasured ( const RPMeasuredAlignmentRecord iRecord)

Definition at line 163 of file CTPPSIncludeAlignments.cc.

References acMeasured.

Referenced by CTPPSIncludeAlignments().

164 {
165  return std::make_unique<RPAlignmentCorrectionsData>(acMeasured);
166 }
RPAlignmentCorrectionsData acMeasured
std::unique_ptr< RPAlignmentCorrectionsData > CTPPSIncludeAlignments::produceMisaligned ( const RPMisalignedAlignmentRecord iRecord)

Definition at line 177 of file CTPPSIncludeAlignments.cc.

References acMisaligned.

Referenced by CTPPSIncludeAlignments().

178 {
179  return std::make_unique<RPAlignmentCorrectionsData>(acMisaligned);
180 }
RPAlignmentCorrectionsData acMisaligned
std::unique_ptr< RPAlignmentCorrectionsData > CTPPSIncludeAlignments::produceReal ( const RPRealAlignmentRecord iRecord)

Definition at line 170 of file CTPPSIncludeAlignments.cc.

References acReal.

Referenced by CTPPSIncludeAlignments().

171 {
172  return std::make_unique<RPAlignmentCorrectionsData>(acReal);
173 }
RPAlignmentCorrectionsData acReal
void CTPPSIncludeAlignments::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey key,
const edm::IOVSyncValue iosv,
edm::ValidityInterval valInt 
)
overrideprotectedvirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 184 of file CTPPSIncludeAlignments.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(), edm::ValidityInterval::last(), min(), edm::eventsetup::EventSetupRecordKey::name(), edm::EventID::run(), lumiQTWidget::t, edm::IOVSyncValue::time(), edm::Timestamp::unixTime(), edm::Timestamp::value(), TimeValidityInterval::ValueToUNIXString(), and verbosity.

186 {
187  if (verbosity)
188  {
189  LogVerbatim("CTPPSIncludeAlignments")
190  << ">> CTPPSIncludeAlignments::setIntervalFor(" << key.name() << ")";
191 
192  time_t unixTime = iosv.time().unixTime();
193  char timeStr[50];
194  strftime(timeStr, 50, "%F %T", localtime(&unixTime));
195 
196  LogVerbatim("CTPPSIncludeAlignments")
197  << " run=" << iosv.eventID().run() << ", event=" << iosv.eventID().event() << ", UNIX timestamp=" << unixTime << " (" << timeStr << ")";
198  }
199 
200  // determine what sequence and corrections should be used
201  RPAlignmentCorrectionsDataSequence *seq = nullptr;
202  RPAlignmentCorrectionsData *corr = nullptr;
203 
204  if (strcmp(key.name(), "RPMeasuredAlignmentRecord") == 0)
205  {
206  seq = &acsMeasured;
207  corr = &acMeasured;
208  }
209 
210  if (strcmp(key.name(), "RPRealAlignmentRecord") == 0)
211  {
212  seq = &acsReal;
213  corr = &acReal;
214  }
215 
216  if (strcmp(key.name(), "RPMisalignedAlignmentRecord") == 0)
217  {
218  seq = &acsMisaligned;
219  corr = &acMisaligned;
220  }
221 
222  if (seq == nullptr)
223  throw cms::Exception("CTPPSIncludeAlignments::setIntervalFor") << "Unknown record " << key.name();
224 
225  // find the corresponding time interval
226  bool next_exists = false;
227  TimeValue_t t = iosv.time().value(), next_start = TimeValidityInterval::EndOfTime();
228 
229  for (auto & it : *seq)
230  {
231  if (it.first.first <= t && it.first.last >= t)
232  {
233  valInt = ValidityInterval(IOVSyncValue(Timestamp(it.first.first)), IOVSyncValue(Timestamp(it.first.last)));
234  *corr = it.second;
235 
236  if (verbosity)
237  {
238  LogVerbatim("CTPPSIncludeAlignments")
239  << " setting validity interval [" << TimeValidityInterval::ValueToUNIXString(valInt.first().time().value())
240  << ", " << TimeValidityInterval::ValueToUNIXString(valInt.last().time().value()) << "]";
241  }
242 
243  return;
244  }
245 
246  if (t <= it.first.first)
247  {
248  next_exists = true;
249  next_start = min(next_start, it.first.first);
250  }
251  }
252 
253  // no interval found, set empty corrections
254  *corr = RPAlignmentCorrectionsData();
255 
256  if (!next_exists)
257  valInt = ValidityInterval(iosv, iosv.endOfTime());
258  else
259  valInt = ValidityInterval(iosv, IOVSyncValue(Timestamp(next_start - 1)));
260 
261  if (verbosity)
262  {
263  LogVerbatim("CTPPSIncludeAlignments")
264  << " setting validity interval [" << TimeValidityInterval::ValueToUNIXString(valInt.first().time().value())
265  << ", " << TimeValidityInterval::ValueToUNIXString(valInt.last().time().value()) << "]";
266  }
267 }
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
RPAlignmentCorrectionsDataSequence acsMeasured
Time sequence of alignment corrections.
RPAlignmentCorrectionsDataSequence acsMisaligned
const EventID & eventID() const
Definition: IOVSyncValue.h:42
RPAlignmentCorrectionsData acMisaligned
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
RPAlignmentCorrectionsDataSequence acsReal
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
const IOVSyncValue & last() const
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
unsigned long long TimeValue_t
Definition: Timestamp.h:28
JetCorrectorParameters corr
Definition: classes.h:5
RPAlignmentCorrectionsData acReal
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 CTPPSIncludeAlignments::acMeasured
protected

Definition at line 44 of file CTPPSIncludeAlignments.cc.

Referenced by produceMeasured(), and setIntervalFor().

RPAlignmentCorrectionsData CTPPSIncludeAlignments::acMisaligned
protected

Definition at line 44 of file CTPPSIncludeAlignments.cc.

Referenced by produceMisaligned(), and setIntervalFor().

RPAlignmentCorrectionsData CTPPSIncludeAlignments::acReal
protected

Definition at line 44 of file CTPPSIncludeAlignments.cc.

Referenced by produceReal(), and setIntervalFor().

RPAlignmentCorrectionsDataSequence CTPPSIncludeAlignments::acsMeasured
protected

Definition at line 43 of file CTPPSIncludeAlignments.cc.

Referenced by CTPPSIncludeAlignments(), and setIntervalFor().

RPAlignmentCorrectionsDataSequence CTPPSIncludeAlignments::acsMisaligned
protected

Definition at line 43 of file CTPPSIncludeAlignments.cc.

Referenced by CTPPSIncludeAlignments(), and setIntervalFor().

RPAlignmentCorrectionsDataSequence CTPPSIncludeAlignments::acsReal
protected

Definition at line 43 of file CTPPSIncludeAlignments.cc.

Referenced by CTPPSIncludeAlignments(), and setIntervalFor().

unsigned int CTPPSIncludeAlignments::verbosity
protected

Definition at line 42 of file CTPPSIncludeAlignments.cc.

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