]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMDCalibGain.cxx
Adding the option to zero shared entries below threshold
[u/mrichter/AliRoot.git] / PMD / AliPMDCalibGain.cxx
index 6200cffcc629ec972cd36537ae33fc710bccac10..e800f59781c2c75e7452c16c28e88930fce8d155 100644 (file)
@@ -16,6 +16,7 @@
 //
 //////////////////////////////////////////////////////////////////////////////
 
+#include "Riostream.h"
 #include "TF1.h"
 #include "TFile.h"
 #include "TObjString.h"
@@ -143,8 +144,8 @@ Int_t AliPMDCalibGain::ExtractPedestal(const Char_t *rootFile)
   // Pedestal extraction from the PMD_PED.root file
   // To be called once at the beginning
   
-  Int_t   det, sm, row, col;
-  Float_t mean, rms;
+  Int_t   det=0, sm=0, row=0, col=0;
+  Float_t mean=0., rms=0.;
   
   TFile *pedfile = new TFile(rootFile);
   
@@ -187,15 +188,28 @@ Int_t AliPMDCalibGain::ExtractHotChannel(const Char_t *rootFile)
   // HotChannel extraction from the PMD_HOT.root file
   // To be called once at the beginning
 
-  Int_t   det, sm, row, col;
-  Float_t flag;
+  Int_t   det=0, sm=0, row=0, col=0;
+  Float_t flag=0.;
 
   TFile *hotmapfile = new TFile(rootFile);
 
   if(!hotmapfile)
     {
-      printf(" NO HOTCHANNEL MAP FOUND (PMD_HOR.root) FILE IS FOUND \n");
-      fHotFlag[kDet][kMaxSMN][kMaxRow][kMaxCol] = 0.;
+      printf(" NO HOTCHANNEL MAP (PMD_HOT.root) FILE IS FOUND \n");
+
+      for (Int_t idet = 0; idet < kDet; idet++)
+       {
+         for (Int_t ismn = 0; ismn < kMaxSMN; ismn++)
+           {
+             for (Int_t irow = 0; irow < kMaxRow; irow++)
+               {
+                 for (Int_t icol = 0; icol < kMaxCol; icol++)
+                   {
+                     fHotFlag[idet][ismn][irow][icol] = 0.;
+                   }
+               }
+           }
+       }
     }
 
 
@@ -231,18 +245,19 @@ void AliPMDCalibGain::ReadTempFile(const Char_t *tempFile)
 {
   // Read the variables from the file
   
-  fpw = fopen(tempFile,"r");
-  
-  Float_t smcount, smiso;
-  Float_t cellcount, celliso;
+  ifstream intmpfile;
+  intmpfile.open(tempFile);
+
+  Int_t iddet = 0, issm = 0, irrow = 0, iccol = 0;
+  Float_t smcount = 0., smiso = 0.;
+  Float_t cellcount = 0., celliso = 0.;
 
 
   for (Int_t idet = 0; idet < kDet; idet++)
     {
       for (Int_t ism = 0; ism < kMaxSMN; ism++)
        {
-         fscanf(fpw,"%d %d %f %f",&idet,&ism,&smcount,&smiso);
-         
+         intmpfile >> iddet >> issm >> smcount >> smiso;
          fSMCount[idet][ism] = smcount;
          fSMIso[idet][ism]   = smiso;
        }
@@ -256,9 +271,8 @@ void AliPMDCalibGain::ReadTempFile(const Char_t *tempFile)
            {
              for (Int_t icol = 0; icol < kMaxCol; icol++)
                {
-                 fscanf(fpw,"%d %d %d %d %f %f",&idet,&ism,&irow,&icol,
-                        &cellcount,&celliso);
-                 
+                 intmpfile >> iddet >> issm >> irrow >> iccol
+                           >> cellcount >> celliso;
                  fCellCount[idet][ism][irow][icol] = cellcount;
                  fCellIso[idet][ism][irow][icol]   = celliso;
                }
@@ -266,7 +280,8 @@ void AliPMDCalibGain::ReadTempFile(const Char_t *tempFile)
        }
     }
   
-  fclose(fpw);
+
+  intmpfile.close();
 
 }
 // ------------------------------------------------------------------------ //
