hot cell search method added
authorbasanta <basanta@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 9 Jun 2009 15:38:45 +0000 (15:38 +0000)
committerbasanta <basanta@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 9 Jun 2009 15:38:45 +0000 (15:38 +0000)
PMD/AliPMDCalibGain.cxx
PMD/AliPMDCalibGain.h

index f59fce1..6200cff 100644 (file)
@@ -24,6 +24,7 @@
 #include "TH1F.h"
 #include "TObjArray.h"
 #include "TTree.h"
+#include "TMath.h"
 
 // --- Standard library ---
 
@@ -42,94 +43,97 @@ AliPMDCalibGain::AliPMDCalibGain():
   fpw(NULL)
 {
   // Standard Constructor
-    for(Int_t idet = 0; idet < kDet; idet++)
+  for(Int_t idet = 0; idet < kDet; idet++)
     {
-     fDetCount[kDet] =0.;
-       for(Int_t ismn = 0; ismn < kMaxSMN; ismn++)
+      for(Int_t ismn = 0; ismn < kMaxSMN; ismn++)
        {
-           fSMIso[idet][ismn]   = 0.;
-           fSMCount[idet][ismn] = 0.;
-           for(Int_t jrow = 0; jrow < kMaxRow; jrow++)
+         fSMIso[idet][ismn]   = 0.;
+         fSMCount[idet][ismn] = 0.;
+         fCountSm[idet][ismn]=0.;
+         fTempnhit[idet][ismn]=0.;
+         fTempnhitSq[idet][ismn]=0.;
+         for(Int_t jrow = 0; jrow < kMaxRow; jrow++)
            {
-               for(Int_t kcol = 0; kcol < kMaxCol; kcol++)
+             for(Int_t kcol = 0; kcol < kMaxCol; kcol++)
                {
-                   fCellIso[idet][ismn][jrow][kcol]   = 0.;
-                   fCellCount[idet][ismn][jrow][kcol] = 0.;
-                   fPedMeanRMS[idet][ismn][jrow][kcol] = 0.;
-
+                 fCellIso[idet][ismn][jrow][kcol]    = 0.;
+                 fCellCount[idet][ismn][jrow][kcol]  = 0.;
+                 fNhitCell[idet][ismn][jrow][kcol]   = 0.;
+                 fPedMeanRMS[idet][ismn][jrow][kcol] = 0.;
+                 fHotFlag[idet][ismn][jrow][kcol]    = 0.;
+                 
                }
            }
        }
     }
-
-
-
+  
 }
 // ------------------------------------------------------------------------ //
 AliPMDCalibGain::AliPMDCalibGain(const AliPMDCalibGain &pmdcalibgain):
   TObject(pmdcalibgain),
   fpw(NULL)
 {
-    for(Int_t idet = 0; idet < kDet; idet++)
+  for(Int_t idet = 0; idet < kDet; idet++)
     {
-     fDetCount[idet] = pmdcalibgain.fDetCount[idet];
-     fDetIso[idet] = pmdcalibgain.fDetIso[idet];
-       for(Int_t ismn = 0; ismn < kMaxSMN; ismn++)
+      for(Int_t ismn = 0; ismn < kMaxSMN; ismn++)
        {
-           fSMIso[idet][ismn] = pmdcalibgain.fSMIso[idet][ismn] ;
-           fSMCount[idet][ismn] = pmdcalibgain.fSMCount[idet][ismn] ;
-           for(Int_t jrow = 0; jrow < kMaxRow; jrow++)
+         fSMIso[idet][ismn] = pmdcalibgain.fSMIso[idet][ismn] ;
+         fSMCount[idet][ismn] = pmdcalibgain.fSMCount[idet][ismn] ;
+         fCountSm[idet][ismn] = pmdcalibgain.fCountSm[idet][ismn];
+         fTempnhit[idet][ismn] = pmdcalibgain.fTempnhit[idet][ismn];
+         fTempnhitSq[idet][ismn] = pmdcalibgain.fTempnhitSq[idet][ismn];
+         for(Int_t jrow = 0; jrow < kMaxRow; jrow++)
            {
-               for(Int_t kcol = 0; kcol < kMaxCol; kcol++)
+             for(Int_t kcol = 0; kcol < kMaxCol; kcol++)
                {
-                 fCellIso[idet][ismn][jrow][kcol]    =
-                   pmdcalibgain.fCellIso[idet][ismn][jrow][kcol];
-                 fCellCount[idet][ismn][jrow][kcol]  =
-                   pmdcalibgain.fCellCount[idet][ismn][jrow][kcol];
-                 fPedMeanRMS[idet][ismn][jrow][kcol] =
-                   pmdcalibgain.fPedMeanRMS[idet][ismn][jrow][kcol];
-
+                 fCellIso[idet][ismn][jrow][kcol] = pmdcalibgain.fCellIso[idet][ismn][jrow][kcol];
+                 fCellCount[idet][ismn][jrow][kcol] = pmdcalibgain.fCellCount[idet][ismn][jrow][kcol];
+                 fNhitCell[idet][ismn][jrow][kcol] = pmdcalibgain.fNhitCell[idet][ismn][jrow][kcol];
+                 fPedMeanRMS[idet][ismn][jrow][kcol] = pmdcalibgain.fPedMeanRMS[idet][ismn][jrow][kcol];
+                 fHotFlag[idet][ismn][jrow][kcol] = pmdcalibgain.fHotFlag[idet][ismn][jrow][kcol];
+                 
                }
            }
        }
     }
-    
+  
 }
 // ------------------------------------------------------------------------ //
 AliPMDCalibGain &AliPMDCalibGain::operator=(const AliPMDCalibGain &pmdcalibgain)
 {
-    if(this != &pmdcalibgain)
+  if(this != &pmdcalibgain)
     {
       this->fpw = pmdcalibgain.fpw;
-       for(Int_t idet = 0; idet < kDet; idet++)
+      for(Int_t idet = 0; idet < kDet; idet++)
        {
-           for(Int_t ismn = 0; ismn < kMaxSMN; ismn++)
+         for(Int_t ismn = 0; ismn < kMaxSMN; ismn++)
            {
-               fSMIso[idet][ismn] = pmdcalibgain.fSMIso[idet][ismn];
-               fSMCount[idet][ismn] = pmdcalibgain.fSMCount[idet][ismn];
-               for(Int_t jrow = 0; jrow < kMaxRow;jrow++)
+             fSMIso[idet][ismn]      = pmdcalibgain.fSMIso[idet][ismn];
+             fSMCount[idet][ismn]    = pmdcalibgain.fSMCount[idet][ismn];
+             fCountSm[idet][ismn]    = pmdcalibgain.fCountSm[idet][ismn];
+             fTempnhit[idet][ismn]   = pmdcalibgain.fTempnhit[idet][ismn];
+             fTempnhitSq[idet][ismn] = pmdcalibgain.fTempnhitSq[idet][ismn];
+             for(Int_t jrow = 0; jrow < kMaxRow;jrow++)
                {
-                   for(Int_t kcol = 0; kcol < kMaxCol; kcol++)
-                     {
-                       fCellIso[idet][ismn][jrow][kcol]  =
-                         pmdcalibgain.fCellIso[idet][ismn][jrow][kcol];
-                       fCellCount[idet][ismn][jrow][kcol]  =
-                         pmdcalibgain.fCellCount[idet][ismn][jrow][kcol];
-                       fPedMeanRMS[idet][ismn][jrow][kcol] = 
-                         pmdcalibgain.fPedMeanRMS[idet][ismn][jrow][kcol];
-
+                 for(Int_t kcol = 0; kcol < kMaxCol; kcol++)
+                   {
+                     fCellIso[idet][ismn][jrow][kcol] = pmdcalibgain.fCellIso[idet][ismn][jrow][kcol];
+                     fCellCount[idet][ismn][jrow][kcol] = pmdcalibgain.fCellCount[idet][ismn][jrow][kcol];
+                     fNhitCell[idet][ismn][jrow][kcol] = pmdcalibgain.fNhitCell[idet][ismn][jrow][kcol]; //za 
+                     fPedMeanRMS[idet][ismn][jrow][kcol] = pmdcalibgain.fPedMeanRMS[idet][ismn][jrow][kcol];
+                     fHotFlag[idet][ismn][jrow][kcol] = pmdcalibgain.fHotFlag[idet][ismn][jrow][kcol];
+                     
                    }
                }
            }
        }
     }
-    return *this;
+  return *this;
 }
 // ------------------------------------------------------------------------ //
 AliPMDCalibGain::~AliPMDCalibGain()
 {
-    // dtor
-
+  // dtor
 }
 
 // ------------------------------------------------------------------------ //
@@ -138,12 +142,12 @@ 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;
-
+  
   TFile *pedfile = new TFile(rootFile);
-
+  
   if(!pedfile)
     {
       printf("ERROR --- NO PEDESTAL (PMD_PED1.root) FILE IS FOUND --- STOP GAIN DA\n");
@@ -176,6 +180,51 @@ Int_t AliPMDCalibGain::ExtractPedestal(const Char_t *rootFile)
 
   return 1;
 }
+//------------------------------------------------------------------------------------------------
+
+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;
+
+  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.;
+    }
+
+
+  TTree *hot =(TTree*)hotmapfile->Get("hot");
+  
+  hot->SetBranchAddress("det",&det);
+  hot->SetBranchAddress("sm",&sm);
+  hot->SetBranchAddress("row",&row);
+  hot->SetBranchAddress("col",&col);
+  hot->SetBranchAddress("flag",&flag);
+  
+  Int_t nentries = (Int_t)hot->GetEntries();
+  
+  for (Int_t ient = 0; ient < nentries; ient++)
+    {
+      hot->GetEntry(ient);
+      fHotFlag[det][sm][row][col] = flag;
+
+      //printf(" HotFlag=%f\n",fHotFlag[det][sm][row][col]);
+    }
+
+  hotmapfile->Close();
+  delete hotmapfile;
+  hotmapfile = 0x0;
+  
+  return 1;
+}
+
+
 // ------------------------------------------------------------------------ //
 
 void AliPMDCalibGain::ReadTempFile(const Char_t *tempFile)
