Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
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 = nullptr;
}
//_____________________________________________________________________________
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) {
Int_t from = 0;
while (nms.Tokenize(nam, from, ",")) {
if (gEnv->Lookup(nam)) {
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.
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:69
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:218
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:229
Option_t Option_t option
void Print(Option_t *option="") const override
Print all resources or the global, user or local resources separately.
Definition TEnv.cxx:556
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
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:622
1-D histogram with an int per channel (see TH1 documentation)
Definition TH1.h:540
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:7556
Double_t GetRMS(Int_t axis=1) const
This function returns the Standard Deviation (Sigma) of the distribution not the Root Mean Square (RM...
Definition TH1.h:319
A doubly linked list.
Definition TList.h:38
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
Basic string class.
Definition TString.h:139
A TTree represents a columnar dataset.
Definition TTree.h:79
TH1F * h1
Definition legend1.C:5
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123
Author
Gerardo Ganis (gerar.nosp@m.do.g.nosp@m.anis@.nosp@m.cern.nosp@m..ch)

Definition in file ProofTests.C.