From 7b7c15335990bc27772c67f9ee7bc90cc48bc9a3 Mon Sep 17 00:00:00 2001 From: schutz Date: Wed, 4 Jul 2001 16:22:42 +0000 Subject: [PATCH] A lot of changes here: usage systematiquement de TTAsk et TFolder et QA L'idee est la suivante: 1. Il y a 5 tasks independants qui produisent 5 types d'objets SDIgits, Digits, RecPoints, TrackSegments et RecParticles. Les task sont postes dans des folders selon la hierachie //YSAlice/tasks/SDigitizer/phos/nom_du_task/ etc... 2. Les objets produits sont ranges comme toujours dans des Tree's et postes dans des folders selon la hierarchie //YSAlice/WhiteBoard/SDigits/PHOS/nom_du_task_qui_a_produit_cet_Objet etc..... Je peux avoir plusieurs liste de SDigits venant de hits differents pour le event mixing. C'est le Digitizer qui gere ca. 3. Les tasks communiquent entre eux exclusivement par les folders. Un nouvel objet (AliPHOSGetter) se charge de cette communication. 4. A L'ouverture d'un fichier galice.root le AliPHOSGetter inspecte toutes les branches de chacun des Tree et poste les objets existants dans les folders correspondants. 5. Les alarmes du QA sont postes dans un folder et sauvegardees dans un nouveau Tree (TreeQA) 6. AliPHOSGetter sait gerer le cas ou il y a plus d'un evenement dans galice.root. A un instant donne seul l'evenement courrant est poste dans les folders. --- PHOS/AliPHOS.cxx | 115 +++- PHOS/AliPHOS.h | 13 +- PHOS/AliPHOSAnalyze.cxx | 218 ++++---- PHOS/AliPHOSAnalyze.h | 4 +- PHOS/AliPHOSClusterizer.cxx | 6 +- PHOS/AliPHOSClusterizer.h | 8 +- PHOS/AliPHOSClusterizerv1.cxx | 510 +++++++++--------- PHOS/AliPHOSClusterizerv1.h | 27 +- PHOS/AliPHOSCpvRecPoint.cxx | 6 +- PHOS/AliPHOSCpvRecPoint.h | 1 + PHOS/AliPHOSDigit.cxx | 4 +- PHOS/AliPHOSDigitizer.cxx | 788 +++++++++++++--------------- PHOS/AliPHOSDigitizer.h | 47 +- PHOS/AliPHOSEmcRecPoint.cxx | 41 +- PHOS/AliPHOSFastRecParticle.h | 2 +- PHOS/AliPHOSGeometry.cxx | 24 +- PHOS/AliPHOSGeometry.h | 14 +- PHOS/AliPHOSPID.cxx | 9 +- PHOS/AliPHOSPID.h | 12 +- PHOS/AliPHOSPIDv1.cxx | 423 ++++++++------- PHOS/AliPHOSPIDv1.h | 39 +- PHOS/AliPHOSPpsdRecPoint.cxx | 8 +- PHOS/AliPHOSQAAlarm.cxx | 3 +- PHOS/AliPHOSQAAlarm.h | 7 +- PHOS/AliPHOSQAChecker.cxx | 3 +- PHOS/AliPHOSQAFloatCheckable.cxx | 4 +- PHOS/AliPHOSQAIntCheckable.cxx | 4 +- PHOS/AliPHOSQAMeanChecker.cxx | 2 +- PHOS/AliPHOSQAObjectCheckable.cxx | 3 +- PHOS/AliPHOSQAVirtualCheckable.cxx | 20 +- PHOS/AliPHOSQAVirtualCheckable.h | 10 +- PHOS/AliPHOSRecPoint.cxx | 11 +- PHOS/AliPHOSRecPoint.h | 1 - PHOS/AliPHOSReconstructioner.cxx | 8 +- PHOS/AliPHOSSDigitizer.cxx | 239 ++++----- PHOS/AliPHOSSDigitizer.h | 23 +- PHOS/AliPHOSTrackSegmentMaker.cxx | 7 +- PHOS/AliPHOSTrackSegmentMaker.h | 7 +- PHOS/AliPHOSTrackSegmentMakerv1.cxx | 393 +++++++------- PHOS/AliPHOSTrackSegmentMakerv1.h | 25 +- PHOS/AliPHOSv0.cxx | 21 +- PHOS/AliPHOSv1.cxx | 4 + PHOS/AliPHOSv4.cxx | 9 +- 43 files changed, 1587 insertions(+), 1536 deletions(-) diff --git a/PHOS/AliPHOS.cxx b/PHOS/AliPHOS.cxx index a3696b235f4..fd5aea7b757 100644 --- a/PHOS/AliPHOS.cxx +++ b/PHOS/AliPHOS.cxx @@ -49,20 +49,19 @@ AliPHOS:: AliPHOS() : AliDetector() { // Create folder and task hierarchy fName="PHOS"; - CreatePHOSFolders(); - fGeom = 0 ; + CreatePHOSWhiteBoard(); + } //____________________________________________________________________________ AliPHOS::AliPHOS(const char* name, const char* title): AliDetector(name, title) { // Create folder and task hierarchy - CreatePHOSFolders(); - fGeom = 0 ; + CreatePHOSWhiteBoard(); } //____________________________________________________________________________ -void AliPHOS::CreatePHOSFolders() +void AliPHOS::CreatePHOSWhiteBoard() { // create the ALICE TFolder // create the ALICE TTasks @@ -70,20 +69,39 @@ void AliPHOS::CreatePHOSFolders() // create the ALICE main TFolder // add the Alice QA Alarms // this should be done of course by AliRun + //==================== BEG TO BE DONE BY AliRUN =========================== + TFolder *alice = gROOT->GetRootFolder()->AddFolder("YSAlice","Alice Folder") ; + gROOT->GetListOfBrowsables()->Add(alice, "YSAlice") ; - TFolder * alice = new TFolder(); - alice->SetNameTitle("YSAlice", "Alice Folder") ; - gROOT->GetListOfBrowsables()->Add(alice) ; - - TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ; + TFolder * aliceF = alice->AddFolder("WhiteBoard", "Alice memory Folder") ; // make it the owner of the objects that it contains aliceF->SetOwner() ; // geometry folder TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ; // alarms folder TFolder * alarmsF = aliceF->AddFolder("QAAlarms", "Alarms raised by QA check") ; + // Hits folder + TFolder * hitsF = aliceF->AddFolder("Hits", "Hits") ; + // SDigits folder + TFolder * sdigitsF = aliceF->AddFolder("SDigits", "Summable Digits") ; + // Digits folder + TFolder * digitsF = aliceF->AddFolder("Digits", "Digits") ; + // RecPoints folder + TFolder * rpointsF = aliceF->AddFolder("RecPoints", "RecPoints") ; + // TrackSegments folder + TFolder * tsF = aliceF->AddFolder("TrackSegments", "TrackSegments") ; + // RecParticles folder + TFolder * rparticlesF = aliceF->AddFolder("RecParticles", "RecParticles") ; // make it the owner of the objects that it contains alarmsF->SetOwner() ; + hitsF->SetOwner() ; + sdigitsF->SetOwner() ; + digitsF->SetOwner() ; + rpointsF->SetOwner() ; + tsF->SetOwner() ; + rparticlesF->SetOwner() ; + + // Tasks folder TFolder * aliceT = alice->AddFolder("tasks", "Alice tasks Folder") ; // make it the owner of the objects that it contains aliceT->SetOwner() ; @@ -91,27 +109,40 @@ void AliPHOS::CreatePHOSFolders() TTask * aliceQA = new TTask("QA", "Alice QA tasks") ; aliceT->Add(aliceQA); - TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ; + TTask * aliceSD = new TTask("SDigitizer", "Alice SDigitizer") ; + aliceT->Add(aliceSD); + + TTask * aliceDi = new TTask("Digitizer", "Alice Digitizer") ; aliceT->Add(aliceDi); TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ; aliceT->Add(aliceRe); + //==================== END TO BE DONE BY AliRUN =========================== + + // =================== Creating PHOS related folders char * tempo = new char[80] ; // creates the PHOSQA (QAChecker knows how to add itself in the tasks list) sprintf(tempo, "%sCheckers container",GetName() ) ; fQATask = new AliPHOSQAChecker(GetName(), tempo); - // creates the PHOS(S)Digitizer and adds it to alice main (S)Digitizer task + // creates the PHOS SDigitizer and adds it to alice main SDigitizer task + sprintf(tempo, "%sSDigitizers container",GetName() ) ; + TTask * sdT = new TTask(GetName(), tempo); + aliceSD->Add(sdT) ; + + // creates the PHOS Digitizer and adds it to alice main Digitizer task sprintf(tempo, "%sDigitizers container",GetName() ) ; - fSDTask = new TTask(GetName(), tempo); - aliceDi->Add(fSDTask) ; + TTask * dT = new TTask(GetName(), tempo); + aliceDi->Add(dT) ; // creates the PHOS reconstructioner and adds it to alice main Reconstructioner task - sprintf(tempo, "%sReconstructioner container",GetName() ) ; - fReTask = new TTask(GetName(), tempo); - aliceRe->Add(fReTask) ; + sprintf(tempo, "%s Reconstructioner container",GetName() ) ; + TTask * reT = new TTask(GetName(), tempo); + aliceRe->Add(reT) ; + + // creates the PHOS clusterizer, tracksegment maker and PID and adds it to the PHOS Reconstructioner task delete tempo ; @@ -119,6 +150,24 @@ void AliPHOS::CreatePHOSFolders() geomF->AddFolder("PHOS", "Geometry for PHOS") ; // creates the PHOSQA alarm folder alarmsF->AddFolder("PHOS", "QA alarms from PHOS") ; + // creates the PHOS Hits folder + hitsF->AddFolder("PHOS", "Hits for PHOS") ; + // creates the PHOS Summable Digits folder + sdigitsF->AddFolder("PHOS", "Summable Digits for PHOS") ; + // creates the PHOS Digits folder + digitsF->AddFolder("PHOS", "Digits for PHOS") ; + // creates the PHOS RecPoints folder + TFolder * prpF = rpointsF->AddFolder("PHOS", "RecPoints for PHOS") ; + // creates the PHOS EMC RecPoints folder + prpF->AddFolder("emc", "EMC RecPoints for PHOS") ; + // creates the PHOS CPV RecPoints folder + prpF->AddFolder("cpv", "CPV RecPoints for PHOS") ; + + // creates the PHOS TrackSegments folder + tsF->AddFolder("PHOS", "Track Segments for PHOS") ; + // creates the PHOS RecParticles folder + rparticlesF->AddFolder("PHOS", "RecParticles for PHOS") ; + } //____________________________________________________________________________ AliPHOS::~AliPHOS() @@ -126,8 +175,7 @@ AliPHOS::~AliPHOS() // remove the alice folder and alice QA task that PHOS creates instead of AliRun // remove and delete the PHOS QA tasks - TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("YSAlice") ; - TTask * aliceQA = (TTask*)alice->FindObject("tasks/QA") ; + TTask * aliceQA = (TTask*)gROOT->FindObjectAny("YSAlice/tasks/QA") ; fQATask->GetListOfTasks()->Delete() ; aliceQA->GetListOfTasks()->Remove(fQATask) ; delete fQATask ; @@ -400,14 +448,11 @@ AliPHOSGeometry * AliPHOS::GetGeometry() const { // gets the pointer to the AliPHOSGeometry unique instance from the folder - AliPHOSGeometry * rv ; + AliPHOSGeometry * rv = 0 ; - TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("YSAlice") ; - TString path("folders/Geometry/PHOS/") ; + TString path("YSAlice/WhiteBoard/Geometry/PHOS/") ; path += GetTitle() ; - rv = (AliPHOSGeometry*)alice->FindObject(path) ; - if ( !rv ) - rv = fGeom ; + rv = (AliPHOSGeometry*)gROOT->FindObjectAny(path) ; return rv ; } @@ -431,4 +476,24 @@ void AliPHOS::SetTreeAddress() } } +//____________________________________________________________________________ +void AliPHOS::WriteQA() +{ + + // Make TreeQA in the output file. + + if(fTreeQA == 0) + fTreeQA = new TTree("TreeQA", "QA Alarms") ; + // Create Alarms branches + Int_t bufferSize = 32000 ; + Int_t splitlevel = 0 ; + TFolder * alarmsF = (TFolder*)gROOT->FindObjectAny("YSAlice/WhiteBoard/QAAlarms/PHOS") ; + TString branchName(alarmsF->GetName()); + TBranch * alarmsBranch = fTreeQA->Branch(branchName,"TFolder", &alarmsF, bufferSize, splitlevel); + TString branchTitle = branchName + " QA alarms" ; + alarmsBranch->SetTitle(branchTitle); + alarmsBranch->Fill() ; + + // fTreeQA->Fill() ; +} diff --git a/PHOS/AliPHOS.h b/PHOS/AliPHOS.h index d8a92485c44..622aceafb0a 100644 --- a/PHOS/AliPHOS.h +++ b/PHOS/AliPHOS.h @@ -41,13 +41,15 @@ class AliPHOS : public AliDetector { } virtual void AddHit( Int_t shunt, Int_t primary, Int_t track, Int_t id, Float_t *hits ) = 0 ; virtual void CreateMaterials() ; - void CreatePHOSFolders(); + void CreatePHOSWhiteBoard(); + virtual void FinishRun() {WriteQA();} virtual AliPHOSGeometry * GetGeometry() const ; virtual Int_t IsVersion(void) const = 0 ; AliPHOSQAChecker * QAChecker() {return fQATask;} - virtual void SetTreeAddress(); + virtual void SetTreeAddress(); + virtual TTree * TreeQA() const {return fTreeQA; } virtual TString Version() {return TString(" ") ; } - + virtual void AliPHOS::WriteQA() ; AliPHOS & operator = (const AliPHOS & rvalue) { // assignement operator requested by coding convention // but not needed @@ -57,11 +59,8 @@ class AliPHOS : public AliDetector { protected: - TFolder * fFGeom ; //! Folder that holds the Geometry definition - AliPHOSGeometry * fGeom ; // Geometry definition AliPHOSQAChecker * fQATask ; //! PHOS checkers container - TTask * fSDTask ; //! PHOS (S)Digitizer container - TTask * fReTask ; //! PHOS Reconstructioner container + TTree * fTreeQA ; // the QA tree that contains the alarms ClassDef(AliPHOS,2) // Photon Spectrometer Detector (base class) diff --git a/PHOS/AliPHOSAnalyze.cxx b/PHOS/AliPHOSAnalyze.cxx index ad6346398fb..c268803baac 100644 --- a/PHOS/AliPHOSAnalyze.cxx +++ b/PHOS/AliPHOSAnalyze.cxx @@ -91,6 +91,7 @@ #include "AliPHOSIndexToObject.h" #include "AliPHOSCpvRecPoint.h" #include "AliPHOSPpsdRecPoint.h" +#include "AliPHOSGetter.h" ClassImp(AliPHOSAnalyze) @@ -107,9 +108,7 @@ AliPHOSAnalyze::AliPHOSAnalyze(Text_t * fileName) { // ctor: analyze events from root file "name" ffileName = fileName ; - fCorrection = 1.05 ; //Value calculated for default parameters of reconstruction - fObjGetter = 0 ; // should be instantiated - + fCorrection = 1.05 ; //Value calculated for default parameters of reconstruction } //____________________________________________________________________________ @@ -144,36 +143,37 @@ void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,c TH2F * recPhot = new TH2F("recPhot","RecParticles with primary Photon",64,-71.,71.,64,-71.,71.); TH2F * recNbar = new TH2F("recNbar","RecParticles with primary Nbar", 64,-71.,71.,64,-71.,71.); - //========== Create IndexToObjectGetter - fObjGetter = AliPHOSIndexToObject::GetInstance(ffileName.Data(),branchName,branchTitle) ; - fObjGetter->GetEvent(Nevent); + //========== Create ObjectGetter + AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ; + const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ; + gime->Event(Nevent); //Plot Primary Particles - TParticle * primary ; + const TParticle * primary ; Int_t iPrimary ; - for ( iPrimary = 0 ; iPrimary < fObjGetter->GimeNPrimaries() ; iPrimary++) + for ( iPrimary = 0 ; iPrimary < gime->NPrimaries() ; iPrimary++) { - primary = fObjGetter->GimePrimary(iPrimary) ; + primary = gime->Primary(iPrimary) ; Int_t primaryType = primary->GetPdgCode() ; if( (primaryType == 211)||(primaryType == -211)||(primaryType == 2212)||(primaryType == -2212) ) { Int_t moduleNumber ; Double_t primX, primZ ; - fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; + phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; if(moduleNumber==Nmod) charg->Fill(primZ,primX,primary->Energy()) ; } if( primaryType == 22 ) { Int_t moduleNumber ; Double_t primX, primZ ; - fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; - if(moduleNumber==Nmod) + phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; + if(moduleNumber==Nmod) phot->Fill(primZ,primX,primary->Energy()) ; } else{ if( primaryType == -2112 ) { Int_t moduleNumber ; Double_t primX, primZ ; - fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; + phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; if(moduleNumber==Nmod) nbar->Fill(primZ,primX,primary->Energy()) ; } @@ -181,16 +181,16 @@ void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,c } Int_t iSDigit ; - AliPHOSDigit * sdigit ; + const AliPHOSDigit * sdigit ; - for(iSDigit = 0; iSDigit < fObjGetter->GimeNSDigits(); iSDigit++) + for(iSDigit = 0; iSDigit < gime->NSDigits(); iSDigit++) { - sdigit = fObjGetter->GimeSDigit(iSDigit) ; + sdigit = gime->SDigit(iSDigit) ; Int_t relid[4]; - fGeom->AbsToRelNumbering(sdigit->GetId(), relid) ; + phosgeom->AbsToRelNumbering(sdigit->GetId(), relid) ; Float_t x,z ; - fGeom->RelPosInModule(relid,x,z) ; - Float_t e = fObjGetter->GimeSDigitizer()->Calibrate(sdigit->GetAmp()) ; + phosgeom->RelPosInModule(relid,x,z) ; + Float_t e = gime->SDigitizer()->Calibrate(sdigit->GetAmp()) ; if(relid[0]==Nmod){ if(relid[1]==0) //EMC sdigitOccupancy->Fill(x,z,e) ; @@ -203,15 +203,15 @@ void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,c //Plot digits Int_t iDigit ; - AliPHOSDigit * digit ; - for(iDigit = 0; iDigit < fObjGetter->GimeNDigits(); iDigit++) + const AliPHOSDigit * digit ; + for(iDigit = 0; iDigit < gime->NDigits(); iDigit++) { - digit = fObjGetter->GimeDigit(iDigit) ; + digit = gime->Digit(iDigit) ; Int_t relid[4]; - fGeom->AbsToRelNumbering(digit->GetId(), relid) ; + phosgeom->AbsToRelNumbering(digit->GetId(), relid) ; Float_t x,z ; - fGeom->RelPosInModule(relid,x,z) ; - Float_t e = fObjGetter->GimeSDigitizer()->Calibrate(digit->GetAmp()) ; + phosgeom->RelPosInModule(relid,x,z) ; + Float_t e = gime->SDigitizer()->Calibrate(digit->GetAmp()) ; if(relid[0]==Nmod){ if(relid[1]==0) //EMC digitOccupancy->Fill(x,z,e) ; @@ -227,8 +227,8 @@ void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,c Int_t irecp ; TVector3 pos ; - for(irecp = 0; irecp < fObjGetter->GimeNEmcRecPoints() ; irecp ++){ - AliPHOSEmcRecPoint * emc= fObjGetter->GimeEmcRecPoint(irecp) ; + for(irecp = 0; irecp < gime->NEmcRecPoints() ; irecp ++){ + const AliPHOSEmcRecPoint * emc= gime->EmcRecPoint(irecp) ; if(emc->GetPHOSMod()==Nmod){ emc->GetLocalPosition(pos) ; emcOccupancy->Fill(pos.X(),pos.Z(),emc->GetEnergy()); @@ -236,8 +236,8 @@ void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,c } - for(irecp = 0; irecp < fObjGetter->GimeNCpvRecPoints() ; irecp ++){ - AliPHOSRecPoint * cpv = fObjGetter->GimeCpvRecPoint(irecp) ; + for(irecp = 0; irecp < gime->NCpvRecPoints() ; irecp ++){ + const AliPHOSRecPoint * cpv = gime->CpvRecPoint(irecp) ; if((strcmp(cpv->ClassName(),"AliPHOSPpsdRecPoint" )) == 0){ // PPSD Rec Point AliPHOSPpsdRecPoint * ppsd = (AliPHOSPpsdRecPoint*) cpv ; ppsd->GetLocalPosition(pos) ; @@ -260,14 +260,14 @@ void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,c //Plot RecParticles - AliPHOSRecParticle * recParticle ; + const AliPHOSRecParticle * recParticle ; Int_t iRecParticle ; - for(iRecParticle = 0; iRecParticle < fObjGetter->GimeNRecParticles() ;iRecParticle++ ) + for(iRecParticle = 0; iRecParticle < gime->NRecParticles() ;iRecParticle++ ) { - recParticle = fObjGetter->GimeRecParticle(iRecParticle) ; + recParticle = gime->RecParticle(iRecParticle) ; Int_t moduleNumberRec ; Double_t recX, recZ ; - fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ; + phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ; if(moduleNumberRec == Nmod){ Double_t minDistance = 5. ; @@ -275,18 +275,18 @@ void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,c //extract list of primaries: it is stored at EMC RecPoints - Int_t emcIndex = fObjGetter->GimeTrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ; + Int_t emcIndex = gime->TrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ; Int_t numberofprimaries ; - Int_t * listofprimaries = fObjGetter->GimeEmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ; + Int_t * listofprimaries = gime->EmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ; Int_t index ; - TParticle * primary ; + const TParticle * primary ; Double_t distance = minDistance ; for ( index = 0 ; index < numberofprimaries ; index++){ - primary = fObjGetter->GimePrimary(listofprimaries[index]) ; + primary = gime->Primary(listofprimaries[index]) ; Int_t moduleNumber ; Double_t primX, primZ ; - fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, 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) @@ -298,7 +298,7 @@ void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,c if(closestPrimary >=0 ){ - Int_t primaryType = fObjGetter->GimePrimary(closestPrimary)->GetPdgCode() ; + Int_t primaryType = gime->Primary(closestPrimary)->GetPdgCode() ; if(primaryType==22) recPhot->Fill(recZ,recX,recParticle->Energy()) ; @@ -330,8 +330,7 @@ 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 - if(fObjGetter == 0) - fObjGetter = AliPHOSIndexToObject::GetInstance(ffileName.Data()) ; + AliPHOSGetter::GetInstance(ffileName.Data()) ; Int_t ibranch; TObjArray * branches; @@ -373,7 +372,7 @@ void AliPHOSAnalyze::Ls(){ void AliPHOSAnalyze::InvariantMass(const char* branchTitle) { // Calculates Real and Mixed invariant mass distributions - fObjGetter = AliPHOSIndexToObject::GetInstance(ffileName.Data(),"PHOSRP",branchTitle) ; + AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ; Int_t nMixedEvents = 4 ; //# of events used for calculation of 'mixed' distribution @@ -412,16 +411,17 @@ void AliPHOSAnalyze::Ls(){ //scan over all events Int_t event ; - for(event = 0; event < fObjGetter->GetMaxEvent(); event++ ){ - - fObjGetter->GetEvent(event); + Int_t maxevent = gAlice->TreeE()->GetEntries() ; + // for(event = 0; event < gime->MaxEvent(); event++ ){ + for(event = 0; event < maxevent; event++ ){ + gime->Event(event); //copy EM RecParticles to the "total" list - AliPHOSRecParticle * recParticle ; + const AliPHOSRecParticle * recParticle ; Int_t iRecParticle ; - for(iRecParticle = 0; iRecParticle < fObjGetter->GimeNRecParticles() ;iRecParticle++ ) + for(iRecParticle = 0; iRecParticle < gime->NRecParticles() ;iRecParticle++ ) { - recParticle = fObjGetter->GimeRecParticle(iRecParticle) ; + recParticle = gime->RecParticle(iRecParticle) ; if((recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA)|| (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM)) new( (*allRecParticleList)[iRecPhot++] ) AliPHOSRecParticle(*recParticle) ; @@ -431,7 +431,10 @@ void AliPHOSAnalyze::Ls(){ nRecParticles[mevent] = iRecPhot-1 ; //check, if it is time to calculate invariant mass? - if((mevent == 0) && (event +1 == fObjGetter->GetMaxEvent())){ + Int_t maxevent = gAlice->TreeE()->GetEntries() ; + if((mevent == 0) && (event +1 == maxevent)){ + + // if((mevent == 0) && (event +1 == gime->MaxEvent())){ //calculate invariant mass: Int_t irp1,irp2 ; @@ -525,44 +528,46 @@ void AliPHOSAnalyze::Ls(){ hEMEnergy = new TH2F("hEMEnergy", "Energy of EM with primary photon", 100, 0., 5., 100, 0., 5.); - fObjGetter = AliPHOSIndexToObject::GetInstance(ffileName.Data(),"PHOSRP",branchTitle) ; - fGeom = fObjGetter->GetPHOSGeometry() ; + AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ; + const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ; Int_t ievent; - for ( ievent=0; ievent < fObjGetter->GetMaxEvent() ; ievent++){ + Int_t maxevent = gAlice->TreeE()->GetEntries() ; + // for ( ievent=0; ievent < gime->MaxEvent() ; ievent++){ + for ( ievent=0; ievent < maxevent ; ievent++){ //read the current event - fObjGetter->GetEvent(ievent) ; + gime->Event(ievent) ; - AliPHOSRecParticle * recParticle ; + const AliPHOSRecParticle * recParticle ; Int_t iRecParticle ; - for(iRecParticle = 0; iRecParticle < fObjGetter->GimeNRecParticles() ;iRecParticle++ ){ - recParticle = fObjGetter->GimeRecParticle(iRecParticle) ; + for(iRecParticle = 0; iRecParticle < gime->NRecParticles() ;iRecParticle++ ){ + recParticle = gime->RecParticle(iRecParticle) ; //find the closest primary Int_t moduleNumberRec ; Double_t recX, recZ ; - fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ; + phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ; Double_t minDistance = 100. ; Int_t closestPrimary = -1 ; //extract list of primaries: it is stored at EMC RecPoints - Int_t emcIndex = fObjGetter->GimeTrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ; + Int_t emcIndex = gime->TrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ; Int_t numberofprimaries ; - Int_t * listofprimaries = fObjGetter->GimeEmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ; + Int_t * listofprimaries = gime->EmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ; Int_t index ; - TParticle * primary ; + const TParticle * primary ; Double_t distance = minDistance ; Double_t dX, dZ; Double_t dXmin = 0.; Double_t dZmin = 0. ; for ( index = 0 ; index < numberofprimaries ; index++){ - primary = fObjGetter->GimePrimary(listofprimaries[index]) ; + primary = gime->Primary(listofprimaries[index]) ; Int_t moduleNumber ; Double_t primX, primZ ; - fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; + phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; if(moduleNumberRec == moduleNumber) { dX = recX - primX; dZ = recZ - primZ; @@ -578,7 +583,7 @@ void AliPHOSAnalyze::Ls(){ //if found primary, fill histograms if(closestPrimary >=0 ){ - TParticle * primary = fObjGetter->GimePrimary(closestPrimary) ; + const TParticle * primary = gime->Primary(closestPrimary) ; if(primary->GetPdgCode() == 22){ hAllEnergy->Fill(primary->Energy(), recParticle->Energy()) ; if(recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA){ @@ -643,48 +648,48 @@ void AliPHOSAnalyze::PositionResolution(const char * branchTitle) "Delta X of any RP with primary photon",100, -2., 2.); - fObjGetter = AliPHOSIndexToObject::GetInstance(ffileName.Data(),"PHOSRP",branchTitle) ; - + AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ; + const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ; - fGeom = AliPHOSGeometry::GetInstance(((AliPHOS*)gAlice->GetModule("PHOS"))->GetGeometry()->GetName(), - ((AliPHOS*)gAlice->GetModule("PHOS"))->GetGeometry()->GetTitle() ); - Int_t ievent; - for ( ievent=0; ievent < fObjGetter->GetMaxEvent() ; ievent++){ + Int_t maxevent = gAlice->TreeE()->GetEntries() ; + // for ( ievent=0; ievent < gime->MaxEvent() ; ievent++){ + for ( ievent=0; ievent < maxevent ; ievent++){ + //read the current event - fObjGetter->GetEvent(ievent) ; + gime->Event(ievent) ; - AliPHOSRecParticle * recParticle ; + const AliPHOSRecParticle * recParticle ; Int_t iRecParticle ; - for(iRecParticle = 0; iRecParticle < fObjGetter->GimeNRecParticles() ;iRecParticle++ ){ - recParticle = fObjGetter->GimeRecParticle(iRecParticle) ; + for(iRecParticle = 0; iRecParticle < gime->NRecParticles() ;iRecParticle++ ){ + recParticle = gime->RecParticle(iRecParticle) ; //find the closest primary Int_t moduleNumberRec ; Double_t recX, recZ ; - fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ; + phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ; Double_t minDistance = 100. ; Int_t closestPrimary = -1 ; //extract list of primaries: it is stored at EMC RecPoints - Int_t emcIndex = fObjGetter->GimeTrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ; + Int_t emcIndex = gime->TrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ; Int_t numberofprimaries ; - Int_t * listofprimaries = fObjGetter->GimeEmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ; + Int_t * listofprimaries = gime->EmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ; Int_t index ; - TParticle * primary ; + const TParticle * primary ; Double_t distance = minDistance ; Double_t dX = 1000; // incredible number Double_t dZ = 1000; // for the case if no primary will be found Double_t dXmin = 0.; Double_t dZmin = 0. ; for ( index = 0 ; index < numberofprimaries ; index++){ - primary = fObjGetter->GimePrimary(listofprimaries[index]) ; + primary = gime->Primary(listofprimaries[index]) ; Int_t moduleNumber ; Double_t primX, primZ ; - fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; + phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; if(moduleNumberRec == moduleNumber) { dX = recX - primX; dZ = recZ - primZ; @@ -700,7 +705,7 @@ void AliPHOSAnalyze::PositionResolution(const char * branchTitle) //if found primary, fill histograms if(closestPrimary >=0 ){ - TParticle * primary = fObjGetter->GimePrimary(closestPrimary) ; + const TParticle * primary = gime->Primary(closestPrimary) ; if(primary->GetPdgCode() == 22){ hAllPosition->Fill(primary->Energy(), minDistance) ; hAllPositionX->Fill(primary->Energy(), dX) ; @@ -861,26 +866,27 @@ void AliPHOSAnalyze::Contamination(const char* RecPointsTitle){ - fObjGetter = AliPHOSIndexToObject::GetInstance(ffileName.Data(),"PHOSRP",RecPointsTitle) ; - fGeom = AliPHOSGeometry::GetInstance(((AliPHOS*)gAlice->GetModule("PHOS"))->GetGeometry()->GetName(), - ((AliPHOS*)gAlice->GetModule("PHOS"))->GetGeometry()->GetTitle() ); - + AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),RecPointsTitle) ; + const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ; + Int_t ievent; - for ( ievent=0; ievent < fObjGetter->GetMaxEvent() ; ievent++){ + Int_t maxevent = gAlice->TreeE()->GetEntries() ; + // for ( ievent=0; ievent < gime->MaxEvent() ; ievent++){ + for ( ievent=0; ievent < maxevent ; ievent++){ - fObjGetter->GetEvent(ievent) ; + gime->Event(ievent) ; //=========== Make spectrum of the primary photons - TParticle * primary ; + const TParticle * primary ; Int_t iPrimary ; - for( iPrimary = 0 ; iPrimary < fObjGetter->GimeNPrimaries() ; iPrimary++){ - primary = fObjGetter->GimePrimary(iPrimary) ; + for( iPrimary = 0 ; iPrimary < gime->NPrimaries() ; iPrimary++){ + primary = gime->Primary(iPrimary) ; Int_t primaryType = primary->GetPdgCode() ; if( primaryType == 22 ) { //check, if photons folls onto PHOS Int_t moduleNumber ; Double_t primX, primZ ; - fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; + phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; if(moduleNumber) hPrimary->Fill(primary->Energy()) ; @@ -888,36 +894,36 @@ void AliPHOSAnalyze::Contamination(const char* RecPointsTitle){ } //========== Now scan over RecParticles - AliPHOSRecParticle * recParticle ; + const AliPHOSRecParticle * recParticle ; Int_t iRecParticle ; - for(iRecParticle = 0; iRecParticle < fObjGetter->GimeNRecParticles(); iRecParticle++ ){ - recParticle = fObjGetter->GimeRecParticle(iRecParticle) ; + for(iRecParticle = 0; iRecParticle < gime->NRecParticles(); iRecParticle++ ){ + recParticle = gime->RecParticle(iRecParticle) ; //fill histo spectrum of all RecParticles hAllRP->Fill(CorrectedEnergy(recParticle->Energy())) ; //==========find the closest primary Int_t moduleNumberRec ; Double_t recX, recZ ; - fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ; + phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ; Double_t minDistance = 100. ; Int_t closestPrimary = -1 ; //extract list of primaries: it is stored at EMC RecPoints - Int_t emcIndex = fObjGetter->GimeTrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ; + Int_t emcIndex = gime->TrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ; Int_t numberofprimaries ; - Int_t * listofprimaries = fObjGetter->GimeEmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ; + Int_t * listofprimaries = gime->EmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ; Int_t index ; - TParticle * primary ; + const TParticle * primary ; Double_t distance = minDistance ; Double_t dX, dZ; Double_t dXmin = 0.; Double_t dZmin = 0. ; for ( index = 0 ; index < numberofprimaries ; index++){ - primary = fObjGetter->GimePrimary(listofprimaries[index]) ; + primary = gime->Primary(listofprimaries[index]) ; Int_t moduleNumber ; Double_t primX, primZ ; - fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; + phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ; if(moduleNumberRec == moduleNumber) { dX = recX - primX; dZ = recZ - primZ; @@ -934,7 +940,7 @@ void AliPHOSAnalyze::Contamination(const char* RecPointsTitle){ //===========define the "type" of closest primary if(closestPrimary >=0 ){ Int_t primaryCode = -1; - TParticle * primary = fObjGetter->GimePrimary(closestPrimary) ; + const TParticle * primary = gime->Primary(closestPrimary) ; Int_t primaryType = primary->GetPdgCode() ; if(primaryType == 22) // photon ? primaryCode = 0 ; @@ -947,10 +953,12 @@ void AliPHOSAnalyze::Contamination(const char* RecPointsTitle){ else if(primaryType == -2122) //Anti proton primaryCode = 4 ; - else - if(fObjGetter->GimePrimary(closestPrimary)->GetPDG()->Charge()) + 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::kGAMMA){ @@ -1070,8 +1078,10 @@ void AliPHOSAnalyze::Contamination(const char* RecPointsTitle){ //print Final Table + maxevent = gAlice->TreeE()->GetEntries() ; + // cout << "Resolutions: Analyzed " << gime->MaxEvent() << " event(s)" << endl ; - cout << "Resolutions: Analyzed " << fObjGetter->GetMaxEvent() << " event(s)" << endl ; + cout << "Resolutions: Analyzed " << maxevent << " event(s)" << endl ; cout << endl ; cout << " Primary: Photon Neutron Antineutron Charged hadron AntiProton" << endl ; diff --git a/PHOS/AliPHOSAnalyze.h b/PHOS/AliPHOSAnalyze.h index b940e26b524..acb0147ff09 100644 --- a/PHOS/AliPHOSAnalyze.h +++ b/PHOS/AliPHOSAnalyze.h @@ -24,7 +24,7 @@ class TH2F ; class AliPHOSv1 ; class AliPHOSGeometry ; -class AliPHOSIndexToObject ; +class AliPHOSGetter ; class AliPHOSAnalyze : public TObject { @@ -71,8 +71,6 @@ private: Float_t fCorrection ; //! Conversion coefficient between True and Reconstructed energies Int_t fEvt ; //! the evt number being processed - AliPHOSGeometry * fGeom ; //! the PHOS Geometry object - AliPHOSIndexToObject * fObjGetter ; //! provides methods to retrieve objects from their index in a list TString ffileName ; //! the root file that contains the data diff --git a/PHOS/AliPHOSClusterizer.cxx b/PHOS/AliPHOSClusterizer.cxx index c4d8dc4f616..03cfac03027 100644 --- a/PHOS/AliPHOSClusterizer.cxx +++ b/PHOS/AliPHOSClusterizer.cxx @@ -36,13 +36,13 @@ ClassImp(AliPHOSClusterizer) //____________________________________________________________________________ - AliPHOSClusterizer::AliPHOSClusterizer():TTask("AliPHOSClusterizer","") + AliPHOSClusterizer::AliPHOSClusterizer():TTask("","") { // ctor } //____________________________________________________________________________ -AliPHOSClusterizer::AliPHOSClusterizer(const char* HeaderFile,const char* DigitsFile = 0): -TTask("AliPHOSClusterizer","") +AliPHOSClusterizer::AliPHOSClusterizer(const char* headerFile, const char* name): +TTask(name, headerFile) { // ctor } diff --git a/PHOS/AliPHOSClusterizer.h b/PHOS/AliPHOSClusterizer.h index ff9a0ba1afa..5963be46d7b 100644 --- a/PHOS/AliPHOSClusterizer.h +++ b/PHOS/AliPHOSClusterizer.h @@ -22,8 +22,8 @@ class AliPHOSClusterizer : public TTask { public: - AliPHOSClusterizer() ; // ctor - AliPHOSClusterizer(const char * headerFile,const char * digitsBrancheTitle); + AliPHOSClusterizer() ; // default ctor + AliPHOSClusterizer(const char * headerFile, const char * name) ; virtual ~AliPHOSClusterizer() ; // dtor virtual Float_t GetEmcClusteringThreshold()const = 0 ; @@ -46,13 +46,11 @@ public: virtual void SetCpvLocalMaxCut(Float_t cut) = 0 ; virtual void SetCpvLogWeight(Float_t w) = 0 ; virtual void SetPpsdClusteringThreshold(Float_t cluth) = 0 ; - virtual void SetDigitsBranch(const char * title) = 0 ; virtual void SetRecPointsBranch(const char *title) = 0 ; - virtual void SetUnfolding(Bool_t toUnfold ) = 0 ; + virtual const char * Version() const = 0 ; - ClassDef(AliPHOSClusterizer,1) // Clusterization algorithm class } ; diff --git a/PHOS/AliPHOSClusterizerv1.cxx b/PHOS/AliPHOSClusterizerv1.cxx index 663ca988d96..6c063afe612 100644 --- a/PHOS/AliPHOSClusterizerv1.cxx +++ b/PHOS/AliPHOSClusterizerv1.cxx @@ -79,16 +79,15 @@ #include "AliPHOSEmcRecPoint.h" #include "AliPHOS.h" #include "AliPHOSPpsdRecPoint.h" +#include "AliPHOSGetter.h" #include "AliRun.h" ClassImp(AliPHOSClusterizerv1) //____________________________________________________________________________ - AliPHOSClusterizerv1::AliPHOSClusterizerv1():AliPHOSClusterizer() + AliPHOSClusterizerv1::AliPHOSClusterizerv1() : AliPHOSClusterizer() { // default ctor (to be used mainly by Streamer) - SetName("AliPHOSClusterizer"); - SetTitle("Version 1") ; fNumberOfCpvClusters = 0 ; fNumberOfEmcClusters = 0 ; @@ -102,25 +101,19 @@ ClassImp(AliPHOSClusterizerv1) fW0 = 4.5 ; fW0CPV = 4.0 ; - - fGeom = 0 ; - - fDigits = 0 ; - fDigitizer = 0 ; - fEmcRecPoints = 0 ; - fCpvRecPoints = 0 ; - fIsInitialized = kFALSE ; + fHeaderFileName = "" ; + fDigitsBranchTitle = "" ; } + //____________________________________________________________________________ -AliPHOSClusterizerv1::AliPHOSClusterizerv1(const char* headerFile,const char* digitsFile):AliPHOSClusterizer() +AliPHOSClusterizerv1::AliPHOSClusterizerv1(const char* headerFile,const char* name) +:AliPHOSClusterizer(headerFile, name) { // ctor with the indication of the file where header Tree and digits Tree are stored - - SetName("AliPHOSClusterizer"); - SetTitle("Version 1") ; + fNumberOfCpvClusters = 0 ; fNumberOfEmcClusters = 0 ; @@ -136,33 +129,72 @@ AliPHOSClusterizerv1::AliPHOSClusterizerv1(const char* headerFile,const char* di fToUnfold = kTRUE ; - fHeaderFileName = headerFile ; - fDigitsBranchTitle = digitsFile ; + fHeaderFileName = GetTitle() ; + fDigitsBranchTitle = GetName() ; - fIsInitialized = kFALSE ; + TString tempo(GetName()) ; + tempo.Append(Version()) ; + SetName(tempo.Data()) ; Init() ; } + //____________________________________________________________________________ void AliPHOSClusterizerv1::Exec(Option_t * option) { - // Steering function + // Steering method - if(!fIsInitialized) Init() ; + if( strcmp(GetName(), "")== 0 ) + Init() ; if(strstr(option,"tim")) - gBenchmark->Start("PHOSClusterizer"); + gBenchmark->Start("PHOSClusterizerv1"); - Int_t nEvents = (Int_t) gAlice->TreeE()->GetEntries() ; + if(strstr(option,"print")) + Print("") ; + + //check, if the branch with name of this" already exits? + TObjArray * lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ; + TIter next(lob) ; + TBranch * branch = 0 ; + Bool_t phosemcfound = kFALSE, phoscpvfound = kFALSE, clusterizerfound = kFALSE ; - for(fEvent = 0;fEvent< nEvents; fEvent++){ - if(!ReadDigits()) //reads digits for event fEvent + TString taskName(GetName()) ; + taskName.ReplaceAll(Version(), "") ; + + while ( (branch = (TBranch*)next()) && (!phosemcfound || !phoscpvfound || !clusterizerfound) ) { + if ( (strcmp(branch->GetName(), "PHOSEmcRP")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) + phosemcfound = kTRUE ; + + else if ( (strcmp(branch->GetName(), "PHOSCpvRP")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) + phoscpvfound = kTRUE ; + + else if ( (strcmp(branch->GetName(), "AliPHOSClusterizer")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) + clusterizerfound = kTRUE ; + } + + if ( phoscpvfound || phosemcfound || clusterizerfound ) { + cerr << "WARNING: AliPHOSClusterizer::Exec -> Emc(Cpv)RecPoints and/or Clusterizer branch with name " + << taskName.Data() << " already exits" << endl ; + return ; + } + + Int_t nevents = (Int_t) gAlice->TreeE()->GetEntries() ; + Int_t ievent ; + + for(ievent = 0; ievent < nevents; ievent++){ + + if(!ReadDigits(ievent)) //reads digits for event fEvent return; + MakeClusters() ; - if(fToUnfold) MakeUnfolding() ; - WriteRecPoints() ; + if(fToUnfold) + MakeUnfolding() ; + + WriteRecPoints(ievent) ; + if(strstr(option,"deb")) PrintRecPoints(option) ; } @@ -171,7 +203,7 @@ void AliPHOSClusterizerv1::Exec(Option_t * option) gBenchmark->Stop("PHOSClusterizer"); cout << "AliPHOSClusterizer:" << endl ; cout << " took " << gBenchmark->GetCpuTime("PHOSClusterizer") << " seconds for Clusterizing " - << gBenchmark->GetCpuTime("PHOSClusterizer")/nEvents << " seconds per event " << endl ; + << gBenchmark->GetCpuTime("PHOSClusterizer")/nevents << " seconds per event " << endl ; cout << endl ; } @@ -185,6 +217,10 @@ Bool_t AliPHOSClusterizerv1::FindFit(AliPHOSEmcRecPoint * emcRP, int * maxAt, Fl // The initial values for fitting procedure are set equal to the positions of local maxima. // Cluster will be fitted as a superposition of nPar/3 electromagnetic showers + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + TClonesArray * digits = gime->Digits() ; + + gMinuit->mncler(); // Reset Minuit's list of paramters gMinuit->SetPrintLevel(-1) ; // No Printout gMinuit->SetFCN(AliPHOSClusterizerv1::UnfoldingChiSquare) ; @@ -192,7 +228,7 @@ Bool_t AliPHOSClusterizerv1::FindFit(AliPHOSEmcRecPoint * emcRP, int * maxAt, Fl TList * toMinuit = new TList(); toMinuit->AddAt(emcRP,0) ; - toMinuit->AddAt(fDigits,1) ; + toMinuit->AddAt(digits,1) ; gMinuit->SetObjectFit(toMinuit) ; // To tranfer pointer to UnfoldingChiSquare @@ -205,15 +241,16 @@ Bool_t AliPHOSClusterizerv1::FindFit(AliPHOSEmcRecPoint * emcRP, int * maxAt, Fl Int_t iDigit ; + const AliPHOSGeometry * geom = gime->PHOSGeometry() ; for(iDigit = 0; iDigit < nDigits; iDigit++){ digit = (AliPHOSDigit *) maxAt[iDigit]; Int_t relid[4] ; - Float_t x ; - Float_t z ; - fGeom->AbsToRelNumbering(digit->GetId(), relid) ; - fGeom->RelPosInModule(relid, x, z) ; + Float_t x = 0.; + Float_t z = 0.; + geom->AbsToRelNumbering(digit->GetId(), relid) ; + geom->RelPosInModule(relid, x, z) ; Float_t energy = maxAtEnergy[iDigit] ; @@ -270,42 +307,31 @@ void AliPHOSClusterizerv1::Init() { // Make all memory allocations which can not be done in default constructor. // Attach the Clusterizer task to the list of PHOS tasks + + if ( strcmp(GetTitle(), "") == 0 ) + SetTitle("galice.root") ; - if(!fIsInitialized){ - if(fHeaderFileName.IsNull()) - fHeaderFileName = "galice.root" ; - - TFile * file = (TFile*) gROOT->GetFile(fHeaderFileName.Data() ) ; - - if(file == 0){ - if(fHeaderFileName.Contains("rfio")) // if we read file using HPSS - file = TFile::Open(fHeaderFileName.Data(),"update") ; - else - file = new TFile(fHeaderFileName.Data(),"update") ; - gAlice = (AliRun *) file->Get("gAlice") ; - } - - AliPHOS * phos = (AliPHOS *) gAlice->GetDetector("PHOS") ; - fGeom = AliPHOSGeometry::GetInstance(phos->GetGeometry()->GetName(),phos->GetGeometry()->GetTitle() ); - - fDigits = new TClonesArray("AliPHOSDigit",10) ; - fDigitizer = new AliPHOSDigitizer() ; - fEmcRecPoints = new TObjArray(200) ; - fCpvRecPoints = new TObjArray(200) ; - fEmcRecPoints->SetOwner(); // This lets Clear() really detete rec.points in array - fCpvRecPoints->SetOwner(); - - if(!gMinuit) gMinuit = new TMinuit(100) ; - - //add Task to //YSAlice/tasks/Reconstructioner/PHOS - TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("YSAlice") ; - TTask * aliceRe = (TTask*)alice->FindObject("tasks/Reconstructioner") ; - TTask * phosRe = (TTask*)aliceRe->GetListOfTasks()->FindObject("PHOS") ; - phosRe->Add(this) ; + TString taskName(GetName()) ; + taskName.ReplaceAll(Version(), "") ; - fIsInitialized = kTRUE ; - } + AliPHOSGetter * gime = AliPHOSGetter::GetInstance(GetTitle(), taskName.Data()) ; + if ( gime == 0 ) { + cerr << "ERROR: AliPHOSClusterizerv1::Init -> Could not obtain the Getter object !" << endl ; + return ; + } + + if(!gMinuit) + gMinuit = new TMinuit(100) ; + + //add Task to //YSAlice/tasks/Reconstructioner/PHOS + TTask * aliceRe = (TTask*)gROOT->FindObjectAny("YSAlice/tasks/Reconstructioner") ; + TTask * phosRe = (TTask*)aliceRe->GetListOfTasks()->FindObject("PHOS") ; + phosRe->Add(this) ; + // create a folder on the white board //YSAlice/WhiteBoard/RecPoints/PHOS/recpointsName + gime->Post(GetTitle(), "R", taskName.Data() ) ; + } + //____________________________________________________________________________ Int_t AliPHOSClusterizerv1::AreNeighbours(AliPHOSDigit * d1, AliPHOSDigit * d2)const { @@ -316,13 +342,15 @@ Int_t AliPHOSClusterizerv1::AreNeighbours(AliPHOSDigit * d1, AliPHOSDigit * d2)c // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster // which is compared to a digit (d2) not yet in a cluster + const AliPHOSGeometry * geom = AliPHOSGetter::GetInstance()->PHOSGeometry() ; + Int_t rv = 0 ; Int_t relid1[4] ; - fGeom->AbsToRelNumbering(d1->GetId(), relid1) ; + geom->AbsToRelNumbering(d1->GetId(), relid1) ; Int_t relid2[4] ; - fGeom->AbsToRelNumbering(d2->GetId(), relid2) ; + geom->AbsToRelNumbering(d2->GetId(), relid2) ; if ( (relid1[0] == relid2[0]) && (relid1[1]==relid2[1]) ) { // inside the same PHOS module and the same PPSD Module Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ; @@ -347,7 +375,7 @@ Int_t AliPHOSClusterizerv1::AreNeighbours(AliPHOSDigit * d1, AliPHOSDigit * d2)c //Do NOT clusterize upper PPSD if( IsInPpsd(d1) && IsInPpsd(d2) && relid1[1] > 0 && - relid1[1] < fGeom->GetNumberOfPadsPhi()*fGeom->GetNumberOfPadsPhi() ) rv = 2 ; + relid1[1] < geom->GetNumberOfPadsPhi()*geom->GetNumberOfPadsPhi() ) rv = 2 ; return rv ; } @@ -359,9 +387,10 @@ Bool_t AliPHOSClusterizerv1::IsInEmc(AliPHOSDigit * digit) const // Tells if (true) or not (false) the digit is in a PHOS-EMC module Bool_t rv = kFALSE ; + const AliPHOSGeometry * geom = AliPHOSGetter::GetInstance()->PHOSGeometry() ; Int_t relid[4] ; - fGeom->AbsToRelNumbering(digit->GetId(), relid) ; + geom->AbsToRelNumbering(digit->GetId(), relid) ; if ( relid[1] == 0 ) rv = kTRUE; @@ -374,11 +403,12 @@ Bool_t AliPHOSClusterizerv1::IsInPpsd(AliPHOSDigit * digit) const // Tells if (true) or not (false) the digit is in a PHOS-PPSD module Bool_t rv = kFALSE ; + const AliPHOSGeometry * geom = AliPHOSGetter::GetInstance()->PHOSGeometry() ; Int_t relid[4] ; - fGeom->AbsToRelNumbering(digit->GetId(), relid) ; + geom->AbsToRelNumbering(digit->GetId(), relid) ; - if ( relid[1] > 0 && relid[0] > fGeom->GetNCPVModules() ) rv = kTRUE; + if ( relid[1] > 0 && relid[0] > geom->GetNCPVModules() ) rv = kTRUE; return rv ; } @@ -389,16 +419,17 @@ Bool_t AliPHOSClusterizerv1::IsInCpv(AliPHOSDigit * digit) const // Tells if (true) or not (false) the digit is in a PHOS-CPV module Bool_t rv = kFALSE ; + const AliPHOSGeometry * geom = AliPHOSGetter::GetInstance()->PHOSGeometry() ; Int_t relid[4] ; - fGeom->AbsToRelNumbering(digit->GetId(), relid) ; + geom->AbsToRelNumbering(digit->GetId(), relid) ; - if ( relid[1] > 0 && relid[0] <= fGeom->GetNCPVModules() ) rv = kTRUE; + if ( relid[1] > 0 && relid[0] <= geom->GetNCPVModules() ) rv = kTRUE; return rv ; } //____________________________________________________________________________ -Bool_t AliPHOSClusterizerv1::ReadDigits() +Bool_t AliPHOSClusterizerv1::ReadDigits(Int_t event) { // reads digitis with specified title from TreeD @@ -406,147 +437,99 @@ Bool_t AliPHOSClusterizerv1::ReadDigits() fNumberOfCpvClusters = 0 ; // Get Digits Tree header from file - gAlice->GetEvent(fEvent) ; - gAlice->SetEvent(fEvent) ; - - TTree * treeD = gAlice->TreeD() ; + gAlice->GetEvent(event) ; + gAlice->SetEvent(event) ; - if(treeD==0){ - char treeName[20]; - sprintf(treeName,"TreeD%d",fEvent); - cout << "Error in AliPHOSClusterizerv1 : no "<TreeD()==0) { + cerr << "ERROR: AliPHOSClusterizerv1::ReadDigits There is no Digit Tree" << endl; + return kFALSE; } - + + //set address of the Digits and Digitizer TBranch * digitsBranch = 0; TBranch * digitizerBranch = 0; - - TObjArray * branches = treeD->GetListOfBranches() ; - Int_t ibranch; - Bool_t phosNotFound = kTRUE ; - Bool_t digitizerNotFound = kTRUE ; + TObjArray * lob = (TObjArray*)gAlice->TreeD()->GetListOfBranches() ; + TIter next(lob) ; + TBranch * branch = 0 ; + Bool_t phosfound = kFALSE, digitizerfound = kFALSE ; - for(ibranch = 0;ibranch GetEntries();ibranch++){ + TString taskName(GetName()) ; + taskName.ReplaceAll(Version(), "") ; - if(phosNotFound){ - digitsBranch=(TBranch *) branches->At(ibranch) ; - if( fDigitsBranchTitle.CompareTo(digitsBranch->GetTitle())==0 ) - if( strcmp(digitsBranch->GetName(),"PHOS") == 0) - phosNotFound = kFALSE ; + while ( (branch = (TBranch*)next()) && (!phosfound || !digitizerfound) ) { + if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) { + phosfound = kTRUE ; + digitsBranch = branch ; } - if(digitizerNotFound){ - digitizerBranch = (TBranch *) branches->At(ibranch) ; - if( fDigitsBranchTitle.CompareTo(digitizerBranch->GetTitle()) == 0) - if( strcmp(digitizerBranch->GetName(),"AliPHOSDigitizer") == 0) - digitizerNotFound = kFALSE ; + else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) { + digitizerfound = kTRUE ; + digitizerBranch = branch ; } - } + if ( !phosfound || !digitizerfound ) { + cerr << "WARNING: AliPHOSClusterizerv1::ReadDigits -> Digits and/or Digitizer branch with name " << taskName.Data() + << " not found" << endl ; + return kFALSE ; + } - if(digitizerNotFound || phosNotFound){ - cout << "ERROR in AliPHOSClusterizerv1: " << endl ; - cout << " Can't find Branch with digits or Digitizer "<< endl ; ; - cout << " Do nothing" <Digits() ; + digits->Clear() ; + digitsBranch->SetAddress(&digits) ; - digitsBranch->SetAddress(&fDigits) ; - digitizerBranch->SetAddress(&fDigitizer) ; + AliPHOSDigitizer * digitizer = gime->Digitizer() ; + digitizerBranch->SetAddress(&digitizer) ; digitsBranch->GetEntry(0) ; digitizerBranch->GetEntry(0) ; - fPedestal = fDigitizer->GetPedestal() ; - fSlope = fDigitizer->GetSlope() ; + fPedestal = digitizer->GetPedestal() ; + fSlope = digitizer->GetSlope() ; + return kTRUE ; } //____________________________________________________________________________ -void AliPHOSClusterizerv1::WriteRecPoints() +void AliPHOSClusterizerv1::WriteRecPoints(Int_t event) { - // Checks, if PHOSEmcRP etc. branches with given title already exist, - // if yes exits without writing, - // else creates new branches with given title + + // Creates new branches with given title // fills and writes into TreeR. + AliPHOSGetter *gime = AliPHOSGetter::GetInstance() ; + TObjArray * emcRecPoints = gime->EmcRecPoints() ; + TObjArray * cpvRecPoints = gime->CpvRecPoints() ; + TClonesArray * digits = gime->Digits() ; + Int_t index ; //Evaluate poisition, dispersion and other RecPoint properties... - for(index = 0; index < fEmcRecPoints->GetEntries(); index++) - ((AliPHOSEmcRecPoint *)fEmcRecPoints->At(index))->EvalAll(fW0,fDigits) ; + for(index = 0; index < emcRecPoints->GetEntries(); index++) + ((AliPHOSEmcRecPoint *)emcRecPoints->At(index))->EvalAll(fW0,digits) ; - fEmcRecPoints->Sort() ; + emcRecPoints->Sort() ; - for(index = 0; index < fEmcRecPoints->GetEntries(); index++) - ((AliPHOSEmcRecPoint *)fEmcRecPoints->At(index))->SetIndexInList(index) ; + for(index = 0; index < emcRecPoints->GetEntries(); index++) + ((AliPHOSEmcRecPoint *)emcRecPoints->At(index))->SetIndexInList(index) ; - fEmcRecPoints->Expand(fEmcRecPoints->GetEntriesFast()) ; + emcRecPoints->Expand(emcRecPoints->GetEntriesFast()) ; //Now the same for CPV - for(index = 0; index < fCpvRecPoints->GetEntries(); index++) - ((AliPHOSRecPoint *)fCpvRecPoints->At(index))->EvalAll(fW0CPV,fDigits) ; + for(index = 0; index < cpvRecPoints->GetEntries(); index++) + ((AliPHOSRecPoint *)cpvRecPoints->At(index))->EvalAll(fW0CPV,digits) ; - fCpvRecPoints->Sort() ; + cpvRecPoints->Sort() ; - for(index = 0; index < fCpvRecPoints->GetEntries(); index++) - ((AliPHOSRecPoint *)fCpvRecPoints->At(index))->SetIndexInList(index) ; + for(index = 0; index < cpvRecPoints->GetEntries(); index++) + ((AliPHOSRecPoint *)cpvRecPoints->At(index))->SetIndexInList(index) ; - fCpvRecPoints->Expand(fCpvRecPoints->GetEntriesFast()) ; + cpvRecPoints->Expand(cpvRecPoints->GetEntriesFast()) ; + gAlice->GetEvent(event) ; if(gAlice->TreeR()==0) gAlice->MakeTree("R") ; - - //Check, if branches already exist - TBranch * emcBranch = 0; - TBranch * cpvBranch = 0; - TBranch * clusterizerBranch = 0; - - TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ; - Int_t ibranch; - Bool_t emcNotFound = kTRUE ; - Bool_t cpvNotFound = kTRUE ; - Bool_t clusterizerNotFound = kTRUE ; - - for(ibranch = 0;ibranch GetEntries();ibranch++){ - - if(emcNotFound){ - emcBranch=(TBranch *) branches->At(ibranch) ; - if( fRecPointsBranchTitle.CompareTo(emcBranch->GetTitle())==0 ){ - if( strcmp(emcBranch->GetName(),"PHOSEmcRP") == 0) { - emcNotFound = kFALSE ; - } - } - } - if(cpvNotFound){ - cpvBranch=(TBranch *) branches->At(ibranch) ; - if( fRecPointsBranchTitle.CompareTo(cpvBranch->GetTitle())==0 ){ - if( strcmp(cpvBranch->GetName(),"PHOSCpvRP") == 0) { - cpvNotFound = kFALSE ; - } - } - } - - if(clusterizerNotFound){ - clusterizerBranch = (TBranch *) branches->At(ibranch) ; - if( fRecPointsBranchTitle.CompareTo(clusterizerBranch->GetTitle()) == 0){ - if( strcmp(clusterizerBranch->GetName(),"AliPHOSClusterizer") == 0) { - clusterizerNotFound = kFALSE ; - } - } - } - - } - - if(!(clusterizerNotFound && emcNotFound && cpvNotFound)){ - cout << "AliPHOSClusterizer error" << endl; - cout << " Branches PHOSEmcRP, PHOSCpvRP and AliPHOSClusterizer " << endl ; - cout << " with title '" << fRecPointsBranchTitle.Data() <<"' already exist" << endl ; - cout << " can not overwrite " << endl ; - return ; - } - //Make branches in TreeR for RecPoints and Clusterizer char * filename = 0; if(gSystem->Getenv("CONFIG_SPLIT_FILE")!=0){ //generating file name @@ -557,11 +540,14 @@ void AliPHOSClusterizerv1::WriteRecPoints() //Make new branches TDirectory *cwd = gDirectory; + TString branchName(GetName()) ; + branchName.ReplaceAll(Version(), "") ; + //First EMC Int_t bufferSize = 32000 ; Int_t splitlevel = 0 ; - emcBranch = gAlice->TreeR()->Branch("PHOSEmcRP","TObjArray",&fEmcRecPoints,bufferSize,splitlevel); - emcBranch->SetTitle(fRecPointsBranchTitle.Data()); + TBranch * emcBranch = gAlice->TreeR()->Branch("PHOSEmcRP","TObjArray",&emcRecPoints,bufferSize,splitlevel); + emcBranch->SetTitle(branchName); if (filename) { emcBranch->SetFile(filename); TIter next( emcBranch->GetListOfBranches()); @@ -574,8 +560,8 @@ void AliPHOSClusterizerv1::WriteRecPoints() } //Now CPV branch - cpvBranch = gAlice->TreeR()->Branch("PHOSCpvRP","TObjArray",&fCpvRecPoints,bufferSize,splitlevel); - cpvBranch->SetTitle(fRecPointsBranchTitle.Data()); + TBranch * cpvBranch = gAlice->TreeR()->Branch("PHOSCpvRP","TObjArray",&cpvRecPoints,bufferSize,splitlevel); + cpvBranch->SetTitle(branchName); if (filename) { cpvBranch->SetFile(filename); TIter next( cpvBranch->GetListOfBranches()); @@ -587,10 +573,10 @@ void AliPHOSClusterizerv1::WriteRecPoints() } //And Finally clusterizer branch - AliPHOSClusterizerv1 * cl = this ; - clusterizerBranch = gAlice->TreeR()->Branch("AliPHOSClusterizer","AliPHOSClusterizerv1", + AliPHOSClusterizerv1 * cl = (AliPHOSClusterizerv1*)gime->Clusterizer(GetName()) ; + TBranch * clusterizerBranch = gAlice->TreeR()->Branch("AliPHOSClusterizer","AliPHOSClusterizerv1", &cl,bufferSize,splitlevel); - clusterizerBranch->SetTitle(fRecPointsBranchTitle.Data()); + clusterizerBranch->SetTitle(branchName); if (filename) { clusterizerBranch->SetFile(filename); TIter next( clusterizerBranch->GetListOfBranches()); @@ -614,18 +600,25 @@ void AliPHOSClusterizerv1::MakeClusters() { // Steering method to construct the clusters stored in a list of Reconstructed Points // A cluster is defined as a list of neighbour digits - fEmcRecPoints->Clear() ; - fCpvRecPoints->Clear() ; - + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + + TObjArray * emcRecPoints = gime->EmcRecPoints() ; + TObjArray * cpvRecPoints = gime->CpvRecPoints() ; + emcRecPoints->Clear() ; + cpvRecPoints->Clear() ; + + TClonesArray * digits = gime->Digits() ; + TClonesArray * digitsC = (TClonesArray*)digits->Clone() ; + + // Clusterization starts - TClonesArray * digits = (TClonesArray*)fDigits->Clone() ; - TIter nextdigit(digits) ; + TIter nextdigit(digitsC) ; AliPHOSDigit * digit ; Bool_t notremoved = kTRUE ; - while ( (digit = (AliPHOSDigit *)nextdigit()) ) { // scan over the list of digits + while ( (digit = (AliPHOSDigit *)nextdigit()) ) { // scan over the list of digitsC AliPHOSRecPoint * clu = 0 ; TArrayI clusterdigitslist(1500) ; @@ -636,41 +629,45 @@ void AliPHOSClusterizerv1::MakeClusters() ( IsInCpv (digit) && Calibrate(digit->GetAmp()) > fCpvClusteringThreshold ) ) { Int_t iDigitInCluster = 0 ; - + if ( IsInEmc(digit) ) { // start a new EMC RecPoint - if(fNumberOfEmcClusters >= fEmcRecPoints->GetSize()) fEmcRecPoints->Expand(2*fNumberOfEmcClusters+1) ; - fEmcRecPoints->AddAt(new AliPHOSEmcRecPoint(), fNumberOfEmcClusters) ; - clu = (AliPHOSEmcRecPoint *) fEmcRecPoints->At(fNumberOfEmcClusters) ; + if(fNumberOfEmcClusters >= emcRecPoints->GetSize()) + emcRecPoints->Expand(2*fNumberOfEmcClusters+1) ; + + emcRecPoints->AddAt(new AliPHOSEmcRecPoint(), fNumberOfEmcClusters) ; + clu = (AliPHOSEmcRecPoint *) emcRecPoints->At(fNumberOfEmcClusters) ; fNumberOfEmcClusters++ ; clu->AddDigit(*digit, Calibrate(digit->GetAmp())) ; clusterdigitslist[iDigitInCluster] = digit->GetIndexInList() ; iDigitInCluster++ ; - digits->Remove(digit) ; + digitsC->Remove(digit) ; } else { // start a new PPSD/CPV cluster - if(fNumberOfCpvClusters >= fCpvRecPoints->GetSize()) fCpvRecPoints->Expand(2*fNumberOfCpvClusters+1); + if(fNumberOfCpvClusters >= cpvRecPoints->GetSize()) + cpvRecPoints->Expand(2*fNumberOfCpvClusters+1); + if(IsInPpsd(digit)) - fCpvRecPoints->AddAt(new AliPHOSPpsdRecPoint(),fNumberOfCpvClusters) ; + cpvRecPoints->AddAt(new AliPHOSPpsdRecPoint(),fNumberOfCpvClusters) ; else - fCpvRecPoints->AddAt(new AliPHOSCpvRecPoint(), fNumberOfCpvClusters) ; - clu = (AliPHOSPpsdRecPoint *) fCpvRecPoints->At(fNumberOfCpvClusters) ; - fNumberOfCpvClusters++ ; + cpvRecPoints->AddAt(new AliPHOSCpvRecPoint(), fNumberOfCpvClusters) ; + clu = (AliPHOSPpsdRecPoint *) cpvRecPoints->At(fNumberOfCpvClusters) ; + fNumberOfCpvClusters++ ; clu->AddDigit(*digit, Calibrate(digit->GetAmp()) ) ; clusterdigitslist[iDigitInCluster] = digit->GetIndexInList() ; iDigitInCluster++ ; - digits->Remove(digit) ; + digitsC->Remove(digit) ; nextdigit.Reset() ; - // Here we remove resting EMC digits, which cannot make cluster + // Here we remove remaining EMC digits, which cannot make a cluster if( notremoved ) { while( ( digit = (AliPHOSDigit *)nextdigit() ) ) { if( IsInEmc(digit) ) - digits->Remove(digit) ; + digitsC->Remove(digit) ; else break ; } @@ -684,7 +681,7 @@ void AliPHOSClusterizerv1::MakeClusters() AliPHOSDigit * digitN ; index = 0 ; while (index < iDigitInCluster){ // scan over digits already in cluster - digit = (AliPHOSDigit*)fDigits->At(clusterdigitslist[index]) ; + digit = (AliPHOSDigit*)digits->At(clusterdigitslist[index]) ; index++ ; while ( (digitN = (AliPHOSDigit *)nextdigit()) ) { // scan over the reduced list of digits Int_t ineb = AreNeighbours(digit, digitN); // call (digit,digitN) in THAT oder !!!!! @@ -695,7 +692,7 @@ void AliPHOSClusterizerv1::MakeClusters() clu->AddDigit(*digitN, Calibrate( digitN->GetAmp() ) ) ; clusterdigitslist[iDigitInCluster] = digitN->GetIndexInList() ; iDigitInCluster++ ; - digits->Remove(digitN) ; + digitsC->Remove(digitN) ; break ; case 2 : // too far from each other goto endofloop; @@ -713,7 +710,7 @@ void AliPHOSClusterizerv1::MakeClusters() } // while digit - delete digits ; + delete digitsC ; } @@ -723,28 +720,35 @@ void AliPHOSClusterizerv1::MakeUnfolding() // Unfolds clusters using the shape of an ElectroMagnetic shower // Performs unfolding of all EMC/CPV but NOT ppsd clusters + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + + const AliPHOSGeometry * geom = gime->PHOSGeometry() ; + TObjArray * emcRecPoints = gime->EmcRecPoints() ; + TObjArray * cpvRecPoints = gime->CpvRecPoints() ; + TClonesArray * digits = gime->Digits() ; + // Unfold first EMC clusters if(fNumberOfEmcClusters > 0){ - Int_t nModulesToUnfold = fGeom->GetNModules() ; + Int_t nModulesToUnfold = geom->GetNModules() ; Int_t numberofNotUnfolded = fNumberOfEmcClusters ; Int_t index ; for(index = 0 ; index < numberofNotUnfolded ; index++){ - AliPHOSEmcRecPoint * emcRecPoint = (AliPHOSEmcRecPoint *) fEmcRecPoints->At(index) ; + AliPHOSEmcRecPoint * emcRecPoint = (AliPHOSEmcRecPoint *) emcRecPoints->At(index) ; if(emcRecPoint->GetPHOSMod()> nModulesToUnfold) break ; Int_t nMultipl = emcRecPoint->GetMultiplicity() ; Int_t * maxAt = new Int_t[nMultipl] ; Float_t * maxAtEnergy = new Float_t[nMultipl] ; - Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy,fEmcLocMaxCut,fDigits) ; + Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy,fEmcLocMaxCut,digits) ; if( nMax > 1 ) { // if cluster is very flat (no pronounced maximum) then nMax = 0 UnfoldCluster(emcRecPoint, nMax, maxAt, maxAtEnergy) ; - fEmcRecPoints->Remove(emcRecPoint); - fEmcRecPoints->Compress() ; + emcRecPoints->Remove(emcRecPoint); + emcRecPoints->Compress() ; index-- ; fNumberOfEmcClusters -- ; numberofNotUnfolded-- ; @@ -760,13 +764,13 @@ void AliPHOSClusterizerv1::MakeUnfolding() // Unfold now CPV clusters if(fNumberOfCpvClusters > 0){ - Int_t nModulesToUnfold = fGeom->GetNCPVModules() ; + Int_t nModulesToUnfold = geom->GetNCPVModules() ; Int_t numberofCpvNotUnfolded = fNumberOfCpvClusters ; Int_t index ; for(index = 0 ; index < numberofCpvNotUnfolded ; index++){ - AliPHOSRecPoint * recPoint = (AliPHOSRecPoint *) fCpvRecPoints->At(index) ; + AliPHOSRecPoint * recPoint = (AliPHOSRecPoint *) cpvRecPoints->At(index) ; if(recPoint->GetPHOSMod()> nModulesToUnfold) break ; @@ -776,12 +780,12 @@ void AliPHOSClusterizerv1::MakeUnfolding() Int_t nMultipl = emcRecPoint->GetMultiplicity() ; Int_t * maxAt = new Int_t[nMultipl] ; Float_t * maxAtEnergy = new Float_t[nMultipl] ; - Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy,fCpvLocMaxCut,fDigits) ; + Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy,fCpvLocMaxCut,digits) ; if( nMax > 1 ) { // if cluster is very flat (no pronounced maximum) then nMax = 0 UnfoldCluster(emcRecPoint, nMax, maxAt, maxAtEnergy) ; - fCpvRecPoints->Remove(emcRecPoint); - fCpvRecPoints->Compress() ; + cpvRecPoints->Remove(emcRecPoint); + cpvRecPoints->Compress() ; index-- ; numberofCpvNotUnfolded-- ; fNumberOfCpvClusters-- ; @@ -815,6 +819,12 @@ void AliPHOSClusterizerv1::UnfoldCluster(AliPHOSEmcRecPoint * iniEmc, { // Performs the unfolding of a cluster with nMax overlapping showers + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + const AliPHOSGeometry * geom = gime->PHOSGeometry() ; + TClonesArray * digits = gime->Digits() ; + TObjArray * emcRecPoints = gime->EmcRecPoints() ; + TObjArray * cpvRecPoints = gime->CpvRecPoints() ; + Int_t nPar = 3 * nMax ; Float_t * fitparameters = new Float_t[nPar] ; @@ -831,18 +841,18 @@ void AliPHOSClusterizerv1::UnfoldCluster(AliPHOSEmcRecPoint * iniEmc, Int_t nDigits = iniEmc->GetMultiplicity() ; Float_t * efit = new Float_t[nDigits] ; - Float_t xDigit,zDigit,distance ; - Float_t xpar,zpar,epar ; + Float_t xDigit=0.,zDigit=0.,distance=0. ; + Float_t xpar=0.,zpar=0.,epar=0. ; Int_t relid[4] ; - AliPHOSDigit * digit ; + AliPHOSDigit * digit = 0 ; Int_t * emcDigits = iniEmc->GetDigitsList() ; Int_t iparam ; Int_t iDigit ; for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){ - digit = (AliPHOSDigit*) fDigits->At(emcDigits[iDigit] ) ; - fGeom->AbsToRelNumbering(digit->GetId(), relid) ; - fGeom->RelPosInModule(relid, xDigit, zDigit) ; + digit = (AliPHOSDigit*) digits->At(emcDigits[iDigit] ) ; + geom->AbsToRelNumbering(digit->GetId(), relid) ; + geom->RelPosInModule(relid, xDigit, zDigit) ; efit[iDigit] = 0; iparam = 0 ; @@ -872,31 +882,31 @@ void AliPHOSClusterizerv1::UnfoldCluster(AliPHOSEmcRecPoint * iniEmc, epar = fitparameters[iparam+2] ; iparam += 3 ; - AliPHOSEmcRecPoint * emcRP ; + AliPHOSEmcRecPoint * emcRP = 0 ; if(iniEmc->IsEmc()){ //create new entries in fEmcRecPoints... - if(fNumberOfEmcClusters >= fEmcRecPoints->GetSize()) - fEmcRecPoints->Expand(2*fNumberOfEmcClusters) ; + if(fNumberOfEmcClusters >= emcRecPoints->GetSize()) + emcRecPoints->Expand(2*fNumberOfEmcClusters) ; - (*fEmcRecPoints)[fNumberOfEmcClusters] = new AliPHOSEmcRecPoint() ; - emcRP = (AliPHOSEmcRecPoint *) fEmcRecPoints->At(fNumberOfEmcClusters); + (*emcRecPoints)[fNumberOfEmcClusters] = new AliPHOSEmcRecPoint() ; + emcRP = (AliPHOSEmcRecPoint *) emcRecPoints->At(fNumberOfEmcClusters); fNumberOfEmcClusters++ ; } else{//create new entries in fCpvRecPoints - if(fNumberOfCpvClusters >= fCpvRecPoints->GetSize()) - fCpvRecPoints->Expand(2*fNumberOfCpvClusters) ; + if(fNumberOfCpvClusters >= cpvRecPoints->GetSize()) + cpvRecPoints->Expand(2*fNumberOfCpvClusters) ; - (*fCpvRecPoints)[fNumberOfCpvClusters] = new AliPHOSCpvRecPoint() ; - emcRP = (AliPHOSEmcRecPoint *) fCpvRecPoints->At(fNumberOfCpvClusters); + (*cpvRecPoints)[fNumberOfCpvClusters] = new AliPHOSCpvRecPoint() ; + emcRP = (AliPHOSEmcRecPoint *) cpvRecPoints->At(fNumberOfCpvClusters); fNumberOfCpvClusters++ ; } Float_t eDigit ; for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){ - digit = (AliPHOSDigit*) fDigits->At( emcDigits[iDigit] ) ; - fGeom->AbsToRelNumbering(digit->GetId(), relid) ; - fGeom->RelPosInModule(relid, xDigit, zDigit) ; + digit = (AliPHOSDigit*) digits->At( emcDigits[iDigit] ) ; + geom->AbsToRelNumbering(digit->GetId(), relid) ; + geom->RelPosInModule(relid, xDigit, zDigit) ; distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ; distance = TMath::Sqrt(distance) ; ratio = epar * ShowerShape(distance) / efit[iDigit] ; @@ -928,7 +938,7 @@ void AliPHOSClusterizerv1::UnfoldingChiSquare(Int_t & nPar, Double_t * Grad, Dou Int_t * emcDigits = emcRP->GetDigitsList() ; - Int_t nOfDigits = emcRP->GetDigitsMultiplicity() ; + Int_t nOdigits = emcRP->GetDigitsMultiplicity() ; Float_t * emcEnergies = emcRP->GetEnergiesList() ; @@ -946,7 +956,7 @@ void AliPHOSClusterizerv1::UnfoldingChiSquare(Int_t & nPar, Double_t * Grad, Dou AliPHOSDigit * digit ; Int_t iDigit ; - for( iDigit = 0 ; iDigit < nOfDigits ; iDigit++) { + for( iDigit = 0 ; iDigit < nOdigits ; iDigit++) { digit = (AliPHOSDigit*) digits->At( emcDigits[iDigit] ) ; @@ -1015,11 +1025,14 @@ void AliPHOSClusterizerv1::Print(Option_t * option)const { // Print clusterizer parameters - if(fIsInitialized){ + if( strcmp(GetName(), "") !=0 ){ // Print parameters - - cout << "---------------"<< GetName() << " " << GetTitle()<< "-----------" << endl + + TString taskName(GetName()) ; + taskName.ReplaceAll(Version(), "") ; + + cout << "---------------"<< taskName.Data() << " " << GetTitle()<< "-----------" << endl << "Clusterizing digits from the file: " << fHeaderFileName.Data() << endl << " Branch: " << fDigitsBranchTitle.Data() << endl << endl @@ -1047,9 +1060,12 @@ void AliPHOSClusterizerv1::PrintRecPoints(Option_t * option) { // Prints list of RecPoints produced at the current pass of AliPHOSClusterizer + TObjArray * emcRecPoints = AliPHOSGetter::GetInstance()->EmcRecPoints() ; + TObjArray * cpvRecPoints = AliPHOSGetter::GetInstance()->CpvRecPoints() ; + cout << "AliPHOSClusterizerv1: " << endl ; - cout << " Found "<< fEmcRecPoints->GetEntriesFast() << " EMC Rec Points and " - << fCpvRecPoints->GetEntriesFast() << " CPV RecPoints" << endl ; + cout << " Found "<< emcRecPoints->GetEntriesFast() << " EMC Rec Points and " + << cpvRecPoints->GetEntriesFast() << " CPV RecPoints" << endl ; if(strstr(option,"all")) { cout << "EMC clusters " << endl ; @@ -1067,8 +1083,8 @@ void AliPHOSClusterizerv1::PrintRecPoints(Option_t * option) << " Primaries list " << endl; Int_t index ; - for (index = 0 ; index < fEmcRecPoints->GetEntries() ; index++) { - AliPHOSEmcRecPoint * rp = (AliPHOSEmcRecPoint * )fEmcRecPoints->At(index) ; + for (index = 0 ; index < emcRecPoints->GetEntries() ; index++) { + AliPHOSEmcRecPoint * rp = (AliPHOSEmcRecPoint * )emcRecPoints->At(index) ; cout << setw(6) << rp->GetIndexInList() << " "; cout << setw(6) << rp->GetEnergy() << " "; @@ -1098,7 +1114,7 @@ void AliPHOSClusterizerv1::PrintRecPoints(Option_t * option) } cout << endl ; - //Now plot PCV/PPSD recPoints + //Now plot CPV/PPSD recPoints cout << "EMC clusters " << endl ; cout << " Index " << " Multi " @@ -1110,8 +1126,8 @@ void AliPHOSClusterizerv1::PrintRecPoints(Option_t * option) << " # of prim " << " Primaries list " << endl; - for (index = 0 ; index < fEmcRecPoints->GetEntries() ; index++) { - AliPHOSRecPoint * rp = (AliPHOSRecPoint * )fCpvRecPoints->At(index) ; + for (index = 0 ; index < cpvRecPoints->GetEntries() ; index++) { + AliPHOSRecPoint * rp = (AliPHOSRecPoint * )cpvRecPoints->At(index) ; cout << setw(6) << rp->GetIndexInList() << " "; cout << setw(6) << rp->GetPHOSMod() << " "; diff --git a/PHOS/AliPHOSClusterizerv1.h b/PHOS/AliPHOSClusterizerv1.h index 228123b8613..80ecda8a5fe 100644 --- a/PHOS/AliPHOSClusterizerv1.h +++ b/PHOS/AliPHOSClusterizerv1.h @@ -32,7 +32,7 @@ class AliPHOSClusterizerv1 : public AliPHOSClusterizer { public: AliPHOSClusterizerv1() ; // ctor - AliPHOSClusterizerv1(const char * headerFile,const char *digitsBrancheTitle=0); + AliPHOSClusterizerv1(const char * headerFile, const char * name = 0); virtual ~AliPHOSClusterizerv1(){} // dtor Int_t AreNeighbours(AliPHOSDigit * d1, AliPHOSDigit * d2)const ; @@ -61,18 +61,18 @@ public: virtual void SetCpvLocalMaxCut(Float_t cut) { fCpvLocMaxCut = cut ; } virtual void SetCpvLogWeight(Float_t w) { fW0CPV = w ; } virtual void SetPpsdClusteringThreshold(Float_t cluth) { fPpsdClusteringThreshold = cluth ; } - virtual void SetDigitsBranch(const char * title) { fDigitsBranchTitle = title ;} virtual void SetRecPointsBranch(const char *title){fRecPointsBranchTitle = title; } - virtual void SetUnfolding(Bool_t toUnfold = kTRUE ) {fToUnfold = toUnfold ;} - - static void UnfoldingChiSquare(Int_t & nPar, Double_t * Grad, Double_t & fret, Double_t * x, Int_t iflag) ; - // Chi^2 of the fit. Should be static to be passes to MINUIT static Double_t ShowerShape(Double_t r) ; // Shape of EM shower used in unfolding; //class member function (not object member function) + static void UnfoldingChiSquare(Int_t & nPar, Double_t * Grad, Double_t & fret, Double_t * x, Int_t iflag) ; + // Chi^2 of the fit. Should be static to be passes to MINUIT + virtual const char * Version() const { return "clu-v1" ; } + private: + virtual Float_t Calibrate(Int_t amp)const { return (amp-fPedestal)/fSlope ;} // Tranforms Amp to energy Bool_t FindFit(AliPHOSEmcRecPoint * emcRP, int * MaxAt, Float_t * maxAtEnergy, Int_t NPar, Float_t * FitParametres) const; //Used in UnfoldClusters, calls TMinuit @@ -84,10 +84,10 @@ private: virtual void MakeClusters( ) ; virtual void MakeUnfolding() ; - Bool_t ReadDigits() ; + Bool_t ReadDigits(Int_t event) ; void UnfoldCluster(AliPHOSEmcRecPoint * iniEmc,Int_t Nmax, int * maxAt,Float_t * maxAtEnergy ) ; //Unfolds cluster using TMinuit package - void WriteRecPoints() ; + void WriteRecPoints(Int_t event) ; void PrintRecPoints(Option_t * option) ; private: @@ -96,21 +96,12 @@ private: TString fDigitsBranchTitle ; // name of the file, where digits branch is stored TString fRecPointsBranchTitle ; // name of the file, where RecPoints branchs are stored - Int_t fEvent ; // Number of event currently processed Bool_t fToUnfold ; // To perform unfolding - Bool_t fIsInitialized ; // kTRUE if clisterizer is initialized - - AliPHOSGeometry * fGeom ; // !pointer to PHOS geometry - - AliPHOSDigitizer * fDigitizer ; // !digitizer which produced Digits we treat Int_t fNumberOfEmcClusters ; // number of EMC clusters found Int_t fNumberOfCpvClusters ; // number of CPV+PPSD clusters found - TClonesArray * fDigits ; // ! Initial list of digits - TObjArray * fEmcRecPoints ; // ! Final list of EMC Rec Points - TObjArray * fCpvRecPoints ; // ! Final list of CPV/PPSD recPoints - + Float_t fPedestal ; // Calibration parameters Float_t fSlope ; // read from Digitizer diff --git a/PHOS/AliPHOSCpvRecPoint.cxx b/PHOS/AliPHOSCpvRecPoint.cxx index c949e06a5ca..5174401d1c1 100644 --- a/PHOS/AliPHOSCpvRecPoint.cxx +++ b/PHOS/AliPHOSCpvRecPoint.cxx @@ -146,7 +146,7 @@ void AliPHOSCpvRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) const // // static Int_t pxold, pyold; -// AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ; +// AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; // static TGraph * digitgraph = 0 ; @@ -175,7 +175,7 @@ void AliPHOSCpvRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) const // Float_t zimin = 999. ; // for(iDigit=0; iDigitGimeDigit(fDigitsList[iDigit]) ) ; +// digit = (AliPHOSDigit *) ( gime->Digit(fDigitsList[iDigit]) ) ; // phosgeom->AbsToRelNumbering(digit->GetId(), relid) ; // phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]); // if ( xi[iDigit] > ximax ) @@ -207,7 +207,7 @@ void AliPHOSCpvRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) const // Float_t x, z ; // for(iDigit=0; iDigitGimeDigit(fDigitsList[iDigit]) ) ; +// digit = (AliPHOSDigit *) ( gime->Digit(fDigitsList[iDigit]) ) ; // phosgeom->AbsToRelNumbering(digit->GetId(), relid) ; // phosgeom->RelPosInModule(relid, x, z); // histo->Fill(x, z, fEnergyList[iDigit] ) ; diff --git a/PHOS/AliPHOSCpvRecPoint.h b/PHOS/AliPHOSCpvRecPoint.h index 1de5c39b003..8902a62e182 100644 --- a/PHOS/AliPHOSCpvRecPoint.h +++ b/PHOS/AliPHOSCpvRecPoint.h @@ -22,6 +22,7 @@ #include "AliPHOSDigit.h" #include "AliPHOSEmcRecPoint.h" +#include "AliPHOSGeometry.h" class AliPHOSCpvRecPoint : public AliPHOSEmcRecPoint { diff --git a/PHOS/AliPHOSDigit.cxx b/PHOS/AliPHOSDigit.cxx index 83ac5d132db..200d74e084f 100644 --- a/PHOS/AliPHOSDigit.cxx +++ b/PHOS/AliPHOSDigit.cxx @@ -48,12 +48,12 @@ ClassImp(AliPHOSDigit) } //____________________________________________________________________________ -AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t DigEnergy, Int_t index) +AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t digEnergy, Int_t index) { // ctor with all data fNMaxPrimary = 5 ; - fAmp = DigEnergy ; + fAmp = digEnergy ; fId = id ; fIndexInList = index ; if( primary != -1){ diff --git a/PHOS/AliPHOSDigitizer.cxx b/PHOS/AliPHOSDigitizer.cxx index 7dca6e9ec8c..ccf5eef1f78 100644 --- a/PHOS/AliPHOSDigitizer.cxx +++ b/PHOS/AliPHOSDigitizer.cxx @@ -21,6 +21,10 @@ // This TTask performs digitization of Summable digits (in the PHOS case it is just // the sum of contributions from all primary particles into a given cell). // In addition it performs mixing of summable digits from different events. +// The name of the TTask is also the title of the branch that will contain +// the created SDigits +// The title of the TTAsk is the name of the file that contains the hits from +// which the SDigits are created // // For each event two branches are created in TreeD: // "PHOS" - list of digits @@ -66,6 +70,7 @@ #include "AliRun.h" #include "AliPHOSDigit.h" #include "AliPHOS.h" +#include "AliPHOSGetter.h" #include "AliPHOSDigitizer.h" #include "AliPHOSSDigitizer.h" #include "AliPHOSGeometry.h" @@ -74,105 +79,31 @@ ClassImp(AliPHOSDigitizer) //____________________________________________________________________________ - AliPHOSDigitizer::AliPHOSDigitizer():TTask("AliPHOSDigitizer","") + AliPHOSDigitizer::AliPHOSDigitizer():TTask("","") { // ctor - fSDigitizer = 0 ; - - fNinputs = 1 ; fPinNoise = 0.01 ; fEMCDigitThreshold = 0.01 ; fCPVNoise = 0.01; fCPVDigitThreshold = 0.09 ; fPPSDNoise = 0.0000001; fPPSDDigitThreshold = 0.0000002 ; - fInitialized = kFALSE ; - - fHeaderFiles = 0; - fSDigitsTitles = 0; - fSDigits = 0 ; - fDigits = 0; - -} -//____________________________________________________________________________ -void AliPHOSDigitizer::Init() -{ - // Makes all memory allocations - // Adds Digitizer task to the folder of PHOS tasks - - if(!fInitialized){ - - if (fHeaderFiles == 0) { - fHeaderFiles = new TClonesArray("TObjString",1) ; - new((*fHeaderFiles)[0]) TObjString("galice.root") ; - } - - //Test, if this file already open - - TFile *file = (TFile*) gROOT->GetFile(((TObjString *) fHeaderFiles->At(0))->GetString() ) ; - - if(file==0){ - if(((TObjString *) fHeaderFiles->At(0))->GetString().Contains("rfio")) - file = TFile::Open(((TObjString *) fHeaderFiles->At(0))->GetString(),"update") ; - else - file = new TFile(((TObjString *) fHeaderFiles->At(0))->GetString(),"update") ; - gAlice = (AliRun *) file->Get("gAlice") ; //If not read yet - } - else - file = new TFile(((TObjString *) fHeaderFiles->At(0))->GetString()) ; - - file->cd() ; - - if (fSDigitsTitles == 0) { - fSDigitsTitles = new TClonesArray("TObjString",1); - new((*fSDigitsTitles)[0]) TObjString("") ; - } - - fSDigits = new TClonesArray("TClonesArray",1) ; - new((*fSDigits)[0]) TClonesArray("AliPHOSDigit",1000) ; - fSDigitizer = 0 ; - - fDigitsTitle = "" ; - - fDigits = new TClonesArray("AliPHOSDigit",200000) ; - - fIevent = new TArrayI(1) ; - fIevent->AddAt(-1,0 ) ; - fIeventMax = new TArrayI(1) ; - - fIeventMax->AddAt((Int_t) gAlice->TreeE()->GetEntries(), 0 ); - - //add Task to //YSAlice/tasks/(S)Diditizer/PHOS - TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("YSAlice") ; - TTask * aliceSD = (TTask*)alice->FindObject("tasks/(S)Digitizer") ; - TTask * phosSD = (TTask*)aliceSD->GetListOfTasks()->FindObject("PHOS") ; - phosSD->Add(this) ; - - fInitialized = kTRUE ; - } } //____________________________________________________________________________ -AliPHOSDigitizer::AliPHOSDigitizer(const char *headerFile,const char *sDigitsTitle): - TTask("AliPHOSDigitizer","") +AliPHOSDigitizer::AliPHOSDigitizer(const char *headerFile,const char * name): + TTask(name, headerFile) { // ctor - fHeaderFiles = new TClonesArray("TObjString",1) ; - new((*fHeaderFiles)[0]) TObjString(headerFile) ; - - fSDigitsTitles = new TClonesArray("TObjString",1); // Title name of the SDigits branch - new((*fSDigitsTitles)[0]) TObjString(sDigitsTitle) ; - - fNinputs = 1 ; + fPinNoise = 0.01 ; fEMCDigitThreshold = 0.01 ; fCPVNoise = 0.01; fCPVDigitThreshold = 0.09 ; fPPSDNoise = 0.0000001; fPPSDDigitThreshold = 0.0000002 ; - fInitialized = kFALSE ; Init() ; @@ -183,54 +114,11 @@ AliPHOSDigitizer::AliPHOSDigitizer(const char *headerFile,const char *sDigitsTit { // dtor - if(fHeaderFiles) delete fHeaderFiles ; - if(fSDigitsTitles) delete fSDigitsTitles ; - if(fSDigits) delete fSDigits ; - if(fDigits) delete fDigits ; -} -//____________________________________________________________________________ -void AliPHOSDigitizer::Reset() -{ - // sets current event number to the first simulated event - - if(!fInitialized) - Init() ; - Int_t inputs ; - for(inputs = 0; inputs < fNinputs ;inputs++) - fIevent->AddAt(-1, inputs ) ; - -} -//____________________________________________________________________________ -Bool_t AliPHOSDigitizer::Combinator() -{ - // Makes all desirable combinations of Signal+Background, - // returns kFALSE when all combinations are made. - // May be useful to introduce options like "One-to-One", "All-to-One" and "All-to-All" ? - //realizing "One-to-One" option... - - if(!fInitialized) - Init() ; - - Int_t inputs ; - Bool_t endNotReached = kTRUE ; - - for(inputs = 0; (inputs < fNinputs) && endNotReached ;inputs++){ - if(fIevent->At(inputs)+1 < fIeventMax->At(inputs)) - fIevent->AddAt(fIevent->At(inputs)+1, inputs ) ; - else - if(inputs == 0) - endNotReached = kFALSE ; - else //for inputs other than base one start from the beginning - fIevent->AddAt(0, inputs ) ; - - } - return endNotReached ; - } //____________________________________________________________________________ -void AliPHOSDigitizer::Digitize(Option_t *option) +void AliPHOSDigitizer::Digitize(const Int_t event) { // Makes the digitization of the collected summable digits. @@ -240,13 +128,15 @@ void AliPHOSDigitizer::Digitize(Option_t *option) // This design avoids scanning over the list of digits to add // contribution to new SDigits only. - if(!fInitialized) + if( strcmp(GetName(), "") == 0 ) Init() ; - fDigits->Clear() ; + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + TClonesArray * digits = gime->Digits() ; + + digits->Clear() ; - AliPHOS * phos = (AliPHOS *) gAlice->GetDetector("PHOS") ; - AliPHOSGeometry *geom = AliPHOSGeometry::GetInstance( phos->GetGeometry()->GetName(), phos->GetGeometry()->GetTitle() ); + const AliPHOSGeometry *geom = gime->PHOSGeometry() ; //Making digits with noise, first EMC Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ(); @@ -269,308 +159,187 @@ void AliPHOSDigitizer::Digitize(Option_t *option) nPPSD = nCPV; - fDigits->Expand(nPPSD) ; + digits->Expand(nPPSD) ; - + + // sdigitize random gaussian noise and add it to all cells (EMCA+CPV+PPSD) + // get first the sdigitizer from the tasks list (must have same name as the digitizer) + const AliPHOSSDigitizer * sDigitizer = gime->SDigitizer(GetName()); + if ( !sDigitizer) { + cerr << "ERROR: AliPHOSDigitizer::Digitize -> SDigitizer with name " << GetName() << " not found " << endl ; + abort() ; + } for(absID = 1; absID <= nEMC; absID++){ Float_t noise = gRandom->Gaus(0., fPinNoise) ; - new((*fDigits)[absID-1]) AliPHOSDigit( -1,absID,fSDigitizer->Digitize(noise) ) ; + new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise) ) ; } for(absID = nEMC+1; absID <= nCPV; absID++){ Float_t noise = gRandom->Gaus(0., fCPVNoise) ; - new((*fDigits)[absID-1]) AliPHOSDigit( -1,absID,fSDigitizer->Digitize(noise) ) ; + new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise) ) ; } for(absID = nCPV+1; absID <= nPPSD; absID++){ Float_t noise = gRandom->Gaus(0., fPPSDNoise) ; - new((*fDigits)[absID-1]) AliPHOSDigit( -1,absID,fSDigitizer->Digitize(noise) ) ; + new((*digits)[absID-1]) AliPHOSDigit( -1,absID,sDigitizer->Digitize(noise) ) ; } - - // Now look throught (unsorted) list of SDigits and add corresponding digits - AliPHOSDigit *curSDigit ; - AliPHOSDigit *digit ; - - Int_t inputs; - for(inputs = 0; inputs< fNinputs ; inputs++){ //loop over (possible) merge sources - - TClonesArray * sdigits= (TClonesArray *)fSDigits->At(inputs) ; - Int_t isdigit ; - - Int_t nSDigits = sdigits->GetEntries() ; - for(isdigit=0;isdigit< nSDigits; isdigit++){ - curSDigit = (AliPHOSDigit *)sdigits->At(isdigit) ; - if(inputs) //Shift primaries for non-background sdigits - curSDigit->ShiftPrimary(inputs) ; - digit = (AliPHOSDigit *)fDigits->At(curSDigit->GetId() - 1); - *digit = *digit + *curSDigit ; - } + // loop through the sdigits posted to the White Board and add them to the noise + TCollection * folderslist = ((TFolder*)gROOT->FindObjectAny("YSAlice/WhiteBoard/SDigits/PHOS"))->GetListOfFolders() ; + TIter next(folderslist) ; + TFolder * folder = 0 ; + TClonesArray * sdigits = 0 ; + TString eventS ; + eventS += event ; + while ( (folder = (TFolder*)next()) ) { + if ( (strcmp(folder->GetTitle(), eventS.Data()) == 0) || (strcmp(folder->GetTitle(), "") == 0) ) { + Int_t numberoffiles = 0 ; + if ( (sdigits = (TClonesArray*)folder->FindObject(GetName()) ) ) { + cout << "INFO: AliPHOSDigitizer::Exec -> Adding SDigits " << GetName() << " from " << folder->GetName() << endl ; + numberoffiles++ ; + Int_t index ; + AliPHOSDigit * curSDigit ; + AliPHOSDigit * digit ; + for ( index = 0 ; index < sdigits->GetEntriesFast(); index++) { + curSDigit = (AliPHOSDigit*)sdigits->At(index) ; + curSDigit->ShiftPrimary(numberoffiles) ; + digit = (AliPHOSDigit*)digits->At(curSDigit->GetId() - 1 ) ; + *digit = *digit + *curSDigit ; + } + } + } } - - //remove digits below thresholds for(absID = 0; absID < nEMC ; absID++) - if(fSDigitizer->Calibrate(((AliPHOSDigit*)fDigits->At(absID))->GetAmp()) < fEMCDigitThreshold) - fDigits->RemoveAt(absID) ; + if(sDigitizer->Calibrate(((AliPHOSDigit*)digits->At(absID))->GetAmp()) < fEMCDigitThreshold) + digits->RemoveAt(absID) ; + for(absID = nEMC; absID < nCPV ; absID++) - if(fSDigitizer->Calibrate(((AliPHOSDigit*)fDigits->At(absID))->GetAmp()) < fCPVDigitThreshold) - fDigits->RemoveAt(absID) ; + if(sDigitizer->Calibrate(((AliPHOSDigit*)digits->At(absID))->GetAmp()) < fCPVDigitThreshold) + digits->RemoveAt(absID) ; + for(absID = nCPV; absID < nPPSD ; absID++) - if(fSDigitizer->Calibrate(((AliPHOSDigit *)fDigits->At(absID))->GetAmp()) < fPPSDDigitThreshold) - fDigits->RemoveAt(absID) ; + if(sDigitizer->Calibrate(((AliPHOSDigit *)digits->At(absID))->GetAmp()) < fPPSDDigitThreshold) + digits->RemoveAt(absID) ; - fDigits->Compress() ; + digits->Compress() ; - Int_t ndigits = fDigits->GetEntriesFast() ; + Int_t ndigits = digits->GetEntriesFast() ; - fDigits->Expand(ndigits) ; + digits->Expand(ndigits) ; //Set indexes in list of digits Int_t i ; for (i = 0 ; i < ndigits ; i++) { - AliPHOSDigit * digit = (AliPHOSDigit *) fDigits->At(i) ; + AliPHOSDigit * digit = (AliPHOSDigit *) digits->At(i) ; digit->SetIndexInList(i) ; } -} -//____________________________________________________________________________ -void AliPHOSDigitizer::WriteDigits() -{ - - // Makes TreeD in the output file. - // Check if branch already exists: - // if yes, exit without writing: ROOT TTree does not support overwriting/updating of - // already existing branches. - // else creates branch with Digits, named "PHOS", title "...", - // and branch "AliPHOSDigitizer", with the same title to keep all the parameters - // and names of files, from which digits are made. - gAlice->GetEvent(fIevent->At(0)) ; // Suitable only for One-To-One mixing - gAlice->SetEvent(fIevent->At(0)) ; // for all-to-all will produce a lot of branches in TreeD +} - if(gAlice->TreeD()==0) - gAlice->MakeTree("D") ; +//____________________________________________________________________________ +void AliPHOSDigitizer::Exec(Option_t *option) +{ + // Managing method - //Check, if this branch already exits? - TBranch * digitsBranch = 0; - TBranch * digitizerBranch = 0; - - TObjArray * branches = gAlice->TreeD()->GetListOfBranches() ; - Int_t ibranch; - Bool_t phosNotFound = kTRUE ; - Bool_t digitizerNotFound = kTRUE ; + if( strcmp(GetName(), "") == 0 ) + Init() ; - for(ibranch = 0;ibranch GetEntries();ibranch++){ - - if(phosNotFound){ - digitsBranch=(TBranch *) branches->At(ibranch) ; - if( (strcmp("PHOS",digitsBranch->GetName())==0 ) && - (fDigitsTitle.CompareTo(digitsBranch->GetTitle()) == 0) ) - phosNotFound = kFALSE ; - } - if(digitizerNotFound){ - digitizerBranch = (TBranch *) branches->At(ibranch) ; - if( (strcmp(digitizerBranch->GetName(),"AliPHOSDigitizer") == 0) && - (fDigitsTitle.CompareTo(digitizerBranch->GetTitle()) == 0)) - digitizerNotFound = kFALSE ; - } + if (strstr(option,"print")) { + Print(""); + return ; } - - if(!(digitizerNotFound && phosNotFound)){ - cout << "AliPHOSDigitizer error: " << endl ; - cout << " can not update/overwrite existing branches "<< endl ; - cout << " do not write " << endl ; - return ; - } - - // create new branches + if(strstr(option,"tim")) + gBenchmark->Start("PHOSDigitizer"); - //First generate file name - char * file =0; - if(gSystem->Getenv("CONFIG_SPLIT_FILE")){ //generating file name - file = new char[strlen(gAlice->GetBaseFile())+20] ; - sprintf(file,"%s/PHOS.Digits.root",gAlice->GetBaseFile()) ; - } + //Check, if this branch already exits + TObjArray * lob = (TObjArray*)gAlice->TreeD()->GetListOfBranches() ; + TIter next(lob) ; + TBranch * branch = 0 ; + Bool_t phosfound = kFALSE, digitizerfound = kFALSE ; - TDirectory *cwd = gDirectory; - - //First create list of sdigits - Int_t bufferSize = 32000 ; - digitsBranch = gAlice->TreeD()->Branch("PHOS",&fDigits,bufferSize); - digitsBranch->SetTitle(fDigitsTitle.Data()); - if (file) { - digitsBranch->SetFile(file); - TIter next( digitsBranch->GetListOfBranches()); - TBranch * sbr ; - while ((sbr=(TBranch*)next())) { - sbr->SetFile(file); - } - cwd->cd(); - } + while ( (branch = (TBranch*)next()) && (!phosfound || !digitizerfound) ) { + if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), GetName())==0) ) + phosfound = kTRUE ; - //second - create Digitizer - Int_t splitlevel = 0 ; - AliPHOSDigitizer * d = this ; - digitizerBranch = gAlice->TreeD()->Branch("AliPHOSDigitizer","AliPHOSDigitizer", - &d,bufferSize,splitlevel); - digitizerBranch->SetTitle(fDigitsTitle.Data()); - if (file) { - digitizerBranch->SetFile(file); - TIter next( digitizerBranch->GetListOfBranches()); - TBranch * sbr; - while ((sbr=(TBranch*)next())) { - sbr->SetFile(file); - } - cwd->cd(); + else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && (strcmp(branch->GetTitle(), GetName())==0) ) + digitizerfound = kTRUE ; } - digitsBranch->Fill() ; - digitizerBranch->Fill() ; + if ( phosfound || digitizerfound ) { + cerr << "WARNING: AliPHOSDigitizer::WriteDigits -> Digits and/or Digitizer branch with name " << GetName() + << " already exits" << endl ; + return ; + } - gAlice->TreeD()->Write(0,kOverwrite) ; - - //remove fSDigitizer before new event. - if(fSDigitizer){ - delete fSDigitizer ; - fSDigitizer = 0 ; - } + Int_t nevents = (Int_t) gAlice->TreeE()->GetEntries() ; + Int_t ievent ; + for(ievent = 0; ievent < nevents; ievent++){ -} - -//____________________________________________________________________________ -void AliPHOSDigitizer::Exec(Option_t *option) -{ - // Managing method - - if(!fInitialized) Init() ; - - if(strstr(option,"tim")) - gBenchmark->Start("PHOSDigitizer"); - - //reset events numbers to start from the beginnig - Reset() ; - - while(Combinator()){ - - if(!ReadSDigits()) //read sdigits event(s) evaluated by Combinator() from file(s) + if(!ReadSDigits(ievent)) //read sdigits event(s) evaluated by Combinator() from file(s) return ; - Digitize(option) ; //Add prepared SDigits to digits and add the noise - WriteDigits() ; + Digitize(ievent) ; //Add prepared SDigits to digits and add the noise - if(strstr(option,"deb")) - PrintDigits(option); - + WriteDigits(ievent) ; } + + if(strstr(option,"deb")) + PrintDigits(option); + if(strstr(option,"tim")){ gBenchmark->Stop("PHOSDigitizer"); cout << "AliPHOSDigitizer:" << endl ; cout << " took " << gBenchmark->GetCpuTime("PHOSDigitizer") << " seconds for SDigitizing " - << gBenchmark->GetCpuTime("PHOSDigitizer")/(fIeventMax->At(0)) << " seconds per event " << endl ; + << gBenchmark->GetCpuTime("PHOSDigitizer") << " seconds per event " << endl ; + // << gBenchmark->GetCpuTime("PHOSDigitizer")/(fIeventMax->At(0)) << " seconds per event " << endl ; cout << endl ; } } -//__________________________________________________________________ -Bool_t AliPHOSDigitizer::ReadSDigits() +//____________________________________________________________________________ +void AliPHOSDigitizer::Init() { - // Reads summable digits from the opened files for the particular set of events given by fIevent - - if(!fInitialized) Init() ; - - - Int_t inputs ; - for(inputs = fNinputs-1; inputs >= 0; inputs --){ - - Int_t event = fIevent->At(inputs) ; - - TFile * file = (TFile*) gROOT->GetFile(((TObjString *) fHeaderFiles->At(inputs))->GetString() ) ; - file->cd() ; - - // Get SDigits Tree header from file - char treeName[20]; - sprintf(treeName,"TreeS%d",event); - TTree * treeS = (TTree*)file->Get(treeName); - - if(treeS==0){ - cout << "Error at AliPHOSDigitizer: no "<GetName() << endl ; - cout << "Do nothing " << endl ; - return kFALSE ; - } - - TBranch * sdigitsBranch = 0; - TBranch * sdigitizerBranch = 0; - - TObjArray * branches = treeS->GetListOfBranches() ; - Int_t ibranch; - Bool_t phosNotFound = kTRUE ; - Bool_t sdigitizerNotFound = kTRUE ; - - for(ibranch = 0;ibranch GetEntries();ibranch++){ - - if(phosNotFound){ - sdigitsBranch=(TBranch *) branches->At(ibranch) ; - if(( strcmp("PHOS",sdigitsBranch->GetName())==0 ) && - ((TObjString*) fSDigitsTitles->At(inputs))->GetString().CompareTo(sdigitsBranch->GetTitle())== 0 ) - phosNotFound = kFALSE ; - - } - - if(sdigitizerNotFound){ - sdigitizerBranch = (TBranch *) branches->At(ibranch) ; - if(( strcmp(sdigitizerBranch->GetName(),"AliPHOSSDigitizer") == 0) && - ((TObjString*) fSDigitsTitles->At(inputs))->GetString().CompareTo(sdigitizerBranch->GetTitle())== 0 ) - sdigitizerNotFound = kFALSE ; - - } - } - - if(sdigitizerNotFound || phosNotFound){ - cout << "Can't find Branch with sdigits or SDigitizer in the file " ; - if( ((TObjString*)fSDigitsTitles->At(inputs))->GetString().IsNull() ) - cout << file->GetName() << endl ; - else - cout << ((TObjString*)fSDigitsTitles->At(inputs))->GetString().Data() << endl ; - cout << "Do nothing" <At(inputs) ; - sdigitsBranch->SetAddress(&sdigits) ; - - AliPHOSSDigitizer *sDigitizer = new AliPHOSSDigitizer(); - sdigitizerBranch->SetAddress(&sDigitizer) ; - - sdigitsBranch->GetEntry(0) ; - sdigitizerBranch->GetEntry(0) ; + // Makes all memory allocations + // Adds Digitizer task to the folder of PHOS tasks + //============================================================= YS + // The initialisation is now done by AliPHOSGetter - if(fSDigitizer == 0) - fSDigitizer = sDigitizer ; - else - if(!((*fSDigitizer)==(*sDigitizer)) ){ - cout << "AliPHOSDigitizer ERROR:" << endl ; - cout << " you are using sdigits made with different SDigitizers" << endl ; - cout << "fSD " << fSDigitizer << " SD" << sDigitizer << endl ; - fSDigitizer->Print("") ; - sDigitizer->Print("") ; - cout << "Do Nothing " << endl ; - return kFALSE ; - } + if( strcmp(GetTitle(), "") == 0 ) + SetTitle("galice.root") ; + + + // the SDigits name is stored by AliPHOSGetter as the name of the TClones Array + // //YSAlice/WhiteBoard/SDigits/PHOS/headerFile/branchname and has branchTitle as title. - } - fPedestal = fSDigitizer->GetPedestalParameter() ; - fSlope = fSDigitizer->GetCalibrationParameter() ; + AliPHOSGetter * gime = AliPHOSGetter::GetInstance(GetTitle(), GetName()) ; + if ( gime == 0 ) { + cerr << "ERROR: AliPHOSDigitizer::Init -> Could not obtain the Getter object !" << endl ; + return ; + } + +// fIevent = new TArrayI(1) ; +// fIevent->AddAt(-1,0 ) ; +// fIeventMax = new TArrayI(1) ; - return kTRUE ; +// fIeventMax->AddAt((Int_t) gAlice->TreeE()->GetEntries(), 0 ); + + //add Task to //YSAlice/tasks/Digitizer/PHOS + TTask * aliceSD = (TTask*)gROOT->FindObjectAny("YSAlice/tasks/Digitizer") ; + TTask * phosSD = (TTask*)aliceSD->GetListOfTasks()->FindObject("PHOS") ; + phosSD->Add(this) ; + // create a folder on the white board //YSAlice/WhiteBoard/Digits/PHOS/headerFile/digitsTitle + gime->Post(GetTitle(), "D", GetName() ) ; } + //__________________________________________________________________ -void AliPHOSDigitizer::MixWith(char* HeaderFile, char* sDigitsTitle) +void AliPHOSDigitizer::MixWith(const char* headerFile) { // Alows to produce digits by superimposing background and signal event. // It is assumed, that headers file with SIGNAL events is opened in @@ -581,73 +350,95 @@ void AliPHOSDigitizer::MixWith(char* HeaderFile, char* sDigitsTitle) // opened in constructor file. // // One can open as many files to mix with as one needs. + // However only Sdigits with the same name (i.e. constructed with the same SDigitizer) + // can be mixed. - - if(!fInitialized) + if( strcmp(GetName(), "") == 0 ) Init() ; + const char* sDigitsTitle = GetName() ; + + // check if the specified SDigits do not already exist on the White Board: + // //YSAlice/WhiteBoard/SDigits/PHOS/headerFile/sDigitsTitle - if(HeaderFile == 0){ - cout << "Specify at least header file to merge"<< endl ; - return ; + TString path = "YSAlice/WhiteBoard/SDigits/PHOS/" ; + path += headerFile ; + path += "/" ; + path += sDigitsTitle ; + if ( gROOT->FindObjectAny(path.Data()) ) { + cerr << "WARNING: AliPHOSDigitizer::MixWith -> Entry already exists, do not add" << endl ; + return; } - - Int_t inputs ; - for(inputs = 0; inputs < fNinputs ; inputs++){ - if(strcmp(((TObjString *)fHeaderFiles->At(inputs))->GetString(),HeaderFile) == 0 ){ - if(sDigitsTitle == 0){ - if(((TObjString*)fSDigitsTitles->At(inputs))->GetString().CompareTo("") == 0){ - cout << "Entry already exists, do not add" << endl ; - return ; - } + // check if the requested file is already open or exist and if SDigits Branch exist + TFile * file = (TFile*)gROOT->FindObject(headerFile); + if ( !file ) { + file = new TFile(headerFile, "READ") ; + if (!file) { + cerr << "ERROR: AliPHOSDigitizer::MixWith -> File " << headerFile << " does not exist!" << endl ; + return ; + } + } + Int_t nevent = (Int_t)((TTree*)file->Get("TE"))->GetEntries() ; + Int_t ievent ; + for (ievent = 0; ievent < nevent; ievent++) { + TString tsname("TreeS") ; + tsname += ievent ; + TTree * ts = (TTree*)file->Get(tsname.Data()) ; + if ( !ts ) { + cerr << "ERROR: AliPHOSDigitizer::MixWith -> TreeS0 " << " does not exist in " << headerFile << endl ; + return ; + } + + TObjArray * lob = (TObjArray*)ts->GetListOfBranches() ; + TIter next(lob) ; + TBranch * branch = 0 ; + TBranch * sdigitsbranch = 0 ; + TBranch * sdigitizerbranch = 0 ; + Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ; + + while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) { + if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), sDigitsTitle)==0) ) { + sdigitsbranch = branch ; + phosfound = kTRUE ; } - else - if(((TObjString*)fSDigitsTitles->At(inputs))->GetString().CompareTo(sDigitsTitle)){ - cout << "Entry already exists, do not add" << endl ; - return; - } - } - } - - fHeaderFiles->Expand(fNinputs+1) ; - new((*fHeaderFiles)[fNinputs]) TObjString(HeaderFile) ; - - - TFile * file = new TFile(((TObjString *) fHeaderFiles->At(fNinputs))->GetString()) ; - - file->cd() ; - - fSDigitsTitles->Expand(fNinputs+1) ; - new((*fSDigitsTitles)[fNinputs]) TObjString(sDigitsTitle) ; - - fSDigits->Expand(fNinputs+1) ; - new((*fSDigits)[fNinputs]) TClonesArray("AliPHOSDigit",1000) ; - - fIevent->Set(fNinputs+1) ; - fIevent->AddAt(-1, fNinputs) ; - - fIeventMax->Set(fNinputs+1) ; - - TTree * te = (TTree *) file->Get("TE") ; - fIeventMax->AddAt((Int_t) te->GetEntries(), fNinputs ); - - fNinputs++ ; - + else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), sDigitsTitle)==0) ) { + sdigitizerbranch = branch ; + sdigitizerfound = kTRUE ; + } + } + + if ( !phosfound || !sdigitizerfound ) { + cerr << "WARNING: AliPHOSDigitizer::MixWith -> Cannot find SDigits and/or SDigitizer with name " << sDigitsTitle << endl ; + return ; + } + + // post the new SDigits to the White Board + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + gime->Post(headerFile, "S", sDigitsTitle, ievent ) ; + TClonesArray * sdigits = gime->SDigits(sDigitsTitle, headerFile) ; + sdigitsbranch->SetAddress(&sdigits) ; + sdigitsbranch->GetEvent(0) ; + } } + //__________________________________________________________________ void AliPHOSDigitizer::Print(Option_t* option)const { // Print Digitizer's parameters - if(fInitialized){ + if( strcmp(GetName(), "") != 0 ){ cout << "------------------- "<< GetName() << " -------------" << endl ; cout << "Digitizing sDigits from file(s): " <At(input))->GetString() << - " Branch title:" << ((TObjString *) fSDigitsTitles->At(input))->GetString() << endl ; + + TCollection * folderslist = ((TFolder*)gROOT->FindObjectAny("YSAlice/WhiteBoard/SDigits/PHOS"))->GetListOfFolders() ; + TIter next(folderslist) ; + TFolder * folder = 0 ; + + while ( (folder = (TFolder*)next()) ) { + if ( folder->FindObject(GetName()) ) + cout << "Adding SDigits " << GetName() << " from " << folder->GetName() << endl ; } cout << endl ; - cout << "Writing digits to " << ((TObjString *) fHeaderFiles->At(0))->GetString() << endl ; + cout << "Writing digits to " << GetTitle() << endl ; cout << endl ; cout << "With following parameters: " << endl ; @@ -667,8 +458,11 @@ void AliPHOSDigitizer::Print(Option_t* option)const { void AliPHOSDigitizer::PrintDigits(Option_t * option){ // Print a table of digits + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + TClonesArray * digits = gime->Digits() ; + cout << "AliPHOSDigitiser:"<< endl ; - cout << " Number of entries in Digits list " << fDigits->GetEntriesFast() << endl ; + cout << " Number of entries in Digits list " << digits->GetEntriesFast() << endl ; cout << endl ; if(strstr(option,"all")){ @@ -676,8 +470,8 @@ void AliPHOSDigitizer::PrintDigits(Option_t * option){ AliPHOSDigit * digit; cout << "Digit Id " << " Amplitude " << " Index " << " Nprim " << " Primaries list " << endl; Int_t index ; - for (index = 0 ; index < fDigits->GetEntries() ; index++) { - digit = (AliPHOSDigit * ) fDigits->At(index) ; + for (index = 0 ; index < digits->GetEntries() ; index++) { + digit = (AliPHOSDigit * ) digits->At(index) ; cout << setw(8) << digit->GetId() << " " << setw(3) << digit->GetAmp() << " " << setw(6) << digit->GetIndexInList() << " " << setw(5) << digit->GetNprimary() <<" "; @@ -690,23 +484,159 @@ void AliPHOSDigitizer::PrintDigits(Option_t * option){ } } + //__________________________________________________________________ void AliPHOSDigitizer::SetSDigitsBranch(const char* title) { // we set title (comment) of the SDigits branch in the first! header file - if(!fInitialized) Init() ; - - ((TObjString*) fSDigitsTitles->At(0) )->SetString((char*)title) ; + if( strcmp(GetName(), "") == 0 ) + Init() ; + AliPHOSGetter::GetInstance()->SDigits()->SetName(title) ; + } + //__________________________________________________________________ -void AliPHOSDigitizer::SetDigitsBranch(const char* title) +Bool_t AliPHOSDigitizer::ReadSDigits(Int_t event) { - //Sets the title (comment) of the branch to which Digits branch - if(!fInitialized) Init() ; + // Reads summable digits from the opened files for the particular set of events given by fIevent + + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; - fDigitsTitle = title ; + TFile * file = (TFile*)gROOT->GetFile(GetTitle()); + file->cd() ; -} -//__________________________________________________________________ +// Get SDigits Tree header from file + TString treeName("TreeS") ; + treeName += event ; + TTree * treeS = (TTree*)file->Get(treeName.Data()); + + if(treeS==0){ + cerr << "ERROR: AliPHOSDigitizer::ReadSDigits There is no SDigit Tree" << endl; + return kFALSE; + } + + //set address of the SDigits and SDigitizer + TBranch * sdigitsBranch = 0; + TBranch * sdigitizerBranch = 0; + TObjArray * lob = (TObjArray*)gAlice->TreeS()->GetListOfBranches() ; + TIter next(lob) ; + TBranch * branch = 0 ; + Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ; + + while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) { + if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), GetName())==0) ) { + phosfound = kTRUE ; + sdigitsBranch = branch ; + } + + else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), GetName())==0) ) { + sdigitizerfound = kTRUE ; + sdigitizerBranch = branch ; + } + } + if ( !phosfound || !sdigitizerfound ) { + cerr << "WARNING: AliPHOSDigitizer::ReadSDigits -> Digits and/or Digitizer branch with name " << GetName() + << " not found" << endl ; + return kFALSE ; + } + + + TClonesArray * sdigits = gime->SDigits() ; + sdigitsBranch->SetAddress(&sdigits) ; + + AliPHOSSDigitizer * sdigitizer = gime->SDigitizer() ; + sdigitizerBranch->SetAddress(&sdigitizer) ; + + sdigitsBranch->GetEntry(0) ; + sdigitizerBranch->GetEntry(0) ; + fPedestal = sdigitizer->GetPedestalParameter() ; + fSlope = sdigitizer->GetCalibrationParameter() ; + + return kTRUE ; + +} + +//____________________________________________________________________________ +void AliPHOSDigitizer::Reset() +{ + // sets current event number to the first simulated event + + if( strcmp(GetName(), "") == 0 ) + Init() ; + + // Int_t inputs ; +// for(inputs = 0; inputs < fNinputs ;inputs++) +// fIevent->AddAt(-1, inputs ) ; + +} + +//____________________________________________________________________________ +void AliPHOSDigitizer::WriteDigits(Int_t event) +{ + + // Makes TreeD in the output file. + // Check if branch already exists: + // if yes, exit without writing: ROOT TTree does not support overwriting/updating of + // already existing branches. + // else creates branch with Digits, named "PHOS", title "...", + // and branch "AliPHOSDigitizer", with the same title to keep all the parameters + // and names of files, from which digits are made. + + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + TClonesArray * digits = gime->Digits() ; + + + gAlice->GetEvent(event) ; + if(gAlice->TreeD()==0) + gAlice->MakeTree("D") ; + + // create new branches + // -- generate file name if necessary + char * file =0; + if(gSystem->Getenv("CONFIG_SPLIT_FILE")){ //generating file name + file = new char[strlen(gAlice->GetBaseFile())+20] ; + sprintf(file,"%s/PHOS.Digits.root",gAlice->GetBaseFile()) ; + } + + TDirectory *cwd = gDirectory; + + // -- create Digits branch + Int_t bufferSize = 32000 ; + TBranch * digitsBranch = gAlice->TreeD()->Branch("PHOS",&digits,bufferSize); + digitsBranch->SetTitle(GetName()); + if (file) { + digitsBranch->SetFile(file); + TIter next( digitsBranch->GetListOfBranches()); + TBranch * sbr ; + while ((sbr=(TBranch*)next())) { + sbr->SetFile(file); + } + cwd->cd(); + } + + // -- Create Digitizer branch + Int_t splitlevel = 0 ; + AliPHOSDigitizer * d = gime->Digitizer(GetName()) ; + TBranch * digitizerBranch = gAlice->TreeD()->Branch("AliPHOSDigitizer", "AliPHOSDigitizer", &d,bufferSize,splitlevel); + digitizerBranch->SetTitle(GetName()); + if (file) { + digitizerBranch->SetFile(file); + TIter next( digitizerBranch->GetListOfBranches()); + TBranch * sbr; + while ((sbr=(TBranch*)next())) { + sbr->SetFile(file); + } + cwd->cd(); + } + + + digitsBranch->Fill() ; + digitizerBranch->Fill() ; + + gAlice->TreeD()->Write(0,kOverwrite) ; + +} + + diff --git a/PHOS/AliPHOSDigitizer.h b/PHOS/AliPHOSDigitizer.h index 8cf50c0dd79..e938ec2de8e 100644 --- a/PHOS/AliPHOSDigitizer.h +++ b/PHOS/AliPHOSDigitizer.h @@ -28,27 +28,24 @@ class AliPHOSDigitizer: public TTask { public: AliPHOSDigitizer() ; // ctor - AliPHOSDigitizer(const char *headerFile,const char * sDigitsBranchTitle = 0) ; + AliPHOSDigitizer(const char *headerFile, const char * name = "No Name") ; AliPHOSDigitizer(const AliPHOSDigitizer & dtizer) {( (AliPHOSDigitizer &)dtizer ).Copy(*this) ;} // cpy ctor virtual ~AliPHOSDigitizer() ; - void Digitize(Option_t *option); // Make Digits from SDigits stored in fSDigits + void Digitize(const Int_t event) ; // Make Digits from SDigits void Exec(Option_t *option); // Supervising method - Float_t GetCPVNoise() const { return fCPVNoise ;} - Float_t GetCPVThreshold() const { return fCPVDigitThreshold ;} - Float_t GetEMCThreshold() const { return fEMCDigitThreshold;} - Float_t GetPedestal() const { return fPedestal; } - Float_t GetPinNoise() const { return fPinNoise;} - Float_t GetPPSDNoise() const { return fPPSDNoise ;} - Float_t GetPPSDThreshold()const { return fPPSDDigitThreshold ;} - Float_t GetSlope() const { return fSlope; } - char * GetDigitsBranch ()const { return (char*)fDigitsTitle.Data() ;} - char * GetSDigitsBranch()const { return (char*)((TObjString*)fSDigitsTitles->At(0))->GetString().Data() ;} - TClonesArray * GetHeadersFiles() const { return fHeaderFiles ;} - TArrayI * GetCurrentEvents()const { return fIevent ;} - - void MixWith(char* HeaderFile, char* SDigitsTitle =0) ; // Add another one file to mix + const Float_t GetCPVNoise() const { return fCPVNoise ;} + const Float_t GetCPVThreshold() const { return fCPVDigitThreshold ;} + const Float_t GetEMCThreshold() const { return fEMCDigitThreshold;} + const Float_t GetPedestal() const { return fPedestal; } + const Float_t GetPinNoise() const { return fPinNoise;} + const Float_t GetPPSDNoise() const { return fPPSDNoise ;} + const Float_t GetPPSDThreshold()const { return fPPSDDigitThreshold ;} + const Float_t GetSlope() const { return fSlope; } + // const TArrayI * GetCurrentEvents()const { return fIevent ;} + + void MixWith(const char* HeaderFile) ; // Add another one file to mix virtual void Print(Option_t* option)const ; void Reset() ; //restarts starts event processing from 0 event(s) @@ -59,7 +56,6 @@ public: void SetPPSDNoise(Float_t PPSDNoise) {fPPSDNoise = PPSDNoise;} void SetPPSDThreshold(Float_t PPSDThreshold){fPPSDDigitThreshold = PPSDThreshold;} - void SetDigitsBranch (const char* file) ; void SetSDigitsBranch(const char* file) ; AliPHOSDigitizer & operator = (const AliPHOSDigitizer & rvalue) { @@ -69,23 +65,12 @@ public: } private: - Bool_t Combinator() ; // makes all desirable combination sig+Bg - void Init(); - Bool_t ReadSDigits() ; // Read sdigits for particular events - void WriteDigits() ; // Writes Digits for particular event + void Init() ; void PrintDigits(Option_t * option) ; + Bool_t ReadSDigits(Int_t evt) ; // Read sdigits for particular events + void WriteDigits(Int_t evt) ; // Writes Digits for particular event private: - TClonesArray * fSDigitsTitles ; // Titles of sdigits branches - TClonesArray * fHeaderFiles ; // Names of files with headers to merge - TString fDigitsTitle ; // Title of the Digits Branch - TClonesArray * fSDigits ; // ! Lists of SDigits - TClonesArray * fDigits ; // ! Final list of digits - AliPHOSSDigitizer * fSDigitizer ; // ! SDigitizer to extarct some sdigitizing parameters - Int_t fNinputs ; // Number of input files - Bool_t fInitialized ; // kTRUE if AliPHOSDigitizer is initialized - TArrayI * fIevent ; // events to read at the next ReadSDigits() call - TArrayI * fIeventMax ; // Maximal number of events in each input file Float_t fPedestal ; // Calibration parameters Float_t fSlope ; // read from SDigitizer diff --git a/PHOS/AliPHOSEmcRecPoint.cxx b/PHOS/AliPHOSEmcRecPoint.cxx index d77e96bdf61..fc4a1a8a071 100644 --- a/PHOS/AliPHOSEmcRecPoint.cxx +++ b/PHOS/AliPHOSEmcRecPoint.cxx @@ -38,6 +38,7 @@ #include "AliPHOSGeometry.h" #include "AliPHOSEmcRecPoint.h" #include "AliRun.h" +#include "AliPHOSGetter.h" ClassImp(AliPHOSEmcRecPoint) @@ -50,9 +51,8 @@ AliPHOSEmcRecPoint::AliPHOSEmcRecPoint() : AliPHOSRecPoint() fAmp = 0. ; fCoreEnergy = 0 ; fEnergyList = 0 ; - fGeom = AliPHOSGeometry::GetInstance() ; fLocPos.SetX(1000000.) ; //Local position should be evaluated - + } //____________________________________________________________________________ @@ -114,7 +114,9 @@ Bool_t AliPHOSEmcRecPoint::AreNeighbours(AliPHOSDigit * digit1, AliPHOSDigit * d Bool_t aren = kFALSE ; - AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ; + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry(); + Int_t relid1[4] ; phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ; @@ -177,7 +179,7 @@ Int_t AliPHOSEmcRecPoint::Compare(const TObject * obj) const void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) const { // Commented by Dmitri Peressounko: there is no possibility to ensure, -// that AliPHOSIndexToObject keeps the correct information. +// that AliPHOSGetter keeps the correct information. // // Execute action corresponding to one event // // This member function is called when a AliPHOSRecPoint is clicked with the locator @@ -188,7 +190,7 @@ void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) const // // static Int_t pxold, pyold; -// AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ; +// AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; // static TGraph * digitgraph = 0 ; @@ -201,7 +203,8 @@ void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) const // case kButton1Down: { // AliPHOSDigit * digit ; -// AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ; +// AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; +// AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry(); // Int_t iDigit; // Int_t relid[4] ; @@ -217,7 +220,7 @@ void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) const // Float_t zimin = 999. ; // for(iDigit=0; iDigitGimeDigit(fDigitsList[iDigit]) ) ; +// digit = (AliPHOSDigit *) ( gime->Digit(fDigitsList[iDigit]) ) ; // phosgeom->AbsToRelNumbering(digit->GetId(), relid) ; // phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]); // if ( xi[iDigit] > ximax ) @@ -249,7 +252,7 @@ void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) const // Float_t x, z ; // for(iDigit=0; iDigitGimeDigit(fDigitsList[iDigit]) ) ; +// digit = (AliPHOSDigit *) ( gime->Digit(fDigitsList[iDigit]) ) ; // phosgeom->AbsToRelNumbering(digit->GetId(), relid) ; // phosgeom->RelPosInModule(relid, x, z); // histo->Fill(x, z, fEnergyList[iDigit] ) ; @@ -298,7 +301,9 @@ void AliPHOSEmcRecPoint::EvalDispersion(Float_t logWeight,TClonesArray * digits Float_t z = locpos.Z() ; AliPHOSDigit * digit ; - AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ; + + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry(); Int_t iDigit; for(iDigit=0; iDigit < fMulDigit; iDigit++) { @@ -334,8 +339,10 @@ void AliPHOSEmcRecPoint::EvalCoreEnergy(TClonesArray * digits) Float_t z = locpos.Z() ; AliPHOSDigit * digit ; - AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ; - + + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry(); + Int_t iDigit; for(iDigit=0; iDigit < fMulDigit; iDigit++) { digit = (AliPHOSDigit *) ( digits->At(fDigitsList[iDigit]) ) ; @@ -364,7 +371,10 @@ void AliPHOSEmcRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits) Double_t dxz = 0.; AliPHOSDigit * digit ; - AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ; + + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry(); + Int_t iDigit; for(iDigit=0; iDigitGetIPtoCrystalSurface() ; +// AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; +// AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry(); + // Double_t DistanceToIP= (Double_t ) phosgeom->GetIPtoCrystalSurface() ; // CosX = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+x*x) ; // CosZ = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+z*z) ; @@ -439,7 +451,8 @@ void AliPHOSEmcRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * dig AliPHOSDigit * digit ; - AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ; + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry(); Int_t iDigit; diff --git a/PHOS/AliPHOSFastRecParticle.h b/PHOS/AliPHOSFastRecParticle.h index e6fa46d4932..d754271cdc9 100644 --- a/PHOS/AliPHOSFastRecParticle.h +++ b/PHOS/AliPHOSFastRecParticle.h @@ -41,7 +41,7 @@ class AliPHOSFastRecParticle : public TParticle { return fIndexInList ; } Int_t GetPrimary(){return fPrimary;} - Int_t GetType() { + const Int_t GetType() const { // returns the type of the particle return fType ; } diff --git a/PHOS/AliPHOSGeometry.cxx b/PHOS/AliPHOSGeometry.cxx index 35fd78b1833..18d7b35af9b 100644 --- a/PHOS/AliPHOSGeometry.cxx +++ b/PHOS/AliPHOSGeometry.cxx @@ -105,12 +105,14 @@ void AliPHOSGeometry::Init(void) fRotMatrixArray = new TObjArray(fNModules) ; // post the geometry into the appropriate folder - // get the alice folder - TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("YSAlice") ; - // the folder that contains the alarms for PHOS - TFolder * folder = (TFolder*)alice->FindObject("folders/Geometry/PHOS"); + TFolder * folder = (TFolder*)gROOT->FindObjectAny("YSAlice/WhiteBoard/Geometry/PHOS"); + if ( !folder ) { + cerr << "ERROR: AliPHOSGeometry::Init -> No WhiteBoard/Geometry/PHOS found !" << endl ; + abort(); + } else { folder->SetOwner() ; folder->Add(this) ; + } } else { fgInit = kFALSE ; @@ -191,7 +193,7 @@ void AliPHOSGeometry::SetPHOSAngles() } //____________________________________________________________________________ -Bool_t AliPHOSGeometry::AbsToRelNumbering(const Int_t AbsId, Int_t * relid) +Bool_t AliPHOSGeometry::AbsToRelNumbering(const Int_t AbsId, Int_t * relid) const { // Converts the absolute numbering into the following array/ // relid[0] = PHOS Module number 1:fNModules @@ -261,7 +263,7 @@ Bool_t AliPHOSGeometry::AbsToRelNumbering(const Int_t AbsId, Int_t * relid) } //____________________________________________________________________________ -void AliPHOSGeometry::EmcModuleCoverage(const Int_t mod, Double_t & tm, Double_t & tM, Double_t & pm, Double_t & pM, Option_t * opt) +void AliPHOSGeometry::EmcModuleCoverage(const Int_t mod, Double_t & tm, Double_t & tM, Double_t & pm, Double_t & pM, Option_t * opt) const { // calculates the angular coverage in theta and phi of one EMC (=PHOS) module @@ -295,7 +297,7 @@ void AliPHOSGeometry::EmcModuleCoverage(const Int_t mod, Double_t & tm, Double_t } //____________________________________________________________________________ -void AliPHOSGeometry::EmcXtalCoverage(Double_t & theta, Double_t & phi, Option_t * opt) +void AliPHOSGeometry::EmcXtalCoverage(Double_t & theta, Double_t & phi, Option_t * opt) const { // calculates the angular coverage in theta and phi of a single crystal in a EMC(=PHOS) module @@ -396,7 +398,7 @@ void AliPHOSGeometry::GetGlobal(const AliRecPoint* RecPoint, TVector3 & gpos) co } //____________________________________________________________________________ -void AliPHOSGeometry::ImpactOnEmc(const Double_t theta, const Double_t phi, Int_t & ModuleNumber, Double_t & z, Double_t & x) +void AliPHOSGeometry::ImpactOnEmc(const Double_t theta, const Double_t phi, Int_t & ModuleNumber, Double_t & z, Double_t & x) const { // calculates the impact coordinates on PHOS of a neutral particle // emitted in the direction theta and phi in the ALICE global coordinate system @@ -423,7 +425,7 @@ void AliPHOSGeometry::ImpactOnEmc(const Double_t theta, const Double_t phi, Int_ } //____________________________________________________________________________ -Bool_t AliPHOSGeometry::RelToAbsNumbering(const Int_t * relid, Int_t & AbsId) +Bool_t AliPHOSGeometry::RelToAbsNumbering(const Int_t * relid, Int_t & AbsId) const { // Converts the relative numbering into the absolute numbering // EMCA crystals: @@ -477,7 +479,7 @@ Bool_t AliPHOSGeometry::RelToAbsNumbering(const Int_t * relid, Int_t & AbsId) //____________________________________________________________________________ -void AliPHOSGeometry::RelPosInAlice(const Int_t id, TVector3 & pos ) +void AliPHOSGeometry::RelPosInAlice(const Int_t id, TVector3 & pos ) const { // Converts the absolute numbering into the global ALICE coordinate system // It works only for the GPS2 geometry @@ -533,7 +535,7 @@ void AliPHOSGeometry::RelPosInAlice(const Int_t id, TVector3 & pos ) } //____________________________________________________________________________ -void AliPHOSGeometry::RelPosInModule(const Int_t * relid, Float_t & x, Float_t & z) +void AliPHOSGeometry::RelPosInModule(const Int_t * relid, Float_t & x, Float_t & z) const { // Converts the relative numbering into the local PHOS-module (x, z) coordinates // Note: sign of z differs from that in the previous version (Yu.Kharlov, 12 Oct 2000) diff --git a/PHOS/AliPHOSGeometry.h b/PHOS/AliPHOSGeometry.h index 097d27d2eb7..862d902b882 100644 --- a/PHOS/AliPHOSGeometry.h +++ b/PHOS/AliPHOSGeometry.h @@ -73,23 +73,23 @@ public: return TString("rad") ; } - Bool_t AbsToRelNumbering(const Int_t AbsId, Int_t * RelId) ; // converts the absolute PHOS numbering to a relative + Bool_t AbsToRelNumbering(const Int_t AbsId, Int_t * RelId) const ; // converts the absolute PHOS numbering to a relative - void EmcModuleCoverage(const Int_t m, Double_t & tm, Double_t & tM, Double_t & pm, Double_t & pM, Option_t * opt = Radian() ); + void EmcModuleCoverage(const Int_t m, Double_t & tm, Double_t & tM, Double_t & pm, Double_t & pM, Option_t * opt = Radian() ) const ; // calculates the angular coverage in theta and phi of a EMC module - void EmcXtalCoverage(Double_t & theta, Double_t & phi, Option_t * opt = Radian() ) ; + void EmcXtalCoverage(Double_t & theta, Double_t & phi, Option_t * opt = Radian() ) const ; // calculates the angular coverage in theta and phi of a // single crystal in a EMC module - void ImpactOnEmc(const Double_t theta, const Double_t phi, Int_t & ModuleNumber, Double_t & z, Double_t & x) ; + void ImpactOnEmc(const Double_t theta, const Double_t phi, Int_t & ModuleNumber, Double_t & z, Double_t & x) const ; // calculates the impact coordinates of a neutral particle // emitted in direction theta and phi in ALICE - void RelPosInModule(const Int_t * RelId, Float_t & y, Float_t & z) ; // gets the position of element (pad or Xtal) relative to + void RelPosInModule(const Int_t * RelId, Float_t & y, Float_t & z) const ; // gets the position of element (pad or Xtal) relative to // center of PHOS module - void RelPosInAlice(const Int_t AbsId, TVector3 & pos) ; // gets the position of element (pad or Xtal) relative to + void RelPosInAlice(const Int_t AbsId, TVector3 & pos) const ; // gets the position of element (pad or Xtal) relative to // Alice - Bool_t RelToAbsNumbering(const Int_t * RelId, Int_t & AbsId) ; // converts the absolute PHOS numbering to a relative + Bool_t RelToAbsNumbering(const Int_t * RelId, Int_t & AbsId) const ; // converts the absolute PHOS numbering to a relative Bool_t IsInitialized(void) const { return fgInit ; } diff --git a/PHOS/AliPHOSPID.cxx b/PHOS/AliPHOSPID.cxx index b0b73aad456..bea4c3382b2 100644 --- a/PHOS/AliPHOSPID.cxx +++ b/PHOS/AliPHOSPID.cxx @@ -42,18 +42,17 @@ ClassImp(AliPHOSPID) //____________________________________________________________________________ - AliPHOSPID::AliPHOSPID():TTask() + AliPHOSPID::AliPHOSPID():TTask("","") { // ctor } + //____________________________________________________________________________ -AliPHOSPID::AliPHOSPID(const char* header,const char * branch ):TTask() +AliPHOSPID::AliPHOSPID(const char* headerFile, const char * name ):TTask(name, headerFile) { // ctor - cout << "AliPHOSPID: This constructor should be overwritten! "<< endl ; - abort() ; - } + //____________________________________________________________________________ AliPHOSPID::~AliPHOSPID() { diff --git a/PHOS/AliPHOSPID.h b/PHOS/AliPHOSPID.h index b9b50e20ee1..39b0ad69c88 100644 --- a/PHOS/AliPHOSPID.h +++ b/PHOS/AliPHOSPID.h @@ -30,28 +30,24 @@ class AliPHOSPID : public TTask { public: AliPHOSPID() ; // ctor - AliPHOSPID(const char* headerFile,const char * tsBranch) ; + AliPHOSPID(const char* headerFile,const char * name) ; virtual ~AliPHOSPID() ; // dtor virtual void Exec(Option_t * option) = 0 ; virtual char * GetRecParticlesBranch()const = 0 ; virtual char * GetTrackSegmentsBranch()const = 0 ; virtual void Init()= 0 ; - virtual void Print(Option_t * option) const = 0 ; virtual void PlotDispersionCuts()const = 0; - virtual Bool_t ReadTrackSegments()= 0 ; - + virtual Bool_t ReadTrackSegments(Int_t event)= 0 ; virtual void SetIdentificationMethod(char * option) = 0 ; - virtual void SetShowerProfileCut(char * formula) = 0 ; virtual void SetDispersionCut(Float_t cut) = 0 ; virtual void SetCpvtoEmcDistanceCut(Float_t cut ) = 0; - virtual void SetTrackSegmentsBranch(const char* title) = 0 ; virtual void SetRecParticlesBranch (const char* title) = 0 ; - - virtual void WriteRecParticles()= 0 ; + virtual const char * Version() const = 0 ; + virtual void WriteRecParticles(Int_t event)= 0 ; protected: diff --git a/PHOS/AliPHOSPIDv1.cxx b/PHOS/AliPHOSPIDv1.cxx index a58fdec8aa0..6f47a5d7746 100644 --- a/PHOS/AliPHOSPIDv1.cxx +++ b/PHOS/AliPHOSPIDv1.cxx @@ -81,6 +81,8 @@ #include "AliPHOSTrackSegment.h" #include "AliPHOSTrackSegmentMakerv1.h" #include "AliPHOSRecParticle.h" +#include "AliPHOSGeometry.h" +#include "AliPHOSGetter.h" ClassImp( AliPHOSPIDv1) @@ -88,191 +90,168 @@ ClassImp( AliPHOSPIDv1) AliPHOSPIDv1::AliPHOSPIDv1():AliPHOSPID() { // default ctor - fIsInitialized = kFALSE ; + fFormula = 0 ; + fDispersion = 0. ; + fCpvEmcDistance = 0 ; + fHeaderFileName = "" ; + fTrackSegmentsTitle= "" ; + fRecPointsTitle = "" ; + fRecParticlesTitle = "" ; + fIDOptions = "" ; } //____________________________________________________________________________ -AliPHOSPIDv1::AliPHOSPIDv1(const char * headeFile,const char * tsBranchTitle):AliPHOSPID() +AliPHOSPIDv1::AliPHOSPIDv1(const char * headerFile,const char * name) : AliPHOSPID(headerFile, name) { //ctor with the indication on where to look for the track segments - fHeaderFileName = headeFile ; - - fTSTitle = tsBranchTitle ; - - SetName("AliPHOSPID") ; - SetTitle("version1") ; - fIsInitialized = kFALSE ; - + fFormula = new TFormula("LambdaCuts","(x>1)*(x<2.5)*(y>0)*(yGetFile(fHeaderFileName.Data() ) ; - - if(file == 0){ - if(fHeaderFileName.Contains("rfio")) // if we read file using HPSS - file = TFile::Open(fHeaderFileName.Data(),"update") ; - else - file = new TFile(fHeaderFileName.Data(),"update") ; - gAlice = (AliRun *) file->Get("gAlice") ; - } - - AliPHOS * phos = (AliPHOS *) gAlice->GetDetector("PHOS") ; - fGeom = AliPHOSGeometry::GetInstance(phos->GetGeometry()->GetName(),phos->GetGeometry()->GetTitle() ); - - fTrackSegments = new TClonesArray("AliPHOSTrackSegment",1) ; - fTSMaker = new AliPHOSTrackSegmentMakerv1() ; - fEmcRecPoints = new TObjArray(1) ; - fCpvRecPoints = new TObjArray(1) ; - fClusterizer = new AliPHOSClusterizerv1() ; - fRecParticles = new TClonesArray("AliPHOSRecParticle",100) ; - - fFormula = new TFormula("LambdaCuts","(x>1)*(x<2.5)*(y>0)*(yGetListOfBrowsables()->FindObject("YSAlice") ; - TTask * aliceRe = (TTask*)alice->FindObject("tasks/Reconstructioner") ; - TTask * phosRe = (TTask*)aliceRe->GetListOfTasks()->FindObject("PHOS") ; - phosRe->Add(this) ; - - fIsInitialized = kTRUE ; - } -} //____________________________________________________________________________ -Bool_t AliPHOSPIDv1::ReadTrackSegments() +Bool_t AliPHOSPIDv1::ReadTrackSegments(Int_t event) { // Reads TrackSegments an extracts the title of the RecPoints // branch from which TS were made of. // Then reads both TrackSegments and RecPoints. //Fist read Track Segment Branch and extract RecPointsBranch from fTSMaker - fTrackSegments->Clear() ; - fEmcRecPoints->Clear() ; - fCpvRecPoints->Clear() ; - fRecParticles->Clear() ; - gAlice->GetEvent(fNEvent) ; + gAlice->GetEvent(event) ; + gAlice->SetEvent(event) ; - TTree * treeR = gAlice->TreeR() ; - - if(treeR==0){ - char treeName[20]; - sprintf(treeName,"TreeR%d",fNEvent); - cout << "Error in AliPHOSClusterizerv1 : no "<TreeR()==0){ + cerr << "ERROR: AliPHOSPIDv1::ReadTrackSegments -> There is no Reconstruction Tree" << endl; + return kFALSE; } + + // Find TrackSegments + TBranch * tsbranch = 0; + TBranch * tsmakerbranch = 0; + TObjArray * lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ; + TIter next(lob) ; + TBranch * branch = 0 ; + Bool_t phostsfound = kFALSE, tsmakerfound = kFALSE ; + + TString taskName(GetName()) ; + taskName.ReplaceAll(Version(), "") ; - //first read TSMaker branch and extract information about RecPoints Branches - TBranch * tsMakerBranch = 0; - TBranch * tsBranch = 0; - - TObjArray * branches = treeR->GetListOfBranches() ; - Int_t ibranch; - Bool_t tsMakerNotFound = kTRUE ; - Bool_t tsNotFound = kTRUE ; + while ( (branch = (TBranch*)next()) && (!phostsfound || !tsmakerfound) ) { + if ( (strcmp(branch->GetName(), "PHOSTS")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) { + phostsfound = kTRUE ; + tsbranch = branch ; - for(ibranch = 0;(ibranch GetEntries())&&(tsMakerNotFound||tsNotFound);ibranch++){ - if(tsMakerNotFound){ - tsMakerBranch=(TBranch *) branches->At(ibranch) ; - if( fTSTitle.CompareTo(tsMakerBranch->GetTitle())==0 ) - if( strcmp(tsMakerBranch->GetName(),"AliPHOSTrackSegmentMaker") == 0) - tsMakerNotFound = kFALSE ; - } - if(tsNotFound){ - tsBranch=(TBranch *) branches->At(ibranch) ; - if( fTSTitle.CompareTo(tsBranch->GetTitle())==0 ) - if( strcmp(tsBranch->GetName(),"PHOSTS") == 0) - tsNotFound = kFALSE ; + } else if ( (strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) { + tsmakerfound = kTRUE ; + tsmakerbranch = branch ; } } - - if(tsMakerNotFound ||tsNotFound ){ - cout << "Can't find Branch with TrackSegmentMaker and TrackSegments " ; - cout << "Do nothing" <SetAddress(&fTSMaker) ; - tsBranch->SetAddress(&fTrackSegments) ; - - tsMakerBranch->GetEntry(0) ; - tsBranch->GetEntry(0) ; - - fRecPointsTitle = fTSMaker->GetRecPointsBranch() ; - - //reading now recponts branches - TBranch * emcBranch = 0; - TBranch * cpvBranch = 0; - TBranch * cluBranch = 0; - - Bool_t emcNotFound = kTRUE ; - Bool_t cpvNotFound = kTRUE ; - Bool_t cluNotFound = kTRUE ; + if ( !phostsfound || !tsmakerfound ) { + cerr << "WARNING: AliPHOSPIDv1::ReadTrackSegments -> TrackSegments and/or TrackSegmentMaker branch with name " << taskName.Data() + << " not found" << endl ; + return kFALSE ; + } - for(ibranch = 0;(ibranch GetEntries())&&(emcNotFound||cpvNotFound||cluNotFound);ibranch++){ - if(emcNotFound){ - emcBranch=(TBranch *) branches->At(ibranch) ; - if( fRecPointsTitle.CompareTo(emcBranch->GetTitle())==0 ) - if( strcmp(emcBranch->GetName(),"PHOSEmcRP") == 0) - emcNotFound = kFALSE ; - } - if(cpvNotFound){ - cpvBranch=(TBranch *) branches->At(ibranch) ; - if( fRecPointsTitle.CompareTo(cpvBranch->GetTitle())==0 ) - if( strcmp(cpvBranch->GetName(),"PHOSCpvRP") == 0) - cpvNotFound = kFALSE ; + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + + TClonesArray * trackSegments = gime->TrackSegments() ; + trackSegments->Clear() ; + tsbranch->SetAddress(&trackSegments) ; + + AliPHOSTrackSegmentMaker * tsmaker = 0 ; + tsmakerbranch->SetAddress(&tsmaker) ; + tsmakerbranch->GetEntry(0) ; + TString tsmakerName( fRecParticlesTitle ) ; + tsmakerName.Append(tsmaker->Version()) ; + tsmaker = gime->TrackSegmentMaker(tsmakerName) ; + + tsbranch->GetEntry(0) ; + tsmakerbranch->GetEntry(0) ; + + fRecPointsTitle = tsmaker->GetRecPointsBranch() ; + + // Find RecPoints + TBranch * emcbranch = 0; + TBranch * cpvbranch = 0; + TBranch * clusterizerbranch = 0; + lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ; + TIter next2(lob) ; + branch = 0 ; + Bool_t phosemcfound = kFALSE, phoscpvfound = kFALSE, clusterizerfound = kFALSE ; + + while ( (branch = (TBranch*)next2()) && (!phosemcfound || !phoscpvfound || !clusterizerfound) ) { + if ( (strcmp(branch->GetName(), "PHOSEmcRP")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) { + phosemcfound = kTRUE ; + emcbranch = branch ; } - if(cluNotFound){ - cluBranch=(TBranch *) branches->At(ibranch) ; - if( fRecPointsTitle.CompareTo(cluBranch->GetTitle())==0 ) - if( strcmp(cluBranch->GetName(),"AliPHOSClusterizer") == 0) - cluNotFound = kFALSE ; + + else if ( (strcmp(branch->GetName(), "PHOSCpvRP")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) { + phoscpvfound = kTRUE ; + cpvbranch = branch ; + + } else if ( (strcmp(branch->GetName(), "AliPHOSClusterizer")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) { + clusterizerfound = kTRUE ; + clusterizerbranch = branch ; } } + if ( !phosemcfound || !phoscpvfound || !clusterizerfound ) { + cerr << "WARNING: AliPHOSTrackPIDv1::ReadTrackSegments -> emc(cpv)RecPoints and/or Clusterizer branch with name " << taskName.Data() + << " not found" << endl ; + return kFALSE ; + } + + TObjArray * emcRecPoints = gime->EmcRecPoints() ; + emcRecPoints->Clear() ; + emcbranch->SetAddress(&emcRecPoints) ; - if(emcNotFound ||cpvNotFound ||cluNotFound ){ - cout << "Can't find Branch with RecPoints or AliPHOSClusterizer " ; - cout << "Do nothing" <CpvRecPoints() ; + cpvRecPoints->Clear() ; + cpvbranch->SetAddress(&cpvRecPoints) ; - emcBranch->SetAddress(&fEmcRecPoints) ; - cpvBranch->SetAddress(&fCpvRecPoints) ; - cluBranch->SetAddress(&fClusterizer) ; - - emcBranch->GetEntry(0) ; - cpvBranch->GetEntry(0) ; - cluBranch->GetEntry(0) ; - + + AliPHOSClusterizer * clusterizer = 0 ; + clusterizerbranch->SetAddress(&clusterizer) ; + clusterizerbranch->GetEntry(0) ; + TString clusterizerName( fTrackSegmentsTitle ) ; + clusterizerName.Append(clusterizer->Version()) ; + clusterizer = gime->Clusterizer(clusterizerName) ; + + emcbranch->GetEntry(0) ; + cpvbranch->GetEntry(0) ; + clusterizerbranch->GetEntry(0) ; + return kTRUE ; - - - + } + //____________________________________________________________________________ Float_t AliPHOSPIDv1::GetDistance(AliPHOSEmcRecPoint * emc,AliPHOSRecPoint * cpv, Option_t * Axis)const { // Calculates the distance between the EMC RecPoint and the PPSD RecPoint + const AliPHOSGeometry * geom = AliPHOSGetter::GetInstance()->PHOSGeometry() ; TVector3 vecEmc ; TVector3 vecCpv ; @@ -282,8 +261,8 @@ Float_t AliPHOSPIDv1::GetDistance(AliPHOSEmcRecPoint * emc,AliPHOSRecPoint * cp // Correct to difference in CPV and EMC position due to different distance to center. // we assume, that particle moves from center - Float_t dCPV = fGeom->GetIPtoOuterCoverDistance(); - Float_t dEMC = fGeom->GetIPtoCrystalSurface() ; + Float_t dCPV = geom->GetIPtoOuterCoverDistance(); + Float_t dEMC = geom->GetIPtoCrystalSurface() ; dEMC = dEMC / dCPV ; vecCpv = dEMC * vecCpv - vecEmc ; if (Axis == "X") return vecCpv.X(); @@ -300,20 +279,51 @@ void AliPHOSPIDv1::Exec(Option_t * option) { //Steering method - if(!fIsInitialized) + if( strcmp(GetName(), "")== 0 ) Init() ; - if(strstr(option,"tim")) + if(strstr(option,"tim")) gBenchmark->Start("PHOSPID"); + + if(strstr(option,"print")) { + Print("") ; + return ; + } + + //check, if the branch with name of this" already exits? + TObjArray * lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ; + TIter next(lob) ; + TBranch * branch = 0 ; + Bool_t phospidfound = kFALSE, pidfound = kFALSE ; + + TString taskName(GetName()) ; + taskName.ReplaceAll(Version(), "") ; + while ( (branch = (TBranch*)next()) && (!phospidfound || !pidfound) ) { + if ( (strcmp(branch->GetName(), "PHOSPID")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) + phospidfound = kTRUE ; + + else if ( (strcmp(branch->GetName(), "AliPHOSPID")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) + pidfound = kTRUE ; + } - Int_t nEvents = (Int_t) gAlice->TreeE()->GetEntries() ; - - for(fNEvent = 0 ;fNEvent RecParticles and/or PIDtMaker branch with name " + << taskName.Data() << " already exits" << endl ; + return ; + } + + Int_t nevents = (Int_t) gAlice->TreeE()->GetEntries() ; + Int_t ievent ; + + for(ievent = 0; ievent < nevents; ievent++){ + if(!ReadTrackSegments(ievent)) //reads TrackSegments for event ievent return ; + MakeRecParticles() ; - WriteRecParticles(); + cout << "MAKE" << endl ; + WriteRecParticles(ievent); + if(strstr(option,"deb")) PrintRecParticles(option) ; } @@ -322,17 +332,50 @@ void AliPHOSPIDv1::Exec(Option_t * option) gBenchmark->Stop("PHOSPID"); cout << "AliPHOSPID:" << endl ; cout << " took " << gBenchmark->GetCpuTime("PHOSPID") << " seconds for PID " - << gBenchmark->GetCpuTime("PHOSPID")/nEvents << " seconds per event " << endl ; + << gBenchmark->GetCpuTime("PHOSPID")/nevents << " seconds per event " << endl ; cout << endl ; } } +//____________________________________________________________________________ +void AliPHOSPIDv1::Init() +{ + // Make all memory allocations that are not possible in default constructor + // Add the PID task to the list of PHOS tasks + + if ( strcmp(GetTitle(), "") == 0 ) + SetTitle("galice.root") ; + + TString taskName(GetName()) ; + taskName.ReplaceAll(Version(), "") ; + + AliPHOSGetter * gime = AliPHOSGetter::GetInstance(GetTitle(), taskName.Data()) ; + if ( gime == 0 ) { + cerr << "ERROR: AliPHOSPIDv1::Init -> Could not obtain the Getter object !" << endl ; + return ; + } + + //add Task to //YSAlice/tasks/Reconstructioner/PHOS + TTask * aliceRe = (TTask*)gROOT->FindObjectAny("YSAlice/tasks/Reconstructioner") ; + TTask * phosRe = (TTask*)aliceRe->GetListOfTasks()->FindObject("PHOS") ; + phosRe->Add(this) ; + // create a folder on the white board //YSAlice/WhiteBoard/RecParticles/PHOS/recparticlesName + gime->Post(GetTitle(), "P", taskName.Data() ) ; + +} + //____________________________________________________________________________ void AliPHOSPIDv1::MakeRecParticles(){ // Makes a RecParticle out of a TrackSegment - TIter next(fTrackSegments) ; + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + TObjArray * emcRecPoints = gime->EmcRecPoints() ; + TObjArray * cpvRecPoints = gime->CpvRecPoints() ; + TClonesArray * trackSegments = gime->TrackSegments() ; + TClonesArray * recParticles = gime->RecParticles() ; + + TIter next(trackSegments) ; AliPHOSTrackSegment * ts ; Int_t index = 0 ; AliPHOSRecParticle * rp ; @@ -342,21 +385,21 @@ void AliPHOSPIDv1::MakeRecParticles(){ while ( (ts = (AliPHOSTrackSegment *)next()) ) { - new( (*fRecParticles)[index] ) AliPHOSRecParticle() ; - rp = (AliPHOSRecParticle *)fRecParticles->At(index) ; + new( (*recParticles)[index] ) AliPHOSRecParticle() ; + rp = (AliPHOSRecParticle *)recParticles->At(index) ; rp->SetTraskSegment(index) ; AliPHOSEmcRecPoint * emc = 0 ; if(ts->GetEmcIndex()>=0) - emc = (AliPHOSEmcRecPoint *) fEmcRecPoints->At(ts->GetEmcIndex()) ; + emc = (AliPHOSEmcRecPoint *) emcRecPoints->At(ts->GetEmcIndex()) ; AliPHOSRecPoint * cpv = 0 ; if(ts->GetCpvIndex()>=0) - cpv = (AliPHOSRecPoint *) fCpvRecPoints->At(ts->GetCpvIndex()) ; + cpv = (AliPHOSRecPoint *) cpvRecPoints->At(ts->GetCpvIndex()) ; AliPHOSRecPoint * ppsd = 0 ; if(ts->GetPpsdIndex()>=0) - ppsd= (AliPHOSRecPoint *) fCpvRecPoints->At(ts->GetPpsdIndex()) ; + ppsd= (AliPHOSRecPoint *) cpvRecPoints->At(ts->GetPpsdIndex()) ; //set momentum and energy first Float_t e = emc->GetEnergy() ; @@ -408,8 +451,8 @@ void AliPHOSPIDv1:: Print(Option_t * option) const cout << "Making PID "<< endl ; cout << " Headers file: " << fHeaderFileName.Data() << endl ; cout << " RecPoints branch title: " << fRecPointsTitle.Data() << endl ; - cout << " TrackSegments Branch title: " << fTSTitle.Data() << endl ; - cout << " RecParticles Branch title " << fRecparticlesTitle.Data() << endl; + cout << " TrackSegments Branch title: " << fTrackSegmentsTitle.Data() << endl ; + cout << " RecParticles Branch title " << fRecParticlesTitle.Data() << endl; cout << "with parameters: " << endl ; cout << " Maximal EMC - CPV (PPSD) distance (cm) " << fCpvEmcDistance << endl ; if(fIDOptions.Contains("dis",TString::kIgnoreCase )) @@ -431,40 +474,15 @@ void AliPHOSPIDv1::SetShowerProfileCut(char * formula) fFormula = new TFormula("Lambda Cut",formula) ; } //____________________________________________________________________________ -void AliPHOSPIDv1::WriteRecParticles() +void AliPHOSPIDv1::WriteRecParticles(Int_t event) { - //check, if these branches already exist - TBranch * pidBranch = 0; - TBranch * rpBranch = 0; - - TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ; - Int_t ibranch; - Bool_t pidNotFound = kTRUE ; - Bool_t rpNotFound = kTRUE ; - - for(ibranch = 0;(ibranch GetEntries())&& pidNotFound && rpNotFound;ibranch++){ - if(pidNotFound){ - pidBranch=(TBranch *) branches->At(ibranch) ; - if( (strcmp(pidBranch->GetName(),"PHOSPID") == 0) && - (fRecparticlesTitle.CompareTo(pidBranch->GetTitle()) == 0) ) - pidNotFound = kFALSE ; - } - if(rpNotFound){ - rpBranch=(TBranch *) branches->At(ibranch) ; - if( (strcmp(rpBranch->GetName(),"PHOSRP") == 0) && - (fRecparticlesTitle.CompareTo(rpBranch->GetTitle())==0 )) - rpNotFound = kFALSE ; - } - } - - if(!pidNotFound || !rpNotFound) { - cout << "AliPHOSPIDv1 error: " << endl ; - cout << " Branch PHOSRP and PHOSPID with title '"<RecParticles() ; + + gAlice->GetEvent(event) ; - //Make branch in TreeR for TrackSegments + //Make branch in TreeR for RecParticles char * filename = 0; if(gSystem->Getenv("CONFIG_SPLIT_FILE")!=0){ //generating file name filename = new char[strlen(gAlice->GetBaseFile())+20] ; @@ -475,8 +493,8 @@ void AliPHOSPIDv1::WriteRecParticles() //First rp Int_t bufferSize = 32000 ; - rpBranch = gAlice->TreeR()->Branch("PHOSRP",&fRecParticles,bufferSize); - rpBranch->SetTitle(fRecparticlesTitle.Data()); + TBranch * rpBranch = gAlice->TreeR()->Branch("PHOSRP",&recParticles,bufferSize); + rpBranch->SetTitle(fRecParticlesTitle.Data()); if (filename) { rpBranch->SetFile(filename); TIter next( rpBranch->GetListOfBranches()); @@ -490,8 +508,8 @@ void AliPHOSPIDv1::WriteRecParticles() //second, pid Int_t splitlevel = 0 ; AliPHOSPIDv1 * pid = this ; - pidBranch = gAlice->TreeR()->Branch("AliPHOSPID","AliPHOSPIDv1",&pid,bufferSize,splitlevel); - pidBranch->SetTitle(fRecparticlesTitle.Data()); + TBranch * pidBranch = gAlice->TreeR()->Branch("AliPHOSPID","AliPHOSPIDv1",&pid,bufferSize,splitlevel); + pidBranch->SetTitle(fRecParticlesTitle.Data()); if (filename) { pidBranch->SetFile(filename); TIter next( pidBranch->GetListOfBranches()); @@ -508,6 +526,7 @@ void AliPHOSPIDv1::WriteRecParticles() gAlice->TreeR()->Write(0,kOverwrite) ; } + //____________________________________________________________________________ void AliPHOSPIDv1::PlotDispersionCuts()const { @@ -593,8 +612,12 @@ void AliPHOSPIDv1::PrintRecParticles(Option_t * option) { // Print table of reconstructed particles + AliPHOSGetter *gime = AliPHOSGetter::GetInstance() ; + TClonesArray * recParticles = gime->RecParticles() ; + + cout << "AliPHOSPIDv1: " << endl ; - cout << " found " << fRecParticles->GetEntriesFast() << " RecParticles " << endl ; + cout << " found " << recParticles->GetEntriesFast() << " RecParticles " << endl ; if(strstr(option,"all")) { // printing found TS @@ -607,8 +630,8 @@ void AliPHOSPIDv1::PrintRecParticles(Option_t * option) // << " Primaries list " << endl; Int_t index ; - for (index = 0 ; index < fRecParticles->GetEntries() ; index++) { - AliPHOSRecParticle * rp = (AliPHOSRecParticle * ) fRecParticles->At(index) ; + for (index = 0 ; index < recParticles->GetEntries() ; index++) { + AliPHOSRecParticle * rp = (AliPHOSRecParticle * ) recParticles->At(index) ; Text_t particle[11]; switch(rp->GetType()) { diff --git a/PHOS/AliPHOSPIDv1.h b/PHOS/AliPHOSPIDv1.h index af1c8e64d60..c3341e11068 100644 --- a/PHOS/AliPHOSPIDv1.h +++ b/PHOS/AliPHOSPIDv1.h @@ -33,47 +33,36 @@ public: virtual ~AliPHOSPIDv1() ; // dtor virtual void Exec(Option_t * option); - virtual char * GetRecParticlesBranch()const {return (char*) fRecparticlesTitle.Data() ;} - virtual char * GetTrackSegmentsBranch()const{return (char*) fTSTitle.Data(); } + virtual char * GetRecParticlesBranch()const {return (char*) fRecParticlesTitle.Data() ;} + virtual char * GetTrackSegmentsBranch()const{return (char*) fTrackSegmentsTitle.Data(); } virtual void Init() ; - virtual void PlotDispersionCuts()const ; - virtual void Print(Option_t * option)const ; - - virtual Bool_t ReadTrackSegments() ; - virtual void SetIdentificationMethod(char * option = "CPV DISP" ){fIDOptions = option ;} - - virtual void SetShowerProfileCut(char * formula = - "0.35*0.35 - (x-1.386)*(x-1.386) - 1.707*1.707*(y-1.008)*(y-1.008)") ; - + virtual void SetShowerProfileCut(char * formula = "0.35*0.35 - (x-1.386)*(x-1.386) - 1.707*1.707*(y-1.008)*(y-1.008)") ; virtual void SetDispersionCut(Float_t cut){fDispersion = cut ; } virtual void SetCpvtoEmcDistanceCut(Float_t cut ) {fCpvEmcDistance = cut ;} - virtual void SetTrackSegmentsBranch(const char* title) { fTSTitle = title;} - virtual void SetRecParticlesBranch (const char* title) { fRecparticlesTitle = title;} - - virtual void WriteRecParticles() ; + virtual void SetTrackSegmentsBranch(const char* title) { fTrackSegmentsTitle = title;} + virtual void SetRecParticlesBranch (const char* title) { fRecParticlesTitle = title;} + virtual const char * Version() const { return "pid-v1" ; } - private: + void MakeRecParticles(void ) ; - Float_t GetDistance(AliPHOSEmcRecPoint * emc, AliPHOSRecPoint * cpv, Option_t * Axis)const ; - // Relative Distance PPSD-EMC + Float_t GetDistance(AliPHOSEmcRecPoint * emc, AliPHOSRecPoint * cpv, Option_t * Axis)const ; // Relative Distance PPSD-EMC TVector3 GetMomentumDirection(AliPHOSEmcRecPoint * emc, AliPHOSRecPoint * cpv, AliPHOSRecPoint * ppsd)const ; - void PrintRecParticles(Option_t * option) ; + virtual Bool_t ReadTrackSegments(Int_t event) ; + virtual void WriteRecParticles(Int_t event) ; private: TString fHeaderFileName ; // file name with event header - TString fTSTitle; // branch name with track segments + TString fTrackSegmentsTitle; // branch name with track segments TString fRecPointsTitle ; // branch name with rec points - TString fRecparticlesTitle ; // branch name with rec particles - + TString fRecParticlesTitle ; // branch name with rec particles TString fIDOptions ; // PID option - Int_t fNEvent ; // current event number TObjArray * fEmcRecPoints ; // ! initial EMC RecPoints TObjArray * fCpvRecPoints ; // ! initial CPV RecPoints @@ -83,14 +72,10 @@ public: AliPHOSClusterizer * fClusterizer ; // ! AliPHOSTrackSegmentMaker * fTSMaker ; // ! - AliPHOSGeometry * fGeom ; // !pointer to PHOS geometry TFormula * fFormula ; // formula to define cut on the shouer elips axis Float_t fDispersion ; // dispersion cut Float_t fCpvEmcDistance ; // Max EMC-CPV distance - Bool_t fIsInitialized ; // kTRUE is inifialized - - ClassDef( AliPHOSPIDv1,1) // Particle identifier implementation version 1 }; diff --git a/PHOS/AliPHOSPpsdRecPoint.cxx b/PHOS/AliPHOSPpsdRecPoint.cxx index 4c8bcf3dab7..609bcc5d1eb 100644 --- a/PHOS/AliPHOSPpsdRecPoint.cxx +++ b/PHOS/AliPHOSPpsdRecPoint.cxx @@ -36,6 +36,7 @@ #include "AliPHOSPpsdRecPoint.h" #include "AliPHOSCpvRecPoint.h" #include "AliRun.h" +#include "AliPHOSGetter.h" ClassImp(AliPHOSPpsdRecPoint) @@ -45,7 +46,6 @@ AliPHOSPpsdRecPoint::AliPHOSPpsdRecPoint(void) // ctor fMulDigit = 0 ; - fGeom = AliPHOSGeometry::GetInstance() ; fLocPos.SetX(1000000.) ; //Local position should be evaluated } @@ -187,7 +187,8 @@ void AliPHOSPpsdRecPoint::EvalLocalPosition(Float_t logWeight,TClonesArray * dig Float_t x = 0. ; Float_t z = 0. ; - AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ; + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry(); AliPHOSDigit * digit ; Int_t iDigit; @@ -219,7 +220,8 @@ void AliPHOSPpsdRecPoint::EvalUp(TClonesArray * digits) Int_t relid[4] ; - AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ; + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry(); AliPHOSDigit *digit = (AliPHOSDigit *) digits->At(fDigitsList[0]) ; diff --git a/PHOS/AliPHOSQAAlarm.cxx b/PHOS/AliPHOSQAAlarm.cxx index 5d14e710e9b..02b6035a3b3 100644 --- a/PHOS/AliPHOSQAAlarm.cxx +++ b/PHOS/AliPHOSQAAlarm.cxx @@ -41,6 +41,7 @@ ClassImp(AliPHOSQAAlarm) fCable = checked ; fCer = checker ; fMessage = message ; + fEvent = gAlice->GetEvNumber() ; } //____________________________________________________________________________ @@ -54,5 +55,5 @@ ClassImp(AliPHOSQAAlarm) { // print the message - cout << fMessage << endl; + cout << "Event# " << fEvent << " " << fMessage << endl; } diff --git a/PHOS/AliPHOSQAAlarm.h b/PHOS/AliPHOSQAAlarm.h index c21c20b3c37..395015c2206 100644 --- a/PHOS/AliPHOSQAAlarm.h +++ b/PHOS/AliPHOSQAAlarm.h @@ -7,7 +7,7 @@ //_________________________________________________________________________ // An alarm object that is instanciated by a AliPHOSQACheckable in response to -// a AliPHOSQAChecker +// a AliPHOSQAAlarm // //*-- Author: Yves Schutz (SUBATECH) @@ -23,6 +23,7 @@ // --- AliRoot header files --- +#include "AliRun.h" class AliPHOSQAAlarm : public TObject { @@ -35,11 +36,11 @@ public: private: - - TString fTime ; // time when the alarm was raised TString fCable ; // checkable name that raised the alarm TString fCer ; // checker name that raised the alarm + Int_t fEvent ; // event number where alarms occured TString fMessage ; // the whole error message + TString fTime ; // time when the alarm was raised ClassDef(AliPHOSQAAlarm,1) // description diff --git a/PHOS/AliPHOSQAChecker.cxx b/PHOS/AliPHOSQAChecker.cxx index a2efbbb1785..2d4a048312c 100644 --- a/PHOS/AliPHOSQAChecker.cxx +++ b/PHOS/AliPHOSQAChecker.cxx @@ -41,8 +41,7 @@ ClassImp(AliPHOSQAChecker) { // ctor // stores checkers in the PHOS QA TTask folder //YSAlice/tasks/QA/PHOS - TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("YSAlice") ; - TTask * aliceQA = (TTask*)alice->FindObject("tasks/QA") ; + TTask * aliceQA = (TTask*)gROOT->FindObjectAny("YSAlice/tasks/QA") ; TTask * phosQA = (TTask*)aliceQA->GetListOfTasks()->FindObject("PHOS") ; if (phosQA) // PHOS QA Tasks container exists phosQA->Add(this) ; diff --git a/PHOS/AliPHOSQAFloatCheckable.cxx b/PHOS/AliPHOSQAFloatCheckable.cxx index 31d299eb402..178cb4f5536 100644 --- a/PHOS/AliPHOSQAFloatCheckable.cxx +++ b/PHOS/AliPHOSQAFloatCheckable.cxx @@ -40,8 +40,7 @@ ClassImp(AliPHOSQAFloatCheckable) AliPHOSQAFloatCheckable::AliPHOSQAFloatCheckable(const char * name) : AliPHOSQAVirtualCheckable(name) { //ctor initial value is zero - fType = new char[1] ; - strcpy(fType,"F") ; + fType = "F" ; fValue = 0. ; } @@ -50,7 +49,6 @@ ClassImp(AliPHOSQAFloatCheckable) AliPHOSQAFloatCheckable::~AliPHOSQAFloatCheckable() { // dtor - delete fType ; } diff --git a/PHOS/AliPHOSQAIntCheckable.cxx b/PHOS/AliPHOSQAIntCheckable.cxx index 1a250b16a49..cc49b77822e 100644 --- a/PHOS/AliPHOSQAIntCheckable.cxx +++ b/PHOS/AliPHOSQAIntCheckable.cxx @@ -40,8 +40,7 @@ ClassImp(AliPHOSQAIntCheckable) AliPHOSQAIntCheckable::AliPHOSQAIntCheckable(const char * name) : AliPHOSQAVirtualCheckable(name) { //ctor initial value is zero - fType = new char[1] ; - strcpy(fType,"I") ; + fType = "I" ; fValue = 0 ; } @@ -50,7 +49,6 @@ ClassImp(AliPHOSQAIntCheckable) AliPHOSQAIntCheckable::~AliPHOSQAIntCheckable() { // dtor - delete fType ; } //____________________________________________________________________________ diff --git a/PHOS/AliPHOSQAMeanChecker.cxx b/PHOS/AliPHOSQAMeanChecker.cxx index 16f1ad426ef..c3236813ecb 100644 --- a/PHOS/AliPHOSQAMeanChecker.cxx +++ b/PHOS/AliPHOSQAMeanChecker.cxx @@ -68,7 +68,7 @@ TString AliPHOSQAMeanChecker::CheckingOperation() TString rv ; Float_t checked = 0. ; - if ( strcmp(fCheckable->HasA(),"I") && strcmp(fCheckable->HasA(),"F") ) { + if ( (fCheckable->HasA() == "I") && (fCheckable->HasA() == "F") ) { cout << " ERROR : checker " << GetName() << " says you got the wrong checkable " << fCheckable->GetName() << endl ; cout << " or the checkable has no value !" << endl ; diff --git a/PHOS/AliPHOSQAObjectCheckable.cxx b/PHOS/AliPHOSQAObjectCheckable.cxx index c38682f8d46..15d8c976f62 100644 --- a/PHOS/AliPHOSQAObjectCheckable.cxx +++ b/PHOS/AliPHOSQAObjectCheckable.cxx @@ -39,8 +39,7 @@ ClassImp(AliPHOSQAObjectCheckable) //____________________________________________________________________________ AliPHOSQAObjectCheckable::AliPHOSQAObjectCheckable(const char * name) : AliPHOSQAVirtualCheckable(name) { - fType = new char[1] ; - strcpy(fType,"O") ; + fType = "O" ; fObject = 0 ; } diff --git a/PHOS/AliPHOSQAVirtualCheckable.cxx b/PHOS/AliPHOSQAVirtualCheckable.cxx index aff1e5f4792..a6bc4e69c64 100644 --- a/PHOS/AliPHOSQAVirtualCheckable.cxx +++ b/PHOS/AliPHOSQAVirtualCheckable.cxx @@ -26,6 +26,7 @@ #include "TClass.h" #include "TFolder.h" #include "TROOT.h" +#include "TTree.h" // --- Standard library --- @@ -37,6 +38,8 @@ #include "AliPHOSQAVirtualCheckable.h" #include "AliPHOSQAChecker.h" #include "AliPHOSQAAlarm.h" +#include "AliPHOSGetter.h" +#include "AliPHOS.h" ClassImp(AliPHOSQAVirtualCheckable) @@ -44,20 +47,18 @@ ClassImp(AliPHOSQAVirtualCheckable) AliPHOSQAVirtualCheckable::AliPHOSQAVirtualCheckable(const char * name) : TNamed(name, name) { // ctor, creates the task(s) + fType = "" ; fChange = kFALSE ; // create a new folder that will hold the list of alarms - // get the alice folder - TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("YSAlice") ; // the folder that contains the alarms for PHOS - fAlarms = (TFolder*)alice->FindObject("folders/QAAlarms/PHOS"); + fAlarms = (TFolder*)gROOT->FindObjectAny("YSAlice/WhiteBoard/QAAlarms/PHOS"); // make it the owner of the objects that it contains fAlarms->SetOwner() ; - // add the alarms list to //YSAlice/folders/QAAlarms/PHOS - TList * alarms = new TList() ; // deleted when fAlarms is deleted + // add the alarms list to //YSAlice/WhiteBoard/QAAlarms/PHOS + TObjArray * alarms = new TObjArray() ; // deleted when fAlarms is deleted alarms->SetName(name) ; fAlarms->Add(alarms) ; fChecker = 0 ; - } //____________________________________________________________________________ @@ -65,7 +66,6 @@ ClassImp(AliPHOSQAVirtualCheckable) { // ctor delete fAlarms ; - delete fType ; } //____________________________________________________________________________ @@ -83,7 +83,7 @@ ClassImp(AliPHOSQAVirtualCheckable) void AliPHOSQAVirtualCheckable::Alarms() const { // Prints all the alarms - TList * alarms = GetAlarms() ; + TObjArray * alarms = GetAlarms() ; if (alarms->IsEmpty() ) cout << " No alarms raised for checkable " << GetName() << endl ; else { @@ -105,7 +105,7 @@ void AliPHOSQAVirtualCheckable::CheckMe() //____________________________________________________________________________ void AliPHOSQAVirtualCheckable::RaiseAlarm(const char * time, const char * checked, const char * checker, const char * message) { - // Raise an alarm and store it in the appropriate folder : //YSAlice/folders/QAAlarms/PHOS/.. + // Raise an alarm and store it in the appropriate folder : //YSAlice/WhiteBoard/QAAlarms/PHOS/.. // cout << message ; AliPHOSQAAlarm * alarm = new AliPHOSQAAlarm(time, checked, checker, message) ; GetAlarms()->Add(alarm) ; @@ -126,7 +126,7 @@ void AliPHOSQAVirtualCheckable::RaiseAlarm(const char * time, const char * check void AliPHOSQAVirtualCheckable::ResetAlarms() { // resets the list of alarms (delete the alarms from the list) - TList * alarms = GetAlarms() ; + TObjArray * alarms = GetAlarms() ; if (alarms->IsEmpty() ) cout << " No alarms raised for checkable " << GetName() << endl ; else { diff --git a/PHOS/AliPHOSQAVirtualCheckable.h b/PHOS/AliPHOSQAVirtualCheckable.h index 42205123bdf..ac77fdce371 100644 --- a/PHOS/AliPHOSQAVirtualCheckable.h +++ b/PHOS/AliPHOSQAVirtualCheckable.h @@ -39,9 +39,9 @@ public: void Alarms() const ; void CheckMe() ; virtual Bool_t HasChanged() const { return fChange ; } - TList * GetAlarms() const { return (TList*)fAlarms->FindObject(GetName()) ; } + TObjArray * GetAlarms() const { return (TObjArray*)fAlarms->FindObject(GetName()) ; } virtual Float_t GetValue() const = 0 ; - char * HasA() const { return fType ; } + TString HasA() const { return fType ; } virtual void Print() const = 0 ; void RaiseAlarm(const char * time, const char * checked, const char * checker, const char * message) ; void RemoveChecker(AliPHOSQAChecker *ch) ; @@ -52,9 +52,9 @@ public: protected: AliPHOSQAChecker * fChecker ; // the task(s) that is going to act on the checkable - char * fType ; //[1] I, F, or O - TFolder * fAlarms ; // folder that contains the PHOS alarms - Bool_t fChange ; // tells if the checkable has been updated + TString fType ; // I, F, or O + TFolder * fAlarms ; // folder that contains the PHOS alarms + Bool_t fChange ; // tells if the checkable has been updated ClassDef(AliPHOSQAVirtualCheckable,1) // description diff --git a/PHOS/AliPHOSRecPoint.cxx b/PHOS/AliPHOSRecPoint.cxx index e756bea8e06..1e01fdeb088 100644 --- a/PHOS/AliPHOSRecPoint.cxx +++ b/PHOS/AliPHOSRecPoint.cxx @@ -33,6 +33,7 @@ #include "AliPHOSGeometry.h" #include "AliPHOSDigit.h" #include "AliPHOSRecPoint.h" +#include "AliPHOSGetter.h" ClassImp(AliPHOSRecPoint) @@ -43,9 +44,10 @@ AliPHOSRecPoint::AliPHOSRecPoint() { // ctor - fGeom = (AliPHOSGeometry*) AliPHOSGeometry::GetInstance() ; fMaxTrack = 200 ; fPHOSMod = 0; + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + fGeom = (AliPHOSGeometry*)gime->PHOSGeometry(); } //____________________________________________________________________________ @@ -97,7 +99,9 @@ void AliPHOSRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) case kButton1Down:{ AliPHOSDigit * digit ; - AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ; + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry(); + Int_t iDigit; Int_t relid[4] ; @@ -167,7 +171,8 @@ void AliPHOSRecPoint::EvalPHOSMod(AliPHOSDigit * digit) if( fPHOSMod == 0){ Int_t relid[4] ; - AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ; + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry(); phosgeom->AbsToRelNumbering(digit->GetId(), relid) ; fPHOSMod = relid[0]; diff --git a/PHOS/AliPHOSRecPoint.h b/PHOS/AliPHOSRecPoint.h index 31192d46589..aa0dd75bdfa 100644 --- a/PHOS/AliPHOSRecPoint.h +++ b/PHOS/AliPHOSRecPoint.h @@ -21,7 +21,6 @@ #include "AliRecPoint.h" #include "AliPHOSDigit.h" -#include "AliPHOSGeometry.h" class AliPHOSRecPoint : public AliRecPoint { diff --git a/PHOS/AliPHOSReconstructioner.cxx b/PHOS/AliPHOSReconstructioner.cxx index dc23cdd92d9..e73805d9bd3 100644 --- a/PHOS/AliPHOSReconstructioner.cxx +++ b/PHOS/AliPHOSReconstructioner.cxx @@ -427,8 +427,8 @@ void AliPHOSReconstructioner::SetBranchTitle(const char* branch, const char * ti } if(strcmp(branch,"Digits") == 0){ - fDigitizer->SetDigitsBranch(title) ; - fClusterizer->SetDigitsBranch(title) ; + fDigitizer->SetName(title) ; + fClusterizer->SetName(title) ; fDigitsBranch = title ; return ; } @@ -507,8 +507,8 @@ void AliPHOSReconstructioner::StartFrom(char * module,char* title) fSDigitsBranch = title ; break ; case 16: //"AliPHOSDigitizer" - fDigitizer->SetDigitsBranch(title) ; - fClusterizer->SetDigitsBranch(title) ; + fDigitizer->SetName(title) ; + fClusterizer->SetName(title) ; fDigitsBranch = title ; break ; case 18: //"AliPHOSClusterizer" diff --git a/PHOS/AliPHOSSDigitizer.cxx b/PHOS/AliPHOSSDigitizer.cxx index b0ca76bc7f1..113a6367794 100644 --- a/PHOS/AliPHOSSDigitizer.cxx +++ b/PHOS/AliPHOSSDigitizer.cxx @@ -17,6 +17,10 @@ //_________________________________________________________________________ // This is a TTask that makes SDigits out of Hits +// The name of the TTask is also the title of the branch that will contain +// the created SDigits +// The title of the TTAsk is the name of the file that contains the hits from +// which the SDigits are created // A Summable Digits is the sum of all hits originating // from one primary in one active cell // A threshold for assignment of the primary to SDigit is applied @@ -59,6 +63,7 @@ // --- AliRoot header files --- #include "AliRun.h" #include "AliPHOSDigit.h" +#include "AliPHOSGetter.h" #include "AliPHOSHit.h" #include "AliPHOSSDigitizer.h" @@ -67,43 +72,25 @@ ClassImp(AliPHOSSDigitizer) //____________________________________________________________________________ - AliPHOSSDigitizer::AliPHOSSDigitizer():TTask("AliPHOSSDigitizer","") + AliPHOSSDigitizer::AliPHOSSDigitizer():TTask("","") { // ctor fA = 0; fB = 10000000.; fPrimThreshold = 0.01 ; - fNevents = 0 ; - fSDigits = 0 ; - fHits = 0 ; - fIsInitialized = kFALSE ; - } //____________________________________________________________________________ -AliPHOSSDigitizer::AliPHOSSDigitizer(const char* headerFile, const char *sDigitsTitle):TTask("AliPHOSSDigitizer","") +AliPHOSSDigitizer::AliPHOSSDigitizer(const char * headerFile, const char * sDigitsTitle):TTask(sDigitsTitle, headerFile) { // ctor fA = 0; fB = 10000000.; fPrimThreshold = 0.01 ; - fNevents = 0 ; - fSDigitsTitle = sDigitsTitle ; - fHeadersFile = headerFile ; - fIsInitialized = kFALSE ; - Init(); } -//____________________________________________________________________________ -AliPHOSSDigitizer::~AliPHOSSDigitizer() -{ - // dtor - if(fSDigits) - delete fSDigits ; - if(fHits) - delete fHits ; -} + //____________________________________________________________________________ void AliPHOSSDigitizer::Init() { @@ -111,141 +98,131 @@ void AliPHOSSDigitizer::Init() // attach task SDigitizer to the list of PHOS tasks // // Initialization can not be done in the default constructor - - if(!fIsInitialized){ - - if(fHeadersFile.IsNull()) - fHeadersFile="galice.root" ; - - TFile * file = (TFile*) gROOT->GetFile(fHeadersFile.Data() ) ; - - //if file was not opened yet, read gAlice - if(file == 0){ - if(fHeadersFile.Contains("rfio")) - file = TFile::Open(fHeadersFile,"update") ; - else - file = new TFile(fHeadersFile.Data(),"update") ; - gAlice = (AliRun *) file->Get("gAlice") ; - } - - fHits = new TClonesArray("AliPHOSHit",1000); - fSDigits = new TClonesArray("AliPHOSDigit",1000); - - //add Task to //YSAlice/tasks/(S)Diditizer/PHOS - TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("YSAlice") ; - TTask * aliceSD = (TTask*)alice->FindObject("tasks/(S)Digitizer") ; - TTask * phosSD = (TTask*)aliceSD->GetListOfTasks()->FindObject("PHOS") ; + //============================================================= YS + // The initialisation is now done by AliPHOSGetter + + if( strcmp(GetTitle(), "") == 0 ) + SetTitle("galice.root") ; + + AliPHOSGetter * gime = AliPHOSGetter::GetInstance(GetTitle(), GetName()) ; + if ( gime == 0 ) { + cerr << "ERROR: AliPHOSSDigitizer::Init -> Could not obtain the Getter object !" << endl ; + return ; + } + + //add Task to //YSAlice/tasks/SDiditizer/PHOS + TTask * aliceSD = (TTask*)gROOT->FindObjectAny("YSAlice/tasks/SDigitizer") ; + TTask * phosSD = (TTask*)aliceSD->GetListOfTasks()->FindObject("PHOS") ; + if ( ! phosSD->GetListOfTasks()->FindObject(GetName()) ) phosSD->Add(this) ; + // create a folder on the white board //YSAlice/WhiteBoard/SDigits/PHOS/headerFile/sdigitsTitle + gime->Post(GetTitle(), "S", GetName() ) ; - fIsInitialized = kTRUE ; - } } + //____________________________________________________________________________ void AliPHOSSDigitizer::Exec(Option_t *option) { // Collects all hits in the same active volume into digit - - if(!fIsInitialized) + if( strcmp(GetName(), "") == 0 ) Init() ; + + if (strstr(option, "print") ) { + Print("") ; + return ; + } if(strstr(option,"tim")) gBenchmark->Start("PHOSSDigitizer"); + + //Check, if this branch already exits + TObjArray * lob = (TObjArray*)gAlice->TreeS()->GetListOfBranches() ; + TIter next(lob) ; + TBranch * branch = 0 ; + Bool_t phosfound = kFALSE, sdigitizerfound = kFALSE ; - fNevents = (Int_t) gAlice->TreeE()->GetEntries() ; + while ( (branch = (TBranch*)next()) && (!phosfound || !sdigitizerfound) ) { + if ( (strcmp(branch->GetName(), "PHOS")==0) && (strcmp(branch->GetTitle(), GetName())==0) ) + phosfound = kTRUE ; + + else if ( (strcmp(branch->GetName(), "AliPHOSSDigitizer")==0) && (strcmp(branch->GetTitle(), GetName())==0) ) + sdigitizerfound = kTRUE ; + } + + if ( phosfound || sdigitizerfound ) { + cerr << "WARNING: AliPHOSSDigitizer::Exec -> SDigits and/or SDigitizer branch with name " << GetName() + << " already exits" << endl ; + return ; + } + + + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + + TClonesArray * hits = gime->Hits() ; + + Int_t nevents = (Int_t) gAlice->TreeE()->GetEntries() ; Int_t ievent ; - for(ievent = 0; ievent < fNevents; ievent++){ + for(ievent = 0; ievent < nevents; ievent++){ gAlice->GetEvent(ievent) ; gAlice->SetEvent(ievent) ; if(gAlice->TreeH()==0){ - cout << "AliPHOSSDigitizer: There is no Hit Tree" << endl; + cerr << "ERROR: AliPHOSSDigitizer::Exec There is no Hit Tree" << endl; return ; } //set address of the hits TBranch * branch = gAlice->TreeH()->GetBranch("PHOS"); if (branch) - branch->SetAddress(&fHits); + branch->SetAddress(&hits); else{ - cout << "ERROR in AliPHOSSDigitizer: "<< endl ; - cout << " no branch PHOS in TreeH"<< endl ; - cout << " do nothing " << endl ; + cerr << "ERROR: AliPHOSSDigitizer::Exec -> No branch PHOS in TreeH " << endl ; + cerr << " Do nothing " << endl ; return ; } - - fSDigits->Clear(); + + TClonesArray * sdigits = gime->SDigits(GetName()) ; + + sdigits->Clear(); Int_t nSdigits = 0 ; - //Now made SDigits from hits, for PHOS it is the same, so just copy + //Now make SDigits from hits, for PHOS it is the same, so just copy Int_t itrack ; for (itrack=0; itrack < gAlice->GetNtrack(); itrack++){ - + //=========== Get the PHOS branch from Hits Tree for the Primary track itrack branch->GetEntry(itrack,0); - Int_t i; - for ( i = 0 ; i < fHits->GetEntries() ; i++ ) { - AliPHOSHit * hit = (AliPHOSHit*)fHits->At(i) ; - + for ( i = 0 ; i < hits->GetEntries() ; i++ ) { + const AliPHOSHit * hit = gime->Hit(i) ; // Assign primary number only if contribution is significant + if( hit->GetEnergy() > fPrimThreshold) - new((*fSDigits)[nSdigits]) AliPHOSDigit( hit->GetPrimary(), hit->GetId(), Digitize( hit->GetEnergy() ) ) ; + new((*sdigits)[nSdigits]) AliPHOSDigit( hit->GetPrimary(), hit->GetId(), Digitize( hit->GetEnergy() ) ) ; else - new((*fSDigits)[nSdigits]) AliPHOSDigit( -1 , hit->GetId(), Digitize( hit->GetEnergy() ) ) ; + new((*sdigits)[nSdigits]) AliPHOSDigit( -1 , hit->GetId(), Digitize( hit->GetEnergy() ) ) ; nSdigits++ ; } - + } // loop over tracks - fSDigits->Sort() ; - - nSdigits = fSDigits->GetEntriesFast() ; - fSDigits->Expand(nSdigits) ; + sdigits->Sort() ; + nSdigits = sdigits->GetEntriesFast() ; + sdigits->Expand(nSdigits) ; Int_t i ; for (i = 0 ; i < nSdigits ; i++) { - AliPHOSDigit * digit = (AliPHOSDigit *) fSDigits->At(i) ; + AliPHOSDigit * digit = (AliPHOSDigit *) sdigits->At(i) ; digit->SetIndexInList(i) ; } if(gAlice->TreeS() == 0) gAlice->MakeTree("S") ; - //check, if this branch already exits? - TBranch * sdigitsBranch = 0; - TBranch * sdigitizerBranch = 0; - - TObjArray * branches = gAlice->TreeS()->GetListOfBranches() ; - Int_t ibranch; - Bool_t phosNotFound = kTRUE ; - Bool_t sdigitizerNotFound = kTRUE ; - - for(ibranch = 0;ibranch GetEntries();ibranch++){ - - if(phosNotFound){ - sdigitsBranch=(TBranch *) branches->At(ibranch) ; - if( (strcmp("PHOS",sdigitsBranch->GetName())==0 ) && - (fSDigitsTitle.CompareTo(sdigitsBranch->GetTitle()) == 0) ) - phosNotFound = kFALSE ; - } - if(sdigitizerNotFound){ - sdigitizerBranch = (TBranch *) branches->At(ibranch) ; - if( (strcmp(sdigitizerBranch->GetName(),"AliPHOSSDigitizer") == 0)&& - (fSDigitsTitle.CompareTo(sdigitizerBranch->GetTitle()) == 0) ) - sdigitizerNotFound = kFALSE ; - } - } - - if(!(sdigitizerNotFound && phosNotFound)){ - cout << "AliPHOSSdigitizer error:" << endl ; - cout << "Can not overwrite existing branches: do not write" << endl ; - return ; - } - //Make (if necessary) branches char * file =0; if(gSystem->Getenv("CONFIG_SPLIT_FILE")){ //generating file name @@ -257,8 +234,8 @@ void AliPHOSSDigitizer::Exec(Option_t *option) //First list of sdigits Int_t bufferSize = 32000 ; - sdigitsBranch = gAlice->TreeS()->Branch("PHOS",&fSDigits,bufferSize); - sdigitsBranch->SetTitle(fSDigitsTitle.Data()); + TBranch * sdigitsBranch = gAlice->TreeS()->Branch("PHOS",&sdigits,bufferSize); + sdigitsBranch->SetTitle(GetName()); if (file) { sdigitsBranch->SetFile(file); TIter next( sdigitsBranch->GetListOfBranches()); @@ -269,12 +246,12 @@ void AliPHOSSDigitizer::Exec(Option_t *option) cwd->cd(); } - //second - SDigitizer + //Next - SDigitizer Int_t splitlevel = 0 ; AliPHOSSDigitizer * sd = this ; - sdigitizerBranch = gAlice->TreeS()->Branch("AliPHOSSDigitizer","AliPHOSSDigitizer", + TBranch * sdigitizerBranch = gAlice->TreeS()->Branch("AliPHOSSDigitizer","AliPHOSSDigitizer", &sd,bufferSize,splitlevel); - sdigitizerBranch->SetTitle(fSDigitsTitle.Data()); + sdigitizerBranch->SetTitle(GetName()); if (file) { sdigitizerBranch->SetFile(file); TIter next( sdigitizerBranch->GetListOfBranches()); @@ -299,7 +276,7 @@ void AliPHOSSDigitizer::Exec(Option_t *option) gBenchmark->Stop("PHOSSDigitizer"); cout << "AliPHOSSDigitizer:" << endl ; cout << " took " << gBenchmark->GetCpuTime("PHOSSDigitizer") << " seconds for SDigitizing " - << gBenchmark->GetCpuTime("PHOSSDigitizer")/fNevents << " seconds per event " << endl ; + << gBenchmark->GetCpuTime("PHOSSDigitizer")/nevents << " seconds per event " << endl ; cout << endl ; } @@ -309,16 +286,34 @@ void AliPHOSSDigitizer::Exec(Option_t *option) void AliPHOSSDigitizer::SetSDigitsBranch(const char * title ) { // Setting title to branch SDigits - if(!fSDigitsTitle.IsNull()) - cout << "AliPHOSSdigitizer: changing SDigits file from " <TreeS()->GetListOfBranches()->FindObject("PHOS") ; + TBranch * sdigitizerBranch = (TBranch*)gAlice->TreeS()->GetListOfBranches()->FindObject("AliPHOSSDigitizer") ; + const char * sdigitsTitle = sdigitsBranch ->GetTitle() ; + const char * sdigitizerTitle = sdigitizerBranch ->GetTitle() ; + if ( stitle.CompareTo(sdigitsTitle)==0 || stitle.CompareTo(sdigitizerTitle)==0 ){ + cerr << "ERROR: AliPHOSSdigitizer::SetSDigitsBranch -> Cannot overwrite existing branch with title " << title << endl ; + return ; + } + + cout << "AliPHOSSdigitizer::SetSDigitsBranch -> Changing SDigits file from " << GetName() << " to " << title << endl ; + + SetName(title) ; + + // Post to the WhiteBoard + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + gime->Post(GetTitle(), "S", GetName()) ; } + //__________________________________________________________________ void AliPHOSSDigitizer::Print(Option_t* option)const { // Prints parameters of SDigitizer cout << "------------------- "<< GetName() << " -------------" << endl ; - cout << " Writing SDigitis to branch with title " << fSDigitsTitle.Data() << endl ; + cout << " Writing SDigitis to branch with title " << GetName() << endl ; cout << " with digitization parameters A = " << fA << endl ; cout << " B = " << fB << endl ; cout << " Threshold for Primary assignment= " << fPrimThreshold << endl ; @@ -340,9 +335,12 @@ Bool_t AliPHOSSDigitizer::operator==( AliPHOSSDigitizer const &sd )const void AliPHOSSDigitizer::PrintSDigits(Option_t * option) { // Prints list of digits produced in the current pass of AliPHOSDigitizer - + + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + TClonesArray * sdigits = gime->SDigits(GetName()) ; + cout << "AliPHOSSDigitizer: " << endl ; - cout << " Number of entries in SDigits list " << fSDigits->GetEntriesFast() << endl ; + cout << " Number of entries in SDigits list " << sdigits->GetEntriesFast() << endl ; cout << endl ; if(strstr(option,"all")){// print all digits @@ -351,8 +349,8 @@ void AliPHOSSDigitizer::PrintSDigits(Option_t * option) AliPHOSDigit * digit; cout << "SDigit Id " << " Amplitude " << " Index " << " Nprim " << " Primaries list " << endl; Int_t index ; - for (index = 0 ; index < fSDigits->GetEntries() ; index++) { - digit = (AliPHOSDigit * ) fSDigits->At(index) ; + for (index = 0 ; index < sdigits->GetEntries() ; index++) { + digit = (AliPHOSDigit * ) sdigits->At(index) ; cout << setw(8) << digit->GetId() << " " << setw(3) << digit->GetAmp() << " " << setw(6) << digit->GetIndexInList() << " " << setw(5) << digit->GetNprimary() <<" "; @@ -365,3 +363,10 @@ void AliPHOSSDigitizer::PrintSDigits(Option_t * option) } } + +//____________________________________________________________________________ +void AliPHOSSDigitizer::UseHitsFrom(const char * filename) +{ + SetTitle(filename) ; + Init() ; +} diff --git a/PHOS/AliPHOSSDigitizer.h b/PHOS/AliPHOSSDigitizer.h index 5075eace06d..1b4ab37c04f 100644 --- a/PHOS/AliPHOSSDigitizer.h +++ b/PHOS/AliPHOSSDigitizer.h @@ -24,17 +24,17 @@ class AliPHOSSDigitizer: public TTask { public: AliPHOSSDigitizer() ; // ctor - AliPHOSSDigitizer(const char* HeaderFile,const char *SdigitsTitle = 0) ; - virtual ~AliPHOSSDigitizer() ; // dtor + AliPHOSSDigitizer(const char* HeaderFile,const char *SdigitsTitle = "No Name") ; + virtual ~AliPHOSSDigitizer(){} // dtor Float_t Calibrate(Int_t amp)const {return (amp - fA)/fB ; } Int_t Digitize(Float_t Energy)const { return (Int_t ) ( fA + Energy*fB); } virtual void Exec(Option_t *option); - Float_t GetPedestalParameter()const {return fA;} - Float_t GetCalibrationParameter()const{return fB;} - char * GetSDigitsBranch()const{return (char*) fSDigitsTitle.Data();} + const Float_t GetPedestalParameter()const {return fA;} + const Float_t GetCalibrationParameter()const{return fB;} + const char * GetSDigitsBranch()const{return GetName();} virtual void Print(Option_t* option) const ; @@ -42,6 +42,8 @@ public: void SetSlopeParameter(Float_t B){fB = B ;} void SetSDigitsBranch(const char * title ) ; + void UseHitsFrom(const char * filename) ; + Bool_t operator == (const AliPHOSSDigitizer & sd) const ; private: @@ -49,15 +51,10 @@ private: void PrintSDigits(Option_t * option) ; private: - Float_t fA ; //Pedestal parameter - Float_t fB ; //Slope Digitizition parameters - Int_t fNevents ; // Number of events to digitize + + Float_t fA ; // Pedestal parameter + Float_t fB ; // Slope Digitizition parameters Float_t fPrimThreshold ; // To store primari if Elos > threshold - TString fSDigitsTitle ; // title of SDigits branch - TString fHeadersFile ; //input file - Bool_t fIsInitialized ; // kTRUE if SDigitizer is initialized - TClonesArray * fSDigits ; //! list of SDigits - TClonesArray * fHits ; //! ClassDef(AliPHOSSDigitizer,1) // description diff --git a/PHOS/AliPHOSTrackSegmentMaker.cxx b/PHOS/AliPHOSTrackSegmentMaker.cxx index b8571ad4ef3..14e329068a1 100644 --- a/PHOS/AliPHOSTrackSegmentMaker.cxx +++ b/PHOS/AliPHOSTrackSegmentMaker.cxx @@ -32,11 +32,14 @@ ClassImp( AliPHOSTrackSegmentMaker) //____________________________________________________________________________ - AliPHOSTrackSegmentMaker:: AliPHOSTrackSegmentMaker() : TTask() + AliPHOSTrackSegmentMaker:: AliPHOSTrackSegmentMaker() : TTask("","") { + // ctor } + //____________________________________________________________________________ -AliPHOSTrackSegmentMaker::AliPHOSTrackSegmentMaker(char * header,char * branch): TTask("AliPHOSTrackSegmentMaker","") +AliPHOSTrackSegmentMaker::AliPHOSTrackSegmentMaker(const char * headerFile, const char * name): TTask(name, headerFile) { + // ctor } diff --git a/PHOS/AliPHOSTrackSegmentMaker.h b/PHOS/AliPHOSTrackSegmentMaker.h index f79d2d3ed99..5606aa4cfc1 100644 --- a/PHOS/AliPHOSTrackSegmentMaker.h +++ b/PHOS/AliPHOSTrackSegmentMaker.h @@ -29,7 +29,7 @@ class AliPHOSTrackSegmentMaker : public TTask { public: AliPHOSTrackSegmentMaker() ; - AliPHOSTrackSegmentMaker(char* headerFile, char* branchTitle) ; + AliPHOSTrackSegmentMaker(const char* headerFile, const char* name) ; virtual ~ AliPHOSTrackSegmentMaker(){ // dtor @@ -43,10 +43,11 @@ public: // virtual void Set... // method to choose recPoints: along z only, along x ...??? // virtual void SetChoosingAlgirithm() = 0 ; // virtual void SetMaxEmcCpvDistance(Float_t r) = 0 ; - virtual Bool_t ReadRecPoints() = 0 ; + virtual Bool_t ReadRecPoints(Int_t ievent) = 0 ; virtual void SetRecPointsBranch(const char * title) = 0 ; virtual void SetTrackSegmentsBranch(const char * title) = 0 ; - virtual void WriteTrackSegments() = 0 ; + virtual const char * Version() const = 0 ; + virtual void WriteTrackSegments(Int_t event) = 0 ; ClassDef( AliPHOSTrackSegmentMaker,1) // Algorithm class to make PHOS track segments (Base Class) diff --git a/PHOS/AliPHOSTrackSegmentMakerv1.cxx b/PHOS/AliPHOSTrackSegmentMakerv1.cxx index b26b726dc9d..c1c682c27c2 100644 --- a/PHOS/AliPHOSTrackSegmentMakerv1.cxx +++ b/PHOS/AliPHOSTrackSegmentMakerv1.cxx @@ -45,6 +45,7 @@ // --- ROOT system --- #include "TROOT.h" #include "TFile.h" +#include "TFolder.h" #include "TTree.h" #include "TSystem.h" #include "TBenchmark.h" @@ -61,6 +62,7 @@ #include "AliPHOSCpvRecPoint.h" #include "AliPHOSPpsdRecPoint.h" #include "AliPHOSLink.h" +#include "AliPHOSGetter.h" #include "AliPHOS.h" #include "AliRun.h" @@ -70,75 +72,45 @@ ClassImp( AliPHOSTrackSegmentMakerv1) //____________________________________________________________________________ AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1() : AliPHOSTrackSegmentMaker() { - // ctor - SetTitle("version 1") ; - SetName("AliPHOSTrackSegmentMaker") ; - fR0 = 10. ; - fEmcFirst = 0 ; - fEmcLast = 0 ; - fCpvFirst = 0 ; - fCpvLast = 0 ; - fPpsdFirst= 0 ; - fPpsdLast = 0 ; - fLinkLowArray = 0 ; - fLinkUpArray = 0 ; - fIsInitialized = kFALSE ; + // default ctor (to be used mainly by Streamer) + + fR0 = 10. ; + fEmcFirst = 0 ; + fEmcLast = 0 ; + fCpvFirst = 0 ; + fCpvLast = 0 ; + fPpsdFirst = 0 ; + fPpsdLast = 0 ; + fLinkLowArray = 0 ; + fLinkUpArray = 0 ; + fHeaderFileName = "" ; + fRecPointsBranchTitle = "" ; + fTrackSegmentsBranchTitle = "" ; } + //____________________________________________________________________________ - AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1(const char* headerFile, const char* branchTitle): -AliPHOSTrackSegmentMaker() + AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1(const char * headerFile, const char * name) : AliPHOSTrackSegmentMaker(headerFile, name) { // ctor - SetTitle("version 1") ; - SetName("AliPHOSTrackSegmentMaker") ; - fR0 = 10. ; - fEmcFirst = 0 ; - fEmcLast = 0 ; - fCpvFirst = 0 ; - fCpvLast = 0 ; - fPpsdFirst= 0 ; - fPpsdLast = 0 ; - fHeaderFileName = headerFile ; - fRecPointsBranchTitle = branchTitle ; - fIsInitialized = kFALSE ; + fR0 = 10. ; + fEmcFirst = 0 ; + fEmcLast = 0 ; + fCpvFirst = 0 ; + fCpvLast = 0 ; + fPpsdFirst = 0 ; + fPpsdLast = 0 ; + + fHeaderFileName = GetTitle() ; + fRecPointsBranchTitle = GetName() ; + fTrackSegmentsBranchTitle = GetName() ; - Init() ; + TString tempo(GetName()) ; + tempo.Append(Version()) ; + SetName(tempo.Data()) ; -} -//____________________________________________________________________________ -void AliPHOSTrackSegmentMakerv1::Init() -{ - // Make all memory allocations that are not possible in default constructor - - if(!fIsInitialized){ - if(fHeaderFileName.IsNull()) - fHeaderFileName = "galice.root" ; - - TFile * file = (TFile*) gROOT->GetFile(fHeaderFileName.Data() ) ; - - if(file == 0){ - if(fHeaderFileName.Contains("rfio")) // if we read file using HPSS - file = TFile::Open(fHeaderFileName.Data(),"update") ; - else - file = new TFile(fHeaderFileName.Data(),"update") ; - gAlice = (AliRun *) file->Get("gAlice") ; - } - - AliPHOS * phos = (AliPHOS *) gAlice->GetDetector("PHOS") ; - fGeom = AliPHOSGeometry::GetInstance(phos->GetGeometry()->GetName(),phos->GetGeometry()->GetTitle() ); - - fEmcRecPoints = new TObjArray(200) ; - fCpvRecPoints = new TObjArray(200) ; - fClusterizer = new AliPHOSClusterizerv1() ; - - fTrackSegments = new TClonesArray("AliPHOSTrackSegment",200) ; + Init() ; - fLinkLowArray = new TClonesArray("AliPHOSLink", 1000); - fLinkUpArray = new TClonesArray("AliPHOSLink", 1000); - - fIsInitialized = kTRUE ; - } } //____________________________________________________________________________ @@ -155,21 +127,25 @@ void AliPHOSTrackSegmentMakerv1::FillOneModule() // Finds first and last indexes between which // clusters from one PHOS module are + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + const AliPHOSGeometry * geom = gime->PHOSGeometry() ; + TObjArray * emcRecPoints = gime->EmcRecPoints() ; + TObjArray * cpvRecPoints = gime->CpvRecPoints() ; //First EMC clusters - Int_t totalEmc = fEmcRecPoints->GetEntriesFast() ; + Int_t totalEmc = emcRecPoints->GetEntriesFast() ; for(fEmcFirst = fEmcLast; (fEmcLast < totalEmc) && - (((AliPHOSRecPoint *) fEmcRecPoints->At(fEmcLast))->GetPHOSMod() == fModule ); + (((AliPHOSRecPoint *) emcRecPoints->At(fEmcLast))->GetPHOSMod() == fModule ); fEmcLast ++) ; //Now CPV clusters - Int_t totalCpv = fCpvRecPoints->GetEntriesFast() ; + Int_t totalCpv = cpvRecPoints->GetEntriesFast() ; - if(fModule <= fGeom->GetNCPVModules()){ // in CPV geometry + if(fModule <= geom->GetNCPVModules()){ // in CPV geometry for(fCpvFirst = fCpvLast; (fCpvLast < totalCpv) && - (((AliPHOSRecPoint *) fCpvRecPoints->At(fCpvLast))->GetPHOSMod() == fModule ); + (((AliPHOSRecPoint *) cpvRecPoints->At(fCpvLast))->GetPHOSMod() == fModule ); fCpvLast ++) ; fPpsdFirst = fCpvLast ; //To avoid scanning RecPoints between fPpsdFirst and fPpsdLast @@ -179,18 +155,19 @@ void AliPHOSTrackSegmentMakerv1::FillOneModule() fCpvLast = fPpsdLast ; //Upper layer first for(fCpvFirst = fCpvLast; (fCpvLast < totalCpv) && - (((AliPHOSPpsdRecPoint *) fCpvRecPoints->At(fCpvLast))->GetPHOSMod() == fModule ) && - (((AliPHOSPpsdRecPoint *) fCpvRecPoints->At(fCpvLast))->GetUp()) ; + (((AliPHOSPpsdRecPoint *) cpvRecPoints->At(fCpvLast))->GetPHOSMod() == fModule ) && + (((AliPHOSPpsdRecPoint *) cpvRecPoints->At(fCpvLast))->GetUp()) ; fCpvLast ++) ; fPpsdLast= fCpvLast ; for(fPpsdFirst = fPpsdLast; (fPpsdLast < totalCpv) && - (((AliPHOSPpsdRecPoint *) fCpvRecPoints->At(fPpsdLast))->GetPHOSMod() == fModule ) && - (!((AliPHOSPpsdRecPoint *) fCpvRecPoints->At(fPpsdLast))->GetUp()) ; + (((AliPHOSPpsdRecPoint *) cpvRecPoints->At(fPpsdLast))->GetPHOSMod() == fModule ) && + (!((AliPHOSPpsdRecPoint *) cpvRecPoints->At(fPpsdLast))->GetUp()) ; fPpsdLast ++) ; } } + //____________________________________________________________________________ Float_t AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint * emcClu,AliPHOSRecPoint * cpvClu, Bool_t &toofar)const { @@ -227,6 +204,36 @@ Float_t AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint * return r ; } +//____________________________________________________________________________ +void AliPHOSTrackSegmentMakerv1::Init() +{ + // Make all memory allocations that are not possible in default constructor + + if ( strcmp(GetTitle(), "") == 0 ) + SetTitle("galice.root") ; + + TString taskName(GetName()) ; + taskName.ReplaceAll(Version(), "") ; + + AliPHOSGetter * gime = AliPHOSGetter::GetInstance(GetTitle(), taskName.Data()) ; + if ( gime == 0 ) { + cerr << "ERROR: AliPHOSTrackSegmentMakerv1::Init -> Could not obtain the Getter object !" << endl ; + return ; + } + + fLinkLowArray = new TClonesArray("AliPHOSLink", 1000); + fLinkUpArray = new TClonesArray("AliPHOSLink", 1000); + + //add Task to //YSAlice/tasks/Reconstructioner/PHOS + TTask * aliceRe = (TTask*)gROOT->FindObjectAny("YSAlice/tasks/Reconstructioner") ; + TTask * phosRe = (TTask*)aliceRe->GetListOfTasks()->FindObject("PHOS") ; + phosRe->Add(this) ; + // create a folder on the white board //YSAlice/WhiteBoard/RecPoints/PHOS/trackSegmentsName + + gime->Post(GetTitle(), "T", taskName.Data() ) ; + +} + //____________________________________________________________________________ void AliPHOSTrackSegmentMakerv1::MakeLinks()const { @@ -234,6 +241,10 @@ void AliPHOSTrackSegmentMakerv1::MakeLinks()const // which are not further apart from each other than fR0 // and sort them in accordance with this distance + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + TObjArray * emcRecPoints = gime->EmcRecPoints() ; + TObjArray * cpvRecPoints = gime->CpvRecPoints() ; + fLinkUpArray->Clear() ; fLinkLowArray->Clear() ; @@ -246,13 +257,13 @@ void AliPHOSTrackSegmentMakerv1::MakeLinks()const Int_t iEmcRP; for(iEmcRP = fEmcFirst; iEmcRP < fEmcLast; iEmcRP++ ) { - emcclu = (AliPHOSEmcRecPoint *) fEmcRecPoints->At(iEmcRP) ; + emcclu = (AliPHOSEmcRecPoint *) emcRecPoints->At(iEmcRP) ; Bool_t toofar ; Int_t iPpsd ; for(iPpsd = fPpsdFirst; iPpsd < fPpsdLast;iPpsd++ ) { - ppsd = (AliPHOSRecPoint *) fCpvRecPoints->At(iPpsd) ; + ppsd = (AliPHOSRecPoint *) cpvRecPoints->At(iPpsd) ; Float_t r = GetDistanceInPHOSPlane(emcclu, ppsd, toofar) ; if(toofar) @@ -264,7 +275,7 @@ void AliPHOSTrackSegmentMakerv1::MakeLinks()const Int_t iCpv = 0 ; for(iCpv = fCpvFirst; iCpv < fCpvLast;iCpv++ ) { - cpv = (AliPHOSRecPoint *) fCpvRecPoints->At(iCpv) ; + cpv = (AliPHOSRecPoint *) cpvRecPoints->At(iCpv) ; Float_t r = GetDistanceInPHOSPlane(emcclu, cpv, toofar) ; if(toofar) @@ -287,6 +298,11 @@ void AliPHOSTrackSegmentMakerv1::MakePairs() // unassigned RecParticles. We assign these RecPoints to TrackSegment and // remove them from the list of "unassigned". + AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ; + TObjArray * emcRecPoints = gime->EmcRecPoints() ; + TObjArray * cpvRecPoints = gime->CpvRecPoints() ; + TClonesArray * trackSegments = gime->TrackSegments() ; + //Make arrays to mark clusters already chousen Int_t * emcExist = 0; if(fEmcLast > fEmcFirst) @@ -322,11 +338,11 @@ void AliPHOSTrackSegmentMakerv1::MakePairs() if( (emcExist[linkLow->GetEmc()-fEmcFirst]> 0) && ppsdExist[linkLow->GetPpsd()-fPpsdFirst] ){ // RecPoints not removed yet - new ((*fTrackSegments)[fNTrackSegments]) AliPHOSTrackSegment((AliPHOSEmcRecPoint *) fEmcRecPoints->At(linkLow->GetEmc()), + new ((*trackSegments)[fNTrackSegments]) AliPHOSTrackSegment((AliPHOSEmcRecPoint *) emcRecPoints->At(linkLow->GetEmc()), nullpointer, - (AliPHOSRecPoint *)fCpvRecPoints->At(linkLow->GetPpsd()) ) ; + (AliPHOSRecPoint *)cpvRecPoints->At(linkLow->GetPpsd()) ) ; - ((AliPHOSTrackSegment* )fTrackSegments->At(fNTrackSegments))->SetIndexInList(fNTrackSegments); + ((AliPHOSTrackSegment* )trackSegments->At(fNTrackSegments))->SetIndexInList(fNTrackSegments); //replace index of emc to negative and shifted index of TS emcExist[linkLow->GetEmc()-fEmcFirst] = -2 - fNTrackSegments ; //mark ppsd as used @@ -343,14 +359,14 @@ void AliPHOSTrackSegmentMakerv1::MakePairs() if(emcExist[linkUp->GetEmc()-fEmcFirst] > 0){ //without ppsd Low => create new TS - new ((* fTrackSegments)[fNTrackSegments]) AliPHOSTrackSegment((AliPHOSEmcRecPoint *) fEmcRecPoints->At(linkUp->GetEmc()) , - (AliPHOSRecPoint *)fCpvRecPoints->At(linkUp->GetPpsd()), + new ((* trackSegments)[fNTrackSegments]) AliPHOSTrackSegment((AliPHOSEmcRecPoint *) emcRecPoints->At(linkUp->GetEmc()) , + (AliPHOSRecPoint *)cpvRecPoints->At(linkUp->GetPpsd()), nullpointer) ; - ((AliPHOSTrackSegment *) fTrackSegments->At(fNTrackSegments))->SetIndexInList(fNTrackSegments); + ((AliPHOSTrackSegment *) trackSegments->At(fNTrackSegments))->SetIndexInList(fNTrackSegments); fNTrackSegments++ ; } else{ // append ppsd Up to existing TS - ((AliPHOSTrackSegment *)fTrackSegments->At(-2-emcExist[linkUp->GetEmc()-fEmcFirst]))->SetCpvRecPoint((AliPHOSCpvRecPoint *)fCpvRecPoints->At(linkUp->GetPpsd())); + ((AliPHOSTrackSegment *)trackSegments->At(-2-emcExist[linkUp->GetEmc()-fEmcFirst]))->SetCpvRecPoint((AliPHOSCpvRecPoint *)cpvRecPoints->At(linkUp->GetPpsd())); } emcExist[linkUp->GetEmc()-fEmcFirst] = -1 ; //Mark emc that Cpv was found @@ -365,10 +381,10 @@ void AliPHOSTrackSegmentMakerv1::MakePairs() Int_t iEmcRP ; for(iEmcRP = 0; iEmcRP < fEmcLast-fEmcFirst ; iEmcRP++ ){ if(emcExist[iEmcRP] > 0 ){ - new ((*fTrackSegments)[fNTrackSegments]) AliPHOSTrackSegment((AliPHOSEmcRecPoint *)fEmcRecPoints->At(iEmcRP+fEmcFirst), + new ((*trackSegments)[fNTrackSegments]) AliPHOSTrackSegment((AliPHOSEmcRecPoint *)emcRecPoints->At(iEmcRP+fEmcFirst), nullpointer, nullpointer ) ; - ((AliPHOSTrackSegment *) fTrackSegments->At(fNTrackSegments))->SetIndexInList(fNTrackSegments); + ((AliPHOSTrackSegment *) trackSegments->At(fNTrackSegments))->SetIndexInList(fNTrackSegments); fNTrackSegments++; } } @@ -381,18 +397,49 @@ void AliPHOSTrackSegmentMakerv1::Exec(Option_t * option) { // STEERing method - if(! fIsInitialized) Init() ; + if( strcmp(GetName(), "")== 0 ) + Init() ; if(strstr(option,"tim")) - gBenchmark->Start("PHOSTSMaker"); + gBenchmark->Start("PHOSTrackSegmentMakerv1"); + + if(strstr(option,"print")) { + Print("") ; + return ; + } - Int_t nEvents = (Int_t) gAlice->TreeE()->GetEntries() ; + //check, if the branch with name of this" already exits? + TObjArray * lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ; + TIter next(lob) ; + TBranch * branch = 0 ; + Bool_t phostsfound = kFALSE, tracksegmentmakerfound = kFALSE ; - for(fEvent = 0;fEvent< nEvents; fEvent++){ - if(!ReadRecPoints()) //reads RecPoints for event fEvent + TString taskName(GetName()) ; + taskName.ReplaceAll(Version(), "") ; + + while ( (branch = (TBranch*)next()) && (!phostsfound || !tracksegmentmakerfound) ) { + if ( (strcmp(branch->GetName(), "PHOSTS")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) + phostsfound = kTRUE ; + + else if ( (strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) + tracksegmentmakerfound = kTRUE ; + } + + if ( phostsfound || tracksegmentmakerfound ) { + cerr << "WARNING: AliPHOSTrackSegmentMakerv1::Exec -> TrackSegments and/or TrackSegmentMaker branch with name " + << taskName.Data() << " already exits" << endl ; + return ; + } + + const AliPHOSGeometry * geom = AliPHOSGetter::GetInstance()->PHOSGeometry() ; + Int_t nevents = (Int_t) gAlice->TreeE()->GetEntries() ; + Int_t ievent ; + + for(ievent = 0; ievent < nevents; ievent++){ + if(!ReadRecPoints(ievent)) //reads RecPoints for event ievent return; - for(fModule = 1; fModule <= fGeom->GetNModules() ; fModule++ ){ + for(fModule = 1; fModule <= geom->GetNModules() ; fModule++ ){ FillOneModule() ; @@ -402,32 +449,34 @@ void AliPHOSTrackSegmentMakerv1::Exec(Option_t * option) } - WriteTrackSegments() ; + WriteTrackSegments(ievent) ; + if(strstr(option,"deb")) PrintTrackSegments(option) ; + } if(strstr(option,"tim")){ gBenchmark->Stop("PHOSTSMaker"); cout << "AliPHOSTSMaker:" << endl ; cout << " took " << gBenchmark->GetCpuTime("PHOSTSMaker") << " seconds for making TS " - << gBenchmark->GetCpuTime("PHOSTSMaker")/nEvents << " seconds per event " << endl ; + << gBenchmark->GetCpuTime("PHOSTSMaker")/nevents << " seconds per event " << endl ; cout << endl ; } - - + } + //____________________________________________________________________________ void AliPHOSTrackSegmentMakerv1::Print(Option_t * option)const { // Print TrackSegmentMaker parameters - if(fIsInitialized){ + if( strcmp(GetName(), "") != 0 ) { cout << "======== AliPHOSTrackSegmentMakerv1 ========" << endl ; cout << "Making Track segments "<< endl ; cout << " Headers file: " << fHeaderFileName.Data() << endl ; cout << " RecPoints branch file name: " << fRecPointsBranchTitle.Data() << endl ; - cout << " TrackSegments Branch file name: " << fTSBranchTitle.Data() << endl ; + cout << " TrackSegments Branch file name: " << fTrackSegmentsBranchTitle.Data() << endl ; cout << "with parameters: " << endl ; cout << " Maximal EMC - CPV (PPSD) distance (cm)" << fR0 << endl ; cout << "============================================" << endl ; @@ -436,16 +485,14 @@ void AliPHOSTrackSegmentMakerv1::Print(Option_t * option)const cout << "AliPHOSTrackSegmentMakerv1 not initialized " << endl ; } //____________________________________________________________________________ -Bool_t AliPHOSTrackSegmentMakerv1::ReadRecPoints() +Bool_t AliPHOSTrackSegmentMakerv1::ReadRecPoints(Int_t event) { - // Reads Emc and CPV recPoints with given title (fRecPointsBranchTitle) + // Reads Emc and CPV recPoints // made previously with Clusterizer. //Make some initializations - fEmcRecPoints->Clear() ; - fCpvRecPoints->Clear() ; - fTrackSegments->Clear() ; + fNTrackSegments = 0 ; fEmcFirst = 0 ; fEmcLast = 0 ; @@ -455,75 +502,77 @@ Bool_t AliPHOSTrackSegmentMakerv1::ReadRecPoints() fPpsdLast = 0 ; - gAlice->GetEvent(fEvent) ; + gAlice->GetEvent(event) ; + gAlice->SetEvent(event) ; // Get TreeR header from file if(gAlice->TreeR()==0){ - char treeName[20]; - sprintf(treeName,"TreeR%d",fEvent); - cout << "Error in AliPHOSTrackSegmentMakerv1 : no "< There is no Reconstruction Tree" << endl; + return kFALSE; } - //Find RecPoints with title fRecPointsBranchTitle - TBranch * emcBranch = 0; - TBranch * cpvBranch = 0; - TBranch * clusterizerBranch = 0; - - TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ; - Int_t ibranch; - Bool_t emcNotFound = kTRUE ; - Bool_t cpvNotFound = kTRUE ; - Bool_t clusterizerNotFound = kTRUE ; + // Find RecPoints + TBranch * emcbranch = 0; + TBranch * cpvbranch = 0; + TBranch * clusterizerbranch = 0; + TObjArray * lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ; + TIter next(lob) ; + TBranch * branch = 0 ; + Bool_t phosemcfound = kFALSE, phoscpvfound = kFALSE, clusterizerfound = kFALSE ; - for(ibranch = 0;ibranch GetEntries();ibranch++){ + TString taskName(GetName()) ; + taskName.ReplaceAll(Version(), "") ; - if(emcNotFound){ - emcBranch=(TBranch *) branches->At(ibranch) ; - if( fRecPointsBranchTitle.CompareTo(emcBranch->GetTitle())==0 ) - if( strcmp(emcBranch->GetName(),"PHOSEmcRP") == 0) { - emcNotFound = kFALSE ; - } + while ( (branch = (TBranch*)next()) && (!phosemcfound || !phoscpvfound || !clusterizerfound) ) { + if ( (strcmp(branch->GetName(), "PHOSEmcRP")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) { + phosemcfound = kTRUE ; + emcbranch = branch ; } - if(cpvNotFound){ - cpvBranch=(TBranch *) branches->At(ibranch) ; - if( fRecPointsBranchTitle.CompareTo(cpvBranch->GetTitle())==0 ) - if( strcmp(cpvBranch->GetName(),"PHOSCpvRP") == 0) - cpvNotFound = kFALSE ; - } - - if(clusterizerNotFound){ - clusterizerBranch = (TBranch *) branches->At(ibranch) ; - if( fRecPointsBranchTitle.CompareTo(clusterizerBranch->GetTitle()) == 0) - if( strcmp(clusterizerBranch->GetName(),"AliPHOSClusterizer") == 0) - clusterizerNotFound = kFALSE ; + else if ( (strcmp(branch->GetName(), "PHOSCpvRP")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) { + phoscpvfound = kTRUE ; + cpvbranch = branch ; + + } else if ( (strcmp(branch->GetName(), "AliPHOSClusterizer")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) { + clusterizerfound = kTRUE ; + clusterizerbranch = branch ; } - } + if ( !phosemcfound || !phoscpvfound || !clusterizerfound ) { + cerr << "WARNING: AliPHOSTrackSegmentMakerv1::ReadRecPoints -> emc(cpv)RecPoints and/or Clusterizer branch with name " << taskName.Data() + << " not found" << endl ; + return kFALSE ; + } - if(clusterizerNotFound || emcNotFound || cpvNotFound){ - cout << "AliPHOSTrackSegmentMakerv1: " << endl ; - cout << " Can't find Branch with RecPoints or Clusterizer " ; - cout << " Do nothing" <SetAddress(&fEmcRecPoints) ; - cpvBranch->SetAddress(&fCpvRecPoints) ; - clusterizerBranch->SetAddress(&fClusterizer) ; + TObjArray * emcRecPoints = gime->EmcRecPoints() ; + emcRecPoints->Clear() ; + emcbranch->SetAddress(&emcRecPoints) ; - emcBranch->GetEntry(0) ; - cpvBranch->GetEntry(0) ; - clusterizerBranch->GetEntry(0) ; + TObjArray * cpvRecPoints = gime->CpvRecPoints() ; + cpvRecPoints->Clear() ; + cpvbranch->SetAddress(&cpvRecPoints) ; + + + AliPHOSClusterizer * clusterizer = 0 ; + clusterizerbranch->SetAddress(&clusterizer) ; + clusterizerbranch->GetEntry(0) ; + TString clusterizerName( fTrackSegmentsBranchTitle ) ; + clusterizerName.Append(clusterizer->Version()) ; + clusterizer = gime->Clusterizer(clusterizerName) ; + + emcbranch->GetEntry(0) ; + cpvbranch->GetEntry(0) ; + clusterizerbranch->GetEntry(0) ; return kTRUE ; } + //____________________________________________________________________________ -void AliPHOSTrackSegmentMakerv1::WriteTrackSegments() +void AliPHOSTrackSegmentMakerv1::WriteTrackSegments(Int_t event) { // Writes found TrackSegments to TreeR. Creates branches // "PHOSTS" and "AliPHOSTrackSegmentMaker" with the same title. @@ -533,37 +582,10 @@ void AliPHOSTrackSegmentMakerv1::WriteTrackSegments() // first we check, if branches with the same title already exist. // If yes - exits without writing. - //First, check, if branches already exist - TBranch * tsMakerBranch = 0; - TBranch * tsBranch = 0; - - TObjArray * branches = gAlice->TreeR()->GetListOfBranches() ; - Int_t ibranch; - Bool_t tsMakerNotFound = kTRUE ; - Bool_t tsNotFound = kTRUE ; - - for(ibranch = 0;(ibranch GetEntries())&&(tsMakerNotFound||tsNotFound);ibranch++){ - if(tsMakerNotFound){ - tsMakerBranch=(TBranch *) branches->At(ibranch) ; - if( (strcmp(tsMakerBranch->GetName(),"AliPHOSTrackSegmentMaker") == 0) && - (fTSBranchTitle.CompareTo( tsMakerBranch->GetTitle())==0 )) - tsMakerNotFound = kFALSE ; - } - if(tsNotFound){ - tsBranch=(TBranch *) branches->At(ibranch) ; - if( (strcmp(tsBranch->GetName(),"PHOSTS") == 0) && - (fTSBranchTitle.CompareTo( tsBranch->GetTitle())==0 )) - tsNotFound = kFALSE ; - } - } + AliPHOSGetter *gime = AliPHOSGetter::GetInstance() ; + TClonesArray * trackSegments = gime->TrackSegments() ; - if(!(tsMakerNotFound && tsNotFound )){ - cout << "AliPHOSTrackSegmentMakerv1 error:"<< endl ; - cout << " Branches PHOSTS and AliPHOSTrackSegementMaker " << endl ; - cout << " with title '"<GetEvent(event) ; //Make branch in TreeR for TrackSegments char * filename = 0; @@ -576,8 +598,8 @@ void AliPHOSTrackSegmentMakerv1::WriteTrackSegments() //First TS Int_t bufferSize = 32000 ; - tsBranch = gAlice->TreeR()->Branch("PHOSTS",&fTrackSegments,bufferSize); - tsBranch->SetTitle(fTSBranchTitle.Data()); + TBranch * tsBranch = gAlice->TreeR()->Branch("PHOSTS",&trackSegments,bufferSize); + tsBranch->SetTitle(fTrackSegmentsBranchTitle.Data()); if (filename) { tsBranch->SetFile(filename); TIter next( tsBranch->GetListOfBranches()); @@ -591,9 +613,9 @@ void AliPHOSTrackSegmentMakerv1::WriteTrackSegments() //Second -TSMaker Int_t splitlevel = 0 ; AliPHOSTrackSegmentMakerv1 * ts = this ; - tsMakerBranch = gAlice->TreeR()->Branch("AliPHOSTrackSegmentMaker","AliPHOSTrackSegmentMakerv1", + TBranch * tsMakerBranch = gAlice->TreeR()->Branch("AliPHOSTrackSegmentMaker","AliPHOSTrackSegmentMakerv1", &ts,bufferSize,splitlevel); - tsMakerBranch->SetTitle(fTSBranchTitle.Data()); + tsMakerBranch->SetTitle(fTrackSegmentsBranchTitle.Data()); if (filename) { tsMakerBranch->SetFile(filename); TIter next( tsMakerBranch->GetListOfBranches()); @@ -618,16 +640,17 @@ void AliPHOSTrackSegmentMakerv1::PrintTrackSegments(Option_t * option) // option deb - prints # of found TrackSegments // option deb all - prints as well indexed of found RecParticles assigned to the TS + TClonesArray * trackSegments = AliPHOSGetter::GetInstance()->TrackSegments() ; cout << "AliPHOSTrackSegmentMakerv1: " << endl ; - cout << " Found " << fTrackSegments->GetEntriesFast() << " trackSegments " << endl ; + cout << " Found " << trackSegments->GetEntriesFast() << " trackSegments " << endl ; if(strstr(option,"all")) { // printing found TS cout << "TrackSegment # " << " EMC RP# " << " CPV RP# " << " PPSD RP#" << endl ; Int_t index; - for (index = 0 ; index GetEntriesFast() ; index++) { - AliPHOSTrackSegment * ts = (AliPHOSTrackSegment * )fTrackSegments->At(index) ; + for (index = 0 ; index GetEntriesFast() ; index++) { + AliPHOSTrackSegment * ts = (AliPHOSTrackSegment * )trackSegments->At(index) ; cout<<" "<< setw(4) << ts->GetIndexInList() << " " <GetEmcIndex()<< " " <GetCpvIndex()<< " " diff --git a/PHOS/AliPHOSTrackSegmentMakerv1.h b/PHOS/AliPHOSTrackSegmentMakerv1.h index 0d99a01a09d..348f05da447 100644 --- a/PHOS/AliPHOSTrackSegmentMakerv1.h +++ b/PHOS/AliPHOSTrackSegmentMakerv1.h @@ -28,7 +28,7 @@ class AliPHOSTrackSegmentMakerv1 : public AliPHOSTrackSegmentMaker { public: AliPHOSTrackSegmentMakerv1() ; - AliPHOSTrackSegmentMakerv1(const char* headerFile,const char* branchTitle = 0) ; + AliPHOSTrackSegmentMakerv1(const char* headerFile, const char* name = 0) ; AliPHOSTrackSegmentMakerv1(const AliPHOSTrackSegmentMakerv1 & tsm) { // cpy ctor: no implementation yet // requested by the Coding Convention @@ -38,7 +38,7 @@ public: virtual ~ AliPHOSTrackSegmentMakerv1() ; // dtor virtual char* GetRecPointsBranch (void)const{return (char*)fRecPointsBranchTitle.Data() ;} - virtual char* GetTrackSegmentsBranch(void)const{return (char*)fTSBranchTitle.Data() ;} + virtual char* GetTrackSegmentsBranch(void)const{return (char*)fTrackSegmentsBranchTitle.Data() ;} virtual void Exec(Option_t * option) ; void FillOneModule() ; // Finds range in which RecPoints belonging current PHOS module are @@ -46,11 +46,10 @@ public: void MakeLinks() const; //Evaluates distances(links) between EMC and PPSD void MakePairs() ; //Finds pairs(triplets) with smallest link virtual void Print(Option_t * option) const ; - virtual Bool_t ReadRecPoints() ; virtual void SetMaxEmcPpsdDistance(Float_t r){ fR0 = r ;} virtual void SetRecPointsBranch(const char * title) { fRecPointsBranchTitle = title ;} - virtual void SetTrackSegmentsBranch(const char * title){ fTSBranchTitle = title ; } - virtual void WriteTrackSegments() ; + virtual void SetTrackSegmentsBranch(const char * title){ fTrackSegmentsBranchTitle = title ; } + virtual const char * Version() const { return "tsm-v1" ; } AliPHOSTrackSegmentMakerv1 & operator = (const AliPHOSTrackSegmentMakerv1 & ) { // assignement operator requested by coding convention but not needed @@ -58,26 +57,20 @@ public: return *this ; } + private: Float_t GetDistanceInPHOSPlane(AliPHOSEmcRecPoint * EmcClu , AliPHOSRecPoint * Ppsd , Bool_t & TooFar )const ; // see R0 void Init() ; void PrintTrackSegments(Option_t *option) ; + virtual Bool_t ReadRecPoints(Int_t event) ; + virtual void WriteTrackSegments(Int_t event) ; private: TString fHeaderFileName ; // name of the file which contains gAlice, Tree headers etc. TString fRecPointsBranchTitle ; // name of the file, where RecPoints branchs are stored - TString fTSBranchTitle ; // name of the file, where TrackSegment branchs is stored - AliPHOSClusterizer * fClusterizer ; // ! - Int_t fNTrackSegments ; // number of track segments found - AliPHOSGeometry * fGeom ; //! pointer to PHOS geometry - Int_t fEvent ; // ! event being precessed - TObjArray * fEmcRecPoints ; // ! List of EMC Rec Points - TObjArray * fCpvRecPoints ; // ! List of CPV/PPSD recPoints - TClonesArray * fTrackSegments; // ! list of final track segments - - - Bool_t fIsInitialized ; // kTRUE if track segment maker is initialized + TString fTrackSegmentsBranchTitle ; // name of the file, where TrackSegment branchs is stored + Int_t fNTrackSegments ; // number of track segments found Float_t fR0 ; // Maximum distance between a EMC RecPoint and a PPSD RecPoint diff --git a/PHOS/AliPHOSv0.cxx b/PHOS/AliPHOSv0.cxx index 901523b0256..e711f6fa1a3 100644 --- a/PHOS/AliPHOSv0.cxx +++ b/PHOS/AliPHOSv0.cxx @@ -12,9 +12,9 @@ * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ - /* $Id$ */ + //_________________________________________________________________________ // Implementation version v0 of PHOS Manager class // Layout EMC + PPSD has name GPS2 @@ -33,6 +33,7 @@ #include "TGeometry.h" #include "TFolder.h" #include "TROOT.h" +#include "TTree.h" // --- Standard library --- @@ -49,6 +50,7 @@ #include "AliConst.h" #include "AliMC.h" #include "AliPHOSGeometry.h" +#include "AliPHOSGetter.h" ClassImp(AliPHOSv0) @@ -62,10 +64,8 @@ AliPHOSv0::AliPHOSv0(const char *name, const char *title): // MIXT = 4 modules (EMC + CPV) and 1 module (EMC + PPSD) // create the geometry parameters object - // it will posted to a folder - - if (strcmp(GetTitle(),"") != 0 ) - fGeom = AliPHOSGeometry::GetInstance(GetTitle(), "") ; + // and post it to a folder (Post retrieves the correct geometry) + AliPHOSGetter::GetInstance(gDirectory->GetName(), 0)->Post(gDirectory->GetName(), "G") ; } @@ -443,32 +443,42 @@ void AliPHOSv0:: BuildGeometryforPPSD(void) // inside bottom micromegas micro2node->cd() ; // a. top lid + y = ( geom->GetMicromegas2Thickness() - geom->GetLidThickness() ) / 2. ; sprintf(nodename, "%s%d%d%d", "Lidb", i, iphi, iz) ; + TNode * toplidbnode = new TNode(nodename, nodename, "TopLid", 0, y, 0) ; toplidbnode->SetLineColor(kColorPPSD) ; fNodes->Add(toplidbnode) ; // b. composite panel + y = y - geom->GetLidThickness() / 2. - geom->GetCompositeThickness() / 2. ; sprintf(nodename, "%s%d%d%d", "CompUb", i, iphi, iz) ; + TNode * compupbnode = new TNode(nodename, nodename, "TopPanel", 0, y, 0) ; compupbnode->SetLineColor(kColorPPSD) ; fNodes->Add(compupbnode) ; // c. anode + y = y - geom->GetCompositeThickness() / 2. - geom->GetAnodeThickness() / 2. ; sprintf(nodename, "%s%d%d%d", "Anob", i, iphi, iz) ; + TNode * anodebnode = new TNode(nodename, nodename, "Anode", 0, y, 0) ; anodebnode->SetLineColor(kColorPPSD) ; fNodes->Add(anodebnode) ; // d. conversion gas + y = y - geom->GetAnodeThickness() / 2. - ( geom->GetConversionGap() + geom->GetAvalancheGap() ) / 2. ; sprintf(nodename, "%s%d%d%d", "GGapb", i, iphi, iz) ; + TNode * ggapbnode = new TNode(nodename, nodename, "GasGap", 0, y, 0) ; ggapbnode->SetLineColor(kColorGas) ; fNodes->Add(ggapbnode) ; // f. cathode + y = y - ( geom->GetConversionGap() + geom->GetAvalancheGap() ) / 2. - geom->GetCathodeThickness() / 2. ; sprintf(nodename, "%s%d%d%d", "Cathodeb", i, iphi, iz) ; + TNode * cathodebnode = new TNode(nodename, nodename, "Cathode", 0, y, 0) ; cathodebnode->SetLineColor(kColorPPSD) ; fNodes->Add(cathodebnode) ; @@ -1518,3 +1528,4 @@ void AliPHOSv0::Init(void) } } + diff --git a/PHOS/AliPHOSv1.cxx b/PHOS/AliPHOSv1.cxx index c5a1d983434..a7e6e69caec 100644 --- a/PHOS/AliPHOSv1.cxx +++ b/PHOS/AliPHOSv1.cxx @@ -127,6 +127,7 @@ AliPHOSv1::AliPHOSv1(const char *name, const char *title): ((AliPHOSQAIntCheckable*)(*fQAHitsMulB)[i])->AddChecker(bhmc) ; ((AliPHOSQAFloatCheckable*)(*fQATotEnerB)[i])->AddChecker(bemc) ; } + } //____________________________________________________________________________ @@ -139,6 +140,8 @@ AliPHOSv1::~AliPHOSv1() delete fHits ; fHits = 0 ; } + if (fTreeQA) + delete fTreeQA ; } //____________________________________________________________________________ @@ -236,6 +239,7 @@ void AliPHOSv1::FinishEvent() //____________________________________________________________________________ void AliPHOSv1::StepManager(void) { + // Accumulates hits as long as the track stays in a single crystal or PPSD gas Cell Int_t relid[4] ; // (box, layer, row, column) indices diff --git a/PHOS/AliPHOSv4.cxx b/PHOS/AliPHOSv4.cxx index cac1555d7d7..4e47582eff9 100644 --- a/PHOS/AliPHOSv4.cxx +++ b/PHOS/AliPHOSv4.cxx @@ -41,6 +41,7 @@ #include "AliPHOSFastRecParticle.h" #include "AliPHOSGeometry.h" #include "AliPHOSv4.h" +#include "AliPHOSGetter.h" #include "AliRun.h" #include "AliConst.h" #include "AliMC.h" @@ -74,10 +75,10 @@ AliPHOSv4::AliPHOSv4(const char *name, const char *title): { // ctor - // gets an instance of the geometry parameters class - if (strcmp(GetTitle(),"") != 0 ) - fGeom = AliPHOSGeometry::GetInstance(GetTitle(), "") ; - + + // create the geometry parameters object + // and post it to a folder (Post retrieves the correct geometry) + AliPHOSGetter::GetInstance(gDirectory->GetName(), 0)->Post(gDirectory->GetName(), "G") ; SetBigBox(0, GetGeometry()->GetOuterBoxSize(0) ) ; SetBigBox(1, GetGeometry()->GetOuterBoxSize(1) + GetGeometry()->GetCPVBoxSize(1) ) ; -- 2.43.0