@@ -183,24 +232,17 @@ void AliPMDCalibGain::ReadTempFile(const Char_t *tempFile)
   // Read the variables from the file
   
   fpw = fopen(tempFile,"r");
-
-  Float_t detcount, detiso;
+  
   Float_t smcount, smiso;
   Float_t cellcount, celliso;
 
-  for (Int_t idet = 0; idet < kDet; idet++)
-    {
-      fscanf(fpw,"%d %f %f",&idet,&detcount,&detiso);
-      fDetCount[idet] = detcount;
-      fDetIso[idet]   = detiso;
-    }
 
   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);
-
+         
          fSMCount[idet][ism] = smcount;
          fSMIso[idet][ism]   = smiso;
        }
@@ -215,15 +257,15 @@ 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);
-
+                        &cellcount,&celliso);
+                 
                  fCellCount[idet][ism][irow][icol] = cellcount;
                  fCellIso[idet][ism][irow][icol]   = celliso;
                }
            }
        }
     }
-
+  
   fclose(fpw);
 
 }
@@ -246,12 +288,12 @@ void AliPMDCalibGain::WriteTempFile(const Char_t *tempFile)
 
 
   fpw = fopen(tempFile,"w+");
-
+  
   for (Int_t idet = 0; idet < kDet; idet++)
     {
-      fprintf(fpw,"%d %f %f\n",idet,fDetCount[idet],fDetIso[idet]);
+     // fprintf(fpw,"%d %f %f\n",idet,fDetCount[idet],fDetIso[idet]);
     }
