CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
tfwliteselectortest::ThingsTSelector Class Reference

#include <ThingsTSelector.h>

Inheritance diagram for tfwliteselectortest::ThingsTSelector:
TFWLiteSelectorBasic

Public Member Functions

void begin (TList *&) override
 
void postProcessing (TList &) override
 
void preProcessing (const TList *, TList &) override
 
void process (const edm::Event &) override
 
void terminate (TList &) override
 
 ThingsTSelector ()
 
- Public Member Functions inherited from TFWLiteSelectorBasic
 TFWLiteSelectorBasic ()
 
 ~TFWLiteSelectorBasic () override
 

Private Member Functions

ThingsTSelector operator= (ThingsTSelector const &)
 
 ThingsTSelector (ThingsTSelector const &)
 

Private Attributes

edm::propagate_const< TH1F * > h_a
 histograms More...
 
edm::propagate_const< TH1F * > h_refA
 

Detailed Description

Definition at line 16 of file ThingsTSelector.h.

Constructor & Destructor Documentation

◆ ThingsTSelector() [1/2]

tfwliteselectortest::ThingsTSelector::ThingsTSelector ( )
inline

Definition at line 18 of file ThingsTSelector.h.

18 : h_a(nullptr), h_refA(nullptr) {}
edm::propagate_const< TH1F * > h_a
histograms
edm::propagate_const< TH1F * > h_refA

◆ ThingsTSelector() [2/2]

tfwliteselectortest::ThingsTSelector::ThingsTSelector ( ThingsTSelector const &  )
private

Member Function Documentation

◆ begin()

void ThingsTSelector::begin ( TList *&  in)
overridevirtual

Called each time the 'client' begins processing (remote 'slaves' do not see this message)

Parameters
inan assignable pointer to a list of objects you want passed to 'preProcessing'. This list is used to communicate with remote slaves. NOTE: you are responsible for deleting this TList and its content once you are done with it.

Implements TFWLiteSelectorBasic.

Definition at line 15 of file ThingsTSelector.cc.

15 {}

◆ operator=()

ThingsTSelector tfwliteselectortest::ThingsTSelector::operator= ( ThingsTSelector const &  )
private

◆ postProcessing()

void ThingsTSelector::postProcessing ( TList &  out)
overridevirtual

Called each time the 'slave' has seen all the events

Parameters
outthe list of objects that will be sent to 'terminate'. You can Add() additional objects to 'out' at this point as well.

Implements TFWLiteSelectorBasic.

Definition at line 74 of file ThingsTSelector.cc.

74 {}

◆ preProcessing()

void ThingsTSelector::preProcessing ( const TList *  in,
TList &  out 
)
overridevirtual

Called each time the 'slave' is about to start processing

Parameters
ina pointer to the list of objects created in 'begin()'. The pointer can be 0
outa list of objects that are the result of processing (e.g. histograms). You should call 'Add()' for each object you want sent to the 'terminate' method.

Implements TFWLiteSelectorBasic.

Definition at line 17 of file ThingsTSelector.cc.

References edm::propagate_const< T >::get(), h_a, h_refA, kA, kRefA, and MillePedeFileConverter_cfg::out.

17  {
18  if (nullptr != h_a) {
19  out.Remove(h_a);
20  delete h_a.get();
21  h_a = nullptr;
22  }
23  h_a = new TH1F(kA, "a", 100, 0, 20);
24  out.Add(h_a);
25 
26  if (nullptr != h_refA) {
27  out.Remove(h_refA);
28  delete h_refA.get();
29  h_refA = nullptr;
30  }
31  h_refA = new TH1F(kRefA, "refA", 100, 0, 20);
32  out.Add(h_refA);
33 }
static const char * kA
static const char * kRefA
constexpr element_type const * get() const
edm::propagate_const< TH1F * > h_a
histograms
edm::propagate_const< TH1F * > h_refA

◆ process()