@@ -333,8 +348,8 @@ Bool_t AliPMDCalibGain::ProcessEvent(AliRawReader *rawReader, TObjArray *pmdddlc
   Int_t neibx[6] = {1,0,-1,-1,0,1};
   Int_t neiby[6] = {0,1,1,0,-1,-1};
   
-  Int_t id1,jd1;  //neighbour row/col
-  Int_t isocount; //number of neighbours with 0 signal
+  Int_t id1 = 0,jd1 = 0;  //neighbour row/col
+  Int_t isocount = 0;     //number of neighbours with 0 signal
 
   Float_t d1[kDet][kMaxSMN][kMaxRow][kMaxCol];
   
@@ -413,6 +428,10 @@ Bool_t AliPMDCalibGain::ProcessEvent(AliRawReader *rawReader, TObjArray *pmdddlc
                        {
                          id1 = irow + neibx[ii];
                          jd1 = icol + neiby[ii];
+                         if (id1 < 0) id1 = 0;
+                         if (id1 > kMaxRow-1) id1 = kMaxRow - 1;
+                         if (jd1 < 0) jd1 = 0;
+                         if (jd1 > kMaxCol-1) jd1 = kMaxCol - 1;
                          if(d1[idet][ismn][id1][jd1] == 0)
                            {
                              isocount++;
@@ -459,14 +478,23 @@ Bool_t AliPMDCalibGain::ProcessEvent(AliRawReader *rawReader, TObjArray *pmdddlc
   
 }
 // ------------------------------------------------------------------------ //
-void AliPMDCalibGain::Analyse(TTree *gaintree)
+void AliPMDCalibGain::Analyse(TTree *gaintree, TTree *meantree)
 {
   // Calculates the mean
-  Int_t   det, sm, row, col;
-  Float_t gain;
-  Float_t modmean  = 0.;
+  Int_t   det = 0, sm = 0, row = 0, col = 0;
+  Float_t gain = 0.;
   Float_t cellmean = 0.;
 
+  Float_t modmean[2][24];
+
+  for (Int_t idet=0; idet < 2; idet++)
+    {
+      for (Int_t ism = 0; ism < 24; ism++)
+       {
+         modmean[idet][ism] = 0.;
+       }
+    }
+
   gaintree->Branch("det",&det,"det/I");
   gaintree->Branch("sm",&sm,"sm/I");
   gaintree->Branch("row",&row,"row/I");
@@ -478,7 +506,7 @@ void AliPMDCalibGain::Analyse(TTree *gaintree)
       for(Int_t ism = 0; ism < kMaxSMN; ism++)
        {
          if (fSMCount[idet][ism] > 0)
-           modmean = fSMIso[idet][ism]/fSMCount[idet][ism];
+           modmean[idet][ism] = fSMIso[idet][ism]/fSMCount[idet][ism];
          for(Int_t irow = 0; irow < kMaxRow; irow++)
            {
              for(Int_t icol = 0; icol < kMaxCol; icol++)
@@ -493,7 +521,7 @@ void AliPMDCalibGain::Analyse(TTree *gaintree)
                  col      = icol;
                  if (cellmean > 0.0 && fCellCount[idet][ism][irow][icol]>0.)
                    {
-                     gain = cellmean/modmean;
+                     gain = cellmean/modmean[idet][ism];
                    }
                  else
                    {
@@ -505,18 +533,38 @@ void AliPMDCalibGain::Analyse(TTree *gaintree)
            }
        }
     }
+
+  Float_t smmean;
+
+  // Writing each module mean value
+  meantree->Branch("det",&det,"det/I");
+  meantree->Branch("sm",&sm,"sm/I");
+  meantree->Branch("smmean",&smmean,"row/F");
   
+  for(Int_t idet = 0; idet < kDet; idet++)
+    {
+      for (Int_t ism = 0; ism < kMaxSMN; ism++)
+       {
+         det    = idet;
+         sm     = ism;
+         smmean = modmean[idet][ism];
+         meantree->Fill();
+       }
+    }
+
 }
 // ------------------------------------------------------------------------ //
-void AliPMDCalibGain::AnalyseHotCell(TTree *hottree)
+void AliPMDCalibGain::FindHotCell(TTree *hottree, Float_t xvar)
 {
   // Calculates the mean
-  Int_t   det, sm, row, col;
-  Float_t flag;
-  Float_t meannhit;
-  Float_t meanSqnhit;
-  Float_t sigmanhit,nhitcut;
-  
+  Int_t   det = 0, sm = 0, row = 0, col = 0;
+  Float_t flag = 0.;
+  Float_t meannhit = 0.;
+  Float_t meanSqnhit = 0.;
+  Float_t sigmanhit = 0.,nhitcut = 0.;
+
+  //Float_t xvar = 5.;
+
   hottree->Branch("det",&det,"det/I");
   hottree->Branch("sm",&sm,"sm/I");
   hottree->Branch("row",&row,"row/I");
@@ -532,7 +580,7 @@ void AliPMDCalibGain::AnalyseHotCell(TTree *hottree)
              meannhit   = fTempnhit[idet][ism]/fCountSm[idet][ism];
              meanSqnhit = fTempnhitSq[idet][ism]/fCountSm[idet][ism];
              sigmanhit  = sqrt(meanSqnhit-(meannhit*meannhit));
-             nhitcut    = meannhit + 6.*sigmanhit;
+             nhitcut    = meannhit + xvar*sigmanhit;
 
              for(Int_t irow = 0; irow < kMaxRow; irow++)
                {