X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;ds=sidebyside;f=PHOS%2FAliPHOSIhepAnalyze.cxx;h=5b3723a6e138645555296906b26e90ccbfe70c80;hb=4821f07dc803887393ccc80cb6da1fc1fae2fcdb;hp=cd625e1396acaba9866e58527670e44a532f8a1d;hpb=cbd576a64219396dafbf3823df61bb86df031d80;p=u%2Fmrichter%2FAliRoot.git diff --git a/PHOS/AliPHOSIhepAnalyze.cxx b/PHOS/AliPHOSIhepAnalyze.cxx index cd625e1396a..5b3723a6e13 100644 --- a/PHOS/AliPHOSIhepAnalyze.cxx +++ b/PHOS/AliPHOSIhepAnalyze.cxx @@ -37,15 +37,17 @@ // --- Standard library --- -#include -#include - // --- AliRoot header files --- +#include "AliRunLoader.h" +#include "AliHeader.h" + +// --- PHOS header files --- +#include "AliLog.h" #include "AliPHOSIhepAnalyze.h" #include "AliPHOSDigit.h" #include "AliPHOSRecParticle.h" -#include "AliPHOSGetter.h" +#include "AliPHOSLoader.h" #include "AliPHOSHit.h" #include "AliPHOSImpact.h" #include "AliPHOSvImpacts.h" @@ -57,12 +59,24 @@ ClassImp(AliPHOSIhepAnalyze) //____________________________________________________________________________ - - AliPHOSIhepAnalyze::AliPHOSIhepAnalyze() {} +AliPHOSIhepAnalyze::AliPHOSIhepAnalyze(): + fRunLoader(0), + fFileName() +{ +} //____________________________________________________________________________ - -AliPHOSIhepAnalyze::AliPHOSIhepAnalyze(Text_t * name) : fFileName(name) {} +AliPHOSIhepAnalyze::AliPHOSIhepAnalyze(Text_t * name) : + fRunLoader(0), + fFileName(name) +{ + // Constructor: open a header file + fRunLoader = AliRunLoader::Open(fFileName); + if (fRunLoader == 0x0) + { + AliFatal(Form("Can not load event from file %s",name)); + } +} //____________________________________________________________________________ void AliPHOSIhepAnalyze::AnalyzeCPV1(Int_t Nevents) @@ -90,27 +104,44 @@ void AliPHOSIhepAnalyze::AnalyzeCPV1(Int_t Nevents) TList * fCpvImpacts ; TBranch * branchCPVimpacts; - AliPHOSGetter * please = AliPHOSGetter::GetInstance(GetFileName().Data(),"PHOS"); - const AliPHOSGeometry * fGeom = please->PHOSGeometry(); + + + AliPHOSLoader* please = dynamic_cast(fRunLoader->GetLoader("PHOSLoader")); + if ( please == 0 ) + { + AliError(Form("Could not obtain the Loader object !")); + return ; + } + + AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ; - cout << "Start CPV Analysis-1. Resolutions, cluster multiplicity and lengths"<GetEvent(ievent); - cout<<" >>>>>>>Event "<>>>>>>Event %d .<<<<<<<", ievent)) ; + /******************************************************************/ + TTree* treeH = please->TreeH(); + if (treeH == 0x0) + { + AliError(Form("Can not get TreeH")); + return; + } +/******************************************************************/ + // Get branch of CPV impacts - if (! (branchCPVimpacts =gAlice->TreeH()->GetBranch("PHOSCpvImpacts")) ) { - cout<<" Couldn't find branch PHOSCpvImpacts. Exit."<GetBranch("PHOSCpvImpacts")) ) { + AliWarning(Form("Couldn't find branch PHOSCpvImpacts. Exit.")) ; return; } // Create and fill arrays of hits for each CPV module - Int_t nOfModules = fGeom->GetNModules(); + Int_t nOfModules = phosgeom->GetNModules(); TClonesArray **hitsPerModule = new TClonesArray *[nOfModules]; Int_t iModule = 0; for (iModule=0; iModule < nOfModules; iModule++) @@ -127,7 +158,7 @@ void AliPHOSIhepAnalyze::AnalyzeCPV1(Int_t Nevents) branchCPVimpacts ->SetAddress(&fCpvImpacts); branchCPVimpacts ->GetEntry(itrack,0); - for (Int_t iModule=0; iModule < nOfModules; iModule++) { + for (iModule=0; iModule < nOfModules; iModule++) { impacts = (TClonesArray *)fCpvImpacts->At(iModule); // Do loop over impacts in the module for (Int_t iImpact=0; iImpactGetEntries(); iImpact++) { @@ -151,7 +182,7 @@ void AliPHOSIhepAnalyze::AnalyzeCPV1(Int_t Nevents) // The distance from the rec.point to the closest hit // gives the coordinate resolution of the CPV - please->Event(ievent); + fRunLoader->GetEvent(ievent); TIter nextRP(please->CpvRecPoints()) ; AliPHOSCpvRecPoint *cpvRecPoint ; Float_t xgen, ygen, zgen; @@ -184,14 +215,12 @@ void AliPHOSIhepAnalyze::AnalyzeCPV1(Int_t Nevents) ygen = impact->Y(); //Transform to the local ref.frame - const AliPHOSGeometry* geom = please->PHOSGeometry(); - Float_t phig = geom->GetPHOSAngle(phosModule); + Float_t phig = phosgeom->GetPHOSAngle(phosModule); Float_t phi = TMath::Pi()/180*phig; - Float_t distanceIPtoCPV = geom->GetIPtoOuterCoverDistance() - - (geom->GetFTPosition(1)+ - geom->GetFTPosition(2)+ - geom->GetCPVTextoliteThickness() - )/2; + Float_t distanceIPtoCPV = phosgeom->GetIPtoOuterCoverDistance() - + (phosgeom->GetFTPosition(1)+ + phosgeom->GetFTPosition(2)+ + phosgeom->GetCPVTextoliteThickness())/2; Float_t xoL,yoL,zoL ; // xoL = xgen*TMath::Cos(phig)+ygen*TMath::Sin(phig) ; // yoL = -xgen*TMath::Sin(phig)+ygen*TMath::Cos(phig) + distanceIPtoCPV; @@ -211,10 +240,10 @@ void AliPHOSIhepAnalyze::AnalyzeCPV1(Int_t Nevents) gImpY = ygen; } } - cout<<" Impact global (X,Z,Y) = "<Fill(dxmin); hDz ->Fill(dzmin); // hDr ->Fill(TMath::Sqrt(r2min)); @@ -224,9 +253,8 @@ void AliPHOSIhepAnalyze::AnalyzeCPV1(Int_t Nevents) } delete [] hitsPerModule; - cout<<"++++ Event "<CpvRecPoints()->GetEntries() - <<" rec. points."<CpvRecPoints()->GetEntries())) ; } // Save histograms @@ -310,26 +338,41 @@ void AliPHOSIhepAnalyze::AnalyzeEMC1(Int_t Nevents) TList * fEmcImpacts ; TBranch * branchEMCimpacts; - AliPHOSGetter * please = AliPHOSGetter::GetInstance(GetFileName().Data(),"PHOS"); - const AliPHOSGeometry * fGeom = please->PHOSGeometry(); + AliPHOSLoader* please = dynamic_cast(fRunLoader->GetLoader("PHOSLoader")); + if ( please == 0 ) + { + AliError(Form("Could not obtain the Loader object !")); + return ; + } + + AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ; - cout << "Start EMC Analysis-1. Resolutions, cluster multiplicity and lengths"<GetEvent(ievent); - cout<<" >>>>>>>Event "<>>>>>>Event %d .<<<<<<<", ievent)) ; + + TTree* treeH = please->TreeH(); + if (treeH == 0x0) + { + AliError(Form("Can not get TreeH")); + return; + } + // Get branch of EMC impacts - if (! (branchEMCimpacts =gAlice->TreeH()->GetBranch("PHOSEmcImpacts")) ) { - cout<<" Couldn't find branch PHOSEmcImpacts. Exit."<GetBranch("PHOSEmcImpacts")) ) { + AliWarning(Form(" Couldn't find branch PHOSEmcImpacts. Exit.")); return; } // Create and fill arrays of hits for each EMC module - Int_t nOfModules = fGeom->GetNModules(); + Int_t nOfModules = phosgeom->GetNModules(); TClonesArray **hitsPerModule = new TClonesArray *[nOfModules]; Int_t iModule = 0; for (iModule=0; iModule < nOfModules; iModule++) @@ -346,7 +389,7 @@ void AliPHOSIhepAnalyze::AnalyzeEMC1(Int_t Nevents) branchEMCimpacts ->SetAddress(&fEmcImpacts); branchEMCimpacts ->GetEntry(itrack,0); - for (Int_t iModule=0; iModule < nOfModules; iModule++) { + for (iModule=0; iModule < nOfModules; iModule++) { impacts = (TClonesArray *)fEmcImpacts->At(iModule); // Do loop over impacts in the module for (Int_t iImpact=0; iImpactGetEntries(); iImpact++) { @@ -368,7 +411,7 @@ void AliPHOSIhepAnalyze::AnalyzeEMC1(Int_t Nevents) // The distance from the rec.point to the closest hit // gives the coordinate resolution of the EMC - please->Event(ievent); + fRunLoader->GetEvent(ievent); TIter nextRP(please->EmcRecPoints()) ; AliPHOSEmcRecPoint *emcRecPoint ; Float_t xgen, ygen, zgen; @@ -401,10 +444,9 @@ void AliPHOSIhepAnalyze::AnalyzeEMC1(Int_t Nevents) //Transform to the local ref.frame - const AliPHOSGeometry* geom = please->PHOSGeometry(); - Float_t phig = geom->GetPHOSAngle(phosModule); + Float_t phig = phosgeom->GetPHOSAngle(phosModule); Float_t phi = TMath::Pi()/180*phig; - Float_t distanceIPtoEMC = geom->GetIPtoCrystalSurface(); + Float_t distanceIPtoEMC = phosgeom->GetIPtoCrystalSurface(); Float_t xoL,yoL,zoL ; // xoL = xgen*TMath::Cos(phig)+ygen*TMath::Sin(phig) ; // yoL = -xgen*TMath::Sin(phig)+ygen*TMath::Cos(phig) + distanceIPtoEMC; @@ -424,10 +466,10 @@ void AliPHOSIhepAnalyze::AnalyzeEMC1(Int_t Nevents) gImpY = ygen; } } - cout<<" Impact global (X,Z,Y) = "<Fill(dxmin); hDz ->Fill(dzmin); // hDr ->Fill(TMath::Sqrt(r2min)); @@ -437,8 +479,8 @@ void AliPHOSIhepAnalyze::AnalyzeEMC1(Int_t Nevents) } delete [] hitsPerModule; - cout<<"++++ Event "<EmcRecPoints()->GetEntriesFast()<<" Emc rec. points."<EmcRecPoints()->GetEntriesFast())) ; } // Save histograms @@ -501,36 +543,49 @@ void AliPHOSIhepAnalyze::AnalyzeCPV2(Int_t Nevents) // 24 March 2001 - TH1F* hDrij_cpv_r = new TH1F("Drij_cpv_r","Distance between reconstructed hits in CPV",140,0,50); - TH1F* hDrij_cpv_g = new TH1F("Drij_cpv_g","Distance between generated hits in CPV",140,0,50); - TH1F* hDrij_cpv_ratio = new TH1F("Drij_cpv_ratio","R_{ij}^{rec}/R_{ij}^{gen} in CPV",140,0,50); + TH1F* hDrijCPVr = new TH1F("Drij_cpv_r","Distance between reconstructed hits in CPV",140,0,50); + TH1F* hDrijCPVg = new TH1F("Drij_cpv_g","Distance between generated hits in CPV",140,0,50); + TH1F* hDrijCPVratio = new TH1F("Drij_cpv_ratio","R_{ij}^{rec}/R_{ij}^{gen} in CPV",140,0,50); // TH1F* hT0 = new TH1F("hT0","Type of entering particle",20000,-10000,10000); - hDrij_cpv_r->Sumw2(); - hDrij_cpv_g->Sumw2(); - hDrij_cpv_ratio->Sumw2(); //correct treatment of errors + hDrijCPVr->Sumw2(); + hDrijCPVg->Sumw2(); + hDrijCPVratio->Sumw2(); //correct treatment of errors TList * fCpvImpacts = new TList(); TBranch * branchCPVimpacts; - AliPHOSGetter * please = AliPHOSGetter::GetInstance(GetFileName().Data(),"PHOS"); - const AliPHOSGeometry * fGeom = please->PHOSGeometry(); + AliPHOSLoader* please = dynamic_cast(fRunLoader->GetLoader("PHOSLoader")); + if ( please == 0 ) + { + AliError(Form("Could not obtain the Loader object !")); + return ; + } + AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ; + fRunLoader->LoadHeader(); for (Int_t nev=0; nevGetEvent(nev); - please->Event(nev); + fRunLoader->GetEvent(nev); + Int_t ntracks = fRunLoader->GetHeader()->GetNtrack(); - Int_t nrec_cpv = 0; // Reconstructed points in event - Int_t ngen_cpv = 0; // Impacts in event + Int_t nRecCPV = 0; // Reconstructed points in event + Int_t nGenCPV = 0; // Impacts in event // Get branch of CPV impacts - if (! (branchCPVimpacts =gAlice->TreeH()->GetBranch("PHOSCpvImpacts")) ) return; + TTree* treeH = please->TreeH(); + if (treeH == 0x0) + { + AliError(Form("Can not get TreeH")); + return; + } + + if (! (branchCPVimpacts =treeH->GetBranch("PHOSCpvImpacts")) ) return; // Create and fill arrays of hits for each CPV module - Int_t nOfModules = fGeom->GetNModules(); + Int_t nOfModules = phosgeom->GetNModules(); TClonesArray **hitsPerModule = new TClonesArray *[nOfModules]; Int_t iModule = 0; for (iModule=0; iModule < nOfModules; iModule++) @@ -541,10 +596,10 @@ void AliPHOSIhepAnalyze::AnalyzeCPV2(Int_t Nevents) for (Int_t itrack=0; itrackSetAddress(&fCpvImpacts); - cout<<" branchCPVimpacts ->SetAddress(&fCpvImpacts) OK."<SetAddress(&fCpvImpacts) OK.")); branchCPVimpacts ->GetEntry(itrack,0); - for (Int_t iModule=0; iModule < nOfModules; iModule++) { + for (iModule=0; iModule < nOfModules; iModule++) { impacts = (TClonesArray *)fCpvImpacts->At(iModule); // Do loop over impacts in the module for (Int_t iImpact=0; iImpactGetEntries(); iImpact++) { @@ -561,20 +616,20 @@ void AliPHOSIhepAnalyze::AnalyzeCPV2(Int_t Nevents) Int_t nsum = hitsPerModule[iModule]->GetEntriesFast(); printf("CPV module %d has %d hits\n",iModule,nsum); - AliPHOSImpact* GenHit1; - AliPHOSImpact* GenHit2; + AliPHOSImpact* genHit1; + AliPHOSImpact* genHit2; Int_t irp1,irp2; for(irp1=0; irp1< nsum; irp1++) { - GenHit1 = (AliPHOSImpact*)((hitsPerModule[iModule])->At(irp1)); + genHit1 = (AliPHOSImpact*)((hitsPerModule[iModule])->At(irp1)); for(irp2 = irp1+1; irp2At(irp2)); - Float_t dx = GenHit1->X() - GenHit2->X(); - Float_t dz = GenHit1->Z() - GenHit2->Z(); + genHit2 = (AliPHOSImpact*)((hitsPerModule[iModule])->At(irp2)); + Float_t dx = genHit1->X() - genHit2->X(); + Float_t dz = genHit1->Z() - genHit2->Z(); Float_t dr = TMath::Sqrt(dx*dx + dz*dz); - hDrij_cpv_g->Fill(dr); -// cout<<"(dx dz dr): "<Fill(dr); +// AliInfo(Form("(dx dz dr): %f %f", dx, dz)); } } } @@ -583,47 +638,48 @@ void AliPHOSIhepAnalyze::AnalyzeCPV2(Int_t Nevents) //--------- Combinatoric distance between rec. hits in CPV TObjArray* cpvRecPoints = please->CpvRecPoints(); - nrec_cpv = cpvRecPoints->GetEntriesFast(); + nRecCPV = cpvRecPoints->GetEntriesFast(); - if(nrec_cpv) + if(nRecCPV) { - AliPHOSCpvRecPoint* RecHit1; - AliPHOSCpvRecPoint* RecHit2; - TIter next_cpv_rec1(cpvRecPoints); - while(TObject* obj1 = next_cpv_rec1() ) + AliPHOSCpvRecPoint* recHit1; + AliPHOSCpvRecPoint* recHit2; + TIter nextCPVrec1(cpvRecPoints); + while(TObject* obj1 = nextCPVrec1() ) { - TIter next_cpv_rec2(cpvRecPoints); - while (TObject* obj2 = next_cpv_rec2()) + TIter nextCPVrec2(cpvRecPoints); + while (TObject* obj2 = nextCPVrec2()) { if(!obj2->IsEqual(obj1)) { - RecHit1 = (AliPHOSCpvRecPoint*)obj1; - RecHit2 = (AliPHOSCpvRecPoint*)obj2; + recHit1 = (AliPHOSCpvRecPoint*)obj1; + recHit2 = (AliPHOSCpvRecPoint*)obj2; TVector3 locpos1; TVector3 locpos2; - RecHit1->GetLocalPosition(locpos1); - RecHit2->GetLocalPosition(locpos2); + recHit1->GetLocalPosition(locpos1); + recHit2->GetLocalPosition(locpos2); Float_t dx = locpos1.X() - locpos2.X(); Float_t dz = locpos1.Z() - locpos2.Z(); Float_t dr = TMath::Sqrt(dx*dx + dz*dz); - if(RecHit1->GetPHOSMod() == RecHit2->GetPHOSMod()) - hDrij_cpv_r->Fill(dr); + if(recHit1->GetPHOSMod() == recHit2->GetPHOSMod()) + hDrijCPVr->Fill(dr); } } } } - cout<<" Event "<Draw(); -// hDrij_cpv_r->Draw(); - hDrij_cpv_ratio->Divide(hDrij_cpv_r,hDrij_cpv_g); - hDrij_cpv_ratio->Draw(); +// hDrijCPVg->Draw(); +// hDrijCPVr->Draw(); + hDrijCPVratio->Divide(hDrijCPVr,hDrijCPVg); + hDrijCPVratio->Draw(); // hT0->Draw(); @@ -643,11 +699,16 @@ void AliPHOSIhepAnalyze::CpvSingle(Int_t nevents) TH1S *hNrpX = new TH1S("hNrpX","CPV rec.point Phi-length" ,21,-0.5,20.5); TH1S *hNrpZ = new TH1S("hNrpZ","CPV rec.point Z-length" ,21,-0.5,20.5); - AliPHOSGetter* gime = AliPHOSGetter::GetInstance(GetFileName().Data(),"PHOS"); + AliPHOSLoader* gime = dynamic_cast(fRunLoader->GetLoader("PHOSLoader")); + if ( gime == 0 ) + { + AliError(Form("Could not obtain the Loader object !")); + return ; + } for(Int_t ievent=0; ieventEvent(ievent); + fRunLoader->GetEvent(ievent); if(gime->CpvRecPoints()->GetEntriesFast()>1) continue; AliPHOSCpvRecPoint* pt = (AliPHOSCpvRecPoint*)(gime->CpvRecPoints())->At(0); @@ -664,7 +725,8 @@ void AliPHOSIhepAnalyze::CpvSingle(Int_t nevents) hNrpX->Fill(rpMultX); hNrpZ->Fill(rpMultZ); hChi2->Fill(((AliPHOSEvalRecPoint*)pt)->Chi2Dof()); - cout<<"+++++ Event "<PHOSGeometry(); + AliPHOSLoader* please = dynamic_cast(fRunLoader->GetLoader("PHOSLoader")); + if ( please == 0 ) + { + AliError(Form("Could not obtain the Loader object !")); + return ; + } + AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ; printf("\n=================== Event %10d ===================\n",nev); - Int_t ntracks = gAlice->GetEvent(nev); - please->Event(nev); + fRunLoader->GetEvent(nev); + Int_t ntracks = fRunLoader->GetHeader()->GetNtrack(); -// Int_t nrec_cpv = 0; // Reconstructed points in event // 01.10.2001 -// Int_t ngen_cpv = 0; // Impacts in event +// Int_t nRecCPV = 0; // Reconstructed points in event // 01.10.2001 +// Int_t nGenCPV = 0; // Impacts in event // Get branch of CPV impacts - if (! (branchCPVimpacts =gAlice->TreeH()->GetBranch("PHOSCpvImpacts")) ) return; + TTree* treeH = please->TreeH(); + if (treeH == 0x0) + { + AliError(Form("Can not get TreeH")); + return; + } + + if (! (branchCPVimpacts =treeH->GetBranch("PHOSCpvImpacts")) ) return; // Create and fill arrays of hits for each CPV module - Int_t nOfModules = fGeom->GetNModules(); + Int_t nOfModules = phosgeom->GetNModules(); TClonesArray **hitsPerModule = new TClonesArray *[nOfModules]; Int_t iModule = 0; for (iModule=0; iModule < nOfModules; iModule++) @@ -749,10 +823,10 @@ void AliPHOSIhepAnalyze::HitsCPV(TClonesArray& hits, Int_t nev) for (Int_t itrack=0; itrackSetAddress(&fCpvImpacts); - cout<<" branchCPVimpacts ->SetAddress(&fCpvImpacts) OK."<SetAddress(&fCpvImpacts) OK.")); branchCPVimpacts ->GetEntry(itrack,0); - for (Int_t iModule=0; iModule < nOfModules; iModule++) { + for (iModule=0; iModule < nOfModules; iModule++) { impacts = (TClonesArray *)fCpvImpacts->At(iModule); // Do loop over impacts in the module for (Int_t iImpact=0; iImpactGetEntries(); iImpact++) { @@ -774,40 +848,40 @@ void AliPHOSIhepAnalyze::HitsCPV(TClonesArray& hits, Int_t nev) // AliPHOSImpact* impact; // TClonesArray* impacts; -// AliPHOSGetter * please = AliPHOSGetter::GetInstance(GetFileName().Data(),"PHOS"); +// AliPHOSLoader * please = AliPHOSLoader::GetInstance(GetFileName().Data(),"PHOS"); // const AliPHOSGeometry * fGeom = please->PHOSGeometry(); // Int_t ntracks = gAlice->GetEvent(ievent); // Int_t nOfModules = fGeom->GetNModules(); -// cout<<" Tracks: "<TreeH()->GetBranch("PHOSCpvImpacts")) ) return; // for (Int_t itrack=0; itrackSetAddress(&fCpvImpacts); -// cout<<" branchCPVimpacts ->SetAddress(&fCpvImpacts) OK."<SetAddress(&fCpvImpacts) OK."); // branchCPVimpacts ->GetEntry(itrack,0); -// cout<<" branchCPVimpacts ->GetEntry(itrack,0) OK."<GetEntry(itrack,0) OK.")); // for (Int_t iModule=0; iModule < nOfModules; iModule++) { // impacts = (TClonesArray *)fCpvImpacts->At(iModule); -// cout<<" fCpvImpacts->At(iModule) OK."<At(iModule) OK.")); // // Do loop over impacts in the module // for (Int_t iImpact=0; iImpactGetEntries(); iImpact++) { // impact=(AliPHOSImpact*)impacts->At(iImpact); // impact->Print(); // if(IsCharged(impact->GetPid())) // { -// cout<<" Add charged hit.."; +// Info(Form(" Add charged hit..")); // new(hits[hits.GetEntriesFast()]) AliPHOSImpact(*impact); -// cout<<"done."<Clear(); // } -// cout<<" PHOS event "<GetEntries()<<" charged CPV hits."<GetEntries()<<" charged CPV hits.")); // } -Bool_t AliPHOSIhepAnalyze::IsCharged(Int_t pdg_code) +Bool_t AliPHOSIhepAnalyze::IsCharged(Int_t pdgCode) { // For HIJING - cout<<" pdg_code "<