-
+  
   for (Int_t idet = 0; idet < kDet; idet++)
     {
       for (Int_t ism = 0; ism < kMaxSMN; ism++)
@@ -259,7 +301,7 @@ void AliPMDCalibGain::WriteTempFile(const Char_t *tempFile)
          fprintf(fpw,"%d %d %f %f\n",idet,ism, fSMCount[idet][ism],fSMIso[idet][ism]);
        }
     }
-
+  
   for (Int_t idet = 0; idet < kDet; idet++)
     {
       for (Int_t ism = 0; ism < kMaxSMN; ism++)
@@ -275,9 +317,9 @@ void AliPMDCalibGain::WriteTempFile(const Char_t *tempFile)
            }
        }
     }
-
+  
   fclose(fpw);
-
+  
 }
 
 // ------------------------------------------------------------------------ //
@@ -285,7 +327,7 @@ void AliPMDCalibGain::WriteTempFile(const Char_t *tempFile)
 Bool_t AliPMDCalibGain::ProcessEvent(AliRawReader *rawReader, TObjArray *pmdddlcont)
 {
   // Calculates the ADC of isolated cell
-
+  
   const Int_t kDDL           = AliDAQ::NumberOfDdls("PMD");
   const Int_t kCellNeighbour = 6;
   Int_t neibx[6] = {1,0,-1,-1,0,1};
@@ -295,152 +337,226 @@ Bool_t AliPMDCalibGain::ProcessEvent(AliRawReader *rawReader, TObjArray *pmdddlc
   Int_t isocount; //number of neighbours with 0 signal
 
   Float_t d1[kDet][kMaxSMN][kMaxRow][kMaxCol];
-
+  
   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 irow = 0; irow < kMaxRow; irow++)
             {
               for(Int_t icol = 0; icol < kMaxCol; icol++)
                 {
-                  d1[idet][ismn][irow][icol] = 0.;
+                 d1[idet][ismn][irow][icol] = 0.;
                 }
            }
        }
     }