void ThingsTSelector::process ( const edm::Event event)
overridevirtual

Call each time the 'slave' gets a new Event

Parameters
eventa standard edm::Event which works just like it does in cmsRun

Implements TFWLiteSelectorBasic.

Definition at line 35 of file ThingsTSelector.cc.

References CMS_SA_ALLOW, gather_cfg::cout, cppFunctionSkipper::exception, h_a, h_refA, mps_fire::i, iEvent, dqmdumpme::things, and x.

35  {
36  std::cout << "processing event " << std::endl;
37  // chain->GetEntry( entry );
38  using namespace edmtest;
40  // In case of an exception prints the message and aborts the process
41  CMS_SA_ALLOW try {
42  iEvent.getByLabel("OtherThing", "testUserTag", hOThings);
43  std::cout << ">> other things found:" << hOThings->size() << std::endl;
44 
45  for (size_t i = 0; i < hOThings->size(); ++i) {
46  const OtherThing& thing = (*hOThings)[i];
47  h_refA->Fill(thing.ref->a);
48  std::cout << ">> ref->a: " << thing.ref->a << std::endl;
49  }
50 
52  iEvent.getByLabel("Thing", hThings);
53  const ThingCollection& things = *hThings;
54  std::cout << ">> things found:" << things.size() << std::endl;
55  for (size_t i = 0; i < things.size(); ++i) {
56  const Thing& thing = things[i];
57  h_a->Fill(thing.a);
58  std::cout << ">> a: " << thing.a << std::endl;
59  }
60  } catch (cms::Exception& x) {
61  std::cout << std::endl << "Failed with cms::Exception: " << std::endl;
62  std::cout << x.what() << std::endl;
63  abort();
64  } catch (std::exception& x) {
65  std::cout << std::endl << "Failed with std::exception" << std::endl;
66  std::cout << x.what() << std::endl;
67  abort();
68  } catch (...) {
69  std::cout << std::endl << "Failed with unknown exception" << std::endl;
70  abort();
71  }
72 }
#define CMS_SA_ALLOW
int iEvent
Definition: GenABIO.cc:224
edm::propagate_const< TH1F * > h_a
histograms
edm::propagate_const< TH1F * > h_refA

◆ terminate()

void ThingsTSelector::terminate ( TList &  out)
overridevirtual

Called each time the 'client' has finished processing.

Parameters
outcontains the accumulated output of all slaves.

Implements TFWLiteSelectorBasic.

Definition at line 76 of file ThingsTSelector.cc.

References svgfig::canvas(), gather_cfg::cout, compareTotals::hist, kA, kRefA, and MillePedeFileConverter_cfg::out.

76  {
77  std::cout << "terminate" << std::endl;
78  TCanvas* canvas = new TCanvas();
79  {
80  TObject* hist = out.FindObject(kA);
81  if (nullptr != hist) {
82  hist->Draw();
83  canvas->SaveAs("a.jpg");
84  } else {
85  std::cout << "no '" << kA << "' histogram" << std::endl;
86  }
87  }
88  {
89  TObject* hist = out.FindObject(kRefA);
90  if (nullptr != hist) {
91  hist->Draw();
92  canvas->SaveAs("refA.jpg");
93  } else {
94  std::cout << "no '" << kRefA << "' histogram" << std::endl;
95  }
96  }
97  delete canvas;
98 }
static const char * kA
static const char * kRefA
def canvas(sub, attr)
Definition: svgfig.py:482

Member Data Documentation

◆ h_a

edm::propagate_const<TH1F*> tfwliteselectortest::ThingsTSelector::h_a
private

histograms

Definition at line 27 of file ThingsTSelector.h.

Referenced by preProcessing(), and process().

◆ h_refA

edm::propagate_const<TH1F*> tfwliteselectortest::ThingsTSelector::h_refA
private

Definition at line 28 of file ThingsTSelector.h.

Referenced by preProcessing(), and process().