StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEventCompendiumMaker.cxx
1 //
2 // $Id: StEventCompendiumMaker.cxx,v 1.5 2018/09/28 20:17:35 fisyak Exp $
3 //
4 //#include <iostream>
5 #include "Stiostream.h"
6 #include <cmath>
7 #include "StEventCompendiumMaker.h"
8 #include "TDataSet.h"
9 #include "StDetectorDbMaker/St_MagFactorC.h"
10 #include "StMessMgr.h"
11 #include "StEvent.h"
12 #include "StEventSummary.h"
13 #include "StContainers.h"
14 #include "StTrackNode.h"
15 #include "StTrack.h"
16 #include "StTrackGeometry.h"
17 #include "StPrimaryVertex.h"
18 
19 static const char rcsid[] = "$Id: StEventCompendiumMaker.cxx,v 1.5 2018/09/28 20:17:35 fisyak Exp $";
20 ClassImp(StEventCompendiumMaker)
21 //________________________________________________________________________________
22 Int_t StEventCompendiumMaker::Make(){
23  StEvent* rEvent = 0;
24  rEvent = (StEvent*) GetInputDS("StEvent");
25  if (!rEvent) {
26  gMessMgr->Warning() << "StEventCompendiumMaker::Make: No StEvent found, bail out!" << endm;
27  return kStWarn;
28  }
29  fillEventSummary(rEvent);
30  if (Debug() > 1) {
31  rEvent->summary()->Dump();
32  }
33  return kStOK;
34 }
35 //________________________________________________________________________________
36 void StEventCompendiumMaker::fillEventSummary(StEvent* e) {
37  StEventSummary* summary = e->summary();
38  if (!e->trackNodes().size()){
39  cout << "fillEventSummary: Zero tracks nodes in StEvent...\n" << endl;
40  }
41  // Initialize global track counters & sum variables
42  int glb_trk_good(0), glb_trk_plus(0), glb_trk_minus(0);
43  int prim_trk_good(0);
44  float mean_pt(0), mean_pt2(0), mean_eta(0), rms_eta(0);
45  // Fill pt, eta & phi histograms */
46  const StSPtrVecTrackNode& nodes = e->trackNodes();
47  for (size_t itrk=0; itrk < nodes.size(); itrk++) {/* begin global track loop */
48  StTrack* gtrk = (StTrack *)nodes[itrk]->track(global);
49  if (! gtrk) continue;
50  // Calculate track multiplicities
51 
52  // good global tracks
53  if ( gtrk->flag() <= 0 ) continue;
54  glb_trk_good++;
55 
56  // good primary tracks
57  StTrack* ptrk = (StTrack *) nodes[itrk]->track(primary);
58  if(ptrk && ptrk->flag()>0) prim_trk_good++;
59 
60  // count plus & minus
61  if ( gtrk->geometry()->charge() > 0 ) glb_trk_plus++; // charge = 1
62  if ( gtrk->geometry()->charge() < 0 ) glb_trk_minus++; // charge = -1
63 
64  const StThreeVectorF& mom = gtrk->geometry()->momentum();
65  // Calculate kinematic varialbles for good tracks only
66  float eta = mom.pseudoRapidity();
67  float pt = mom.perp();
68 
69  // Sum pt, pt^2, eta, eta^2 for all good global charged tracks*/
70  mean_pt += pt;
71  mean_pt2 += pt*pt;
72  mean_eta += eta;
73  rms_eta += eta*eta;
74  }// end of global track loop
75 
76  // Fill track multiplicities into StEventSummary
77  summary->setNumberOfTracks(nodes.size());
78  summary->setNumberOfGoodTracks(glb_trk_good);
79  summary->setNumberOfGoodPrimaryTracks(prim_trk_good);
80  summary->setNumberOfGoodTracks(positive,glb_trk_plus);
81  summary->setNumberOfGoodTracks(negative,glb_trk_minus);
82  // summary->setNumberOfExoticTracks(); //No current definition of "exotic" tracks.
83  summary->setNumberOfVertices(e->numberOfPrimaryVertices());
84 
85  // Count v0, xi, and kink candidates
86  summary->setNumberOfVerticesForType(kV0VtxId,e->v0Vertices().size());
87  summary->setNumberOfVerticesForType(kXiVtxId,e->xiVertices().size());
88  summary->setNumberOfVerticesForType(kKinkVtxId,e->kinkVertices().size());
89 
90 
91  // Pileup Vertices
92  // This assumes that the pileup vertices are inserted into the primary vertex container
93  // and are flagged with kOtherVtxId as their StVertexId.
94  // If this is not true, then this number is incorrect.
95  size_t nPileupVert = 0;
96  for (size_t i=0; i<e->numberOfPrimaryVertices();++i) {
97  StVertexId vtx_id = e->primaryVertex(i)->type();
98  if(vtx_id == kOtherVtxId) nPileupVert++ ;
99  }
100  summary->setNumberOfPileupVertices(nPileupVert);
101 
102  // Fill mean eta, pt, pt^2 and rms_eta
103  if (glb_trk_good > 0) {
104  summary->setMeanPt(mean_pt/(float)glb_trk_good);
105  summary->setMeanPt2(mean_pt2/(float)glb_trk_good);
106  summary->setMeanEta(mean_eta/(float)glb_trk_good);
107  summary->setRmsEta(sqrt(rms_eta/(float)glb_trk_good));
108  }
109 
110  // Fill Primary vertex information
111  if (e->primaryVertex()) {
112  summary->setPrimaryVertexPosition(e->primaryVertex()->position());
113  }
114 
115 
116  // The eta, pt, phi, emc energy vs eta and emc energy vs phi histograms
117  // are _not_ filled by this routine.
118  // Also, StEventSummary doesn't have the mutator methods for them.
119 
120  return;
121 } // End of fillEventSummary
122 
123 
Class for Making a Compendium of the information in StEvent.
Definition: Stypes.h:42
Definition: Stypes.h:40