]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMDRawToSDigits.cxx
Avoid alien plugin limitations:
[u/mrichter/AliRoot.git] / PMD / AliPMDRawToSDigits.cxx
index 1940d75f912d2bf44fafd100afc973ce4f97490d..3dd99bce2d1ee38ec32fa4f9e47b416a367d33c5 100644 (file)
@@ -110,7 +110,7 @@ void AliPMDRawToSDigits::Raw2SDigits(AliRunLoader *runLoader, AliRawReader *rawR
   if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
   treeS->Branch("PMDSDigit", &fSDigits, bufsize); 
 
-  const Int_t kDDL = AliDAQ::NumberOfDdls("PMD");
+//  const Int_t kDDL = AliDAQ::NumberOfDdls("PMD");
   const Int_t kRow = 48;
   const Int_t kCol = 96;
   const Int_t kSMN = 48;
@@ -137,15 +137,10 @@ void AliPMDRawToSDigits::Raw2SDigits(AliRunLoader *runLoader, AliRawReader *rawR
        }
     }
   
-  for (Int_t indexDDL = 0; indexDDL < kDDL; indexDDL++)
-    {
-
-      rawReader->Reset();
-      AliPMDRawStream pmdinput(rawReader);
-      rawReader->Select("PMD", indexDDL, indexDDL);
-      
-      pmdinput.DdlData(indexDDL,&pmdddlcont);
-      
+  AliPMDRawStream pmdinput(rawReader);
+  Int_t indexDDL = -1;
+  while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0)
+  {
       Int_t ientries = pmdddlcont.GetEntries();
       for (Int_t ient = 0; ient < ientries; ient++)
        {
@@ -186,14 +181,14 @@ void AliPMDRawToSDigits::Raw2SDigits(AliRunLoader *runLoader, AliRawReader *rawR
   for ( indexsmn = 0; indexsmn < kSMN; indexsmn++)
     {
 
-      if (indexsmn <= 23)
+      if (indexsmn < 23)
        {
          idet = 0;
          ismn = indexsmn;
        }
       else if (indexsmn > 23)
        {
-         idet = 1;
+         idet = 0;
          ismn = indexsmn - 24;
        }
       for (Int_t irow = 0; irow < kRow; irow++)
@@ -201,15 +196,16 @@ void AliPMDRawToSDigits::Raw2SDigits(AliRunLoader *runLoader, AliRawReader *rawR
          for (Int_t icol = 0; icol < kCol; icol++)
            {
 
-             Int_t trno = -99999;
-             Int_t sig1 = precpvADC[indexsmn][irow][icol];
+             Int_t trno  = -99999;   // when extracted from raw data
+             Int_t trpid = -99999;   // when extracted from raw data
+             Int_t sig1  = precpvADC[indexsmn][irow][icol];
              
              // plug in a function to convert to adc to MeV
              Float_t edep = 0.;
              if (sig1 > 0)
                {
                  AdcToMeV(sig1,edep);
-                 AddSDigit(trno,idet,ismn,irow,icol,edep);
+                 AddSDigit(trno,trpid,idet,ismn,irow,icol,edep);
                }
            } // row
        }     // col
@@ -255,7 +251,7 @@ void AliPMDRawToSDigits::Raw2Digits(AliRunLoader *runLoader, AliRawReader *rawRe
   if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
   treeD->Branch("PMDDigit", &fDigits, bufsize); 
   
-  const Int_t kDDL = AliDAQ::NumberOfDdls("PMD");
+//  const Int_t kDDL = AliDAQ::NumberOfDdls("PMD");
   const Int_t kRow = 48;
   const Int_t kCol = 96;
   const Int_t kSMN = 48;
@@ -281,16 +277,11 @@ void AliPMDRawToSDigits::Raw2Digits(AliRunLoader *runLoader, AliRawReader *rawRe
            }
        }
     }
-  for (Int_t indexDDL = 0; indexDDL < kDDL; indexDDL++)
-    {    
-      rawReader->Reset();
-      AliPMDRawStream pmdinput(rawReader);
-      rawReader->Select("PMD", indexDDL, indexDDL);
-      
-      //pmdinput.DdlData(&pmdddlcont);
-      pmdinput.DdlData(indexDDL,&pmdddlcont);
-      
-      
+
+  AliPMDRawStream pmdinput(rawReader);
+  Int_t indexDDL = -1;
+  while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0)
+  {
       Int_t ientries = pmdddlcont.GetEntries();
       for (Int_t ient = 0; ient < ientries; ient++)
        {
@@ -328,7 +319,7 @@ void AliPMDRawToSDigits::Raw2Digits(AliRunLoader *runLoader, AliRawReader *rawRe
   // Add the digits here
   for (indexsmn = 0; indexsmn < kSMN; indexsmn++)
     {
-      if (indexsmn <= 23)
+      if (indexsmn < 23)
        {
          ismn = indexsmn;
          idet = 0;
@@ -342,13 +333,14 @@ void AliPMDRawToSDigits::Raw2Digits(AliRunLoader *runLoader, AliRawReader *rawRe
        {
          for (Int_t icol = 0; icol < kCol; icol++)
            {
-             Int_t trno = -99999;
-             Int_t sig1 = precpvADC[indexsmn][irow][icol];
+             Int_t trno  = -99999;    // when extracted from raw
+             Int_t trpid = -99999;    // when extracted from raw
+             Int_t sig1  = precpvADC[indexsmn][irow][icol];
              
              // plug in a function to convert to adc to MeV
              if (sig1 > 0)
                {
-                 AddDigit(trno,idet,ismn,irow,icol,sig1);
+                 AddDigit(trno,trpid,idet,ismn,irow,icol,sig1);
                }
            } // row
        }     // col
@@ -377,40 +369,37 @@ void AliPMDRawToSDigits::Raw2Digits(AliRunLoader *runLoader, AliRawReader *rawRe
 
 void AliPMDRawToSDigits::AdcToMeV(Int_t adc, Float_t &edep)
 {
-  // To be implemented, this is just for the test
+  // These constants are from Test Beam 2010
 
-  const Float_t kConstant   = 9.0809;
-  //  const Float_t kErConstant = 1.6763;
-  const Float_t kSlope      = 128.348;
-  //  const Float_t kErSlope    = 0.4703;
+  const Float_t kConstant   = 0.612796;
+  const Float_t kSlope      = 130.158;
 
-
-
-  Float_t adc12bit = (Float_t) adc;
-  edep     = (1000.0/kSlope)*(adc12bit - kConstant);
+  edep     = (1000.0/kSlope)*(adc - kConstant);
 }
 
-//------------------------------------------------------------------------- //
+// ------------------------------------------------------------------------- //
 
-void AliPMDRawToSDigits::AddSDigit(Int_t trnumber, Int_t det, Int_t smnumber, 
+void AliPMDRawToSDigits::AddSDigit(Int_t trnumber, Int_t trpid, Int_t det,
+                                  Int_t smnumber, 
                                   Int_t irow, Int_t icol, Float_t adc)
 {
   // Add SDigit
   //
   if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000);
   TClonesArray &lsdigits = *fSDigits;
-  new(lsdigits[fNsdigit++]) AliPMDsdigit(trnumber,det,smnumber,irow,icol,adc);
+  new(lsdigits[fNsdigit++]) AliPMDsdigit(trnumber,trpid,det,smnumber,irow,icol,adc);
 }
 
 // ------------------------------------------------------------------------- //
-void AliPMDRawToSDigits::AddDigit(Int_t trnumber, Int_t det, Int_t smnumber, 
+void AliPMDRawToSDigits::AddDigit(Int_t trnumber, Int_t trpid, Int_t det,
+                                 Int_t smnumber, 
                                  Int_t irow, Int_t icol, Float_t adc)
 {
   // Add Digit
   //
   if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
   TClonesArray &ldigits = *fDigits;
-  new(ldigits[fNdigit++]) AliPMDdigit(trnumber,det,smnumber,irow,icol,adc);
+  new(ldigits[fNdigit++]) AliPMDdigit(trnumber,trpid,det,smnumber,irow,icol,adc);
 }
 
 // ------------------------------------------------------------------------- //