CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

tfwliteselectortest::ThingsTSelector Class Reference

#include <ThingsTSelector.h>

Inheritance diagram for tfwliteselectortest::ThingsTSelector:
TFWLiteSelectorBasic

List of all members.

Public Member Functions

void begin (TList *&)
void postProcessing (TList &)
void preProcessing (const TList *, TList &)
void process (const edm::Event &)
void terminate (TList &)
 ThingsTSelector ()

Private Member Functions

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

Private Attributes

TH1F * h_a
 histograms
TH1F * h_refA

Detailed Description

Definition at line 16 of file ThingsTSelector.h.


Constructor & Destructor Documentation

tfwliteselectortest::ThingsTSelector::ThingsTSelector ( ) [inline]

Definition at line 18 of file ThingsTSelector.h.

: h_a(0), h_refA(0) {}
tfwliteselectortest::ThingsTSelector::ThingsTSelector ( ThingsTSelector const &  ) [private]

Member Function Documentation

void ThingsTSelector::begin ( TList *&  in) [virtual]

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 14 of file ThingsTSelector.cc.

{
}
ThingsTSelector tfwliteselectortest::ThingsTSelector::operator= ( ThingsTSelector const &  ) [private]
void ThingsTSelector::postProcessing ( TList &  out) [virtual]

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 76 of file ThingsTSelector.cc.

{
}
void ThingsTSelector::preProcessing ( const TList *  in,
TList &  out 
) [virtual]

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 18 of file ThingsTSelector.cc.

References h_a, h_refA, kA, and kRefA.

                                                             {
  if(0!=h_a) {
     out.Remove(h_a);
     delete h_a;
     h_a=0;
  }
  h_a  = new TH1F( kA , "a"  , 100,  0, 20 );
  out.Add(h_a);

  if(0!=h_refA) {
     out.Remove(h_refA);
     delete h_refA;
     h_refA=0;
  }
  h_refA  = new TH1F( kRefA , "refA"  , 100,  0, 20 );
  out.Add(h_refA);
}
void ThingsTSelector::process ( const edm::Event event) [virtual]

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 36 of file ThingsTSelector.cc.

References gather_cfg::cout, exception, edm::Event::getByLabel(), h_a, h_refA, i, cms::Exception::what(), and x.

                                                      {
  std::cout << "processing event " << std::endl;
  //  chain->GetEntry( entry );
  using namespace edmtest;
  edm::Handle<OtherThingCollection> hOThings;

  try {
    iEvent.getByLabel("OtherThing", "testUserTag", hOThings);
    std::cout << ">> other things found:" << hOThings->size() << std::endl;

    for ( size_t i = 0; i < hOThings->size(); ++i ) {
      const OtherThing & thing = (*hOThings)[ i ];
      h_refA ->Fill( thing.ref->a );
      std::cout << ">> ref->a:  " << thing.ref->a << std::endl;
    }

    edm::Handle<ThingCollection> hThings;
    iEvent.getByLabel("Thing",hThings);
    const ThingCollection& things = *hThings;
    std::cout << ">> things found:" << things.size() << std::endl;
    for ( size_t i = 0; i < things.size(); ++i ) {
      const Thing & thing = things[ i ];
      h_a ->Fill( thing.a );
      std::cout << ">> a:  " << thing.a << std::endl;
    }
  } catch (cms::Exception& x) {
    std::cout << std::endl << "Failed with cms::Exception: " << std::endl;
    std::cout << x.what() << std::endl;
    abort();
  } catch (std::exception& x) {
    std::cout << std::endl << "Failed with std::exception" << std::endl;
    std::cout << x.what() << std::endl;
    abort();
  } catch (...) {
    std::cout << std::endl << "Failed with unknown exception" << std::endl;
    abort();
  }

}
void ThingsTSelector::terminate ( TList &  out) [virtual]

Called each time the 'client' has finished processing.

Parameters:
outcontains the accumulated output of all slaves.

Implements TFWLiteSelectorBasic.

Definition at line 80 of file ThingsTSelector.cc.

References MultipleCompare::canvas, gather_cfg::cout, estimatePileup::hist, kA, and kRefA.

                                          {
  std::cout << "terminate" << std::endl;
  TCanvas * canvas = new TCanvas( );
  {
     TObject* hist = out.FindObject(kA);
     if(0 != hist) {
        hist->Draw();
        canvas->SaveAs( "a.jpg" );
     } else {
        std::cout <<"no '"<<kA<<"' histogram"<< std::endl;
     }
  }
  {
     TObject* hist = out.FindObject(kRefA);
     if(0 != hist) {
        hist->Draw();
        canvas->SaveAs( "refA.jpg" );
     } else {
        std::cout <<"no '"<<kRefA<<"' histogram"<< std::endl;
     }
  }
  delete canvas;
}

Member Data Documentation

histograms

Definition at line 27 of file ThingsTSelector.h.

Referenced by preProcessing(), and process().

Definition at line 27 of file ThingsTSelector.h.

Referenced by preProcessing(), and process().