StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjTowerEnergyCorrectionForTracks.cxx
1 // $Id: StjTowerEnergyCorrectionForTracks.cxx,v 1.1 2008/11/27 07:35:25 tai Exp $
2 #include "StjTowerEnergyCorrectionForTracks.h"
3 
4 #include <iostream>
5 
7 
8 using namespace std;
9 
10 const int StjTowerEnergyCorrectionForTracks::mNOfBemcTowers;
11 
12 StjTowerEnergyList StjTowerEnergyCorrectionForTracks::operator()(const StjTowerEnergyList &energyDepositList, const StjTrackList& trackList)
13  {
14  return Do(energyDepositList, trackList);
15 }
16 
17 StjTowerEnergyList StjTowerEnergyCorrectionForTracks::Do(const StjTowerEnergyList &energyDepositList, const StjTrackList& trackList)
18 {
19  for (int i = 1; i <= mNOfBemcTowers; ++i) {
20  mNtracksOnTower[i] = 0;
21  }
22 
23  for(StjTrackList::const_iterator track = trackList.begin(); track != trackList.end(); ++track) {
24  countTracksOnBemcTower(*track);
25  }
26 
27  StjTowerEnergyList ret;
28 
29  for(StjTowerEnergyList::const_iterator it = energyDepositList.begin(); it != energyDepositList.end(); ++it) {
30 
31  StjTowerEnergy energyDeposit(*it);
32 
33  energyDeposit.energy = correctBemcTowerEnergyForTracks_(energyDeposit.energy, energyDeposit.towerId, energyDeposit.towerEta, energyDeposit.towerPhi);
34 
35  energyDeposit.energy = (energyDeposit.energy <= 0) ? 0 : energyDeposit.energy;
36 
37  ret.push_back(energyDeposit);
38  }
39 
40  return ret;
41 }
42 
43 void StjTowerEnergyCorrectionForTracks::countTracksOnBemcTower(const StjTrack& track)
44 {
45  if(track.exitDetectorId == 9 && track.exitTowerId != 0 && track.exitTowerId <= mNOfBemcTowers)
46  mNtracksOnTower[track.exitTowerId]++;
47 }
48 
49 double StjTowerEnergyCorrectionForTracks::correctBemcTowerEnergyForTracks_(double energy, int bemcTowerId, float eta, float phi)
50 {
51  if(bemcTowerId > mNOfBemcTowers) return energy;
52 
53  float theta=2.*atan(exp(-eta));
54 
55  //do a quick correction for hadronic MIP eneryg deposition:
56  double MipE = 0.261*(1.+0.056*eta*eta)/sin(theta); //GeV
57 
58  return energy - mNtracksOnTower[bemcTowerId]*MipE;
59 }