]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Two end words are added at the end of DDL file in Simulation
authorbasanta <basanta@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 Jun 2008 09:54:19 +0000 (09:54 +0000)
committerbasanta <basanta@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 Jun 2008 09:54:19 +0000 (09:54 +0000)
Bugs fixed in AliPMDRawStream.cxx to read both Simulation file and data
file
ReadNextInt is replaced by ReadNextData in AliPMDRawStream.cxx
Arguments in AliPMDRawStream::DdlData method
Appropriately DdlData is changed in all the classes
pmdClus and pmdtracker objects are defined static in AliPMDReconstructor

15 files changed:
PMD/AliPMDCalibGain.cxx
PMD/AliPMDCalibPedestal.cxx
PMD/AliPMDCalibPedestal.h
PMD/AliPMDCalibrator.cxx
PMD/AliPMDClusterFinder.cxx
PMD/AliPMDDDLRawData.cxx
PMD/AliPMDRawDataRead.C
PMD/AliPMDRawStream.cxx
PMD/AliPMDRawStream.h
PMD/AliPMDRawToSDigits.cxx
PMD/AliPMDReconstructor.cxx
PMD/AliPMDRootDataRead.C
PMD/AliPMDtracker.cxx
PMD/PMDGAINda.cxx
PMD/PMDPEDESTALda.cxx

index 6fc0b6d49ecf6f0c219222a07168e1b45caa8410..07d8bc05edb50d670ee8abbc628bf441279a1ea7 100644 (file)
@@ -129,7 +129,6 @@ Bool_t AliPMDCalibGain::ProcessEvent(AliRawReader *rawReader)
   Int_t isocount; //number of neighbours with 0 signal
 
   Float_t d1[kDet][kMaxSMN][kMaxRow][kMaxCol];
-  Bool_t  streamout = kFALSE;
 
   for(Int_t idet = 0; idet < kDet; idet++)
     {
@@ -147,11 +146,13 @@ Bool_t AliPMDCalibGain::ProcessEvent(AliRawReader *rawReader)
 
   AliPMDRawStream rawStream(rawReader);
 
-  for (Int_t iddl = 0; iddl < kDDL; iddl++)
-  {
-      rawReader->Select("PMD", iddl, iddl);
-      streamout = rawStream.DdlData(iddl,&pmdddlcont);
-      
+  Int_t iddl;
+
+  Int_t numberofDDLs = 0;
+
+    while ((iddl = rawStream.DdlData(&pmdddlcont)) >=0) {
+      numberofDDLs++;
+
       Int_t ientries = pmdddlcont.GetEntries();
       for (Int_t ient = 0; ient < ientries; ient++)
       {
@@ -209,7 +210,11 @@ Bool_t AliPMDCalibGain::ProcessEvent(AliRawReader *rawReader)
       }
       
   }
-  return streamout;
+
+  if (numberofDDLs < kDDL)
+      return kFALSE;
+  return kTRUE;
+
 }
 // ------------------------------------------------------------------------ //
 void AliPMDCalibGain::Analyse(TTree *gaintree)
index e7d6239ee16cc86a32674fff5779daec7279ec72..cafd40374e471d23d4182950c6b313b754b230a2 100644 (file)
@@ -31,7 +31,7 @@
 #include "AliRawReader.h"
 #include "AliPMDRawStream.h"
 #include "AliPMDddldata.h"
-
+#include "AliBitPacking.h"
 //header file
 #include "AliPMDCalibPedestal.h"
 
@@ -57,6 +57,7 @@ AliPMDCalibPedestal::AliPMDCalibPedestal() :
                    fPedVal[i][j][k][l]   = 0.;
                    fPedValSq[i][j][k][l] = 0.;
                    fPedCount[i][j][k][l] = 0.;
+                   fPedChain[i][j][k][l] = 0;
                }
            }
        }
@@ -82,6 +83,7 @@ AliPMDCalibPedestal::AliPMDCalibPedestal(const AliPMDCalibPedestal &ped) :
                    fPedVal[i][j][k][l]   = ped.fPedVal[i][j][k][l];
                    fPedValSq[i][j][k][l] = ped.fPedValSq[i][j][k][l];
                    fPedCount[i][j][k][l] = ped.fPedCount[i][j][k][l];
+                   fPedChain[i][j][k][l] = ped.fPedChain[i][j][k][l];
                }
            }
        }
@@ -115,36 +117,51 @@ Bool_t AliPMDCalibPedestal::ProcessEvent(AliRawReader *rawReader)
 
     const Int_t kDDL = AliDAQ::NumberOfDdls("PMD");
 
+    UInt_t busmcmch;
+    UInt_t pbus, mcm, chno;
+
     AliPMDRawStream rawStream(rawReader);
 
     TObjArray pmdddlcont;
-    Bool_t streamout = kTRUE;
+    Int_t iddl = -1;
+    Int_t numberofDDLs = 0;
 
