37 #include "StEmcHitCollection.h"
38 #include "St_TableSorter.h"
46 mNHit = 0; mEnergySum = 0.0, mEtSum = 0.0;
48 mNumsModule.Set(120); mIndexFirstLast.Set(121);
51 StEmcHitCollection::StEmcHitCollection(
const Char_t *Name) :
St_DataSet(Name) ,
StEmcGeom(Name) {
54 mNHit = 0; mEnergySum = 0.0, mEtSum = 0.0;
56 mNumsModule.Set(120); mIndexFirstLast.Set(121);
59 StEmcHitCollection::~StEmcHitCollection(){ }
61 Int_t StEmcHitCollection::ADCtoEnergy(St_emc_hits *emc_hit){
64 Int_t i; TString name(GetName());
65 Int_t n = emc_hit->GetNRows();
66 emc_hits_st *
hit = emc_hit->GetTable();
68 TString n_ped_h=
"emc/new/"+name+
"/pedestal/ped_"+name+
"_h";
69 TString n_ped =
"emc/new/"+name+
"/pedestal/ped_"+name;
70 TString n_slp_h=
"emc/new/"+name+
"/gain/slp_"+name+
"_h";
71 TString n_slp =
"emc/new/"+name+
"/gain/slp_"+name;
74 St_emc_calib_header *m_ped_h = (St_emc_calib_header *) local(n_ped_h);
75 St_emc_pedestal *m_ped = (St_emc_pedestal *) local(n_ped);
76 St_emc_calib_header *m_slp_h = (St_emc_calib_header *) local(n_slp_h);
77 St_emc_adcslope *m_slp = (St_emc_adcslope *) local(n_slp);
78 if(m_ped_h && m_ped && m_slp_h && m_slp){
79 emc_calib_header_st *ped_h = m_ped_h->GetTable();
80 emc_pedestal_st *ped = m_ped->GetTable();
81 emc_calib_header_st *slp_h = m_slp_h->GetTable();
82 emc_adcslope_st *slp = m_slp->GetTable();
83 if(ped_h->det != Detector()){
84 cout <<
"***StEmcHitCollection::ADCtoEnergy: Pedestal data is not for this datector: "
88 if(slp_h->det != Detector()){
89 cout <<
"***StEmcHitCollection::ADCtoEnergy: Gain data is not for this datector: "
93 if(ped_h->nmodule != NModule() ||
94 ped_h->neta != NEta() ||
95 ped_h->nsub != NSub() ||
96 slp_h->nmodule != NModule() ||
97 slp_h->neta != NEta() ||
98 slp_h->nsub != NSub() ){
99 cout <<
"***StEmcHitCollection::ADCtoEnergy: Inconsistent Ped or Gain data: "
104 mNHit=0; mEnergySum=0.0; mEtSum =0.0;
108 for(i = 0; i<n; i++){
109 Float_t eta, phi; Int_t id,m,e,s;
110 m = (Int_t)hit[i].module;
111 e = (Int_t)hit[i].eta;
112 s = (Int_t)hit[i].sub;
114 if(!getId(m, e, s,
id)){
115 getEta(m, e, eta); getPhi(m, s, phi);
118 if(slp[
id].p0 > 0.0){
119 Float_t Et = (hit[i].adc-ped[id].ped)/slp[
id].p0;
123 mEnergy[mNHit]=E; mId[mNHit]=id;
124 mNHit++; mEnergySum+=E; mEtSum+=Et;
127 cout <<
"StEmcHitCollection::ADCtoEnergy: Adcslope is less equal 0: "
128 << name <<
" : " <<
id <<endl;
133 mEnergy[mNHit]=E; mId[mNHit]=id;
134 mNHit++; mEnergySum+=E; mEtSum+=E/cosh(eta);
137 cout<<
" Bad index m "<<m<<
" e "<<e<<
" s "<<s<<endl;
142 cout<<
"***StEmcHitCollection::ADCtoEnergy: Function has not been implimented yet: "
143 <<name<<
" : "<<slp_h->func<<endl;
147 cout<<
"StEmcHitCollection::ADCtoEnergy: Not enough information, use GEANT energy: "
148 << name <<
" Nhits " << n << endl;
149 for(i = 0; i<n; i++){
150 if(hit[i].energy>0.0){
151 Float_t eta, phi; Int_t id,m,e,s;
152 m = (Int_t)hit[i].module;
153 e = (Int_t)hit[i].eta;
154 s = (Int_t)hit[i].sub;
156 if(!getId(m, e, s,
id)){
157 getEta(m, e, eta); getPhi(m, s, phi);
160 mEnergy[mNHit]=E; mId[mNHit]=id;
161 mNHit++; mEnergySum+=E; mEtSum+=E/cosh(eta);
164 cout<<
" Bad index m "<<m<<
" e "<<e<<
" s "<<s<<endl;
172 Int_t StEmcHitCollection::fill(St_emc_hits *emc_hits)
177 Int_t n=emc_hits->GetNRows();
178 if(n==0) {
return kStOK; cout<<
" No ADC in "<<GetName()<<endl;}
180 emc_hits_st *hit = emc_hits->GetTable();
181 if(hit[0].det<1 || hit[0].det>MAXDET){
182 cout<<
"StEmcHitCollection::Fill: Bad detector# in emc_hits_st : "
183 << hit[0].det<<
" "<< GetName() <<endl;
187 mId.Set(n); mEnergy.Set(n);
191 TArrayF ecopy=mEnergy;
192 TArrayL idcopy(mNHit);
193 for(i=0; i< mNHit; i++) {idcopy[i] =(Long_t)mId[i];}
196 for(i=0; i< mNHit; i++) {
197 Int_t j=sort.GetIndex(i);
199 mEnergy[i] = ecopy[j];
203 Int_t id, m, e, s, mold;
206 mNumsModule[0] = (Short_t)mold;
207 mIndexFirstLast[0] = 0;
208 mIndexFirstLast[1] = mNHit;
212 for(i=1; i<mNHit; i++){
217 mNumsModule[mModule] = (Short_t)mold;
218 mIndexFirstLast[mModule] = i;
219 mIndexFirstLast[mModule+1] = mNHit;
230 St_emc_hits* StEmcHitCollection::copyToTable(
const Char_t *Name){
232 Int_t i, id, m, e, s, n=0;
234 St_emc_hits *emc_hits =
new St_emc_hits((Text_t*)Name, mNHit);
235 for(i=0; i<mNHit; i++){
239 raw.det = Detector();
244 raw.energy = mEnergy[i];
245 emc_hits->AddAt(&raw, n);
252 void StEmcHitCollection::printHits(Int_t n, Int_t start){
255 cout << endl << GetName() <<
" : ";
256 if(mNHit<=0){cout <<
"No hits" << endl;
return;}
257 else{cout << mNHit <<
" hits" <<
" Modules "<<mModule<< endl;}
258 cout <<
"Raw ID Module Eta Sub Energy"<<endl;
261 if(start>=mNHit) start=mNHit-1;
262 if(start+n>=mNHit) n=mNHit-start;
265 for(i=start; i<start+n; i++){
266 id = (Int_t) mId[i];
getBin(
id, m, e, s);
267 if(i == start) mold=m;
269 cout <<
"-------------------------------"<<endl;
272 cout <<i<<
" "<<
id<<
" "<<m<<
" "<<e<<
" "<<s<<
" "<<mEnergy[i]<<endl;
275 for(i=0; i<mModule; i++){
276 Int_t jm=mIndexFirstLast[i+1] - mIndexFirstLast[i];
277 cout<<i<<
" #Modules "<<mNumsModule[i]<<
" jm "<<jm<<
278 " First "<<mIndexFirstLast[i]<<
" Last "<<mIndexFirstLast[i+1]-1<<endl;
282 void StEmcHitCollection::printHitsAll(){
292 void StEmcHitCollection::printNameTable(){
293 if(mEmcCalib) printf(
" mEmcCalib unzero, name %s \n", mEmcCalib->GetName());
294 else printf(
" <E> Pointer of mEmcCalib is zero ************** \n");
void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
Int_t getBin(const Float_t phi, const Float_t eta, Int_t &m, Int_t &e, Int_t &s) const