|
@@ -0,0 +1,133 @@
|
|
|
+/**
|
|
|
+ * \brief Example of how to read a file (list of files) using StFemtoEvent classes
|
|
|
+ *
|
|
|
+ * RunFemtoDstAnalyzer.C is an example of reading FemtoDst format.
|
|
|
+ * One can use either FemtoDst file or a list of femtoDst files (inFile.lis or
|
|
|
+ * inFile.list) as an input, and preform physics analysis
|
|
|
+ *
|
|
|
+ * \author Grigory Nigmatkulov
|
|
|
+ * \date May 29, 2018
|
|
|
+ */
|
|
|
+
|
|
|
+// This is needed for calling standalone classes
|
|
|
+#define _VANILLA_ROOT_
|
|
|
+
|
|
|
+// C++ headers
|
|
|
+#include <iostream>
|
|
|
+
|
|
|
+// ROOT headers
|
|
|
+#include "TROOT.h"
|
|
|
+#include "TFile.h"
|
|
|
+#include "TChain.h"
|
|
|
+#include "TTree.h"
|
|
|
+#include "TSystem.h"
|
|
|
+#include "TH1.h"
|
|
|
+#include "TH2.h"
|
|
|
+#include "TMath.h"
|
|
|
+
|
|
|
+// FemtoDst headers
|
|
|
+#include "/mnt/pool/rhic/1/nigmatkulov/soft/StFemtoEvent/StFemtoDstReader.h"
|
|
|
+#include "/mnt/pool/rhic/1/nigmatkulov/soft/StFemtoEvent/StFemtoDst.h"
|
|
|
+#include "/mnt/pool/rhic/1/nigmatkulov/soft/StFemtoEvent/StFemtoEvent.h"
|
|
|
+#include "/mnt/pool/rhic/1/nigmatkulov/soft/StFemtoEvent/StFemtoTrack.h"
|
|
|
+
|
|
|
+// Load libraries (for ROOT_VERSTION_CODE >= 393215)
|
|
|
+#if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0)
|
|
|
+R__LOAD_LIBRARY(/mnt/pool/rhic/1/nigmatkulov/soft/StFemtoEvent/libStFemtoDst)
|
|
|
+#endif
|
|
|
+
|
|
|
+// inFile - is a name of name.FemtoDst.root file or a name
|
|
|
+// of a name.lis(t) files, that contains a list of
|
|
|
+// name1.FemtoDst.root, name2.FemtoDst.root, ... files
|
|
|
+
|
|
|
+//_________________
|
|
|
+void FemtoDstAnalyzer(const Char_t *inFile = "st_physics_12150008_raw_4030001.femtoDst.root",const Char_t *oFileName = "oTest.root") {
|
|
|
+
|
|
|
+ std::cout << "Hi! Lets do some physics, Master!" << std::endl;
|
|
|
+
|
|
|
+ #if ROOT_VERSION_CODE < ROOT_VERSION(6,0,0)
|
|
|
+ gSystem->Load("/mnt/pool/rhic/1/nigmatkulov/soft/StFemtoEvent/libStFemtoDst.so");
|
|
|
+ #endif
|
|
|
+
|
|
|
+ StFemtoDstReader* femtoReader = new StFemtoDstReader(inFile);
|
|
|
+ femtoReader->Init();
|
|
|
+
|
|
|
+ // This is a way if you want to spead up IO
|
|
|
+ std::cout << "Explicit read status for some branches" << std::endl;
|
|
|
+ femtoReader->SetStatus("*",0);
|
|
|
+ femtoReader->SetStatus("Event",1);
|
|
|
+ femtoReader->SetStatus("Track",1);
|
|
|
+ std::cout << "Status has been set" << std::endl;
|
|
|
+
|
|
|
+ std::cout << "Now I know what to read, Master!" << std::endl;
|
|
|
+
|
|
|
+ if( !femtoReader->chain() ) {
|
|
|
+ std::cout << "No chain has been found." << std::endl;
|
|
|
+ }
|
|
|
+ Long64_t eventsInTree = femtoReader->tree()->GetEntries();
|
|
|
+ std::cout << "eventsInTree: " << eventsInTree << std::endl;
|
|
|
+ Long64_t events2read = femtoReader->chain()->GetEntries();
|
|
|
+
|
|
|
+ std::cout << "Number of events to read: " << events2read << std::endl;
|
|
|
+
|
|
|
+ // Loop over events
|
|
|
+ for(Long64_t iEvent=0; iEvent<events2read; iEvent++) {
|
|
|
+
|
|
|
+ std::cout << "Working on event #[" << (iEvent+1)
|
|
|
+ << "/" << events2read << "]" << std::endl;
|
|
|
+
|
|
|
+ Bool_t readEvent = femtoReader->readFemtoEvent(iEvent);
|
|
|
+ if( !readEvent ) {
|
|
|
+ std::cout << "Something went wrong, Master! Nothing to analyze..." << std::endl;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Retrieve femtoDst
|
|
|
+ StFemtoDst *dst = femtoReader->femtoDst();
|
|
|
+
|
|
|
+ // Retrieve event information
|
|
|
+ StFemtoEvent *event = dst->event();
|
|
|
+ if( !event ) {
|
|
|
+ std::cout << "Something went wrong, Master! Event is hiding from me..." << std::endl;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Return primary vertex position
|
|
|
+ TVector3 pVtx = event->primaryVertex();
|
|
|
+
|
|
|
+ // Reject vertices that are far from the central membrane along the beam
|
|
|
+ if( TMath::Abs( pVtx.Z() ) > 200. ) continue;
|
|
|
+
|
|
|
+ // Track analysis
|
|
|
+ Int_t nTracks = dst->numberOfTracks();
|
|
|
+
|
|
|
+ // Track loop
|
|
|
+ for(Int_t iTrk=0; iTrk<nTracks; iTrk++) {
|
|
|
+
|
|
|
+ // Retrieve i-th femto track
|
|
|
+ StFemtoTrack *femtoTrack = dst->track(iTrk);
|
|
|
+
|
|
|
+ if (!femtoTrack) continue;
|
|
|
+
|
|
|
+ // Must be a primary track
|
|
|
+ if ( !femtoTrack->isPrimary() ) continue;
|
|
|
+
|
|
|
+ // Simple single-track cut
|
|
|
+ if( femtoTrack->gMom().Mag() < 0.1 || femtoTrack->gDCA(pVtx).Mag() > 3. ) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Check if track has TOF signal
|
|
|
+ if ( femtoTrack->isTofTrack() ) {
|
|
|
+
|
|
|
+ } //if( isTofTrack() )
|
|
|
+
|
|
|
+ } //for(Int_t iTrk=0; iTrk<nTracks; iTrk++)
|
|
|
+
|
|
|
+ } //for(Long64_t iEvent=0; iEvent<events2read; iEvent++)
|
|
|
+
|
|
|
+ femtoReader->Finish();
|
|
|
+
|
|
|
+ std::cout << "I'm done with analysis. We'll have a Nobel Prize, Master!"
|
|
|
+ << std::endl;
|
|
|
+}
|