CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DaqProvenanceHelper.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <vector>
3 
5 
16 
17 namespace edm {
19  : constBranchDescription_(BranchDescription(InEvent
20  , "rawDataCollector"
21  //, "source"
22  , "LHC"
23  // , "HLT"
24  , "FEDRawDataCollection"
25  , "FEDRawDataCollection"
26  , ""
27  , "DaqSource"
28  , ParameterSetID()
29  , TypeWithDict(rawDataType.typeInfo())
30  , false))
31  , dummyProvenance_(constBranchDescription_.branchID())
32  , processParameterSet_()
33  , oldProcessName_()
34  , oldBranchID_()
35  , newBranchID_()
36  , oldProcessHistoryID_(nullptr)
37  , phidMap_() {
38 
39  // Now we create a process parameter set for the "LHC" process.
40  // We don't currently use the untracked parameters, However, we make them available, just in case.
41  std::string const& moduleLabel = constBranchDescription_.moduleLabel();
42  std::string const& processName = constBranchDescription_.processName();
43  std::string const& moduleName = constBranchDescription_.moduleName();
44  typedef std::vector<std::string> vstring;
45  vstring empty;
46 
47  vstring modlbl;
48  modlbl.reserve(1);
49  modlbl.push_back(moduleLabel);
50  processParameterSet_.addParameter("@all_sources", modlbl);
51 
52  ParameterSet triggerPaths;
53  triggerPaths.addParameter<vstring>("@trigger_paths", empty);
54  processParameterSet_.addParameter<ParameterSet>("@trigger_paths", triggerPaths);
55 
56  ParameterSet pseudoInput;
57  pseudoInput.addParameter<std::string>("@module_edm_type", "Source");
58  pseudoInput.addParameter<std::string>("@module_label", moduleLabel);
59  pseudoInput.addParameter<std::string>("@module_type", moduleName);
60  processParameterSet_.addParameter<ParameterSet>(moduleLabel, pseudoInput);
61 
62  processParameterSet_.addParameter<vstring>("@all_esmodules", empty);
63  processParameterSet_.addParameter<vstring>("@all_esprefers", empty);
64  processParameterSet_.addParameter<vstring>("@all_essources", empty);
65  processParameterSet_.addParameter<vstring>("@all_loopers", empty);
66  processParameterSet_.addParameter<vstring>("@all_modules", empty);
67  processParameterSet_.addParameter<vstring>("@end_paths", empty);
68  processParameterSet_.addParameter<vstring>("@paths", empty);
69  processParameterSet_.addParameter<std::string>("@process_name", processName);
70  // Now we register the process parameter set.
72 
73  //std::cerr << processParameterSet_.dump() << std::endl;
74  }
75 
78  // Now we need to set all the metadata
79  // Add the product to the product registry
80  productRegistry.copyProduct(constBranchDescription_.me());
81 
82  // Insert an entry for this process in the process history registry
83  ProcessHistory ph;
85  ProcessConfiguration const& pc = ph.data().back();
87 
88  // Insert an entry for this process in the process configuration registry
90 
91  // Save the process history ID for use every event.
92  return ph.id();
93  }
94 
95  bool
97  for(auto const& pc : ph) {
98  if(pc.processName() == oldProcessName_) {
99  return(pc.releaseVersion() == newPC.releaseVersion() && pc.passID() == newPC.passID());
100  }
101  }
102  return false;
103  }
104 
105  void
106  DaqProvenanceHelper::fixMetaData(std::vector<ProcessConfiguration>& pcv, std::vector<ProcessHistory>& phv) {
107  phv.push_back(ProcessHistory()); // For new processHistory, containing only processConfiguration_
108  std::vector<ProcessConfiguration> newPCs;
109  for(auto const& pc : pcv) {
110  if(pc.processName() == oldProcessName_) {
111  newPCs.emplace_back(constBranchDescription_.processName(),
113  pc.releaseVersion(), pc.passID());
114  }
115  }
116  assert(!newPCs.empty());
117  pcv.reserve(pcv.size() + newPCs.size());
118  pcv.insert(pcv.end(), newPCs.begin(), newPCs.end());
119  // update existing process histories
120  for(auto& ph : phv) {
121  for(auto const& newPC : newPCs) {
122  if(ph.empty() || matchProcesses(newPC, ph)) {
123  ProcessHistoryID oldPHID = ph.id();
124  ph.push_front(newPC);
125  ProcessHistoryID newPHID = ph.id();
126  phidMap_.insert(std::make_pair(oldPHID, newPHID));
127  break;
128  }
129  }
130  }
131  // For new process histories, containing only the new process configurations
132  phv.reserve(phv.size() + newPCs.size());
133  for(auto const& newPC : newPCs) {
134  phv.emplace_back();
135  phv.back().push_front(newPC);
136  }
137  }
138 
139  void
140  DaqProvenanceHelper::fixMetaData(std::vector<BranchID>& branchID) const {
141  std::replace(branchID.begin(), branchID.end(), oldBranchID_, newBranchID_);
142  }
143 
144  void
145  DaqProvenanceHelper::fixMetaData(BranchIDLists const& branchIDLists) const {
148  // The const_cast is ugly, but it beats the alternatives.
149  BranchIDLists& lists = const_cast<BranchIDLists&>(branchIDLists);
150  for(auto& list : lists) {
151  std::replace(list.begin(), list.end(), oldID, newID);
152  }
153  }
154 
155  void
157  typedef std::map<BranchID, std::set<BranchID> > BCMap;
158  // The const_cast is ugly, but it beats the alternatives.
159  BCMap& childLookup = const_cast<BCMap&>(branchChildren.childLookup());
160  // First fix any old branchID's in the key.
161  {
162  BCMap::iterator i = childLookup.find(oldBranchID_);
163  if(i != childLookup.end()) {
164  childLookup.insert(std::make_pair(newBranchID_, i->second));
165  childLookup.erase(i);
166  }
167  }
168  // Now fix any old branchID's in the sets;
169  for(auto& child : childLookup) {
170  if(child.second.erase(oldBranchID_) != 0) {
171  child.second.insert(newBranchID_);
172  }
173  }
174  }
175 
176  // Replace process history ID.
177  ProcessHistoryID const&
179  ProcessHistoryIDMap::const_iterator it = phidMap_.find(phid);
180  assert(it != phidMap_.end());
181  oldProcessHistoryID_ = &it->first;
182  return it->second;
183  }
184 
185  // Replace parentage ID.
186  ParentageID const&
188  ParentageIDMap::const_iterator it = parentageIDMap_.find(parentageID);
189  if(it == parentageIDMap_.end()) {
190  return parentageID;
191  }
192  return it->second;
193  }
194 
195  // Replace branch ID if necessary.
196  BranchID const&
198  return(branchID == oldBranchID_ ? newBranchID_ : branchID);
199  }
200 }
std::string const & processName() const
std::string getPassID()
Definition: GetPassID.h:8
int i
Definition: DBlmapReader.cc:9
DaqProvenanceHelper(TypeID const &rawDataType)
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
BranchDescription const & me() const
std::vector< std::string > vstring
Definition: Schedule.cc:277
ParameterSetID id() const
static ThreadSafeRegistry * instance()
BranchID const & mapBranchID(BranchID const &branchID) const
#define nullptr
collection_type const & data() const
def replace
Definition: linker.py:10
bool insertMapped(value_type const &v)
PassID const & passID() const
unsigned int id() const
Definition: BranchID.h:23
void emplace_back(Args &&...args)
ProcessHistoryID daqInit(ProductRegistry &productRegistry) const
std::string const & moduleName() const
ProcessHistoryID const & mapProcessHistoryID(ProcessHistoryID const &phid)
ConstBranchDescription constBranchDescription_
map_t const & childLookup() const
unsigned int value_type
Definition: BranchID.h:16
ProcessHistoryIDMap phidMap_
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:145
std::string getReleaseVersion()
ReleaseVersion const & releaseVersion() const
void fixMetaData(std::vector< ProcessConfiguration > &pcv, std::vector< ProcessHistory > &phv)
ParentageID const & mapParentageID(ParentageID const &phid) const
ProcessHistoryID id() const
ParameterSet const & registerIt()
void copyProduct(BranchDescription const &productdesc)
std::string const & moduleLabel() const
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
ProcessHistoryID const * oldProcessHistoryID_
bool matchProcesses(ProcessConfiguration const &pc, ProcessHistory const &ph) const