-    for (Int_t iddl = 0; iddl < kDDL; iddl++)
-    {
-       rawReader->Select("PMD", iddl, iddl);
-       //cout << reader.GetDataSize() << endl;
-       streamout = rawStream.DdlData(iddl, &pmdddlcont);
-       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();
+      //printf("iddl = %d ientries = %d\n",iddl, ientries);
+      for (Int_t ient = 0; ient < ientries; ient++)
        {
            AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
            
            Int_t det = pmdddl->GetDetector();
            Int_t smn = pmdddl->GetSMN();
-           //Int_t mcm = pmdddl->GetMCM();
-           //Int_t chno = pmdddl->GetChannel();
            Int_t row = pmdddl->GetRow();
            Int_t col = pmdddl->GetColumn();
            Float_t sig = (Float_t) pmdddl->GetSignal();
 
+           pbus = (UInt_t) pmdddl->GetPatchBusId();
+           mcm  = (UInt_t) pmdddl->GetMCM();
+           chno = (UInt_t) pmdddl->GetChannel();
+
+           busmcmch = 0;
+           AliBitPacking::PackWord(chno,busmcmch,0,7);
+           AliBitPacking::PackWord(mcm,busmcmch,8,15);
+           AliBitPacking::PackWord(pbus,busmcmch,16,23);
+
+
+           if (fPedChain[det][smn][row][col] == 0)
+               fPedChain[det][smn][row][col]   = busmcmch;
+
            fPedVal[det][smn][row][col]   += sig;
            fPedValSq[det][smn][row][col] += sig*sig;
            fPedCount[det][smn][row][col]++;
        }
        pmdddlcont.Clear();
     }
-    return streamout;
+    if (numberofDDLs < kDDL)
+      return kFALSE;
+    return kTRUE;
 }
 //_____________________________________________________________________
 
@@ -153,11 +170,23 @@ void AliPMDCalibPedestal::Analyse(TTree *pedtree)
     //
     //  Calculate pedestal Mean and RMS
     //
+
+    FILE *fpw0 = fopen("pedestal2304.ped","w");
+    FILE *fpw1 = fopen("pedestal2305.ped","w");
+    FILE *fpw2 = fopen("pedestal2306.ped","w");
+    FILE *fpw3 = fopen("pedestal2307.ped","w");
+    FILE *fpw4 = fopen("pedestal2308.ped","w");
+    FILE *fpw5 = fopen("pedestal2309.ped","w");
+
+    UInt_t  busmcmch;
+    UInt_t  pbus, mcm, chno;
+    Int_t   ddlno;
     Int_t   det, sm, row, col;
     Float_t mean, rms;
     Float_t meansq, diff;
 
 
+
     pedtree->Branch("det",&det,"det/I");
     pedtree->Branch("sm",&sm,"sm/I");
     pedtree->Branch("row",&row,"row/I");
@@ -169,6 +198,7 @@ void AliPMDCalibPedestal::Analyse(TTree *pedtree)
     {
        for (int ism = 0; ism < kMaxSMN; ism++)
        {
+           ConvertDDL(idet,ism,ddlno);
            for (int irow = 0; irow < kMaxRow; irow++)
            {
                for (int icol = 0; icol < kMaxCol; icol++)
@@ -177,11 +207,14 @@ void AliPMDCalibPedestal::Analyse(TTree *pedtree)
                    sm   = ism;
                    row  = irow;
                    col  = icol;
+                   mean = 0.;
+                   rms  = 0.;
+
                    if (fPedCount[idet][ism][irow][icol] > 0)
                    {
-                       mean = fPedVal[idet][ism][irow][icol]/fPedCount[idet][ism][irow][icol];
+                     mean = fPedVal[idet][ism][irow][icol]/fPedCount[idet][ism][irow][icol];
 
-                       meansq = fPedValSq[idet][ism][irow][icol]/fPedCount[idet][ism][irow][icol];
+                     meansq = fPedValSq[idet][ism][irow][icol]/fPedCount[idet][ism][irow][icol];
 
                        diff = meansq - mean*mean;
                        if (diff > 0.)
@@ -192,12 +225,97 @@ void AliPMDCalibPedestal::Analyse(TTree *pedtree)
                        {
                            rms = 0.;
                        }
-                   }
+                       pedtree->Fill();
+
+                       busmcmch = fPedChain[idet][ism][irow][icol];
 
-                   pedtree->Fill();
+                       chno = busmcmch & 0x00FF;
+                       mcm  = (busmcmch >> 8) & 0x00FF;
+                       pbus = (busmcmch >> 16) & 0x00FF;
+                       
+                       if (ddlno == 0)
+                       {
+                           fprintf(fpw0,"%d %d %d %f %f\n",
+                                   pbus, mcm, chno, mean, rms);
+                       }
+                       else if (ddlno == 1)
+                       {
+                           fprintf(fpw1,"%d %d %d %f %f\n",
+                                   pbus, mcm, chno, mean, rms);
+                       }
+                       else if (ddlno == 2)
+                       {
+                           fprintf(fpw2,"%d %d %d %f %f\n",
+                                   pbus, mcm, chno, mean, rms);
+                       }
+                       else if (ddlno == 3)
+                       {
+                           fprintf(fpw3,"%d %d %d %f %f\n",
+                                   pbus, mcm, chno, mean, rms);
+                       }
+                       else if (ddlno == 4)
+                       {
+                           fprintf(fpw4,"%d %d %d %f %f\n",
+                                   pbus, mcm, chno, mean, rms);
+                       }
+                       else if (ddlno == 5)
+                       {
+                           fprintf(fpw5,"%d %d %d %f %f\n",
+                                   pbus, mcm, chno, mean, rms);
+                       }
+                       
+                   }
+                   
                }
            }
        }
     }
+    
+    fclose(fpw0);
+    fclose(fpw1);
+    fclose(fpw2);
+    fclose(fpw3);
+    fclose(fpw4);
+    fclose(fpw5);
 }
