#include "SimpleAnalysisMaker.h" #include #include "StPicoEvent/StPicoDst.h" #include "StPicoEvent/StPicoEvent.h" #include "StPicoEvent/StPicoTrack.h" #include "StPicoDstMaker/StPicoDstMaker.h" #include "TH1.h" #include "TFile.h" #include "TObjArray.h" #define NumberOfTH1F 2 // Number of Histograms ClassImp(SimpleAnalysisMaker) // Macro for CINT compatibility SimpleAnalysisMaker::SimpleAnalysisMaker( StPicoDstMaker* maker ) : StMaker("SimpleAnalysisMaker") { // Initialize and/or zero all public/private data members here. for ( Int_t i = 0 ; i < NumberOfTH1F ; i++ ) // Zero the histogram pointers { histogram[i] = NULL ; } histogram_output = NULL ; // Zero the Pointer to histogram output file mPicoDstMaker = maker ; // Pass picoDst pointer to DstAnlysisMaker Class member functions mEventsProcessed = 0 ; // Zero the Number of Events processed by the maker mHistogramOutputFileName = "" ; // Histogram Output File Name will be set inside the "analysis".C macro } SimpleAnalysisMaker::~SimpleAnalysisMaker() { // Destroy and/or zero out all public/private data members here. } Int_t SimpleAnalysisMaker::Init( ) { // Do once at the start of every analysis // Create Histogram output file histogram_output = new TFile( mHistogramOutputFileName, "recreate" ) ; // Name was set previously in calling macro // Create Histograms const Int_t nbins = 100 ; histogram[0] = new TH1F( "Vertex", "Event Vertex Z Position", nbins, -25.0, 25.0 ) ; histogram[1] = new TH1F( "Pt", "Transverse Momentum for all particles", nbins, 0.0, 10.0 ) ; return kStOK ; } Int_t SimpleAnalysisMaker::Make( ) { // Get events StPicoDst* mPicoDst = mPicoDstMaker->picoDst() ; if ( !mPicoDst ) return kStOK ; StPicoEvent* picoEvent = mPicoDst->event() ; if ( !picoEvent ) return kStOK ; // Do 'event' analysis based on the 'event' data histogram[0] -> Fill( picoEvent->primaryVertex().z() ) ; // Make histogram of the vertex Z distribution // Get 'track' data, make cuts on tracks, do physics analysis, histogram results int ntracks = mPicoDst->numberOfTracks() ; // Number of tracks (global+primary). We will filter primaries (below). for( Int_t inc = 0 ; inc < ntracks ; inc++ ) { StPicoTrack* track = mPicoDst->track(inc) ; // Pointer to track StPicoTrackCovMatrix* trackCov = mPicoDst->trackCovMatrix(inc) ; // Pointer to covariance matrix for the track if ( !track ) continue ; // Check if its a good track (global and/or primary) if ( !track->isPrimary() ) continue ; // Check if its a primary track (order of lines is important) if ( !trackCov ) continue ; // Check if its a primary with a valid Covariance matrix histogram[1] -> Fill( track->pMom().Perp() ) ; } mEventsProcessed++ ; return kStOK ; } Int_t SimpleAnalysisMaker::Finish( ) { // Do once at the end the analysis // Write histograms to disk, output miscellaneous other information histogram_output -> Write() ; // Write all histograms to disk cout << "Total Events Processed in DstMaker " << mEventsProcessed << endl ; return kStOk ; }