StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjTrgDisableTowerJP.cxx
1 // $Id: StjTrgDisableTowerJP.cxx,v 1.1 2008/09/21 19:11:46 tai Exp $
2 // Copyright (C) 2008 Tai Sakuma <sakuma@bnl.gov>
3 #include "StjTrgDisableTowerJP.h"
4 
5 #include "StjTrgBEMCJetPatchTowerIdMap.h"
6 #include "StjTowerEnergyList.h"
7 #include "StjBEMC.h"
8 #include "StjTowerEnergyCutEt.h"
9 #include "StjTowerEnergyListCut.h"
10 
11 #include <TVector3.h>
12 #include <TMath.h>
13 
14 #include <iostream>
15 
16 ClassImp(StjTrgDisableTowerJP)
17 
18 using namespace std;
19 
20 void StjTrgDisableTowerJP::read() const
21 {
22  _jetPatches.clear();
23  _jetPatchDsmAdc.clear();
24  _jetPatchAdc.clear();
25  _jetPatchEnergy.clear();
26  _jetPatchEt.clear();
27 
28  if( ! _src->soft() )
29  {
30  _passed = false;
31  return;
32  }
33 
34  vector<int> srcJetPatchs = _src->jetPatches();
35  vector<int> srcJetPatchDsmAdc = _src->jetPatchDsmAdc();
36 
38  cut.addCut( new StjTowerEnergyCutEt(0.2) );
39 
40  StjTowerEnergyList energyList = _bemc->getEnergyList();
41  energyList = cut(energyList);
42 
43  for(size_t i = 0; i != srcJetPatchs.size(); ++i)
44  {
45  _jetPatches.push_back(srcJetPatchs[i]);
46  _jetPatchDsmAdc.push_back(srcJetPatchDsmAdc[i]);
47  unsigned int adc = 0;
48  double energy = 0;
49  double et = 0;
50  for(StjTowerEnergyList::const_iterator it = energyList.begin(); it != energyList.end(); ++it)
51  {
52  if( _badTowerIdSet.count((*it).towerId) ) continue;
53  if(srcJetPatchs[i] == _jpTowerMap->getJetPatchIdForTower((*it).towerId))
54  {
55  adc += (*it).adc;
56  energy += (*it).energy;
57  TVector3 vec3;
58  vec3.SetPtEtaPhi((*it).towerR, (*it).towerEta, (*it).towerPhi);
59  et += ((*it).energy)*TMath::Sin(vec3.Theta());
60  }
61  }
62  _jetPatchAdc.push_back(adc);
63  _jetPatchEnergy.push_back(energy);
64  _jetPatchEt.push_back(et);
65  }
66 
67  _passed = ( ! _jetPatches.empty() );
68 }
69 
70 bool StjTrgDisableTowerJP::soft() const
71 {
72  readIfNewEvent();
73  return _passed;
74 }
75 
76 vector<int> StjTrgDisableTowerJP::jetPatches()
77 {
78  readIfNewEvent();
79  return _jetPatches;
80 }
81 
82 vector<int> StjTrgDisableTowerJP::jetPatchDsmAdc()
83 {
84  readIfNewEvent();
85  return _jetPatchDsmAdc;
86 }
87 
88 vector<unsigned int> StjTrgDisableTowerJP::jetPatchAdc()
89 {
90  readIfNewEvent();
91  return _jetPatchAdc;
92 }
93 
94 vector<double> StjTrgDisableTowerJP::jetPatchEnergy()
95 {
96  readIfNewEvent();
97  return _jetPatchEnergy;
98 }
99 
100 vector<double> StjTrgDisableTowerJP::jetPatchEt()
101 {
102  readIfNewEvent();
103  return _jetPatchEt;
104 }
105