]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMDCalibGain.cxx
bug fixed for alignment, removed alignment database access from AliPMDUtility class
[u/mrichter/AliRoot.git] / PMD / AliPMDCalibGain.cxx
index 6200cffcc629ec972cd36537ae33fc710bccac10..e4436d5c83ecbcbe543127e34af2f697491a57b5 100644 (file)
@@ -143,8 +143,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 +187,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; idet++)
+           {
+             for (Int_t irow = 0; irow < kMaxRow; idet++)
+               {
+                 for (Int_t icol = 0; icol < kMaxCol; idet++)
+                   {
+                     fHotFlag[idet][kMaxSMN][kMaxRow][kMaxCol] = 0.;
+                   }
+               }
+           }
+       }
     }
 
 
@@ -233,8 +246,8 @@ void AliPMDCalibGain::ReadTempFile(const Char_t *tempFile)
   
   fpw = fopen(tempFile,"r");
   
-  Float_t smcount, smiso;
-  Float_t cellcount, celliso;
+  Float_t smcount = 0., smiso = 0.;
+  Float_t cellcount = 0., celliso = 0.;
 
 
   for (Int_t idet = 0; idet < kDet; idet++)
@@ -333,8 +346,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 +426,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 +476,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 +504,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 +519,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 +531,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 +578,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++)
                {