X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=PHOS%2FAliPHOSRecParticle.cxx;h=0bf30b95ff0af907a4e5853a1342a7337bfdc958;hb=09b20ad1c29952cef09057dbfdfdb134149c5127;hp=d42a13e3ff777381a0ad89ae99dd146722aced50;hpb=a73f33f08284d11550deec9af806219953d782cb;p=u%2Fmrichter%2FAliRoot.git diff --git a/PHOS/AliPHOSRecParticle.cxx b/PHOS/AliPHOSRecParticle.cxx index d42a13e3ff7..0bf30b95ff0 100644 --- a/PHOS/AliPHOSRecParticle.cxx +++ b/PHOS/AliPHOSRecParticle.cxx @@ -12,44 +12,52 @@ * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ - +/* $Id$ */ //_________________________________________________________________________ -// Reconstructed Particle -//*-- Y. Schutz: SUBATECH -////////////////////////////////////////////////////////////////////////////// +// A Reconstructed Particle in PHOS +// To become a general class of AliRoot ? +// Why should I put meaningless comments +// just to satisfy +// the code checker +// +//*-- Author: Yves Schutz (SUBATECH) + // --- ROOT system --- // --- Standard library --- -// --- AliRoot header files --- +// --- AliRoot header files --- #include "AliPHOSRecParticle.h" -#include "TPad.h" - -ClassImp(AliPHOSRecParticle) - +#include "AliPHOSGetter.h" +#include "AliPHOSGeometry.h" +#include "AliLog.h" //____________________________________________________________________________ - AliPHOSRecParticle::AliPHOSRecParticle(AliPHOSTrackSegment * ts) +AliPHOSRecParticle::AliPHOSRecParticle(): + fPHOSTrackSegment(0), + fDebug(kFALSE), + fPos() { // ctor - - fPHOSTrackSegment = new AliPHOSTrackSegment(*ts) ; - fE = ts->GetEnergy() ; - TVector3 momdir = ts->GetMomentumDirection() ; - fPx = fE * momdir.X() ; - fPy = fE * momdir.Y() ; - fPz = fE * momdir.Z() ; - fType = kUNDEFINED ; - + const Int_t nSPECIES = AliPID::kSPECIESN; + for(Int_t i = 0; iXtoAbsPixel(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; +Int_t AliPHOSRecParticle::GetNPrimariesToRecParticles() const +{ + // Get the number of primaries at the origine of the RecParticle + Int_t rv = 0 ; + AliPHOSGetter * gime = AliPHOSGetter::Instance() ; + Int_t emcRPindex = dynamic_cast(gime->TrackSegments()->At(GetPHOSTSIndex()))->GetEmcIndex(); + dynamic_cast(gime->EmcRecPoints()->At(emcRPindex))->GetPrimaries(rv) ; + return rv ; } -//___________________________________________________________________________ - void AliPHOSRecParticle::Draw(Option_t *option) - { - // Draw this AliPHOSRecParticle with its current attributes - - AppendPad(option); - } - -//______________________________________________________________________________ -void AliPHOSRecParticle::ExecuteEvent(Int_t event, Int_t px, Int_t py) +//____________________________________________________________________________ +const TParticle * AliPHOSRecParticle::GetPrimary() const { - // Execute action corresponding to one event - // This member function is called when a AliPHOSRecParticle is clicked with the locator - // + // Get the primary particle at the origine of the RecParticle and + // which has deposited the largest energy in SDigits + AliPHOSGetter * gime = AliPHOSGetter::Instance() ; + if (!gime) + Error("GetPrimary", "Getter not yet instantiated") ; + gime->Event(gime->EventNumber(), "SRTPX") ; + if(GetNPrimaries() == 0) + return 0 ; + if(GetNPrimaries() == 1) + return GetPrimary(0) ; + Int_t AbsId = 0; + Int_t module ; + const AliPHOSGeometry * geom = gime->PHOSGeometry() ; + Double_t x,z ; +//DP to be fixed: Why do we use this method here??? M.B. use RecPoint??? + Double_t vtx[3]={0.,0.,0.} ; + geom->ImpactOnEmc(vtx,static_cast(Theta()),static_cast(Phi()), module,z,x); + Int_t amp = 0 ; + Int_t iPrim=-1 ; + if(module != 0){ + geom->RelPosToAbsId(module,x,z,AbsId) ; + TClonesArray * sdigits = gime->SDigits() ; + AliPHOSDigit * sdig ; - if (!gPad->IsEditable()) - return ; + for(Int_t i = 0 ; i < sdigits->GetEntriesFast() ; i++){ + sdig = static_cast(sdigits->At(i)) ; + if((sdig->GetId() == AbsId)){ + if((sdig->GetAmp() > amp) && (sdig->GetNprimary())){ + amp = sdig->GetAmp() ; + iPrim = sdig->GetPrimary(1) ; + } + // do not scan rest of list + if(sdig->GetId() > AbsId) + continue ; + } + } + } + if(iPrim >= 0) + return gime->Primary(iPrim) ; + else + return 0 ; +} + +//____________________________________________________________________________ +Int_t AliPHOSRecParticle::GetPrimaryIndex() const +{ + // Get the primary track index in TreeK which deposits the most energy + // in Digits which forms EmcRecPoint, which produces TrackSegment, + // which the RecParticle is created from - 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 ; - } + AliPHOSGetter * gime = AliPHOSGetter::Instance() ; + if (!gime) + AliError(Form("Getter not yet instantiated")) ; + //PH gime->Event(gime->EventNumber(), "DRTX") ; + gime->Event(gime->EventNumber(), "DRT") ; - case kButton1Up: { - delete clustertext ; - clustertext = 0 ; - gPad->Update() ; - break ; + // Get TrackSegment corresponding to this RecParticle + AliPHOSTrackSegment *ts = gime->TrackSegment(fPHOSTrackSegment); + + // Get EmcRecPoint corresponding to this TrackSegment + Int_t emcRecPointIndex = ts->GetEmcIndex(); + + AliPHOSEmcRecPoint *emcRecPoint = gime->EmcRecPoint(emcRecPointIndex); + + // Get the list of digits forming this EmcRecParticle + Int_t nDigits = emcRecPoint->GetDigitsMultiplicity(); + Int_t *digitList = emcRecPoint->GetDigitsList(); + + // Find the digit with maximum amplitude + AliPHOSDigit *digit = 0; + Int_t maxAmp = 0; + Int_t bestDigitIndex = -1; + for (Int_t iDigit=0; iDigitDigit(digitList[iDigit]); + if (digit->GetAmp() > maxAmp) { + maxAmp = digit->GetAmp(); + bestDigitIndex = iDigit; + } } + if (bestDigitIndex>-1) + digit = gime->Digit(digitList[bestDigitIndex]); + if (digit==0) return -12345; + - } + // Get the list of primary tracks producing this digit + // and find which track has more track energy. + //Int_t nPrimary = digit->GetNprimary(); + //TParticle *track = 0; + //Double_t energyEM = 0; + //Double_t energyHadron = 0; + //Int_t trackEM = -1; + //Int_t trackHadron = -1; + //for (Int_t iPrim=0; iPrimGetPrimary(iPrim+1); + // if (iPrimary == -1 || TMath::Abs(iPrimary)>10000000) + // continue ; //PH 10000000 is the shift of the track + // //PH indexes in the underlying event + // track = gime->Primary(iPrimary); + // Int_t pdgCode = track->GetPdgCode(); + // Double_t energy = track->Energy(); + // if (pdgCode==22 || TMath::Abs(pdgCode)==11) { + // if (energy > energyEM) { + // energyEM = energy; + // trackEM = iPrimary; + // } + // } + // else { + // if (energy > energyHadron) { + // energyHadron = energy; + // trackHadron = iPrimary; + // } + // } + //} + // Preferences are given to electromagnetic tracks + //if (trackEM != -1) return trackEM; // track is gamma or e+- + //if (trackHadron != -1) return trackHadron; // track is hadron + //return -12345; // no track found :( -} -//____________________________________________________________________________ -TString AliPHOSRecParticle::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 ; + // Get the list of hits producing this digit, + // find which hit has deposited more energy + // and find the primary track. + + AliPHOSHit *hit = 0; + TClonesArray *hits = gime->Hits(); + if (hits==0) return -12345; + + Double_t maxedep = 0; + Int_t maxtrack = -1; + Int_t nHits = hits ->GetEntries(); + Int_t id = digit->GetId(); + + for (Int_t iHit=0; iHitHit(iHit); + if(hit->GetId() == id){ + Double_t edep = hit->GetEnergy(); + Int_t track = hit->GetPrimary(); + if(edep > maxedep){ + maxedep = edep; + maxtrack = track; + } + } } - return name ; + + if (maxtrack != -1) return maxtrack; // track is hadron + return -12345; // no track found :( } -//______________________________________________________________________________ -void AliPHOSRecParticle::Paint(Option_t *) +//____________________________________________________________________________ +const TParticle * AliPHOSRecParticle::GetPrimary(Int_t index) const { -// 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,"") ; + // Get one of the primary particles at the origine of the RecParticle + if ( index > GetNPrimariesToRecParticles() ) { + if (fDebug) + Warning("GetPrimary", "AliPHOSRecParticle::GetPrimary -> %d is larger that the number of primaries %d", + index, GetNPrimaries()) ; + return 0 ; + } + else { + Int_t dummy ; + AliPHOSGetter * gime = AliPHOSGetter::Instance() ; + + Int_t emcRPindex = dynamic_cast(gime->TrackSegments()->At(GetPHOSTSIndex()))->GetEmcIndex(); + Int_t primaryindex = dynamic_cast(gime->EmcRecPoints()->At(emcRPindex))->GetPrimaries(dummy)[index] ; + return gime->Primary(primaryindex) ; + } + // return 0 ; } //____________________________________________________________________________ -void AliPHOSRecParticle::Print() +void AliPHOSRecParticle::SetPID(Int_t type, Float_t weight) { - cout << "AliPHOSRecParticle > " << "type is " << Name() << endl - << " " << "Energy = " << fE << endl - << " " << "Px = " << fPx << endl - << " " << "Py = " << fPy << endl - << " " << "Pz = " << fPz << endl ; + // Set the probability densities that this reconstructed particle + // has a type of i: + // i particle types + // ---------------------- + // 0 electron + // 1 muon + // 2 pi+- + // 3 K+- + // 4 p/pbar + // 5 photon + // 6 pi0 at high pt + // 7 neutron + // 8 K0L + // 9 Conversion electron + + fPID[type] = weight ; }