CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MEtoEDMFormat.h
Go to the documentation of this file.
1 #ifndef MEtoEDMFormat_h
2 #define MEtoEDMFormat_h
3 
14 #include <TObject.h>
15 #include <TH1F.h>
16 #include <TH1S.h>
17 #include <TH1D.h>
18 #include <TH2F.h>
19 #include <TH2S.h>
20 #include <TH2D.h>
21 #include <TH3F.h>
22 #include <TProfile.h>
23 #include <TProfile2D.h>
24 #include <TObjString.h>
25 #include <TString.h>
26 #include <TList.h>
27 
28 #include <string>
29 #include <vector>
30 #include <memory>
31 #include <map>
32 #include <stdint.h>
33 
34 #define debug 0
35 
36 template <class T>
37 class MEtoEDM
38 {
39  public:
40  MEtoEDM() {}
41  explicit MEtoEDM(size_t reservedSize) {
42  MEtoEdmObject.reserve(reservedSize);
43  }
44  virtual ~MEtoEDM() {}
45 
46  typedef std::vector<uint32_t> TagList;
47 
49  {
53  };
54 
55  typedef std::vector<MEtoEDMObject> MEtoEdmObjectVector;
56 
58  const TagList &tags,
59  const T &object)
60  {
62  MEtoEdmObject.push_back(temp);
63  MEtoEdmObject.back().name = name;
64  MEtoEdmObject.back().tags = tags;
65  MEtoEdmObject.back().object = object;
66  }
67 
69  { return MEtoEdmObject; }
70 
71  bool mergeProduct(const MEtoEDM<T> &newMEtoEDM) {
72  const MEtoEdmObjectVector &newMEtoEDMObject = newMEtoEDM.getMEtoEdmObject();
73  const size_t nObjects = newMEtoEDMObject.size();
74  // NOTE: we remember the present size since we will only add content
75  // from newMEtoEDMObject after this point
76  const size_t nOldObjects = MEtoEdmObject.size();
77 
78  // if the old and new are not the same size, we want to report a problem
79  if (nObjects != nOldObjects) {
80  std::cout << "WARNING MEtoEDM::mergeProducts(): the lists of histograms to be merged have different sizes: new=" << nObjects << ", old=" << nOldObjects << std::endl;
81  }
82 
83  for (unsigned int i = 0; i < nObjects; ++i) {
84  unsigned int j = 0;
85  // see if the name is already in the old container up to the point where
86  // we may have added new entries in the container
87  const std::string& name = newMEtoEDMObject[i].name;
88  if (i < nOldObjects && (MEtoEdmObject[i].name == name)) {
89  j = i;
90  } else {
91  j = 0;
92  while (j < nOldObjects && (MEtoEdmObject[j].name != name) ) ++j;
93  }
94  if (j >= nOldObjects) {
95  // this value is only in the new container, not the old one
96 #if debug
97  std::cout << "WARNING MEtoEDM::mergeProducts(): adding new histogram '" << name << "'" << std::endl;
98 #endif
99  MEtoEdmObject.push_back(newMEtoEDMObject[i]);
100  } else if (MEtoEdmObject[j].object.TestBit(TH1::kCanRebin) == true && newMEtoEDMObject[i].object.TestBit(TH1::kCanRebin) == true) {
101  TList list;
102  list.Add((TObject*)&newMEtoEDMObject[i].object);
103  if (MEtoEdmObject[j].object.Merge(&list) == -1) {
104  std::cout << "ERROR MEtoEDM::mergeProducts(): merge failed for '" << name << "'" << std::endl;
105  }
106  } else {
107  // this value is also in the new container: add the two
108  if (MEtoEdmObject[j].object.GetNbinsX() == newMEtoEDMObject[i].object.GetNbinsX() &&
109  MEtoEdmObject[j].object.GetXaxis()->GetXmin() == newMEtoEDMObject[i].object.GetXaxis()->GetXmin() &&
110  MEtoEdmObject[j].object.GetXaxis()->GetXmax() == newMEtoEDMObject[i].object.GetXaxis()->GetXmax() &&
111  MEtoEdmObject[j].object.GetNbinsY() == newMEtoEDMObject[i].object.GetNbinsY() &&
112  MEtoEdmObject[j].object.GetYaxis()->GetXmin() == newMEtoEDMObject[i].object.GetYaxis()->GetXmin() &&
113  MEtoEdmObject[j].object.GetYaxis()->GetXmax() == newMEtoEDMObject[i].object.GetYaxis()->GetXmax() &&
114  MEtoEdmObject[j].object.GetNbinsZ() == newMEtoEDMObject[i].object.GetNbinsZ() &&
115  MEtoEdmObject[j].object.GetZaxis()->GetXmin() == newMEtoEDMObject[i].object.GetZaxis()->GetXmin() &&
116  MEtoEdmObject[j].object.GetZaxis()->GetXmax() == newMEtoEDMObject[i].object.GetZaxis()->GetXmax()) {
117  MEtoEdmObject[j].object.Add(&newMEtoEDMObject[i].object);
118  } else {
119  std::cout << "ERROR MEtoEDM::mergeProducts(): found histograms with different axis limits, '" << name << "' not merged" << std::endl;
120 #if debug
121  std::cout << MEtoEdmObject[j].name << " " << newMEtoEDMObject[i].name << std::endl;
122  std::cout << MEtoEdmObject[j].object.GetNbinsX() << " " << newMEtoEDMObject[i].object.GetNbinsX() << std::endl;
123  std::cout << MEtoEdmObject[j].object.GetXaxis()->GetXmin() << " " << newMEtoEDMObject[i].object.GetXaxis()->GetXmin() << std::endl;
124  std::cout << MEtoEdmObject[j].object.GetXaxis()->GetXmax() << " " << newMEtoEDMObject[i].object.GetXaxis()->GetXmax() << std::endl;
125  std::cout << MEtoEdmObject[j].object.GetNbinsY() << " " << newMEtoEDMObject[i].object.GetNbinsY() << std::endl;
126  std::cout << MEtoEdmObject[j].object.GetYaxis()->GetXmin() << " " << newMEtoEDMObject[i].object.GetYaxis()->GetXmin() << std::endl;
127  std::cout << MEtoEdmObject[j].object.GetYaxis()->GetXmax() << " " << newMEtoEDMObject[i].object.GetYaxis()->GetXmax() << std::endl;
128  std::cout << MEtoEdmObject[j].object.GetNbinsZ() << " " << newMEtoEDMObject[i].object.GetNbinsZ() << std::endl;
129  std::cout << MEtoEdmObject[j].object.GetZaxis()->GetXmin() << " " << newMEtoEDMObject[i].object.GetZaxis()->GetXmin() << std::endl;
130  std::cout << MEtoEdmObject[j].object.GetZaxis()->GetXmax() << " " << newMEtoEDMObject[i].object.GetZaxis()->GetXmax() << std::endl;
131 #endif
132  }
133  }
134  }
135  return true;
136  }
137 
138  void swap(MEtoEDM<T>& iOther) {
139  MEtoEdmObject.swap(iOther.MEtoEdmObject);
140  }
141  private:
142 
144 
145 }; // end class declaration
146 
147 template <>
148 inline bool
150 {
151  const MEtoEdmObjectVector &newMEtoEDMObject = newMEtoEDM.getMEtoEdmObject();
152  const size_t nObjects = newMEtoEDMObject.size();
153  // NOTE: we remember the present size since we will only add content
154  // from newMEtoEDMObject after this point
155  const size_t nOldObjects = MEtoEdmObject.size();
156 
157  // if the old and new are not the same size, we want to report a problem
158  if (nObjects != nOldObjects) {
159  std::cout << "WARNING MEtoEDM::mergeProducts(): the lists of histograms to be merged have different sizes: new=" << nObjects << ", old=" << nOldObjects << std::endl;
160  }
161 
162  for (unsigned int i = 0; i < nObjects; ++i) {
163  unsigned int j = 0;
164  // see if the name is already in the old container up to the point where
165  // we may have added new entries in the container
166  const std::string& name = newMEtoEDMObject[i].name;
167  if (i < nOldObjects && (MEtoEdmObject[i].name == name)) {
168  j = i;
169  } else {
170  j = 0;
171  while (j < nOldObjects && (MEtoEdmObject[j].name != name) ) ++j;
172  }
173  if (j >= nOldObjects) {
174  // this value is only in the new container, not the old one
175 #if debug
176  std::cout << "WARNING MEtoEDM::mergeProducts(): adding new histogram '" << name << "'" << std::endl;
177 #endif
178  MEtoEdmObject.push_back(newMEtoEDMObject[i]);
179  }
180  }
181  return true;
182 }
183 
184 template <>
185 inline bool
187 {
188  const MEtoEdmObjectVector &newMEtoEDMObject = newMEtoEDM.getMEtoEdmObject();
189  const size_t nObjects = newMEtoEDMObject.size();
190  // NOTE: we remember the present size since we will only add content
191  // from newMEtoEDMObject after this point
192  const size_t nOldObjects = MEtoEdmObject.size();
193 
194  // if the old and new are not the same size, we want to report a problem
195  if (nObjects != nOldObjects) {
196  std::cout << "WARNING MEtoEDM::mergeProducts(): the lists of histograms to be merged have different sizes: new=" << nObjects << ", old=" << nOldObjects << std::endl;
197  }
198 
199  for (unsigned int i = 0; i < nObjects; ++i) {
200  unsigned int j = 0;
201  // see if the name is already in the old container up to the point where
202  // we may have added new entries in the container
203  const std::string& name = newMEtoEDMObject[i].name;
204  if (i < nOldObjects && (MEtoEdmObject[i].name == name)) {
205  j = i;
206  } else {
207  j = 0;
208  while (j < nOldObjects && (MEtoEdmObject[j].name != name) ) ++j;
209  }
210  if (j >= nOldObjects) {
211  // this value is only in the new container, not the old one
212 #if debug
213  std::cout << "WARNING MEtoEDM::mergeProducts(): adding new histogram '" << name << "'" << std::endl;
214 #endif
215  MEtoEdmObject.push_back(newMEtoEDMObject[i]);
216  } else {
217  // this value is also in the new container: add the two
218  if ( MEtoEdmObject[j].name.find("EventInfo/processedEvents") != std::string::npos ) {
219  MEtoEdmObject[j].object += (newMEtoEDMObject[i].object);
220  }
221  if ( MEtoEdmObject[j].name.find("EventInfo/iEvent") != std::string::npos ||
222  MEtoEdmObject[j].name.find("EventInfo/iLumiSection") != std::string::npos) {
223  if (MEtoEdmObject[j].object < newMEtoEDMObject[i].object) {
224  MEtoEdmObject[j].object = (newMEtoEDMObject[i].object);
225  }
226  }
227  }
228  }
229  return true;
230 }
231 
232 template <>
233 inline bool
235 {
236  const MEtoEdmObjectVector &newMEtoEDMObject = newMEtoEDM.getMEtoEdmObject();
237  const size_t nObjects = newMEtoEDMObject.size();
238  // NOTE: we remember the present size since we will only add content
239  // from newMEtoEDMObject after this point
240  const size_t nOldObjects = MEtoEdmObject.size();
241 
242  // if the old and new are not the same size, we want to report a problem
243  if (nObjects != nOldObjects) {
244  std::cout << "WARNING MEtoEDM::mergeProducts(): the lists of histograms to be merged have different sizes: new=" << nObjects << ", old=" << nOldObjects << std::endl;
245  }
246 
247  for (unsigned int i = 0; i < nObjects; ++i) {
248  unsigned int j = 0;
249  // see if the name is already in the old container up to the point where
250  // we may have added new entries in the container
251  const std::string& name = newMEtoEDMObject[i].name;
252  if (i < nOldObjects && (MEtoEdmObject[i].name == name)) {
253  j = i;
254  } else {
255  j = 0;
256  while (j < nOldObjects && (MEtoEdmObject[j].name != name) ) ++j;
257  }
258  if (j >= nOldObjects) {
259  // this value is only in the new container, not the old one
260 #if debug
261  std::cout << "WARNING MEtoEDM::mergeProducts(): adding new histogram '" << name << "'" << std::endl;
262 #endif
263  MEtoEdmObject.push_back(newMEtoEDMObject[i]);
264  } else {
265  // this value is also in the new container: add the two
266  if ( MEtoEdmObject[j].name.find("EventInfo/processedEvents") != std::string::npos ) {
267  MEtoEdmObject[j].object += (newMEtoEDMObject[i].object);
268  }
269  if ( MEtoEdmObject[j].name.find("EventInfo/iEvent") != std::string::npos ||
270  MEtoEdmObject[j].name.find("EventInfo/iLumiSection") != std::string::npos) {
271  if (MEtoEdmObject[j].object < newMEtoEDMObject[i].object) {
272  MEtoEdmObject[j].object = (newMEtoEDMObject[i].object);
273  }
274  }
275  }
276  }
277  return true;
278 }
279 
280 template <>
281 inline bool
283 {
284  const MEtoEdmObjectVector &newMEtoEDMObject = newMEtoEDM.getMEtoEdmObject();
285  const size_t nObjects = newMEtoEDMObject.size();
286  // NOTE: we remember the present size since we will only add content
287  // from newMEtoEDMObject after this point
288  const size_t nOldObjects = MEtoEdmObject.size();
289 
290  // if the old and new are not the same size, we want to report a problem
291  if (nObjects != nOldObjects) {
292  std::cout << "WARNING MEtoEDM::mergeProducts(): the lists of histograms to be merged have different sizes: new=" << nObjects << ", old=" << nOldObjects << std::endl;
293  }
294 
295  for (unsigned int i = 0; i < nObjects; ++i) {
296  unsigned int j = 0;
297  // see if the name is already in the old container up to the point where
298  // we may have added new entries in the container
299  const std::string& name = newMEtoEDMObject[i].name;
300  if (i < nOldObjects && (MEtoEdmObject[i].name == name)) {
301  j = i;
302  } else {
303  j = 0;
304  while (j < nOldObjects && (MEtoEdmObject[j].name != name) ) ++j;
305  }
306  if (j >= nOldObjects) {
307  // this value is only in the new container, not the old one
308 #if debug
309  std::cout << "WARNING MEtoEDM::mergeProducts(): adding new histogram '" << name << "'" << std::endl;
310 #endif
311  MEtoEdmObject.push_back(newMEtoEDMObject[i]);
312  }
313  }
314  return true;
315 }
316 
317 #endif
int i
Definition: DBlmapReader.cc:9
void swap(MEtoEDM< T > &iOther)
virtual ~MEtoEDM()
Definition: MEtoEDMFormat.h:44
MEtoEDM(size_t reservedSize)
Definition: MEtoEDMFormat.h:41
bool mergeProduct(const MEtoEDM< T > &newMEtoEDM)
Definition: MEtoEDMFormat.h:71
int j
Definition: DBlmapReader.cc:9
Container::value_type value_type
tuple tags
Definition: o2o.py:248
const MEtoEdmObjectVector & getMEtoEdmObject() const
Definition: MEtoEDMFormat.h:68
list object
Definition: dbtoconf.py:77
tuple cout
Definition: gather_cfg.py:121
std::vector< MEtoEDMObject > MEtoEdmObjectVector
Definition: MEtoEDMFormat.h:55
std::vector< uint32_t > TagList
Definition: MEtoEDMFormat.h:46
long double T
void putMEtoEdmObject(const std::string &name, const TagList &tags, const T &object)
Definition: MEtoEDMFormat.h:57
MEtoEdmObjectVector MEtoEdmObject
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