-
+  
   AliPMDRawStream rawStream(rawReader);
 
   Int_t iddl = -1;
-
+  
   Int_t numberofDDLs = 0;
 
-    while ((iddl = rawStream.DdlData(pmdddlcont)) >=0) {
-      numberofDDLs++;
-
-      Int_t ientries = pmdddlcont->GetEntries();
-
-      for (Int_t ient = 0; ient < ientries; ient++)
+  while ((iddl = rawStream.DdlData(pmdddlcont)) >=0) {
+    numberofDDLs++;
+    
+    Int_t ientries = pmdddlcont->GetEntries();
+    
+    for (Int_t ient = 0; ient < ientries; ient++)
       {
-         AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont->UncheckedAt(ient);
-         
-         Int_t idet = pmdddl->GetDetector();
-         Int_t ismn = pmdddl->GetSMN();
-         Int_t mcm = pmdddl->GetMCM();
-         //Int_t ichno = pmdddl->GetChannel();
-         Int_t irow = pmdddl->GetRow();
-         Int_t icol = pmdddl->GetColumn();
-         Int_t isig = pmdddl->GetSignal();
-
-         // This is the protection not to crash the code 
-
-         if(mcm == 0) continue;
-         if (irow < 0 || icol < 0 || irow > 47 || icol > 95) continue;
-
-         // Pedestal subtraction
+       AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont->UncheckedAt(ient);
+       
+       Int_t idet = pmdddl->GetDetector();
+       Int_t ismn = pmdddl->GetSMN();
+       Int_t mcm = pmdddl->GetMCM();
+       //Int_t ichno = pmdddl->GetChannel();
+       Int_t irow = pmdddl->GetRow();
+       Int_t icol = pmdddl->GetColumn();
+       Int_t isig = pmdddl->GetSignal();
+       
+       // This is the protection not to crash the code 
+       
+       if(mcm == 0) continue;
+       if (irow < 0 || icol < 0 || irow > 47 || icol > 95) continue;
+       
+       // Pedestal subtraction
+       if(fHotFlag[idet][ismn][irow][icol] == 1.0) isig = 0;
+       
+       if (isig>0)
+         {
+           d1[idet][ismn][irow][icol] =
+             (Float_t) isig - fPedMeanRMS[idet][ismn][irow][icol];
+           
+           //printf("Signal_ped_subtracted=%f, pedestal=%f\n",d1[idet][ismn][irow][icol]),fPedMeanRMS[idet][ismn][irow][icol];
+           
+           fNhitCell[idet][ismn][irow][icol]++;     //cell hit frequency
+         }
+       
 
-         if (isig>0)
-           {
-             d1[idet][ismn][irow][icol] =
-               (Float_t) isig - fPedMeanRMS[idet][ismn][irow][icol];
-//printf("Signal_ped_subtracted=%f, pedestal=%f\n",d1[idet][ismn][irow][icol]),fPedMeanRMS[idet][ismn][irow][icol];
-           }
       }
-      pmdddlcont->Delete();
-  }
+    pmdddlcont->Delete();
+    }
   
   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++)
