Logo ROOT  
Reference Guide
ProofTests.C File Reference

Detailed Description

Auxilliary selector used to test PROOF functionality.

#define ProofTests_cxx
#include "ProofTests.h"
#include <TEnv.h>
#include <TH1F.h>
#include <TH1I.h>
#include <TMath.h>
#include <TString.h>
#include <TSystem.h>
#include <TParameter.h>
//_____________________________________________________________________________
ProofTests::ProofTests()
{
// Constructor
fTestType = 0;
fStat = 0;
}
//_____________________________________________________________________________
ProofTests::~ProofTests()
{
// Destructor
}
//_____________________________________________________________________________
void ProofTests::ParseInput()
{
// This function sets some control member variables based on the input list
// content. Called by Begin and SlaveBegin.
// Determine the test type
TNamed *ntype = dynamic_cast<TNamed*>(fInput->FindObject("ProofTests_Type"));
if (ntype) {
if (!strcmp(ntype->GetTitle(), "InputData")) {
fTestType = 0;
} else if (!strcmp(ntype->GetTitle(), "PackTest1")) {
fTestType = 1;
} else if (!strcmp(ntype->GetTitle(), "PackTest2")) {
fTestType = 2;
} else {
Warning("ParseInput", "unknown type: '%s'", ntype->GetTitle());
}
}
Info("ParseInput", "test type: %d (from '%s')", fTestType, ntype ? ntype->GetTitle() : "undef");
}
//_____________________________________________________________________________
void ProofTests::Begin(TTree * /*tree*/)
{
// The Begin() function is called at the start of the query.
// When running with PROOF Begin() is only called on the client.
// The tree argument is deprecated (on PROOF 0 is passed).
}
//_____________________________________________________________________________
void ProofTests::SlaveBegin(TTree * /*tree*/)
{
// The SlaveBegin() function is called after the Begin() function.
// When running with PROOF SlaveBegin() is called on each slave server.
// The tree argument is deprecated (on PROOF 0 is passed).
TString option = GetOption();
// Fill relevant members
ParseInput();
// Output histo
fStat = new TH1I("TestStat", "Test results", 20, .5, 20.5);
fOutput->Add(fStat);
// We were started
fStat->Fill(1.);
// Depends on the test
if (fTestType == 0) {
// Retrieve objects from the input list and copy them to the output
// H1
TList *h1list = dynamic_cast<TList*>(fInput->FindObject("h1list"));
if (h1list) {
// Retrieve objects from the input list and copy them to the output
TH1F *h1 = dynamic_cast<TH1F*>(h1list->FindObject("h1data"));
if (h1) {
TParameter<Double_t> *h1avg = dynamic_cast<TParameter<Double_t>*>(h1list->FindObject("h1avg"));
TParameter<Double_t> *h1rms = dynamic_cast<TParameter<Double_t>*>(h1list->FindObject("h1rms"));
if (h1avg && h1rms) {
if (TMath::Abs(h1avg->GetVal() - h1->GetMean()) < 0.0001) {
if (TMath::Abs(h1rms->GetVal() - h1->GetRMS()) < 0.0001) {
fStat->Fill(2.);
}
}
} else {
Warning("SlaveBegin", "%d: info 'h1avg' or 'h1rms' not found!", fTestType);
}
} else {
Warning("SlaveBegin", "%d: input histo 'h1data' not found!", fTestType);
}
} else {
Warning("SlaveBegin", "%d: input list 'h1list' not found!", fTestType);
}
// H2
TList *h2list = dynamic_cast<TList*>(fInput->FindObject("h2list"));
if (h2list) {
// Retrieve objects from the input list and copy them to the output
TH1F *h2 = dynamic_cast<TH1F*>(h2list->FindObject("h2data"));
if (h2) {
TParameter<Double_t> *h2avg = dynamic_cast<TParameter<Double_t>*>(h2list->FindObject("h2avg"));
TParameter<Double_t> *h2rms = dynamic_cast<TParameter<Double_t>*>(h2list->FindObject("h2rms"));
if (h2avg && h2rms) {
if (TMath::Abs(h2avg->GetVal() - h2->GetMean()) < 0.0001) {
if (TMath::Abs(h2rms->GetVal() - h2->GetRMS()) < 0.0001) {
fStat->Fill(3.);
}
}
} else {
Warning("SlaveBegin", "%d: info 'h2avg' or 'h2rms' not found!", fTestType);
}
} else {
Warning("SlaveBegin", "%d: input histo 'h2data' not found!", fTestType);
}
} else {
Warning("SlaveBegin", "%d: input list 'h2list' not found!", fTestType);
}
TNamed *iob = dynamic_cast<TNamed*>(fInput->FindObject("InputObject"));
if (iob) {
fStat->Fill(4.);
} else {
Warning("SlaveBegin", "%d: input histo 'InputObject' not found!", fTestType);
}
} else if (fTestType == 1) {
// We should find in the input list the name of a test variable which should exist
// at this point in the gEnv table
TNamed *nm = dynamic_cast<TNamed*>(fInput->FindObject("testenv"));
if (nm) {
if (gEnv->Lookup(nm->GetTitle())) {
fStat->Fill(2.);
} else {
Warning("SlaveBegin", "%d: lookup for '%s' failed!", fTestType, nm->GetTitle());
gEnv->Print();
}
} else {
Warning("SlaveBegin", "%d: TNamed with the test env info not found!", fTestType);
}
} else if (fTestType == 2) {
// We should find in the input list the list of names of test variables which should exist
// at this point in the gEnv table
TNamed *nm = dynamic_cast<TNamed*>(fInput->FindObject("testenv"));
if (nm) {
TString nms(nm->GetTitle()), nam;
Int_t from = 0;
while (nms.Tokenize(nam, from, ",")) {
if (gEnv->Lookup(nam)) {
Double_t xx = gEnv->GetValue(nam, -1.);
if (xx > 1.) fStat->Fill(xx);
} else {
Warning("SlaveBegin", "RC-env '%s' not found!", nam.Data());
}
}
} else {
Warning("SlaveBegin", "%d: TNamed with the test env info not found!", fTestType);
}
}
}
//_____________________________________________________________________________
Bool_t ProofTests::Process(Long64_t)
{
// The Process() function is called for each entry in the tree (or possibly
// keyed object in the case of PROOF) to be processed. The entry argument
// specifies which entry in the currently loaded tree is to be processed.
// It can be passed to either ProofTests::GetEntry() or TBranch::GetEntry()
// to read either all or the required parts of the data. When processing
// keyed objects with PROOF, the object is already loaded and is available
// via the fObject pointer.
//
// This function should contain the "body" of the analysis. It can contain
// simple or elaborate selection criteria, run algorithms on the data
// of the event and typically fill histograms.
//
// The processing can be stopped by calling Abort().
//
// Use fStatus to set the return value of TTree::Process().
//
// The return value is currently not used.
return kTRUE;
}
//_____________________________________________________________________________
void ProofTests::SlaveTerminate()
{
// The SlaveTerminate() function is called after all entries or objects
// have been processed. When running with PROOF SlaveTerminate() is called
// on each slave server.
}
//_____________________________________________________________________________
void ProofTests::Terminate()
{
// The Terminate() function is the last function to be called during
// a query. It always runs on the client, it can be used to present
// the results graphically or save the results to file.
}
Auxilliary selector used to test PROOF functionality.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
long long Long64_t
Definition: RtypesCore.h:69
const Bool_t kTRUE
Definition: RtypesCore.h:87
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
void Info(const char *location, const char *msgfmt,...)
void Warning(const char *location, const char *msgfmt,...)
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:491
virtual TEnvRec * Lookup(const char *n) const
Loop over all resource records and return the one with name.
Definition: TEnv.cxx:547
virtual void Print(Option_t *option="") const
Print all resources or the global, user or local resources separately.
Definition: TEnv.cxx:556
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:571
1-D histogram with an int per channel (see TH1 documentation)}
Definition: TH1.h:530
virtual Double_t GetMean(Int_t axis=1) const
For axis = 1,2 or 3 returns the mean value of the histogram along X,Y or Z axis.
Definition: TH1.cxx:7074
Double_t GetRMS(Int_t axis=1) const
Definition: TH1.h:311
A doubly linked list.
Definition: TList.h:44
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:575
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
Named parameter, streamable and storable.
Definition: TParameter.h:37
const AParamType & GetVal() const
Definition: TParameter.h:69
Basic string class.
Definition: TString.h:131
const char * Data() const
Definition: TString.h:364
A TTree represents a columnar dataset.
Definition: TTree.h:72
TH1F * h1
Definition: legend1.C:5
void Begin(Int_t type)
static constexpr double nm
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
Author
Gerardo Ganis (gerar.nosp@m.do.g.nosp@m.anis@.nosp@m.cern.nosp@m..ch)

Definition in file ProofTests.C.