<commit_before>/**************************************************************************
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
*                                                                        *
* Author: The ALICE Off-line Project.                                    *
* Contributors are mentioned in the code where appropriate.              *
*                                                                        *
* Permission to use, copy, modify and distribute this software and its   *
* documentation strictly for non-commercial purposes is hereby granted   *
* without fee, provided that the above copyright notice appears in all   *
* copies and that both the copyright notice and this permission notice   *
* appear in the supporting documentation. The authors make no claims     *
* about the suitability of this software for any purpose. It is          *
* provided "as is" without express or implied warranty.                  *
**************************************************************************/

/* $Id$ */

/// \class AliMUONTriggerCircuit
/// Contains as data members the Y positions of the X declusturized strips and 
/// the X positions of the (doubled or not) Y strips.
/// This is used to associate the global positions to the fired strips of the 
/// local trigger output (see AliMUONTrackReconstructor::MakeTriggerTrack)
///
/// \author <NAME> (LPCCFd)

#include "AliMUONTriggerCircuit.h"
#include "AliMUONLocalTriggerBoard.h"
#include "AliMUONTriggerCrateStore.h"
#include "AliMUONTriggerCrate.h"
#include "AliMUONGeometryTransformer.h"

#include "AliMpTriggerSegmentation.h"
#include "AliMpTrigger.h"
#include "AliMpSlat.h"
#include "AliMpPCB.h"
#include "AliMpSegmentation.h"
#include "AliMpVSegmentation.h"
#include "AliMpCathodType.h"

#include "AliRun.h"
#include "AliLog.h"

#include <TMath.h>
#include <Riostream.h>

/// \cond CLASSIMP
ClassImp(AliMUONTriggerCircuit)
/// \endcond

//----------------------------------------------------------------------
AliMUONTriggerCircuit::AliMUONTriggerCircuit()
: TObject(),
  fILocalBoard(0),
  fTransformer(0x0)
{
/// Constructor
  
  Int_t i;  
  for (i=0; i<16; i++) { fXpos11[i]=0.; }
  for (i=0; i<31; i++) { fYpos11[i]=0.; }
  for (i=0; i<63; i++) { fYpos21[i]=0.; }
}

//----------------------------------------------------------------------
AliMUONTriggerCircuit::~AliMUONTriggerCircuit()
{
/// Destructor
} 

//----------------------------------------------------------------------
AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONTriggerCircuit& circuit)
   :  TObject(circuit),
      fILocalBoard(circuit.fILocalBoard),
  fTransformer(0x0)
{
/// Copy constructor

  for (Int_t i = 0; i < 16; ++i)
    fXpos11[i] = circuit.fXpos11[i];

  for (Int_t i = 0; i < 31; ++i)
    fYpos11[i] = circuit.fYpos11[i];

  for (Int_t i = 0; i < 63; ++i)
    fYpos21[i] = circuit.fYpos21[i];

}
//----------------------------------------------------------------------
AliMUONTriggerCircuit& AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& circuit) 
{
/// Assignment operator

  if (this == &circuit) return *this;

  fILocalBoard = circuit.fILocalBoard;

  for (Int_t i = 0; i < 16; ++i)
    fXpos11[i] = circuit.fXpos11[i];

  for (Int_t i = 0; i < 31; ++i)
    fYpos11[i] = circuit.fYpos11[i];

  for (Int_t i = 0; i < 63; ++i)
    fYpos21[i] = circuit.fYpos21[i];

  return *this;

}
//----------------------------------------------------------------------
void AliMUONTriggerCircuit::Init(Int_t iCircuit, const AliMUONTriggerCrateStore& crates) 
{
/// initialize circuit characteristics
  fILocalBoard=iCircuit+1;//AliMUONTriggerConstants::CircuitId(iCircuit);
 
  LoadXPos(crates);
  LoadYPos(crates);
  
}

