calibration function added
authorbnandi <bnandi@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 14 Mar 2006 15:26:02 +0000 (15:26 +0000)
committerbnandi <bnandi@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 14 Mar 2006 15:26:02 +0000 (15:26 +0000)
PMD/AliPMDClusterFinder.cxx
PMD/AliPMDClusterFinder.h
PMD/AliPMDDigitizer.cxx
PMD/AliPMDDigitizer.h

index ef90929..5329388 100644 (file)
 #include "AliPMDrecpoint1.h"
 #include "AliPMDrechit.h"
 #include "AliPMDRawStream.h"
+#include "AliPMDCalibData.h"
+
+#include "AliCDBManager.h"
+#include "AliCDBEntry.h"
 
 
 
@@ -60,6 +64,7 @@ AliPMDClusterFinder::AliPMDClusterFinder():
 //
 // Constructor
 //
+  fCalibData = GetCalibData();
 }
 // ------------------------------------------------------------------------- //
 AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader):
@@ -77,6 +82,7 @@ AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader):
 //
 // Constructor
 //
+  fCalibData = GetCalibData();
 }
 // ------------------------------------------------------------------------- //
 AliPMDClusterFinder::~AliPMDClusterFinder()
@@ -162,6 +168,15 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
          xpos   = pmddigit->GetRow();
          ypos   = pmddigit->GetColumn();
          adc    = pmddigit->GetADC();
+         
+         // CALIBRATION
+         Float_t gain = fCalibData->GetGainFact(det,smn,xpos,ypos);
+         
+        // printf("adc = %d gain = %f\n",adc,gain);
+         
+         adc = adc*gain;
+
+
          //Int_t trno   = pmddigit->GetTrackNumber();
          fCellADC[xpos][ypos] = (Double_t) adc;
        }
@@ -188,8 +203,6 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt)
 
          AddRecPoint(idet,ismn,clusdata);
 
-         // This part will be worked out
-         // BKN
          Int_t ncell = (Int_t) clusdata[3];
          for(Int_t ihit = 0; ihit < ncell; ihit++)
            {
@@ -287,6 +300,15 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
          Int_t col = pmdinput.GetColumn();
          Int_t sig = pmdinput.GetSignal();
          
+         Float_t sig1 = (Float_t) sig;
+
+         // CALIBRATION
+         Float_t gain = fCalibData->GetGainFact(det,smn,row,col);
+         
+       //  printf("sig = %d gain = %f\n",sig,gain);
+         
+         sig = (Int_t) (sig1*gain);
+         
          Int_t indexsmn = 0;
 
          if (indexDDL < 4)
@@ -389,7 +411,7 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
              clusdata[5] = pmdcl->GetClusSigmaY();
 
              AddRecPoint(idet,ismn,clusdata);
-             // BKN
+
              Int_t ncell = (Int_t) clusdata[3];
              for(Int_t ihit = 0; ihit < ncell; ihit++)
                {
@@ -501,6 +523,14 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
          Int_t row = pmdinput.GetRow();
          Int_t col = pmdinput.GetColumn();
          Int_t sig = pmdinput.GetSignal();
+
+         Float_t sig1 = (Float_t) sig;
+         // CALIBRATION
+         Float_t gain = fCalibData->GetGainFact(det,smn,row,col);
+         
+        // printf("sig = %d gain = %f\n",sig,gain);
+         
+         sig = (Int_t) (sig1*gain);
          
          Int_t indexsmn = 0;
 
@@ -605,7 +635,6 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
 
              AddRecPoint(idet,ismn,clusdata);
 
-             // BKN
              Int_t ncell = (Int_t) clusdata[3];
              for(Int_t ihit = 0; ihit < ncell; ihit++)
                {
@@ -729,3 +758,31 @@ void AliPMDClusterFinder::UnLoadClusters()
   fPMDLoader->UnloadRecPoints();
 }
 // ------------------------------------------------------------------------- //
+
+AliPMDCalibData* AliPMDClusterFinder::GetCalibData() const
+{
+  // The run number will be centralized in AliCDBManager,
+  // you don't need to set it here!
+  // Added by ZA
+  AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/Data");
+  
+  if(!entry){
+    AliWarning("Calibration object retrieval failed! Dummy calibration will be used.");
+    
+    // this just remembers the actual default storage. No problem if it is null.
+    AliCDBStorage *origStorage = AliCDBManager::Instance()->GetDefaultStorage();
+    AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
+    
+    entry = AliCDBManager::Instance()->Get("PMD/Calib/Data");
+    
+    // now reset the original default storage to AliCDBManager...
+    AliCDBManager::Instance()->SetDefaultStorage(origStorage);  
+  }
+  
+  AliPMDCalibData *calibdata=0;
+  if (entry) calibdata = (AliPMDCalibData*) entry->GetObject();
+  
+  if (!calibdata)  AliError("No calibration data from calibration database !");
+  
+  return calibdata;
+}
index 8da7ff6..f9a2a21 100644 (file)
@@ -18,6 +18,7 @@ class TTree;
 class AliLoader;
 class AliRunLoader;
 class AliRawReader;
+class AliPMDCalibData;
 
 class AliPMDClusterFinder : public TObject
 {
@@ -42,10 +43,14 @@ class AliPMDClusterFinder : public TObject
   void UnLoad();
   void UnLoadClusters();
 
+  AliPMDCalibData *GetCalibData() const;
+
  protected:
   AliRunLoader *fRunLoader; // Pointer to Run Loader
   AliLoader    *fPMDLoader; // Pointer to specific detector loader
 
+  AliPMDCalibData *fCalibData;  //! calibration data
+
   TTree        *fTreeD;     // Digits tree
   TTree        *fTreeR;     // Reconstructed points
 
@@ -62,7 +67,7 @@ class AliPMDClusterFinder : public TObject
   static const Int_t fgkCol = 96; // Total number of cols in one unitmodule
   Double_t fCellADC[fgkRow][fgkCol]; // Array containing individual cell ADC
 
-  ClassDef(AliPMDClusterFinder,8) // To run PMD clustering
+  ClassDef(AliPMDClusterFinder,9) // To run PMD clustering
 };
 #endif
 
index 780d72e..12eaf51 100644 (file)
@@ -33,8 +33,6 @@
 
 #include "AliLog.h"
 #include "AliRun.h"
-#include "AliPMD.h"
-#include "AliPMDhit.h"
 #include "AliHit.h"
 #include "AliDetector.h"
 #include "AliRunLoader.h"
 #include "AliRunDigitizer.h"
 #include "AliDigitizer.h"
 #include "AliHeader.h"
+#include "AliCDBManager.h"
+#include "AliCDBStorage.h"
+#include "AliCDBEntry.h"
+#include "AliMC.h"
 
+#include "AliPMD.h"
+#include "AliPMDhit.h"
 #include "AliPMDcell.h"
 #include "AliPMDsdigit.h"
 #include "AliPMDdigit.h"
+#include "AliPMDCalibData.h"
 #include "AliPMDDigitizer.h"
-#include "AliMC.h"
+
 
 ClassImp(AliPMDDigitizer)
 
@@ -82,6 +87,7 @@ AliPMDDigitizer::AliPMDDigitizer() :
            }
        }
     }
