Purdue CMS
PROOF Print
 

PROOF Example

Introduction


In this example you will find how to make an analysis with TSelector and PROOF with full CMSSW support. You can find the ExampleSelector  at /grp/cms/www/Proof320/Selectors at the machine cms.rcac.purdue.edu. It will provide you with the following information:
  • how to access and loop the reco::TrackCollection within a TSelector::process
  • how to setup the CMSSW environment with PROOF
  • how to make an analysis with TSelector and PROOF
The actual example is given for CMSSW_3_2_0. This version comes with root 5.22.00

How to get the code


To run the example at CMSSW_3_2_8 and older, check out the following tag for TFWLiteSelector. Otherwise, just skip this step.
addpkg FWCore/TFWLiteSelector V00-10-01 
 
And add our TSelector example codes in the directory of /grp/cms/www/Proof320/ to your directory of CMSSW_3_2_0/src
cp -r Selectors CMSSW_3_2_6/src/. 

How to run the code


If you have not set up a project area of CMSSW_3_2_6 yet:
source /apps/02/cmssoft/cms/cmsset_default.sh
scramv1 p CMSSW CMSSW_3_2_6
 
Compile and run the example as given below:
source /apps/02/cmssoft/cms/cmsset_default.sh
cd CMSSW_3_2_6/src
cmsenv 
scram b
cd Selectors/ExampleSelector
root -l
 
At root prompt run the example as give below:
.x prooflogon.C
.x run_ExampleSelector.C+

Find out more about the details


You can find the compilation description for the executable in Selectors/ExampleSelector/BuildFile 
<use name=DataFormats/Common>
<use name=DataFormats/TestObjects>
<use name=DataFormats/TrackReco>
<use name=FWCore/Framework>
<use name=FWCore/TFWLiteSelector>
<use name=PhysicsTools/UtilAlgos>
<use name=rootcore>
<use name=root>
<use name=rootrflx>
<export>
 <lib name=ExampleSelector>
</export>

You can find how to write a TSelector to access and loop the reco::TrackCollection in ExampleSelector.h and ExampleSelector.cc.
The ExampleSelector itself is a child class of TFWLiteBasicSelector. This is shown in ExampleSelector.h
#include <TH1F.h>
#include "FWCore/TFWLiteSelector/interface/TFWLiteSelectorBasic.h"

namespace selectors {
class ExampleSelector : public TFWLiteSelectorBasic {
public :
      ExampleSelector() {}
      void begin(TList*&);
      void preProcessing(const TList*, TList&);
      void process(const edm::Event&);
      void postProcessing(TList&);
      void terminate(TList&);

private:
  /// histograms
  TH1F * h_pt;

  ExampleSelector(ExampleSelector const&);
  ExampleSelector operator=(ExampleSelector const&);
};
}
 
In the ExampleSelector::preProcessing function of ExampleSelector.cc, the histogram is booked for each slave.

void ExampleSelector::preProcessing(const TList*, TList& out ) {

   h_pt  = new TH1F( "pt" , "a"  , 10,  -2, 200 );

   out.Add(h_pt);

}

In the process function the events are looped, within one event the reco::TrackCollection for generalTracks is received from part of the input files and the track collection is looped. A simple histogram is filled.
void ExampleSelector::process( const edm::Event& iEvent ) {
  //cout << "processing event " << endl;

  using namespace edm;
  using reco::TrackCollection;
  edm::Handle<reco::TrackCollection> tracks;
  iEvent.getByLabel("generalTracks",tracks);
  for (TrackCollection::const_iterator itTrack=tracks->begin();
        itTrack != tracks->end();
        ++itTrack)
  {
    double track_pt=0;
    track_pt=itTrack->pt();
    //std::cout<<"track_pt "<<track_pt<<std::endl;
    h_pt->Fill(track_pt);
  }
}
 
In the terminate function, all histograms are found and merged to one histogram.
void ExampleSelector::terminate(TList& out) {
  cout << "terminate" << endl;
  {
     TH1F* hist = (TH1F *)out.FindObject("pt");
     if(hist == 0) {
        cout <<"no pt histogram"<<endl;
        return;
     }

        hist->Draw();
  }

  //delete canvas;

}

You can find how to set up the CMSSW environment for the PROOF in the file prooflogon.C and rootlogon.C . In the prooflogon.C, current CMSSW environment parameters are copied to the PROOF environment. By typing .x prooflogon.C at the root prompt, we make all the CMSSW libraries accessible on all the slave PROOF nodes, such as proof-01.

In the rootlogon.C, we set path parameters for our ExampleSelector library, load "libFWCoreFWLite" and enable AutoLibraryLoader. We will execute gProof->Exec(".x rootlogon.C") in the macro run_ExampleSelector.C

 

You can find how to make analysis with TSelector and PROOF in the macro run_ExampleSelector.C .

Initialize a PROOF session at our PROOF farm:

 TProof *gProof=TProof::Open("proof-00.rcac.purdue.edu");

Or initialize a PROOF-Lite session at your current machine:

 TProof *gProof=TProof::Open(" ");

Add user library paths to the PROOF environment:

 gProof->Exec(".x rootlogon.C");

Create a chain and add root files to this chain:

 TDSet c("TTree","Event");

 c.Add("root://dcache-00.rcac.purdue.edu/pnfs/rcac.purdue.edu/data/store..."); # this is xrootd door access

 c.Add("dcap://dcache.rcac.purdue.edu:22125/pnfs/rcac.purdue.edu/data/store..."); # this is dcap door access

Start a Selector process:

 c.Process("selectors::ExampleSelector");

 
The example will get a histogram as follows.




The PROOF session will show a progress GUI as follows.

Currrent configuration of the PROOF farm:

 
 

 

 

Utilization
400 jobs running
Total: 2328 job slots
Jobs running: 400
Jobs queued: 3
dCache
74% utilization
Total: 516 TB
74% Used, 26% Free

This site, and the work it describes, is primarily funded by a grant from the National Science Foundation (NSF).