//---------------------------------------------------------------------
void AliMUONTriggerCircuit::LoadYPos(const AliMUONTriggerCrateStore& crates)
{
/// fill fYpos11 and fYpos21 -> y position of X declusterized strips
  
  const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
  
  if (!localBoard)
  {
    AliError(Form("Did not get localboard %d",fILocalBoard));
    return;
  }
  StdoutToAliDebug(1,localBoard->Print("CONF"););
  
  Int_t ichamber = 0;
  Int_t icathode = 0;    
  
  const AliMpVSegmentation* seg;
  
  Int_t zeroDown = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroDown);
  Int_t zeroUp = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroUp);
  
  //--- first plane 
  ichamber = 10;
  
  char side;
  Int_t iline, icol;
  DecodeBoardName(localBoard->GetName(),side,iline,icol);
  
  Int_t detElemId = DetElemId(ichamber,side,iline);
  seg = AliMpSegmentation::Instance()
        ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));  

  Int_t iFirstStrip = FirstStrip(localBoard->GetName());
  Int_t iLastStrip = iFirstStrip + 16;    
  Int_t iStripCircuit = 0;
  FillXstrips(seg,detElemId,icol, 
              iFirstStrip,iLastStrip,iStripCircuit,fYpos11);
  
  //--- second plane 
  ichamber = 12;
  
  detElemId = DetElemId(ichamber,side,iline);
  seg = AliMpSegmentation::Instance()
        ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));  

  // second plane middle part
  Int_t iFirstStripMiddle = FirstStrip(localBoard->GetName());
  Int_t iLastStripMiddle = iFirstStrip + 16;
  iStripCircuit=8;
  FillXstrips(seg,detElemId,icol, 
              iFirstStripMiddle,iLastStripMiddle,iStripCircuit,fYpos21);
  
  // second plane upper part
  if (zeroUp == 0) { // something up
    Int_t iFirstStripUp;
    Int_t iLastStripUp;
    Int_t icolUp=icol;
    // check if we need to move to another detElemId
    AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iLastStripMiddle+1),kFALSE);
    if (pad.IsValid()) { // upper strips within same detElemId
      iFirstStripUp = iLastStripMiddle;
      iLastStripUp = iFirstStripUp + 8;
      //	    icolUp = icol;
    } else {             // upper strips in another detElemId
      detElemId = DetElemId(ichamber,side,iline+1); // get detElemId
      seg = AliMpSegmentation::Instance()
            ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));  

      iFirstStripUp = 0;
      iLastStripUp = iFirstStripUp + 8;
      if (iline == 4) icolUp = icol - 1; // special case
      if (iline == 5) icolUp = icol + 1; // special case
    }
    
    iStripCircuit=24;
    FillXstrips(seg,detElemId,icolUp, 
                iFirstStripUp,iLastStripUp,iStripCircuit,fYpos21);
    
    // fill strip between middle and upper part
    fYpos21[47]=(fYpos21[46]+fYpos21[48])/2.;
  } // end of something up
  
  // restore current detElemId & segmentation
  detElemId = DetElemId(ichamber,side,iline); 
  seg = AliMpSegmentation::Instance()
        ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));  

  // second plane lower part
  if (zeroDown == 0) { // something down
    Int_t iFirstStripDo;
    Int_t iLastStripDo;
    Int_t icolDo=icol;
    
    // check if we need to move to another detElemId      
    AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iFirstStripMiddle-1),kFALSE);
    if (pad.IsValid()) { // lower strips within same detElemId
      iFirstStripDo = iFirstStripMiddle - 8;
      iLastStripDo = iFirstStripDo + 8;	      
      //	    icolDo = icol;
    } else {             // lower strips in another detElemId 
      detElemId = DetElemId(ichamber,side,iline-1); // get detElemId
      seg = AliMpSegmentation::Instance()
            ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));  

      // get iFirstStrip in this module 
      const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
      const AliMpTrigger* t = trig->Slat();
      const AliMpSlat* slat = t->GetLayer(0);
      if (iline == 5) icolDo = icol + 1; // special case
      if (iline == 6) icolDo = icol - 1; // special case	    
      const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
      iFirstStripDo = (pcb->Iymax() + 1) - 8;
      iLastStripDo =  iFirstStripDo + 8;
    }  
    
    iStripCircuit=0;
    FillXstrips(seg,detElemId,icolDo, 
                iFirstStripDo,iLastStripDo,iStripCircuit,fYpos21);
    
    // fill strip between middle and upper part
    fYpos21[15]=(fYpos21[14]+fYpos21[16])/2.;
  } // end of something down
  
}

