+//__________________________________________________________
+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_";
+ TString histnameTrackErrX="HistTrackErrX_mod_";
+ TString histnameTrackErrZ="HistTrackErrZ_mod_";
+ TString histnameClusErrX="HistClusErrX_mod_";
+ TString histnameClusErrZ="HistClusErrZ_mod_";
+//
+
+ TH1::AddDirectory(kFALSE);
+
+ fHisResX=new TH1F*[kNHisto];
+ fHisResZ=new TH1F*[kNHisto];
+ fHisResXZ=new TH2F*[kNHisto];
+ fHisClusterSize=new TH2I*[kNHisto];
+ fHisTrackErrX=new TH1F*[kNHisto];
+ fHisTrackErrZ=new TH1F*[kNHisto];
+ fHisClusErrX=new TH1F*[kNHisto];
+ fHisClusErrZ=new TH1F*[kNHisto];
+
+ for (Int_t nhist=0;nhist<kNHisto;nhist++){
+ aux=histnameResX;
+ aux+=nhist;
+ fHisResX[nhist]=new TH1F("histname","histname",500,-0.10,0.10); // +- 1000 micron; 1 bin=4 micron
+ fHisResX[nhist]->SetName(aux.Data());
+ fHisResX[nhist]->SetTitle(aux.Data());
+
+ aux=histnameResZ;
+ aux+=nhist;
+ fHisResZ[nhist]=new TH1F("histname","histname",750,-0.75,0.75); // +-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.04,0.04,40,-0.32,0.32); // binning:
+ // 20 micron in x;
+ // 160 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());
+
+ aux=histnameTrackErrX;
+ aux+=nhist;
+ fHisTrackErrX[nhist]=new TH1F("histname","histname",300,0.,0.24); // 0-2400 micron; 1 bin=8 micron
+ fHisTrackErrX[nhist]->SetName(aux.Data());
+ fHisTrackErrX[nhist]->SetTitle(aux.Data());
+
+ aux=histnameTrackErrZ;
+ aux+=nhist;
+ fHisTrackErrZ[nhist]=new TH1F("histname","histname",300,0.,0.48); // 0-4800 micron; 1 bin=16 micron
+ fHisTrackErrZ[nhist]->SetName(aux.Data());
+ fHisTrackErrZ[nhist]->SetTitle(aux.Data());
+
+ aux=histnameClusErrX;
+ aux+=nhist;
+ fHisClusErrX[nhist]=new TH1F("histname","histname",300,0.,0.24); // 0-2400 micron; 1 bin=8 micron
+ fHisClusErrX[nhist]->SetName(aux.Data());
+ fHisClusErrX[nhist]->SetTitle(aux.Data());
+
+ aux=histnameClusErrZ;
+ aux+=nhist;
+ fHisClusErrZ[nhist]=new TH1F("histname","histname",200,0.,0.32); // 0-1600 micron; 1 bin=16 micron
+ fHisClusErrZ[nhist]->SetName(aux.Data());
+ fHisClusErrZ[nhist]->SetTitle(aux.Data());
+
+ }
+
+ TH1::AddDirectory(kTRUE);
+
+return;
+}
+//__________________________________________________________
+void AliITSPlaneEffSSD::DeleteHistos() {
+// Delete histograms and remove them from memory
+ if(fHisResX) {
+ for (Int_t i=0; i<kNHisto; i++ ) delete fHisResX[i];
+ delete [] fHisResX; fHisResX=0;
+ }
+ if(fHisResZ) {
+ for (Int_t i=0; i<kNHisto; i++ ) delete fHisResZ[i];
+ delete [] fHisResZ; fHisResZ=0;
+ }
+ if(fHisResXZ) {
+ for (Int_t i=0; i<kNHisto; i++ ) delete fHisResXZ[i];
+ delete [] fHisResXZ; fHisResXZ=0;
+ }
+ if(fHisClusterSize) {
+ for (Int_t i=0; i<kNHisto; i++ ) delete fHisClusterSize[i];
+ delete [] fHisClusterSize; fHisClusterSize=0;
+ }
+ if(fHisTrackErrX) {
+ for (Int_t i=0; i<kNHisto; i++ ) delete fHisTrackErrX[i];
+ delete [] fHisTrackErrX; fHisTrackErrX=0;
+ }
+ if(fHisTrackErrZ) {
+ for (Int_t i=0; i<kNHisto; i++ ) delete fHisTrackErrZ[i];
+ delete [] fHisTrackErrZ; fHisTrackErrZ=0;
+ }
+ if(fHisClusErrX) {
+ for (Int_t i=0; i<kNHisto; i++ ) delete fHisClusErrX[i];
+ delete [] fHisClusErrX; fHisClusErrX=0;
+ }
+ if(fHisClusErrZ) {
+ for (Int_t i=0; i<kNHisto; i++ ) delete fHisClusErrZ[i];
+ delete [] fHisClusErrZ; fHisClusErrZ=0;
+ }
+
+return;
+}
+//__________________________________________________________
+Bool_t AliITSPlaneEffSSD::FillHistos(UInt_t key, Bool_t found,
+ Float_t *tr, Float_t *clu, Int_t *csize, Float_t*) {
+// this method fill the histograms
+// input: - key: unique key of the basic block
+// - found: Boolean to asses whether a cluster has been associated to the track or not
+// - tr[0],tr[1] local X and Z coordinates of the track prediction, respectively
+// - tr[2],tr[3] error on local X and Z coordinates of the track prediction, respectively
+// - clu[0],clu[1] local X and Z coordinates of the cluster associated to the track, respectively
+// - clu[2],clu[3] error on local X and Z coordinates of the cluster associated to the track, respectively
+// - csize[0][1] cluster size in X and Z, respectively
+// output: kTRUE if filling was succesfull kFALSE otherwise
+// side effects: updating of the histograms.
+//
+ if (!fHis) {
+ AliWarning("FillHistos: histograms do not exist! Call SetCreateHistos(kTRUE) first");
+ return kFALSE;
+ }
+ if(key>=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=tr[0]-clu[0];
+ Float_t resz=tr[1]-clu[1];
+ fHisResX[id]->Fill(resx);
+ fHisResZ[id]->Fill(resz);
+ fHisResXZ[id]->Fill(resx,resz);
+ fHisClusterSize[id]->Fill((Double_t)csize[0],(Double_t)csize[1]);
+ }
+ fHisTrackErrX[id]->Fill(tr[2]);
+ fHisTrackErrZ[id]->Fill(tr[3]);
+ fHisClusErrX[id]->Fill(clu[2]);
+ fHisClusErrZ[id]->Fill(clu[3]);
+ 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.IsNull() || filename.IsWhitespace()) {
+ AliWarning("WriteHistosToFile: null output filename!");
+ return kFALSE;
+ }
+
+ 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;
+ TH1F *histTrErrZ,*histTrErrX;
+ TH1F *histClErrZ,*histClErrX;
+
+ histZ=new TH1F();
+ histX=new TH1F();
+ histXZ=new TH2F();
+ histClusterType=new TH2I();
+ histTrErrX=new TH1F();
+ histTrErrZ=new TH1F();
+ histClErrX=new TH1F();
+ histClErrZ=new TH1F();
+
+ 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);
+ SSDTree->Branch("histTrErrX","TH1F",&histTrErrX,128000,0);
+ SSDTree->Branch("histTrErrZ","TH1F",&histTrErrZ,128000,0);
+ SSDTree->Branch("histClErrX","TH1F",&histClErrX,128000,0);
+ SSDTree->Branch("histClErrZ","TH1F",&histClErrZ,128000,0);
+
+ for(Int_t j=0;j<kNHisto;j++){
+ histX=fHisResX[j];
+ histZ=fHisResZ[j];
+ histXZ=fHisResXZ[j];
+ histClusterType=fHisClusterSize[j];
+ histTrErrX=fHisTrackErrX[j];
+ histTrErrZ=fHisTrackErrZ[j];
+ histClErrX=fHisClusErrX[j];
+ histClErrZ=fHisClusErrZ[j];
+
+ SSDTree->Fill();
+ }
+ 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.IsNull() || filename.IsWhitespace()) {
+ AliWarning("ReadHistosFromFile: incorrect output filename!");
+ return kFALSE;
+ }
+
+ 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");
+ TBranch *histTrErrX = (TBranch*) tree->GetBranch("histTrErrX");
+ TBranch *histTrErrZ = (TBranch*) tree->GetBranch("histTrErrZ");
+ TBranch *histClErrX = (TBranch*) tree->GetBranch("histClErrX");
+ TBranch *histClErrZ = (TBranch*) tree->GetBranch("histClErrZ");
+
+ 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;j<kNHisto;j++){
+ histX->GetEntry(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;j<kNHisto;j++){
+ histZ->GetEntry(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;j<kNHisto;j++){
+ histXZ->GetEntry(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;j<kNHisto;j++){
+ histClusterType->GetEntry(j);
+ fHisClusterSize[j]->Add(h2i);
+ }
+
+ nevent = (Int_t)histTrErrX->GetEntries();
+ if(nevent!=kNHisto)
+ {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
+ histTrErrX->SetAddress(&h);
+ for(Int_t j=0;j<kNHisto;j++){
+ histTrErrX->GetEntry(j);
+ fHisTrackErrX[j]->Add(h);
+ }
+
+ nevent = (Int_t)histTrErrZ->GetEntries();
+ if(nevent!=kNHisto)
+ {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
+ histTrErrZ->SetAddress(&h);
+ for(Int_t j=0;j<kNHisto;j++){
+ histTrErrZ->GetEntry(j);
+ fHisTrackErrZ[j]->Add(h);
+ }
+
+ nevent = (Int_t)histClErrX->GetEntries();
+ if(nevent!=kNHisto)
+ {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
+ histClErrX->SetAddress(&h);
+ for(Int_t j=0;j<kNHisto;j++){
+ //delete h; h=0;
+ histClErrX->GetEntry(j);
+ fHisClusErrX[j]->Add(h);
+ }
+
+ nevent = (Int_t)histClErrZ->GetEntries();
+ if(nevent!=kNHisto)
+ {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
+ histClErrZ->SetAddress(&h);
+ for(Int_t j=0;j<kNHisto;j++){
+ //delete h; h=0;
+ histClErrZ->GetEntry(j);
+ fHisClusErrZ[j]->Add(h);
+ }
+
+ delete h;
+ delete h2;
+ delete h2i;
+
+ if (file) {
+ file->Close();
+ delete file;
+ }
+return kTRUE;
+}
+