StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjRunJetFinder.cxx
1 // $Id: StjRunJetFinder.cxx,v 1.3 2008/08/13 15:34:26 tai Exp $
2 // Copyright (C) 2008 Tai Sakuma <sakuma@bnl.gov>
3 #include "StjRunJetFinder.h"
4 
5 #include <StJetFinder/StJetFinder.h>
6 #include <StJetFinder/StJetPars.h>
7 
8 #include <StjFourVecForJetFinder.h>
9 
10 #include <StjEtaToDetectorEta.h>
11 
12 #include <TLorentzVector.h>
13 
14 #include <iostream>
15 
16 ClassImp(StjRunJetFinder)
17 
18 using namespace std;
19 
20 void StjRunJetFinder::Init(StJetPars* pars)
21 {
22  _jetFinder = pars->constructJetFinder();
23  _jetFinder->Init();
24 }
25 
26 StjJetList StjRunJetFinder::operator()(const StjFourVecList& fourVecList)
27 {
28  typedef std::list<StProtoJet> ProtoJetList;
29  typedef std::vector<const AbstractFourVec*> FourList;
30 
31  FourList fourList;
32 
33  for(StjFourVecList::const_iterator p4 = fourVecList.begin(); p4 != fourVecList.end(); ++p4) {
34  fourList.push_back(new StjFourVecForJetFinder(*p4));
35  }
36 
37  ProtoJetList protoJetList;
38 
39  _jetFinder->findJets(protoJetList, fourList);
40 
41  StjJetList jetList;
42 
43  int jetId(1);
44  for(list<StProtoJet>::iterator it = protoJetList.begin(); it != protoJetList.end(); ++it) {
45  StProtoJet& protoJet = *it;
46 
47  StjJet jet;
48  jet.jetId = jetId++;
49  jet.pt = protoJet.pt();
50  jet.eta = protoJet.eta();
51  jet.phi = protoJet.phi();
52  jet.m = protoJet.mass();
53 
54  FourList parList = protoJet.list();
55  for(FourList::const_iterator it = parList.begin(); it != parList.end(); ++it) {
56  StjFourVec fourVec = (dynamic_cast<const StjFourVecForJetFinder*>(*it))->fourVec();
57  jet.runNumber = fourVec.runNumber;
58  jet.eventId = fourVec.eventId;
59  jet.vertexZ = fourVec.vertexZ;
60  jet.fourVecList.push_back(fourVec);
61  }
62  jet.neuRt = computeNeuRt(jet.fourVecList);
63  StjEtaToDetectorEta eta2deta;
64  jet.detectorEta = eta2deta(jet.eta, jet.vertexZ);
65  jetList.push_back(jet);
66  }
67 
68  for(FourList::iterator it = fourList.begin(); it != fourList.end(); ++it) {
69  delete *it;
70  }
71 
72  return jetList;
73 }
74 
75 double StjRunJetFinder::computeNeuRt(const StjFourVecList& fourList)
76 {
77  double totalEt = 0.0;
78  double neutralEt = 0.0;
79  for(StjFourVecList::const_iterator it = fourList.begin(); it != fourList.end(); ++it) {
80  TLorentzVector p4;
81  p4.SetPtEtaPhiM((*it).pt, (*it).eta, (*it).phi, (*it).m);
82  totalEt += p4.Et();
83  if((*it).type == 2) neutralEt += p4.Et();
84  }
85  return (totalEt) ? neutralEt/totalEt: 0.0;
86 }
87