64 verbosity(pSet.getUntrackedParameter<unsigned
int>(
"verbosity", 1))
66 std::vector<std::string> realFiles;
67 for (
auto rFile: pSet.
getParameter< vector<string> >(
"RealFiles"))
77 findingRecord<RPMeasuredAlignmentRecord>();
78 findingRecord<RPRealAlignmentRecord>();
79 findingRecord<RPMisalignedAlignmentRecord>();
93 map< TimeValue_t, vector< pair<bool, const RPAlignmentCorrectionsData*> > > bounds;
95 for (
const auto &
file : files)
97 for (RPAlignmentCorrectionsDataSequence::const_iterator iit =
file.begin(); iit !=
file.end(); ++iit)
102 bounds[tvi.
first].emplace_back( pair<bool, const RPAlignmentCorrectionsData*>(
true, corr) );
105 bounds[tvi.
last +
delta].emplace_back( pair<bool, const RPAlignmentCorrectionsData*>(
false, corr) );
110 set<const RPAlignmentCorrectionsData*> accumulator;
113 for (
map<
TimeValue_t, vector< pair<bool, const RPAlignmentCorrectionsData*> > >::const_iterator tit = bounds.begin(); tit != bounds.end(); ++tit)
115 for (
const auto & cit : tit->second)
117 bool add = cit.first;
121 accumulator.insert(corr);
123 accumulator.erase(corr);
126 map< TimeValue_t, vector< pair<bool, const RPAlignmentCorrectionsData*> > >::const_iterator tit_next = tit;
128 if (tit_next == bounds.end())
136 printf(
"\tfirst=%10s, last=%10s: alignment blocks=%li\n",
143 for (
auto sit : accumulator)
144 result[tvi].addCorrections(*sit);
155 printf(
">> CTPPSIncludeAlignments::PrepareSequence(%s)\n", label.c_str());
157 vector<RPAlignmentCorrectionsDataSequence> sequences;
158 for (
const auto &
file : files)
161 seq =
Merge(sequences);
168 return std::make_unique<RPAlignmentCorrectionsData>(
acMeasured);
175 return std::make_unique<RPAlignmentCorrectionsData>(
acReal);
182 return std::make_unique<RPAlignmentCorrectionsData>(
acMisaligned);
193 <<
">> CTPPSIncludeAlignments::setIntervalFor(" << key.
name() <<
")";
197 strftime(timeStr, 50,
"%F %T", localtime(&unixTime));
200 <<
" run=" << iosv.
eventID().
run() <<
", event=" << iosv.
eventID().
event() <<
", UNIX timestamp=" << unixTime <<
" (" << timeStr <<
")";
207 if (strcmp(key.
name(),
"RPMeasuredAlignmentRecord") == 0)
213 if (strcmp(key.
name(),
"RPRealAlignmentRecord") == 0)
219 if (strcmp(key.
name(),
"RPMisalignedAlignmentRecord") == 0)
226 throw cms::Exception(
"CTPPSIncludeAlignments::setIntervalFor") <<
"Unknown record " << key.
name();
229 bool next_exists =
false;
232 for (
auto & it : *seq)
234 if (it.first.first <= t && it.first.last >= t)
249 if (t <= it.first.first)
252 next_start =
min(next_start, it.first.first);
T getParameter(std::string const &) const
EventNumber_t event() const
RPAlignmentCorrectionsDataSequence Merge(const std::vector< RPAlignmentCorrectionsDataSequence > &) const
merges an array of sequences to one
RPAlignmentCorrectionsDataSequence acsMeasured
Time sequence of alignment corrections.
RPAlignmentCorrectionsDataSequence acsMisaligned
const EventID & eventID() const
Validity interval in timestamps.
RPAlignmentCorrectionsData acMisaligned
static const IOVSyncValue & endOfTime()
RPAlignmentCorrectionsDataSequence acsReal
std::pair< Time_t, Time_t > ValidityInterval
std::unique_ptr< RPAlignmentCorrectionsData > produceReal(const RPRealAlignmentRecord &)
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
const IOVSyncValue & last() const
~CTPPSIncludeAlignments() override
std::unique_ptr< RPAlignmentCorrectionsData > produceMeasured(const RPMeasuredAlignmentRecord &)
RPAlignmentCorrectionsData acMeasured
const char * name() const
CTPPSIncludeAlignments(const edm::ParameterSet &p)
static std::string ValueToUNIXString(const edm::TimeValue_t &v)
unsigned int unixTime() const
Time in seconds since January 1, 1970.
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
unsigned long long TimeValue_t
RPAlignmentCorrectionsData acReal
edm::TimeValue_t first
the boundaries (included) of the interval expressed as UNIX timestamps
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
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...
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
const Timestamp & time() const
const IOVSyncValue & first() const
static const edm::TimeValue_t EndOfTime()
TimeValue_t value() const
std::unique_ptr< RPAlignmentCorrectionsData > produceMisaligned(const RPMisalignedAlignmentRecord &)