From e5373622abd054da821f82817f0ff302d8597d2b Mon Sep 17 00:00:00 2001 From: shahoian Date: Mon, 6 Aug 2012 22:50:01 +0000 Subject: [PATCH] Segmentation can be stored/retreaved from file (in Config.C...) --- ITS/UPGRADE/AliITSsegmentationPixUpg.cxx | 75 +++++++++++++++++++++++- ITS/UPGRADE/AliITSsegmentationPixUpg.h | 8 ++- ITS/UPGRADE/CMakelibITSUpgradeBase.pkg | 1 + ITS/UPGRADE/ITSUpgradeBaseLinkDef.h | 1 + 4 files changed, 82 insertions(+), 3 deletions(-) diff --git a/ITS/UPGRADE/AliITSsegmentationPixUpg.cxx b/ITS/UPGRADE/AliITSsegmentationPixUpg.cxx index 71f2265b038..d7b163a3257 100644 --- a/ITS/UPGRADE/AliITSsegmentationPixUpg.cxx +++ b/ITS/UPGRADE/AliITSsegmentationPixUpg.cxx @@ -17,6 +17,10 @@ #include #include #include +#include +#include +#include +#include #include "AliITSsegmentationPixUpg.h" //////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -31,11 +35,13 @@ ClassImp(AliITSsegmentationPixUpg) +const char* AliITSsegmentationPixUpg::fgkSegmListName = "ITSUpgradeSegmentations"; + //_____________________________________________________________________________RS AliITSsegmentationPixUpg::AliITSsegmentationPixUpg(int nchips,int ncol,int nrow, double pitchX,double pitchZ, - double pitchLftC,double pitchRgtC, double thickness, + double pitchLftC,double pitchRgtC, double edgL,double edgR,double edgT,double edgB) : AliITSsegmentation() ,fGuardLft(edgL) @@ -370,3 +376,70 @@ void AliITSsegmentationPixUpg::Init() { // init settings } + +//______________________________________________________________________ +Bool_t AliITSsegmentationPixUpg::StoreWithID(UInt_t id, const char* outf) +{ + // store in the special list under given ID + TString fns = outf; + gSystem->ExpandPathName(fns); + if (fns.IsNull()) {AliFatal("No file name provided"); return kFALSE;} + TFile* fout = TFile::Open(fns.Data(),"update"); + if (!fout) {AliFatal(Form("Failed to open output file %s",outf)); return kFALSE;} + TObjArray* arr = (TObjArray*)fout->Get(fgkSegmListName); + if (!arr) arr = new TObjArray(); + else { + int nent = arr->GetEntriesFast(); + for (int i=nent;i--;) { + AliITSsegmentationPixUpg* segm = dynamic_cast(arr->At(i)); + if (segm && segm->GetUniqueID()==id) { + AliFatal(Form("Segmenation %d already exists in file %s",id,outf)); + return kFALSE; + } + } + } + // + this->SetUniqueID(id); + arr->AddLast(this); + arr->SetOwner(kTRUE); + fout->WriteObject(arr,fgkSegmListName,"kSingleKey"); + fout->Close(); + delete fout; + arr->Remove(this); + delete arr; + AliInfo(Form("Stored segmentation %d in %s",id,outf)); + return kTRUE; + // +} + +//______________________________________________________________________ +AliITSsegmentationPixUpg* AliITSsegmentationPixUpg::LoadWithID(UInt_t id, const char* inpf) +{ + // store in the special list under given ID + TString fns = inpf; + gSystem->ExpandPathName(fns); + if (fns.IsNull()) {AliFatalGeneral("LoadWithID","No file name provided"); return 0;} + TFile* finp = TFile::Open(fns.Data()); + if (!finp) {AliFatalGeneral("LoadWithID",Form("Failed to open file %s",inpf)); return 0;} + TObjArray* arr = (TObjArray*)finp->Get(fgkSegmListName); + if (!arr) { + AliFatalGeneral("LoadWithID",Form("Failed to find segmenation array %s in %s",fgkSegmListName,inpf)); + return 0; + } + AliITSsegmentationPixUpg* segm = 0; + int nent = arr->GetEntriesFast(); + for (int i=nent;i--;) { + segm = dynamic_cast(arr->At(i)); + if (segm && segm->GetUniqueID()==id) {arr->RemoveAt(i); break;} + segm = 0; + } + // + if (!segm) {AliFatalGeneral("LoadWithID",Form("Failed to find segmenation %d in %s",id,inpf)); return 0;} + // + arr->SetOwner(kTRUE); // to not leave in memory other segmenations + finp->Close(); + delete finp; + delete arr; + // + return segm; +} diff --git a/ITS/UPGRADE/AliITSsegmentationPixUpg.h b/ITS/UPGRADE/AliITSsegmentationPixUpg.h index 36451a42820..030be26ead1 100644 --- a/ITS/UPGRADE/AliITSsegmentationPixUpg.h +++ b/ITS/UPGRADE/AliITSsegmentationPixUpg.h @@ -13,8 +13,8 @@ public AliITSsegmentation { enum {kCM2MC=10000}; AliITSsegmentationPixUpg(int nchips=0,int ncol=0,int nrow=0, double pitchX=0,double pitchZ=0, - double pitchLftC=-1,double pitchRgtC=-1, double thickness=0, + double pitchLftC=-1,double pitchRgtC=-1, double edgL=0,double edgR=0,double edgT=0,double edgB=0); // AliITSsegmentationPixUpg(Option_t *opt="" ); @@ -56,6 +56,9 @@ public AliITSsegmentation { // virtual void PrintDefaultParameters() const {AliWarning("No def. parameters defined as const static data members");} // + Bool_t StoreWithID(UInt_t id, const char* outf); + static AliITSsegmentationPixUpg* LoadWithID(UInt_t id, const char* inpf); + // protected: Float_t Z2Col(Float_t z) const; Float_t Col2Z(Int_t col) const; @@ -75,7 +78,8 @@ public AliITSsegmentation { Int_t fNRow; // number of rows Int_t fNCol; // number of columns (total) // - + static const char* fgkSegmListName; // pattern for segmentations list name + // ClassDef(AliITSsegmentationPixUpg,1) //Segmentation class upgrade pixels }; diff --git a/ITS/UPGRADE/CMakelibITSUpgradeBase.pkg b/ITS/UPGRADE/CMakelibITSUpgradeBase.pkg index a13bbd66c89..97b72864662 100644 --- a/ITS/UPGRADE/CMakelibITSUpgradeBase.pkg +++ b/ITS/UPGRADE/CMakelibITSUpgradeBase.pkg @@ -34,6 +34,7 @@ AliITSInitGeometryUpg.cxx AliITSLoaderUpg.cxx AliITSgeomTGeoUpg.cxx AliITSCalibrationPixUpg.cxx +AliITSsegmentationPixUpg.cxx ) string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" ) diff --git a/ITS/UPGRADE/ITSUpgradeBaseLinkDef.h b/ITS/UPGRADE/ITSUpgradeBaseLinkDef.h index 0e1420e0b40..83c136d7837 100644 --- a/ITS/UPGRADE/ITSUpgradeBaseLinkDef.h +++ b/ITS/UPGRADE/ITSUpgradeBaseLinkDef.h @@ -19,4 +19,5 @@ #pragma link C++ class AliITSLoaderUpg+; #pragma link C++ class AliITSgeomTGeoUpg+; #pragma link C++ class AliITSCalibrationPixUpg+; +#pragma link C++ class AliITSsegmentationPixUpg+; #endif -- 2.43.0