//----------------------------------------------------------------------
void AliMUONTriggerCircuit::LoadXPos(const AliMUONTriggerCrateStore& crates)
{
/// fill fXpos11 -> x position of Y strips for the first plane only
/// fXpos11 contains the x position of Y strip for the current circuit
/// taking into account whether or nor not part(s) of the circuit
/// (middle, up or down) has(have) 16 strips (handdled by means of switchs)
  
  const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
  
  if (!localBoard)
  {
    AliError(Form("Did not get localboard %d",fILocalBoard));
    return;
  }
  StdoutToAliDebug(1,localBoard->Print("CONF"););
  
  Int_t ichamber = 10;
  Int_t icathode = 1;
  
  Int_t x2u = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2u);
  Int_t x2m = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2m);
  Int_t x2d = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2d);
  Int_t zeroAllYLSB = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroAllYLSB);
  Int_t iStripCircuit = 0;
  Int_t iFirstStrip = 0;
  Int_t iLastStrip = 0;
  Bool_t doubling = kFALSE;
  
  const AliMpVSegmentation* seg;

  char side;
  Int_t iline, icol;
  
  DecodeBoardName(localBoard->GetName(),side,iline,icol);
  
  Int_t detElemId=DetElemId(ichamber,side,iline); // get detElemId
  seg = AliMpSegmentation::Instance()
        ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));  

  // check if one needs a strip doubling or not
  if ( (x2u == 1 || x2m == 1 || x2d == 1) && x2m == 1) doubling = kTRUE;
  
  // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
  if (zeroAllYLSB == 1) iStripCircuit = 8;
  
  // get iFirstStrip in this module 
  const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
  const AliMpTrigger* t = trig->Slat();
  const AliMpSlat* slat = t->GetLayer(0);
  
  const AliMpPCB* pcb = slat->GetPCB(icol-1);
  iFirstStrip = pcb->Ixmin();
  
  if (doubling) iLastStrip = iFirstStrip + 8;
  else iLastStrip = iFirstStrip + 16;
  
  FillYstrips(seg,detElemId, 
              iFirstStrip,iLastStrip,iStripCircuit,doubling);  
}

//----------------------------------------------------------------------
void AliMUONTriggerCircuit::FillYstrips(
                                           const AliMpVSegmentation* seg,
                                           const Int_t detElemId, 
                                           const Int_t iFirstStrip, const Int_t iLastStrip, Int_t liStripCircuit,
                                           const Bool_t doubling)
{    
/// fill
  Double_t xyGlobal[4]={0.,0.,0.,0.};
  for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {
    AliMpPad pad = seg->PadByIndices(AliMpIntPair(istrip,0),kTRUE);
    if ( !pad.IsValid() )
    {
	StdoutToAliError(cout << "Pad not found in seg " << endl;
			 seg->Print();
			 cout << " ix,iy=" << istrip << "," << 0 << endl;
			 );
    }
    XYGlobal(detElemId,pad,xyGlobal);
    
    if (!doubling) {	    
      fXpos11[liStripCircuit]=xyGlobal[0];
    } else if (doubling) {	    
      fXpos11[2*liStripCircuit]=TMath::Sign(1.,xyGlobal[0]) * 
	(TMath::Abs(xyGlobal[0]) - xyGlobal[2]/2.);
      fXpos11[2*liStripCircuit+1]=TMath::Sign(1.,xyGlobal[0]) *
        (TMath::Abs(fXpos11[2*liStripCircuit]) + xyGlobal[2]); 
    }	
    liStripCircuit++;
  }    
}

