+//____________________________________________________________________________
+void AliEMCALQADataMakerRec::GetTruChannelPosition( Int_t &globRow, Int_t &globColumn, Int_t module, Int_t ddl, Int_t branch, Int_t column )
+{
+ Int_t mrow;
+ Int_t mcol;
+ Int_t trow;
+ Int_t tcol;
+ Int_t drow;
+ Int_t rcu;
+ // RCU 0 or 1
+ rcu = ddl % 2;
+
+ // 12 rows of 2x2s in a module (3 TRUs by 4 rows)
+ mrow = (module/2) * 12;
+ // 24 columns per module, odd module numbers increased by 24
+ mcol = (module%2) * 24;
+
+ // position within TRU coordinates
+ tcol = column / 4;
+ trow = column % 4;
+
+ //.combine
+ if( module%2 == 0 ){ // A side
+ // mirror rows
+ trow = 3 - trow;
+
+ // TRU in module row addition
+ drow = (rcu*branch+rcu) * 4;
+
+ }
+ else{ // C side
+ // mirror columns
+ tcol = 23 - tcol;
+
+ // TRU in module row addition
+ drow = (2 - (rcu*branch+rcu)) * 4;
+ }
+
+ // output global row/collumn position (0,0 = SMA0, phi = 0, |eta| = max)
+ globRow = mrow + drow + trow;
+ globColumn = mcol + tcol;
+ return;
+
+}
+//____________________________________________________________________________
+void AliEMCALQADataMakerRec::MakeRawsSTU(AliRawReader* rawReader){
+
+ AliEMCALTriggerSTURawStream* inSTU = new AliEMCALTriggerSTURawStream(rawReader);
+
+ rawReader->Reset();
+ rawReader->Select("EMCAL", 44);
+
+
+ //L1 segmentation
+ Int_t sizeL1gsubr = 1;
+ Int_t sizeL1gpatch = 2;
+ Int_t sizeL1jsubr = 4;
+
+ Int_t EMCALtrig[AliEMCALGeoParams::fgkEMCALSTUCols][AliEMCALGeoParams::fgkEMCALSTURows];
+
+ memset(EMCALtrig, 0, sizeof(int) * AliEMCALGeoParams::fgkEMCALSTUCols * AliEMCALGeoParams::fgkEMCALSTURows);
+
+
+
+
+ if (inSTU->ReadPayLoad())
+ {
+
+ //Fw version (use in case of change in L1 jet
+ Int_t fw = inSTU->GetFwVersion();
+ Int_t sizeL1jpatch = 2+(fw >> 16);
+
+ //To check link
+
+ Int_t mask = inSTU->GetFrameReceived();
+
+
+ for (int i = 0; i < 32; i++)
+ {
+ if ((mask >> i) & 0x1) FillRawsData(kSTUTRU, i);
+ }
+
+
+ //V0 signal in STU
+ Int_t V0Sig = inSTU->GetV0A()+inSTU->GetV0C();
+
+ //FastOR amplitude receive from TRU
+ for (Int_t i = 0; i < 32; i++)
+ {
+ UInt_t adc[96];
+ for (Int_t j = 0; j < 96; j++) adc[j] = 0;
+
+ inSTU->GetADC(i, adc);
+
+ Int_t iTRU = fGeom->GetTRUIndexFromSTUIndex(i);
+
+ for (Int_t j = 0; j < 96; j++)
+ {
+ Int_t idx;
+ fGeom->GetAbsFastORIndexFromTRU(iTRU, j, idx);
+
+ Int_t px, py;
+ fGeom->GetPositionInEMCALFromAbsFastORIndex(idx, px, py);
+
+ EMCALtrig[px][py] = adc[j];
+ }
+ }
+
+ //L1 Gamma patches
+ Int_t iTRU_STU, x, y;
+ for (Int_t i = 0; i < inSTU->GetNL1GammaPatch(); i++)
+ {
+ if (inSTU->GetL1GammaPatch(i, iTRU_STU, x, y)) // col (0..23), row (0..3)
+ {
+ Int_t iTRU;
+ iTRU = fGeom->GetTRUIndexFromSTUIndex(iTRU_STU);
+
+ Int_t etaG = 23-x, phiG = y + 4 * int(iTRU/2); //position in EMCal
+
+ if (iTRU%2) etaG += 24; //C-side
+
+ etaG = etaG - sizeL1gsubr * sizeL1gpatch + 1;
+
+ //Position of patch L1G (bottom-left FastOR of the patch)
+ FillRawsData(kGL1, etaG, phiG);
+
+ //loop to sum amplitude of FOR in the gamma patch
+ Int_t L1G_PatchAmp = 0;
+ for (Int_t L1Gx = 0; L1Gx < sizeL1gpatch; L1Gx ++)
+ {
+ for (Int_t L1Gy = 0; L1Gy < sizeL1gpatch; L1Gy ++)
+ {
+ if (etaG+L1Gx < 48 && phiG+L1Gy < 64) L1G_PatchAmp += EMCALtrig[etaG+L1Gx][phiG+L1Gy];
+ //cout << EMCALtrig[etaG+L1Gx][phiG+L1Gy] << endl;
+ }
+ }
+
+ //if (L1G_PatchAmp > 500) cout << "L1G amp =" << L1G_PatchAmp << endl;
+ FillRawsData(kGL1V0, V0Sig, L1G_PatchAmp);
+
+ }
+ }
+
+
+ //L1 Jet patches
+ for (Int_t i = 0; i < inSTU->GetNL1JetPatch(); i++)
+ {
+ if (inSTU->GetL1JetPatch(i, x, y)) // col (0,15), row (0,11)
+ {
+
+ Int_t etaJ = sizeL1jsubr * (11-y-sizeL1jpatch + 1);
+ Int_t phiJ = sizeL1jsubr * (15-x-sizeL1jpatch + 1);
+
+ //position of patch L1J (FOR bottom-left)
+ FillRawsData(kJL1, etaJ, phiJ);
+
+ //loop the sum aplitude of FOR in the jet patch
+ Int_t L1J_PatchAmp = 0;
+ for (Int_t L1Jx = 0; L1Jx < sizeL1jpatch*4; L1Jx ++)
+ {
+ for (Int_t L1Jy = 0; L1Jy < sizeL1jpatch*4; L1Jy ++)
+ {
+ if (etaJ+L1Jx < 48 && phiJ+L1Jy < 64) L1J_PatchAmp += EMCALtrig[etaJ+L1Jx][phiJ+L1Jy];
+ }
+ }
+
+ //cout << "L1J amp =" << L1J_PatchAmp << endl;
+ FillRawsData(kJL1V0, V0Sig, L1J_PatchAmp);
+
+ }
+ }
+
+ }
+
+ //Fill FOR amplitude histo
+ for (Int_t i = 0; i < 48; i++)
+ {
+ for (Int_t j = 0; j < 60; j++)
+ {
+ if (EMCALtrig[i][j] != 0) FillRawsData(kAmpL1, i, j, EMCALtrig[i][j]);
+ }
+ }
+
+ delete inSTU;
+ return;
+}
+
+