72 MonitorElement* createElement(DQMStore& iStore,
const char* iName, TH1F* iHist) {
74 return iStore.
book1D(iName, iHist);
77 void mergeTogether(TH1* iOriginal, TH1* iToAdd) {
78 if (iOriginal->CanExtendAllAxes() && iToAdd->CanExtendAllAxes()) {
81 if (-1 == iOriginal->Merge(&list)) {
82 edm::LogError(
"MergeFailure") <<
"Failed to merge DQM element " << iOriginal->GetName();
85 if (iOriginal->GetNbinsX() == iToAdd->GetNbinsX() &&
86 iOriginal->GetXaxis()->GetXmin() == iToAdd->GetXaxis()->GetXmin() &&
87 iOriginal->GetXaxis()->GetXmax() == iToAdd->GetXaxis()->GetXmax() &&
88 iOriginal->GetNbinsY() == iToAdd->GetNbinsY() &&
89 iOriginal->GetYaxis()->GetXmin() == iToAdd->GetYaxis()->GetXmin() &&
90 iOriginal->GetYaxis()->GetXmax() == iToAdd->GetYaxis()->GetXmax() &&
91 iOriginal->GetNbinsZ() == iToAdd->GetNbinsZ() &&
92 iOriginal->GetZaxis()->GetXmin() == iToAdd->GetZaxis()->GetXmin() &&
93 iOriginal->GetZaxis()->GetXmax() == iToAdd->GetZaxis()->GetXmax() &&
97 iOriginal->Add(iToAdd);
99 edm::LogError(
"MergeFailure") <<
"Found histograms with different axis limits or different labels'" 100 << iOriginal->GetName() <<
"' not merged.";
105 void mergeWithElement(MonitorElement* iElement, TH1F* iHist) {
107 mergeTogether(iElement->
getTH1F(), iHist);
109 MonitorElement* createElement(DQMStore& iStore,
const char* iName, TH1S* iHist) {
110 return iStore.book1S(iName, iHist);
112 void mergeWithElement(MonitorElement* iElement, TH1S* iHist) { mergeTogether(iElement->
getTH1S(), iHist); }
113 MonitorElement* createElement(DQMStore& iStore,
const char* iName, TH1D* iHist) {
114 return iStore.book1DD(iName, iHist);
116 void mergeWithElement(MonitorElement* iElement, TH1D* iHist) { mergeTogether(iElement->
getTH1D(), iHist); }
117 MonitorElement* createElement(DQMStore& iStore,
const char* iName, TH2F* iHist) {
118 return iStore.book2D(iName, iHist);
120 void mergeWithElement(MonitorElement* iElement, TH2F* iHist) { mergeTogether(iElement->
getTH2F(), iHist); }
121 MonitorElement* createElement(DQMStore& iStore,
const char* iName, TH2S* iHist) {
122 return iStore.book2S(iName, iHist);
124 void mergeWithElement(MonitorElement* iElement, TH2S* iHist) { mergeTogether(iElement->
getTH2S(), iHist); }
125 MonitorElement* createElement(DQMStore& iStore,
const char* iName, TH2D* iHist) {
126 return iStore.book2DD(iName, iHist);
128 void mergeWithElement(MonitorElement* iElement, TH2D* iHist) { mergeTogether(iElement->
getTH2D(), iHist); }
129 MonitorElement* createElement(DQMStore& iStore,
const char* iName, TH3F* iHist) {
130 return iStore.book3D(iName, iHist);
132 void mergeWithElement(MonitorElement* iElement, TH3F* iHist) { mergeTogether(iElement->
getTH3F(), iHist); }
133 MonitorElement* createElement(DQMStore& iStore,
const char* iName, TProfile* iHist) {
134 return iStore.bookProfile(iName, iHist);
136 void mergeWithElement(MonitorElement* iElement, TProfile* iHist) { mergeTogether(iElement->
getTProfile(), iHist); }
137 MonitorElement* createElement(DQMStore& iStore,
const char* iName, TProfile2D* iHist) {
138 return iStore.bookProfile2D(iName, iHist);
140 void mergeWithElement(MonitorElement* iElement, TProfile2D* iHist) {
144 MonitorElement* createElement(DQMStore& iStore,
const char* iName, Long64_t& iValue) {
145 MonitorElement*
e = iStore.bookInt(iName);
151 void mergeWithElement(MonitorElement* iElement, Long64_t& iValue) {
153 if (name.find(
"EventInfo/processedEvents") != std::string::npos) {
155 }
else if (name.find(
"EventInfo/iEvent") != std::string::npos ||
156 name.find(
"EventInfo/iLumiSection") != std::string::npos) {
158 iElement->
Fill(iValue);
161 iElement->
Fill(iValue);
165 MonitorElement* createElement(DQMStore& iStore,
const char* iName,
double& iValue) {
166 MonitorElement* e = iStore.bookFloat(iName);
170 void mergeWithElement(MonitorElement* iElement,
double& iValue) {
172 iElement->
Fill(iValue);
174 MonitorElement* createElement(DQMStore& iStore,
const char* iName,
std::string* iValue) {
175 return iStore.bookString(iName, *iValue);
177 void mergeWithElement(MonitorElement* iElement,
std::string* iValue) {
179 iElement->
Fill(*iValue);
184 size_t index = oPath.find_last_of(
'/');
185 if (index == std::string::npos) {
187 oName = iFullName.c_str();
190 oName = iFullName.c_str() + index + 1;
194 struct RunLumiToRange {
195 unsigned int m_run, m_lumi, m_historyIDIndex;
196 ULong64_t m_beginTime;
198 ULong64_t m_firstIndex, m_lastIndex;
202 class TreeReaderBase {
205 virtual ~TreeReaderBase() {}
207 MonitorElement*
read(ULong64_t iIndex, DQMStore& iStore,
bool iIsLumi) {
return doRead(iIndex, iStore, iIsLumi); }
208 virtual void setTree(TTree* iTree) = 0;
214 virtual MonitorElement* doRead(ULong64_t iIndex, DQMStore& iStore,
bool iIsLumi) = 0;
218 class TreeObjectReader :
public TreeReaderBase {
221 MonitorElement* doRead(ULong64_t iIndex, DQMStore& iStore,
bool iIsLumi)
override {
222 m_tree->GetEntry(iIndex);
223 MonitorElement* element = iStore.get(*m_fullName);
225 if (
nullptr == element) {
228 splitName(*m_fullName, path, name);
229 iStore.setCurrentFolder(path);
230 element = createElement(iStore, name, m_buffer);
235 mergeWithElement(element, m_buffer);
243 void setTree(TTree* iTree)
override {
258 class TreeSimpleReader :
public TreeReaderBase {
260 TreeSimpleReader() : m_tree(
nullptr), m_fullName(
nullptr), m_buffer(0), m_tag(0) {}
261 MonitorElement* doRead(ULong64_t iIndex, DQMStore& iStore,
bool iIsLumi)
override {
262 m_tree->GetEntry(iIndex);
263 MonitorElement* element = iStore.get(*m_fullName);
264 if (
nullptr == element) {
267 splitName(*m_fullName, path, name);
268 iStore.setCurrentFolder(path);
269 element = createElement(iStore, name, m_buffer);
274 mergeWithElement(element, m_buffer);
278 void setTree(TTree* iTree)
override {
313 unsigned int run()
const {
return run_; }
316 return run_ < right.
run();
329 : processHistoryID_(phid), run_(run), lumi_(lumi) {}
331 unsigned int run()
const {
return run_; }
332 unsigned int lumi()
const {
return lumi_; }
335 if (run_ == right.
run()) {
336 return lumi_ < right.
lumi();
338 return run_ < right.
run();
351 std::shared_ptr<edm::RunAuxiliary> readRunAuxiliary_()
override;
352 std::shared_ptr<edm::LuminosityBlockAuxiliary> readLuminosityBlockAuxiliary_()
override;
357 std::unique_ptr<edm::FileBlock> readFile_()
override;
358 void closeFile_()
override;
362 void readNextItemType();
363 bool setupFile(
unsigned int iIndex);
415 desc.
addUntracked<std::vector<std::string> >(
"fileNames")->setComment(
"Names of files to be processed.");
416 desc.
addUntracked<
unsigned int>(
"filterOnRun", 0)->setComment(
"Just limit the process to the selected run.");
417 desc.
addUntracked<
bool>(
"skipBadFiles",
false)->setComment(
"Skip the file if it is not valid");
419 ->setComment(
"An alternate file catalog to use instead of the standard site one.");
420 std::vector<edm::LuminosityBlockRange> defaultLumis;
421 desc.
addUntracked<std::vector<edm::LuminosityBlockRange> >(
"lumisToProcess", defaultLumis)
422 ->setComment(
"Skip any lumi inside the specified run:lumi range.");
431 m_catalog(iPSet.getUntrackedParameter<
std::vector<
std::
string> >(
"fileNames"),
432 iPSet.getUntrackedParameter<
std::
string>(
"overrideCatalog")),
436 m_treeReaders(
kNIndicies,
std::shared_ptr<TreeReaderBase>()),
437 m_lastSeenReducedPHID(),
439 m_lastSeenReducedPHID2(),
442 m_filterOnRun(iPSet.getUntrackedParameter<unsigned
int>(
"filterOnRun", 0)),
443 m_skipBadFiles(iPSet.getUntrackedParameter<
bool>(
"skipBadFiles",
false)),
446 m_justOpenedFileSoNeedToGenerateRunTransition(
false),
447 m_shouldReadMEs(
true) {
449 for (std::vector<edm::LuminosityBlockRange>::const_iterator itr =
m_lumisToProcess.begin();
517 assert(
m_historyIDs.size() > runLumiRange.m_historyIDIndex);
520 return std::make_shared<edm::RunAuxiliary>(
m_runAux);
530 assert(
m_historyIDs.size() > runLumiRange.m_historyIDIndex);
534 return std::make_shared<edm::LuminosityBlockAuxiliary>(
m_lumiAux);
542 unsigned int runID = rpCache.
id().
run();
543 assert(runID == runLumiRange.m_run);
563 std::vector<MonitorElement*> allMEs = (*store).getAllContents(
"");
564 for (
auto const&
ME : allMEs) {
565 if (!(*store).isCollate())
576 if (runLumiRange.m_lumi == 0) {
589 assert(runLumiRange.m_run == lbCache.
id().
run());
597 std::vector<MonitorElement*> allMEs = (*store).getAllContents(
"");
623 if (
m_file.get() ==
nullptr) {
641 m_file->GetUUID().AsString(),
642 std::vector<std::string>());
648 if (
m_file.get() ==
nullptr) {
658 bool shouldContinue =
false;
660 shouldContinue =
false;
668 ULong64_t index = runLumiRange.m_firstIndex;
669 ULong64_t endIndex = runLumiRange.m_lastIndex + 1;
670 for (; index != endIndex; ++
index) {
671 bool isLumi = runLumiRange.m_lumi != 0;
673 reader->read(index, *store, isLumi);
685 (nextRunLumiRange.m_run == runLumiRange.m_run) && (nextRunLumiRange.m_lumi == runLumiRange.m_lumi)) {
686 shouldContinue =
true;
687 runLumiRange = nextRunLumiRange;
690 }
while (shouldContinue);
708 runLumiRange.m_run = 0;
711 bool shouldContinue =
false;
713 shouldContinue =
false;
731 (nextRunLumiRange.m_run == runLumiRange.m_run) && (nextRunLumiRange.m_lumi == runLumiRange.m_lumi)) {
732 shouldContinue =
true;
736 }
while (shouldContinue);
749 if (
m_file.get() !=
nullptr && iIndex > 0) {
756 bool hasFallback = !fallbackFileName.empty() && fallbackFileName !=
m_catalog.
fileNames()[iIndex];
761 std::unique_ptr<TFile> newFile;
762 std::list<std::string> originalInfo;
770 TDirectory::TContext contextEraser;
776 if (e != std::exception_ptr()) {
778 std::rethrow_exception(e);
789 <<
" was not found, could not be opened, or is corrupted.\n";
796 if (newFile && not newFile->IsZombie()) {
805 ex <<
"Input file " <<
m_catalog.
fileNames()[iIndex].c_str() <<
" could not be opened.\n";
813 if (!newFile && hasFallback) {
814 logFileAction(
" Initiating request to open fallback file ", fallbackFileName.c_str());
817 TDirectory::TContext contextEraser;
818 newFile = std::unique_ptr<TFile>(TFile::Open(fallbackFileName.c_str()));
821 if (e != std::exception_ptr()) {
823 std::rethrow_exception(e);
831 ex <<
"\nInput file " <<
m_catalog.
fileNames()[iIndex] <<
" and fallback input file " << fallbackFileName
832 <<
" were not found, could not be opened, or are corrupted.\n";
833 for (
auto const&
s : originalInfo) {
839 if (not newFile->IsZombie()) {
847 ex <<
"Input file " <<
m_catalog.
fileNames()[iIndex] <<
" and fallback input file " << fallbackFileName
848 <<
" could not be opened.\n";
850 for (
auto const&
s : originalInfo) {
859 if (0 != strcmp(newFile->GetTitle(),
"1")) {
871 if (
nullptr == metaDir) {
875 <<
" appears to be corrupted since it does not have the proper internal structure.\n" 876 " Check to see if the file was closed properly.\n";
885 assert(
nullptr != parameterSetTree);
888 assert(
nullptr != psr);
893 for (
unsigned int index = 0; index != parameterSetTree->GetEntries(); ++
index) {
894 parameterSetTree->GetEntry(index);
901 assert(
nullptr != processHistoryTree);
902 unsigned int phIndex = 0;
908 std::string* pParameterSetIDBlob = ¶meterSetIDBlob;
918 std::vector<edm::ProcessConfiguration>
configs;
922 for (
unsigned int i = 0;
i != processHistoryTree->GetEntries(); ++
i) {
923 processHistoryTree->GetEntry(
i);
925 if (not configs.empty()) {
935 configs.push_back(pc);
937 if (not configs.empty()) {
948 assert(
nullptr != indicesTree);
955 indicesTree->SetBranchAddress(
kRunBranch, &temp.m_run);
956 indicesTree->SetBranchAddress(
kLumiBranch, &temp.m_lumi);
960 indicesTree->SetBranchAddress(
kTypeBranch, &temp.m_type);
961 indicesTree->SetBranchAddress(
kFirstIndex, &temp.m_firstIndex);
962 indicesTree->SetBranchAddress(
kLastIndex, &temp.m_lastIndex);
973 typedef std::map<RunLumiPHIDKey, std::list<unsigned int>::iterator> RunLumiToLastEntryMap;
974 RunLumiToLastEntryMap runLumiToLastEntryMap;
978 typedef std::map<RunPHIDKey, std::pair<std::list<unsigned int>::iterator, std::list<unsigned int>::iterator> >
979 RunToFirstLastEntryMap;
980 RunToFirstLastEntryMap runToFirstLastEntryMap;
982 for (Long64_t index = 0; index != indicesTree->GetEntries(); ++
index) {
983 indicesTree->GetEntry(index);
996 RunLumiToLastEntryMap::iterator itFind = runLumiToLastEntryMap.find(runLumi);
997 if (itFind == runLumiToLastEntryMap.end()) {
1002 RunToFirstLastEntryMap::iterator itRunFirstLastEntryFind = runToFirstLastEntryMap.find(runKey);
1003 bool needNewEntryInRunFirstLastEntryMap =
true;
1004 if (itRunFirstLastEntryFind != runToFirstLastEntryMap.end()) {
1005 needNewEntryInRunFirstLastEntryMap =
false;
1006 if (temp.m_lumi != 0) {
1008 itLastOfRun = itRunFirstLastEntryFind->second.second;
1013 itLastOfRun = itRunFirstLastEntryFind->second.first;
1016 std::list<unsigned int>::iterator iter =
m_orderedIndices.insert(itLastOfRun, index);
1017 runLumiToLastEntryMap[runLumi] = iter;
1018 if (needNewEntryInRunFirstLastEntryMap)
1019 runToFirstLastEntryMap[runKey] = std::make_pair(iter, iter);
1021 if (temp.m_lumi != 0) {
1023 runToFirstLastEntryMap[runKey].second = iter;
1027 runToFirstLastEntryMap[runKey].first = iter;
1033 std::list<unsigned int>::iterator itNext = itFind->second;
1035 std::list<unsigned int>::iterator iter =
m_orderedIndices.insert(itNext, index);
1036 RunToFirstLastEntryMap::iterator itRunFirstLastEntryFind = runToFirstLastEntryMap.find(runKey);
1037 if (itRunFirstLastEntryFind->second.second == itFind->second) {
1039 itRunFirstLastEntryFind->second.second = iter;
1041 itFind->second = iter;
1050 assert(
nullptr !=
m_trees[index]);
edm::InputSource::ItemType m_nextItemType
unsigned int m_lastSeenRun2
virtual TH2D * getTH2D() const
unsigned int lumi() const
std::shared_ptr< edm::RunAuxiliary > readRunAuxiliary_() override
virtual TH2F * getTH2F() const
static void logFileAction(char const *msg, std::string const &fileName)
edm::JobReport::Token m_jrToken
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void closeFile_() override
void logFileAction(char const *msg, char const *fileName) const
edm::RunAuxiliary m_runAux
void reportInputRunNumber(unsigned int run)
std::vector< edm::RunNumber_t > m_runsToProcess
edm::ProcessHistoryID const & processHistoryID() const
virtual TH1F * getTH1F() const
bool registerProcessHistory(ProcessHistory const &processHistory)
static bool CheckBinLabels(const TAxis *a1, const TAxis *a2)
Check the consistency of the axis labels.
std::set< MonitorElement * > m_lumiElements
void setLumiFlag()
this ME is meant to be stored for each luminosity section
virtual int64_t getIntValue() const
std::list< unsigned int >::iterator m_presentIndexItr
unsigned int m_filterOnRun
bool operator<(RunPHIDKey const &right) const
std::set< MonitorElement * > m_runElements
void fillRunPrincipal(ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=0)
unsigned int LuminosityBlockNumber_t
std::vector< edm::ProcessHistoryID > m_reducedHistoryIDs
virtual TH1S * getTH1S() const
const std::string getFullname() const
get full name of ME including Pathname
dqm::dqmstoreimpl::DQMStore DQMStore
std::list< std::string > const & additionalInfo() const
Token inputFileOpened(std::string const &physicalFileName, std::string const &logicalFileName, std::string const &catalog, std::string const &inputType, std::string const &inputSourceClassName, std::string const &moduleLabel, std::string const &guid, std::vector< std::string > const &branchNames)
~DQMRootSource() override
edm::InputSource::ItemType getNextItemType() override
void fillLuminosityBlockPrincipal(ProcessHistoryRegistry const &processHistoryRegistry, DelayedReader *reader=0)
std::vector< RunLumiToRange > m_runlumiToRange
void addDefault(ParameterSetDescription const &psetDescription)
edm::LuminosityBlockAuxiliary m_lumiAux
std::vector< edm::ProcessHistoryID > m_historyIDs
edm::ProcessHistoryID const & processHistoryID() const
edm::ProcessHistoryID processHistoryID_
void reportInputLumiSection(unsigned int run, unsigned int lumiSectId)
bool m_justOpenedFileSoNeedToGenerateRunTransition
std::shared_ptr< edm::LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_() override
edm::InputFileCatalog m_catalog
edm::ProcessHistoryID m_lastSeenReducedPHID2
std::list< unsigned int > m_orderedIndices
void addAdditionalInfo(std::string const &info)
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
void setProcessHistoryID(ProcessHistoryID const &phid)
std::unique_ptr< edm::FileBlock > readFile_() override
virtual TProfile2D * getTProfile2D() const
std::vector< TTree * > m_trees
virtual TH2S * getTH2S() const
static void registerFromString(std::string const &rep)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
unsigned int m_lastSeenLumi2
dqm::legacy::MonitorElement MonitorElement
virtual TProfile * getTProfile() const
virtual TH1D * getTH1D() const
std::vector< std::shared_ptr< TreeReaderBase > > m_treeReaders
std::vector< edm::LuminosityBlockRange > m_lumisToProcess
bool operator<(RunLumiPHIDKey const &right) const
bool search_all(ForwardSequence const &s, Datum const &d)
LuminosityBlockNumber_t luminosityBlock() const
void readRun_(edm::RunPrincipal &rpCache) override
void addContext(std::string const &context)
void setException(std::exception_ptr e)
std::unique_ptr< TFile > m_file
edm::ProcessHistoryID m_lastSeenReducedPHID
bool skipIt(edm::RunNumber_t, edm::LuminosityBlockNumber_t) const
std::vector< EventRange > & sortAndRemoveOverlaps(std::vector< EventRange > &eventRange)
std::exception_ptr getException()
RunPHIDKey(edm::ProcessHistoryID const &phid, unsigned int run)
bool binary_search_all(ForwardSequence const &s, Datum const &d)
wrappers for std::binary_search
bool lessThan(EventRange const &lh, EventRange const &rh)
MonitorElement * book1D(char_string const &name, char_string const &title, int const nchX, double const lowX, double const highX)
Book 1D histogram.
RunLumiPHIDKey(edm::ProcessHistoryID const &phid, unsigned int run, unsigned int lumi)
std::list< unsigned int >::iterator m_nextIndexItr
void setProcessHistoryID(ProcessHistoryID const &phid)
DQMRootSource(edm::ParameterSet const &, const edm::InputSourceDescription &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void readEvent_(edm::EventPrincipal &) override
void readLuminosityBlock_(edm::LuminosityBlockPrincipal &lbCache) override
ProcessHistoryID id() const
std::string m_presentlyOpenFileName
unsigned int m_lastSeenRun
void inputFileClosed(InputType inputType, Token fileToken)
edm::ProcessHistoryID processHistoryID_
virtual TH3F * getTH3F() const
static Registry * instance()
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
LuminosityBlockID id() const
bool setupFile(unsigned int iIndex)