From a73f33f08284d11550deec9af806219953d782cb Mon Sep 17 00:00:00 2001 From: schutz Date: Wed, 1 Mar 2000 13:32:02 +0000 Subject: [PATCH] Continuous progress on the Fast Simulation: AliPHOSFastRecParticle is born --- PHOS/AliPHOSFastRecParticle.cxx | 219 ++++++++++++++++++++++++++++++++ PHOS/AliPHOSFastRecParticle.h | 55 ++++++++ PHOS/AliPHOSRecParticle.cxx | 35 +++++ PHOS/AliPHOSRecParticle.h | 9 +- PHOS/AliPHOSvFast.cxx | 95 +++++++++++--- PHOS/AliPHOSvFast.h | 38 ++++-- PHOS/Makefile | 2 +- PHOS/PHOSLinkDef.h | 1 + 8 files changed, 418 insertions(+), 36 deletions(-) create mode 100644 PHOS/AliPHOSFastRecParticle.cxx create mode 100644 PHOS/AliPHOSFastRecParticle.h diff --git a/PHOS/AliPHOSFastRecParticle.cxx b/PHOS/AliPHOSFastRecParticle.cxx new file mode 100644 index 00000000000..770f92703f8 --- /dev/null +++ b/PHOS/AliPHOSFastRecParticle.cxx @@ -0,0 +1,219 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +//_________________________________________________________________________ +// Particle modified by PHOS response to be used by AliPHOSvFast +//*-- Y. Schutz: SUBATECH +////////////////////////////////////////////////////////////////////////////// + +// --- ROOT system --- + +// --- Standard library --- + +#include + +// --- AliRoot header files --- + +#include "AliPHOSFastRecParticle.h" +#include "TPad.h" +#include "TPaveText.h" + +ClassImp(AliPHOSFastRecParticle) + +//____________________________________________________________________________ + AliPHOSFastRecParticle::AliPHOSFastRecParticle(const AliPHOSFastRecParticle & rp) +{ + fType = rp.fType ; +// fPdgCode = rp.fPdgCode; +// fStatusCode = rp.fStatusCode; +// fMother[0] = rp.fMother[0]; +// fMother[1] = rp.fMother[1]; +// fDaughter[0] = rp.fDaughter[0]; +// fDaughter[1] = rp.fDaughter[1]; +// fWeight = rp.fWeight; +// fCalcMass = rp.fCalcMass; +// fPx = rp.fPx; +// fPy = rp.fPy; +// fPz = rp.fPz; +// fE = rp.fE; +// fVx = rp.fVx; +// fVy = rp.fVy; +// fVz = rp.fVz; +// fVt = rp.fVt; +// fPolarTheta = rp.fPolarTheta; +// fPolarPhi = rp.fPolarPhi; +// fParticlePDG = rp.fParticlePDG; +} + +//____________________________________________________________________________ + AliPHOSFastRecParticle::AliPHOSFastRecParticle(const TParticle & pp) +{ + TParticle & pnoconst = const_cast(pp) ; + AliPHOSFastRecParticle & p = static_cast(pnoconst) ; + + fPdgCode = p.fPdgCode; + fStatusCode = p.fStatusCode; + fMother[0] = p.fMother[0]; + fMother[1] = p.fMother[1]; + fDaughter[0] = p.fDaughter[0]; + fDaughter[1] = p.fDaughter[1]; + fWeight = p.fWeight; + fCalcMass = p.fCalcMass; + fPx = p.fPx; + fPy = p.fPy; + fPz = p.fPz; + fE = p.fE; + fVx = p.fVx; + fVy = p.fVy; + fVz = p.fVz; + fVt = p.fVt; + fPolarTheta = p.fPolarTheta; + fPolarPhi = p.fPolarPhi; + fParticlePDG = p.fParticlePDG; +} + +//____________________________________________________________________________ + AliPHOSFastRecParticle::~AliPHOSFastRecParticle() +{ +} + +//____________________________________________________________________________ +Int_t AliPHOSFastRecParticle::DistancetoPrimitive(Int_t px, Int_t py) +{ + // Compute distance from point px,py to a AliPHOSFastRecParticle considered as a Tmarker + // Compute the closest distance of approach from point px,py to this marker. + // The distance is computed in pixels units. + + Double_t kRADDEG = 180. / TMath::Pi() ; + Coord_t x = Phi() * kRADDEG ; + Coord_t y = Theta() * kRADDEG ; + const Int_t kMaxDiff = 10; + Int_t pxm = gPad->XtoAbsPixel(x); + Int_t pym = gPad->YtoAbsPixel(y); + Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym); + + if (dist > kMaxDiff) return 9999; + return dist; +} + +//___________________________________________________________________________ + void AliPHOSFastRecParticle::Draw(Option_t *option) + { + // Draw this AliPHOSFastRecParticle with its current attributes + + AppendPad(option); + } + +//______________________________________________________________________________ +void AliPHOSFastRecParticle::ExecuteEvent(Int_t event, Int_t px, Int_t py) +{ + // Execute action corresponding to one event + // This member function is called when a AliPHOSFastRecParticle is clicked with the locator + // + + if (!gPad->IsEditable()) + return ; + + static TPaveText * clustertext = 0 ; + + switch (event) { + + case kButton1Down: { + Double_t kRADDEG = 180. / TMath::Pi() ; + Coord_t x = Phi() * kRADDEG ; + Coord_t y = Theta() * kRADDEG ; + clustertext = new TPaveText(x-1, y+1, x+5, y+3, "") ; + Text_t line1[40] ; + Text_t line2[40] ; + sprintf( line1, "PID: %s ", (const char*)Name() ) ; + sprintf( line2, "ENERGY: %f ", Energy() ) ; + clustertext ->AddText(line1) ; + clustertext ->AddText(line2) ; + clustertext ->Draw(""); + gPad->Update() ; + break ; + } + + case kButton1Up: { + delete clustertext ; + clustertext = 0 ; + gPad->Update() ; + break ; + } + + } + +} +//____________________________________________________________________________ +TString AliPHOSFastRecParticle::Name() +{ + TString name ; + switch (fType) { + case kGAMMA: + name = "PHOTON" ; + break ; + case kELECTRON: + name = "ELECTRON" ; + break ; + case kNEUTRAL: + name = "NEUTRAL" ; + break ; + case kCHARGEDHADRON: + name = "CHARGED HADRON" ; + break ; + case kNEUTRALHADRON: + name = "NEUTRAL HADRON" ; + break ; + case kNEUTRALEM: + name = "NEUTRAL EM" ; + break ; + case kGAMMAHADRON: + name = "PHOTON HADRON" ; + break ; + + } + return name ; +} + +//______________________________________________________________________________ +void AliPHOSFastRecParticle::Paint(Option_t *) +{ +// Paint this ALiRecParticle in theta,phi coordinate as a TMarker with its current attributes + + Double_t kRADDEG = 180. / TMath::Pi() ; + Coord_t x = Phi() * kRADDEG ; + Coord_t y = Theta() * kRADDEG ; + Color_t markercolor = 1 ; + Size_t markersize = 1. ; + Style_t markerstyle = 5 ; + + if (!gPad->IsBatch()) { + gVirtualX->SetMarkerColor(markercolor) ; + gVirtualX->SetMarkerSize (markersize) ; + gVirtualX->SetMarkerStyle(markerstyle) ; + } + gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ; + gPad->PaintPolyMarker(1,&x,&y,"") ; +} + +//____________________________________________________________________________ +void AliPHOSFastRecParticle::Print() +{ + cout << "AliPHOSFastRecParticle > " << "type is " << Name() << endl + << " " << "Energy = " << fE << endl + << " " << "Px = " << fPx << endl + << " " << "Py = " << fPy << endl + << " " << "Pz = " << fPz << endl ; +} diff --git a/PHOS/AliPHOSFastRecParticle.h b/PHOS/AliPHOSFastRecParticle.h new file mode 100644 index 00000000000..113f39fe35b --- /dev/null +++ b/PHOS/AliPHOSFastRecParticle.h @@ -0,0 +1,55 @@ +#ifndef ALIPHOSFASTRECPARTICLE_H +#define ALIPHOSFASTRECPARTICLE_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//////////////////////////////////////////////// +// A Particle modified by PHOS response // +// Yves Schutz SUBATECH // +// To become a general class of AliRoot ? // +// // +//////////////////////////////////////////////// + +// --- ROOT system --- + +#include "TParticle.h" +#include "TVector3.h" + +// --- Standard library --- + +// --- AliRoot header files --- + +#include "AliPHOSRecParticle.h" + +typedef TClonesArray FastRecParticlesList ; + + +class AliPHOSFastRecParticle : public TParticle { + +public: + + AliPHOSFastRecParticle() {}; // ctor + AliPHOSFastRecParticle(const AliPHOSFastRecParticle & rp) ; // ctor + AliPHOSFastRecParticle(const TParticle & p) ; // ctor + virtual ~AliPHOSFastRecParticle() ; // dtor + + virtual Int_t DistancetoPrimitive(Int_t px, Int_t py) ; + virtual void Draw(Option_t *option) ; + virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py) ; + Int_t GetType() { return fType ; } + TString Name() ; + virtual void Paint(Option_t * option=""); + void Print() ; + void SetType(Int_t type) { fType = type ; } + +private: + + Int_t fType ; // identified particle type + + ClassDef(AliPHOSFastRecParticle,1) // Reconstructed Particle, version 1 + +}; + +#endif // AliPHOSFASTRECPARTICLE_H diff --git a/PHOS/AliPHOSRecParticle.cxx b/PHOS/AliPHOSRecParticle.cxx index d88d1993f02..d42a13e3ff7 100644 --- a/PHOS/AliPHOSRecParticle.cxx +++ b/PHOS/AliPHOSRecParticle.cxx @@ -45,6 +45,41 @@ ClassImp(AliPHOSRecParticle) } +//____________________________________________________________________________ + AliPHOSRecParticle::AliPHOSRecParticle(const AliPHOSRecParticle & rp) +{ + fPHOSTrackSegment = new AliPHOSTrackSegment( *( rp.GetPHOSTrackSegment()) ) ; + fType = rp.fType ; + fPdgCode = rp.fPdgCode; + fStatusCode = rp.fStatusCode; + fMother[0] = rp.fMother[0]; + fMother[1] = rp.fMother[1]; + fDaughter[0] = rp.fDaughter[0]; + fDaughter[1] = rp.fDaughter[1]; + fWeight = rp.fWeight; + fCalcMass = rp.fCalcMass; + fPx = rp.fPx; + fPy = rp.fPy; + fPz = rp.fPz; + fE = rp.fE; + fVx = rp.fVx; + fVy = rp.fVy; + fVz = rp.fVz; + fVt = rp.fVt; + fPolarTheta = rp.fPolarTheta; + fPolarPhi = rp.fPolarPhi; + fParticlePDG = rp.fParticlePDG; +} + +//____________________________________________________________________________ + AliPHOSRecParticle::~AliPHOSRecParticle() +{ + if(!fPHOSTrackSegment) { + delete fPHOSTrackSegment ; + fPHOSTrackSegment = 0 ; + } +} + //____________________________________________________________________________ Int_t AliPHOSRecParticle::DistancetoPrimitive(Int_t px, Int_t py) { diff --git a/PHOS/AliPHOSRecParticle.h b/PHOS/AliPHOSRecParticle.h index 7b9cac0e5f5..7dfc983df3a 100644 --- a/PHOS/AliPHOSRecParticle.h +++ b/PHOS/AliPHOSRecParticle.h @@ -22,6 +22,7 @@ // --- AliRoot header files --- #include "AliPHOSTrackSegment.h" +#include const static Int_t kUNDEFINED = -1; const static Int_t kGAMMA = 0 ; @@ -39,13 +40,15 @@ public: AliPHOSRecParticle() {}; // ctor AliPHOSRecParticle(AliPHOSTrackSegment * ts) ; // ctor + AliPHOSRecParticle(const AliPHOSRecParticle & rp) ; // ctor + AliPHOSRecParticle& operator= (const AliPHOSRecParticle& rp) { assert(0==1) ; } // forbidden - virtual ~AliPHOSRecParticle(){} ; // dtor + virtual ~AliPHOSRecParticle() ; // dtor virtual Int_t DistancetoPrimitive(Int_t px, Int_t py) ; - virtual void Draw(Option_t *option) ; + virtual void Draw(Option_t *option) ; virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py) ; - AliPHOSTrackSegment * GetPHOSTrackSegment() { return fPHOSTrackSegment ; } + AliPHOSTrackSegment * GetPHOSTrackSegment() const { return fPHOSTrackSegment ; } Int_t GetType() { return fType ; } TString Name() ; virtual void Paint(Option_t * option=""); diff --git a/PHOS/AliPHOSvFast.cxx b/PHOS/AliPHOSvFast.cxx index 08c5216c684..d1e2b4d6274 100644 --- a/PHOS/AliPHOSvFast.cxx +++ b/PHOS/AliPHOSvFast.cxx @@ -32,7 +32,6 @@ // --- AliRoot header files --- #include "AliPHOSvFast.h" -#include "AliPHOSReconstructioner.h" #include "AliRun.h" #include "AliConst.h" @@ -41,7 +40,7 @@ ClassImp(AliPHOSvFast) //____________________________________________________________________________ AliPHOSvFast::AliPHOSvFast() { - fRecParticles = 0 ; + fFastRecParticles = 0 ; fNRecParticles = 0 ; } @@ -63,24 +62,29 @@ AliPHOSvFast::AliPHOSvFast(const char *name, const char *title): SetBigBox(2, fGeom->GetOuterBoxSize(0) ); fNRecParticles = 0 ; + fFastRecParticles = new FastRecParticlesList("AliPHOSFastRecParticle", 100) ; + + fResPara1 = 30.0 ; + fResPara2 = 0.03 ; + fResPara3 = 0.01 ; + } //____________________________________________________________________________ AliPHOSvFast::~AliPHOSvFast() { - fRecParticles->Delete() ; - delete fRecParticles ; - fRecParticles = 0 ; + fFastRecParticles->Delete() ; + delete fFastRecParticles ; + fFastRecParticles = 0 ; } //____________________________________________________________________________ -void AliPHOSvFast::AddRecParticle(Int_t primary) -{ - TClonesArray * particlelist = gAlice->Particles() ; - TParticle * part = (TParticle *)particlelist->At(primary) ; - cout << " AliPHOSvFast::AddRecParticle " << part->GetName() << endl ; +void AliPHOSvFast::AddRecParticle(const AliPHOSFastRecParticle & rp) +{ + new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ; + fNRecParticles++ ; } //____________________________________________________________________________ @@ -218,14 +222,46 @@ void AliPHOSvFast::MakeBranch(Option_t* opt) char branchname[10]; sprintf(branchname,"%s",GetName()); - char *cd = strstr(opt,"D"); + char *cd = strstr(opt,"R"); - if (fDigits && gAlice->TreeD() && cd) { - gAlice->TreeD()->Branch(branchname, &fRecParticles, fBufferSize); - // printf("* AliPHOS::MakeBranch * Making Branch %s for RecParticles \n",branchname); + if (fFastRecParticles && gAlice->TreeR() && cd) { + gAlice->TreeR()->Branch(branchname, &fFastRecParticles, fBufferSize); } } +//____________________________________________________________________________ +Double_t AliPHOSvFast::MakeEnergy(const Double_t energy) +{ + Double_t sigma = SigmaE(energy*1000.) ; + return fRan.Gaus(energy*1000., sigma)/1000. ; +} + +//____________________________________________________________________________ +void AliPHOSvFast::MakeRecParticle(AliPHOSFastRecParticle & rp) +{ + + // get the detected type of particle + Int_t type = MakeType( rp.GetName() ) ; + rp.SetType(type) ; + + + // get the detected energy + + TLorentzVector momentum ; + rp.Momentum(momentum) ; + Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ; + Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ; + cout << modifiedkineticenergy << endl ; + // rp.SetMomentum(tempo) ; + } + +//____________________________________________________________________________ +Int_t AliPHOSvFast::MakeType(const Text_t * name) +{ + Int_t rv = kUNDEFINED ; + return rv ; +} + //___________________________________________________________________________ void AliPHOSvFast::SetBigBox(Int_t index, Float_t value) { @@ -244,17 +280,40 @@ void AliPHOSvFast::SetBigBox(Int_t index, Float_t value) } +//____________________________________________________________________________ +Double_t AliPHOSvFast::SigmaE(Double_t energy) +{ + Double_t rv = -1 ; + + rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2) + + TMath::Power(fResPara2/TMath::Sqrt(energy), 2) + + TMath::Power(fResPara3, 2) ) ; + + return rv * energy ; +} + //____________________________________________________________________________ void AliPHOSvFast::StepManager(void) { Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() ); - TString name = fGeom->GetName() ; + TLorentzVector lv ; + gMC->TrackPosition(lv) ; + + // Makes a reconstructed particle from the primary particle - // add the primary particle to the RecParticles list + TClonesArray * particlelist = gAlice->Particles() ; + TParticle * part = (TParticle *)particlelist->At(primary) ; + + AliPHOSFastRecParticle rp(*part) ; + + // Adds the response of PHOS to the particle + MakeRecParticle(rp) ; - AddRecParticle(primary); - fNRecParticles++ ; + // add the primary particle to the FastRecParticles list + AddRecParticle(rp) ; + + // stop the track as soon PHOS is reached gMC->StopTrack() ; } diff --git a/PHOS/AliPHOSvFast.h b/PHOS/AliPHOSvFast.h index 00ef13f7377..24860250ca8 100644 --- a/PHOS/AliPHOSvFast.h +++ b/PHOS/AliPHOSvFast.h @@ -15,12 +15,13 @@ // --- ROOT system --- #include "TClonesArray.h" +#include "TRandom.h" // --- AliRoot header files --- #include "AliPHOS.h" #include "AliPHOSGeometry.h" #include "AliPHOSPID.h" - +#include "AliPHOSFastRecParticle.h" class AliPHOSvFast : public AliPHOS { @@ -30,26 +31,35 @@ public: AliPHOSvFast(const char *name, const char *title="") ; virtual ~AliPHOSvFast(void) ; - void AddRecParticle(Int_t primary) ; // adds primary particle to the RecParticles list - virtual void BuildGeometry(void) ; // creates the geometry for the ROOT display - virtual void CreateGeometry(void) ; // creates the geometry for GEANT + void AddRecParticle(const AliPHOSFastRecParticle & rp) ; // adds primary particle to the RecParticles list + virtual void BuildGeometry(void) ; // creates the geometry for the ROOT display + virtual void CreateGeometry(void) ; // creates the geometry for GEANT Float_t GetBigBox(Int_t index) ; virtual AliPHOSGeometry * GetGeometry() { return fGeom ; } - virtual void Init(void) ; // does nothing + virtual void Init(void) ; // does nothing Int_t IsVersion(void) const { return -1 ; } - void MakeBranch(Option_t* opt) ; - RecParticlesList * RecParticles() { return fRecParticles ; } // gets TClonesArray of reconstructed particles + void MakeBranch(Option_t* opt) ; + Double_t MakeEnergy(const Double_t energy) ; // makes the detected energy + void MakeRecParticle(AliPHOSFastRecParticle & rp) ; // makes a reconstructes particle from primary + Int_t MakeType(const Text_t * name) ; // gets the detected type of particle + FastRecParticlesList * FastRecParticles() { return fFastRecParticles ; } // gets TClonesArray of reconstructed particles void SetBigBox(Int_t index, Float_t value) ; - virtual void StepManager(void) ; // does the tracking through PHOS and a preliminary digitalization + Double_t SigmaE(Double_t energy) ; // calulates the energy resolution at a given Energy + virtual void StepManager(void) ; // does the tracking through PHOS and a preliminary digitalization private: - Float_t fBigBoxX ; // main box containing all PHOS (EMC+PPSD) - Float_t fBigBoxY ; // main box containing all PHOS (EMC+PPSD) - Float_t fBigBoxZ ; // main box containing all PHOS (EMC+PPSD) - AliPHOSGeometry * fGeom ; // geometry definition - Int_t fNRecParticles ; // number of detected particles - RecParticlesList * fRecParticles ; // list of detected particles + Float_t fBigBoxX ; // main box containing all PHOS (EMC+PPSD) + Float_t fBigBoxY ; // main box containing all PHOS (EMC+PPSD) + Float_t fBigBoxZ ; // main box containing all PHOS (EMC+PPSD) + FastRecParticlesList * fFastRecParticles ; // list of particles modified by the response function + AliPHOSGeometry * fGeom ; // geometry definition + Int_t fNRecParticles ; // number of detected particles + TRandom fRan ; // random number generator + Double_t fResPara1 ; // parameter for the energy resolution dependence ; + Double_t fResPara2 ; // parameter for the energy resolution dependence ; + Double_t fResPara3 ; // parameter for the energy resolution dependence ; + ClassDef(AliPHOSvFast,1) // PHOS main class , version for fast simulation diff --git a/PHOS/Makefile b/PHOS/Makefile index 20196e96e27..2bdde88b0c6 100644 --- a/PHOS/Makefile +++ b/PHOS/Makefile @@ -17,7 +17,7 @@ SRCS = AliPHOS.cxx AliPHOSv0.cxx AliPHOSv1.cxx AliPHOSHit.cxx \ AliPHOSReconstructioner.cxx AliPHOSTrackSegment.cxx \ AliPHOSTrackSegmentMaker.cxx AliPHOSTrackSegmentMakerv1.cxx \ AliPHOSRecParticle.cxx AliPHOSPID.cxx AliPHOSPIDv1.cxx \ - AliPHOSAnalyze.cxx AliPHOSvFast.cxx + AliPHOSAnalyze.cxx AliPHOSvFast.cxx AliPHOSFastRecParticle.cxx # C++ Headers diff --git a/PHOS/PHOSLinkDef.h b/PHOS/PHOSLinkDef.h index 523df102da0..2f6eea0635e 100644 --- a/PHOS/PHOSLinkDef.h +++ b/PHOS/PHOSLinkDef.h @@ -9,6 +9,7 @@ #pragma link C++ class AliPHOSClusterizerv1 ; #pragma link C++ class AliPHOSDigit ; #pragma link C++ class AliPHOSEmcRecPoint- ; +#pragma link C++ class AliPHOSFastRecParticle ; #pragma link C++ class AliPHOSGeometry ; #pragma link C++ class AliPHOSHit ; #pragma link C++ class AliPHOSLink ; -- 2.39.3