]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSPlaneEffSDD.cxx
Coverity
[u/mrichter/AliRoot.git] / ITS / AliITSPlaneEffSDD.cxx
index 92a5a460b697bf02d920feb245916782d246956c..0bc4c7890443881f17687e1b5640a2755545e383 100644 (file)
@@ -60,10 +60,10 @@ AliITSPlaneEffSDD::AliITSPlaneEffSDD():
   fHisClusErrX(0),
   fHisClusErrZ(0){
   for (UInt_t i=0; i<kNModule*kNChip*kNWing*kNSubWing; i++){
+  // default constructor
     fFound[i]=0;
     fTried[i]=0;
   }
-  // default constructor
   AliDebug(1,Form("Calling default constructor"));
 }
 //______________________________________________________________________
@@ -239,23 +239,7 @@ void AliITSPlaneEffSDD::CopyHistos(AliITSPlaneEffSDD &target) const {
   }
 return;
 }
-/* Commented out by M.Masera 8/3/08
-//______________________________________________________________________
-AliITSPlaneEff&  AliITSPlaneEffSDD::operator=(const
-                                           AliITSPlaneEff &s){
-    //    Assignment operator
-    // Inputs:
-    //    AliITSPlaneEffSDD &s The original class for which
-    //                                this class is a copy of
-    // Outputs:
-    //    none.
-    // Return:
 
-    if(&s == this) return *this;
-    AliError("operator=: Not allowed to make a =, use default creater instead");
-    return *this;
-}
-*/
 //_______________________________________________________________________
 Int_t AliITSPlaneEffSDD::GetMissingTracksForGivenEff(Double_t eff, Double_t RelErr,
           UInt_t im, UInt_t ic, UInt_t iw, UInt_t is) const {
@@ -275,7 +259,11 @@ Int_t AliITSPlaneEffSDD::GetMissingTracksForGivenEff(Double_t eff, Double_t RelE
 if (im>=kNModule || ic>=kNChip || iw>=kNWing || is>=kNSubWing) 
  {AliError("GetMissingTracksForGivenEff: you asked for a non existing block");
  return -1;}
-else return GetNTracksForGivenEff(eff,RelErr)-fTried[GetKey(im,ic,iw,is)];
+else {
+  UInt_t key=GetKey(im,ic,iw,is);
+  if (key<kNModule*kNChip*kNWing*kNSubWing) return GetNTracksForGivenEff(eff,RelErr)-fTried[key];
+  else return -1;
+}
 }
 //_________________________________________________________________________
 Double_t  AliITSPlaneEffSDD::PlaneEff(const UInt_t im,const UInt_t ic,
@@ -288,8 +276,13 @@ Double_t  AliITSPlaneEffSDD::PlaneEff(const UInt_t im,const UInt_t ic,
 //        is     -> chip number [0,kNSubWing-1]
 if (im>=kNModule || ic>=kNChip || iw>=kNWing || is>=kNSubWing) 
  {AliError("PlaneEff(UInt_t,UInt_t,UInt_t,UInt_t): you asked for a non existing block"); return -1.;}
- Int_t nf=fFound[GetKey(im,ic,iw,is)];
- Int_t nt=fTried[GetKey(im,ic,iw,is)];
+UInt_t key=GetKey(im,ic,iw,is);
+Int_t nf=-1;
+Int_t nt=-1;
+if (key<kNModule*kNChip*kNWing*kNSubWing) {
+  nf=fFound[key];
+  nt=fTried[key];
+}
 return AliITSPlaneEff::PlaneEff(nf,nt);
 }
 //_________________________________________________________________________
@@ -304,8 +297,13 @@ Double_t  AliITSPlaneEffSDD::ErrPlaneEff(const UInt_t im,const UInt_t ic,
     //        is     -> chip number [0,kNSubWing-1]
 if (im>=kNModule || ic>=kNChip || iw>=kNWing || is>=kNSubWing) 
  {AliError("ErrPlaneEff(UInt_t,UInt_t,UInt_t,UInt_t): you asked for a non existing block"); return -1.;}
-Int_t nf=fFound[GetKey(im,ic,iw,is)];
-Int_t nt=fTried[GetKey(im,ic,iw,is)];
+UInt_t key=GetKey(im,ic,iw,is);
+Int_t nf=-1;
+Int_t nt=-1;
+if (key<kNModule*kNChip*kNWing*kNSubWing) {
+  nf=fFound[key];
+  nt=fTried[key];
+}
 return AliITSPlaneEff::ErrPlaneEff(nf,nt);
 } 
 //_________________________________________________________________________
@@ -315,9 +313,15 @@ Bool_t AliITSPlaneEffSDD::UpDatePlaneEff(const Bool_t Kfound,
   // Update efficiency for a basic block
 if (im>=kNModule || ic>=kNChip || iw>=kNWing || is>=kNSubWing) 
  {AliError("UpDatePlaneEff: you asked for a non existing block"); return kFALSE;}
- fTried[GetKey(im,ic,iw,is)]++;
- if(Kfound) fFound[GetKey(im,ic,iw,is)]++;
- return kTRUE;
+ UInt_t key=GetKey(im,ic,iw,is);
+ if (key<kNModule*kNChip*kNWing*kNSubWing) { 
+   fTried[key]++;
+   if(Kfound) fFound[key]++;
+   return kTRUE;
+ }
+ else {
+   return kFALSE;
+ }
 }
 //_________________________________________________________________________
 void AliITSPlaneEffSDD::ChipAndWingFromAnode(const UInt_t anode, UInt_t& chip,
@@ -525,6 +529,7 @@ return kTRUE;
 }
 //_____________________________________________________________________________
 Bool_t AliITSPlaneEffSDD::AddFromCDB(AliCDBId *cdbId) {
+// read efficiency values from CDB
 AliCDBEntry *cdbEntry=0;
 if (!cdbId) {
   if(!fInitCDBCalled)
@@ -790,19 +795,19 @@ void AliITSPlaneEffSDD::InitHistos() {
   for (Int_t nhist=0;nhist<kNHisto;nhist++){
     aux=histnameResX;
     aux+=nhist;
-    fHisResX[nhist]=new TH1F("histname","histname",1500,-0.30,0.30); // +- 3000 micron; 1 bin=4 micron
+    fHisResX[nhist]=new TH1F("histname","histname",2000,-0.40,0.40); // +- 4000 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",500,-0.15,0.15); // +-1500 micron; 1 bin=6 micron
+    fHisResZ[nhist]=new TH1F("histname","histname",1000,-0.30,0.30); // +-3000 micron; 1 bin=6 micron
     fHisResZ[nhist]->SetName(aux.Data());
     fHisResZ[nhist]->SetTitle(aux.Data());
 
     aux=histnameResXZ;
     aux+=nhist;
-    fHisResXZ[nhist]=new TH2F("histname","histname",50,-0.2,0.2,30,-0.12,0.12); // binning:
+    fHisResXZ[nhist]=new TH2F("histname","histname",100,-0.4,0.4,60,-0.24,0.24); // binning:
                                                                                    // 80 micron in x; 
                                                                                    // 80 micron in z; 
     fHisResXZ[nhist]->SetName(aux.Data());
@@ -835,7 +840,7 @@ void AliITSPlaneEffSDD::InitHistos() {
       aux+=nhist;
       aux+="_clu_";
       aux+=clu+1; // clu=0 --> cluster size 1
-      fHisResZclu[nhist][clu]=new TH1F("histname","histname",500,-0.15,0.15); // +-1500 micron; 1 bin=6 micron
+      fHisResZclu[nhist][clu]=new TH1F("histname","histname",1000,-0.30,0.30); // +-3000 micron; 1 bin=6 micron
       fHisResZclu[nhist][clu]->SetName(aux.Data());
       fHisResZclu[nhist][clu]->SetTitle(aux.Data());
     }
@@ -866,7 +871,7 @@ void AliITSPlaneEffSDD::InitHistos() {
 
     aux=histnameTrackErrX;
     aux+=nhist;
-    fHisTrackErrX[nhist]=new TH1F("histname","histname",200,0.,0.16); // 0-1600 micron; 1 bin=8 micron
+    fHisTrackErrX[nhist]=new TH1F("histname","histname",500,0.,0.50); // 0-5000 micron; 1 bin=10 micron
     fHisTrackErrX[nhist]->SetName(aux.Data());
     fHisTrackErrX[nhist]->SetTitle(aux.Data());
 
@@ -878,13 +883,13 @@ void AliITSPlaneEffSDD::InitHistos() {
 
     aux=histnameClusErrX;
     aux+=nhist;
-    fHisClusErrX[nhist]=new TH1F("histname","histname",200,0.,0.04); //  0-400 micron; 1 bin=2 micron
+    fHisClusErrX[nhist]=new TH1F("histname","histname",400,0.,0.24); //  0-2400 micron; 1 bin=6 micron
     fHisClusErrX[nhist]->SetName(aux.Data());
     fHisClusErrX[nhist]->SetTitle(aux.Data());
 
     aux=histnameClusErrZ;
     aux+=nhist;
-    fHisClusErrZ[nhist]=new TH1F("histname","histname",200,0.,0.16); //  0-1600 micron; 1 bin=8 micron
+    fHisClusErrZ[nhist]=new TH1F("histname","histname",400,0.,0.32); //  0-3200 micron; 1 bin=8 micron
     fHisClusErrZ[nhist]->SetName(aux.Data());
     fHisClusErrZ[nhist]->SetTitle(aux.Data());
 
@@ -896,6 +901,7 @@ return;
 }
 //__________________________________________________________
 void AliITSPlaneEffSDD::DeleteHistos() {
+ // delete the histograms and clean the memory
   if(fHisResX) {
     for (Int_t i=0; i<kNHisto; i++ ) delete fHisResX[i];
     delete [] fHisResX; fHisResX=0;
@@ -969,8 +975,7 @@ return;
 }
 //__________________________________________________________
 Bool_t AliITSPlaneEffSDD::FillHistos(UInt_t key, Bool_t found, 
-                               //      Float_t tXZ[2], Float_t cXZ[2], Int_t ctXZ[2]) {
-                                     Float_t *tr, Float_t *clu, Int_t *csize) {
+                                     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 
@@ -1018,11 +1023,11 @@ 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()=="") {
+  if (filename.IsNull() || filename.IsWhitespace()) {
      AliWarning("WriteHistosToFile: null output filename!");
      return kFALSE;
   }
-  char branchname[30];
+  char branchname[51];
   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");
@@ -1060,9 +1065,9 @@ Bool_t AliITSPlaneEffSDD::WriteHistosToFile(TString filename, Option_t* option)
   SDDTree->Branch("histClusterType","TH2I",&histClusterType,128000,0);
   SDDTree->Branch("profileResXvsCluSizeX","TProfile",&profileResXvsCluSizeX,128000,0);
   for(Int_t clu=0;clu<kNclu;clu++) {
-    //sprintf(branchname,"histXclu_%d",clu+1);
+    //snprintf(branchname,50,"histXclu_%d",clu+1);
     //SDDTree->Branch(branchname,"TH1F",&histXclu[clu],128000,0);
-    sprintf(branchname,"histZclu_%d",clu+1);
+    snprintf(branchname,50,"histZclu_%d",clu+1);
     SDDTree->Branch(branchname,"TH1F",&histZclu[clu],128000,0);
   }
   SDDTree->Branch("profileResXvsX","TProfile",&profileResXvsX,128000,0);
@@ -1105,11 +1110,11 @@ Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
   // Read histograms from an already existing file 
   //
   if (!fHis) return kFALSE;
-  if (filename.Data()=="") {
+  if (filename.IsNull() || filename.IsWhitespace()) {
      AliWarning("ReadHistosFromFile: incorrect output filename!");
      return kFALSE;
   }
-  char branchname[30];
+  char branchname[51];
 
   TH1F *h  = 0;
   TH2F *h2 = 0;
@@ -1133,9 +1138,9 @@ Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
   //TBranch *histXclu[kNclu], *histZclu[kNclu];
   TBranch *histZclu[kNclu];
   for(Int_t clu=0; clu<kNclu; clu++) {
-    //sprintf(branchname,"histXclu_%d",clu+1);
+    //snprintf(branchname,50,"histXclu_%d",clu+1);
     //histXclu[clu]= (TBranch*) tree->GetBranch(branchname);
-    sprintf(branchname,"histZclu_%d",clu+1);
+    snprintf(branchname,50,"histZclu_%d",clu+1);
     histZclu[clu]= (TBranch*) tree->GetBranch(branchname);
   }
   TBranch *profileResXvsX = (TBranch*) tree->GetBranch("profileResXvsX");
@@ -1154,7 +1159,6 @@ Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
     {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
   histX->SetAddress(&h);
   for(Int_t j=0;j<kNHisto;j++){
-    delete h; h=0;
     histX->GetEntry(j);
     fHisResX[j]->Add(h);
   }
@@ -1164,7 +1168,6 @@ Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
     {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
   histZ->SetAddress(&h);
   for(Int_t j=0;j<kNHisto;j++){
-    delete h; h=0;
     histZ->GetEntry(j);
     fHisResZ[j]->Add(h);
   }
@@ -1174,7 +1177,6 @@ Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
     {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
   histXZ->SetAddress(&h2);
   for(Int_t j=0;j<kNHisto;j++){
-    delete h2; h2=0;
     histXZ->GetEntry(j);
     fHisResXZ[j]->Add(h2);
   }
@@ -1184,7 +1186,6 @@ Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
     {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
   histClusterType->SetAddress(&h2i);
   for(Int_t j=0;j<kNHisto;j++){
-    delete h2i; h2i=0;
     histClusterType->GetEntry(j);
     fHisClusterSize[j]->Add(h2i);
   }
@@ -1194,7 +1195,6 @@ Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
     {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
   profileResXvsCluSizeX->SetAddress(&p);
   for(Int_t j=0;j<kNHisto;j++){
-    delete p; p=0;
     profileResXvsCluSizeX->GetEntry(j);
     fProfResXvsCluSizeX[j]->Add(p);
   }
@@ -1206,7 +1206,6 @@ Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
       {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
     histXclu[clu]->SetAddress(&h);
     for(Int_t j=0;j<kNHisto;j++){
-      delete h; h=0;
       histXclu[clu]->GetEntry(j);
       fHisResXclu[j][clu]->Add(h);
     }*/
@@ -1216,7 +1215,6 @@ Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
       {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
     histZclu[clu]->SetAddress(&h);
     for(Int_t j=0;j<kNHisto;j++){
-      delete h; h=0;
       histZclu[clu]->GetEntry(j);
       fHisResZclu[j][clu]->Add(h);
     }
@@ -1227,7 +1225,6 @@ Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
     {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
   profileResXvsX->SetAddress(&p);
   for(Int_t j=0;j<kNHisto;j++){
-    delete p; p=0;
     profileResXvsX->GetEntry(j);
     fProfResXvsX[j]->Add(p);
   }
@@ -1237,7 +1234,6 @@ Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
     {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
   profileResZvsX->SetAddress(&p);
   for(Int_t j=0;j<kNHisto;j++){
-    delete p; p=0;
     profileResZvsX->GetEntry(j);
     fProfResZvsX[j]->Add(p);
   }
@@ -1247,7 +1243,6 @@ Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
     {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
   profileClSizXvsX->SetAddress(&p);
   for(Int_t j=0;j<kNHisto;j++){
-    delete p; p=0;
     profileClSizXvsX->GetEntry(j);
     fProfClustSizeXvsX[j]->Add(p);
   }
@@ -1257,7 +1252,6 @@ Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
     {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
   profileClSizZvsX->SetAddress(&p);
   for(Int_t j=0;j<kNHisto;j++){
-    delete p; p=0;
     profileClSizZvsX->GetEntry(j);
     fProfClustSizeZvsX[j]->Add(p);
   }
@@ -1267,7 +1261,6 @@ Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
     {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
   histTrErrX->SetAddress(&h);
   for(Int_t j=0;j<kNHisto;j++){
-    delete h; h=0;
     histTrErrX->GetEntry(j);
     fHisTrackErrX[j]->Add(h);
   }
@@ -1277,7 +1270,6 @@ Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
     {AliWarning("ReadHistosFromFile: trying to read too many or too few histos!"); return kFALSE;}
   histTrErrZ->SetAddress(&h);
   for(Int_t j=0;j<kNHisto;j++){
-    delete h; h=0;
     histTrErrZ->GetEntry(j);
     fHisTrackErrZ[j]->Add(h);
   }
@@ -1287,7 +1279,6 @@ Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
     {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);
   }
@@ -1297,19 +1288,18 @@ Bool_t AliITSPlaneEffSDD::ReadHistosFromFile(TString filename) {
     {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;   h=0;
-  delete h2;  h2=0;
-  delete h2i; h2i=0;
-  delete p;   p=0;
+  delete h;  
+  delete h2;  
+  delete h2i; 
+  delete p;   
 
   if (file) {
     file->Close();
+    delete file;
   }
 return kTRUE;
 }
-