//----------------------------------------------------------------------
void AliMUONTriggerCircuit::FillXstrips(
                                           const AliMpVSegmentation* seg,
                                           const Int_t detElemId, const Int_t icol, 
                                           const Int_t iFirstStrip, const Int_t iLastStrip, 
                                           Int_t liStripCircuit, Float_t *tab)
{    
/// fill 
  Double_t xyGlobal[4]={0.,0.,0.,0.};<commit_msg>fix problem with fXpos11 in LoadXPos (Philippe C., thanks to Christian)<commit_after>/**************************************************************************
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
*                                                                        *
* Author: The ALICE Off-line Project.                                    *
* Contributors are mentioned in the code where appropriate.              *
*                                                                        *
* Permission to use, copy, modify and distribute this software and its   *
* documentation strictly for non-commercial purposes is hereby granted   *
* without fee, provided that the above copyright notice appears in all   *
* copies and that both the copyright notice and this permission notice   *
* appear in the supporting documentation. The authors make no claims     *
* about the suitability of this software for any purpose. It is          *
* provided "as is" without express or implied warranty.                  *
**************************************************************************/

/* $Id$ */

/// \class AliMUONTriggerCircuit
/// Contains as data members the Y positions of the X declusturized strips and 
/// the X positions of the (doubled or not) Y strips.
/// This is used to associate the global positions to the fired strips of the 
/// local trigger output (see AliMUONTrackReconstructor::MakeTriggerTrack)
///
/// \author <NAME> (LPCCFd)

#include "AliMUONTriggerCircuit.h"
#include "AliMUONLocalTriggerBoard.h"
#include "AliMUONTriggerCrateStore.h"
#include "AliMUONTriggerCrate.h"
#include "AliMUONGeometryTransformer.h"

#include "AliMpTriggerSegmentation.h"
#include "AliMpTrigger.h"
#include "AliMpSlat.h"
#include "AliMpPCB.h"
#include "AliMpSegmentation.h"
#include "AliMpVSegmentation.h"
#include "AliMpCathodType.h"

#include "AliRun.h"
#include "AliLog.h"

#include <TMath.h>
#include <Riostream.h>

/// \cond CLASSIMP
ClassImp(AliMUONTriggerCircuit)
/// \endcond

//----------------------------------------------------------------------
AliMUONTriggerCircuit::AliMUONTriggerCircuit()
: TObject(),
  fILocalBoard(0),
  fTransformer(0x0)
{
/// Constructor
  
  Int_t i;  
  for (i=0; i<16; i++) { fXpos11[i]=0.; }
  for (i=0; i<31; i++) { fYpos11[i]=0.; }
  for (i=0; i<63; i++) { fYpos21[i]=0.; }
}

//----------------------------------------------------------------------
AliMUONTriggerCircuit::~AliMUONTriggerCircuit()
{
/// Destructor
} 

//----------------------------------------------------------------------
AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONTriggerCircuit& circuit)
   :  TObject(circuit),
      fILocalBoard(circuit.fILocalBoard),
  fTransformer(0x0)
{
/// Copy constructor

  for (Int_t i = 0; i < 16; ++i)
    fXpos11[i] = circuit.fXpos11[i];

  for (Int_t i = 0; i < 31; ++i)
    fYpos11[i] = circuit.fYpos11[i];

  for (Int_t i = 0; i < 63; ++i)
    fYpos21[i] = circuit.fYpos21[i];

}
//----------------------------------------------------------------------
AliMUONTriggerCircuit& AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& circuit) 
{
/// Assignment operator

  if (this == &circuit) return *this;

  fILocalBoard = circuit.fILocalBoard;

  for (Int_t i = 0; i < 16; ++i)
    fXpos11[i] = circuit.fXpos11[i];

  for (Int_t i = 0; i < 31; ++i)
    fYpos11[i] = circuit.fYpos11[i];

  for (Int_t i = 0; i < 63; ++i)
    fYpos21[i] = circuit.fYpos21[i];

  return *this;

}
//----------------------------------------------------------------------
void AliMUONTriggerCircuit::Init(Int_t iCircuit, const AliMUONTriggerCrateStore& crates) 
{
/// initialize circuit characteristics
  fILocalBoard=iCircuit+1;//AliMUONTriggerConstants::CircuitId(iCircuit);
 
  LoadXPos(crates);
  LoadYPos(crates);
  
}

