From 3ebe30ad50da453dc746879a30f1ee4c3c6511e6 Mon Sep 17 00:00:00 2001 From: masera Date: Wed, 13 Feb 2008 10:30:41 +0000 Subject: [PATCH] Plane Efficiency framework upgrade: possibility to create histograms with residuals, etc. (G. Bruno) --- ITS/AliITSPlaneEffSDD.cxx | 535 +++++++++++++++++++++++++++++++++++++- ITS/AliITSPlaneEffSDD.h | 34 ++- ITS/AliITSPlaneEffSPD.cxx | 10 +- ITS/AliITSPlaneEffSPD.h | 11 +- ITS/AliITSPlaneEffSSD.cxx | 297 ++++++++++++++++++++- ITS/AliITSPlaneEffSSD.h | 30 ++- ITS/AliITStrackerMI.cxx | 16 +- 7 files changed, 889 insertions(+), 44 deletions(-) diff --git a/ITS/AliITSPlaneEffSDD.cxx b/ITS/AliITSPlaneEffSDD.cxx index 5f729eeacfb..4377c6c9161 100644 --- a/ITS/AliITSPlaneEffSDD.cxx +++ b/ITS/AliITSPlaneEffSDD.cxx @@ -26,6 +26,10 @@ /* $Id$ */ #include +#include +#include +#include +#include #include "AliITSPlaneEffSDD.h" #include "AliLog.h" #include "AliCDBStorage.h" @@ -39,7 +43,17 @@ ClassImp(AliITSPlaneEffSDD) //______________________________________________________________________ AliITSPlaneEffSDD::AliITSPlaneEffSDD(): - AliITSPlaneEff(){ + AliITSPlaneEff(), + fHisResX(0), + fHisResZ(0), + fHisResXZ(0), + fHisClusterSize(0), + fHisResXclu(0), + fHisResZclu(0), + fProfResXvsX(0), + fProfResZvsX(0), + fProfClustSizeXvsX(0), + fProfClustSizeZvsX(0){ for (UInt_t i=0; iCopy(*fHisResX[i]); + s.fHisResZ[i]->Copy(*fHisResZ[i]); + s.fHisResXZ[i]->Copy(*fHisResXZ[i]); + s.fHisClusterSize[i]->Copy(*fHisClusterSize[i]); + for(Int_t clu=0; clu cluster size 1 + s.fHisResXclu[i][clu]->Copy(*fHisResXclu[i][clu]); + s.fHisResZclu[i][clu]->Copy(*fHisResZclu[i][clu]); + } + s.fProfResXvsX[i]->Copy(*fProfResXvsX[i]); + s.fProfResZvsX[i]->Copy(*fProfResZvsX[i]); + s.fProfClustSizeXvsX[i]->Copy(*fProfClustSizeXvsX[i]); + s.fProfClustSizeZvsX[i]->Copy(*fProfClustSizeZvsX[i]); + } + } } //_________________________________________________________________________ AliITSPlaneEffSDD& AliITSPlaneEffSDD::operator+=(const AliITSPlaneEffSDD &add){ @@ -83,6 +129,22 @@ AliITSPlaneEffSDD& AliITSPlaneEffSDD::operator+=(const AliITSPlaneEffSDD &add){ fFound[i] += add.fFound[i]; fTried[i] += add.fTried[i]; } + if(fHis && add.fHis) { + for(Int_t i=0; iAdd(add.fHisResX[i]); + fHisResZ[i]->Add(add.fHisResZ[i]); + fHisResXZ[i]->Add(add.fHisResXZ[i]); + fHisClusterSize[i]->Add(add.fHisClusterSize[i]); + for(Int_t clu=0; clu cluster size 1 + fHisResXclu[i][clu]->Add(add.fHisResXclu[i][clu]); + fHisResZclu[i][clu]->Add(add.fHisResZclu[i][clu]); + } + fProfResXvsX[i]->Add(add.fProfResXvsX[i]); + fProfResZvsX[i]->Add(add.fProfResZvsX[i]); + fProfClustSizeXvsX[i]->Add(add.fProfClustSizeXvsX[i]); + fProfClustSizeZvsX[i]->Add(add.fProfClustSizeZvsX[i]); + } + } return *this; } //______________________________________________________________________ @@ -98,21 +160,54 @@ AliITSPlaneEffSDD& AliITSPlaneEffSDD::operator=(const if(this==&s) return *this; s.Copy(*this); -// if(&s == this) return *this; -// for (UInt_t i=0; ifFound[i] = s.fFound[i]; -// this->fTried[i] = s.fTried[i]; -// } return *this; } //______________________________________________________________________ void AliITSPlaneEffSDD::Copy(TObject &obj) const { // protected method. copy this to obj AliITSPlaneEff::Copy(obj); + AliITSPlaneEffSDD& target = (AliITSPlaneEffSDD &) obj; for(Int_t i=0;i cluster size 1 + target.fHisResXclu[i][clu] = new TH1F(*fHisResXclu[i][clu]); + target.fHisResZclu[i][clu] = new TH1F(*fHisResZclu[i][clu]); + } + target.fProfResXvsX[i]=new TProfile(*fProfResXvsX[i]); + target.fProfResZvsX[i]=new TProfile(*fProfResZvsX[i]); + target.fProfClustSizeXvsX[i]=new TProfile(*fProfClustSizeXvsX[i]); + target.fProfClustSizeZvsX[i]=new TProfile(*fProfClustSizeZvsX[i]); + } } +return; } //______________________________________________________________________ AliITSPlaneEff& AliITSPlaneEffSDD::operator=(const @@ -394,7 +489,8 @@ if(!fInitCDBCalled) AliCDBEntry *cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSDD",fRunNumber); AliITSPlaneEffSDD* eff= (AliITSPlaneEffSDD*)cdbEntry->GetObject(); if(this==eff) return kFALSE; -eff->Copy(*this); +if(fHis) CopyHistos(*eff); // If histos already exist then copy them to eff +eff->Copy(*this); // copy everything (statistics and histos) from eff to this return kTRUE; } //_____________________________________________________________________________ @@ -582,4 +678,421 @@ xmn=kconv*(kDxDefault-kDxDefault/kNSubWing*(subw+1)); else {AliError("GetBlockBoundaries: you got wrong n. of wing"); return kFALSE;} return kTRUE; } -//________________________________________________________ +//__________________________________________________________ +void AliITSPlaneEffSDD::InitHistos() { + // for the moment let's create the histograms + // module by module + TString histnameResX="HistResX_mod_",aux; + TString histnameResZ="HistResZ_mod_"; + TString histnameResXZ="HistResXZ_mod_"; + TString histnameClusterType="HistClusterType_mod_"; + TString histnameResXclu="HistResX_mod_"; + TString histnameResZclu="HistResZ_mod_"; + TString profnameResXvsX="ProfResXvsX_mod_"; + TString profnameResZvsX="ProfResZvsX_mod_"; + TString profnameClustSizeXvsX="ProfClustSizeXvsX_mod_"; + TString profnameClustSizeZvsX="ProfClustSizeZvsX_mod_"; +// + fHisResX=new TH1F*[kNHisto]; + fHisResZ=new TH1F*[kNHisto]; + fHisResXZ=new TH2F*[kNHisto]; + fHisClusterSize=new TH2I*[kNHisto]; + fHisResXclu=new TH1F**[kNHisto]; + fHisResZclu=new TH1F**[kNHisto]; + fProfResXvsX=new TProfile*[kNHisto]; + fProfResZvsX=new TProfile*[kNHisto]; + fProfClustSizeXvsX=new TProfile*[kNHisto]; + fProfClustSizeZvsX=new TProfile*[kNHisto]; + + for (Int_t nhist=0;nhistSetName(aux.Data()); + fHisResX[nhist]->SetTitle(aux.Data()); + + aux=histnameResZ; + aux+=nhist; + fHisResZ[nhist]=new TH1F("histname","histname",500,-0.05,0.05); // +-500 micron; 1 bin=2 micron + fHisResZ[nhist]->SetName(aux.Data()); + fHisResZ[nhist]->SetTitle(aux.Data()); + + aux=histnameResXZ; + aux+=nhist; + fHisResXZ[nhist]=new TH2F("histname","histname",50,-0.1,0.1,30,-0.03,0.03); // binning: + // 40 micron in x; + // 20 micron in z; + fHisResXZ[nhist]->SetName(aux.Data()); + fHisResXZ[nhist]->SetTitle(aux.Data()); + + aux=histnameClusterType; + aux+=nhist; + fHisClusterSize[nhist]=new TH2I("histname","histname",10,0.5,10.5,10,0.5,10.5); + fHisClusterSize[nhist]->SetName(aux.Data()); + fHisClusterSize[nhist]->SetTitle(aux.Data()); + + fHisResXclu[nhist]=new TH1F*[kNclu]; + fHisResZclu[nhist]=new TH1F*[kNclu]; + for(Int_t clu=0; clu cluster size 1 + aux=histnameResXclu; + aux+=nhist; + aux+="_clu_"; + aux+=clu+1; // clu=0 --> cluster size 1 + fHisResXclu[nhist][clu]=new TH1F("histname","histname",1500,-0.15,0.15);// +- 1500 micron; 1 bin=2 micron + fHisResXclu[nhist][clu]->SetName(aux.Data()); + fHisResXclu[nhist][clu]->SetTitle(aux.Data()); + + aux=histnameResZclu; + aux+=nhist; + aux+="_clu_"; + aux+=clu+1; // clu=0 --> cluster size 1 + fHisResZclu[nhist][clu]=new TH1F("histname","histname",500,-0.05,0.05); // +-500 micron; 1 bin=2 micron + fHisResZclu[nhist][clu]->SetName(aux.Data()); + fHisResZclu[nhist][clu]->SetTitle(aux.Data()); + } + + aux=profnameResXvsX; + aux+=nhist; + fProfResXvsX[nhist]=new TProfile("histname","histname",140,-3.5,-3.5); + fProfResXvsX[nhist]->SetName(aux.Data()); + fProfResXvsX[nhist]->SetTitle(aux.Data()); + + aux=profnameResZvsX; + aux+=nhist; + fProfResZvsX[nhist]=new TProfile("histname","histname",140,-3.5,-3.5); + fProfResZvsX[nhist]->SetName(aux.Data()); + fProfResZvsX[nhist]->SetTitle(aux.Data()); + + aux=profnameClustSizeXvsX; + aux+=nhist; + fProfClustSizeXvsX[nhist]=new TProfile("histname","histname",140,-3.5,-3.5); + fProfClustSizeXvsX[nhist]->SetName(aux.Data()); + fProfClustSizeXvsX[nhist]->SetTitle(aux.Data()); + + aux=profnameClustSizeZvsX; + aux+=nhist; + fProfClustSizeZvsX[nhist]=new TProfile("histname","histname",140,-3.5,-3.5); + fProfClustSizeZvsX[nhist]->SetName(aux.Data()); + fProfClustSizeZvsX[nhist]->SetTitle(aux.Data()); + + } +return; +} +//__________________________________________________________ +void AliITSPlaneEffSDD::DeleteHistos() { + if(fHisResX) { + for (Int_t i=0; i=kNModule*kNChip*kNWing*kNSubWing) + {AliWarning("FillHistos: you asked for a non existing key"); return kFALSE;} + Int_t id=GetModFromKey(key); + if(id>=kNHisto) + {AliWarning("FillHistos: you want to fill a non-existing histos"); return kFALSE;} + if(found) { + Float_t resx=tXZ[0]-cXZ[0]; + Float_t resz=tXZ[1]-cXZ[1]; + fHisResX[id]->Fill(resx); + fHisResZ[id]->Fill(resz); + fHisResXZ[id]->Fill(resx,resz); + fHisClusterSize[id]->Fill((Double_t)ctXZ[0],(Double_t)ctXZ[1]); + if(ctXZ[0]>0 && ctXZ[0]<=kNclu) fHisResXclu[id][ctXZ[0]-1]->Fill(resx); + if(ctXZ[1]>0 && ctXZ[1]<=kNclu) fHisResZclu[id][ctXZ[1]-1]->Fill(resx); + fProfResXvsX[id]->Fill(cXZ[0],resx); + fProfResZvsX[id]->Fill(cXZ[0],resz); + fProfClustSizeXvsX[id]->Fill(cXZ[0],(Double_t)ctXZ[0]); + fProfClustSizeZvsX[id]->Fill(cXZ[0],(Double_t)ctXZ[1]); + } + return kTRUE; +} +//__________________________________________________________ +Bool_t AliITSPlaneEffSDD::WriteHistosToFile(TString filename, Option_t* option) { + // + // Saves the histograms into a tree and saves the trees into a file + // + if (!fHis) return kFALSE; + if (filename.Data()=="") { + AliWarning("WriteHistosToFile: null output filename!"); + return kFALSE; + } + char branchname[30]; + TFile *hFile=new TFile(filename.Data(),option, + "The File containing the TREEs with ITS PlaneEff Histos"); + TTree *SDDTree=new TTree("SDDTree","Tree whith Residuals and Cluster Type distributions for SDD"); + TH1F *histZ,*histX; + TH2F *histXZ; + TH2I *histClusterType; + TH1F *histXclu[kNclu]; + TH1F *histZclu[kNclu]; + TProfile *profileResXvsX, *profileResZvsX, *profileClSizXvsX, *profileClSizZvsX; + + histZ=new TH1F(); + histX=new TH1F(); + histXZ=new TH2F(); + histClusterType=new TH2I(); + for(Int_t clu=0;cluBranch("histX","TH1F",&histX,128000,0); + SDDTree->Branch("histZ","TH1F",&histZ,128000,0); + SDDTree->Branch("histXZ","TH2F",&histXZ,128000,0); + SDDTree->Branch("histClusterType","TH2I",&histClusterType,128000,0); + for(Int_t clu=0;cluBranch(branchname,"TH1F",&histXclu[clu],128000,0); + sprintf(branchname,"histZclu_%d",clu+1); + SDDTree->Branch(branchname,"TH1F",&histZclu[clu],128000,0); + } + SDDTree->Branch("profileResXvsX","TProfile",&profileResXvsX,128000,0); + SDDTree->Branch("profileResZvsX","TProfile",&profileResZvsX,128000,0); + SDDTree->Branch("profileClSizXvsX","TProfile",&profileClSizXvsX,128000,0); + SDDTree->Branch("profileClSizZvsX","TProfile",&profileClSizZvsX,128000,0); + + for(Int_t j=0;jFill(); + } + hFile->Write(); + hFile->Close(); +return kTRUE; +} +//__________________________________________________________ +Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) { + // + // Read histograms from an already existing file + // + if (!fHis) return kFALSE; + if (filename.Data()=="") { + AliWarning("ReadHistosFromFile: incorrect output filename!"); + return kFALSE; + } + char branchname[30]; + + TH1F *h = 0; + TH2F *h2 = 0; + TH2I *h2i= 0; + TProfile *p = 0; + + TFile *file=TFile::Open(filename.Data(),"READONLY"); + + if (!file || file->IsZombie()) { + AliWarning(Form("Can't open %s !",filename.Data())); + delete file; + return kFALSE; + } + TTree *tree = (TTree*) file->Get("SDDTree"); + + TBranch *histX = (TBranch*) tree->GetBranch("histX"); + TBranch *histZ = (TBranch*) tree->GetBranch("histZ"); + TBranch *histXZ = (TBranch*) tree->GetBranch("histXZ"); + TBranch *histClusterType = (TBranch*) tree->GetBranch("histClusterType"); + + TBranch *histXclu[kNclu], *histZclu[kNclu]; + for(Int_t clu=0; cluGetBranch(branchname); + sprintf(branchname,"histZclu_%d",clu+1); + histZclu[clu]= (TBranch*) tree->GetBranch(branchname); + } + TBranch *profileResXvsX = (TBranch*) tree->GetBranch("profileResXvsX"); + TBranch *profileResZvsX = (TBranch*) tree->GetBranch("profileResZvsX"); + TBranch *profileClSizXvsX = (TBranch*) tree->GetBranch("profileClSizXvsX"); + TBranch *profileClSizZvsX = (TBranch*) tree->GetBranch("profileClSizZvsX"); + + gROOT->cd(); + + Int_t nevent = (Int_t)histX->GetEntries(); + if(nevent!=kNHisto) + {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;} + histX->SetAddress(&h); + for(Int_t j=0;jGetEntry(j); + fHisResX[j]->Add(h); + } + + nevent = (Int_t)histZ->GetEntries(); + if(nevent!=kNHisto) + {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;} + histZ->SetAddress(&h); + for(Int_t j=0;jGetEntry(j); + fHisResZ[j]->Add(h); + } + + nevent = (Int_t)histXZ->GetEntries(); + if(nevent!=kNHisto) + {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;} + histXZ->SetAddress(&h2); + for(Int_t j=0;jGetEntry(j); + fHisResXZ[j]->Add(h2); + } + + nevent = (Int_t)histClusterType->GetEntries(); + if(nevent!=kNHisto) + {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;} + histClusterType->SetAddress(&h2i); + for(Int_t j=0;jGetEntry(j); + fHisClusterSize[j]->Add(h2i); + } + + for(Int_t clu=0; cluGetEntries(); + if(nevent!=kNHisto) + {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;} + histXclu[clu]->SetAddress(&h); + for(Int_t j=0;jGetEntry(j); + fHisResXclu[j][clu]->Add(h); + } + + nevent = (Int_t)histZclu[clu]->GetEntries(); + if(nevent!=kNHisto) + {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;} + histZclu[clu]->SetAddress(&h); + for(Int_t j=0;jGetEntry(j); + fHisResZclu[j][clu]->Add(h); + } + } + + nevent = (Int_t)profileResXvsX->GetEntries(); + if(nevent!=kNHisto) + {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;} + profileResXvsX->SetAddress(&p); + for(Int_t j=0;jGetEntry(j); + fProfResXvsX[j]->Add(p); + } + + nevent = (Int_t)profileResZvsX->GetEntries(); + if(nevent!=kNHisto) + {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;} + profileResZvsX->SetAddress(&p); + for(Int_t j=0;jGetEntry(j); + fProfResZvsX[j]->Add(p); + } + + nevent = (Int_t)profileClSizXvsX->GetEntries(); + if(nevent!=kNHisto) + {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;} + profileClSizXvsX->SetAddress(&p); + for(Int_t j=0;jGetEntry(j); + fProfClustSizeXvsX[j]->Add(p); + } + + nevent = (Int_t)profileClSizZvsX->GetEntries(); + if(nevent!=kNHisto) + {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;} + profileClSizZvsX->SetAddress(&p); + for(Int_t j=0;jGetEntry(j); + fProfClustSizeZvsX[j]->Add(p); + } + + delete h; h=0; + delete h2; h2=0; + delete h2i; h2i=0; + delete p; p=0; + + if (file) { + file->Close(); + } +return kTRUE; +} + diff --git a/ITS/AliITSPlaneEffSDD.h b/ITS/AliITSPlaneEffSDD.h index 7256c0fa6bb..7f40df8214a 100644 --- a/ITS/AliITSPlaneEffSDD.h +++ b/ITS/AliITSPlaneEffSDD.h @@ -3,7 +3,8 @@ /* Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. * * See cxx source for full Copyright notice */ - +#include +#include #include "AliITSPlaneEff.h" /////////////////////////////////////////// @@ -51,6 +52,11 @@ class AliITSPlaneEffSDD : public AliITSPlaneEff { // efficiencies due to different drift times. enum {kNAnode = 64}; // Number of channels/chip (i.e. anodes per chip) //enum {kNTimeBin = 174}; // granularity along drift direction (i.e. segmentation in r-phi) + + enum {kNHisto = kNModule}; // The number of histograms: module by module. + enum {kNclu = 3}; // Build specific histos of residuals up to cluster size kNclu. + // If you change them, then you must change implementation of + // the method FillHistos. // // Plane efficiency for active detector (excluding dead/noisy channels) // access to DB is needed @@ -77,14 +83,34 @@ class AliITSPlaneEffSDD : public AliITSPlaneEff { UInt_t Nblock() const; // return the number of basic blocks // compute the geometrical limit of a basic block in detector local coordinate system Bool_t GetBlockBoundaries(const UInt_t key,Float_t& xmn,Float_t& xmx,Float_t& zmn,Float_t& zmx) const; - + // Methods for dealing with auxiliary histograms + // method to set on/off the creation/updates of histograms (Histos are created/destroyed) + void SetCreateHistos(Bool_t his=kFALSE) + {fHis=his; if(fHis) {DeleteHistos(); InitHistos();} else DeleteHistos(); return; } + Bool_t FillHistos(UInt_t key, Bool_t found, Float_t trackXZ[2], Float_t clusterXZ[2], Int_t ctXZ[2]); + Bool_t WriteHistosToFile(TString filename="PlaneEffSDDHistos.root",Option_t* option = "RECREATE"); + Bool_t ReadHistosFromFile(TString filename="PlaneEffSDDHistos.root"); // histos must exist already ! + // This method increases the + // statistics of histos by adding + // those of the input file. protected: virtual void Copy(TObject &obj) const; + void CopyHistos(AliITSPlaneEffSDD& target) const; // copy only histograms to target Int_t GetMissingTracksForGivenEff(Double_t eff, Double_t RelErr, UInt_t im, UInt_t ic, UInt_t iw, UInt_t isw=0) const; // Int_t fFound[kNModule*kNChip*kNWing*kNSubWing]; // number of associated clusters in a given block Int_t fTried[kNModule*kNChip*kNWing*kNSubWing]; // number of tracks used for efficiency evaluation + TH1F **fHisResX; //! histos with residual distribution (track-cluster) along local X (r-phi) + TH1F **fHisResZ; //! histos with residual distribution (track-cluster) along local Z + TH2F **fHisResXZ; //! 2-d histos with residual distribution (track-cluster) along local X and Z + TH2I **fHisClusterSize; //! histos with cluster-size distribution + TH1F ***fHisResXclu; //! histos with residual distribution along local X (r-phi) for cluster type + TH1F ***fHisResZclu; //! histos with residual distribution along local Z for cluster type + TProfile **fProfResXvsX; //! TProfile of X Residuals vs. X (of the cluster) + TProfile **fProfResZvsX; //! TProfile of Z Residuals vs. X (of the cluster) + TProfile **fProfClustSizeXvsX; //! TProfile of cluster_size_X vs. X (of the cluster) + TProfile **fProfClustSizeZvsX; //! TProfile of cluster_size_X vs. X (of the cluster) private: UInt_t GetKey(const UInt_t mod, const UInt_t chip, // unique key to locate the const UInt_t wing, const UInt_t subw=0) const; // basic block of the SDD @@ -106,8 +132,10 @@ class AliITSPlaneEffSDD : public AliITSPlaneEff { void GetAllFromKey(const UInt_t key, UInt_t& mod, UInt_t& chip, UInt_t& wing, UInt_t& subw) const; void GetBadInBlock(const UInt_t key, UInt_t& bad) const; + void InitHistos(); + void DeleteHistos(); - ClassDef(AliITSPlaneEffSDD,1) // SDD Plane Efficiency class + ClassDef(AliITSPlaneEffSDD,2) // SDD Plane Efficiency class }; // inline UInt_t AliITSPlaneEffSDD::Nblock() const {return kNModule*kNChip*kNWing*kNSubWing;} diff --git a/ITS/AliITSPlaneEffSPD.cxx b/ITS/AliITSPlaneEffSPD.cxx index b613aca8473..5bc0cc147f2 100644 --- a/ITS/AliITSPlaneEffSPD.cxx +++ b/ITS/AliITSPlaneEffSPD.cxx @@ -628,19 +628,19 @@ return; void AliITSPlaneEffSPD::DeleteHistos() { if(fHisResX) { for (Int_t i=0; iClose(); } - - fHisResZclu[0][0]->Draw(); return kTRUE; } diff --git a/ITS/AliITSPlaneEffSPD.h b/ITS/AliITSPlaneEffSPD.h index ab1e84b5d8c..b0e37be52b9 100644 --- a/ITS/AliITSPlaneEffSPD.h +++ b/ITS/AliITSPlaneEffSPD.h @@ -79,11 +79,14 @@ class AliITSPlaneEffSPD : public AliITSPlaneEff { // Methods for dealing with auxiliary histograms // method to set on/off the creation/updates of histograms (Histos are created/destroyed) void SetCreateHistos(Bool_t his=kFALSE) - {fHis=his; if(fHis) InitHistos(); else DeleteHistos(); return; } + //{fHis=his; if(fHis) InitHistos(); else DeleteHistos(); return; } + {fHis=his; if(fHis) {DeleteHistos(); InitHistos();} else DeleteHistos(); return; } Bool_t FillHistos(UInt_t key, Bool_t found, Float_t trackXZ[2], Float_t clusterXZ[2], Int_t ctXZ[2]); Bool_t WriteHistosToFile(TString filename="PlaneEffSPDHistos.root",Option_t* option = "RECREATE"); - Bool_t ReadHistosFromFile(TString filename="PlaneEffSPDHistos.root"); - + Bool_t ReadHistosFromFile(TString filename="PlaneEffSPDHistos.root"); // histos must exist already ! + // This method increases the + // statistics of histos by adding + // those of the input file. protected: virtual void Copy(TObject &obj) const; // copy ALL data members to obj // iboth statistics ad histograms) @@ -115,7 +118,7 @@ class AliITSPlaneEffSPD : public AliITSPlaneEff { void InitHistos(); void DeleteHistos(); - ClassDef(AliITSPlaneEffSPD,1) // SPD Plane Efficiency class + ClassDef(AliITSPlaneEffSPD,2) // SPD Plane Efficiency class }; // inline UInt_t AliITSPlaneEffSPD::Nblock() const {return kNModule*kNChip;} diff --git a/ITS/AliITSPlaneEffSSD.cxx b/ITS/AliITSPlaneEffSSD.cxx index a43e10a4e23..50988b0f545 100644 --- a/ITS/AliITSPlaneEffSSD.cxx +++ b/ITS/AliITSPlaneEffSSD.cxx @@ -25,6 +25,10 @@ /* $Id$ */ #include +#include +#include +#include +#include #include "AliITSPlaneEffSSD.h" #include "AliLog.h" #include "AliCDBStorage.h" @@ -36,7 +40,11 @@ ClassImp(AliITSPlaneEffSSD) //______________________________________________________________________ AliITSPlaneEffSSD::AliITSPlaneEffSSD(): - AliITSPlaneEff(){ + AliITSPlaneEff(), + fHisResX(0), + fHisResZ(0), + fHisResXZ(0), + fHisClusterSize(0){ for (UInt_t i=0; iCopy(*fHisResX[i]); + s.fHisResZ[i]->Copy(*fHisResZ[i]); + s.fHisResXZ[i]->Copy(*fHisResXZ[i]); + s.fHisClusterSize[i]->Copy(*fHisClusterSize[i]); + } + } } //_________________________________________________________________________ AliITSPlaneEffSSD& AliITSPlaneEffSSD::operator+=(const AliITSPlaneEffSSD &add){ @@ -79,6 +105,14 @@ AliITSPlaneEffSSD& AliITSPlaneEffSSD::operator+=(const AliITSPlaneEffSSD &add){ fFound[i] += add.fFound[i]; fTried[i] += add.fTried[i]; } + if(fHis && add.fHis) { + for(Int_t i=0; iAdd(add.fHisResX[i]); + fHisResZ[i]->Add(add.fHisResZ[i]); + fHisResXZ[i]->Add(add.fHisResXZ[i]); + fHisClusterSize[i]->Add(add.fHisClusterSize[i]); + } + } return *this; } //______________________________________________________________________ @@ -100,10 +134,31 @@ AliITSPlaneEffSSD& AliITSPlaneEffSSD::operator=(const void AliITSPlaneEffSSD::Copy(TObject &obj) const { // protected method. copy this to obj AliITSPlaneEff::Copy(obj); + AliITSPlaneEffSSD& target = (AliITSPlaneEffSSD &) obj; for(Int_t i=0;i=kNModule) {AliError("GetFracLive: you asked for a non existing key"); return -1.;} - // Compute the fraction of bad (dead+noisy) detector +AliInfo("GetFracLive: it computes only the fraction of working strips (N+P side) / total strips"); UInt_t bad=0; GetBadInModule(key,bad); Double_t live=bad; @@ -220,7 +280,7 @@ return 1.-live; } //_____________________________________________________________________________ void AliITSPlaneEffSSD::GetBadInModule(const UInt_t key, UInt_t& nrBadInMod) const { - // returns the number of dead and noisy pixels + // returns the number of dead and noisy strips (sum of P and N sides). nrBadInMod=0; if(key>=kNModule) {AliError("GetBadInModule: you asked for a non existing key"); @@ -292,7 +352,8 @@ if(!fInitCDBCalled) AliCDBEntry *cdbEntry = AliCDBManager::Instance()->Get("ITS/PlaneEff/PlaneEffSSD",fRunNumber); AliITSPlaneEffSSD* eff= (AliITSPlaneEffSSD*)cdbEntry->GetObject(); if(this==eff) return kFALSE; -eff->Copy(*this); +if(fHis) CopyHistos(*eff); // If histos already exist then copy them to eff +eff->Copy(*this); // copy everything (statistics and histos) from eff to this return kTRUE; } //_____________________________________________________________________________ @@ -315,3 +376,221 @@ if(ilay==1) mod+=748; key=GetKey(mod); return key; } +//__________________________________________________________ +void AliITSPlaneEffSSD::InitHistos() { + // for the moment let's create the histograms + // module by module + TString histnameResX="HistResX_mod_",aux; + TString histnameResZ="HistResZ_mod_"; + TString histnameResXZ="HistResXZ_mod_"; + TString histnameClusterType="HistClusterType_mod_"; + +// + fHisResX=new TH1F*[kNHisto]; + fHisResZ=new TH1F*[kNHisto]; + fHisResXZ=new TH2F*[kNHisto]; + fHisClusterSize=new TH2I*[kNHisto]; + + for (Int_t nhist=0;nhistSetName(aux.Data()); + fHisResX[nhist]->SetTitle(aux.Data()); + + aux=histnameResZ; + aux+=nhist; + fHisResZ[nhist]=new TH1F("histname","histname",500,-0.50,0.50); // +-5000 micron; 1 bin=20 micron + fHisResZ[nhist]->SetName(aux.Data()); + fHisResZ[nhist]->SetTitle(aux.Data()); + + aux=histnameResXZ; + aux+=nhist; + fHisResXZ[nhist]=new TH2F("histname","histname",40,-0.02,0.02,40,-0.16,0.16); // binning: + // 10 micron in x; + // 80 micron in z; + fHisResXZ[nhist]->SetName(aux.Data()); + fHisResXZ[nhist]->SetTitle(aux.Data()); + + aux=histnameClusterType; + aux+=nhist; + fHisClusterSize[nhist]=new TH2I("histname","histname",6,0.5,6.5,6,0.5,6.5); + fHisClusterSize[nhist]->SetName(aux.Data()); + fHisClusterSize[nhist]->SetTitle(aux.Data()); + + } +return; +} +//__________________________________________________________ +void AliITSPlaneEffSSD::DeleteHistos() { + if(fHisResX) { + for (Int_t i=0; i=kNModule) + {AliWarning("FillHistos: you asked for a non existing key"); return kFALSE;} + Int_t id=GetModFromKey(key); + if(id>=kNHisto) + {AliWarning("FillHistos: you want to fill a non-existing histos"); return kFALSE;} + if(found) { + Float_t resx=tXZ[0]-cXZ[0]; + Float_t resz=tXZ[1]-cXZ[1]; + fHisResX[id]->Fill(resx); + fHisResZ[id]->Fill(resz); + fHisResXZ[id]->Fill(resx,resz); + fHisClusterSize[id]->Fill((Double_t)ctXZ[0],(Double_t)ctXZ[1]); + } + return kTRUE; +} +//__________________________________________________________ +Bool_t AliITSPlaneEffSSD::WriteHistosToFile(TString filename, Option_t* option) { + // + // Saves the histograms into a tree and saves the trees into a file + // + if (!fHis) return kFALSE; + if (filename.Data()=="") { + AliWarning("WriteHistosToFile: null output filename!"); + return kFALSE; + } +// char branchname[30]; + TFile *hFile=new TFile(filename.Data(),option, + "The File containing the TREEs with ITS PlaneEff Histos"); + TTree *SSDTree=new TTree("SSDTree","Tree whith Residuals and Cluster Type distributions for SSD"); + TH1F *histZ,*histX; + TH2F *histXZ; + TH2I *histClusterType; + + histZ=new TH1F(); + histX=new TH1F(); + histXZ=new TH2F(); + histClusterType=new TH2I(); + + SSDTree->Branch("histX","TH1F",&histX,128000,0); + SSDTree->Branch("histZ","TH1F",&histZ,128000,0); + SSDTree->Branch("histXZ","TH2F",&histXZ,128000,0); + SSDTree->Branch("histClusterType","TH2I",&histClusterType,128000,0); + + for(Int_t j=0;jFill(); + } + hFile->Write(); + hFile->Close(); +return kTRUE; +} +//__________________________________________________________ +Bool_t AliITSPlaneEffSSD::ReadHistosFromFile(TString filename) { + // + // Read histograms from an already existing file + // + if (!fHis) return kFALSE; + if (filename.Data()=="") { + AliWarning("ReadHistosFromFile: incorrect output filename!"); + return kFALSE; + } + char branchname[30]; + + TH1F *h = 0; + TH2F *h2 = 0; + TH2I *h2i= 0; + + TFile *file=TFile::Open(filename.Data(),"READONLY"); + + if (!file || file->IsZombie()) { + AliWarning(Form("Can't open %s !",filename.Data())); + delete file; + return kFALSE; + } + TTree *tree = (TTree*) file->Get("SSDTree"); + + TBranch *histX = (TBranch*) tree->GetBranch("histX"); + TBranch *histZ = (TBranch*) tree->GetBranch("histZ"); + TBranch *histXZ = (TBranch*) tree->GetBranch("histXZ"); + TBranch *histClusterType = (TBranch*) tree->GetBranch("histClusterType"); + + gROOT->cd(); + + Int_t nevent = (Int_t)histX->GetEntries(); + if(nevent!=kNHisto) + {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;} + histX->SetAddress(&h); + for(Int_t j=0;jGetEntry(j); + fHisResX[j]->Add(h); + } + + nevent = (Int_t)histZ->GetEntries(); + if(nevent!=kNHisto) + {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;} + histZ->SetAddress(&h); + for(Int_t j=0;jGetEntry(j); + fHisResZ[j]->Add(h); + } + + nevent = (Int_t)histXZ->GetEntries(); + if(nevent!=kNHisto) + {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;} + histXZ->SetAddress(&h2); + for(Int_t j=0;jGetEntry(j); + fHisResXZ[j]->Add(h2); + } + + nevent = (Int_t)histClusterType->GetEntries(); + if(nevent!=kNHisto) + {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;} + histClusterType->SetAddress(&h2i); + for(Int_t j=0;jGetEntry(j); + fHisClusterSize[j]->Add(h2i); + } + + delete h; h=0; + delete h2; h2=0; + delete h2i; h2i=0; + + if (file) { + file->Close(); + } +return kTRUE; +} + diff --git a/ITS/AliITSPlaneEffSSD.h b/ITS/AliITSPlaneEffSSD.h index 2b0629de483..493bfbcdc37 100644 --- a/ITS/AliITSPlaneEffSSD.h +++ b/ITS/AliITSPlaneEffSSD.h @@ -3,7 +3,8 @@ /* Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. * * See cxx source for full Copyright notice */ - +#include +#include #include "AliITSPlaneEff.h" /////////////////////////////////////////// @@ -36,8 +37,12 @@ class AliITSPlaneEffSSD : public AliITSPlaneEff { enum {kNChip = 6}; // The number of chips per side of a module (2 sides: 12 chips) enum {kNSide = 2}; // The number of sides of a module (p and n side) enum {kNStrip = 128}; // The number of strips per chip (in a module 2*768 strips) + // + enum {kNHisto = kNModule}; // The number of histograms: module by module. + //enum {kNclu = 3}; // Build specific histos of residuals up to cluster size kNclu. + // If you change them, then you must change implementation of + // the method FillHistos. // -// UInt_t GetChip(const UInt_t col) const; // get the chip number (from 0 to kNChip) // Plane efficiency for active detector (excluding dead/noisy channels) // access to DB is needed virtual Double_t LivePlaneEff(UInt_t mod) const; @@ -57,21 +62,38 @@ class AliITSPlaneEffSSD : public AliITSPlaneEff { UInt_t Nblock() const; // return the number of basic blocks // compute the geometrical limit of a basic block (chip) in detector local coordinate system Bool_t GetBlockBoundaries(const UInt_t key,Float_t& xmn,Float_t& xmx,Float_t& zmn,Float_t& zmx) const; - + // Methods for dealing with auxiliary histograms + // method to set on/off the creation/updates of histograms (Histos are created/destroyed) + void SetCreateHistos(Bool_t his=kFALSE) + {fHis=his; if(fHis) {DeleteHistos(); InitHistos();} else DeleteHistos(); return; } + Bool_t FillHistos(UInt_t key, Bool_t found, Float_t trackXZ[2], Float_t clusterXZ[2], Int_t ctXZ[2]); + Bool_t WriteHistosToFile(TString filename="PlaneEffSSDHistos.root",Option_t* option = "RECREATE"); + Bool_t ReadHistosFromFile(TString filename="PlaneEffSSDHistos.root"); // histos must exist already ! + // This method increases the + // statistics of histos by adding + // those of the input file. protected: virtual void Copy(TObject &obj) const; + void CopyHistos(AliITSPlaneEffSSD& target) const; // copy only histograms to target Int_t GetMissingTracksForGivenEff(Double_t eff, Double_t RelErr, UInt_t im) const; // Int_t fFound[kNModule]; // number of associated clusters in a given module Int_t fTried[kNModule]; // number of tracks used for module efficiency evaluation +// + TH1F **fHisResX; //! histos with residual distribution (track-cluster) along local X (r-phi) + TH1F **fHisResZ; //! histos with residual distribution (track-cluster) along local Z + TH2F **fHisResXZ; //! 2-d histos with residual distribution (track-cluster) along local X and Z + TH2I **fHisClusterSize; //! histos with cluster-size distribution private: UInt_t GetKey(const UInt_t mod) const; // unique key to locate the basic // block of the SSD (the module itself) UInt_t GetModFromKey(const UInt_t key) const; void GetBadInModule(const UInt_t mod, UInt_t& bad) const; + void InitHistos(); + void DeleteHistos(); - ClassDef(AliITSPlaneEffSSD,1) // SSD Plane Efficiency class + ClassDef(AliITSPlaneEffSSD,2) // SSD Plane Efficiency class }; // inline UInt_t AliITSPlaneEffSSD::Nblock() const {return kNModule;} diff --git a/ITS/AliITStrackerMI.cxx b/ITS/AliITStrackerMI.cxx index 412afc6c60a..086aa1d83ed 100644 --- a/ITS/AliITStrackerMI.cxx +++ b/ITS/AliITStrackerMI.cxx @@ -5150,13 +5150,15 @@ void AliITStrackerMI::UseTrackForPlaneEff(AliITStrackMI* track, Int_t ilayer) { tmp.GetXYZ(xyzGlob); AliITSgeomTGeo::GlobalToLocal(ilayer+1,lad,hdet,xyzGlob,xyzLoc); Float_t tr[2]={xyzLoc[0],xyzLoc[2]}; - Float_t cl[2]; - cl[0]=layer.GetCluster(ci)->GetDetLocalX(); - cl[1]=layer.GetCluster(ci)->GetDetLocalZ(); - Int_t cltype[2]; - cltype[0]=layer.GetCluster(ci)->GetNy(); - cltype[1]=layer.GetCluster(ci)->GetNz(); - fPlaneEff->FillHistos(key,found,tr,cl,cltype); + Float_t clu[2]={-99999.,-99999.}; + Int_t cltype[2]={-999,-999}; + if (found){ + clu[0]=layer.GetCluster(ci)->GetDetLocalX(); + clu[1]=layer.GetCluster(ci)->GetDetLocalZ(); + cltype[0]=layer.GetCluster(ci)->GetNy(); + cltype[1]=layer.GetCluster(ci)->GetNz(); + } + fPlaneEff->FillHistos(key,found,tr,clu,cltype); } return; } -- 2.43.0