-//_____________________________________________________________________
+
+
+// -------------------------------------------------------------------
+
+void AliPMDCalibPedestal::ConvertDDL(Int_t det, Int_t smn, Int_t &ddlno)
+{
+// Given the plane number and serial module number, ddlno is calculated
+
+    if (det == 0)
+    {
+       if (smn <= 5)
+       {
+           ddlno = 0;
+       }
+       else if (smn > 5 && smn <= 11)
+       {
+           ddlno = 1;
+       }
+       else if (smn > 11 && smn <= 17)
+       {
+           ddlno = 2;
+       }
+       else if (smn > 17 && smn <= 23)
+       {
+           ddlno = 3;
+       }
+    }
+    else if (det == 1)
+    {
+       if (smn <= 5 || (smn >= 18 && smn <=23))
+       {
+           ddlno = 4;
+       }
+       else if (smn >= 6 && smn <= 17)
+       {
+           ddlno = 5;
+       }
+    }
+
+}
+
index 861c557dad07c8333a50ff6156c9a68232f537ed..60d401cae167775e32543292b77d651a39655762 100644 (file)
@@ -19,6 +19,7 @@ public:
 
   Bool_t ProcessEvent(AliRawReader  *rawReader);
   void   Analyse(TTree *pedtree);
+  void   ConvertDDL(Int_t det, Int_t smn, Int_t &ddlno);
 
 private:
 
@@ -33,9 +34,10 @@ private:
   Float_t fPedVal[kDet][kMaxSMN][kMaxRow][kMaxCol];
   Float_t fPedValSq[kDet][kMaxSMN][kMaxRow][kMaxCol];
   Float_t fPedCount[kDet][kMaxSMN][kMaxRow][kMaxCol];
+  UInt_t  fPedChain[kDet][kMaxSMN][kMaxRow][kMaxCol];
   
 
-  ClassDef(AliPMDCalibPedestal,3)
+  ClassDef(AliPMDCalibPedestal,4)
 };
 
 
index bf2a3a77e39dce6fd09a3c9ba657c5e1cba59bf6..52030d7017364fbf1685158f87f16089a5218b6c 100644 (file)
@@ -123,7 +123,7 @@ AliPMDCalibrator &AliPMDCalibrator::operator=(const AliPMDCalibrator &pmdcalibra
 AliPMDCalibrator::~AliPMDCalibrator()
 {
   // destructor
-  if(fHdetIso)  delete fHdetIso ;
+  if(fHdetIso) delete fHdetIso ;
   if(fHsmIso)  delete fHsmIso ;
   if(fHadcIso) delete fHadcIso ;
   delete fCalibGain;
@@ -179,7 +179,7 @@ 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};
@@ -238,10 +238,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++)
            {
index 46e4531f62a3dfa2a57fb11fbdb75fcff3eba689..07766c891fd1e66cbfd8b79dc2bd2b82da376194 100644 (file)
@@ -124,21 +124,30 @@ AliPMDClusterFinder::~AliPMDClusterFinder()
   // Destructor
   if (fDigits)
     {
-      fDigits->Delete();
-      delete fDigits;
-      fDigits=0;
+       /*
+         fDigits->Delete();
+         delete fDigits;
+         fDigits=0;
+       */
+       fDigits->Clear();
     }
   if (fRecpoints)
     {
-      fRecpoints->Delete();
-      delete fRecpoints;
-      fRecpoints=0;
+      fRecpoints->Clear();
+      /*
+       fRecpoints->Delete();
+       delete fRecpoints;
+       fRecpoints=0;
+      */
     }
   if (fRechits)
     {
-      fRechits->Delete();
-      delete fRechits;
-      fRechits=0;
+      fRechits->Clear();
+      /*
+       fRechits->Delete();
+       delete fRechits;
+       fRechits=0;
+      */
     }
 }
 // ------------------------------------------------------------------------- //
@@ -401,16 +410,17 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
 
   TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize); 
 
-  const Int_t kDDL = AliDAQ::NumberOfDdls("PMD");
   const Int_t kRow = 48;
   const Int_t kCol = 96;
 
   Int_t idet = 0;
   Int_t iSMN = 0;
 
+  Int_t indexDDL = -1;
+  AliPMDRawStream pmdinput(rawReader);
 
-  for (Int_t indexDDL = 0; indexDDL < kDDL; indexDDL++)
-    {
+  while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0)
+  {
       if (indexDDL < 4)
        {
          iSMN = 6;
@@ -437,12 +447,6 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
            }
        }
       ResetCellADC();
-      rawReader->Reset();
-      AliPMDRawStream pmdinput(rawReader);
-
-      rawReader->Select("PMD", indexDDL, indexDDL);
-
-      pmdinput.DdlData(indexDDL,&pmdddlcont);
 
       Int_t indexsmn = 0;
       Int_t ientries = pmdddlcont.GetEntries();
@@ -602,6 +606,7 @@ void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader,
        }
       for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i];
       delete precpvADC;
+
     } // DDL Loop
   
   ResetCellADC();
@@ -641,15 +646,17 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
   TBranch *branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize); 
   TBranch *branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize); 
 
-  const Int_t kDDL = AliDAQ::NumberOfDdls("PMD");
   const Int_t kRow = 48;
   const Int_t kCol = 96;
 
   Int_t idet = 0;
   Int_t iSMN = 0;