//---------------------------------------------------------------------
void AliMUONTriggerCircuit::LoadYPos(const AliMUONTriggerCrateStore& crates)
{
/// fill fYpos11 and fYpos21 -> y position of X declusterized strips
  
  const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
  
  if (!localBoard)
  {
    AliError(Form("Did not get localboard %d",fILocalBoard));
    return;
  }
  StdoutToAliDebug(1,localBoard->Print("CONF"););
  
  Int_t ichamber = 0;
  Int_t icathode = 0;    
  
  const AliMpVSegmentation* seg;
  
  Int_t zeroDown = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroDown);
  Int_t zeroUp = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroUp);
  
  //--- first plane 
  ichamber = 10;
  
  char side;
  Int_t iline, icol;
  DecodeBoardName(localBoard->GetName(),side,iline,icol);
  
  Int_t detElemId = DetElemId(ichamber,side,iline);
  seg = AliMpSegmentation::Instance()
        ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));  

  Int_t iFirstStrip = FirstStrip(localBoard->GetName());
  Int_t iLastStrip = iFirstStrip + 16;    
  Int_t iStripCircuit = 0;
  FillXstrips(seg,detElemId,icol, 
              iFirstStrip,iLastStrip,iStripCircuit,fYpos11);
  
  //--- second plane 
  ichamber = 12;
  
  detElemId = DetElemId(ichamber,side,iline);
  seg = AliMpSegmentation::Instance()
        ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));  

  // second plane middle part
  Int_t iFirstStripMiddle = FirstStrip(localBoard->GetName());
  Int_t iLastStripMiddle = iFirstStrip + 16;
  iStripCircuit=8;
  FillXstrips(seg,detElemId,icol, 
              iFirstStripMiddle,iLastStripMiddle,iStripCircuit,fYpos21);
  
  // second plane upper part
  if (zeroUp == 0) { // something up
    Int_t iFirstStripUp;
    Int_t iLastStripUp;
    Int_t icolUp=icol;
    // check if we need to move to another detElemId
    AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iLastStripMiddle+1),kFALSE);
    if (pad.IsValid()) { // upper strips within same detElemId
      iFirstStripUp = iLastStripMiddle;
      iLastStripUp = iFirstStripUp + 8;
      //	    icolUp = icol;
    } else {             // upper strips in another detElemId
      detElemId = DetElemId(ichamber,side,iline+1); // get detElemId
      seg = AliMpSegmentation::Instance()
            ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));  

      iFirstStripUp = 0;
      iLastStripUp = iFirstStripUp + 8;
      if (iline == 4) icolUp = icol - 1; // special case
      if (iline == 5) icolUp = icol + 1; // special case
    }
    
    iStripCircuit=24;
    FillXstrips(seg,detElemId,icolUp, 
                iFirstStripUp,iLastStripUp,iStripCircuit,fYpos21);
    
    // fill strip between middle and upper part
    fYpos21[47]=(fYpos21[46]+fYpos21[48])/2.;
  } // end of something up
  
  // restore current detElemId & segmentation
  detElemId = DetElemId(ichamber,side,iline); 
  seg = AliMpSegmentation::Instance()
        ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));  

  // second plane lower part
  if (zeroDown == 0) { // something down
    Int_t iFirstStripDo;
    Int_t iLastStripDo;
    Int_t icolDo=icol;
    
    // check if we need to move to another detElemId      
    AliMpPad pad = seg->PadByIndices(AliMpIntPair(icol-1,iFirstStripMiddle-1),kFALSE);
    if (pad.IsValid()) { // lower strips within same detElemId
      iFirstStripDo = iFirstStripMiddle - 8;
      iLastStripDo = iFirstStripDo + 8;	      
      //	    icolDo = icol;
    } else {             // lower strips in another detElemId 
      detElemId = DetElemId(ichamber,side,iline-1); // get detElemId
      seg = AliMpSegmentation::Instance()
            ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));  

      // get iFirstStrip in this module 
      const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
      const AliMpTrigger* t = trig->Slat();
      const AliMpSlat* slat = t->GetLayer(0);
      if (iline == 5) icolDo = icol + 1; // special case
      if (iline == 6) icolDo = icol - 1; // special case	    
      const AliMpPCB* pcb = slat->GetPCB(icolDo-1);
      iFirstStripDo = (pcb->Iymax() + 1) - 8;
      iLastStripDo =  iFirstStripDo + 8;
    }  
    
    iStripCircuit=0;
    FillXstrips(seg,detElemId,icolDo, 
                iFirstStripDo,iLastStripDo,iStripCircuit,fYpos21);
    
    // fill strip between middle and upper part
    fYpos21[15]=(fYpos21[14]+fYpos21[16])/2.;
  } // end of something down
  
}

