X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=PHOS%2FAliPHOSAnalyze.cxx;h=d1c00684761fc915d1b76a3f34a435f0706bb3b9;hb=a19e485abaadda1f8d4ac6c0915e1714b21df84a;hp=853ce1b29c0b0bf74f1111caa3f8142abcc056fe;hpb=afa51c4ecd8a3a3b5dad7dccfa4cfef0132ace50;p=u%2Fmrichter%2FAliRoot.git diff --git a/PHOS/AliPHOSAnalyze.cxx b/PHOS/AliPHOSAnalyze.cxx index 853ce1b29c0..d1c00684761 100644 --- a/PHOS/AliPHOSAnalyze.cxx +++ b/PHOS/AliPHOSAnalyze.cxx @@ -28,8 +28,7 @@ // Contamination(...) - calculates contamination of the photon spectrum and // pobability of reconstruction of several primaries as // kGAMMA,kELECTRON etc. -// -// User Case: +//// User Case: // root [0] AliPHOSAnalyze * a = new AliPHOSAnalyze("galice.root") // // set the file you want to analyse // root [1] a->DrawRecon(1,3) @@ -70,47 +69,60 @@ #include "TH2.h" #include "TParticle.h" #include "TClonesArray.h" -#include "TTree.h" #include "TMath.h" #include "TROOT.h" -#include "TFolder.h" // --- Standard library --- -#include - // --- AliRoot header files --- -#include "AliRun.h" -#include "AliPHOSv1.h" +#include "AliLog.h" +#include "AliStack.h" +#include "AliPHOSGeometry.h" #include "AliPHOSAnalyze.h" #include "AliPHOSDigit.h" #include "AliPHOSSDigitizer.h" +#include "AliPHOSEmcRecPoint.h" +#include "AliPHOSCpvRecPoint.h" #include "AliPHOSTrackSegment.h" #include "AliPHOSRecParticle.h" -#include "AliPHOSCpvRecPoint.h" -#include "AliPHOSGetter.h" +#include "AliPHOSLoader.h" ClassImp(AliPHOSAnalyze) //____________________________________________________________________________ - AliPHOSAnalyze::AliPHOSAnalyze() +AliPHOSAnalyze::AliPHOSAnalyze(): + fCorrection(1.2), //Value calculated for default parameters of reconstruction + fEvt(0), + ffileName(), + fRunLoader(0) { // default ctor (useless) - fCorrection = 1.2 ; //Value calculated for default parameters of reconstruction } //____________________________________________________________________________ -AliPHOSAnalyze::AliPHOSAnalyze(Text_t * fileName) +AliPHOSAnalyze::AliPHOSAnalyze(Text_t * fileName): + fCorrection(1.05), //Value calculated for default parameters of reconstruction + fEvt(0), + ffileName(fileName), + fRunLoader(0) { // ctor: analyze events from root file "name" - ffileName = fileName ; - fCorrection = 1.05 ; //Value calculated for default parameters of reconstruction + fRunLoader = AliRunLoader::Open(fileName,"AliPHOSAnalyze"); + if (fRunLoader == 0x0) + { + AliError(Form("Error Loading session")); + } } //____________________________________________________________________________ -AliPHOSAnalyze::AliPHOSAnalyze(const AliPHOSAnalyze & ana) +AliPHOSAnalyze::AliPHOSAnalyze(const AliPHOSAnalyze & ana): + TObject(ana), + fCorrection(0.), + fEvt(0), + ffileName(), + fRunLoader(0) { // copy ctor ( (AliPHOSAnalyze &)ana ).Copy(*this) ; @@ -123,19 +135,32 @@ AliPHOSAnalyze::~AliPHOSAnalyze() } //____________________________________________________________________________ -void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,const char* branchTitle){ +void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod){ //Draws pimary particles and reconstructed //digits, RecPoints, RecPartices etc //for event Nevent in the module Nmod. - //========== Create ObjectGetter - AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ; - if(Nevent >= gAlice->TreeE()->GetEntries() ) { - cout << "There is no event " << Nevent << ", only " << gAlice->TreeE()->GetEntries() << "events available " <(fRunLoader->GetLoader("PHOSLoader")); + if ( gime == 0 ) + { + AliError(Form("Could not obtain the Loader object !")); + return ; + } + + + if(Nevent >= fRunLoader->GetNumberOfEvents() ) { + AliError(Form("There is no event %d only %d events available", Nevent, fRunLoader->GetNumberOfEvents() )) ; return ; } const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ; - gime->Event(Nevent); + fRunLoader->GetEvent(Nevent); Int_t nx = phosgeom->GetNPhi() ; Int_t nz = phosgeom->GetNZ() ; @@ -181,14 +206,19 @@ void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,c //Plot Primary Particles + + if (fRunLoader->Stack() == 0x0) fRunLoader->LoadKinematics("READ"); + + const TParticle * primary ; Int_t iPrimary ; - for ( iPrimary = 0 ; iPrimary < gime->NPrimaries() ; iPrimary++) + for ( iPrimary = 0 ; iPrimary < fRunLoader->Stack()->GetNprimary() ; iPrimary++) { - primary = gime->Primary(iPrimary) ; - Int_t primaryType = primary->GetPdgCode() ; + primary = fRunLoader->Stack()->Particle(iPrimary); + + Int_t primaryType = primary->GetPdgCode(); // if( (primaryType == 211)||(primaryType == -211)||(primaryType == 2212)||(primaryType == -2212) -// ||(primaryType == 11)||(primaryType == -11) ) { +// ||(primaryType == 11)||(primaryType == -11) ) { // Int_t moduleNumber ; // Double_t primX, primZ ; // phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; @@ -221,25 +251,26 @@ void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,c if(sdigits){ for(iSDigit = 0; iSDigit < sdigits->GetEntriesFast() ; iSDigit++) { - sdigit = (AliPHOSDigit *) sdigits->At(iSDigit) ; - Int_t relid[4]; - phosgeom->AbsToRelNumbering(sdigit->GetId(), relid) ; - Float_t x,z ; - phosgeom->RelPosInModule(relid,x,z) ; - Float_t e = gime->SDigitizer()->Calibrate(sdigit->GetAmp()) ; - nsdig[relid[0]-1]++ ; - if(relid[0]==Nmod){ - if(relid[1]==0) //EMC - emcSdigits->Fill(x,z,e) ; - if( relid[1]!=0 ) - cpvSdigits->Fill(x,z,e) ; - } + sdigit = (AliPHOSDigit *) sdigits->At(iSDigit) ; + Int_t relid[4]; + phosgeom->AbsToRelNumbering(sdigit->GetId(), relid) ; + Float_t x,z ; + phosgeom->RelPosInModule(relid,x,z); + AliPHOSSDigitizer* sd = dynamic_cast(gime->SDigitizer()); + Float_t e = sd->Calibrate(sdigit->GetAmp()) ; + nsdig[relid[0]-1]++ ; + if(relid[0]==Nmod){ + if(relid[1]==0) //EMC + emcSdigits->Fill(x,z,e) ; + if( relid[1]!=0 ) + cpvSdigits->Fill(x,z,e) ; + } } } - cout << "Number of EMC + CPV SDigits per module: " <GetEntriesFast(); iDigit++) { - digit = (AliPHOSDigit *) digits->At(iDigit) ; - Int_t relid[4]; - phosgeom->AbsToRelNumbering(digit->GetId(), relid) ; - Float_t x,z ; - phosgeom->RelPosInModule(relid,x,z) ; - Float_t e = gime->SDigitizer()->Calibrate(digit->GetAmp()) ; - if(relid[0]==Nmod){ - if(relid[1]==0) //EMC - emcDigits->Fill(x,z,e) ; - if( relid[1]!=0 ) - cpvDigits->Fill(x,z,e) ; - } + digit = (AliPHOSDigit *) digits->At(iDigit) ; + Int_t relid[4]; + phosgeom->AbsToRelNumbering(digit->GetId(), relid) ; + Float_t x,z ; + phosgeom->RelPosInModule(relid,x,z) ; + AliPHOSSDigitizer* sd = dynamic_cast(gime->SDigitizer()); + Float_t e = sd->Calibrate(digit->GetAmp()) ; + if(relid[0]==Nmod){ + if(relid[1]==0) //EMC + emcDigits->Fill(x,z,e) ; + if( relid[1]!=0 ) + cpvDigits->Fill(x,z,e) ; + } } } @@ -272,8 +304,8 @@ void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,c for(irecp = 0; irecp < emcrp->GetEntriesFast() ; irecp ++){ AliPHOSEmcRecPoint * emc = (AliPHOSEmcRecPoint *) emcrp->At(irecp) ; if(emc->GetPHOSMod()==Nmod){ - emc->GetLocalPosition(pos) ; - emcRecPoints->Fill(pos.X(),pos.Z(),emc->GetEnergy()); + emc->GetLocalPosition(pos) ; + emcRecPoints->Fill(pos.X(),pos.Z(),emc->GetEnergy()); } } } @@ -283,8 +315,8 @@ void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,c for(irecp = 0; irecp < cpvrp->GetEntriesFast() ; irecp ++){ AliPHOSRecPoint * cpv = (AliPHOSCpvRecPoint *) cpvrp->At(irecp) ; if(cpv->GetPHOSMod()==Nmod){ - cpv->GetLocalPosition(pos) ; - cpvRecPoints->Fill(pos.X(),pos.Z(),cpv->GetEnergy()); + cpv->GetLocalPosition(pos) ; + cpvRecPoints->Fill(pos.X(),pos.Z(),cpv->GetEnergy()); } } } @@ -297,48 +329,48 @@ void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,c if(rp && ts && emcrp) { for(iRecParticle = 0; iRecParticle < rp->GetEntriesFast() ; iRecParticle++ ) { - recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ; - Int_t moduleNumberRec ; - Double_t recX, recZ ; - phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ; - if(moduleNumberRec == Nmod){ - - Double_t minDistance = 5. ; - Int_t closestPrimary = -1 ; - - //extract list of primaries: it is stored at EMC RecPoints - Int_t emcIndex = ((AliPHOSTrackSegment *) ts->At(recParticle->GetPHOSTSIndex()))->GetEmcIndex() ; - Int_t numberofprimaries ; - Int_t * listofprimaries = ((AliPHOSRecPoint*) emcrp->At(emcIndex))->GetPrimaries(numberofprimaries) ; - Int_t index ; - const TParticle * primary ; - Double_t distance = minDistance ; - - for ( index = 0 ; index < numberofprimaries ; index++){ - primary = gime->Primary(listofprimaries[index]) ; - Int_t moduleNumber ; - Double_t primX, primZ ; - phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; - if(moduleNumberRec == moduleNumber) - distance = TMath::Sqrt((recX-primX)*(recX-primX)+(recZ-primZ)*(recZ-primZ) ) ; - if(minDistance > distance) - { - minDistance = distance ; - closestPrimary = listofprimaries[index] ; - } - } - - if(closestPrimary >=0 ){ - - Int_t primaryType = gime->Primary(closestPrimary)->GetPdgCode() ; - - if(primaryType==22) - recPhot->Fill(recZ,recX,recParticle->Energy()) ; -// else -// if(primaryType==-2112) -// recNbar->Fill(recZ,recX,recParticle->Energy()) ; - } - } + recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ; + Int_t moduleNumberRec ; + Double_t recX, recZ ; + phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ; + if(moduleNumberRec == Nmod){ + + Double_t minDistance = 5. ; + Int_t closestPrimary = -1 ; + + //extract list of primaries: it is stored at EMC RecPoints + Int_t emcIndex = ((AliPHOSTrackSegment *) ts->At(recParticle->GetPHOSTSIndex()))->GetEmcIndex() ; + Int_t numberofprimaries ; + Int_t * listofprimaries = ((AliPHOSRecPoint*) emcrp->At(emcIndex))->GetPrimaries(numberofprimaries) ; + Int_t index ; + const TParticle * primary ; + Double_t distance = minDistance ; + + for ( index = 0 ; index < numberofprimaries ; index++){ + primary = fRunLoader->Stack()->Particle(listofprimaries[index]) ; + Int_t moduleNumber ; + Double_t primX, primZ ; + phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; + if(moduleNumberRec == moduleNumber) + distance = TMath::Sqrt((recX-primX)*(recX-primX)+(recZ-primZ)*(recZ-primZ) ) ; + if(minDistance > distance) + { + minDistance = distance ; + closestPrimary = listofprimaries[index] ; + } + } + + if(closestPrimary >=0 ){ + + Int_t primaryType = fRunLoader->Stack()->Particle(closestPrimary)->GetPdgCode() ; + + if(primaryType==22) + recPhot->Fill(recZ,recX,recParticle->Energy()) ; +// else +// if(primaryType==-2112) +// recNbar->Fill(recZ,recX,recParticle->Energy()) ; + } + } } } @@ -357,52 +389,114 @@ void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,c void AliPHOSAnalyze::Ls(){ //lists branches and titles of PHOS-related branches of TreeR, TreeD, TreeS - AliPHOSGetter::GetInstance(ffileName.Data()) ; + if (fRunLoader == 0x0) + { + AliError(Form("Error Loading session")); + return; + } + + AliPHOSLoader* gime = dynamic_cast(fRunLoader->GetLoader("PHOSLoader")); + if ( gime == 0 ) + { + AliError(Form("Could not obtain the Loader object !")); + return ; + } + Int_t ibranch; TObjArray * branches; - branches = gAlice->TreeS()->GetListOfBranches() ; + if (gime->TreeS() == 0x0) + { + if (gime->LoadSDigits("READ")) + { + AliError(Form("Problems with loading summable digits")); + return; + } + } + branches = gime->TreeS()->GetListOfBranches() ; - cout << "TreeS: " << endl ; + TString message ; + message = "TreeS:\n" ; for(ibranch = 0;ibranch GetEntries();ibranch++){ TBranch * branch=(TBranch *) branches->At(ibranch) ; - if(strstr(branch->GetName(),"PHOS") ) - cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ; + if(strstr(branch->GetName(),"PHOS") ){ + message += " " ; + message += branch->GetName() ; + message += " " ; + message += branch->GetTitle() ; + message += "\n" ; + } } - cout << endl ; - - branches = gAlice->TreeD()->GetListOfBranches() ; + if (gime->TreeD() == 0x0) + { + if (gime->LoadDigits("READ")) + { + AliError(Form("Problems with loading digits")); + return; + } + } + + branches = gime->TreeD()->GetListOfBranches() ; - cout << "TreeD: " << endl ; + message += "TreeD:\n" ; for(ibranch = 0;ibranch GetEntries();ibranch++){ TBranch * branch=(TBranch *) branches->At(ibranch) ; - if(strstr(branch->GetName(),"PHOS") ) - cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ; + if(strstr(branch->GetName(),"PHOS") ) { + message += " "; + message += branch->GetName() ; + message += " " ; + message += branch->GetTitle() ; + message +="\n" ; + } } - cout << endl ; + if (gime->TreeR() == 0x0) + { + if (gime->LoadRecPoints("READ")) + { + AliError(Form("Problems with loading rec points")); + return; + } + } - branches = gAlice->TreeR()->GetListOfBranches() ; + branches = gime->TreeR()->GetListOfBranches() ; - cout << "TreeR: " << endl ; + message += "TreeR: \n" ; for(ibranch = 0;ibranch GetEntries();ibranch++){ TBranch * branch=(TBranch *) branches->At(ibranch) ; - if(strstr(branch->GetName(),"PHOS") ) - cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ; + if(strstr(branch->GetName(),"PHOS") ) { + message += " " ; + message += branch->GetName() ; + message += " " ; + message += branch->GetTitle() ; + message += "\n" ; + } } - cout << endl ; - - + AliInfo(Form(message.Data())) ; } //____________________________________________________________________________ - void AliPHOSAnalyze::InvariantMass(const char* branchTitle) + void AliPHOSAnalyze::InvariantMass() { // Calculates Real and Mixed invariant mass distributions - AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ; - + if (fRunLoader == 0x0) + { + AliError(Form("Error Loading session")); + return; + } + + AliPHOSLoader* gime = dynamic_cast(fRunLoader->GetLoader("PHOSLoader")); + if ( gime == 0 ) + { + AliError(Form("Could not obtain the Loader object !")); + return ; + } + + gime->LoadRecParticles("READ"); + Int_t nMixedEvents = 4 ; //# of events used for calculation of 'mixed' distribution - + + //opening file TFile * mfile = new TFile("invmass.root","update"); @@ -438,26 +532,34 @@ void AliPHOSAnalyze::Ls(){ //scan over all events Int_t event ; - Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ; + + + if (fRunLoader->TreeE() == 0x0) fRunLoader->LoadHeader(); + + + Int_t maxevent = (Int_t)fRunLoader->TreeE()->GetEntries(); // for(event = 0; event < gime->MaxEvent(); event++ ){ + + + for(event = 0; event < maxevent; event++ ){ - gime->Event(event,"R"); //will read only TreeR + fRunLoader->GetEvent(event); //will read only TreeR //copy EM RecParticles to the "total" list const AliPHOSRecParticle * recParticle ; Int_t iRecParticle ; TClonesArray * rp = gime->RecParticles() ; if(!rp){ - cout << "AliPHOSAnalyze::InvariantMass --> Can't find RecParticles " << endl ; + AliError(Form("Can't find RecParticles")) ; return ; } for(iRecParticle = 0; iRecParticle < rp->GetEntriesFast(); iRecParticle++ ) { - recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ; - if((recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)|| - (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW)) - new( (*allRecParticleList)[iRecPhot++] ) AliPHOSRecParticle(*recParticle) ; + recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ; + if((recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)|| + (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW)) + new( (*allRecParticleList)[iRecPhot++] ) AliPHOSRecParticle(*recParticle) ; } Int_t mevent = event%nMixedEvents ; //event number in the "mixed" cicle @@ -474,46 +576,46 @@ void AliPHOSAnalyze::Ls(){ Int_t nCurEvent = 0 ; for(irp1 = 0; irp1 < allRecParticleList->GetEntries()-1; irp1++){ - AliPHOSRecParticle * rp1 = (AliPHOSRecParticle *)allRecParticleList->At(irp1) ; - - for(irp2 = irp1+1; irp2 < allRecParticleList->GetEntries(); irp2++){ - AliPHOSRecParticle * rp2 = (AliPHOSRecParticle *)allRecParticleList->At(irp2) ; - - Double_t invMass ; - invMass = (rp1->Energy()+rp2->Energy())*(rp1->Energy()+rp2->Energy())- - (rp1->Px()+rp2->Px())*(rp1->Px()+rp2->Px())- - (rp1->Py()+rp2->Py())*(rp1->Py()+rp2->Py())- - (rp1->Pz()+rp2->Pz())*(rp1->Pz()+rp2->Pz()) ; - - if(invMass> 0) - invMass = TMath::Sqrt(invMass); - - Double_t pt ; - pt = TMath::Sqrt((rp1->Px()+rp2->Px() )*( rp1->Px()+rp2->Px() ) + - (rp1->Py()+rp2->Py() )*( rp1->Py()+rp2->Py() ) ); - - if(irp1 > nRecParticles[nCurEvent]) - nCurEvent++; - - if(irp2 <= nRecParticles[nCurEvent]){ //'Real' event - hRealEM->Fill(invMass,pt); - if((rp1->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)&& - (rp2->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST) ) - hRealPhot->Fill(invMass,pt); - } - else{ - hMixedEM->Fill(invMass,pt); - if((rp1->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)&& - (rp2->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST) ) - hMixedPhot->Fill(invMass,pt); - } //real-mixed - + AliPHOSRecParticle * rp1 = (AliPHOSRecParticle *)allRecParticleList->At(irp1) ; + + for(irp2 = irp1+1; irp2 < allRecParticleList->GetEntries(); irp2++){ + AliPHOSRecParticle * rp2 = (AliPHOSRecParticle *)allRecParticleList->At(irp2) ; + + Double_t invMass ; + invMass = (rp1->Energy()+rp2->Energy())*(rp1->Energy()+rp2->Energy())- + (rp1->Px()+rp2->Px())*(rp1->Px()+rp2->Px())- + (rp1->Py()+rp2->Py())*(rp1->Py()+rp2->Py())- + (rp1->Pz()+rp2->Pz())*(rp1->Pz()+rp2->Pz()) ; + + if(invMass> 0) + invMass = TMath::Sqrt(invMass); + + Double_t pt ; + pt = TMath::Sqrt((rp1->Px()+rp2->Px() )*( rp1->Px()+rp2->Px() ) + + (rp1->Py()+rp2->Py() )*( rp1->Py()+rp2->Py() ) ); + + if(irp1 > nRecParticles[nCurEvent]) + nCurEvent++; + + if(irp2 <= nRecParticles[nCurEvent]){ //'Real' event + hRealEM->Fill(invMass,pt); + if((rp1->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)&& + (rp2->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST) ) + hRealPhot->Fill(invMass,pt); + } + else{ + hMixedEM->Fill(invMass,pt); + if((rp1->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)&& + (rp2->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST) ) + hMixedPhot->Fill(invMass,pt); + } //real-mixed + } //loop over second rp }//loop over first rp //Make some cleanings for(Int_t index = 0; index < nMixedEvents; index ++) - nRecParticles[index] = 0 ; + nRecParticles[index] = 0 ; iRecPhot = 0 ; allRecParticleList->Clear() ; @@ -537,7 +639,7 @@ void AliPHOSAnalyze::Ls(){ } //____________________________________________________________________________ - void AliPHOSAnalyze::EnergyResolution(const char * branchTitle) + void AliPHOSAnalyze::EnergyResolution() { //fills two dimentional histo: energy of primary vs. energy of reconstructed @@ -561,34 +663,48 @@ void AliPHOSAnalyze::Ls(){ hEMEnergy = new TH2F("hEMEnergy", "Energy of EM with primary photon", 100, 0., 5., 100, 0., 5.); - AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ; - const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ; + if (fRunLoader == 0x0) + { + AliError(Form("Error Loading session")); + return; + } + + AliPHOSLoader* gime = dynamic_cast(fRunLoader->GetLoader("PHOSLoader")); + if ( gime == 0 ) + { + AliError(Form("Could not obtain the Loader object !")); + return ; + } + + + const AliPHOSGeometry * phosgeom = gime->PHOSGeometry(); Int_t ievent; - Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ; + Int_t maxevent = (Int_t)fRunLoader->TreeE()->GetEntries(); + + fRunLoader->LoadKinematics("READ"); + gime->LoadTracks("READ"); + for ( ievent=0; ievent < maxevent ; ievent++){ //read the current event - gime->Event(ievent) ; + fRunLoader->GetEvent(ievent) ; const AliPHOSRecParticle * recParticle ; Int_t iRecParticle ; TClonesArray * rp = gime->RecParticles() ; if(!rp) { - cout << "AliPHOSAnalyze::EnergyResolution --> Event " <TrackSegments() ; if(!ts) { - cout << "AliPHOSAnalyze::EnergyResolution --> Event " <EmcRecPoints() ; if(!emcrp){ - cout << "AliPHOSAnalyze::EnergyResolution --> Event " <Primary(listofprimaries[index]) ; - Int_t moduleNumber ; - Double_t primX, primZ ; - phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; - if(moduleNumberRec == moduleNumber) { - dX = recX - primX; - dZ = recZ - primZ; - distance = TMath::Sqrt(dX*dX + dZ*dZ) ; - if(minDistance > distance) { - minDistance = distance ; - dXmin = dX; - dZmin = dZ; - closestPrimary = listofprimaries[index] ; - } - } + + primary = fRunLoader->Stack()->Particle(listofprimaries[index]) ; + + Int_t moduleNumber ; + Double_t primX, primZ ; + phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; + if(moduleNumberRec == moduleNumber) { + dX = recX - primX; + dZ = recZ - primZ; + distance = TMath::Sqrt(dX*dX + dZ*dZ) ; + if(minDistance > distance) { + minDistance = distance ; + dXmin = dX; + dZmin = dZ; + closestPrimary = listofprimaries[index] ; + } + } } //if found primary, fill histograms if(closestPrimary >=0 ){ - const TParticle * primary = gime->Primary(closestPrimary) ; - if(primary->GetPdgCode() == 22){ - hAllEnergy->Fill(primary->Energy(), recParticle->Energy()) ; - if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST){ - hPhotEnergy->Fill(primary->Energy(), recParticle->Energy() ) ; - hEMEnergy->Fill(primary->Energy(), recParticle->Energy() ) ; - } - else - if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW) - hEMEnergy->Fill(primary->Energy(), recParticle->Energy() ) ; - } + const TParticle * primary = fRunLoader->Stack()->Particle(closestPrimary) ; + if(primary->GetPdgCode() == 22){ + hAllEnergy->Fill(primary->Energy(), recParticle->Energy()) ; + if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST){ + hPhotEnergy->Fill(primary->Energy(), recParticle->Energy() ) ; + hEMEnergy->Fill(primary->Energy(), recParticle->Energy() ) ; + } + else + if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW) + hEMEnergy->Fill(primary->Energy(), recParticle->Energy() ) ; + } } } } @@ -660,7 +778,7 @@ void AliPHOSAnalyze::Ls(){ } //____________________________________________________________________________ -void AliPHOSAnalyze::PositionResolution(const char * branchTitle) +void AliPHOSAnalyze::PositionResolution() { //fills two dimentional histo: energy vs. primary - reconstructed distance @@ -680,50 +798,60 @@ void AliPHOSAnalyze::PositionResolution(const char * branchTitle) hAllPosition = (TH2F*)pfile->Get("hAllPosition"); if(hAllPosition == 0) hAllPosition = new TH2F("hAllPosition", - "Position of any RP with primary photon",100, 0., 5., 100, 0., 5.); + "Position of any RP with primary photon",100, 0., 5., 100, 0., 5.); hPhotPosition= (TH2F*)pfile->Get("hPhotPosition"); if(hPhotPosition == 0) hPhotPosition = new TH2F("hPhotPosition", - "Position of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.); + "Position of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.); hEMPosition= (TH2F*)pfile->Get("hEMPosition") ; if(hEMPosition == 0) hEMPosition = new TH2F("hEMPosition", - "Position of EM with primary photon", 100, 0., 5., 100, 0., 5.); - hAllPositionX = (TH1F*)pfile->Get("hAllPositionX") ; + "Position of EM with primary photon", 100, 0., 5., 100, 0., 5.); + hAllPositionX = (TH1F*)pfile->Get("hAllPositionX") ; if(hAllPositionX == 0) hAllPositionX = new TH1F("hAllPositionX", - "Delta X of any RP with primary photon",100, -2., 2.); + "Delta X of any RP with primary photon",100, -2., 2.); hAllPositionZ =(TH1F*) pfile->Get("hAllPositionZ") ; if(hAllPositionZ == 0) hAllPositionZ = new TH1F("hAllPositionZ", - "Delta X of any RP with primary photon",100, -2., 2.); + "Delta X of any RP with primary photon",100, -2., 2.); + if (fRunLoader == 0x0) + { + AliError(Form("Error Loading session")); + return; + } + + AliPHOSLoader* gime = dynamic_cast(fRunLoader->GetLoader("PHOSLoader")); + if ( gime == 0 ) + { + AliError(Form("Could not obtain the Loader object !")); + return ; + } + + if (fRunLoader->TreeE() == 0x0) fRunLoader->LoadHeader(); - AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ; const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ; Int_t ievent; - Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ; + Int_t maxevent = (Int_t)fRunLoader->TreeE()->GetEntries() ; for ( ievent=0; ievent < maxevent ; ievent++){ //read the current event - gime->Event(ievent) ; + fRunLoader->GetEvent(ievent) ; TClonesArray * rp = gime->RecParticles() ; if(!rp) { - cout << "AliPHOSAnalyze::PositionResolution --> Event " <TrackSegments() ; if(!ts) { - cout << "AliPHOSAnalyze::PositionResolution --> Event " <EmcRecPoints() ; if(!emcrp){ - cout << "AliPHOSAnalyze::PositionResolution --> Event " <Primary(listofprimaries[index]) ; - Int_t moduleNumber ; - Double_t primX, primZ ; - phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; - if(moduleNumberRec == moduleNumber) { - dX = recX - primX; - dZ = recZ - primZ; - distance = TMath::Sqrt(dX*dX + dZ*dZ) ; - if(minDistance > distance) { - minDistance = distance ; - dXmin = dX; - dZmin = dZ; - closestPrimary = listofprimaries[index] ; - } - } + primary = fRunLoader->Stack()->Particle(listofprimaries[index]) ; + Int_t moduleNumber ; + Double_t primX, primZ ; + phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; + if(moduleNumberRec == moduleNumber) { + dX = recX - primX; + dZ = recZ - primZ; + distance = TMath::Sqrt(dX*dX + dZ*dZ) ; + if(minDistance > distance) { + minDistance = distance ; + dXmin = dX; + dZmin = dZ; + closestPrimary = listofprimaries[index] ; + } + } } //if found primary, fill histograms if(closestPrimary >=0 ){ - const TParticle * primary = gime->Primary(closestPrimary) ; - if(primary->GetPdgCode() == 22){ - hAllPosition->Fill(primary->Energy(), minDistance) ; - hAllPositionX->Fill(primary->Energy(), dX) ; - hAllPositionZ->Fill(primary->Energy(), dZ) ; - if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST){ - hPhotPosition->Fill(primary->Energy(), minDistance ) ; - hEMPosition->Fill(primary->Energy(), minDistance ) ; - } - else - if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW) - hEMPosition->Fill(primary->Energy(), minDistance ) ; - } + const TParticle * primary = fRunLoader->Stack()->Particle(closestPrimary) ; + if(primary->GetPdgCode() == 22){ + hAllPosition->Fill(primary->Energy(), minDistance) ; + hAllPositionX->Fill(primary->Energy(), dX) ; + hAllPositionZ->Fill(primary->Energy(), dZ) ; + if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST){ + hPhotPosition->Fill(primary->Energy(), minDistance ) ; + hEMPosition->Fill(primary->Energy(), minDistance ) ; + } + else + if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW) + hEMPosition->Fill(primary->Energy(), minDistance ) ; + } } } } @@ -804,7 +932,7 @@ void AliPHOSAnalyze::PositionResolution(const char * branchTitle) } //____________________________________________________________________________ -void AliPHOSAnalyze::Contamination(const char* RecPointsTitle){ +void AliPHOSAnalyze::Contamination(){ // fills spectra of primary photons and several kinds of // reconstructed particles, so that analyzing them one can // estimate conatmination, efficiency of registration etc. @@ -910,31 +1038,41 @@ void AliPHOSAnalyze::Contamination(const char* RecPointsTitle){ - AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),RecPointsTitle) ; + if (fRunLoader == 0x0) + { + AliError(Form("Error Loading session")); + return; + } + + AliPHOSLoader* gime = dynamic_cast(fRunLoader->GetLoader("PHOSLoader")); + if ( gime == 0 ) + { + AliError(Form("Could not obtain the Loader object !")); + return ; + } + + if (fRunLoader->TreeE() == 0x0) fRunLoader->LoadHeader(); const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ; Int_t ievent; - Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ; + Int_t maxevent = (Int_t)fRunLoader->TreeE()->GetEntries() ; for ( ievent=0; ievent < maxevent ; ievent++){ - gime->Event(ievent) ; + fRunLoader->GetEvent(ievent) ; TClonesArray * rp = gime->RecParticles() ; if(!rp) { - cout << "AliPHOSAnalyze::Contamination --> Event " <TrackSegments() ; if(!ts) { - cout << "AliPHOSAnalyze::Contamination --> Event " <EmcRecPoints() ; if(!emcrp){ - cout << "AliPHOSAnalyze::Contamination --> Event " <NPrimaries() ; iPrimary++){ - primary = gime->Primary(iPrimary) ; + for( iPrimary = 0 ; iPrimary < fRunLoader->Stack()->GetNprimary() ; iPrimary++){ + primary = fRunLoader->Stack()->Particle(iPrimary) ; Int_t primaryType = primary->GetPdgCode() ; if( primaryType == 22 ) { - //check, if photons folls onto PHOS - Int_t moduleNumber ; - Double_t primX, primZ ; - phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; - if(moduleNumber) - hPrimary->Fill(primary->Energy()) ; - + //check, if photons folls onto PHOS + Int_t moduleNumber ; + Double_t primX, primZ ; + phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; + if(moduleNumber) + hPrimary->Fill(primary->Energy()) ; + } } @@ -965,7 +1103,7 @@ void AliPHOSAnalyze::Contamination(const char* RecPointsTitle){ //fill histo spectrum of all RecParticles hAllRP->Fill(CorrectedEnergy(recParticle->Energy())) ; - //==========find the closest primary + //==========find the closest primary Int_t moduleNumberRec ; Double_t recX, recZ ; phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ; @@ -984,105 +1122,105 @@ void AliPHOSAnalyze::Contamination(const char* RecPointsTitle){ Double_t dXmin = 0.; Double_t dZmin = 0. ; for ( index = 0 ; index < numberofprimaries ; index++){ - primary = gime->Primary(listofprimaries[index]) ; - Int_t moduleNumber ; - Double_t primX, primZ ; - phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; - if(moduleNumberRec == moduleNumber) { - dX = recX - primX; - dZ = recZ - primZ; - distance = TMath::Sqrt(dX*dX + dZ*dZ) ; - if(minDistance > distance) { - minDistance = distance ; - dXmin = dX; - dZmin = dZ; - closestPrimary = listofprimaries[index] ; - } - } + primary = fRunLoader->Stack()->Particle(listofprimaries[index]) ; + Int_t moduleNumber ; + Double_t primX, primZ ; + phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; + if(moduleNumberRec == moduleNumber) { + dX = recX - primX; + dZ = recZ - primZ; + distance = TMath::Sqrt(dX*dX + dZ*dZ) ; + if(minDistance > distance) { + minDistance = distance ; + dXmin = dX; + dZmin = dZ; + closestPrimary = listofprimaries[index] ; + } + } } //===========define the "type" of closest primary if(closestPrimary >=0 ){ - Int_t primaryCode = -1; - const TParticle * primary = gime->Primary(closestPrimary) ; - Int_t primaryType = primary->GetPdgCode() ; - if(primaryType == 22) // photon ? - primaryCode = 0 ; - else - if(primaryType == 2112) // neutron - primaryCode = 1 ; - else - if(primaryType == -2112) // Anti neutron - primaryCode = 2 ; - else - if(primaryType == -2122) //Anti proton - primaryCode = 4 ; - else { - TParticle tempo(*primary) ; - if(tempo.GetPDG()->Charge()) - primaryCode = 3 ; - } - - //==========Now look at the type of RecParticle - Float_t energy = CorrectedEnergy(recParticle->Energy()) ; - if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST){ - hPhot->Fill(energy ) ; - switch(primaryCode){ - case 0: - hPhotReg->Fill(energy ) ; - break ; - case 1: - hNReg->Fill(energy ) ; - break ; - case 2: - hNBarReg->Fill(energy ) ; - break ; - case 3: - hChargedReg->Fill(energy ) ; - break ; - case 4: - hPbarReg->Fill(energy ) ; - break ; - default: - break ; - } - } - if((recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)|| - (recParticle->GetType() == AliPHOSFastRecParticle::kCHARGEDEMFAST)|| - (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW)|| - (recParticle->GetType() == AliPHOSFastRecParticle::kCHARGEDEMSLOW) ){ //with EM shower - hShape->Fill(energy ) ; - switch(primaryCode){ - case 0: - hPhotEM->Fill(energy ) ; - break ; - case 1: - hNEM->Fill(energy ) ; - break ; - case 2: - hNBarEM->Fill(energy ) ; - break ; - case 3: - hChargedEM->Fill(energy ) ; - break ; - case 4: - hPbarEM->Fill(energy ) ; - break ; - default: - break ; - } - } - - if((recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)|| - (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALHAFAST) || - (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW) || - (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALHASLOW) ) //nuetral - hVeto->Fill(energy ) ; - - //fill number of primaries identified as ... - if(primaryCode >= 0) // Primary code defined - counter[recParticle->GetType()][primaryCode]++ ; - + Int_t primaryCode = -1; + const TParticle * primary = fRunLoader->Stack()->Particle(closestPrimary) ; + Int_t primaryType = primary->GetPdgCode() ; + if(primaryType == 22) // photon ? + primaryCode = 0 ; + else + if(primaryType == 2112) // neutron + primaryCode = 1 ; + else + if(primaryType == -2112) // Anti neutron + primaryCode = 2 ; + else + if(primaryType == -2122) //Anti proton + primaryCode = 4 ; + else { + TParticle tempo(*primary) ; + if(tempo.GetPDG()->Charge()) + primaryCode = 3 ; + } + + //==========Now look at the type of RecParticle + Float_t energy = CorrectedEnergy(recParticle->Energy()) ; + if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST){ + hPhot->Fill(energy ) ; + switch(primaryCode){ + case 0: + hPhotReg->Fill(energy ) ; + break ; + case 1: + hNReg->Fill(energy ) ; + break ; + case 2: + hNBarReg->Fill(energy ) ; + break ; + case 3: + hChargedReg->Fill(energy ) ; + break ; + case 4: + hPbarReg->Fill(energy ) ; + break ; + default: + break ; + } + } + if((recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)|| + (recParticle->GetType() == AliPHOSFastRecParticle::kCHARGEDEMFAST)|| + (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW)|| + (recParticle->GetType() == AliPHOSFastRecParticle::kCHARGEDEMSLOW) ){ //with EM shower + hShape->Fill(energy ) ; + switch(primaryCode){ + case 0: + hPhotEM->Fill(energy ) ; + break ; + case 1: + hNEM->Fill(energy ) ; + break ; + case 2: + hNBarEM->Fill(energy ) ; + break ; + case 3: + hChargedEM->Fill(energy ) ; + break ; + case 4: + hPbarEM->Fill(energy ) ; + break ; + default: + break ; + } + } + + if((recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)|| + (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALHAFAST) || + (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW) || + (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALHASLOW) ) //nuetral + hVeto->Fill(energy ) ; + + //fill number of primaries identified as ... + if(primaryCode >= 0) // Primary code defined + counter[recParticle->GetType()][primaryCode]++ ; + } } // no closest primary found @@ -1114,46 +1252,47 @@ void AliPHOSAnalyze::Contamination(const char* RecPointsTitle){ //print Final Table maxevent = (Int_t)gAlice->TreeE()->GetEntries() ; - // cout << "Resolutions: Analyzed " << gime->MaxEvent() << " event(s)" << endl ; - cout << "Resolutions: Analyzed " << maxevent << " event(s)" << endl ; - cout << endl ; - - cout << " Primary: Photon Neutron Antineutron Charged hadron AntiProton" << endl ; - cout << "--------------------------------------------------------------------------------" << endl ; - cout << " kGAMMA: " - << setw(8) << counter[2][0] << setw(9) << counter[2][1] << setw(13) << counter[2][2] - << setw(15)<< counter[2][3] << setw(13) << counter[2][4] << endl ; - cout << " kGAMMAHA: " - << setw(8) << counter[3][0] << setw(9) << counter[3][1] << setw(13) << counter[3][2] - << setw(15)<< counter[3][3] << setw(13) << counter[3][4] << endl ; - cout << " kNEUTRALEM: " - << setw(8) << counter[0][0] << setw(9) << counter[0][1] << setw(13) << counter[0][2] - << setw(15)<< counter[0][3] << setw(13) << counter[0][4] << endl ; - cout << " kNEUTRALHA: " - << setw(8) << counter[1][0] << setw(9) << counter[1][1] << setw(13) << counter[1][2] - << setw(15)<< counter[1][3] << setw(13) << counter[1][4] << endl ; - cout << " kABSURDEM: " - << setw(8) << counter[4][0] << setw(9) << counter[4][1] << setw(13) << counter[4][2] - << setw(15)<< counter[4][3] << setw(13) << counter[4][4] << endl ; - cout << " kABSURDHA: " - << setw(8) << counter[5][0] << setw(9) << counter[5][1] << setw(13) << counter[5][2] - << setw(15)<< counter[5][3] << setw(13) << counter[5][4] << endl ; - cout << " kELECTRON: " - << setw(8) << counter[6][0] << setw(9) << counter[6][1] << setw(13) << counter[6][2] - << setw(15)<< counter[6][3] << setw(13) << counter[6][4] << endl ; - cout << " kCHARGEDHA: " - << setw(8) << counter[7][0] << setw(9) << counter[7][1] << setw(13) << counter[7][2] - << setw(15)<< counter[7][3] << setw(13) << counter[7][4] << endl ; - cout << "--------------------------------------------------------------------------------" << endl ; - + TString message ; + message = "Resolutions: Analyzed %d event(s)\n" ; + + message += " Primary: Photon Neutron Antineutron Charged hadron AntiProton\n" ; + message += "--------------------------------------------------------------------------------\n" ; + message += " kGAMMA: " ; + message += "%d %d %d %d %d\n" ; + message += " kGAMMAHA: " ; + message += "%d %d %d %d %d\n" ; + message += " kNEUTRALEM: " ; + message += "%d %d %d %d %d\n" ; + message += " kNEUTRALHA: " ; + message += "%d %d %d %d %d\n" ; + message += " kABSURDEM: "; + message += "%d %d %d %d %d\n" ; + message += " kABSURDHA: " ; + message += "%d %d %d %d %d\n" ; + message += " kELECTRON: " ; + message += "%d %d %d %d %d\n" ; + message += " kCHARGEDHA: " ; + message += "%d %d %d %d %d\n" ; + + message += "--------------------------------------------------------------------------------" ; + + Int_t totalInd = 0 ; for(i1 = 0; i1<8; i1++) for(i2 = 0; i2<5; i2++) totalInd+=counter[i1][i2] ; - cout << "Indentified particles: " << totalInd << endl ; + message += "Indentified particles: %d" ; -} - - + AliInfo(Form(message.Data(), maxevent, + counter[2][0], counter[2][1], counter[2][2], counter[2][3], counter[2][4], + counter[3][0], counter[3][1], counter[3][2], counter[3][3], counter[3][4], + counter[0][0], counter[0][1], counter[0][2], counter[0][3], counter[0][4], + counter[1][0], counter[1][1], counter[1][2], counter[1][3], counter[1][4], + counter[4][0], counter[4][1], counter[4][2], counter[4][3], counter[4][4], + counter[5][0], counter[5][1], counter[5][2], counter[5][3], counter[5][4], + counter[6][0], counter[6][1], counter[6][2], counter[6][3], counter[6][4], + counter[7][0], counter[7][1], counter[7][2], counter[7][3], counter[7][4], + totalInd )) ; +}