+  fCalibData = GetCalibData();
 
 }
 //____________________________________________________________________________
@@ -101,6 +107,8 @@ AliPMDDigitizer::AliPMDDigitizer(AliRunDigitizer* manager)
 {
   // ctor which should be used
 
+  fCalibData = GetCalibData();
+
   for (Int_t i = 0; i < fgkTotUM; i++)
     {
       for (Int_t j = 0; j < fgkRow; j++)
@@ -568,11 +576,11 @@ void AliPMDDigitizer::Hits2Digits(Int_t ievt)
              yPos = fPMDHit->Y();
              zPos = fPMDHit->Z();
 
-             edep       = fPMDHit->GetEnergy();
              Int_t vol1 = fPMDHit->GetVolume(1); // Column
              Int_t vol2 = fPMDHit->GetVolume(2); // Row
              Int_t vol3 = fPMDHit->GetVolume(3); // UnitModule
              Int_t vol6 = fPMDHit->GetVolume(6); // SuperModule
+             edep       = fPMDHit->GetEnergy();
 
              // -----------------------------------------//
              // For Super Module 1 & 2                   //
@@ -632,11 +640,11 @@ void AliPMDDigitizer::Hits2Digits(Int_t ievt)
   TrackAssignment2Cell();
   ResetCell();
 
+  Float_t gain1,gain2;
   Float_t adc;
   Float_t deltaE = 0.;
   Int_t detno = 0;
   Int_t trno = 1;
-
   for (Int_t idet = 0; idet < 2; idet++)
     {
       for (Int_t ism = 0; ism < fgkTotUM; ism++)
@@ -647,13 +655,17 @@ void AliPMDDigitizer::Hits2Digits(Int_t ievt)
                {
                  if (idet == 0)
                    {
-                     deltaE = fPRE[ism][jrow][kcol];
+              gain1 =Gain(idet,ism,jrow,kcol);
+  //           cout<<"The gain Factor is"<<gain1<<endl;
+                     deltaE = fPRE[ism][jrow][kcol]*gain1;
                      trno   = fPRETrackNo[ism][jrow][kcol];
                      detno = 0;
                    }
                  else if (idet == 1)
                    {
-                     deltaE = fCPV[ism][jrow][kcol];
+              gain2 =Gain(idet,ism,jrow,kcol);
+   //          cout<<"The Gain factor is"<<gain2<<endl;
+                     deltaE = fCPV[ism][jrow][kcol]*gain2;
                      trno   = fCPVTrackNo[ism][jrow][kcol];
                      detno = 1;
                    }
@@ -831,7 +843,6 @@ void AliPMDDigitizer::MergeSDigits(Int_t filenumber, Int_t troffset)
   Int_t   itrackno, idet, ism;
   Int_t   ixp, iyp;
   Float_t edep;
-  
   Int_t nmodules = (Int_t) treeS->GetEntries();
   AliDebug(1,Form("Number of Modules in the treeS = %d",nmodules));
   AliDebug(1,Form("Track Offset = %d",troffset));
@@ -849,7 +860,6 @@ void AliPMDDigitizer::MergeSDigits(Int_t filenumber, Int_t troffset)
          ixp       = pmdsdigit->GetRow();
          iyp       = pmdsdigit->GetColumn();
          edep      = pmdsdigit->GetCellEdep();
-
          if (idet == 0)
            {
              if (fPRE[ism][ixp][iyp] < edep)
@@ -1193,6 +1203,7 @@ void AliPMDDigitizer::ResetCellADC()
        }
     }
 }
+//------------------------------------------------------
 //____________________________________________________________________________
 
 void AliPMDDigitizer::UnLoad(Option_t *option)
@@ -1216,3 +1227,51 @@ void AliPMDDigitizer::UnLoad(Option_t *option)
       fPMDLoader->UnloadSDigits();
     }
 }
