92 verbosity(pSet.getUntrackedParameter<unsigned
int>(
"verbosity", 0))
94 std::vector<std::string> measuredFiles;
95 for (
const auto &
f: pSet.
getParameter< vector<string> >(
"MeasuredFiles"))
99 std::vector<std::string> realFiles;
100 for (
const auto &
f: pSet.
getParameter< vector<string> >(
"RealFiles"))
104 std::vector<std::string> misalignedFiles;
105 for (
const auto &
f: pSet.
getParameter< vector<string> >(
"MisalignedFiles"))
113 findingRecord<RPMeasuredAlignmentRecord>();
114 findingRecord<RPRealAlignmentRecord>();
115 findingRecord<RPMisalignedAlignmentRecord>();
129 map< edm::EventID, vector< pair<bool, const RPAlignmentCorrectionsData*> > > bounds;
131 for (
const auto & seq : seqs)
133 for (
const auto &
p : seq)
139 bounds[event_first].emplace_back( pair<bool, const RPAlignmentCorrectionsData*>(
true, corr) );
142 bounds[event_after].emplace_back( pair<bool, const RPAlignmentCorrectionsData*>(
false, corr) );
147 set<const RPAlignmentCorrectionsData*> accumulator;
149 for (
map<
EventID, vector< pair<bool, const RPAlignmentCorrectionsData*> > >::const_iterator tit = bounds.begin(); tit != bounds.end(); ++tit)
151 for (
const auto & cit : tit->second)
153 bool add = cit.first;
157 accumulator.insert(corr);
159 accumulator.erase(corr);
164 if (tit_next == bounds.end())
167 const EventID &event_first = tit->first;
175 <<
": alignment blocks " << accumulator.size();
179 for (
auto sit : accumulator)
193 LogVerbatim(
">> CTPPSIncludeAlignmentsFromXML") <<
"CTPPSIncludeAlignmentsFromXML::PrepareSequence(" << label <<
")";
195 vector<RPAlignmentCorrectionsDataSequence> sequences;
196 for (
const auto &
file : files)
199 seq =
Merge(sequences);
206 return std::make_unique<RPAlignmentCorrectionsData>(
acMeasured);
213 return std::make_unique<RPAlignmentCorrectionsData>(
acReal);
220 return std::make_unique<RPAlignmentCorrectionsData>(
acMisaligned);
232 strftime(timeStr, 50,
"%F %T", localtime(&unixTime));
235 <<
">> CTPPSIncludeAlignmentsFromXML::setIntervalFor(" << key.
name() <<
")";
238 <<
" event=" << iosv.
eventID() <<
", UNIX timestamp=" << unixTime <<
" (" << timeStr <<
")";
245 if (strcmp(key.
name(),
"RPMeasuredAlignmentRecord") == 0)
251 if (strcmp(key.
name(),
"RPRealAlignmentRecord") == 0)
257 if (strcmp(key.
name(),
"RPMisalignedAlignmentRecord") == 0)
263 if (p_seq ==
nullptr)
264 throw cms::Exception(
"CTPPSIncludeAlignmentsFromXML::setIntervalFor") <<
"Unknown record " << key.
name();
267 bool next_exists =
false;
271 for (
const auto &it: *p_seq)
273 const auto &it_event_first = it.first.first().eventID();
274 const auto &it_event_last = it.first.last().eventID();
276 bool it_contained_lo = ( (it_event_first.run() < event_curr.
run()) ||
277 ((it_event_first.run() == event_curr.
run()) && (it_event_first.luminosityBlock() <= event_curr.
luminosityBlock())) );
279 bool it_contained_up = ( (it_event_last.run() > event_curr.
run()) ||
280 ((it_event_last.run() == event_curr.
run()) && (it_event_last.luminosityBlock() >= event_curr.
luminosityBlock())) );
282 if (it_contained_lo && it_contained_up)
290 <<
" setting validity interval [" 298 bool it_in_future = ( (it_event_first.run() > event_curr.
run()) ||
299 ((it_event_first.run() == event_curr.
run() && (it_event_first.luminosityBlock() > event_curr.
luminosityBlock()))) );
304 if (event_next_start > it_event_first)
305 event_next_start = it_event_first;
323 <<
" setting validity interval ["
T getParameter(std::string const &) const
EventNumber_t event() const
Time sequence of alignment corrections. I/O methods have been factored out to: Geometry/VeryForwardGe...
static RunNumber_t maxRunNumber()
const EventID & eventID() const
~CTPPSIncludeAlignmentsFromXML() override
RPAlignmentCorrectionsData acMisaligned
std::unique_ptr< RPAlignmentCorrectionsData > produceMeasured(const RPMeasuredAlignmentRecord &)
static const IOVSyncValue & endOfTime()
static RPAlignmentCorrectionsDataSequence loadFromXML(const std::string &fileName)
loads sequence of alignment corrections from XML file
std::pair< Time_t, Time_t > ValidityInterval
void insert(const edm::ValidityInterval &iov, const RPAlignmentCorrectionsData &data)
LuminosityBlockNumber_t luminosityBlock() const
RPAlignmentCorrectionsDataSequence acsMisaligned
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
const IOVSyncValue & last() const
static edm::EventID previousLS(const edm::EventID &src)
RPAlignmentCorrectionsData acMeasured
static LuminosityBlockNumber_t maxLuminosityBlockNumber()
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 &)
const char * name() const
unsigned int unixTime() const
Time in seconds since January 1, 1970.
void addCorrections(const RPAlignmentCorrectionsData &, bool sumErrors=true, bool addSh=true, bool addRot=true)
adds (merges) corrections on top of the current values
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
CTPPSIncludeAlignmentsFromXML(const edm::ParameterSet &p)
Container for CTPPS RP alignment corrections. The corrections are stored on two levels - RP and senso...
RPAlignmentCorrectionsDataSequence acsReal
std::unique_ptr< RPAlignmentCorrectionsData > produceReal(const RPRealAlignmentRecord &)
RPAlignmentCorrectionsDataSequence Merge(const std::vector< RPAlignmentCorrectionsDataSequence > &) const
merges an array of sequences to one
static edm::EventID nextLS(const edm::EventID &src)
RPAlignmentCorrectionsDataSequence acsMeasured
const Timestamp & time() const
RPAlignmentCorrectionsData acReal
const IOVSyncValue & first() const
static std::string iovValueToString(const edm::IOVSyncValue &)