-             {
+               {
                  if(d1[idet][ismn][irow][icol] > 0)
-                 {
+                   {
                      isocount = 0;
                      for(Int_t ii = 0; ii < kCellNeighbour; ii++)
-                     {
+                       {
                          id1 = irow + neibx[ii];
                          jd1 = icol + neiby[ii];
                          if(d1[idet][ismn][id1][jd1] == 0)
-                         {
+                           {
                              isocount++;
                              if(isocount == kCellNeighbour)
-                             {
-                                  fDetIso[idet] += d1[idet][ismn][irow][icol];
+                               {
+                                 //fDetIso[idet] += d1[idet][ismn][irow][icol];
                                  fSMIso[idet][ismn] += d1[idet][ismn][irow][icol];
                                  fCellIso[idet][ismn][irow][icol] += d1[idet][ismn][irow][icol];
-                                 fDetCount[idet]++;
+                                 //fDetCount[idet]++;
                                  fSMCount[idet][ismn]++;
                                  fCellCount[idet][ismn][irow][icol]++;
                                  
-                             }
-                         }
-                     }  // neigh cell cond.
-                 }     // d>0 cond.
-             }
-         }
-      }
-  }
-
-  if (numberofDDLs < kDDL)
-      return kFALSE;
+                               }
+                           }
+                       }  // neigh cell cond.
+                   }     // d>0 cond.
+               }
+           }
+       }
+    }
+  
+  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++)
+               {
+                 if(fNhitCell[idet][ismn][irow][icol]>0)
+                   {
+                     fCountSm[idet][ismn]  += 1;
+                     fTempnhit[idet][ismn] += fNhitCell[idet][ismn][irow][icol];
+                     fTempnhitSq[idet][ismn] += fNhitCell[idet][ismn][irow][icol]
+                       *fNhitCell[idet][ismn][irow][icol];
+                   }
+               }
+           }
+       }
+    }
+  
+  if (numberofDDLs < kDDL) return kFALSE;
   return kTRUE;
