Char_t filename[80];
+ // open the ddl file info to know the modules per DDL
+ TString ddlinfofileName(gSystem->Getenv("ALICE_ROOT"));
+ ddlinfofileName += "/PMD/PMD_ddl_info.dat";
+
+ ifstream infileddl;
+ infileddl.open(ddlinfofileName.Data(), ios::in); // ascii file
+ if(!infileddl) AliError("Could not read the ddl info file");
+
+
Int_t mmodule = 0;
+ Int_t ddlno;
+ Int_t modno;
+ Int_t *modulenoddl = 0x0;
+
for(Int_t iddl = 0; iddl < kDDL; iddl++)
{
+ if (infileddl.eof()) break;
+ infileddl >> ddlno >> modulePerDDL;
+
+ if (modulePerDDL == 0) continue;
+
+ modulenoddl = new Int_t [modulePerDDL];
+ for (Int_t im = 0; im < modulePerDDL; im++)
+ {
+ infileddl >> modno;
+ modulenoddl[im] = modno;
+ }
+
strcpy(filename,AliDAQ::DdlFileName("PMD",iddl));
outfile = new AliFstream(filename);
- if (iddl < 4)
- {
- modulePerDDL = 6;
- mmodule = 6*iddl;
- }
- else if (iddl == 4)
- {
- modulePerDDL = 12;
- mmodule = 24;
- }
- else if (iddl == 5)
- {
- modulePerDDL = 12;
- mmodule = 30;
- }
-
-
-
// Write the Dummy Data Header into the file
Int_t bHPosition = outfile->Tellp();
outfile->WriteBuffer((char*)(&header),sizeof(header));
for(Int_t ium = 0; ium < modulePerDDL; ium++)
{
- if (iddl == 4 && ium == 6) mmodule = 42;
+ //if (iddl == 4 && ium == 6) mmodule = 42;
// Extract energy deposition per cell and pack it
// in a 32-bit word and returns all the total words
// per one unit-module
- GetUMDigitsData(treeD, mmodule, iddl, contentsBus, busPatch);
- mmodule++;
+ mmodule = modulenoddl[ium];
+ GetUMDigitsData(treeD, mmodule, iddl, modulePerDDL, contentsBus, busPatch);
}
-
-
Int_t ij = 0;
Int_t dsp[10];
Int_t dspBus[10];
if (contentsBus[ij] > 0)
{
dsp[i] += contentsBus[ij];
- dspBus[i]++;
}
- //ij++;
+ dspBus[i]++;
}
// Add the patch Bus header to the DSP contents
dsp[i] += 4*dspBus[i];
Int_t dspBlockARDL = 0;
Int_t dspBlockBRDL = 0;
+ Int_t remainder = 0;
+
for (Int_t i = 0; i < 5; i++)
{
if (dsp[ieven] > 0)
{
dspBlockARDL += dsp[ieven];
- Int_t remainder = dsp[ieven]%2;
+ remainder = dsp[ieven]%2;
if (remainder == 1)
{
dspBlockARDL++;
if (dsp[iodd] > 0)
{
dspBlockBRDL += dsp[iodd];
- Int_t remainder = dsp[ieven]%2;
+ remainder = dsp[iodd]%2;
if (remainder == 1)
{
- dspBlockARDL++;
+ dspBlockBRDL++;
}
}
}
-
+
+ dspBlockARDL += 50;
+ dspBlockBRDL += 50;
+
// Start writing the DDL file
AliPMDBlockHeader blHeader;
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++)
{
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];
outfile->WriteBuffer((char*)patchBusHeaderWord,4*sizeof(UInt_t));
+ bknJunk += patchbusRDL;
for (Int_t iword = 0; iword < patchbusRDL; iword++)
{
}
}
+ // 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
delete outfile;
} // DDL Loop over
-
+ delete [] modulenoddl;
+ infileddl.close();
}
//____________________________________________________________________________
void AliPMDDDLRawData::GetUMDigitsData(TTree *treeD, Int_t imodule,
- Int_t ddlno, Int_t *contentsBus,
+ Int_t ddlno, Int_t modulePerDDL,
+ Int_t *contentsBus,
UInt_t busPatch[][1536])
{
- // Retrives digits data UnitModule by UnitModule
+ // Retrieves digits data UnitModule by UnitModule
UInt_t baseword;
UInt_t mcmno, chno;
endRowBus[i] = -1;
endColBus[i] = -1;
}
- Int_t modulePerDDL = 0;
- if (ddlno < 4)
- {
- modulePerDDL = 6;
- }
- else if (ddlno == 4 || ddlno == 5)
- {
- modulePerDDL = 12;
- }
+
TString fileName(gSystem->Getenv("ALICE_ROOT"));
{
infile >> moduleno;
infile >> totPatchBus >> bPatchBus >> ePatchBus;
+
+ if (totPatchBus == 0) continue; // BKN
if (moduleno == imodule)
{
infile.close();
+ // Read if some chains are off
+ TString rchainName(gSystem->Getenv("ALICE_ROOT"));
+ rchainName += "/PMD/PMD_removed_chains.dat";
+
+ ifstream rchainfile;
+ rchainfile.open(rchainName.Data(), ios::in); // ascii file
+ if(!rchainfile)AliError("Could not read the removed cahins file");
+
+ Int_t srowoff1[2][24], erowoff1[2][24];
+ Int_t scoloff1[2][24], ecoloff1[2][24];
+ Int_t srowoff2[2][24], erowoff2[2][24];
+ Int_t scoloff2[2][24], ecoloff2[2][24];
+
+ Int_t rows1, rowe1, cols1, cole1;
+ Int_t rows2, rowe2, cols2, cole2;
+
+ for (Int_t im = 0; im < 48; im++)
+ {
+ rchainfile >> det >> smn >> rows1 >> rowe1 >> cols1 >> cole1
+ >> rows2 >> rowe2 >> cols2 >> cole2;
+
+ srowoff1[det][smn] = rows1;
+ erowoff1[det][smn] = rowe1;
+ scoloff1[det][smn] = cols1;
+ ecoloff1[det][smn] = cole1;
+ srowoff2[det][smn] = rows2;
+ erowoff2[det][smn] = rowe2;
+ scoloff2[det][smn] = cols2;
+ ecoloff2[det][smn] = cole2;
+ }
+
+ rchainfile.close();
+
treeD->GetEntry(imodule);
Int_t nentries = fDigits->GetLast();
Int_t totword = nentries+1;
adc = (UInt_t) pmddigit->GetADC();
TransformS2H(smn,irow,icol);
+
+ // remove the non-existence channels
+
+ //printf("%d %d %d %d\n",det,smn,irow,icol);
+ //printf("--- %d %d %d %d\n",srowoff[det][smn],erowoff[det][smn],
+ // scoloff[det][smn],ecoloff[det][smn]);
+
+ if (irow >= srowoff1[det][smn] && irow <= erowoff1[det][smn])
+ {
+ if (icol >= scoloff1[det][smn] && icol <= ecoloff1[det][smn])
+ {
+ continue;
+ }
+ }
+ if (irow >= srowoff2[det][smn] && irow <= erowoff2[det][smn])
+ {
+ if (icol >= scoloff2[det][smn] && icol <= ecoloff2[det][smn])
+ {
+ continue;
+ }
+ }
- GetMCMCh(ddlno, smn, irow, icol, beginPatchBus, endPatchBus,
+
+ GetMCMCh(imodule, irow, icol, beginPatchBus, endPatchBus,
mcmperBus, startRowBus, startColBus,
endRowBus, endColBus, busno, mcmno, chno);
//____________________________________________________________________________
-void AliPMDDDLRawData::GetMCMCh(Int_t ddlno, Int_t smn, Int_t row, Int_t col,
+void AliPMDDDLRawData::GetMCMCh(Int_t imodule, Int_t row, Int_t col,
Int_t beginPatchBus, Int_t endPatchBus,
Int_t *mcmperBus,
Int_t *startRowBus, Int_t *startColBus,
UInt_t iCh[16][4];
-// ChMap(ddlno, smn, iCh);
-
-
static const UInt_t kChDdl01[16][4] = { {6, 4, 5, 7},
{10, 2, 1, 9},
{12, 0, 3, 11},
for (Int_t i = 0; i < 16; i++)
- {
+ {
for (Int_t j = 0; j < 4; j++)
- {
- if (ddlno == 0 || ddlno == 1) iCh[i][j] = kChDdl01[i][j];
- if (ddlno == 2 || ddlno == 3) iCh[i][j] = kChDdl23[i][j];
+ {
- if (ddlno == 4 && smn < 6) iCh[i][j] = kChDdl41[i][j];
- if (ddlno == 4 && (smn >= 18 && smn < 24))iCh[i][j] = kChDdl42[i][j];
- if (ddlno == 5 && (smn >= 12 && smn < 18))iCh[i][j] = kChDdl51[i][j];
- if (ddlno == 5 && (smn >= 6 && smn < 12))iCh[i][j] = kChDdl52[i][j];
- }
- }
+ if(imodule < 6) iCh[i][j] = kChDdl01[i][j];
+ if(imodule >= 6 && imodule <= 11) iCh[i][j] = kChDdl01[i][j];
+ if(imodule >= 12 && imodule <= 17) iCh[i][j] = kChDdl23[i][j];
+ if(imodule >= 18 && imodule <= 23) iCh[i][j] = kChDdl23[i][j];
+
+ if(imodule >= 24 && imodule <= 29) iCh[i][j] = kChDdl41[i][j];
+ if(imodule >= 42 && imodule <= 47) iCh[i][j] = kChDdl42[i][j];
+ if(imodule >= 36 && imodule <= 41) iCh[i][j] = kChDdl51[i][j];
+ if(imodule >= 30 && imodule <= 35) iCh[i][j] = kChDdl52[i][j];
+
+ }
+ }
Int_t irownew = row%16;
Int_t scol = startColBus[ibus];
Int_t ecol = endColBus[ibus];
Int_t tmcm = mcmperBus[ibus];
+
if ((row >= srow && row <= erow) && (col >= scol && col <= ecol))
{
busno = ibus;
// Find out the MCM Number
//
-
- if (ddlno == 0 || ddlno == 1)
+
+ if (imodule < 6) mcmno = (col-scol)/4 + 1;
+ if (imodule >= 6 && imodule < 12) mcmno = (col-scol)/4 + 1;
+
+ if (imodule >= 12 && imodule < 18)
{
- // PRE plane, SU Mod = 0, 1
- mcmno = (col-scol)/4 + 1;
-
- }
- else if (ddlno == 2 || ddlno == 3)
+ icolnew = (col - scol)/4;
+ mcmno = tmcm - icolnew;
+ }
+ if (imodule >= 18 && imodule < 24)
{
- // PRE plane, SU Mod = 2, 3
- Int_t icolnew = (col - scol)/4;
+ icolnew = (col - scol)/4;
mcmno = tmcm - icolnew;
- }
- else if (ddlno == 4 )
+ }
+
+ // DDL = 4
+ if (imodule >= 24 && imodule < 30)
{
- // CPV plane, SU Mod = 0, 3 : ddl = 4
-
- if(ibus <= 18)
+
+ //if (tmcm == 24)
+ Int_t rowdiff = endRowBus[ibus] - startRowBus[ibus];
+ if(rowdiff > 16)
{
Int_t midrow = srow + 16;
if(row >= srow && row < midrow)
mcmno = 12 + (col-scol)/4 + 1;
}
else if(row >= midrow && row <= erow)
-
+
{
mcmno = (col-scol)/4 + 1;
}
}
-
- else if (ibus > 18)
+ else if (rowdiff < 16)
{
- Int_t rowdiff = endRowBus[ibus] - startRowBus[ibus];
- if(rowdiff > 16)
+ mcmno = (col-scol)/4 + 1;
+ }
+
+ }
+ if (imodule >= 42 && imodule < 48)
+ {
+ Int_t rowdiff = endRowBus[ibus] - startRowBus[ibus];
+ if(rowdiff > 16)
+ {
+ Int_t midrow = srow + 16;
+ if (row >= midrow && row <= erow)
{
- Int_t midrow = srow + 16;
- if (row >= midrow && row <= erow)
- {
- mcmno = 12 + (ecol -col)/4 + 1;
- }
- else if (row >= srow && row < midrow)
- {
- mcmno = (ecol - col)/4 + 1;
- }
+ mcmno = 12 + (ecol -col)/4 + 1;
}
- else if (rowdiff < 16)
+ else if (row >= srow && row < midrow)
{
mcmno = (ecol - col)/4 + 1;
}
}
- }
- else if ( ddlno == 5)
+ else if (rowdiff < 16)
+ {
+ mcmno = (ecol - col)/4 + 1;
+ }
+ }
+
+ // DDL = 5
+ if (imodule >= 30 && imodule < 36)
{
// CPV plane, SU Mod = 1, 2 : ddl = 5
- if(ibus <= 18)
+ //if(tmcm == 24)
+ Int_t rowdiff = endRowBus[ibus] - startRowBus[ibus];
+ if(rowdiff > 16)
{
Int_t midrow = srow + 16;
if(row >= srow && row < midrow)
mcmno = (col-scol)/4 + 1;
}
}
+ else if(rowdiff < 16)
+ {
+ mcmno = (col-scol)/4 + 1;
+ }
- else if (ibus > 18)
+ }
+ if (imodule >= 36 && imodule < 42)
+ {
+ Int_t rowdiff = endRowBus[ibus] - startRowBus[ibus];
+ if(rowdiff > 16)
{
- Int_t rowdiff = endRowBus[ibus] - startRowBus[ibus];
- if(rowdiff > 16)
+ Int_t midrow = srow + 16;
+ if (row >= midrow && row <= erow)
{
- Int_t midrow = srow + 16;
- if (row >= midrow && row <= erow)
- {
- mcmno = 12 + (ecol - col)/4 + 1;
- }
- else if (row >= srow && row < midrow)
- {
- mcmno = (ecol - col)/4 + 1;
- }
+ mcmno = 12 + (ecol - col)/4 + 1;
}
- else if (rowdiff < 16)
+ else if (row >= srow && row < midrow)
{
mcmno = (ecol - col)/4 + 1;
}
}
+ else if (rowdiff < 16)
+ {
+ mcmno = (ecol - col)/4 + 1;
+ }
}
+
}
}
}
//____________________________________________________________________________
-/*
-void ChMap(Int_t ddlno, Int_t smn, UInt_t iCh[][4])
-{
-// Row and Col converted to Channel
-
- static const UInt_t kChDdl01[16][4] = { {6, 4, 5, 7},
- {10, 2, 1, 9},
- {12, 0, 3, 11},
- {14, 8, 13, 15},
- {16, 18, 23, 17},
- {20, 28, 31, 19},
- {22, 30, 29, 21},
- {24, 26, 27, 25},
- {38, 36, 37, 39},
- {42, 34, 33, 41},
- {44, 32, 35, 43},
- {46, 40, 45, 47},
- {48, 50, 55, 49},
- {52, 60, 63, 51},
- {54, 62, 61, 53},
- {56, 58, 59, 57} };
-
-
- static const UInt_t kChDdl23[16][4] = { {57, 59, 58, 56},
- {53, 61, 62, 54},
- {51, 63, 60, 52},
- {49, 55, 50, 48},
- {47, 45, 40, 46},
- {43, 35, 32, 44},
- {41, 33, 34, 42},
- {39, 37, 36, 38},
- {25, 27, 26, 24},
- {21, 29, 30, 22},
- {19, 31, 28, 20},
- {17, 23, 18, 16},
- {15, 13, 8, 14},
- {11, 3, 0, 12},
- {9, 1, 2, 10},
- {7, 5, 4, 6} };
-
-
- static const UInt_t kChDdl41[16][4] = { {56, 58, 59, 57},
- {54, 62, 61, 53},
- {52, 60, 63, 51},
- {48, 50, 55, 49},
- {46, 40, 45, 47},
- {44, 32, 35, 43},
- {42, 34, 33, 41},
- {38, 36, 37, 39},
- {24, 26, 27, 25},
- {22, 30, 29, 21},
- {20, 28, 31, 19},
- {16, 18, 23, 17},
- {14, 8, 13, 15},
- {12, 0, 3, 11},
- {10, 2, 1, 9},
- {6, 4, 5, 7} };
-
-
- static const UInt_t kChDdl42[16][4] = { {7, 5, 4, 6},
- {9, 1, 2, 10},
- {11, 3, 0, 12},
- {15, 13, 8, 14},
- {17, 23, 18, 16},
- {19, 31, 28, 20},
- {21, 29, 30, 22},
- {25, 27, 26, 24},
- {39, 37, 36, 38},
- {41, 33, 34, 42},
- {43, 35, 32, 44},
- {47, 45, 40, 46},
- {49, 55, 50, 48},
- {51, 63, 60, 52},
- {53, 61, 62, 54},
- {57, 59, 58, 56} };
-
-
- static const UInt_t kChDdl51[16][4] = { {7, 5, 4, 6},
- {9, 1, 2, 10},
- {11, 3, 0, 12},
- {15, 13, 8, 14},
- {17, 23, 18, 16},
- {19, 31, 28, 20},
- {21, 29, 30, 22},
- {25, 27, 26, 24},
- {39, 37, 36, 38},
- {41, 33, 34, 42},
- {43, 35, 32, 44},
- {47, 45, 40, 46},
- {49, 55, 50, 48},
- {51, 63, 60, 52},
- {53, 61, 62, 54},
- {57, 59, 58, 56} };
-
-
-
- static const UInt_t kChDdl52[16][4] = { {56, 58, 59, 57},
- {54, 62, 61, 53},
- {52, 60, 63, 51},
- {48, 50, 55, 49},
- {46, 40, 45, 47},
- {44, 32, 35, 43},
- {42, 34, 33, 41},
- {38, 36, 37, 39},
- {24, 26, 27, 25},
- {22, 30, 29, 21},
- {20, 28, 31, 19},
- {16, 18, 23, 17},
- {14, 8, 13, 15},
- {12, 0, 3, 11},
- {10, 2, 1, 9},
- {6, 4, 5, 7} };
-
-
- for (Int_t i = 0; i < 16; i++)
- {
- for (Int_t j = 0; j < 4; j++)
- {
- if (ddlno == 0 || ddlno == 1) iCh[i][j] = kChDdl01[i][j];
- if (ddlno == 2 || ddlno == 3) iCh[i][j] = kChDdl23[i][j];
-
- if (ddlno == 4 && smn < 6) iCh[i][j] = kChDdl41[i][j];
- if (ddlno == 4 && (smn >= 18 && smn < 24))iCh[i][j] = kChDdl42[i][j];
- if (ddlno == 5 && (smn >= 12 && smn < 18))iCh[i][j] = kChDdl51[i][j];
- if (ddlno == 0 && (smn >= 6 && smn < 12))iCh[i][j] = kChDdl52[i][j];
- }
- }
-
-}
-*/
-//____________________________________________________________________________
-
-
-
Int_t AliPMDDDLRawData::ComputeParity(UInt_t baseword)
{
// Generate the parity bit