#include "AliRunLoader.h"
#include "AliLoader.h"
#include "AliRawReader.h" // for raw data
+#include "AliLog.h"
//----------------------------------------------------------------------
fLoader = loader;
// initialize container
- if (data == 0)
- Error("TriggerDecision","No MUONdata for trigger\n");
- else
+ if (data == 0){
+ AliError("No MUONdata for trigger");
+ }else{
fMUONData = data;
-
- // Loading AliRun master
- AliRunLoader* runloader = fLoader->GetRunLoader();
- if (runloader->GetAliRun() == 0x0) runloader->LoadgAlice();
- gAlice = runloader->GetAliRun();
+ }
// getting MUON
fMUON = (AliMUON*) gAlice->GetDetector("MUON");
fDigits = new TObjArray(AliMUONConstants::NCh()); //NTriggerCh
for (Int_t i=0; i<AliMUONConstants::NCh() ;i++)
fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i);
+ fDigitIndices = new TArrayI[AliMUONConstants::NCh()];
}
//----------------------------------------------------------------------
fMUON(0)
{
// Default constructor
+ fDigitIndices = NULL;
}
//----------------------------------------------------------------------
{
// Protected copy constructor
- Fatal("AliMUONTriggerDecision", "Not implemented.");
+ AliFatal("Not implemented.");
}
//----------------------------------------------------------------------
void AliMUONTriggerDecision::ClearDigits()
{
- for ( int i=0;i<AliMUONConstants::NCh();i++ )
+ for ( int i=0;i<AliMUONConstants::NCh();i++ )
+ {
if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear();
+ fDigitIndices[i].Set(0);
+ };
}
//----------------------------------------------------------------------
}
//_____________________________________________________________________________
-void AliMUONTriggerDecision::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
+void AliMUONTriggerDecision::AddDigit(
+ Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits,
+ Int_t digitindex
+ )
{
//
// Add a MUON digit to the list of Digits of the detection plane id
+ // Also adds the digit index to the corresponding fDigitIndices arrays.
//
TClonesArray &ldigits = *Digits(id);
new(ldigits[ldigits.GetEntriesFast()]) AliMUONDigit(tracks,charges,digits);
+
+ TArrayI& indices = fDigitIndices[id];
+ indices.Set(indices.GetSize() + 1);
+ indices[indices.GetSize() - 1] = digitindex;
}
//----------------------------------------------------------------------
delete fDigits;
}
+ if (fDigitIndices)
+ delete [] fDigitIndices;
}
//----------------------------------------------------------------------
if (this == &rhs) return *this;
- Fatal("operator=", "Not implemented.");
+ AliFatal("Not implemented.");
return *this;
}
AliMUONTriggerCircuit* triggerCircuit;
for (Int_t chamber = 11; chamber < 15; chamber++){
- // for (Int_t cathode=1; cathode<3; cathode++){
- // fMUONData->GetCathode(cathode-1);
TClonesArray *muonDigits = Digits(chamber-1);
Int_t ndigits = muonDigits->GetEntriesFast();
- if (fDebug>=3)
- printf("\nFound %d digits in %p %d \n", ndigits, (void*)muonDigits,chamber-1);
+ AliDebug(3,Form("Found %d digits in %p %d", ndigits, (void*)muonDigits,chamber-1));
AliMUONDigit *mdig;
Int_t ix=mdig->PadX();
Int_t iy=mdig->PadY();
cathode = mdig->Cathode() + 1;
- if (fDebug>=3)
- printf("cathode %d ix %d iy %d \n",cathode,ix,iy);
+ AliDebug(3,Form("cathode %d ix %d iy %d ",cathode,ix,iy));
// get the sum of the coded charge
// see coding convention in AliMUONChamberTrigger::DisIntegration
for (Int_t icharge=0; icharge<10; icharge++) {
sumCharge=sumCharge+mdig->TrackCharge(icharge);
}
+
// apply condition on soft background
Int_t testCharge=sumCharge-(Int_t(sumCharge/10))*10;
if(sumCharge<=10||testCharge>0) {
Int_t istrip;
Int_t nStrip;
+ // If I want to fetch the digits as in MUONCheck.C then I need to
+ // know the correct digit index. These were stored in fDigitIndices
+ // by the digitizer so we just need to fetch the correct value.
+ Int_t digitindex = fDigitIndices[chamber-1][digit];
+
if (cathode==1) {
switch (chamber)
{
for (icirc=0; icirc<234; icirc++) {
triggerCircuit = (AliMUONTriggerCircuit*) fTriggerCircuit->At(icirc);
for (istrip=0; istrip<16; istrip++) {
- if (triggerCircuit->GetXcode(0,istrip)==code)
+ if (triggerCircuit->GetXcode(0,istrip)==code)
+ {
fXbit11[icirc][istrip]=1;
+ DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex);
+ };
}
}
break;
triggerCircuit = (AliMUONTriggerCircuit*)fTriggerCircuit->At(icirc);
for (istrip=0; istrip<16; istrip++) {
if (triggerCircuit->GetXcode(1,istrip)==code)
+ {
fXbit12[icirc][istrip]=1;
+ DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex);
+ };
}
}
break;
triggerCircuit = (AliMUONTriggerCircuit*)fTriggerCircuit->At(icirc);
for (istrip=0; istrip<32; istrip++) {
if (triggerCircuit->GetXcode(2,istrip)==code)
+ {
fXbit21[icirc][istrip]=1;
+ DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex);
+ };
}
}
break;
triggerCircuit = (AliMUONTriggerCircuit*)fTriggerCircuit->At(icirc);
for (istrip=0; istrip<32; istrip++) {
if (triggerCircuit->GetXcode(3,istrip)==code)
+ {
fXbit22[icirc][istrip]=1;
+ DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex);
+ };
}
}
break;
nStrip=triggerCircuit->GetNstripY();
for (istrip=0; istrip<nStrip; istrip++) {
if (triggerCircuit->GetYcode(0,istrip)==code)
+ {
fYbit11[icirc][istrip]=1;
+ DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex);
+ };
}
}
break;
nStrip=triggerCircuit->GetNstripY();
for (istrip=0; istrip<nStrip; istrip++) {
if (triggerCircuit->GetYcode(1,istrip)==code)
+ {
fYbit12[icirc][istrip]=1;
+ DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex);
+ };
}
}
break;
nStrip=triggerCircuit->GetNstripY();
for (istrip=0; istrip<nStrip; istrip++) {
if (triggerCircuit->GetYcode(2,istrip)==code)
+ {
fYbit21[icirc][istrip]=1;
+ DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex);
+ };
}
}
break;
nStrip=triggerCircuit->GetNstripY();
for (istrip=0; istrip<nStrip; istrip++) {
if (triggerCircuit->GetYcode(3,istrip)==code)
+ {
fYbit22[icirc][istrip]=1;
+ DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex);
+ };
}
}
break;
} // remove soft background
} // end loop on digit
fMUONData->ResetDigits();
- // } // end loop on cathode
+// } // end loop on cathode
} // end loop on chamber
}
// compare Left & Right deviations
Int_t tmpLeftDev=0, tmpRightDev=0;
for (j=0; j<5; j++){
- tmpLeftDev = tmpLeftDev + Int_t(leftDev[j]*TMath::Power(2,j));
- tmpRightDev = tmpRightDev + Int_t(rightDev[j]*TMath::Power(2,j));
+ tmpLeftDev = tmpLeftDev + Int_t(leftDev[j]<<j);
+ tmpRightDev = tmpRightDev + Int_t(rightDev[j]<<j);
}
// assign mimimum deviation do dev[][]
// returns minimun between dev1 and dev2
Int_t tmpDev1=0, tmpDev2=0;
for (Int_t j=0; j<5; j++){
- tmpDev1 = tmpDev1 + Int_t(dev1[j]*TMath::Power(2,j));
- tmpDev2 = tmpDev2 + Int_t(dev2[j]*TMath::Power(2,j));
+ tmpDev1 = tmpDev1 + Int_t(dev1[j]<<j);
+ tmpDev2 = tmpDev2 + Int_t(dev2[j]<<j);
}
if (tmpDev1 <= tmpDev2 ){
for (Int_t j=0; j<=5; j++) { minDev[j]=dev1[j];}
Int_t signDev=minDev[4];
Int_t deviation=0;
for (i=0; i<4; i++) { // extract deviation
- deviation = deviation+Int_t(minDev[i]*TMath::Power(2,i));
+ deviation = deviation+Int_t(minDev[i]<<i);
}
Int_t istripX1Circ=0;
for (i=0; i<5; i++) { // extract X1 strip fired
- istripX1Circ = istripX1Circ+Int_t(minDevStrip[i]*TMath::Power(2,i));
+ istripX1Circ = istripX1Circ+Int_t(minDevStrip[i]<<i);
}
Int_t iStripY=0;
for (i=0; i<4; i++) { // extract Y strip fired
- iStripY = iStripY+Int_t(coordY[i]*TMath::Power(2,i));
+ iStripY = iStripY+Int_t(coordY[i]<<i);
}
// trigger or not
void AliMUONTriggerDecision::Digits2Trigger(){
// call the Trigger Algorithm and fill TreeD
+ ClearDigitNumbers();
fMUONData->ResetTrigger();
Trigger();
localtr[2] = GetDev(icirc);
localtr[3] = GetStripY11(icirc);
for (Int_t i = 0; i < 2; i++) { // convert the Lut output in 1 digit
- localtr[4] += Int_t(loLpt[i]*TMath::Power(2,i));
- localtr[5] += Int_t(loHpt[i]*TMath::Power(2,i));
- localtr[6] += Int_t(loApt[i]*TMath::Power(2,i));
+ localtr[4] += Int_t(loLpt[i]<<i);
+ localtr[5] += Int_t(loHpt[i]<<i);
+ localtr[6] += Int_t(loApt[i]<<i);
}
for (Int_t i = 0; i < 16; i++) { // convert X/Y bit in bit pattern
localtr[14] |= (fYbit22[icirc][i] << i);
}
- AliMUONLocalTrigger* pLocTrig = new AliMUONLocalTrigger(localtr);
+ AliMUONLocalTrigger* pLocTrig = new AliMUONLocalTrigger(localtr, fDigitNumbers[icirc]);
fMUONData->AddLocalTrigger(*pLocTrig); // add a local trigger in the list
}
}
}
//_______________________________________________________________________
-void AliMUONTriggerDecision::Trigger2Trigger()
+void AliMUONTriggerDecision::ClearDigitNumbers()
{
-// copy trigger from TreeD to TreeR
+// Clears the fDigitNumbers arrays so that they are all empty.
- fMUONData->SetTreeAddress("GLT");
- fMUONData->GetTriggerD();
+ for (Int_t i = 0; i < AliMUONConstants::NTriggerCircuit(); i++)
+ fDigitNumbers[i].Set(0);
}
//_______________________________________________________________________
-void AliMUONTriggerDecision::Trigger2Trigger(AliRawReader* /*rawReader*/)
+void AliMUONTriggerDecision::DigitFiredCircuit(
+ Int_t circuit, Int_t cathode,
+ Int_t chamber, Int_t digit
+ )
{
-// call the Trigger Algorithm from raw data and fill TreeR
-
- Fatal("Trigger2Trigger","Trigger not implemented for raw data input");
-
+// Registers that the specified digit fired the specified circuit.
+// This digit gets added to an array which will be copied to
+// AliMUONLocalTrigger when such an object is created for each circuit.
+
+ Int_t digitnumber = AliMUONLocalTrigger::EncodeDigitNumber(chamber, cathode, digit);
+ Int_t last = fDigitNumbers[circuit].GetSize();
+ fDigitNumbers[circuit].Set(last + 1);
+ fDigitNumbers[circuit][last] = digitnumber;
}
+