-
+  
 }
 // ------------------------------------------------------------------------ //
 void AliPMDCalibGain::Analyse(TTree *gaintree)
 {
-    // Calculates the mean
-    Int_t   det, sm, row, col;
-    Float_t gain;
-    Float_t modmean  = 0.;
-    Float_t cellmean = 0.;
-    Float_t detmean =0.;
-
-    gaintree->Branch("det",&det,"det/I");
-    gaintree->Branch("sm",&sm,"sm/I");
-    gaintree->Branch("row",&row,"row/I");
-    gaintree->Branch("col",&col,"col/I");
-    gaintree->Branch("gain",&gain,"gain/F");
-
-    for(Int_t idet = 0; idet < kDet; idet++)
-      {
-       if (fDetCount[idet]>0 )
-         detmean=fDetIso[idet]/fDetCount[idet];
-       for(Int_t ism = 0; ism < kMaxSMN; ism++)
-         {
-           if (fSMCount[idet][ism] > 0)
-             modmean = fSMIso[idet][ism]/fSMCount[idet][ism];
-           for(Int_t irow = 0; irow < kMaxRow; irow++)
-             {
-               for(Int_t icol = 0; icol < kMaxCol; icol++)
-                 {
-                   if (fCellCount[idet][ism][irow][icol] > 0.)
-                      {
-                       cellmean = fCellIso[idet][ism][irow][icol]/fCellCount[idet][ism][irow][icol];
-                     }
-                   det      = idet;
-                   sm       = ism;
-                   row      = irow;
-                   col      = icol;
-                   if (cellmean > 0.0 && fCellCount[idet][ism][irow][icol]>0.)
-                     {
-                       gain = cellmean/detmean;
-                     }
-                    else
-                      {
-                        gain = -1.;
-                     }
-                    //if(fCellCount[idet][ism][irow][icol]>0.) printf("CellCount =%f, gain= %f\n",fCellCount[idet][ism][irow][icol],gain);
-                   gaintree->Fill();
-                 }
-             }
-         }
-      }
-    
+  // Calculates the mean
+  Int_t   det, sm, row, col;
+  Float_t gain;
+  Float_t modmean  = 0.;
+  Float_t cellmean = 0.;
+
+  gaintree->Branch("det",&det,"det/I");
+  gaintree->Branch("sm",&sm,"sm/I");
+  gaintree->Branch("row",&row,"row/I");
+  gaintree->Branch("col",&col,"col/I");
+  gaintree->Branch("gain",&gain,"gain/F");
+  
+  for(Int_t idet = 0; idet < kDet; idet++)
+    {
+      for(Int_t ism = 0; ism < kMaxSMN; ism++)
+       {
+         if (fSMCount[idet][ism] > 0)
+           modmean = fSMIso[idet][ism]/fSMCount[idet][ism];
+         for(Int_t irow = 0; irow < kMaxRow; irow++)
+           {
+             for(Int_t icol = 0; icol < kMaxCol; icol++)
+               {
+                 if (fCellCount[idet][ism][irow][icol] > 0.)
+                   {
+                     cellmean = fCellIso[idet][ism][irow][icol]/fCellCount[idet][ism][irow][icol];
+                   }
+                 det      = idet;
+                 sm       = ism;
+                 row      = irow;
+                 col      = icol;
+                 if (cellmean > 0.0 && fCellCount[idet][ism][irow][icol]>0.)
+                   {
+                     gain = cellmean/modmean;
+                   }
+                 else
+                   {
+                     gain = 0.;
+                   }
+                 //if(fCellCount[idet][ism][irow][icol]>0.) printf("CellCount =%f, gain= %f\n",fCellCount[idet][ism][irow][icol],gain);
+                 gaintree->Fill();
+               }
+           }
+       }
+    }
+  
 }
 // ------------------------------------------------------------------------ //
