56 #include "StMcEmcHitCollection.hh"
57 #include "StMcEmcModuleHitCollection.hh"
58 #include "StMcCalorimeterHit.hh"
59 #include "StMcTrack.hh"
60 #include "StParticleDefinition.hh"
61 #include "StMessMgr.h"
62 #include "TObjectSet.h"
63 #include "TDataSetIter.h"
66 static const char rcsid[] =
"$Id ";
70 StMcEmcHitCollection::StMcEmcHitCollection():
TDataSet(
"emcHits",0,kTRUE) { MakeHitCollection(); }
72 StMcEmcHitCollection::StMcEmcHitCollection(
char* name):
TDataSet(name,0,kTRUE) {MakeHitCollection();}
73 StMcEmcHitCollection::StMcEmcHitCollection(
const char* name):
TDataSet(name,0,kTRUE) { MakeHitCollection();}
76 StMcEmcHitCollection::MakeHitCollection()
79 TObjArray *modules = GetObjArray();
82 for (
int i=0; i < mNumberOfModules; i++)
85 StMcEmcHitCollection::~StMcEmcHitCollection()
88 StMcEmcHitCollection::EAddHit
91 if(!hit) { LOG_ERROR <<
"tried to add a NULL hit to StMcEmcHitCollection" << endm; }
93 unsigned int m = hit->module();
96 if(m<=mNumberOfModules && m>=1) {
98 for(
unsigned int ih=0; ih<thisModule(i).numberOfDetectorHits(); ih++) {
99 if((*thisModule(i).detectorHits()[ih]) == (*detectorHit)) {
100 (*thisModule(i).detectorHits()[ih]) += (*detectorHit);
101 delete detectorHit; detectorHit = NULL;
106 thisModule(i).detectorHits().push_back(detectorHit);
110 if (m<=mNumberOfModules && m>=1) {
111 if(thisModule(i).numberOfHits() == 0) {
113 thisModule(i).hits().push_back(hit);
117 for(
unsigned int ih=0; ih<thisModule(i).numberOfHits(); ih++){
118 if((*thisModule(i).hits()[ih]) == (*hit)) {
119 (*thisModule(i).hits()[ih]) += (*hit);
123 thisModule(i).hits().push_back(hit);
128 Warning(
"addHit",
"Wrong hit: module=%d but mNumberOfModules=%d",m,mNumberOfModules);
134 StMcEmcHitCollection::numberOfHits()
const
136 unsigned long sum = 0;
137 for (
int i=0; i<mNumberOfModules; i++) {
138 sum += thisModule(i).hits().size();
144 StMcEmcHitCollection::sum()
const
148 for(i=0; i < mNumberOfModules; i++){
150 s += module(m)->sum();
156 StMcEmcHitCollection::module(
unsigned int m)
159 TObjArray &modules = *GetObjArray();
160 unsigned int i = m - 1;
161 if (i>=0 && i < mNumberOfModules)
168 StMcEmcHitCollection::module(
unsigned int m)
const
170 TObjArray &modules = *GetObjArray();
171 unsigned int i = m - 1;
172 if (i>=0 && i < mNumberOfModules)
185 void StMcEmcHitCollection::print() {}
188 os<<
"-----------\n"<<emcColl.GetName()<<
" has "<<emcColl.numberOfHits()<<
" hits in "
189 <<emcColl.GetListSize()<<
" modules. Deposit Energy "<<emcColl.sum()<<
" GeV \n-----------\n";
191 for (i=0; i<emcColl.numberOfModules(); i++) {
193 const StSPtrVecMcCalorimeterHit& hits = emcColl.thisModule(i).hits();
194 int nh = hits.size();
196 os<<
" " <<emcColl.module(m)->GetName()<<
" #hits "<<nh<<
" Dep.Energy " <<
197 emcColl.module(m)->sum()<< endl;
198 os << *(emcColl.module(m)->hits())[0];
199 os <<
"Parent track of this Hit" << endl;
201 if (track) os << *track << endl;
207 void StMcEmcHitCollection::Print(Option_t *option)
const {
208 TString Option(option);
209 if (Option.Contains(
"all",TString::kIgnoreCase)) {
210 cout<<
"-----------\n"<<GetName()<<
" has "<<numberOfHits()<<
" hits in "
211 <<GetListSize()<<
" modules. Deposit Energy "<<sum()<<
" GeV \n-----------\n";
213 for (i=0; i<numberOfModules(); i++) {
215 const StSPtrVecMcCalorimeterHit& hits = thisModule(i).hits();
216 int nh = hits.size();
218 cout<<
" " <<module(m)->GetName()<<
" #hits "<<nh<<
" Dep.Energy " <<
219 module(m)->sum()<< endl;
220 for (
int j = 0; j < nh; j++) {
223 if ( hit->parentTrack()) {
224 cout <<
" key " << hit->parentTrack()->key();
230 }
else cout << *
this;
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
void MakeCollection()
Create the internal container at once if any.