//*-- Author : Paul Eugenio 21-Jan-99 //////////////////////////////////////////////////////////////////////// // TMCesr // //////////////////////////////////////////////////////////////// // // TMCesr contains a TClonesArray of TMCparticle // //////////////////////////////////////////////////////////////////////// #include "TMCesr.h" ClassImp(TMCesr) TClonesArray *TMCesr::fgParticles = 0; //____________________________________________________________________________ TMCesr::TMCesr(){ // Create the object // // if(!fgParticles) fgParticles = new TClonesArray("TMCParticle",10); fParticles = fgParticles; fnParticles=0; } //____________________________________________________________________________ TMCesr::TMCesr(TMCFastHepEvt &hepevt,TMCFastOfflineTrack &offtrk, TLGDsmears &lgdsmears,TMCFastCalorimeter &bcal){ Double_t res=-1; Double_t phires = -1; Fill(hepevt,offtrk,lgdsmears,bcal,res,phires); } TMCesr::TMCesr(TMCFastHepEvt &hepevt,TMCFastOfflineTrack &offtrk, TLGDsmears &lgdsmears,TMCFastCalorimeter &bcal,Double_t bcal_res,Double_t phi_res){ Fill(hepevt,offtrk,lgdsmears,bcal,bcal_res,phi_res); } TMCesr::TMCesr(TMCFastHepEvt &hepevt){ Fill(hepevt); } void TMCesr::Fill(TMCFastHepEvt &hepevt){ fnParticles=0; if(!fgParticles) fgParticles = new TClonesArray("TMCParticle",10); fParticles = fgParticles; SetNparticles(makeParticles(hepevt)); SetNLGDparticles(0); SetNBCALparticles(0); SetNOFFTRKparticles(0); } void TMCesr::Fill(TMCFastHepEvt &hepevt,TMCFastOfflineTrack &offtrk, TLGDsmears &lgdsmears,TMCFastCalorimeter &bcal, Double_t bcal_resolution, Double_t phi_res){ fnParticles=0; if(!fgParticles) fgParticles = new TClonesArray("TMCParticle",10); fParticles = fgParticles; SetNLGDparticles(makeParticles(hepevt,lgdsmears)); SetNBCALparticles(makeParticles(hepevt,bcal,bcal_resolution,phi_res)); SetNOFFTRKparticles(makeParticles(hepevt,offtrk)); SetNparticles(GetNLGDparticles()+GetNBCALparticles()+GetNOFFTRKparticles()); } Int_t TMCesr::makeParticles(TMCFastHepEvt &hepevt,TMCFastCalorimeter &bcal,Double_t bcal_resolution,Double_t phi_res){ // Create a TMCparticle instance // from a TMCFastCalorimeter &bcal // and add the instance to // the TClonesArray fParticles // TClonesArray &heparts = *fParticles; Int_t Ngammas=0,gammaHepIndex[20],n_made=0; Double_t e; for(Int_t i=0;iGetCalHitIndex() == calhit->GetHitIndex() && gammaHepIndex[i] == info->GetHepIndex() ){ e += info->GetEem() + info->GetEmip() + info->GetEhad() ; // the gamma energy can be smeared by hadrons... // Now we have a cal hit that belongs to // the gamma -- there can be many hits to oner gamma. } } } // // Scale the MCFast energies by a kludge factor. // Without kludge, piz mean is too small by 1/1.055 // e *= 1.055; THIS was need in the old MCFast calor code // The new calor code needs less of a correction // This value is based on the average correction needed to // get the correct pizero mass at B5:m1.4 and B12M2.0 // for mcfast version 4_2 it it unknown for v4_4 // e *= 1.03; // e is now the total measured electroMagnetic energy for this gamma if(e){ TMCFastHepParticle heppart = hepevt.GetHepParticle(gammaHepIndex[i]); if((bcal_resolution >= 0 ) && (phi_res >= 0 )) new(heparts[fnParticles++]) TMCParticle(heppart,e,bcal_resolution,phi_res); else if((bcal_resolution = -1) && (phi_res >= 0 )) new(heparts[fnParticles++]) TMCParticle(heppart,e,-1.,phi_res); else if((bcal_resolution >= 0) && (phi_res = -1)) new(heparts[fnParticles++]) TMCParticle(heppart,e,bcal_resolution,-1.); else new(heparts[fnParticles++]) TMCParticle(heppart,e); n_made++; } } return n_made; } Int_t TMCesr::makeParticles(TMCFastHepEvt &hepevt,TLGDsmears &lgd){ // Create TMCparticle instances // from a TLGDsmears &lgdSmears // and add them to // the TClonesArray fParticles // TClonesArray &parts = *fParticles; Int_t Ngammas=0,gammaIndex[20],n_made=0; // Get List of Gammas for(Int_t i=0;iGetHepIndex()){ new(parts[fnParticles++]) TMCParticle(*lgdpart); n_made++; } } } } return n_made; } int TMCesr::makeParticles(TMCFastHepEvt &hepevt,TMCFastOfflineTrack &offtrk){ // Create a TMCparticle instance // from a TMCFastOfflineTrack &offtrk // and add the instance to // the TClonesArray fParticles // TClonesArray &parts = *fParticles; Int_t n_made=0; for(Int_t j=0;jGetLgdParticles() // this->GetParticles()->Clear(); } //____________________________________________________________________________ TMCesr::~TMCesr() { this->Clear(); } //____________________________________________________________________________ int gampID(int id); void TMCesr::DumpGampFormat(ostream *os, Double_t kludge_beamE){ // Print out the esr oject in gamp ascii format // which is used in PWA2000. The format for each event is: // {# nparts} //nparticles where the beam is the first particle) // {gampID} {charge} {p.x} {p.y} {p.z} {p.t} // particle #0 // ... // {gampID} {charge} {p.x} {p.y} {p.z} {p.t} // particle #(nparts-1) *os<GetNparticles()+1<GetNparticles()){ TIter nextMC(this->GetParticles()); while( TMCParticle *p = ( TMCParticle *)nextMC()) *os<GetIdHep())<<" "<< p->GetCharge()<<" " <GetPx()<<" "<GetPy()<<" "<GetPz()<<" "<GetE()<GetNparticles()<GetNparticles()){ TIter nextMC(this->GetParticles()); while( TMCParticle *particle = ( TMCParticle *)nextMC()) particle->Print(os); *os<