CMS 3D CMS Logo

ThingsTSelector2.cc
Go to the documentation of this file.
2 #include <TCanvas.h>
3 #include <iostream>
4 #include "Rtypes.h"
7 #include "DataFormats/TestObjects/interface/OtherThingCollection.h"
8 #include "DataFormats/TestObjects/interface/ThingCollection.h"
10 
11 using namespace tfwliteselectortest;
12 
13 //Names used in common between the worker and the Selector
14 static const char* kA = "a";
15 static const char* kRefA = "refA";
16 
17 ThingsWorker::ThingsWorker(const TList*, TList& out) {
18  std::cout << "begin" << std::endl;
19  h_a = new TH1F(kA, "a", 100, 0, 20);
20  out.Add(h_a);
21 
22  h_refA = new TH1F(kRefA, "refA", 100, 0, 20);
23  out.Add(h_refA);
24 }
25 
27  std::cout << "processing event " << std::endl;
28  // chain->GetEntry( entry );
29  using namespace edmtest;
31  // In case of an exception prints the message and aborts the process
32  CMS_SA_ALLOW try {
33  iEvent.getByLabel("OtherThing", "testUserTag", hOThings);
34 
35  std::cout << ">> other things found:" << hOThings->size() << std::endl;
36  for (size_t i = 0; i < hOThings->size(); ++i) {
37  const OtherThing& thing = (*hOThings)[i];
38  h_refA->Fill(thing.ref->a);
39  std::cout << ">> ref->a: " << thing.ref->a << std::endl;
40  }
41 
43  iEvent.getByLabel("Thing", hThings);
44  const ThingCollection& things = *hThings;
45  std::cout << ">> things found:" << things.size() << std::endl;
46  for (size_t i = 0; i < things.size(); ++i) {
47  const Thing& thing = things[i];
48  h_a->Fill(thing.a);
49  std::cout << ">> a: " << thing.a << std::endl;
50  }
51  } catch (cms::Exception& x) {
52  std::cout << std::endl << "Failed with cms::Exception: " << std::endl;
53  std::cout << x.what() << std::endl;
54  abort();
55  } catch (std::exception& x) {
56  std::cout << std::endl << "Failed with std::exception" << std::endl;
57  std::cout << x.what() << std::endl;
58  abort();
59  } catch (...) {
60  std::cout << std::endl << "Failed with unknown exception" << std::endl;
61  abort();
62  }
63 }
64 
66 
67 void ThingsTSelector2::begin(TList*&) {}
68 
70  std::cout << "terminate" << std::endl;
71  TCanvas* canvas = new TCanvas();
72  {
73  TObject* hist = out.FindObject(kA);
74  if (nullptr != hist) {
75  hist->Draw();
76  canvas->SaveAs("a.jpg");
77  } else {
78  std::cout << "no '" << kA << "' histogram" << std::endl;
79  }
80  }
81  std::cout << "refA" << std::endl;
82  {
83  TObject* hist = out.FindObject(kRefA);
84  if (nullptr != hist) {
85  hist->Draw();
86  canvas->SaveAs("refA.jpg");
87  } else {
88  std::cout << "no '" << kRefA << "' histogram" << std::endl;
89  }
90  }
91  delete canvas;
92 }
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
kRefA
static const char * kRefA
Definition: ThingsTSelector2.cc:15
Handle.h
tfwliteselectortest::ThingsWorker::h_a
edm::propagate_const< TH1F * > h_a
Definition: ThingsTSelector2.h:19
mps_fire.i
i
Definition: mps_fire.py:428
edmtest
Definition: AlignPCLThresholdsReader.cc:11
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ThingsTSelector2.h
tfwliteselectortest::ThingsWorker::process
void process(const edm::Event &iEvent)
Definition: ThingsTSelector2.cc:26
edm::Handle
Definition: AssociativeIterator.h:50
CMS_SA_ALLOW
#define CMS_SA_ALLOW
Definition: thread_safety_macros.h:5
dqmdumpme.things
things
Definition: dqmdumpme.py:19
tfwliteselectortest::ThingsWorker::postProcess
void postProcess(TList &)
Definition: ThingsTSelector2.cc:65
tfwliteselectortest::ThingsWorker::h_refA
edm::propagate_const< TH1F * > h_refA
Definition: ThingsTSelector2.h:20
tfwliteselectortest::ThingsTSelector2::begin
void begin(TList *&) override
Definition: ThingsTSelector2.cc:67
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
Event.h
gpuVertexFinder::hist
__shared__ Hist hist
Definition: gpuClusterTracksDBSCAN.h:48
thread_safety_macros.h
iEvent
int iEvent
Definition: GenABIO.cc:224
tfwliteselectortest::ThingsTSelector2::terminate
void terminate(TList &) override
Definition: ThingsTSelector2.cc:69
tfwliteselectortest
Definition: ThingsTSelector.h:15
kA
static const char * kA
Definition: ThingsTSelector2.cc:14
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
cms::Exception
Definition: Exception.h:70
edm::Event
Definition: Event.h:73
tfwliteselectortest::ThingsWorker::ThingsWorker
ThingsWorker(const TList *, TList &)
Definition: ThingsTSelector2.cc:17