]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMDCalibrator.cxx
Include L0 trigger in the trigger maker and the trigger patch object Add monitoring...
[u/mrichter/AliRoot.git] / PMD / AliPMDCalibrator.cxx
index bf2a3a77e39dce6fd09a3c9ba657c5e1cba59bf6..129097907e00929076799406fb14d0100b2839dc 100644 (file)
@@ -123,9 +123,16 @@ AliPMDCalibrator &AliPMDCalibrator::operator=(const AliPMDCalibrator &pmdcalibra
 AliPMDCalibrator::~AliPMDCalibrator()
 {
   // destructor
-  if(fHdetIso)  delete fHdetIso ;
-  if(fHsmIso)  delete fHsmIso ;
-  if(fHadcIso) delete fHadcIso ;
+  for (Int_t i=0; i<kDet; i++)
+    delete fHdetIso[i] ;
+  for (Int_t i=0; i<kDet; i++)
+    for (Int_t j=0; j<kMaxSMN; j++)
+      delete fHsmIso[i][j] ;
+  for (Int_t i=0; i<kDet; i++)
+    for (Int_t j=0; j<kMaxSMN; j++)
+      for (Int_t k=0; k<kMaxRow; k++)
+       for (Int_t l=0; l<kMaxCol; l++)
+         delete fHadcIso[i][j][k][l] ;
   delete fCalibGain;
   delete fCalibPed;
 }
@@ -141,25 +148,25 @@ void AliPMDCalibrator::Exec()
 void AliPMDCalibrator::Init()
 {
   // intializes everything
-  char hname2[kDet];
-  char htitle2[2];
-  char hname[kMaxSMN];
-  char hname24[kMaxSMN];
+  char hname[50];
+  char hname2[50];
+  char hname24[50];
   char hnameiso[120];
   char htitle1[120];
+  char htitle2[120];
   
   for(Int_t d = 0; d < kDet; d++) {
-    sprintf(hname2,"Isolated cell adc for Det Plane %d",d);//sid
+    snprintf(hname2,50,"Isolated cell adc for Det Plane %d",d);
     fHdetIso[d]= new TH1F(hname2,htitle2,100,0,1000);
     for(Int_t i1 = 0; i1 < kMaxSMN; i1++) {
-      sprintf(hname,"det_%d_iso_sm_%2d",d,i1);
-      sprintf(hname24,"det_%d_iso_sm_%2d",d,i1);
+      snprintf(hname,50,"det_%d_iso_sm_%2d",d,i1);
+      snprintf(hname24,50,"det_%d_iso_sm_%2d",d,i1);
       fHsmIso[d][i1]= new TH1F(hname,hname24,100,0,1000);
       for(Int_t j1 = 0; j1 < kMaxRow; j1++) {
        for(Int_t k1 = 0; k1 < kMaxCol; k1++) {
-         sprintf(hnameiso,"Isolated Cell ADC for det_%d_cell_sm%d_row%d_col%d"
+         snprintf(hnameiso,120,"Isolated Cell ADC for det_%d_cell_sm%d_row%d_col%d"
                  ,d,i1,j1,k1);
-         sprintf(htitle1,"Isolated Cell ADC for det_%d_cell_sm%d_row%d_col%d"
+         snprintf(htitle1,120,"Isolated Cell ADC for det_%d_cell_sm%d_row%d_col%d"
                  ,d,i1,j1,k1);
          
          TObject *old=gDirectory->GetList()->FindObject(hnameiso);
@@ -179,18 +186,18 @@ void AliPMDCalibrator::CalculateIsoCell()
   // Calculates the ADC of isolated cell
 
   TObjArray pmdddlcont;
-  const Int_t kDDL           = AliDAQ::NumberOfDdls("PMD");
+
   const Int_t kCellNeighbour = 6;
 
   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 countisocell = 0 ;  //number of isilated cell
-  Int_t isocount;           //number of neighbours with 0 signal
-  Int_t d1[kDet][kMaxSMN][kMaxRow][kMaxCol];
-  Int_t maxhit;
+  Int_t id1 = 0,jd1 = 0;        //neighbour row/col
+  Int_t countisocell = 0 ;      //number of isilated cell
+  Int_t isocount = 0;           //number of neighbours with 0 signal
+  Int_t maxhit = 0;
   Int_t nhit[kDet][kMaxSMN];
+  Int_t d1[kDet][kMaxSMN][kMaxRow][kMaxCol];
   Int_t nhitcell[kDet][kMaxSMN][kMaxRow][kMaxCol];
   
   for(Int_t idet = 0; idet < kDet; idet++)
@@ -238,10 +245,11 @@ void AliPMDCalibrator::CalculateIsoCell()
   while(reader.NextEvent())
     { 
       // New PMD Reader is plugged in
-      for (Int_t iddl = 0; iddl < kDDL; iddl++)
-       {
-         reader.Select("PMD", iddl, iddl);
-         stream.DdlData(iddl,&pmdddlcont);
+       Int_t iddl = -1;
+       while ((iddl = stream.DdlData(&pmdddlcont)) >=0) {
+
+           //reader.Select("PMD", iddl, iddl);
+           //stream.DdlData(iddl,&pmdddlcont);
          Int_t ientries = pmdddlcont.GetEntries();
          for (Int_t ient = 0; ient < ientries; ient++)
            {
@@ -255,14 +263,14 @@ void AliPMDCalibrator::CalculateIsoCell()
              // Pedestal Subtraction
              Int_t   pedmeanrms = 
                fCalibPed->GetPedMeanRms(idet,ismn,irow,icol);
-             Int_t   pedrms1    = (Int_t) pedmeanrms%1000;
+             Int_t   pedrms1    = (Int_t) pedmeanrms%100;
              Float_t pedrms     = (Float_t)pedrms1/10.;
              Float_t pedmean    = (Float_t) (pedmeanrms - pedrms1)/1000.0;
              Float_t isig = isig1 - (pedmean + 3.0*pedrms);
              if (isig>0)
                {
                  d1[idet][ismn][irow][icol] = (Int_t)isig;
-                 nhitcell[idet][ismn][irow][icol] += 1; //sid
+                 nhitcell[idet][ismn][irow][icol] += 1; 
                }
            }//ient loop
          pmdddlcont.Clear();
@@ -361,8 +369,9 @@ void AliPMDCalibrator::CalculateIsoCell()
            {
              for(Int_t k1 = 0; k1 < kMaxCol; k1++)
                {
-                 if(nhitcell[det1][i1][j1][k1]< nhitcut[det1][i1])//sid
-                   {
+                if(nhitcell[det1][i1][j1][k1]> nhitcut[det1][i1]) fGainFact[det1][i1][j1][k1]=-99.0;
+                  if(nhitcell[det1][i1][j1][k1]< nhitcut[det1][i1])
+                    {
                      isoMean[det1][i1][j1][k1]=fHadcIso[det1][i1][j1][k1]->
                        GetMean();
                      if(isoMean[det1][i1][j1][k1]>0.0 && histMean[det1][i1]>0.0)
@@ -370,9 +379,14 @@ void AliPMDCalibrator::CalculateIsoCell()
                          fGainFact[det1][i1][j1][k1]=
                            isoMean[det1][i1][j1][k1]/(histMean[det1][i1]*
                                                     smNormFactor[det1][i1]);
+
                        }
-                   }                              
+                   }   
+                  Float_t gain = fGainFact[det1][i1][j1][k1];
+                  fCalibGain->SetGainFact(det1,i1,j1,k1,gain);
                }
+                          
+                       
            }
        }
     }
@@ -383,9 +397,9 @@ void AliPMDCalibrator::CalculateIsoCell()
 Bool_t AliPMDCalibrator::Store()
 {
   AliCDBManager *man = AliCDBManager::Instance();
-  //man->SetDefaultStorage("local://$ALICE_ROOT");
+  //man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
   if(!man->IsDefaultStorageSet()) return kFALSE;
-  AliCDBId id("PMD/Calib/Gain",0,0);
+  AliCDBId id("PMD/Calib/Gain",0,999999999);
   AliCDBMetaData md;
   md.SetBeamPeriod(0);
   md.SetComment("Test");