+void AliPMDCalibGain::AnalyseHotCell(TTree *hottree)
+{
+  // Calculates the mean
+  Int_t   det, sm, row, col;
+  Float_t flag;
+  Float_t meannhit;
+  Float_t meanSqnhit;
+  Float_t sigmanhit,nhitcut;
+  
+  hottree->Branch("det",&det,"det/I");
+  hottree->Branch("sm",&sm,"sm/I");
+  hottree->Branch("row",&row,"row/I");
+  hottree->Branch("col",&col,"col/I");
+  hottree->Branch("flag",&flag,"flag/F");
+  
+  for(Int_t idet = 0; idet < kDet; idet++)
+    {
+      for(Int_t ism = 0; ism < kMaxSMN; ism++)
+       {
+         if (fCountSm[idet][ism]> 0)
+           {
+             meannhit   = fTempnhit[idet][ism]/fCountSm[idet][ism];
+             meanSqnhit = fTempnhitSq[idet][ism]/fCountSm[idet][ism];
+             sigmanhit  = sqrt(meanSqnhit-(meannhit*meannhit));
+             nhitcut    = meannhit + 6.*sigmanhit;
+
+             for(Int_t irow = 0; irow < kMaxRow; irow++)
+               {
+                 for(Int_t icol = 0; icol < kMaxCol; icol++)
+                   {
+                     det      = idet;
+                     sm       = ism;
+                     row      = irow;
+                     col      = icol;
+                     
+                     if(fNhitCell[idet][ism][irow][icol] > nhitcut)
+                       {
+                         flag  = 1.0;
+                       }
+                     else
+                       {
+                         flag = 0.;
+                       }
+                     hottree->Fill();
+                   }
+                 
+               }
+           }
+       }
+    }
+}
+
index d5f0343..86416cb 100644 (file)
@@ -17,34 +17,39 @@ class AliPMDCalibGain : public TObject
 
   virtual ~AliPMDCalibGain() ;           // dtor
 
-  Int_t ExtractPedestal(const Char_t *rootFile);       // pedestal 
-  void  ReadTempFile(const Char_t *tempFile); // read inter file
-  void  WriteTempFile(const Char_t *tempFile);// write inter file
+  Int_t ExtractPedestal(const Char_t *rootFile);    // pedestal 
+  Int_t ExtractHotChannel(const Char_t *rootFile);  // Hotchannel root file 
+  void  ReadTempFile(const Char_t *tempFile);       // read inter file
+  void  WriteTempFile(const Char_t *tempFile);      // write inter file
 
   Bool_t ProcessEvent(AliRawReader *rawReader, TObjArray *pmdddlcont);  //Looks for iso cells
 
   void Analyse(TTree *gaintree);
+  void AnalyseHotCell(TTree *hottree); // finds hot cell
   
  private:
 
   enum
       {
          kDet    = 2,   // Number of Planes
-         kMaxSMN = 24,  // Number of Modules
+         kMaxSMN = 24,  // Number of Modules per plane
          kMaxRow = 48,  // Number of Rows
          kMaxCol = 96   // Number of Columns
       };
 
-  Float_t fDetCount[kDet];                             //counter detector wise
-  Float_t fDetIso[kDet];
   Float_t fSMIso[kDet][kMaxSMN];
   Float_t fSMCount[kDet][kMaxSMN];                     // counter
   Float_t fCellIso[kDet][kMaxSMN][kMaxRow][kMaxCol];   // adc of iso cells
-  Float_t fCellCount[kDet][kMaxSMN][kMaxRow][kMaxCol]; // counter
-
+  Float_t fCellCount[kDet][kMaxSMN][kMaxRow][kMaxCol]; // counter of iso cell
+  Float_t fNhitCell[kDet][kMaxSMN][kMaxRow][kMaxCol];  // counter
   Float_t fPedMeanRMS[kDet][kMaxSMN][kMaxRow][kMaxCol];// Pedestal Mean
-  FILE    *fpw;                            // write the temp file
-
-ClassDef(AliPMDCalibGain,5)        // description 
+  Float_t fHotFlag[kDet][kMaxSMN][kMaxRow][kMaxCol];   // HotChannel Flag 
+   
+  Float_t fCountSm[kDet][kMaxSMN];     // event counter for each module
+  Float_t fTempnhit[kDet][kMaxSMN];    // hit frequency of each module
+  Float_t fTempnhitSq[kDet][kMaxSMN];  // square of hit freq. of each mod.
+  FILE    *fpw;                        // write the temp file
+
+ClassDef(AliPMDCalibGain,6)            // description 
 };
 #endif // ALIPMDCALIBGAIN_H