+
+//----------------------------------------------------------------------
+Float_t AliPMDDigitizer::Gain(Int_t det, Int_t smn, Int_t row, Int_t col) const
+{
+  // returns of the gain of the cell
+  // Added this method by ZA
+
+  //cout<<" I am here in gain "<<fCalibData<< "smn,row, col "<<smn
+  //<<" "<<row<<" "<<col<<endl;
+
+  if(!fCalibData) {
+    AliError("No calibration data loaded from CDB!!!");
+    return -1;
+  }
+
+  Float_t GainFact;
+  GainFact = fCalibData->GetGainFact(det,smn,row,col);
+  printf("\t gain=%10.3f\n",GainFact);
+  return GainFact;
+}
+//----------------------------------------------------------------------
+AliPMDCalibData* AliPMDDigitizer::GetCalibData() const
+{
+  // The run number will be centralized in AliCDBManager,
+  // you don't need to set it here!
+  // Added this method by ZA
+  AliCDBEntry  *entry = AliCDBManager::Instance()->Get("PMD/Calib/Data");
+  
+  if(!entry){
+    AliWarning("Calibration object retrieval failed! Dummy calibration will be used.");
+    
+    // this just remembers the actual default storage. No problem if it is null.
+    AliCDBStorage *origStorage = AliCDBManager::Instance()->GetDefaultStorage();
+    AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
+    
+    entry = AliCDBManager::Instance()->Get("PMD/Calib/Data");
+    
+    // now reset the original default storage to AliCDBManager...
+    AliCDBManager::Instance()->SetDefaultStorage(origStorage);  
+  }
+  
+  AliPMDCalibData *calibdata=0;
+  if (entry) calibdata = (AliPMDCalibData*) entry->GetObject();
+  
+  if (!calibdata)  AliError("No calibration data from calibration database !");
+  
+  return calibdata;
+}
index 39b17a8..da1b96b 100644 (file)
@@ -10,7 +10,6 @@
 //                                                     //
 //-----------------------------------------------------//
 
-#include <TObjArray.h>
 
 #include "AliDigitizer.h"
 
@@ -29,10 +28,13 @@ class AliPMDhit;
 class AliHit;
 class AliHeader;
 class AliRunDigitizer;
+class AliCDBManager;
+class AliCDBStorage;
 
 class AliPMDcell;
 class AliPMDsdigit;
 class AliPMDdigit;
+class AliPMDCalibData;
 
 class AliPMDDigitizer:public AliDigitizer
 {
@@ -63,6 +65,10 @@ class AliPMDDigitizer:public AliDigitizer
   void ResetCellADC();
   void UnLoad(Option_t * option);
 
+  Float_t  Gain(Int_t det, Int_t smn, Int_t row, Int_t col) const;
+
+  AliPMDCalibData *GetCalibData() const;
+
  protected:
   AliRunLoader *fRunLoader;  //! Pointer to Run Loader
   AliPMDhit    *fPMDHit;     //! Pointer to specific detector hits
@@ -70,6 +76,8 @@ class AliPMDDigitizer:public AliDigitizer
                              // and Hits containers 
   AliLoader    *fPMDLoader;  //! Pointer to specific detector loader
 
+  AliPMDCalibData *fCalibData;  //! calibration data
+
   TClonesArray *fSDigits;    //! List of summable digits
   TClonesArray *fDigits;     //! List of digits
 
@@ -91,7 +99,7 @@ class AliPMDDigitizer:public AliDigitizer
   Int_t   fCPVTrackNo[fgkTotUM][fgkRow][fgkCol]; //! CPV Array containing track number
 
 
-  ClassDef(AliPMDDigitizer,5)    // To digitize PMD Hits
+  ClassDef(AliPMDDigitizer,6)    // To digitize PMD Hits
 };
 #endif