-  
-  for (Int_t indexDDL = 0; indexDDL < kDDL; indexDDL++)
-    {
+
+  AliPMDRawStream pmdinput(rawReader);
+  Int_t indexDDL = -1;
+
+  while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0) {
+
       if (indexDDL < 4)
        {
          iSMN = 6;
@@ -676,11 +683,7 @@ void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader)
            }
        }
       ResetCellADC();
-      rawReader->Reset();
-      rawReader->Select("PMD", indexDDL, indexDDL);
 
-      AliPMDRawStream pmdinput(rawReader);
-      pmdinput.DdlData(indexDDL,&pmdddlcont);
     
       Int_t indexsmn = 0;
       Int_t ientries = pmdddlcont.GetEntries();
index 6b037d5d141b1e3ac0ae08cb2fafb3366eff1a59..7b7e107f1a058653f27538fe08b2b16d29b94dd0 100644 (file)
@@ -179,6 +179,8 @@ void AliPMDDDLRawData::WritePMDRawData(TTree *treeD)
 
       Int_t dspBlockARDL    = 0;
       Int_t dspBlockBRDL    = 0;
+      Int_t remainder       = 0;
+
 
       for (Int_t i = 0; i < 5; i++)
        {
@@ -187,7 +189,7 @@ void AliPMDDDLRawData::WritePMDRawData(TTree *treeD)
          if (dsp[ieven] > 0)
            {
              dspBlockARDL += dsp[ieven];
-             Int_t remainder = dsp[ieven]%2;
+             remainder = dsp[ieven]%2;
              if (remainder == 1)
                {
                  dspBlockARDL++;
@@ -196,14 +198,14 @@ void AliPMDDDLRawData::WritePMDRawData(TTree *treeD)
          if (dsp[iodd] > 0)
            {
              dspBlockBRDL += dsp[iodd];
-             Int_t remainder = dsp[ieven]%2;
+             remainder = dsp[iodd]%2;
              if (remainder == 1)
                {
-                 dspBlockARDL++;
+                 dspBlockBRDL++;
                }
            }
        }
-      
+
       // Start writing the DDL file
 
       AliPMDBlockHeader blHeader;
@@ -219,6 +221,9 @@ void AliPMDDDLRawData::WritePMDRawData(TTree *treeD)
       UInt_t dspHeaderWord[10];
       UInt_t patchBusHeaderWord[4];
       Int_t  iskip[5];
+      UInt_t ddlEndWord[2] = {0xDEADFACE, 0xDEADFACE};
+
+      Int_t bknJunk = 0;
 
 
       for (Int_t iblock = 0; iblock < 2; iblock++)
@@ -278,19 +283,21 @@ void AliPMDDDLRawData::WritePMDRawData(TTree *treeD)
                {
                  dspHeaderWord[i] = 0;
                }
-             Int_t remainder = dspRDL%2;
+             remainder = dspRDL%2;
              if (remainder == 1) dspRDL++;
 
              dspHeaderWord[1] = dspRDL + kdspHLen;
              dspHeaderWord[2] = dspRDL;
              dspHeaderWord[3] = dspno;
              if (remainder == 1) dspHeaderWord[8] = 1; // setting the padding word
+
+
              outfile->WriteBuffer((char*)dspHeaderWord,kdspHLen*sizeof(UInt_t));
 
              for (Int_t ibus = 0; ibus < 5; ibus++)
                {
                  // Patch Bus Header
-                 // BKN - just added 1
+
                  Int_t busno = iskip[idsp] + ibus + 1;
                  Int_t patchbusRDL = contentsBus[busno];
 
@@ -312,6 +319,7 @@ void AliPMDDDLRawData::WritePMDRawData(TTree *treeD)
 
                  outfile->WriteBuffer((char*)patchBusHeaderWord,4*sizeof(UInt_t));
 
+                 bknJunk += patchbusRDL;
 
                  for (Int_t iword = 0; iword < patchbusRDL; iword++)
                    {
@@ -332,6 +340,9 @@ void AliPMDDDLRawData::WritePMDRawData(TTree *treeD)
            }
        }
 
+      // Write two extra word at the end of each DDL file
+      outfile->WriteBuffer((char*)ddlEndWord,2*sizeof(UInt_t));
+
       // Write real data header
       // take the pointer to the beginning of the data header
       // write the total number of words per ddl and bring the
index dfe11ded43ed74fc135f258b7fd5bc255cee20e9..160a60db09f12b03e04edb4ded471aa365ae1a41 100644 (file)
@@ -4,18 +4,21 @@ void AliPMDRawDataRead(Int_t iEvent)
 {
   TObjArray pmdddlcont;
   
+  TH2F *h2 = new TH2F("h2"," ",100,-100.,100.,100,-100.,100.);
+  Float_t xx, yy;
+  Int_t xpad, ypad;
+
+  AliPMDUtility cc;
+
   for(Int_t ievt = 0; ievt < iEvent; ievt++)
     {
       AliRawReaderFile reader(ievt);
       AliPMDRawStream stream(&reader);
       
-      Int_t indexDDL = 0;
-      for (Int_t iddl = 0; iddl < 6; iddl++)
+      Int_t iddl = -1;
+      while ((iddl = stream.DdlData(&pmdddlcont)) >=0)
        {
-         
-         reader.Select("PMD", iddl, iddl);
-         //cout << reader.GetDataSize() << endl;
-         stream.DdlData(indexDDL,&pmdddlcont);
+           //cout << " inside the macro DDLNO = " << iddl << endl; 
          Int_t ientries = pmdddlcont.GetEntries();
          for (Int_t ient = 0; ient < ientries; ient++)
            {
@@ -28,12 +31,34 @@ void AliPMDRawDataRead(Int_t iEvent)
              Int_t row = pmdddl->GetRow();
              Int_t col = pmdddl->GetColumn();
              Int_t sig = pmdddl->GetSignal();
-             cout<<sig<<endl;
-             
+             //cout<<sig<<endl;
+             if(smn <12)
+             {
+                 xpad = col;
+                 ypad = row;
+             }
+             else if(smn >=12 && smn < 24)
+             {
+                 xpad = row;
+                 ypad = col;
+             }
+   
+             if (det == 1)
+             {
+                 // Draw only for PRE plane
+                 cc.RectGeomCellPos(smn,xpad,ypad,xx,yy);
+
+                 h2->Fill(xx,yy);
+             }
+
+
+
            }
          pmdddlcont.Clear();
          
        }
 
     }
-}
\ No newline at end of file
+
+  h2->Draw();
+}
index 008a6f899bc0659bf6626c32c8ca73858f7266fa..3a6a058da2fb6088bcee5ac68e8face802d9f421 100644 (file)
@@ -44,17 +44,22 @@ ClassImp(AliPMDRawStream)
 
 //_____________________________________________________________________________
 AliPMDRawStream::AliPMDRawStream(AliRawReader* rawReader) :
-  fRawReader(rawReader)
+    fRawReader(rawReader),
+    fData(NULL),
+    fPosition(-1)
 {
 // create an object to read PMD raw digits
 
+  fRawReader->Reset();
   fRawReader->Select("PMD");
 }
 
 //_____________________________________________________________________________
 AliPMDRawStream::AliPMDRawStream(const AliPMDRawStream& stream) :
   TObject(stream),
-  fRawReader(NULL)
+  fRawReader(NULL),
+  fData(NULL),
+  fPosition(-1)
 {
 // copy constructor
 
@@ -81,35 +86,30 @@ AliPMDRawStream::~AliPMDRawStream()
 
 //_____________________________________________________________________________
 
-Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
+Int_t AliPMDRawStream::DdlData(TObjArray *pmdddlcont)
 {
 // read the next raw digit
 // returns kFALSE if there is no digit left
 
+    
+
+    Int_t iddl = -1;
 
   AliPMDddldata *pmdddldata;
 
-  if (!fRawReader->ReadHeader()) return kFALSE;
-  Int_t  iddl  = fRawReader->GetDDLID();
+  if (!fRawReader->ReadHeader()) return iddl;
+
+  iddl           = fRawReader->GetDDLID();
   Int_t dataSize = fRawReader->GetDataSize();
   Int_t totaldataword = dataSize/4;
 
-  if (dataSize <= 0) return kFALSE;
-  if (indexDDL != iddl)
-    {
-      AliWarning("Mismatch in the DDL index");
-      fRawReader->AddFatalErrorLog(kDDLIndexMismatch);
-      return kFALSE;
-    }
+  if (dataSize <= 0) return -1;
 
-  UInt_t *buffer;
-  buffer = new UInt_t[totaldataword];
   UInt_t data;
-  for (Int_t i = 0; i < totaldataword; i++)
-    {
-      fRawReader->ReadNextInt(data);
-      buffer[i] = data;
-    }
+
+  fRawReader->ReadNextData(fData);
+
+  fPosition = 0;
 
   // --- Open the mapping file
 
@@ -141,6 +141,7 @@ Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
 
   ifstream infile;
   infile.open(fileName.Data(), ios::in); // ascii file
+
   if(!infile) {
     AliError(Form("Could not read the mapping file for DDL No = %d",iddl));
     fRawReader->AddFatalErrorLog(kNoMappingFile,Form("ddl=%d",iddl));
@@ -210,11 +211,11 @@ Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
   Int_t dspHeaderWord[10];
   Int_t pbusHeaderWord[4];
 
-  Int_t ilowLimit       = 0;
-  Int_t iuppLimit       = 0;
-  Int_t blRawDataLength = 0;
-  Int_t iwordcount      = 0;
-
+  Int_t ilowLimit        = 0;
+  Int_t iuppLimit        = 0;
+  Int_t blRawDataLength  = 0;
+  Int_t dspRawDataLength = 0;
+  Int_t iwordddl         = 2;
 
   for (Int_t iblock = 0; iblock < 2; iblock++)
     {
@@ -223,24 +224,37 @@ Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
 
       for (Int_t i = ilowLimit; i < iuppLimit; i++)
        {
-         blHeaderWord[i-ilowLimit] = (Int_t) buffer[i];
+           iwordddl++;
+
+           blHeaderWord[i-ilowLimit] = (Int_t) GetNextWord();
        }
 
       blockHeader.SetHeader(blHeaderWord);
-
       blRawDataLength = blockHeader.GetRawDataLength();
 
+      if (iwordddl == totaldataword) continue;
+
+      Int_t iwordblk = 0;
+
       for (Int_t idsp = 0; idsp < 5; idsp++)
        {
+
+
          ilowLimit = iuppLimit;
          iuppLimit = ilowLimit + kdspHLen;
 
          for (Int_t i = ilowLimit; i < iuppLimit; i++)
            {
-             iwordcount++;
-             dspHeaderWord[i-ilowLimit] = (Int_t) buffer[i];
+               iwordddl++;
+               iwordblk++;
+               dspHeaderWord[i-ilowLimit] = (Int_t) GetNextWord();
            }
          dspHeader.SetHeader(dspHeaderWord);
+         dspRawDataLength = dspHeader.GetRawDataLength();
+
+         if (iwordddl == totaldataword) continue;
+
+         Int_t iworddsp = 0;
 
          for (ibus = 0; ibus < 5; ibus++)
            {
@@ -249,9 +263,12 @@ Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
 
              for (Int_t i = ilowLimit; i < iuppLimit; i++)
                {
-                 iwordcount++;
-                 pbusHeaderWord[i-ilowLimit] = (Int_t) buffer[i];
+                   iwordddl++;
+                   iwordblk++;
+                   iworddsp++;
+                 pbusHeaderWord[i-ilowLimit] = (Int_t) GetNextWord();
                }
+
              pbusHeader.SetHeader(pbusHeaderWord);
              Int_t rawdatalength = pbusHeader.GetRawDataLength();
              Int_t pbusid = pbusHeader.GetPatchBusId();
@@ -261,11 +278,15 @@ Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
 
              Int_t imodule = moduleNo[pbusid];
 
+             if (iwordddl == totaldataword) continue;
 
              for (Int_t iword = ilowLimit; iword < iuppLimit; iword++)
                {
-                 iwordcount++;
-                 data = buffer[iword];
+                   iwordddl++;
+                   iwordblk++;
+                   iworddsp++;
+                   data = 0;
+                   data = GetNextWord();
 
                  Int_t isig =  data & 0x0FFF;
                  Int_t ich  = (data >> 12) & 0x003F;
@@ -304,21 +325,30 @@ Bool_t AliPMDRawStream::DdlData(Int_t indexDDL, TObjArray *pmdddlcont)
                  
                } // data word loop
 
-             if (iwordcount == blRawDataLength) break;
+             if (iwordddl == totaldataword) break;
+
+             if (iworddsp == dspRawDataLength) break; // raw data
 
            } // patch bus loop
 
-         if (dspHeader.GetPaddingWord() == 1) iuppLimit++;
-         if (iwordcount == blRawDataLength) break;
+         if (dspHeader.GetPaddingWord() == 1)
+         {
+             iuppLimit++;
+             iwordddl++;
+             iwordblk++;
+             iworddsp++;
+             data = GetNextWord();
+         }
+
+         if (iwordblk == blRawDataLength) break; // for raw data
 
        } // end of DSP
-      if (iwordcount == blRawDataLength) break;
 
     } // end of BLOCK
   
-  delete [] buffer;
+//  delete [] buffer;
 
-  return kTRUE;
+  return iddl;
 }
 //_____________________________________________________________________________
 void AliPMDRawStream::GetRowCol(Int_t ddlno, Int_t smn, Int_t pbusid,
@@ -329,8 +359,6 @@ void AliPMDRawStream::GetRowCol(Int_t ddlno, Int_t smn, Int_t pbusid,
 {
 // decode: ddlno, patchbusid, mcmno, chno -> um, row, col
 
-
-
   UInt_t iCh[64];
 
   static const UInt_t kChDdl01[64] = { 9, 6, 5, 10, 1, 2, 0, 3,
@@ -539,7 +567,7 @@ void AliPMDRawStream::TransformH2S(Int_t smn, Int_t &row, Int_t &col) const
   col = icolnew;
 }
 //_____________________________________________________________________________
-Int_t AliPMDRawStream::ComputeParity(Int_t data)
+Int_t AliPMDRawStream::ComputeParity(UInt_t data)
 {
 // Calculate the parity bit
 
@@ -556,3 +584,19 @@ Int_t AliPMDRawStream::ComputeParity(Int_t data)
 }
 
 //_____________________________________________________________________________
+UInt_t AliPMDRawStream::GetNextWord()
+{
+    // Returns the next 32 bit word
+    // inside the raw data payload.
+
+    if (!fData || fPosition < 0) AliFatal("Raw data payload buffer is not yet initialized !");
+
+    UInt_t word = 0;
+    word |= fData[fPosition++];
+    word |= fData[fPosition++] << 8;
+    word |= fData[fPosition++] << 16;
+    word |= fData[fPosition++] << 24;
+
+    return word;
+}
+
index 2d9f42c2cae5a65caf986925aa09d1f692627d40..3819800bab2e1f0621cbcc55d45269df074e87e6 100644 (file)
@@ -21,7 +21,7 @@ class AliPMDRawStream: public TObject {
     AliPMDRawStream(AliRawReader* rawReader);
     virtual ~AliPMDRawStream();
 
-    Bool_t DdlData(Int_t indexDDL, TObjArray *pmdddlcont);
+    Int_t DdlData(TObjArray *pmdddlcont);
 
     enum {kDDLOffset = 0xC00};      // offset for DDL numbers
 
@@ -43,12 +43,14 @@ class AliPMDRawStream: public TObject {
     void             ConvertDDL2SMN(Int_t iddl, Int_t imodule,
                                    Int_t &smn, Int_t &detector) const;
     void             TransformH2S(Int_t smn, Int_t &row, Int_t &col) const;
-    int              ComputeParity(Int_t data);
+    Int_t            ComputeParity(UInt_t data1);
+    UInt_t           GetNextWord();
 
     AliRawReader*    fRawReader;    // object for reading the raw data
+    UChar_t*         fData;         // pointer to the data
+    Int_t            fPosition;
 
-
-    ClassDef(AliPMDRawStream, 4)    // class for reading PMD raw digits
+    ClassDef(AliPMDRawStream, 5)    // class for reading PMD raw digits
 };
 
 #endif
index 1940d75f912d2bf44fafd100afc973ce4f97490d..8e5bdf1234dae5ace8ea64a1827a09c214e85488 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++)
@@ -255,7 +250,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 +276,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 +318,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;
@@ -379,18 +369,18 @@ void AliPMDRawToSDigits::AdcToMeV(Int_t adc, Float_t &edep)
 {
   // To be implemented, this is just for the test
 
-  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   = 7.181;
+  //  const Float_t kErConstant = 0.6899;
+  const Float_t kSlope      = 35.93;
+  //  const Float_t kErSlope    = 0.306;
 
 
 
-  Float_t adc12bit = (Float_t) adc;
-  edep     = (1000.0/kSlope)*(adc12bit - kConstant);
+  Float_t adc10bit = (Float_t) adc/4;
+  edep     = (1000.0/kSlope)*(adc10bit - kConstant);
 }
 
-//------------------------------------------------------------------------- //
+// ------------------------------------------------------------------------- //
 
 void AliPMDRawToSDigits::AddSDigit(Int_t trnumber, Int_t det, Int_t smnumber, 
                                   Int_t irow, Int_t icol, Float_t adc)
index 145942848c6f534990c20fc76d0c09e7c4a22326..3ee7cf738dbcacbdb6e4ded4c9e6e6ec90f5bf27 100644 (file)
@@ -37,10 +37,8 @@ void AliPMDReconstructor::Reconstruct(AliRawReader *rawReader,
                                      TTree *clustersTree) const
 {
 // reconstruct clusters from Raw Data
-
-  AliPMDClusterFinder pmdClus;
-  pmdClus.Digits2RecPoints(rawReader, clustersTree);
-
+    static AliPMDClusterFinder pmdClus;
+    pmdClus.Digits2RecPoints(rawReader, clustersTree);
 }
 
 // ------------------------------------------------------------------------ //
@@ -49,7 +47,7 @@ void AliPMDReconstructor::Reconstruct(TTree *digitsTree,
 {
 // reconstruct clusters from Raw Data
 
-  AliPMDClusterFinder pmdClus;
+  static AliPMDClusterFinder pmdClus;
   pmdClus.Digits2RecPoints(digitsTree, clustersTree);
 
 }
@@ -58,17 +56,17 @@ void AliPMDReconstructor::Reconstruct(TTree *digitsTree,
 void AliPMDReconstructor::FillESD(AliRawReader* /*rawReader*/,
                                  TTree* clustersTree, AliESDEvent* esd) const
 {
-  AliPMDtracker pmdtracker;
-  pmdtracker.LoadClusters(clustersTree);
-  pmdtracker.Clusters2Tracks(esd);
+    static AliPMDtracker pmdtracker;
+    pmdtracker.LoadClusters(clustersTree);
+    pmdtracker.Clusters2Tracks(esd);
 }
 // ------------------------------------------------------------------------ //
 void AliPMDReconstructor::FillESD(TTree * /*digitsTree*/,
                                  TTree* clustersTree, AliESDEvent* esd) const
 {
-  AliPMDtracker pmdtracker;
-  pmdtracker.LoadClusters(clustersTree);
-  pmdtracker.Clusters2Tracks(esd);
+    static AliPMDtracker pmdtracker;
+    pmdtracker.LoadClusters(clustersTree);
+    pmdtracker.Clusters2Tracks(esd);
 }
 
 
index ae37a8d344503395fb24d74a28e9293b348f196a..cbcab981dc87bb8432efe74d24579c0cbf5de1fd 100644 (file)
@@ -1,13 +1,23 @@
 // To read PMD raw root data and fetch the adc value for each cell
-void AliPMDRootDataRead()
+void AliPMDRootDataRead(Int_t NEVT = 10)
 {
   TObjArray pmdddlcont;
-  
-  Int_t ievt = 2;
+
+  gBenchmark->Start("");
   
   Bool_t junk;
+
+  Int_t   xpad, ypad;
+  Float_t xx, yy;
+
+  AliPMDUtility cc;
+  TH2F *h2 = new TH2F("h2","Y vs. X",200,-100.,100.,200,-100.,100.);
+
+
+  for(Int_t ievt=3; ievt < NEVT; ievt++)
+  {
   
-  AliRawReaderRoot reader("raw.root",ievt);
+  AliRawReaderRoot reader("08000033646024.10.root",ievt);
   // reader.NextEvent();
   cout<<" Processing Event No  : "<<ievt<<endl;
   /*
@@ -17,16 +27,16 @@ void AliPMDRootDataRead()
     cout << "Data Size =    " << reader.GetDataSize()    << endl;
   */
 
+
   AliPMDRawStream stream(&reader);
-  
-  Int_t indexDDL = 0;
-  
-  for (Int_t iddl = 0; iddl < 6; iddl++)
-    {
-      reader.Select("PMD", iddl, iddl);
-      junk = stream.DdlData(iddl,&pmdddlcont);
-      
+
+  Int_t iddl = -1;
+  while((iddl = stream.DdlData(&pmdddlcont)) >= 0)
+  {
       Int_t ientries = pmdddlcont.GetEntries();
+
+      //cout << "iddl = " << iddl << " ientries = " << ientries << endl;
+
       for (Int_t ient = 0; ient < ientries; ient++)
        {
          AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
@@ -38,9 +48,36 @@ void AliPMDRootDataRead()
          Int_t row = pmdddl->GetRow();
          Int_t col = pmdddl->GetColumn();
          Int_t sig = pmdddl->GetSignal();
+
+//       cout << iddl<<"  "<<row << " " << col << " " << sig << endl;
+
+
+         if(smn <12)
+         {
+             xpad = col;
+             ypad = row;
+         }
+         else if(smn >=12 && smn < 24)
+         {
+             xpad = row;
+             ypad = col;
+         }
+         
+         if (det == 0)
+         {
+             cc.RectGeomCellPos(smn,xpad,ypad,xx,yy);
+             h2->Fill(xx,yy); 
+         }
          
-         //cout << iddl<<"  "<<row << " " << col << " " << sig << endl;
        }
+
       pmdddlcont.Clear();
     }
-}
\ No newline at end of file
+
+  }
+  h2->Draw();
+
+  gBenchmark->Show("");
+
+
+}
index bca40916cb08d75b81981d384a8a169e078a21e4..b779770bf3caccacba05210f8c166be48fa652be 100644 (file)
@@ -51,7 +51,7 @@ ClassImp(AliPMDtracker)
 
 AliPMDtracker::AliPMDtracker():
   fTreeR(0),
-  fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
+  fRecpoints(new TClonesArray("AliPMDrecpoint1", 10)),
   fPMDcontin(new TObjArray()),
   fPMDcontout(new TObjArray()),
   fPMDutil(new AliPMDUtility()),
@@ -105,21 +105,30 @@ AliPMDtracker::~AliPMDtracker()
   // Destructor
   if (fRecpoints)
     {
+      fRecpoints->Clear();
+      /*
       fRecpoints->Delete();
       delete fRecpoints;
       fRecpoints=0;
+      */
     }
   if (fPMDcontin)
     {
+      fPMDcontin->Clear();
+      /*
       fPMDcontin->Delete();
       delete fPMDcontin;
       fPMDcontin=0;
+      */
     }
   if (fPMDcontout)
-    {
+  {
+      fPMDcontout->Clear();
+      /*
       fPMDcontout->Delete();
       delete fPMDcontout;
       fPMDcontout=0;
+      */
     }
   delete fPMDutil;
 }
index 305ca3baeb9f06312995017d42cfc078190e9411..96f6eff6bea7fa2124f4ee3d2937bb7f09986130 100644 (file)
@@ -159,7 +159,6 @@ int main(int argc, char **argv) {
        /* exit when last event received, no need to wait for TERM signal */
        if (eventT==END_OF_RUN) {
            printf("EOR event detected\n");
-           //calibped.Analyse(ped);
            calibgain.Analyse(gain);
            
            break;
@@ -177,11 +176,6 @@ int main(int argc, char **argv) {
     /* write report */
     fprintf(fp,"Run #%s, received %d physics events out of %d\n",getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
     
-/*    
-    TFile * pedRun = new TFile ("pmd_ped.root","RECREATE"); 
-    ped->Write();
-    pedRun->Close();
-*/
 
     TFile * gainRun = new TFile ("pmd_calib.root","RECREATE"); 
     gain->Write();
index 1078f01d2bb75dd00ed5656274c18c4e4057df04..2d755f5fa85448081161b63e092d327ab1175d0a 100644 (file)
@@ -4,11 +4,11 @@ PMD DA for online calibration
 contact: basanta@phy.iitb.ac.in
 Link:/afs/cern.ch/user/a/alicepmd/public/pedestaldata/run31270.raw
 Run Type: STANDALONE
-DA Type: MON
+DA Type: LDC
 Number of events needed: 1000
 Input Files: data raw
 Output Files: pmd_ped.root, to be exported to the DAQ FXS
-Trigger types used: PULSER
+Trigger types used: PHYSICS_EVENT
 
 */
 extern "C" {
@@ -67,7 +67,6 @@ int main(int argc, char **argv) {
        return -1;
     }
 
-
     
     /* define data source : this is argument 1 */  
     status=monitorSetDataSource( argv[1] );
@@ -91,8 +90,7 @@ int main(int argc, char **argv) {
     printf("DA example case2 monitoring program started\n");  
     
     /* init some counters */
-    int nevents_physics=0;
-    int nevents_total=0;
+
 
     struct eventHeaderStruct *event;
     eventTypeType eventT;
@@ -136,8 +134,9 @@ int main(int argc, char **argv) {
            case END_OF_RUN:
                break;
                
-           case PULSER:
+           case PHYSICS_EVENT:
                printf(" event number = %i \n",iev);
+               //if (iev == 10) break;
                AliRawReader *rawReader = new AliRawReaderDate((void*)event);
                calibped.ProcessEvent(rawReader);
                
@@ -154,17 +153,21 @@ int main(int argc, char **argv) {
            calibped.Analyse(ped);
            break;
        }
+
+       /*
+       if (iev == 10) {
+           printf("EOR event detected\n");
+           calibped.Analyse(ped);
+           break;
+       }
+       */
     }
     
     
-    TFile * pedRun = new TFile ("pmd_ped.root","RECREATE"); 
+    TFile * pedRun = new TFile ("PMD_PED.root","RECREATE"); 
     ped->Write();
     pedRun->Close();
 
 
-    /* close result file */
-    fclose(fp);
-    
-    
     return status;
 }