//----------------------------------------------------------------------
void AliMUONTriggerCircuit::LoadXPos(const AliMUONTriggerCrateStore& crates)
{
/// fill fXpos11 -> x position of Y strips for the first plane only
/// fXpos11 contains the x position of Y strip for the current circuit
/// taking into account whether or nor not part(s) of the circuit
/// (middle, up or down) has(have) 16 strips (handdled by means of switchs)
  
  const AliMUONLocalTriggerBoard* localBoard = crates.LocalBoard(fILocalBoard);
  
  if (!localBoard)
  {
    AliError(Form("Did not get localboard %d",fILocalBoard));
    return;
  }
  StdoutToAliDebug(1,localBoard->Print("CONF"););
  
  Int_t ichamber = 10;
  Int_t icathode = 1;
  
  Int_t x2u = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2u);
  Int_t x2m = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2m);
  Int_t x2d = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kX2d);
  Int_t zeroAllYLSB = localBoard->GetSwitch(AliMUONLocalTriggerBoard::kZeroAllYLSB);
  Int_t iStripCircuit = 0;
  Int_t iFirstStrip = 0;
  Int_t iLastStrip = 0;
  Bool_t doubling = kFALSE;
  
  const AliMpVSegmentation* seg;

  char side;
  Int_t iline, icol;
  
  DecodeBoardName(localBoard->GetName(),side,iline,icol);
  
  Int_t detElemId=DetElemId(ichamber,side,iline); // get detElemId
  seg = AliMpSegmentation::Instance()
        ->GetMpSegmentation(detElemId, AliMp::GetCathodType(icathode));  

  // check if one needs a strip doubling or not
  if ( (x2u == 1 || x2m == 1 || x2d == 1) && x2m == 1) doubling = kTRUE;

  // check if one starts at strip = 0 or 8 (boards 26-29 and 143-146)
  if (zeroAllYLSB == 1) iStripCircuit = 8;
  
  // get iFirstStrip in this module 
  const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(seg);
  const AliMpTrigger* t = trig->Slat();
  const AliMpSlat* slat = t->GetLayer(0);
  
  const AliMpPCB* pcb = slat->GetPCB(icol-1);
  iFirstStrip = pcb->Ixmin();
  
  if (doubling || zeroAllYLSB == 1) iLastStrip = iFirstStrip + 8;
  else iLastStrip = iFirstStrip + 16;
  
  FillYstrips(seg,detElemId, 
              iFirstStrip,iLastStrip,iStripCircuit,doubling);  
}

//----------------------------------------------------------------------
void AliMUONTriggerCircuit::FillYstrips(
                                           const AliMpVSegmentation* seg,
                                           const Int_t detElemId, 
                                           const Int_t iFirstStrip, const Int_t iLastStrip, Int_t liStripCircuit,
                                           const Bool_t doubling)
{    
/// fill
  Double_t xyGlobal[4]={0.,0.,0.,0.};

  for (Int_t istrip=iFirstStrip; istrip<iLastStrip; istrip++) {

    AliMpPad pad = seg->PadByIndices(AliMpIntPair(istrip,0),kTRUE);
    if ( !pad.IsValid() )
    {
	StdoutToAliError(cout << "Pad not found in seg " << endl;
			 seg->Print();
			 cout << " ix,iy=" << istrip << "," << 0 << endl;
			 );
    }
    XYGlobal(detElemId,pad,xyGlobal);

    if (!doubling) {
	fXpos11[liStripCircuit]=xyGlobal[0];
    } else if (doubling) {	    
      fXpos11[2*liStripCircuit]=TMath::Sign(1.,xyGlobal[0]) * 
	(TMath::Abs(xyGlobal[0]) - xyGlobal[2]/2.);
      fXpos11[2*liStripCircuit+1]=TMath::Sign(1.,xyGlobal[0]) *
        (TMath::Abs(fXpos11[2*liStripCircuit]) + xyGlobal[2]); 
    }	
    liStripCircuit++;
  }    
}

//----------------------------------------------------------------------
void AliMUONTriggerCircuit::FillXstrips(
                                           const AliMpVSegmentation* seg,
                                           const Int_t detElemId, const Int_t icol, 
                                           const Int_t iFirstStrip, const Int_t iLastStrip, 
                                           Int_t liStripCircuit, Float_t *tab)
{    
/// fill 
  Double_t xyGlobal[4]={0.,0.,0.,0.};
{'fraction_non_alphanumeric': 0.1741559188367699, 'fraction_numerical': 0.01926394479585969, 'mean_word_length': 2.4281892424669107, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 46, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7461617', 'n_tokens_mistral': 8519, 'n_tokens_neox': 8008, 'n_words': 1745}