StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjTrgSoftEtThresholdBJP.cxx
1 // $Id: StjTrgSoftEtThresholdBJP.cxx,v 1.5 2008/09/17 18:43:00 tai Exp $
2 // Copyright (C) 2008 Tai Sakuma <sakuma@bnl.gov>
3 #include "StjTrgSoftEtThresholdBJP.h"
4 
5 #include "StjTowerEnergyCutEnergy.h"
6 #include "StjTowerEnergyCutBemcStatus.h"
7 #include "StjTowerEnergyPrint.h"
8 #include "StjTowerEnergyCutBemcStatus.h"
9 #include "StjTowerEnergyCutEnergy.h"
10 #include "StjTowerEnergyCutEt.h"
11 #include "StjTowerEnergyCutAdc.h"
12 
13 #include "StjTrgBEMCJetPatchTowerIdMap.h"
14 
15 #include "StjBEMC.h"
16 
17 #include "StjTrg.h"
18 
19 #include <TVector3.h>
20 #include <TMath.h>
21 
22 #include <iostream>
23 #include <map>
24 
26 
27 using namespace std;
28 
30  : _bemc(bemc), _jpTowerMap(jpTowerMap), _minEt(minEt), _runNumber(-1), _eventId(-1)
31 {
32  _cut.addCut( new StjTowerEnergyCutEnergy(0.0) );
33  _cut.addCut( new StjTowerEnergyCutBemcStatus(1) );
34  _cut.addCut( new StjTowerEnergyCutAdc(0, 2.0) );
35  _cut.addCut( new StjTowerEnergyCutEt(0.2) );
36 }
37 
38 bool StjTrgSoftEtThresholdBJP::isNewEvent()
39 {
40  if(_runNumber != _trg->runNumber()) return true;
41  if(_eventId != _trg->eventId()) return true;
42  return false;
43 }
44 
45 void StjTrgSoftEtThresholdBJP::read()
46 {
47  _runNumber = _trg->runNumber();
48  _eventId = _trg->eventId();
49 
50  _jetPatches.clear();
51  _jetPatchDsmAdc.clear();
52  _jetPatchAdc.clear();
53  _jetPatchEnergy.clear();
54  _jetPatchEt.clear();
55 
56  StjTowerEnergyList energyList = _bemc->getEnergyList();
57  energyList = _cut(energyList);
58 
59  map<int, StjTowerEnergyList> jpMap;
60 
61  for(StjTowerEnergyList::const_iterator it = energyList.begin(); it != energyList.end(); ++it) {
62  int jpid = _jpTowerMap->getJetPatchIdForTower((*it).towerId);
63  if(jpid == -1) continue;
64  jpMap[jpid].push_back(*it);
65  }
66 
67  for(map<int, StjTowerEnergyList>::const_iterator it = jpMap.begin(); it != jpMap.end(); ++it) {
68  int jpid = (*it).first;
69  const StjTowerEnergyList& energyList = (*it).second;
70  double Et = computeEtSum(energyList);
71  if(Et <= _minEt) continue;
72  _jetPatches.push_back(jpid);
73  _jetPatchDsmAdc.push_back(0);
74  _jetPatchAdc.push_back(0);
75  _jetPatchEnergy.push_back(0);
76  _jetPatchEt.push_back(Et);
77  }
78 
79  _passed = ( ! _jetPatches.empty() );
80 
81 }
82 
83 double StjTrgSoftEtThresholdBJP::computeEtSum(const StjTowerEnergyList& energyList)
84 {
85  double ret = 0;
86  for(StjTowerEnergyList::const_iterator it = energyList.begin(); it != energyList.end(); ++it) {
87  TVector3 vec3;
88  vec3.SetPtEtaPhi((*it).towerR, (*it).towerEta, (*it).towerPhi);
89  ret += ((*it).energy)*TMath::Sin(vec3.Theta());
90  }
91  return ret;
92 }
93 
94 bool StjTrgSoftEtThresholdBJP::soft()
95 {
96  if(isNewEvent()) read();
97  return _passed;
98 }
99 
100 vector<int> StjTrgSoftEtThresholdBJP::jetPatches()
101 {
102  if(isNewEvent()) read();
103  return _jetPatches;
104 }
105 
106 vector<int> StjTrgSoftEtThresholdBJP::jetPatchDsmAdc()
107 {
108  if(isNewEvent()) read();
109  return _jetPatchDsmAdc;
110 }
111 
112 vector<unsigned int> StjTrgSoftEtThresholdBJP::jetPatchAdc()
113 {
114  if(isNewEvent()) read();
115  return _jetPatchAdc;
116 }
117 
118 vector<double> StjTrgSoftEtThresholdBJP::jetPatchEnergy()
119 {
120  if(isNewEvent()) read();
121  return _jetPatchEnergy;
122 }
123 
124 vector<double> StjTrgSoftEtThresholdBJP::jetPatchEt()
125 {
126  if(isNewEvent()) read();
127  return _jetPatchEt;
128 }
129 
130