--- /dev/null
+/**************************************************************************
+ * 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. *
+ **************************************************************************/
+
+/*
+
+
+Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
+*/
+
+#include "AliCaloRawAnalyzerFakeALTRO.h"
+#include "AliCaloBunchInfo.h"
+#include "AliCaloFitResults.h"
+#include "AliLog.h"
+#include "TMath.h"
+#include <stdexcept>
+#include <iostream>
+#include "TF1.h"
+#include "TGraph.h"
+
+using namespace std;
+
+
+#define BAD 4 //CRAP PTH
+
+ClassImp( AliCaloRawAnalyzerFakeALTRO )
+
+
+AliCaloRawAnalyzerFakeALTRO::AliCaloRawAnalyzerFakeALTRO() : AliCaloRawAnalyzer("Chi Square Fit", "LMS"),
+ fkEulerSquared(7.389056098930650227),
+ fTf1(0),
+ fTau(2.35),
+ fFixTau(kTRUE)
+{
+ //comment
+ for(int i=0; i < MAXSAMPLES; i++)
+ {
+ fXaxis[i] = i;
+ }
+
+ fTf1 = new TF1( "myformula", "[0]*((x - [1])/[2])^2*exp(-2*(x -[1])/[2])", 0, 30 );
+ if (fFixTau) {
+ fTf1->FixParameter(2, fTau);
+ }
+ else {
+ fTf1->ReleaseParameter(2); // allow par. to vary
+ fTf1->SetParameter(2, fTau);
+ }
+
+}
+
+
+AliCaloRawAnalyzerFakeALTRO::~AliCaloRawAnalyzerFakeALTRO()
+{
+ delete fTf1;
+}
+
+
+
+AliCaloFitResults
+AliCaloRawAnalyzerFakeALTRO::Evaluate( const vector<AliCaloBunchInfo> &bunchvector, const UInt_t altrocfg1, const UInt_t altrocfg2 )
+{
+ // Extracting signal parameters using fitting
+ short maxampindex; //index of maximum amplitude
+ short maxamp; //Maximum amplitude
+ int index = SelectBunch( bunchvector, &maxampindex, &maxamp );
+
+ if( index >= 0)
+ {
+ Float_t ped = ReverseAndSubtractPed( &(bunchvector.at(index)) , altrocfg1, altrocfg2, fReversed );
+ Float_t maxf = TMath::MaxElement( bunchvector.at(index).GetLength(), fReversed );
+ short maxrev = maxampindex - bunchvector.at(index).GetStartBin();
+ // timebinOffset is timebin value at maximum (maxrev)
+ short timebinOffset = maxampindex - (bunchvector.at(index).GetLength()-1);
+ if( maxf < fAmpCut || ( maxamp - ped) > fOverflowCut ) // (maxamp - ped) > fOverflowCut = Close to saturation (use low gain then)
+ {
+ return AliCaloFitResults( maxamp, ped, AliCaloFitResults::kCrude, maxf, timebinOffset);
+ }
+ else if ( maxf >= fAmpCut )
+ {
+ int first = 0;
+ int last = 0;
+ SelectSubarray( fReversed, bunchvector.at(index).GetLength(), maxrev, &first, &last);
+ int nsamples = last - first + 1;
+
+ if( ( nsamples ) >= fNsampleCut )
+ {
+ Float_t tmax = (maxrev - first); // local tmax estimate
+ TGraph *graph = new TGraph( nsamples, fXaxis, &fReversed[first] );
+ fTf1->SetParameter(0, maxf*fkEulerSquared );
+ fTf1->SetParameter(1, tmax - fTau);
+ // set rather loose parameter limits
+ fTf1->SetParLimits(0, 0.5*maxf*fkEulerSquared, 2*maxf*fkEulerSquared );
+ fTf1->SetParLimits(1, tmax - fTau - 4, tmax - fTau + 4);
+
+ if (fFixTau) {
+ fTf1->FixParameter(2, fTau);
+ }
+ else {
+ fTf1->ReleaseParameter(2); // allow par. to vary
+ fTf1->SetParameter(2, fTau);
+ }
+
+ Short_t tmpStatus = 0;
+ try {
+ tmpStatus = graph->Fit(fTf1, "Q0RW");
+ }
+ catch (const std::exception & e) {
+ AliError( Form("TGraph Fit exception %s", e.what()) );
+ return AliCaloFitResults( maxamp, ped, AliCaloFitResults::kNoFit, maxf, timebinOffset,
+ timebinOffset, AliCaloFitResults::kDummy, AliCaloFitResults::kDummy, AliCaloFitResults::kDummy, AliCaloFitSubarray(index, maxrev, first, last) );
+ }
+
+ if( fVerbose == true )
+ {
+ AliCaloRawAnalyzer::PrintBunch( bunchvector.at(index) );
+ PrintFitResult( fTf1 ) ;
+ }
+ // global tmax
+ tmax = fTf1->GetParameter(1) + timebinOffset - (maxrev - first) // abs. t0
+ + fTf1->GetParameter(2); // +tau, makes sum tmax
+
+ delete graph;
+ return AliCaloFitResults( maxamp, ped , AliCaloFitResults::kFitPar,
+ fTf1->GetParameter(0)/fkEulerSquared,
+ tmax,
+ timebinOffset,
+ fTf1->GetChisquare(),
+ fTf1->GetNDF(),
+ AliCaloFitResults::kDummy, AliCaloFitSubarray(index, maxrev, first, last) );
+
+ // delete graph;
+
+ }
+ else
+ {
+ Float_t chi2 = CalculateChi2(maxf, maxrev, first, last);
+ Int_t ndf = last - first - 1; // nsamples - 2
+ return AliCaloFitResults( maxamp, ped, AliCaloFitResults::kCrude, maxf, timebinOffset,
+ timebinOffset, chi2, ndf, AliCaloFitResults::kDummy, AliCaloFitSubarray(index, maxrev, first, last) );
+ }
+ } // ampcut
+ }
+ return AliCaloFitResults( AliCaloFitResults::kInvalid, AliCaloFitResults::kInvalid );
+
+}
+
+
+void
+AliCaloRawAnalyzerFakeALTRO::PrintFitResult(const TF1 *f) const
+{
+ //comment
+ cout << endl;
+ cout << __FILE__ << __LINE__ << "Using this samplerange we get" << endl;
+ cout << __FILE__ << __LINE__ << "AMPLITUDE = " << f->GetParameter(0)/fkEulerSquared << ",.. !!!!" << endl;
+ cout << __FILE__ << __LINE__ << "TOF = " << f->GetParameter(1) << ",.. !!!!" << endl;
+ cout << __FILE__ << __LINE__ << "NDF = " << f->GetNDF() << ",.. !!!!" << endl;
+ // cout << __FILE__ << __LINE__ << "STATUS = " << f->GetStatus() << ",.. !!!!" << endl << endl;
+ cout << endl << endl;
+}
+
--- /dev/null
+#ifndef ALICALORAWANALYZERFAKEALTRO_H
+#define ALICALORAWANALYZERFAKEALTRO_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/*
+
+
+Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
+*/
+
+#include "AliCaloRawAnalyzer.h"
+
+
+class TF1;
+class TGraph;
+
+class AliCaloRawAnalyzerFakeALTRO : public AliCaloRawAnalyzer
+{
+ public:
+ AliCaloRawAnalyzerFakeALTRO();
+ virtual ~AliCaloRawAnalyzerFakeALTRO();
+
+ virtual AliCaloFitResults Evaluate( const std::vector<AliCaloBunchInfo> &bunchvector, const UInt_t altrocfg1, const UInt_t altrocfg2 );
+ void PrintFitResult(const TF1 *f) const;
+
+ // shaper tau value, in time-bins, and flag for keeping tau fixed
+ Float_t GetTau() const { return fTau;};
+ void SetTau(Float_t f) { fTau = f; };
+ Bool_t GetFixTau() const { return fFixTau; };
+ void SetFixTau(Bool_t b) { fFixTau = b; };
+
+ // extra interfaces
+ TF1 * GetFit() const { return fTf1; };
+
+ private:
+ AliCaloRawAnalyzerFakeALTRO(const AliCaloRawAnalyzerFakeALTRO & );
+ AliCaloRawAnalyzerFakeALTRO & operator = (const AliCaloRawAnalyzerFakeALTRO &);
+
+ double fXaxis[MAXSAMPLES]; //Axis if time bins, ( used by TGraph )
+ const double fkEulerSquared; //e^2 = 7.389056098930650227
+ TF1 *fTf1; // Analytical formula of the Semi Gaussian to be fitted
+
+ Float_t fTau; // shaper tau, in time bins
+ Bool_t fFixTau; // flag if tau should be fix
+
+ ClassDef(AliCaloRawAnalyzerFakeALTRO,1)
+
+};
+
+#endif
fDigitsInRun += emcalLoader->Digits()->GetEntriesFast() ;
}//loop
- // delete digitsTRG;
- // delete digitsTMP;
-
emcalLoader->CleanDigitizer() ;
}//loader exists
//____________________________________________________________________________
void AliEMCALDigitizer::Digits2FastOR(TClonesArray* digitsTMP, TClonesArray* digitsTRG)
{
- // FEE digits afterburner to produce TRG digits
- // we are only interested in the FEE digit deposited energy
- // to be converted later into a voltage value
-
- // push the FEE digit to its associated FastOR (numbered from 0:95)
- // TRU is in charge of summing module digits
-
- AliRunLoader *runLoader = AliRunLoader::Instance();
-
- AliRun* run = runLoader->GetAliRun();
-
- AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(runLoader->GetDetectorLoader("EMCAL"));
- if(!emcalLoader){
- AliFatal("Did not get the Loader");
+ // FEE digits afterburner to produce TRG digits
+ // we are only interested in the FEE digit deposited energy
+ // to be converted later into a voltage value
+
+ // push the FEE digit to its associated FastOR (numbered from 0:95)
+ // TRU is in charge of summing module digits
+
+ AliRunLoader *runLoader = AliRunLoader::Instance();
+
+ AliRun* run = runLoader->GetAliRun();
+
+ AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(runLoader->GetDetectorLoader("EMCAL"));
+ if(!emcalLoader){
+ AliFatal("Did not get the Loader");
}
else {
AliEMCALGeometry* geom = dynamic_cast<AliEMCAL*>(run->GetDetector("EMCAL"))->GetGeometry();
// and xfer to the corresponding TRU input (mapping)
TClonesArray* digits = emcalLoader->Digits();
-
+
TIter NextDigit(digits);
while (AliEMCALDigit* digit = (AliEMCALDigit*)NextDigit())
- {
- Int_t id = digit->GetId();
-
- Int_t iSupMod, nModule, nIphi, nIeta, iphi, ieta, iphim, ietam;
-
- geom->GetCellIndex( id, iSupMod, nModule, nIphi, nIeta );
- geom->GetModulePhiEtaIndexInSModule( iSupMod, nModule, iphim, ietam );
- geom->GetCellPhiEtaIndexInSModule( iSupMod, nModule, nIphi, nIeta, iphi, ieta);
-
- // identify to which TRU this FEE digit belong
- //Int_t itru = (iSupMod < 11) ? iphim / 4 + 3 * iSupMod : 31;
- Int_t itru = -1;
- if (iSupMod < 11)
- itru = (iSupMod % 2) ? (2 - int(iphim / 4)) + 3 * iSupMod : iphim / 4 + 3 * iSupMod;
- else
- itru = 31;
-
- //---------
- //
- // FIXME: bad numbering solution to deal w/ the last 2 SM which have only 1 TRU each
- // using the AliEMCALGeometry official numbering
- // only 1 TRU/SM in SM 10 & SM 11
- //
- //---------
- if ((itru == 31 && iphim < 2) || (itru == 30 && iphim > 5)) continue;
-
- // to be compliant with %4 per TRU
- if (itru == 31) iphim -= 2;
-
- Int_t trgid = 0;
- Bool_t isOK = geom->GetAbsFastORIndexFromPositionInTRU(itru, ietam, iphim % 4, trgid);
-
- AliDebug(2,Form("trigger digit id: %d itru: %d isOK: %d\n",trgid,itru,isOK));
-
- if (isOK)
{
- AliEMCALDigit* d = static_cast<AliEMCALDigit*>(digitsTMP->At(trgid));
-
- if (!d)
- {
- new((*digitsTMP)[trgid]) AliEMCALDigit(*digit);
- d = (AliEMCALDigit*)digitsTMP->At(trgid);
- d->SetId(trgid);
- }
- else
- {
- *d = *d + *digit;
- }
+ Int_t id = digit->GetId();
+
+ Int_t trgid;
+ if (geom->GetFastORIndexFromCellIndex(id , trgid))
+ {
+ AliDebug(1,Form("trigger digit id: %d from cell id: %d\n",trgid,id));
+
+ AliEMCALDigit* d = static_cast<AliEMCALDigit*>(digitsTMP->At(trgid));
+
+ if (!d)
+ {
+ new((*digitsTMP)[trgid]) AliEMCALDigit(*digit);
+ d = (AliEMCALDigit*)digitsTMP->At(trgid);
+ d->SetId(trgid);
+ }
+ else
+ {
+ *d = *d + *digit;
+ }
+ }
}
- }
+
+ if (AliDebugLevel()) printf("Number of TRG digits: %d\n",digitsTMP->GetEntriesFast());
Int_t nSamples = 32;
Int_t *timeSamples = new Int_t[nSamples];
NextDigit = TIter(digitsTMP);
while (AliEMCALDigit* digit = (AliEMCALDigit*)NextDigit())
- {
- if (digit)
{
- Int_t id = digit->GetId();
- Float_t time = digit->GetTime();
-
- Double_t depositedEnergy = 0.;
- for (Int_t j = 1; j <= digit->GetNprimary(); j++) depositedEnergy += digit->GetDEPrimary(j);
-
- // FIXME: Check digit time!
- if (depositedEnergy)
- {
- DigitalFastOR(time, depositedEnergy, timeSamples, nSamples);
-
- for (Int_t j=0;j<nSamples;j++)
- {
- timeSamples[j] = ((j << 12) & 0xFF000) | (timeSamples[j] & 0xFFF);
- }
-
- new((*digitsTRG)[digitsTRG->GetEntriesFast()]) AliEMCALRawDigit(id, timeSamples, nSamples);
- }
+ if (digit)
+ {
+ Int_t id = digit->GetId();
+ Float_t time = digit->GetTime();
+
+ Double_t depositedEnergy = 0.;
+ for (Int_t j = 1; j <= digit->GetNprimary(); j++) depositedEnergy += digit->GetDEPrimary(j);
+
+ if (AliDebugLevel()) printf("Deposited Energy: %f\n", depositedEnergy);
+
+ // FIXME: Check digit time!
+ if (depositedEnergy)
+ {
+ DigitalFastOR(time, depositedEnergy, timeSamples, nSamples);
+
+ for (Int_t j=0;j<nSamples;j++)
+ {
+ timeSamples[j] = ((j << 12) & 0xFF000) | (timeSamples[j] & 0xFFF);
+ }
+
+ new((*digitsTRG)[digitsTRG->GetEntriesFast()]) AliEMCALRawDigit(id, timeSamples, nSamples);
+ }
+ }
}
- }
delete [] timeSamples;
fEnvelop[2] = 0.;
for(Int_t i=0;i<12;i++)fkSModuleMatrix[i]=0 ;
+ for (Int_t i = 0; i < 48; i++)
+ for (Int_t j = 0; j < 64; j++) fFastOR2DMap[i][j] = -1;
}
//____________________________________________________________________________
fEnvelop[1] = geo.fEnvelop[1];
fEnvelop[2] = geo.fEnvelop[2];
for(Int_t i=0;i<12;i++)fkSModuleMatrix[i]=0 ;
+
+ for (Int_t i = 0; i < 48; i++)
+ for (Int_t j = 0; j < 64; j++) fFastOR2DMap[i][j] = geo.fFastOR2DMap[i][j];
}
//____________________________________________________________________________
PrintGeometry();
}
+ for (Int_t ix = 0; ix < 48; ix++)
+ for (Int_t jx = 0; jx < 64; jx++) fFastOR2DMap[ix][jx] = -1;
+
+ BuildFastOR2DMap();
}
//____________________________________________________________________________
void AliEMCALGeoUtils::GetGlobal(Int_t absId , double glob[3]) const
{
// Alice numbering scheme - Jun 03, 2006
- static Int_t nSupMod=0, nModule=-1, nIphi=-1, nIeta=-1;
+ static Int_t nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1;
static double loc[3];
glob[0]=glob[1]=glob[2]=0.0; // bad case
void AliEMCALGeoUtils::PrintCellIndexes(Int_t absId, int pri, const char *tit) const
{
// Service methods
- Int_t nSupMod=0, nModule=-1, nIphi=-1, nIeta=-1;
- Int_t iphi=-1, ieta=-1;
+ Int_t nSupMod, nModule, nIphi, nIeta;
+ Int_t iphi, ieta;
TVector3 vg;
GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
Int_t &iphim, Int_t &ietam, Int_t &nModule) const
{
// Transition from cell indexes (ieta,iphi) to module indexes (ietam,iphim, nModule)
- static Int_t nphi=0;
+ static Int_t nphi=-1;
nphi = GetNumberOfModuleInPhiDirection(nSupMod);
ietam = ieta/fNETAdiv;
{
// Nov 17,2006
// stay here - phi problem as usual
- static Int_t nSupMod=0, i=0, ieta=-1, iphi=-1, etaShift=0, nphi=0;
- static Double_t absEta=0.0, d=0.0, dmin=0.0, phiLoc=0.;
+ static Int_t nSupMod=-1, i=0, ieta=-1, iphi=-1, etaShift=0, nphi=-1;
+ static Double_t absEta=0.0, d=0.0, dmin=0.0, phiLoc=0;
absId = nSupMod = - 1;
if(SuperModuleNumberFromEtaPhi(eta, phi, nSupMod)) {
// phi index first
// Return the number of the supermodule given the absolute
// ALICE numbering id
- static Int_t nSupMod=0, nModule=-1, nIphi=-1, nIeta=-1;
+ static Int_t nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1;
GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
return nSupMod;
}
// ietam, iphi - indexes of module in two dimensional grid of SM
// ietam - have to change from 0 to fNZ-1
// iphim - have to change from 0 to nphi-1 (fNPhi-1 or fNPhi/2-1)
- static Int_t nphi = 0;
+ static Int_t nphi=-1;
if(fKey110DEG == 1 && nSupMod>=10) nphi = fNPhi/2;
else nphi = fNPhi;
// Shift index taking into account the difference between standard SM
// and SM of half size in phi direction
const Int_t kphiIndexShift = fCentersOfCellsPhiDir.GetSize()/4; // Nov 22, 2006; was 6 for cas 2X2
- static Int_t nSupMod=0, nModule=-1, nIphi=-1, nIeta=-1, iphi=-1, ieta=-1;
+ static Int_t nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1, iphi=-1, ieta=-1;
if(!CheckAbsCellId(absId)) return kFALSE;
GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
GetAbsCellIdFromEtaPhi(direction.Eta(),direction.Phi(),absId);
//tower absID hitted -> tower/module plane (evaluated at the center of the tower)
- Int_t nSupMod=0, nModule=-1, nIphi=-1, nIeta=-1;
+ Int_t nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1;
Double_t loc[3],loc2[3],loc3[3];
Double_t glob[3]={},glob2[3]={},glob3[3]={};
Double_t r=sqrt(x*x+y*y);
if ( r > fEnvelop[0] ) {
- Double_t theta = TMath::ATan2(r,z);
- Double_t eta = 9999;
- if(theta < 1e-5) // before theta == 0, not allowed by coding convention
+ Double_t theta;
+ theta = TMath::ATan2(r,z);
+ Double_t eta;
+ if(theta == 0)
eta = 9999;
else
eta = -TMath::Log(TMath::Tan(theta/2.));
AliError("TRU out of range!");
return kFALSE;
}
-
- id = iADC + iTRU * 96;
+
+ id = ( iTRU % 2 ) ? iADC%4 + 4 * (23 - int(iADC/4)) : (3 - iADC%4) + 4 * int(iADC/4);
+
+ id += iTRU * 96;
return kTRUE;
}
}
iTRU = id / 96;
+
iADC = id % 96;
+ iADC = ( iTRU % 2 ) ? iADC%4 + 4 * (23 - int(iADC/4)) : (3 - iADC%4) + 4 * int(iADC/4);
+
return kTRUE;
}
{
//Trigger mapping method, get position in TRU from FasOr Index
- Int_t iADC = 0;
-
- Bool_t isOK = GetTRUFromAbsFastORIndex(id, iTRU, iADC);
-
- if (!isOK) return kFALSE;
+ Int_t iADC=-1;
+ if (!GetTRUFromAbsFastORIndex(id, iTRU, iADC)) return kFALSE;
Int_t x = iADC / 4;
Int_t y = iADC % 4;
- if ( int( iTRU / 3 ) % 2 ) // C side
+ if ( iTRU % 2 ) // C side
{
iEta = 23 - x;
iPhi = y;
}
- else // A side
+ else // A side
{
iEta = x;
iPhi = 3 - y;
{
//Trigger mapping method, get position in Super Module from FasOr Index
- Int_t iTRU = 0;
- Bool_t isOK = GetPositionInTRUFromAbsFastORIndex(id, iTRU, iEta, iPhi);
-
- if (!isOK) return kFALSE;
-
- iSM = iTRU / 3;
+ Int_t iTRU=-1;
+
+ if (!GetPositionInTRUFromAbsFastORIndex(id, iTRU, iEta, iPhi)) return kFALSE;
- if ( int( iTRU / 3 ) % 2 ) // C side
+ if (iTRU % 2) // C side
{
- iPhi = iPhi + 4 * ( 2 - ( iTRU % 3 ) );
+ iSM = 2 * ( int( int(iTRU / 2) / 3 ) ) + 1;
}
- else // A side
+ else // A side
{
- iPhi = iPhi + 4 * ( iTRU % 3 );
+ iSM = 2 * ( int( int(iTRU / 2) / 3 ) );
}
+
+ iPhi += 4 * int((iTRU % 6) / 2);
return kTRUE;
}
+//________________________________________________________________________________________________
+Bool_t AliEMCALGeoUtils::GetPositionInEMCALFromAbsFastORIndex(const Int_t id, Int_t& iEta, Int_t& iPhi) const
+{
+ Int_t iSM=-1;
+
+ if (GetPositionInSMFromAbsFastORIndex(id, iSM, iEta, iPhi))
+ {
+ if (iSM % 2) iEta += 24;
+
+ iPhi += 12 * int(iSM / 2);
+
+ return kTRUE;
+ }
+
+ return kFALSE;
+}
+
//________________________________________________________________________________________________
Bool_t AliEMCALGeoUtils::GetAbsFastORIndexFromPositionInTRU(const Int_t iTRU, const Int_t iEta, const Int_t iPhi, Int_t& id) const
{
//Trigger mapping method, get Index if FastOr from Position in TRU
- if (iTRU < 0 || iTRU > 31 || iEta < 0 || iEta > 23 || iPhi < 0 || iPhi > 3) return kFALSE;
+ if (iTRU < 0 || iTRU > 31 || iEta < 0 || iEta > 23 || iPhi < 0 || iPhi > 3)
+ {
+ AliError("Out of range!");
+ return kFALSE;
+ }
+
+ id = iPhi + 4 * iEta + iTRU * 96;
+
+ return kTRUE;
+}
+
+//________________________________________________________________________________________________
+Bool_t AliEMCALGeoUtils::GetAbsFastORIndexFromPositionInSM(const Int_t iSM, const Int_t iEta, const Int_t iPhi, Int_t& id) const
+{
+ //
+ if (iSM < 0 || iSM > 11 || iEta < 0 || iEta > 23 || iPhi < 0 || iPhi > 11)
+ {
+ AliError("Out of range!");
+ return kFALSE;
+ }
+
+ Int_t x = iEta;
+ Int_t y = iPhi % 4;
+
+ Int_t iOff = (iSM % 2) ? 1 : 0;
+ Int_t iTRU = 2 * int(iPhi / 4) + 6 * int(iSM / 2) + iOff;
+
+ if (GetAbsFastORIndexFromPositionInTRU(iTRU, x, y, id))
+ {
+ return kTRUE;
+ }
+
+ return kFALSE;
+}
+
+//________________________________________________________________________________________________
+Bool_t AliEMCALGeoUtils::GetAbsFastORIndexFromPositionInEMCAL(const Int_t iEta, const Int_t iPhi, Int_t& id) const
+{
+ //
+ if (iEta < 0 || iEta > 47 || iPhi < 0 || iPhi > 63 )
+ {
+ AliError("Out of range!");
+ return kFALSE;
+ }
+
+ if (fFastOR2DMap[iEta][iPhi] == -1)
+ {
+ AliError("Invalid index!");
+ return kFALSE;
+ }
+
+ id = fFastOR2DMap[iEta][iPhi];
+
+ return kTRUE;
+}
+
+//________________________________________________________________________________________________
+Bool_t AliEMCALGeoUtils::GetFastORIndexFromCellIndex(const Int_t id, Int_t& idx) const
+{
+ Int_t iSupMod, nModule, nIphi, nIeta, iphim, ietam;
+
+ Bool_t isOK = GetCellIndex( id, iSupMod, nModule, nIphi, nIeta );
+
+ GetModulePhiEtaIndexInSModule( iSupMod, nModule, iphim, ietam );
+
+ if (isOK && GetAbsFastORIndexFromPositionInSM(iSupMod, ietam, iphim, idx))
+ {
+ return kTRUE;
+ }
+
+ return kFALSE;
+}
+
+//________________________________________________________________________________________________
+Bool_t AliEMCALGeoUtils::GetCellIndexFromFastORIndex(const Int_t id, Int_t idx[4]) const
+{
+ Int_t iSM=-1, iEta=-1, iPhi=-1;
+ if (GetPositionInSMFromAbsFastORIndex(id, iSM, iEta, iPhi))
+ {
+ Int_t ix = 2 * iEta;
+ Int_t iy = 2 * iPhi;
+
+ for (Int_t i=0; i<2; i++)
+ {
+ for (Int_t j=0; j<2; j++)
+ {
+ idx[2*i+j] = GetAbsCellIdFromCellIndexes(iSM, iy + i, ix + j);
+ }
+ }
+
+ return kTRUE;
+ }
+
+ return kFALSE;
+}
+
+//________________________________________________________________________________________________
+Bool_t AliEMCALGeoUtils::GetTRUIndexFromSTUIndex(const Int_t id, Int_t& idx) const
+{
+ if (id > 31 || id < 0)
+ {
+ AliError(Form("TRU index out of range: %d",id));
+ return kFALSE;
+ }
+
+ idx = (id > 15) ? 2 * (31 - id) : 2 * (15 - id) + 1;
+
+ return kTRUE;
+}
+
+//________________________________________________________________________________________________
+Int_t AliEMCALGeoUtils::GetTRUIndexFromSTUIndex(const Int_t id) const
+{
+ if (id > 31 || id < 0)
+ {
+ AliError(Form("TRU index out of range: %d",id));
+ }
+
+ Int_t idx = (id > 15) ? 2 * (31 - id) : 2 * (15 - id) + 1;
- if ( int( iTRU / 3 ) % 2 ) // C side
+ return idx;
+}
+
+//________________________________________________________________________________________________
+void AliEMCALGeoUtils::BuildFastOR2DMap()
+{
+ // Needed by STU
+ for (Int_t i = 0; i < 32; i++)
{
- id = iPhi + 4 * ( 23 - iEta ) + iTRU * 96;
+ for (Int_t j = 0; j < 24; j++)
+ {
+ for (Int_t k = 0; k < 4; k++)
+ {
+ Int_t id;
+ if (GetAbsFastORIndexFromPositionInTRU(i, j, k, id))
+ {
+ Int_t x = j, y = k + 4 * int(i / 2);
+
+ if (i % 2) x += 24;
+
+ fFastOR2DMap[x][y] = id;
+ }
+ }
+ }
}
- else
+}
+
+//________________________________________________________________________________________________
+Bool_t AliEMCALGeoUtils::GetFastORIndexFromL0Index(const Int_t iTRU, const Int_t id, Int_t idx[], const Int_t size) const
+{
+ if (size <= 0 ||size > 4)
+ {
+ AliError("Size not supported!");
+ return kFALSE;
+ }
+
+ Int_t motif[4] = {0, 1, 4, 5};
+
+ switch (size)
{
- id = (3 - iPhi) + 4 * iEta + iTRU * 96;
+ case 1: // Cosmic trigger
+ if (!GetAbsFastORIndexFromTRU(iTRU, id, idx[0])) return kFALSE;
+ break;
+ case 4: // 4 x 4
+ for (Int_t k = 0; k < 4; k++)
+ {
+ Int_t iADC = motif[k] + 4 * int(id / 3) + (id % 3);
+
+ if (!GetAbsFastORIndexFromTRU(iTRU, iADC, idx[k])) return kFALSE;
+ }
+ break;
+ default:
+ break;
}
return kTRUE;
void GetModulePhiEtaIndexInSModuleFromTRUIndex(
Int_t itru, Int_t iphitru, Int_t ietatru, Int_t &ietaSM, Int_t &iphiSM) const;
Int_t GetAbsTRUNumberFromNumberInSm(const Int_t row, const Int_t col, const Int_t sm) const ;
+
+
+ void BuildFastOR2DMap();
Bool_t GetAbsFastORIndexFromTRU(const Int_t iTRU, const Int_t iADC, Int_t& id) const;
Bool_t GetAbsFastORIndexFromPositionInTRU(const Int_t iTRU, const Int_t iEta, const Int_t iPhi, Int_t& id) const;
+ Bool_t GetAbsFastORIndexFromPositionInSM( const Int_t iSM, const Int_t iEta, const Int_t iPhi, Int_t& id) const;
+ Bool_t GetAbsFastORIndexFromPositionInEMCAL( const Int_t iEta, const Int_t iPhi, Int_t& id) const;
Bool_t GetTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iADC) const;
Bool_t GetPositionInTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iEta, Int_t& iPhi) const;
Bool_t GetPositionInSMFromAbsFastORIndex(const Int_t id, Int_t& iSM, Int_t& iEta, Int_t& iPhi) const;
-
-
-
+ Bool_t GetPositionInEMCALFromAbsFastORIndex(const Int_t id, Int_t& iEta, Int_t& iPhi) const;
+ Bool_t GetFastORIndexFromCellIndex(const Int_t id, Int_t& idx) const;
+ Bool_t GetCellIndexFromFastORIndex(const Int_t id, Int_t idx[4]) const;
+ Bool_t GetTRUIndexFromSTUIndex(const Int_t id, Int_t& idx) const;
+ Int_t GetTRUIndexFromSTUIndex(const Int_t id) const;
+ Bool_t GetFastORIndexFromL0Index(const Int_t iTRU, const Int_t id, Int_t idx[], const Int_t size) const;
+
///////////////////
// useful utilities
//
Float_t fZLength; // Total length in z direction
Float_t fSampling; // Sampling factor
+ Int_t fFastOR2DMap[48][64]; // FastOR 2D Map over full EMCal
+
TGeoHMatrix* fkSModuleMatrix[12] ; //Orientations of EMCAL super modules
} ;
#endif // AliEMCALGEOUTILS_H
+
* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
+/*
+
+
+
+
+ Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
+*/
// --- ROOT system ---
#include <Riostream.h>
#include <TMath.h>
-// --- Standard library ---
-
// --- AliRoot header files ---
-
#include "AliEMCALRawDigit.h"
+#include "AliLog.h"
ClassImp(AliEMCALRawDigit)
AliEMCALRawDigit::AliEMCALRawDigit() : TObject(),
fId(-1),
fNSamples(0),
-fSamples(0x0)
+fSamples(0x0),
+fAmplitude(0),
+fTime(0)
{
// default ctor
}
AliEMCALRawDigit::AliEMCALRawDigit(Int_t id, Int_t timeSamples[], Int_t nSamples) : TObject(),
fId(id),
fNSamples(nSamples),
-fSamples(0x0)
+fSamples(0x0),
+fAmplitude(0),
+fTime(0)
{
//
- fSamples = new Int_t[fNSamples] ;
- for (Int_t i=0; i < fNSamples; i++) fSamples[i] = timeSamples[i];
-}
-
-//____________________________________________________________________________
-AliEMCALRawDigit::AliEMCALRawDigit(const AliEMCALRawDigit& digit) : TObject(),//AliDigitNew(digit),
-fId(digit.fId),
-fNSamples(digit.fNSamples),
-fSamples(0x0)
-
-{
- // Copy ctor
- // Data members of the base class (AliNewDigit)
-
-// fAmp = digit.fAmp;
-// fIndexInList = digit.fIndexInList;
- fSamples = new Int_t[fNSamples];
- for (Int_t i=0; i < digit.fNSamples; i++) fSamples[i] = digit.fSamples[i];
+ fSamples = new Int_t[fNSamples];
+ for (Int_t i = 0; i < fNSamples; i++) fSamples[i] = timeSamples[i];
}
//____________________________________________________________________________
AliEMCALRawDigit::~AliEMCALRawDigit()
{
- // Delete array of time samples
+ //dtor, delete array of time samples
if(fSamples) delete [] fSamples;
}
//____________________________________________________________________________
void AliEMCALRawDigit::Clear(Option_t *)
{
- // Delete array of time samples
+ // clear, delete array of time samples
if(fSamples) delete [] fSamples;
}
//____________________________________________________________________________
Bool_t AliEMCALRawDigit::GetTimeSample(const Int_t iSample, Int_t& timeBin, Int_t& amp) const
{
+ //
if (iSample > fNSamples || iSample < 0) return kFALSE;
amp = fSamples[iSample] & 0xFFF;
}
//____________________________________________________________________________
-void AliEMCALRawDigit::Print(const Option_t* /*opt*/) const
+void AliEMCALRawDigit::SetTimeSamples(const Int_t timeSamples[], const Int_t nSamples)
{
- printf("===\nDigit id: %4d / %d Time Samples: \n",fId,fNSamples);
- for (Int_t i=0; i < fNSamples; i++)
+ //
+ if (fSamples)
{
- Int_t timeBin=-1, amp=0;
- GetTimeSample(i, timeBin, amp);
- printf("(%d,%d) ",timeBin,amp);
+ AliWarning("Samples already filled: delete first!");
+ fNSamples = 0;
+ delete [] fSamples;
}
- printf("\n");
+ fNSamples = nSamples;
+ fSamples = new Int_t[fNSamples];
+ for (Int_t i = 0; i < fNSamples; i++) fSamples[i] = timeSamples[i];
}
//____________________________________________________________________________
-Int_t AliEMCALRawDigit::Compare(const TObject* obj) const
+Bool_t AliEMCALRawDigit::GetMaximum(Int_t& amplitude, Int_t& time) const
+{
+ //
+ if (!fNSamples)
+ {
+ AliError("Digit has no time sample");
+ return kFALSE;
+ }
+
+ amplitude = 0;
+ for (Int_t i = 0; i < fNSamples; i++)
+ {
+ Int_t t, a;
+ if (GetTimeSample(i, t, a))
+ {
+ if (a > amplitude)
+ {
+ amplitude = a;
+ time = t;
+ }
+ }
+ }
+
+ return kTRUE;
+}
+
+//____________________________________________________________________________
+Int_t AliEMCALRawDigit::Compare(const TObject * obj) const
{
// Compares two digits with respect to its Id
// to sort according increasing Id
-
- Int_t rv=2;
-
- AliEMCALRawDigit* digit = (AliEMCALRawDigit *)obj;
-
- Int_t iddiff = fId - digit->GetId();
-
- if ( iddiff > 0 )
- rv = 1;
- else if ( iddiff < 0 )
+
+ Int_t rv=0;
+
+ AliEMCALRawDigit* digit = (AliEMCALRawDigit*)obj;
+
+ Int_t iddiff = fId - digit->GetId();
+
+ if (iddiff > 0)
+ rv = 1;
+ else if (iddiff < 0)
rv = -1;
else
- rv = 0;
-
+ rv = 0;
+
return rv;
}
//____________________________________________________________________________
-Bool_t AliEMCALRawDigit::operator==(AliEMCALRawDigit const & digit) const
+void AliEMCALRawDigit::Print(const Option_t* /*opt*/) const
{
- // Two digits are equal if they have the same Id
-
- if(fId == digit.fId)
- return kTRUE;
- else
- return kFALSE;
+ //
+ printf("===\n| Digit id: %4d / %d Time Samples: \n",fId,fNSamples);
+ for (Int_t i=0; i < fNSamples; i++)
+ {
+ Int_t timeBin=-1, amp=0;
+ GetTimeSample(i, timeBin, amp);
+ printf("| (%d,%d) ",timeBin,amp);
+ }
+
+ printf("\n");
}
/* $Id: AliEMCALRawDigit.h 17335 2007-03-10 03:40:17Z mvl $ */
-// --- ROOT system ---
+/*
+
+
+ Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
+*/
#include "TObject.h"
-// --- Standard library ---
-
-// --- AliRoot header files ---
-//#include "AliDigitNew.h"
-
class AliEMCALRawDigit : public TObject
{
-// friend ostream& operator<<(ostream& , const AliEMCALRawDigit&);
-
public:
AliEMCALRawDigit();
AliEMCALRawDigit(Int_t id, Int_t timeSamples[], Int_t nSamples);
- AliEMCALRawDigit(const AliEMCALRawDigit& digit);
virtual ~AliEMCALRawDigit();
- void Clear(Option_t *);
- Bool_t operator==(const AliEMCALRawDigit &rValue) const;
- const AliEMCALRawDigit& operator = (const AliEMCALRawDigit&) {return *this;}
+ void Clear(Option_t *);
+ Bool_t IsSortable() const { return kTRUE;}
Int_t Compare(const TObject* obj) const;
- Bool_t IsSortable() const {return kTRUE;}
+
void SetId(Int_t id) {fId = id;}
- Int_t GetId() const {return fId;}
-
- Int_t GetNSamples() const {return fNSamples;}
+ void SetAmplitude(Float_t amp) {fAmplitude = amp;}
+ void SetTime(Float_t time) {fTime = time;}
+ void SetTimeSamples(const Int_t timeSamples[], const Int_t nSamples);
+
+ Int_t GetId() const {return fId;}
+ Float_t GetAmplitude() const {return fAmplitude;}
+ Float_t GetTime() const {return fTime;}
+ Int_t GetNSamples() const {return fNSamples;}
Bool_t GetTimeSample(const Int_t iSample, Int_t& timeBin, Int_t& amp) const;
+ Bool_t GetMaximum(Int_t& amplitude, Int_t& time) const;
+
virtual void Print(const Option_t* opt) const;
-private:
+protected:
+ AliEMCALRawDigit(const AliEMCALRawDigit &cd); // Not implemented
+ AliEMCALRawDigit &operator=(const AliEMCALRawDigit &cd); // Not implemented
+
Int_t fId; //Absolute id
Int_t fNSamples; //Number of time samples
Int_t* fSamples; //[fNSamples]
+ Float_t fAmplitude;
+ Float_t fTime;
ClassDef(AliEMCALRawDigit,1) // Digit in EMCAL
};
/* $Id$ */
+
//_________________________________________________________________________
// Utility Class for handling Raw data
// Does all transitions from Digits to Raw and vice versa,
#include "AliCaloRawAnalyzerLMS.h"
#include "AliCaloRawAnalyzerPeakFinder.h"
#include "AliCaloRawAnalyzerCrude.h"
+#include "AliEMCALTriggerRawDigitMaker.h"
+#include "AliEMCALTriggerSTURawStream.h"
+#include "AliEMCALTriggerData.h"
ClassImp(AliEMCALRawUtils)
fNPedSamples(0), fGeom(0), fOption(""),
fRemoveBadChannels(kTRUE),fFittingAlgorithm(0),
fTimeMin(-1.),fTimeMax(1.),
- fUseFALTRO(kFALSE),fRawAnalyzer(0)
+ fUseFALTRO(kFALSE),fRawAnalyzer(0),
+ fTriggerRawDigitMaker(0x0)
{
//These are default parameters.
}
if(!fGeom) AliFatal(Form("Could not get geometry!"));
+
+ fTriggerRawDigitMaker = new AliEMCALTriggerRawDigitMaker();
}
fNPedSamples(0), fGeom(pGeometry), fOption(""),
fRemoveBadChannels(kTRUE),fFittingAlgorithm(0),
fTimeMin(-1.),fTimeMax(1.),
- fUseFALTRO(kFALSE),fRawAnalyzer()
+ fUseFALTRO(kFALSE),fRawAnalyzer(),
+ fTriggerRawDigitMaker(0x0)
{
//
// Initialize with the given geometry - constructor required by HLT
}
if(!fGeom) AliFatal(Form("Could not get geometry!"));
-
+
+ fTriggerRawDigitMaker = new AliEMCALTriggerRawDigitMaker();
}
//____________________________________________________________________________
fRemoveBadChannels(rawU.fRemoveBadChannels),
fFittingAlgorithm(rawU.fFittingAlgorithm),
fTimeMin(rawU.fTimeMin),fTimeMax(rawU.fTimeMax),
- fUseFALTRO(rawU.fUseFALTRO),
- fRawAnalyzer(rawU.fRawAnalyzer)
+ fUseFALTRO(rawU.fUseFALTRO),
+ fRawAnalyzer(rawU.fRawAnalyzer),
+ fTriggerRawDigitMaker(rawU.fTriggerRawDigitMaker)
{
//copy ctor
fMapping[0] = rawU.fMapping[0];
fOption = rawU.fOption;
fRemoveBadChannels = rawU.fRemoveBadChannels;
fFittingAlgorithm = rawU.fFittingAlgorithm;
- fTimeMin = rawU.fTimeMin;
- fTimeMax = rawU.fTimeMax;
+ fTimeMin = rawU.fTimeMin;
+ fTimeMax = rawU.fTimeMax;
fUseFALTRO = rawU.fUseFALTRO;
fRawAnalyzer = rawU.fRawAnalyzer;
fMapping[0] = rawU.fMapping[0];
fMapping[1] = rawU.fMapping[1];
fMapping[2] = rawU.fMapping[2];
fMapping[3] = rawU.fMapping[3];
+ fTriggerRawDigitMaker = rawU.fTriggerRawDigitMaker;
}
return *this;
TArrayI adcValuesLow(fgTimeBins);
TArrayI adcValuesHigh(fgTimeBins);
-
+
// loop over digits (assume ordered digits)
for (Int_t iDigit = 0; iDigit < digits->GetEntries(); iDigit++) {
AliEMCALDigit* digit = dynamic_cast<AliEMCALDigit *>(digits->At(iDigit)) ;
- if (digit->GetAmplitude() < fgThreshold)
- continue;
-
- //get cell indices
- Int_t nSM = 0;
- Int_t nIphi = 0;
- Int_t nIeta = 0;
- Int_t iphi = 0;
- Int_t ieta = 0;
- Int_t nModule = 0;
- fGeom->GetCellIndex(digit->GetId(), nSM, nModule, nIphi, nIeta);
- fGeom->GetCellPhiEtaIndexInSModule(nSM, nModule, nIphi, nIeta,iphi, ieta) ;
-
- //Check which is the RCU, 0 or 1, of the cell.
- Int_t iRCU = -111;
- //RCU0
- if (0<=iphi&&iphi<8) iRCU=0; // first cable row
- else if (8<=iphi&&iphi<16 && 0<=ieta&&ieta<24) iRCU=0; // first half;
- //second cable row
- //RCU1
- else if(8<=iphi&&iphi<16 && 24<=ieta&&ieta<48) iRCU=1; // second half;
- //second cable row
- else if(16<=iphi&&iphi<24) iRCU=1; // third cable row
-
- if (nSM%2==1) iRCU = 1 - iRCU; // swap for odd=C side, to allow us to cable both sides the same
-
- if (iRCU<0)
- Fatal("Digits2Raw()","Non-existent RCU number: %d", iRCU);
-
- //Which DDL?
- Int_t iDDL = fgDDLPerSuperModule* nSM + iRCU;
- if (iDDL >= nDDL)
- Fatal("Digits2Raw()","Non-existent DDL board number: %d", iDDL);
-
- if (buffers[iDDL] == 0) {
- // open new file and write dummy header
- TString fileName = AliDAQ::DdlFileName("EMCAL",iDDL);
- //Select mapping file RCU0A, RCU0C, RCU1A, RCU1C
- Int_t iRCUside=iRCU+(nSM%2)*2;
- //iRCU=0 and even (0) SM -> RCU0A.data 0
- //iRCU=1 and even (0) SM -> RCU1A.data 1
- //iRCU=0 and odd (1) SM -> RCU0C.data 2
- //iRCU=1 and odd (1) SM -> RCU1C.data 3
- //cout<<" nSM "<<nSM<<"; iRCU "<<iRCU<<"; iRCUside "<<iRCUside<<endl;
- buffers[iDDL] = new AliAltroBuffer(fileName.Data(),fMapping[iRCUside]);
- buffers[iDDL]->WriteDataHeader(kTRUE, kFALSE); //Dummy;
- }
-
- // out of time range signal (?)
- if (digit->GetTimeR() > GetRawFormatTimeMax() ) {
- AliInfo("Signal is out of time range.\n");
- buffers[iDDL]->FillBuffer((Int_t)digit->GetAmplitude());
- buffers[iDDL]->FillBuffer(GetRawFormatTimeBins() ); // time bin
- buffers[iDDL]->FillBuffer(3); // bunch length
- buffers[iDDL]->WriteTrailer(3, ieta, iphi, nSM); // trailer
- // calculate the time response function
- } else {
- Bool_t lowgain = RawSampledResponse(digit->GetTimeR(), digit->GetAmplitude(), adcValuesHigh.GetArray(), adcValuesLow.GetArray()) ;
- if (lowgain)
- buffers[iDDL]->WriteChannel(ieta, iphi, 0, GetRawFormatTimeBins(), adcValuesLow.GetArray(), fgThreshold);
- else
- buffers[iDDL]->WriteChannel(ieta,iphi, 1, GetRawFormatTimeBins(), adcValuesHigh.GetArray(), fgThreshold);
+ if(!digit){
+ AliFatal("NULL Digit");
}
- }
-
+ else{
+ if (digit->GetAmplitude() < fgThreshold)
+ continue;
+
+ //get cell indices
+ Int_t nSM = 0;
+ Int_t nIphi = 0;
+ Int_t nIeta = 0;
+ Int_t iphi = 0;
+ Int_t ieta = 0;
+ Int_t nModule = 0;
+ fGeom->GetCellIndex(digit->GetId(), nSM, nModule, nIphi, nIeta);
+ fGeom->GetCellPhiEtaIndexInSModule(nSM, nModule, nIphi, nIeta,iphi, ieta) ;
+
+ //Check which is the RCU, 0 or 1, of the cell.
+ Int_t iRCU = -111;
+ //RCU0
+ if (0<=iphi&&iphi<8) iRCU=0; // first cable row
+ else if (8<=iphi&&iphi<16 && 0<=ieta&&ieta<24) iRCU=0; // first half;
+ //second cable row
+ //RCU1
+ else if(8<=iphi&&iphi<16 && 24<=ieta&&ieta<48) iRCU=1; // second half;
+ //second cable row
+ else if(16<=iphi&&iphi<24) iRCU=1; // third cable row
+
+ if (nSM%2==1) iRCU = 1 - iRCU; // swap for odd=C side, to allow us to cable both sides the same
+
+ if (iRCU<0)
+ Fatal("Digits2Raw()","Non-existent RCU number: %d", iRCU);
+
+ //Which DDL?
+ Int_t iDDL = fgDDLPerSuperModule* nSM + iRCU;
+ if (iDDL >= nDDL)
+ Fatal("Digits2Raw()","Non-existent DDL board number: %d", iDDL);
+
+ if (buffers[iDDL] == 0) {
+ // open new file and write dummy header
+ TString fileName = AliDAQ::DdlFileName("EMCAL",iDDL);
+ //Select mapping file RCU0A, RCU0C, RCU1A, RCU1C
+ Int_t iRCUside=iRCU+(nSM%2)*2;
+ //iRCU=0 and even (0) SM -> RCU0A.data 0
+ //iRCU=1 and even (0) SM -> RCU1A.data 1
+ //iRCU=0 and odd (1) SM -> RCU0C.data 2
+ //iRCU=1 and odd (1) SM -> RCU1C.data 3
+ //cout<<" nSM "<<nSM<<"; iRCU "<<iRCU<<"; iRCUside "<<iRCUside<<endl;
+ buffers[iDDL] = new AliAltroBuffer(fileName.Data(),fMapping[iRCUside]);
+ buffers[iDDL]->WriteDataHeader(kTRUE, kFALSE); //Dummy;
+ }
+
+ // out of time range signal (?)
+ if (digit->GetTimeR() > GetRawFormatTimeMax() ) {
+ AliInfo("Signal is out of time range.\n");
+ buffers[iDDL]->FillBuffer((Int_t)digit->GetAmplitude());
+ buffers[iDDL]->FillBuffer(GetRawFormatTimeBins() ); // time bin
+ buffers[iDDL]->FillBuffer(3); // bunch length
+ buffers[iDDL]->WriteTrailer(3, ieta, iphi, nSM); // trailer
+ // calculate the time response function
+ } else {
+ Bool_t lowgain = RawSampledResponse(digit->GetTimeR(), digit->GetAmplitude(), adcValuesHigh.GetArray(), adcValuesLow.GetArray()) ;
+ if (lowgain)
+ buffers[iDDL]->WriteChannel(ieta, iphi, 0, GetRawFormatTimeBins(), adcValuesLow.GetArray(), fgThreshold);
+ else
+ buffers[iDDL]->WriteChannel(ieta,iphi, 1, GetRawFormatTimeBins(), adcValuesHigh.GetArray(), fgThreshold);
+ }
+ }//digit exists
+ }//Digit loop
+
// write headers and close files
for (Int_t i=0; i < nDDL; i++) {
if (buffers[i]) {
delete buffers[i];
}
}
-
+
loader->UnloadDigits();
}
//____________________________________________________________________________
-void AliEMCALRawUtils::Raw2Digits(AliRawReader* reader,TClonesArray *digitsArr, const AliCaloCalibPedestal* pedbadmap, TClonesArray *digitsTRG)
+void AliEMCALRawUtils::Raw2Digits(AliRawReader* reader,TClonesArray *digitsArr, const AliCaloCalibPedestal* pedbadmap, TClonesArray *digitsTRG, AliEMCALTriggerData* trgData)
{
// convert raw data of the current event to digits
- digitsArr->Clear("C");
+ if(digitsArr) digitsArr->Clear("C");
if (!digitsArr) {
Error("Raw2Digits", "no digits found !");
Error("Raw2Digits", "no raw reader found !");
return;
}
-
- AliCaloRawStreamV3 in(reader,"EMCAL",fMapping);
+
+ AliEMCALTriggerSTURawStream inSTU(reader);
+
+ AliCaloRawStreamV3 in(reader,"EMCAL",fMapping);
+
// Select EMCAL DDL's;
reader->Select("EMCAL",0,43); // 43 = AliEMCALGeoParams::fgkLastAltroDDL
+ fTriggerRawDigitMaker->Reset();
+ fTriggerRawDigitMaker->SetIO(reader, in, inSTU, digitsTRG, trgData);
+
// fRawAnalyzer setup
fRawAnalyzer->SetNsampleCut(5); // requirement for fits to be done, for the new methods
fRawAnalyzer->SetOverflowCut(fgkOverflowCut);
}//ALTRO
else if(fUseFALTRO)
{// Fake ALTRO
- // if (maxTimeBin && gSig->GetN() > maxTimeBin + 10) gSig->Set(maxTimeBin + 10); // set actual max size of TGraph
- Int_t hwAdd = in.GetHWAddress();
- UShort_t iRCU = in.GetDDLNumber() % 2; // 0/1
- UShort_t iBranch = ( hwAdd >> 11 ) & 0x1; // 0/1
-
- // Now find TRU number
- Int_t itru = 3 * in.GetModule() + ( (iRCU << 1) | iBranch ) - 1;
-
- AliDebug(1,Form("Found TRG digit in TRU: %2d ADC: %2d",itru,in.GetColumn()));
-
- Int_t idtrg=0;
-
- Bool_t isOK = fGeom->GetAbsFastORIndexFromTRU(itru, in.GetColumn(), idtrg);
-
- Int_t timeSamples[256]; for (Int_t j=0;j<256;j++) timeSamples[j] = 0;
- Int_t nSamples = 0;
-
- for (std::vector<AliCaloBunchInfo>::iterator itVectorData = bunchlist.begin(); itVectorData != bunchlist.end(); itVectorData++)
- {
- AliCaloBunchInfo bunch = *(itVectorData);
-
- const UShort_t* sig = bunch.GetData();
- Int_t startBin = bunch.GetStartBin();
-
- for (Int_t iS = 0; iS < bunch.GetLength(); iS++)
- {
- Int_t time = startBin--;
- Int_t amp = sig[iS];
-
- if ( amp ) timeSamples[nSamples++] = ( ( time << 12 ) & 0xFF000 ) | ( amp & 0xFFF );
- }
- }
-
- if (nSamples && isOK) AddDigit(digitsTRG, idtrg, timeSamples, nSamples);
+ fTriggerRawDigitMaker->Add( bunchlist );
}//Fake ALTRO
} // end while over channel
} //end while over DDL's, of input stream
+ fTriggerRawDigitMaker->PostProcess();
+
TrimDigits(digitsArr);
return ;
}
-//____________________________________________________________________________
-void AliEMCALRawUtils::AddDigit(TClonesArray *digitsArr, Int_t id, Int_t timeSamples[], Int_t nSamples)
-{
- //Add raw sample to raw digit
- new((*digitsArr)[digitsArr->GetEntriesFast()]) AliEMCALRawDigit(id, timeSamples, nSamples);
-
- // Int_t idx = digitsArr->GetEntriesFast()-1;
- // AliEMCALRawDigit* d = (AliEMCALRawDigit*)digitsArr->At(idx);
-}
-
//____________________________________________________________________________
void AliEMCALRawUtils::AddDigit(TClonesArray *digitsArr, Int_t id, Int_t lowGain, Float_t amp, Float_t time, Float_t chi2, Int_t ndf) {
//
// N: par[3]
// ped: par[4]
//
- Double_t signal = 0. ;
- Double_t tau = par[2];
- Double_t n = par[3];
- Double_t ped = par[4];
- Double_t xx = ( x[0] - par[1] + tau ) / tau ;
+ Double_t signal = 0.;
+ Double_t tau = par[2];
+ Double_t n = par[3];
+ Double_t ped = par[4];
+ Double_t xx = ( x[0] - par[1] + tau ) / tau ;
if (xx <= 0)
signal = ped ;
// ped: par[4]
//
Double_t signal = 0. ;
- Double_t tau = par[2];
- Double_t n = par[3];
+ Double_t tau = par[2];
+ Double_t n = par[3];
//Double_t ped = par[4]; // not used
- Double_t xx = ( x[0] - par[1] + tau ) / tau ;
+ Double_t xx = ( x[0] - par[1] + tau ) / tau ;
if (xx < 0)
signal = par[0] - n*TMath::Log(TMath::Abs(xx)) + n * (1 - xx ) ;
class AliEMCALGeometry;
class AliCaloCalibPedestal;
class AliCaloRawAnalyzer;
+class AliEMCALTriggerRawDigitMaker;
+class AliEMCALTriggerData;
class AliEMCALRawUtils : public TObject {
public:
void Digits2Raw();
void Raw2Digits(AliRawReader *reader, TClonesArray *digitsArr, const AliCaloCalibPedestal* pedbadmap,
- TClonesArray *digitsTRG=0x0);
+ TClonesArray *digitsTRG=0x0, AliEMCALTriggerData* trgData = 0x0);
void AddDigit(TClonesArray *digitsArr, Int_t id, Int_t lowGain, Float_t amp, Float_t time, Float_t chi2, Int_t ndf);
- void AddDigit(TClonesArray *digitsArr, Int_t id, Int_t timeSamples[], Int_t nSamples);
+// void AddDigit(TClonesArray *digitsArr, Int_t id, Int_t timeSamples[], Int_t nSamples);
void TrimDigits(TClonesArray *digitsArr);
// Signal shape parameters
AliCaloRawAnalyzer *fRawAnalyzer; // e.g. for sample selection for fits
+ AliEMCALTriggerRawDigitMaker* fTriggerRawDigitMaker;
+
ClassDef(AliEMCALRawUtils,7) // utilities for raw signal fitting
};
#include "AliEMCALTriggerElectronics.h"
#include "AliEMCALTriggerDCSConfigDB.h"
#include "AliEMCALTriggerDCSConfig.h"
+#include "AliEMCALTriggerData.h"
+#include "AliEMCALTriggerRawDigit.h"
+#include "AliEMCALTriggerPatch.h"
+#include "AliEMCALTriggerTypes.h"
ClassImp(AliEMCALReconstructor)
AliEMCALTriggerElectronics* AliEMCALReconstructor::fgTriggerProcessor = 0x0;
//____________________________________________________________________________
AliEMCALReconstructor::AliEMCALReconstructor()
- : fDebug(kFALSE), fList(0), fGeom(0),fCalibData(0),fPedestalData(0)
+ : fDebug(kFALSE), fList(0), fGeom(0),fCalibData(0),fPedestalData(0),fTriggerData(0x0)
{
// ctor
//Get calibration parameters
if(!fPedestalData)
{
- AliCDBEntry *entry = (AliCDBEntry*)
- AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
- if (entry) fPedestalData = (AliCaloCalibPedestal*) entry->GetObject();
+ AliCDBEntry *entry = (AliCDBEntry*)
+ AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
+ if (entry) fPedestalData = (AliCaloCalibPedestal*) entry->GetObject();
}
-
+
if(!fPedestalData)
AliFatal("Dead map not found in CDB!");
-
+
InitClusterizer();
-
+
if(!fGeom) AliFatal(Form("Could not get geometry!"));
AliEMCALTriggerDCSConfigDB* dcsConfigDB = AliEMCALTriggerDCSConfigDB::Instance();
if (!dcsConfig) AliFatal("No Trigger DCS Configuration from OCDB!");
fgTriggerProcessor = new AliEMCALTriggerElectronics( dcsConfig );
-
- //Init temporary list of digits
+
+ fTriggerData = new AliEMCALTriggerData();
+
+ //Init temporary list of digits
fgDigitsArr = new TClonesArray("AliEMCALDigit",1000);
fgClustersArr = new TObjArray(1000);
-
+
}
//____________________________________________________________________________
if(fGeom) delete fGeom;
if(fCalibData) delete fCalibData;
if(fPedestalData) delete fPedestalData;
-
+
if(fgDigitsArr){
fgDigitsArr->Clear("C");
delete fgDigitsArr;
AliEMCALRecParam *recParam = NULL;
AliCDBEntry *entry = (AliCDBEntry*)
- AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam");
+ AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam");
//Get The reco param for the default event specie
if (entry)
- recParam = (AliEMCALRecParam*)((TObjArray *) entry->GetObject())->At(0);
-
+ recParam = (AliEMCALRecParam*)((TObjArray *) entry->GetObject())->At(0);
+
if(!recParam)
AliFatal("RecoParam not found in CDB!");
-
+
if (recParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1)
- {
- fgClusterizer = new AliEMCALClusterizerv1(fGeom, fCalibData,fPedestalData);
- }
+ {
+ fgClusterizer = new AliEMCALClusterizerv1(fGeom, fCalibData,fPedestalData);
+ }
else
- {
- fgClusterizer = new AliEMCALClusterizerNxN(fGeom, fCalibData,fPedestalData);
- }
+ {
+ fgClusterizer = new AliEMCALClusterizerNxN(fGeom, fCalibData,fPedestalData);
+ }
}
AliCodeTimerAuto("",0)
ReadDigitsArrayFromTree(digitsTree);
-
+
fgClusterizer->InitParameters();
fgClusterizer->SetOutput(clustersTree);
-
- AliEMCALTriggerData* trgData = new AliEMCALTriggerData();
-
- Int_t bufferSize = 32000;
-
- if (TBranch* triggerBranch = clustersTree->GetBranch("EMTRG"))
- triggerBranch->SetAddress(&trgData);
- else
- clustersTree->Branch("EMTRG","AliEMCALTriggerData",&trgData,bufferSize);
-
- TClonesArray *trgDigits = new TClonesArray("AliEMCALRawDigit",1000);
- TBranch *branchdig = digitsTree->GetBranch("EMTRG");
- if (!branchdig)
- {
- AliError("Can't get the branch with the EMCAL trigger digits !");
- return;
- }
-
- branchdig->SetAddress(&trgDigits);
- branchdig->GetEntry(0);
-
+
//Skip clusterization of LED events
if (GetRecParam()->GetEventSpecie()!=AliRecoParam::kCalib){
- Int_t v0M[2] = {0,0};
- fgTriggerProcessor->Digits2Trigger(trgDigits, v0M, trgData);
-
-
- if(fgDigitsArr && fgDigitsArr->GetEntries()) {
+ if(fgDigitsArr && fgDigitsArr->GetEntries()) {
fgClusterizer->SetInput(digitsTree);
}//not a LED event
clustersTree->Fill();
- trgDigits->Delete();
- delete trgDigits; trgDigits = 0x0;
- delete trgData; trgData = 0x0;
-
}
//____________________________________________________________________________
// Works on a single-event basis
rawReader->Reset() ;
+
+ fTriggerData->SetMode(1);
+
if(fgDigitsArr) fgDigitsArr->Clear("C");
-
- TClonesArray *digitsTrg = new TClonesArray("AliEMCALRawDigit", 200);
+
+ TClonesArray *digitsTrg = new TClonesArray("AliEMCALTriggerRawDigit", 32 * 96);
Int_t bufsize = 32000;
digitsTree->Branch("EMCAL", &fgDigitsArr, bufsize);
fgRawUtils->SetTimeMin(GetRecParam()->GetTimeMin());
fgRawUtils->SetTimeMax(GetRecParam()->GetTimeMax());
- fgRawUtils->Raw2Digits(rawReader,fgDigitsArr,fPedestalData,digitsTrg);
+ fgRawUtils->Raw2Digits(rawReader,fgDigitsArr,fPedestalData,digitsTrg,fTriggerData);
}//skip calibration event
else{
AliDebug(1," Calibration Event, skip!");
// Called by AliReconstruct after Reconstruct() and global tracking and vertexing
// and V0
// Works on the current event
- // printf(" ## AliEMCALReconstructor::FillESD() is started ### \n ");
+ // printf(" ## AliEMCALReconstructor::FillESD() is started ### \n ");
//return;
+ //FIXME UNCOMMENT WHEN ESDTRIGGER AVAILABLE
+// // Trigger
+// Int_t v0M[2] = {0, 0};
+
+// AliESDVZERO* esdV0 = esd->GetVZEROData();
+
+// if (esdV0)
+// {
+// for (Int_t i = 0; i < 32; i++)
+// {
+// v0M[0] += esdV0->GetAdcV0C(i);
+// v0M[1] += esdV0->GetAdcV0A(i);
+// }
+// }
+// else
+// {
+// AliWarning("Cannot retrieve V0 ESD! Run w/ null V0 charges");
+// }
+
+// TClonesArray *trgDigits = new TClonesArray("AliEMCALTriggerRawDigit",1000);
+
+// TBranch *branchtrg = digitsTree->GetBranch("EMTRG");
+
+// if (!branchtrg)
+// {
+// AliError("Can't get the branch with the EMCAL trigger digits!");
+// return;
+// }
+
+// branchtrg->SetAddress(&trgDigits);
+// branchtrg->GetEntry(0);
+
+// // Note: fgTriggerProcessor reset done at the end of this method
+// fgTriggerProcessor->Digits2Trigger(trgDigits, v0M, fTriggerData);
+
+// // Fill ESD
+// AliESDCaloTrigger* trgESD = esd->GetCaloTrigger("EMCAL");
+
+// if (trgESD)
+// {
+// trgESD->Allocate(trgDigits->GetEntriesFast());
+
+// for (Int_t i = 0; i < trgDigits->GetEntriesFast(); i++)
+// {
+// AliEMCALTriggerRawDigit* rdig = (AliEMCALTriggerRawDigit*)trgDigits->At(i);
+
+// Int_t px, py;
+// if (fGeom->GetPositionInEMCALFromAbsFastORIndex(rdig->GetId(), px, py))
+// {
+// Int_t a = -1, t = -1, times[10];
+
+// rdig->GetMaximum(a, t);
+// rdig->GetL0Times(times);
+
+// // rdig->Print("");
+
+// trgESD->Add(px, py, a, t, times, rdig->GetNL0Times(), rdig->GetL1TimeSum());
+// }
+// }
+
+// // cout << "End of Adding................." << endl;
+
+// trgESD->SetL1Threshold(0, fTriggerData->GetL1GammaThreshold());
+
+// trgESD->SetL1Threshold(1, fTriggerData->GetL1JetThreshold() );
+
+// for (Int_t i = 0; i < kTriggerTypeEnd; i++)
+// {
+// for (Int_t j = 0; j < 2; j++)
+// {
+// TClonesArray* patches = fTriggerData->GetPatches((TriggerType_t)i, j);
+
+// TIter NextPatch(patches);
+// while (AliEMCALTriggerPatch* p = (AliEMCALTriggerPatch*)NextPatch())
+// {
+// TVector2 pos; p->Position(pos);
+// trgESD->SetTriggerBits(pos.X(), pos.Y(), i, j);
+// }
+// }
+// }
+// }
+
+// // Resetting
+// fTriggerData->Reset();
+// // cout << "Reset trg data" << endl;
+ //FIXME UNCOMMENT WHEN ESDTRIGGER AVAILABLE
+
//########################################
//##############Fill CaloCells###############
//########################################
ReadDigitsArrayFromTree(digitsTree);
-// TClonesArray *digits = new TClonesArray("AliEMCALDigit",1000);
-// TBranch *branchdig = digitsTree->GetBranch("EMCAL");
-// if (!branchdig) {
-// AliError("can't get the branch with the EMCAL digits !");
-// return;
-// }
-// branchdig->SetAddress(&digits);
-// digitsTree->GetEvent(0);
+// TClonesArray *digits = new TClonesArray("AliEMCALDigit",1000);
+// TBranch *branchdig = digitsTree->GetBranch("EMCAL");
+// if (!branchdig) {
+// AliError("can't get the branch with the EMCAL digits !");
+// return;
+// }
+// branchdig->SetAddress(&digits);
+// digitsTree->GetEvent(0);
Int_t nDigits = fgDigitsArr->GetEntries(), idignew = 0 ;
AliDebug(1,Form("%d digits",nDigits));
Double_t *newFracList = new Double_t[newCellMult];
for(Int_t i = 0; i < newCellMult ; i++) {
newAbsIdList[i]=absIdList[i];
- newFracList[i]=fracList[i];
+ newFracList[i] =fracList[i];
}
ec->SetCellsAbsId(newAbsIdList);
ec->SetCellsAmplitudeFraction(newFracList);
pid->SetReconstructor(kTRUE);
pid->RunPID(esd);
delete pid;
-
- //delete digits;
- //delete clusters;
-
+
//Store EMCAL misalignment matrixes
FillMisalMatrixes(esd) ;
class AliEMCALCalibData ;
class AliCaloCalibPedestal ;
class AliEMCALTriggerElectronics;
+class AliEMCALTriggerData;
// --- Standard library ---
virtual void Init() {;}
virtual void InitClusterizer();
-
+
Bool_t Debug() const { return fDebug ; }
using AliReconstructor::FillESD;
AliCaloCalibPedestal * fPedestalData ; //! Tower status database if aval
static AliEMCALTriggerElectronics* fgTriggerProcessor;
-
+ AliEMCALTriggerData* fTriggerData;
+
+
ClassDef(AliEMCALReconstructor,10) // Reconstruction algorithm class (Base Class)
};
{
for (Int_t i=0;i<fRegionSize->X();i++)
{
- if (fRegion[i]) {delete fRegion[i]; fRegion[i] = 0;}
- if ( fMap[i]) {delete fMap[i]; fMap[i] = 0;}
+ if (fRegion[i]) {free(fRegion[i]); fRegion[i] = 0;}
+ if ( fMap[i]) {free(fMap[i]); fMap[i] = 0;}
}
- delete [] fRegion; fRegion = 0x0;
- delete [] fMap; fMap = 0x0;
+ free(fRegion); fRegion = 0x0;
+ free(fMap); fMap = 0x0;
if(fPatches)fPatches->Delete();
+
delete fPatches;
}
}
//_______________
-void AliEMCALTriggerBoard::SlidingWindow( L1TriggerType_t /*type*/, Int_t thres )
+void AliEMCALTriggerBoard::SlidingWindow(TriggerType_t /*type*/, Int_t thres, Int_t time)
{
//
Int_t ipatch = 0;
//if ( type == kJet ) sum /= 4; // truncate patch sum for jet case
new((*fPatches)[fPatches->GetLast()+1])
- AliEMCALTriggerPatch( int(i/fSubRegionSize->X()), int(j/fSubRegionSize->Y()), int(sum) );
+ AliEMCALTriggerPatch(int(i/fSubRegionSize->X()), int(j/fSubRegionSize->Y()), int(sum), time);
}
}
}
Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
*/
+#include "AliEMCALTriggerTypes.h"
+
#include "TVector2.h"
class TClonesArray;
-typedef enum { kGamma, kJet } L1TriggerType_t;
-
class AliEMCALTriggerBoard : public TObject
{
AliEMCALTriggerBoard(const TVector2& RegionSize);
virtual ~AliEMCALTriggerBoard();
- virtual void SlidingWindow(L1TriggerType_t type, Int_t Threshold);
+ virtual void SlidingWindow(TriggerType_t type, Int_t Threshold, Int_t time = -1);
virtual void ZeroRegion();
virtual void SetRegionSize(const TVector2& Size) { *fRegionSize = Size;}
virtual void SetPatchSize(const TVector2& Size) { *fPatchSize = Size;}
virtual void SetSubRegionSize(const TVector2& Size) { *fSubRegionSize = Size;}
+
+ virtual void SetRegion(Int_t arr[][64]) {for (Int_t i = 0; i < fRegionSize->X(); i++) for (Int_t j = 0; j < fRegionSize->Y(); j++) fRegion[i][j] = arr[i][j];}
virtual Int_t** Region() {return fRegion;}
virtual Int_t** Map() {return fMap;}
- virtual void Map(Int_t arr[][64], const TVector2& Size) {for (Int_t i=0;i<Size.X();i++) for (Int_t j=0;j<Size.Y();j++) arr[i][j] = fMap[i][j];}
+ virtual void Map(Int_t arr[][64], const TVector2& Size) {for (Int_t i = 0; i < Size.X(); i++) for (Int_t j = 0; j < Size.Y(); j++) arr[i][j] = fMap[i][j];}
private:
* provided "as is" without express or implied warranty. *
**************************************************************************/
+/*
+
+
+
+
+Adapted from TRD
+Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
+*/
+
#include <TClonesArray.h>
#include <TObjArray.h>
// Retrieves a cdb object with the given id. The objects are cached as
// long as the run number is not changed.
//
- // Put together the available objects here by using the lines
- // a) For usual calibration objects:
- // case kID<Name> :
- // return CacheCDBEntry(kID<Name>,"TRD/Calib/<Path>");
- // break;
- // See function CacheCDBEntry for details.
- // and
- // b) For calibration data which depends on two objects: One containing
- // a value per detector and one the local fluctuations per pad:
- // case kID<Name> :
- // return CacheMergeCDBEntry(kID<Name>,"TRD/Calib/<padPath>","TRD/Calib/<chamberPath>");
- // break;
- // See function CacheMergeCDBEntry for details.
- //
-
switch (id)
{
// Parameters defined per pad and chamber
}
//_____________________________________________________________________________
-void AliEMCALTriggerDCSConfigDB::GetSTUSegmentation(Int_t ss[], Int_t sp[])
+void AliEMCALTriggerDCSConfigDB::GetSTUSegmentation(Int_t ssg[], Int_t spg[], Int_t ssj[], Int_t spj[])
{
//
//
switch ( fw )
{
case 2223:
- ss[0] = 4;
- ss[1] = 4;
- sp[0] = 2;
- sp[1] = 2;
+ ssg[0] = 1;
+ ssg[1] = 1;
+ spg[0] = 2;
+ spg[1] = 2;
+
+ ssj[0] = 4;
+ ssj[1] = 4;
+ spj[0] = 2;
+ spj[1] = 2;
break;
default:
AliError("Firmware version do not match!");
}
}
+//_____________________________________________________________________________
+Int_t AliEMCALTriggerDCSConfigDB::GetTRUSegmentation(Int_t iTRU)
+{
+ //
+ const AliEMCALTriggerDCSConfig* dcsConf = dynamic_cast<const AliEMCALTriggerDCSConfig*>(GetCachedCDBObject(kIDTriggerConfig));
+
+ AliEMCALTriggerTRUDCSConfig* truConf = dcsConf->GetTRUDCSConfig(iTRU);
+
+ Int_t sel = truConf->GetL0SEL();
+
+ if (sel & 0x0001)
+ return 2;
+ else
+ return 1;
+}
+
//_____________________________________________________________________________
Int_t AliEMCALTriggerDCSConfigDB::GetTRUGTHRL0(Int_t iTRU)
{
* See cxx source for full Copyright notice */
/*
- adapted from TRD: thanks!
+
+
+
+Adapted from TRD: thanks!
+Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
*/
#ifndef ROOT_TObject
void SetRun(Long64_t run);
Long64_t GetRun() const { return fRun; }
const AliEMCALTriggerDCSConfig* GetTriggerDCSConfig();
- void GetSTUSegmentation(Int_t ss[], Int_t sp[]);
+ void GetSTUSegmentation(Int_t ssg[], Int_t spg[], Int_t ssj[], Int_t spj[]);
+ Int_t GetTRUSegmentation(Int_t iTRU);
Int_t GetTRUGTHRL0(Int_t iTRU);
protected:
EMCal trigger data container
-for persistency of produced data presently stored in TTreeD
+for data (both raw & rec) persistency
Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
*/
#include "AliEMCALTriggerData.h"
#include "AliEMCALTriggerPatch.h"
+#include "AliLog.h"
+#include "Riostream.h"
ClassImp(AliEMCALTriggerData)
//_____________
AliEMCALTriggerData::AliEMCALTriggerData() : TObject(),
-fL0Patches( new TClonesArray("AliEMCALTriggerPatch") ),
-fL0NPatches(),
-fL0RegionSize(0,0),
-fL0SubRegionSize(0,0),
-fL0PatchSize(0,0),
-fL1GammaPatches( new TClonesArray("AliEMCALTriggerPatch") ),
-fL1JetPatches( new TClonesArray("AliEMCALTriggerPatch") ),
-fL1RegionSize(0,0),
-fL1GammaPatchSize(0,0),
-fL1GammaSubRegionSize(0,0),
-fL1JetPatchSize(0,0),
-fL1JetSubRegionSize(0,0)
+fMode(0),
+fL0Patches(),
+fL0Region(),
+fL1GammaPatches(),
+fL1JetPatches(),
+fL1Region(),
+fL1GammaThreshold(0),
+fL1JetThreshold(0)
{
- for (Int_t i=0;i<32;i++) fL0NPatches[i] = 0;
- for (Int_t i=0;i<48;i++) for (Int_t j=0;j<64;j++) fL1Region[i][j] = 0;
+ //
+ for (Int_t i = 0; i < 2; i++)
+ {
+ fL0Patches[i] = new TClonesArray("AliEMCALTriggerPatch");
+ fL1GammaPatches[i] = new TClonesArray("AliEMCALTriggerPatch");
+ fL1JetPatches[i] = new TClonesArray("AliEMCALTriggerPatch");
+ }
- fL1V0[0] = fL1V0[1] = 0;
+ for (Int_t i = 0; i < 32; i++) for (Int_t j = 0; j < 24; j++) for (Int_t k = 0; k < 4; k++) fL0Region[i][j][k] = 0;
+ for (Int_t i = 0; i < 2; i++) for (Int_t j = 0; j < 48; j++) for (Int_t k = 0; k < 64; k++) fL1Region[i][j][k] = 0;
}
//_____________
AliEMCALTriggerData::~AliEMCALTriggerData()
{
+ //
+ for (Int_t i = 0; i < 2; i++)
+ {
+ if ( fL0Patches[i]) fL0Patches[i]->Delete();
+ if (fL1GammaPatches[i]) fL1GammaPatches[i]->Delete();
+ if ( fL1JetPatches[i]) fL1JetPatches[i]->Delete();
+ }
}
//_____________
-void AliEMCALTriggerData::SetL0Patches(Int_t i, const TClonesArray& patches)
+void AliEMCALTriggerData::SetL0Region(Int_t i, const Int_t**& region)
{
- Int_t new_size = patches.GetEntriesFast();
- Int_t old_size = fL0Patches->GetEntriesFast();
-
- fL0NPatches[i] = new_size;
-
- Int_t size = 0;
- for (Int_t j=0;j<=i;j++) size += fL0NPatches[j];
-
- fL0Patches->Expand( size );
-
- for (Int_t j=0;j<new_size;j++)
+ //
+ if (i < 0 || i > 31)
{
- AliEMCALTriggerPatch* p = static_cast<AliEMCALTriggerPatch*>( patches.At(j) );
- new((*fL0Patches)[old_size+j]) AliEMCALTriggerPatch( *p );
+ AliError("Bad index!");
+ return;
}
+
+ for (Int_t j=0;j<24;j++)
+ for (Int_t k=0;k<4;k++) fL0Region[i][j][k] = region[j][k];
}
//_____________
-void AliEMCALTriggerData::SetL1GammaPatches(const TClonesArray& patches)
+void AliEMCALTriggerData::GetPatches(TriggerType_t type, Int_t i, TClonesArray& patches) const
{
- Int_t size = patches.GetEntriesFast();
- fL1GammaPatches->Expand( size );
-
- for (Int_t j=0;j<size;j++)
+ //
+ if (i < 0 || i > 1)
{
- AliEMCALTriggerPatch* p = static_cast<AliEMCALTriggerPatch*>( patches.At(j) );
- new((*fL1GammaPatches)[j]) AliEMCALTriggerPatch( *p );
+ AliError("Bad index!");
+ return;
+ }
+
+ switch (type)
+ {
+ case kL0:
+ patches = *fL0Patches[i];
+ break;
+ case kL1Gamma:
+ patches = *fL1GammaPatches[i];
+ break;
+ case kL1Jet:
+ patches = *fL1JetPatches[i];
+ break;
+ default:
+ AliError("Unknown trigger type!");
+ break;
}
}
//_____________
-void AliEMCALTriggerData::SetL1JetPatches(const TClonesArray& patches)
+TClonesArray* AliEMCALTriggerData::GetPatches(TriggerType_t type, Int_t i) const
{
- Int_t size = patches.GetEntriesFast();
-
- fL1JetPatches->Expand( size );
+ //
+ if (i < 0 || i > 1)
+ {
+ AliError("Bad index!");
+ return 0x0;
+ }
- for (Int_t j=0;j<size;j++)
+ switch (type)
{
- AliEMCALTriggerPatch* p = static_cast<AliEMCALTriggerPatch*>( patches.At(j) );
- new((*fL1JetPatches)[j]) AliEMCALTriggerPatch( *p );
+ case kL0:
+ return fL0Patches[i];
+ break;
+ case kL1Gamma:
+ return fL1GammaPatches[i];
+ break;
+ case kL1Jet:
+ return fL1JetPatches[i];
+ break;
+ default:
+ AliError("Unknown trigger type!");
+ break;
}
+
+ return 0x0;
}
//_____________
-void AliEMCALTriggerData::SetL1Region(Int_t**& region)
+void AliEMCALTriggerData::SetPatches(TriggerType_t type, Int_t i, const TClonesArray& patches)
{
//
- for (Int_t i=0;i<48;i++)
- for (Int_t j=0;j<64;j++)
+ if (i < 0 || i > 1)
+ {
+ AliError("Bad index!");
+ return;
+ }
+
+ if (patches.GetEntriesFast())
+ {
+ TClonesArray* arr = 0x0;
+
+ switch (type)
{
- fL1Region[i][j] = region[i][j];
+ case kL0:
+ arr = fL0Patches[i];
+ break;
+ case kL1Gamma:
+ arr = fL1GammaPatches[i];
+ break;
+ case kL1Jet:
+ arr = fL1JetPatches[i];
+ break;
+ default:
+ AliError("Unknown trigger type!");
+ return;
}
+
+ if (arr)
+ {
+ Int_t size = arr->GetSize() + patches.GetSize();
+
+ arr->Expand(size);
+
+ for (Int_t k = 0; k < patches.GetEntriesFast(); k++)
+ {
+ AliEMCALTriggerPatch* p = static_cast<AliEMCALTriggerPatch*>(patches.At(k));
+ new((*arr)[arr->GetEntriesFast()]) AliEMCALTriggerPatch(*p);
+ }
+ }
+ else
+ {
+ AliError("TClonesArray is NULL!");
+ }
+ }
}
//_____________
-void AliEMCALTriggerData::SetL1V0(const Int_t*& arr)
+void AliEMCALTriggerData::SetL1Region(Int_t i, Int_t**& region)
{
- for (Int_t i=0;i<2;i++) fL1V0[i] = arr[i];
+ //
+ if (i < 0 || i > 1)
+ {
+ AliError("Bad index!");
+ return;
+ }
+
+ for (Int_t j = 0; j < 48; j++)
+ for (Int_t k = 0; k < 64; k++) fL1Region[i][j][k] = region[j][k];
}
+//_____________
+void AliEMCALTriggerData::GetL1Region(Int_t i, Int_t arr[][64]) const
+{
+ //
+ if (i < 0 || i > 1)
+ {
+ AliError("Bad index!");
+ return;
+ }
+
+ for (Int_t j = 0; j < 48; j++) for (Int_t k = 0; k < 64; k++) { arr[j][k] = fL1Region[i][j][k]; }
+}
+
+
//_____________
void AliEMCALTriggerData::Scan() const
{
//
printf("L0:\n");
- for (Int_t i=0;i<32;i++) printf("\tFound %2d patches in TRU %2d\n",fL0NPatches[i],i);
-
+ printf("\tFound (%2d , %2d) patches\n", fL0Patches[0]->GetEntriesFast(), fL0Patches[1]->GetEntriesFast());
printf("L1:\n");
- printf("\tRegion of size.....................(%2d,%2d)\n",int(fL1RegionSize.X()),int(fL1RegionSize.Y()));
- printf("\tGamma sub-region size..............(%2d,%2d)\n",int(fL1GammaSubRegionSize.X()),int(fL1GammaSubRegionSize.Y()));
- printf("\tJet sub-region size................(%2d,%2d)\n",int(fL1JetSubRegionSize.X()),int(fL1JetSubRegionSize.Y()));
- printf("\tFound %4d gamma patches of size...(%2d,%2d)\n",fL1GammaPatches->GetEntriesFast(),int(fL1GammaPatchSize.X()),int(fL1GammaPatchSize.Y()));
- printf("\tFound %4d jet patches of size.....(%2d,%2d)\n",fL1JetPatches->GetEntriesFast(),int(fL1JetPatchSize.X()),int(fL1JetPatchSize.Y()));
+ printf("\tFound (%4d,%4d) gamma patches\n",fL1GammaPatches[0]->GetEntriesFast(), fL1GammaPatches[1]->GetEntriesFast());
+ printf("\tFound (%4d,%4d) jet patches\n",fL1JetPatches[0]->GetEntriesFast(), fL1JetPatches[1]->GetEntriesFast());
}
//_____________
void AliEMCALTriggerData::Reset()
{
//
- if (fL0Patches) fL0Patches->Delete();
- if (fL1GammaPatches) fL1GammaPatches->Delete();
- if (fL1JetPatches) fL1JetPatches->Delete();
-
- for (Int_t i=0;i<32;i++) fL0NPatches[i] = 0;
- for (Int_t i=0;i<48;i++) for (Int_t j=0;j<64;j++) fL1Region[i][j] = 0;
- fL1V0[0] = fL1V0[1] = 0;
+ for (Int_t i = 0; i < 2; i++)
+ {
+ if ( fL0Patches[i]) fL0Patches[i]->Delete();
+ if (fL1GammaPatches[i]) fL1GammaPatches[i]->Delete();
+ if ( fL1JetPatches[i]) fL1JetPatches[i]->Delete();
+ }
+
+ for (Int_t i = 0; i < 2; i++) for (Int_t j = 0; j < 48; j++) for (Int_t k = 0; k < 64; k++) fL1Region[i][j][k] = 0;
}
* See cxx source for full Copyright notice */
/*
-EMCal trigger data container
+EMCal trigger data container: can be used independently of the data stream (simulation or raw data)
for persistency of produced data presently stored in TTreeD
Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
*/
+#include "AliEMCALTriggerTypes.h"
+
#include <TObject.h>
#include <TVector2.h>
-
-//#include <TObjArray.h>
-//#include <Riostream.h>
-
#include <TClonesArray.h>
class AliEMCALTriggerData : public TObject
public:
AliEMCALTriggerData();
virtual ~AliEMCALTriggerData();
+
+ virtual void SetMode(Int_t i) {fMode = i;}
- virtual void SetL0Patches(Int_t i, const TClonesArray& patches);
- virtual void SetL0RegionSize( TVector2 size ) { fL0RegionSize = size; }
- virtual void SetL0SubRegionSize( TVector2 size ) { fL0SubRegionSize = size; }
- virtual void SetL0PatchSize( TVector2 size ) { fL0PatchSize = size; }
+ virtual void SetL0Trigger( Int_t i, Int_t j, Int_t k) { fL0Trigger[i][j] = k; }
+ virtual void SetL0Region( Int_t i, const Int_t**& region);
+ virtual void SetL1Region( Int_t i, Int_t**& region);
- virtual void SetL1GammaPatches(const TClonesArray& patches);
- virtual void SetL1JetPatches(const TClonesArray& patches);
-
- virtual void SetL1Region(Int_t**& region);
- virtual void SetL1V0(const Int_t*& arr);
-
- virtual void SetL1RegionSize( TVector2 size ) { fL1RegionSize = size; }
- virtual void SetL1GammaPatchSize( TVector2 size ) { fL1GammaPatchSize = size; }
- virtual void SetL1GammaSubRegionSize( TVector2 size ) { fL1GammaSubRegionSize = size; }
- virtual void SetL1JetPatchSize( TVector2 size ) { fL1JetPatchSize = size; }
- virtual void SetL1JetSubRegionSize( TVector2 size ) { fL1JetSubRegionSize = size; }
-
- virtual void L0Patches( TClonesArray& patches ) const { patches = *fL0Patches; }
- virtual TClonesArray* L0Patches( ) const { return fL0Patches; }
- virtual void L0RegionSize( TVector2 size ) const { size = fL0RegionSize; }
- virtual TVector2 L0RegionSize( ) const { return fL0RegionSize; }
- virtual void L0PatchSize( TVector2 size ) const { size = fL0PatchSize; }
- virtual TVector2 L0PatchSize( ) const { return fL0PatchSize; }
- virtual void L0SubRegionSize( TVector2 size ) const { size = fL0SubRegionSize; }
- virtual TVector2 L0SubRegionSize( ) const { return fL0SubRegionSize; }
- virtual void L0NPatches( Int_t arr[32] ) const { for (Int_t i=0;i<32;i++) arr[i] = fL0NPatches[i]; }
+ virtual void SetPatches(TriggerType_t type, Int_t i, const TClonesArray& patches);
+
+ virtual void SetL1GammaThreshold(Int_t v) {fL1GammaThreshold = v;}
+ virtual void SetL1JetThreshold( Int_t v) { fL1JetThreshold = v;}
- virtual void L1GammaPatches( TClonesArray& patches ) const { patches = *fL1GammaPatches; }
- virtual TClonesArray* L1GammaPatches( ) const { return fL1GammaPatches; }
- virtual void L1JetPatches( TClonesArray& patches ) const { patches = *fL1JetPatches; }
- virtual TClonesArray* L1JetPatches( ) const { return fL1JetPatches; }
- virtual void L1Region( Int_t arr[][64] ) const { for (Int_t i=0;i<48;i++) for (Int_t j=0;j<64;j++) { arr[i][j] = fL1Region[i][j]; } }
- virtual Int_t* L1V0( ) { return &fL1V0[0]; }
- virtual void L1RegionSize( TVector2& size ) const { size = fL1RegionSize; }
- virtual TVector2 L1RegionSize( ) const { return fL1RegionSize; }
- virtual void L1GammaPatchSize( TVector2& size ) const { size = fL1GammaPatchSize; }
- virtual TVector2 L1GammaPatchSize( ) const { return fL1GammaPatchSize; }
- virtual void L1GammaSubRegionSize( TVector2& size ) const { size = fL1GammaSubRegionSize; }
- virtual TVector2 L1GammaSubRegionSize( ) const { return fL1GammaSubRegionSize; }
- virtual void L1JetPatchSize( TVector2& size ) const { size = fL1JetPatchSize; }
- virtual TVector2 L1JetPatchSize( ) const { return fL1JetPatchSize; }
- virtual void L1JetSubRegionSize( TVector2& size ) const { size = fL1JetSubRegionSize; }
- virtual TVector2 L1JetSubRegionSize( ) const { return fL1JetSubRegionSize; }
+ virtual void GetL0Trigger( Int_t i, Int_t j, Int_t& k ) const { k = fL0Trigger[i][j];}
+ virtual Int_t GetL0Trigger( Int_t i, Int_t j ) const {return fL0Trigger[i][j];}
+
+ virtual void GetPatches(TriggerType_t type, Int_t i, TClonesArray& patches) const;
+ virtual TClonesArray* GetPatches(TriggerType_t type, Int_t i ) const;
- virtual void Scan() const;
+ virtual void GetL1Region( Int_t i, Int_t arr[][64] ) const;
+
+ virtual Int_t GetL1GammaThreshold() const {return fL1GammaThreshold;}
+ virtual Int_t GetL1JetThreshold() const {return fL1JetThreshold;}
- virtual void Reset();
+ virtual Int_t GetMode() const {return fMode;}
+
+ virtual void Scan() const;
+ virtual void Reset();
private:
AliEMCALTriggerData(const AliEMCALTriggerData& rhs); // NOT implemented
AliEMCALTriggerData& operator=(const AliEMCALTriggerData& rhs); // NOT implemented
- TClonesArray* fL0Patches; // array of patches
- Int_t fL0NPatches[32];
- TVector2 fL0RegionSize; // region size in units of fast or
- TVector2 fL0SubRegionSize; // subregion size in units of fast or
- TVector2 fL0PatchSize; // patch size in units of subregion
+ Int_t fMode;
+
+ Int_t fL0Trigger[2][32];
- TClonesArray* fL1GammaPatches; // array of patches
- TClonesArray* fL1JetPatches; // array of patches
- Int_t fL1Region[48][64]; // STU FastOR 48-by-124
- Int_t fL1V0[2]; // V0A V0C multiplicity estimates
- TVector2 fL1RegionSize; // region size in units of fast or
- TVector2 fL1GammaPatchSize; // patch size in units of subregion
- TVector2 fL1GammaSubRegionSize; // subregion size in units of fast or
- TVector2 fL1JetPatchSize; // patch size in units of subregion
- TVector2 fL1JetSubRegionSize; // subregion size in units of fast or
+ TClonesArray* fL0Patches[2]; // array of patches
+
+ Int_t fL0Region[32][24][4]; // from F-ALTRO data only
+
+ TClonesArray* fL1GammaPatches[2]; // array of patches
+ TClonesArray* fL1JetPatches[2]; // array of patches
+
+ Int_t fL1Region[2][48][64]; // STU FastOR
+
+ Int_t fL1GammaThreshold; //
+ Int_t fL1JetThreshold; //
ClassDef(AliEMCALTriggerData,1)
};
#include "AliCaloRawStreamV3.h"
#include "AliEMCALTriggerSTURawStream.h"
#include "AliEMCALDigit.h"
-#include "AliEMCALRawDigit.h"
+#include "AliEMCALTriggerRawDigit.h"
+#include "AliEMCALTriggerPatch.h"
#include <TVector2.h>
#include <TClonesArray.h>
for (Int_t i=0;i<kNTRU;i++)
{
AliEMCALTriggerTRUDCSConfig* truConf = dcsConf->GetTRUDCSConfig(i);
- new ((*fTRU)[i]) AliEMCALTriggerTRU(truConf, rSize, int(i/3) % 2);
+ new ((*fTRU)[i]) AliEMCALTriggerTRU(truConf, rSize, i % 2);
}
rSize.Set( 48., 64. );
AliEMCALTriggerSTUDCSConfig* stuConf = dcsConf->GetSTUDCSConfig();
fSTU = new AliEMCALTriggerSTU(stuConf, rSize);
- for (Int_t i=0;i<kNTRU;i++) fSTU->BuildMap( i,
- (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->Map(),
- (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->RegionSize()
- );
+ TString str = "map";
+ for (Int_t i=0;i<kNTRU;i++) fSTU->Build(str,
+ i,
+ (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->Map(),
+ (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->RegionSize()
+ );
}
//________________
}
//__________________
-void AliEMCALTriggerElectronics::Digits2Trigger(const TClonesArray* digits, const Int_t V0M[], AliEMCALTriggerData* data)
+void AliEMCALTriggerElectronics::Digits2Trigger(TClonesArray* digits, const Int_t V0M[], AliEMCALTriggerData* data)
{
//
AliEMCALGeometry* geom = 0x0;
if (!geom) AliError("Cannot access geometry!");
- TIter NextDigit(digits);
- while (AliEMCALRawDigit* digit = (AliEMCALRawDigit*)NextDigit())
+ // digits->Sort();
+
+ Int_t region[48][64], posMap[48][64];
+ for (Int_t i = 0; i < 48; i++) for (Int_t j = 0; j < 64; j++)
+ {
+ region[i][j] = 0;
+ posMap[i][j] = -1;
+ }
+
+ for (Int_t i = 0; i < digits->GetEntriesFast(); i++)
{
- if ( digit )
+ AliEMCALTriggerRawDigit* digit = (AliEMCALTriggerRawDigit*)digits->At(i);
+
+ Int_t id = digit->GetId();
+
+ Int_t iTRU, iADC;
+
+ Bool_t isOK1 = geom->GetTRUFromAbsFastORIndex(id, iTRU, iADC);
+
+ for (Int_t j = 0; j < digit->GetNSamples(); j++)
{
- Int_t id = digit->GetId();
-
-// digit->Print();
+ Int_t time, amp;
+ Bool_t isOK2 = digit->GetTimeSample(j, time, amp);
- Int_t iTRU, iADC;
- Bool_t isOK1 = geom->GetTRUFromAbsFastORIndex(id, iTRU, iADC);
+ if (isOK1 && isOK2 && amp) (static_cast<AliEMCALTriggerTRU*>(fTRU->At(iTRU)))->SetADC(iADC, time, amp);
+ }
+
+ Int_t px, py;
+ if (geom->GetPositionInEMCALFromAbsFastORIndex(id, px, py))
+ {
+ posMap[px][py] = i;
- for (Int_t i = 0; i < digit->GetNSamples(); i++)
+ if (fSTU->GetRawData() && digit->GetL1TimeSum() >= 0)
{
- Int_t time, amp;
- Bool_t isOK2 = digit->GetTimeSample(i, time, amp);
-
- if (isOK1 && isOK2 && amp) (static_cast<AliEMCALTriggerTRU*>(fTRU->At(iTRU)))->SetADC(iADC, time, amp);
+ region[px][py] = digit->GetL1TimeSum();
}
}
}
- /*
- for (Int_t i=0; i<kNTRU; i++)
- {
- printf("===========< TRU %2d >============\n",i);
- (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->Scan();
- }
- */
- Int_t iL0 = 0;
- // At this point all FastOR are available for digitization
- // digitization is done in the TRU and produces time samples
- // Now run the trigger algo & consecutively write trigger outputs in TreeD dedicated branch
+ Int_t iL0 = 0;
for (Int_t i=0; i<kNTRU; i++)
{
- AliDebug(1,Form("===========< TRU %2d >============\n",i));
+ AliDebug(999, Form("===========< TRU %2d >============\n", i));
- AliEMCALTriggerTRU *iTRU = static_cast<AliEMCALTriggerTRU*>(fTRU->At(i));
-
- iL0 += iTRU->L0();
+ AliEMCALTriggerTRU* iTRU = static_cast<AliEMCALTriggerTRU*>(fTRU->At(i));
-// Int_t vL0Peaks[96][2]; iTRU->Peaks( vL0Peaks );
-
- data->SetL0Patches( i , iTRU->Patches() );
-// data->SetL0Peaks( i , vL0Peaks );
-
- if ( !i ) // do it once since identical for all TRU
+ // L0 is always computed from F-ALTRO
+ if (iTRU->L0())
{
- data->SetL0RegionSize( *iTRU->RegionSize() );
- data->SetL0SubRegionSize( *iTRU->SubRegionSize() );
- data->SetL0PatchSize( *iTRU->PatchSize() );
- }
-
- // if ( i == 31 ) i = 35;
- //
- // if ( ( i / 3 ) % 2 ) {
- // TRU->Print( 15 - 2 + ( i - int( i / 3 ) * 3 ) - 3 * ( (i / 3) / 2 ) , runLoader->GetEventNumber() );
- // printf("print data of TRU: from %2d to %2d\n",i,15 - 2 + ( i - int( i / 3 ) * 3 ) - 3 * ( (i / 3) / 2));
- // }
- // else
- // {
- // TRU->Print( 31 - i % 3 - 3 * ( (i / 3) / 2 ) , runLoader->GetEventNumber() );
- // printf("print data of TRU: from %2d to %2d\n",i,31 - i % 3 - 3 * ( (i / 3) / 2 ));
- // }
+ iL0 += iTRU->L0();
+
+ Int_t sizeX = (iTRU->PatchSize())->X() * (iTRU->SubRegionSize())->X();
+
+ Int_t sizeY = (iTRU->PatchSize())->Y() * (iTRU->SubRegionSize())->Y();
+
+ // transform local to global
+ TIter Next(&iTRU->Patches());
+ while (AliEMCALTriggerPatch* p = (AliEMCALTriggerPatch*)Next())
+ {
+ Int_t px, py, id; p->Position(px, py);
+
+ if (geom->GetAbsFastORIndexFromPositionInTRU(i, px, py, id)
+ &&
+ geom->GetPositionInEMCALFromAbsFastORIndex(id, px, py)) p->SetPosition(px, py);
+
+ if (!data->GetMode())
+ {
+ Int_t peaks = p->Peaks();
+
+ for (Int_t j = 0; j < sizeX * sizeY; j++)
+ {
+ if (peaks & (1 << j))
+ {
+
+ Int_t pos = posMap[px + j % sizeX][py + j / sizeX];
+
+// cout << "px: " << px << " py: " << py << " j: " << j << " mod: " << j%sizeX << " ratio: " << j / sizeX << " pos: " << pos << endl;
+
+ AliEMCALTriggerRawDigit* dig = 0x0;
+
+ if (pos == -1)
+ {
+ new((*digits)[digits->GetEntriesFast()]) AliEMCALTriggerRawDigit(id, 0x0, 0);
+
+ dig = (AliEMCALTriggerRawDigit*)digits->At(digits->GetEntriesFast() - 1);
+ }
+ else
+ {
+ dig = (AliEMCALTriggerRawDigit*)digits->At(pos);
+ }
+
+ dig->SetL0Time(p->Time());
+ }
+ }
+ }
+ }
+
+ data->SetL0Trigger(0, i, 1);
+
+ data->SetPatches(kL0, 0, iTRU->Patches());
+ }
+ else
+ data->SetL0Trigger(0, i, 0);
}
// A L0 has been issued, run L1
- if ( iL0 )
+ // Depending on raw data enabled or not in STU data: L1 computation
+ // should be done from F-ALTRO or directly on TRU time sums in STU raw data
+ if (iL0)
{
- for (Int_t i=0; i<kNTRU; i++) fSTU->FetchFOR( i,
- (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->Region(),
- (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->RegionSize()
- );
+ // Use L1 threshold from raw data when reconstructing raw data
+ if (data->GetMode())
+ {
+ fSTU->SetThreshold(kL1Gamma, data->GetL1GammaThreshold());
+ fSTU->SetThreshold(kL1Jet, data->GetL1JetThreshold() );
+ }
+ else
+ {
+ fSTU->ComputeThFromV0(V0M); // C/A
+ data->SetL1GammaThreshold(fSTU->GetThreshold(kL1Gamma));
+ data->SetL1JetThreshold( fSTU->GetThreshold(kL1Jet) );
+ }
- fSTU->SetV0Multiplicity( V0M , 2 ); // C/A
-
- TVector2 size;
+ if (fSTU->GetRawData())
+ {
+ // Compute L1 from STU raw data
+ fSTU->SetRegion(region);
+ }
+ else
+ {
+ // Build STU raw data from F-ALTRO
+ TString str = "region";
+ for (Int_t i = 0; i < kNTRU; i++) fSTU->Build(str,
+ i,
+ (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->Region(),
+ (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->RegionSize());
+ }
- size.Set( 1. , 1. );
- fSTU->SetSubRegionSize( size ); data->SetL1GammaSubRegionSize( size );
+ fSTU->L1(kL1Gamma);
- size.Set( 2. , 2. );
- fSTU->SetPatchSize( size ); data->SetL1GammaPatchSize( size );
-
- fSTU->L1( kGamma );
-
- data->SetL1GammaPatches( fSTU->Patches() );
+ data->SetPatches(kL1Gamma, 0, fSTU->Patches());
fSTU->Reset();
- size.Set( 4. , 4. );
- fSTU->SetSubRegionSize( size ); data->SetL1JetSubRegionSize( size );
+ fSTU->L1(kL1Jet);
- size.Set( 2. , 2. );
- fSTU->SetPatchSize( size ); data->SetL1JetPatchSize( size );
-
- fSTU->L1( kJet );
-
- data->SetL1JetPatches( fSTU->Patches() );
- data->SetL1RegionSize( *fSTU->RegionSize() );
+ data->SetPatches(kL1Jet, 0, fSTU->Patches());
+
+ Int_t** reg = fSTU->Region();
+
+ if (!fSTU->GetRawData())
+ {
+ // Update digits w/ L1 time sum
+ // Done in raw digit maker when raw data enabled
+ for (Int_t i = 0; i < 48; i++)
+ {
+ for (Int_t j = 0; j < 64; j++)
+ {
+ if (reg[i][j])
+ {
+ Int_t id;
+ if (geom->GetAbsFastORIndexFromPositionInEMCAL(i, j, id))
+ {
+ AliEMCALTriggerRawDigit* dig = 0x0;
- Int_t** region = fSTU->Region();
- data->SetL1Region( region );
- const Int_t* mv0 = fSTU->V0();
- data->SetL1V0( mv0 );
+ if (posMap[i][j] == -1)
+ {
+ // Add a new digit with L1 time sum
+ new((*digits)[digits->GetEntriesFast()]) AliEMCALTriggerRawDigit(id, 0x0, 0);
+
+ dig = (AliEMCALTriggerRawDigit*)digits->At(digits->GetEntriesFast() - 1);
+ }
+ else
+ {
+ dig = (AliEMCALTriggerRawDigit*)digits->At(posMap[i][j]);
+ }
+
+ dig->SetL1TimeSum(reg[i][j]);
+ }
+ }
+ }
+ }
+ }
}
- if ( AliDebugLevel() ) data->Scan();
+ if (AliDebugLevel() >= 999) data->Scan();
// Now reset the electronics for a fresh start with next event
Reset();
AliEMCALTriggerElectronics(const AliEMCALTriggerDCSConfig* dcsConfig = 0x0); // ctor
virtual ~AliEMCALTriggerElectronics(); // dtor
- virtual void Digits2Trigger(const TClonesArray* digits, const Int_t V0M[], AliEMCALTriggerData* data);
+ virtual void Digits2Trigger(TClonesArray* digits, const Int_t V0M[], AliEMCALTriggerData* data);
virtual void Reset();
virtual AliEMCALTriggerTRU* GetTRU( Int_t iTRU ) {return (AliEMCALTriggerTRU*)fTRU->At(iTRU);}
*/
#include "AliEMCALTriggerPatch.h"
-#include "AliRunLoader.h"
-#include "AliRun.h"
-#include "AliEMCALGeometry.h"
-#include "AliEMCAL.h"
-
-#include "TArrayI.h"
+#include "AliLog.h"
ClassImp(AliEMCALTriggerPatch)
//____________
AliEMCALTriggerPatch::AliEMCALTriggerPatch() : TObject(),
fPosition(0x0),
-fSum(0)
+fSum(0),
+fTime(0),
+fPeaks(0)
{
// Default constructor
}
//____________
-AliEMCALTriggerPatch::AliEMCALTriggerPatch( Int_t i, Int_t j, Int_t k ) : TObject(),
-fPosition(new TVector2( i , j )),
-fSum(k)
+AliEMCALTriggerPatch::AliEMCALTriggerPatch(Int_t i, Int_t j, Int_t k, Int_t l) : TObject(),
+fPosition(new TVector2(i, j)),
+fSum(k),
+fTime(l),
+fPeaks(0)
{
+ //
}
-//____________
-
//____________________________________________________________________
AliEMCALTriggerPatch::AliEMCALTriggerPatch(const AliEMCALTriggerPatch& other) : TObject(other),
-fPosition( new TVector2(*other.fPosition) ),
-fSum( other.fSum )
+fPosition(new TVector2(*other.fPosition)),
+fSum(other.fSum),
+fTime(other.fTime),
+fPeaks(other.fPeaks)
{
// Copy ctor
}
//____________
AliEMCALTriggerPatch::~AliEMCALTriggerPatch()
{
+ //
if (fPosition) delete fPosition;
}
//____________
-void AliEMCALTriggerPatch::Print(const Option_t*) const
+void AliEMCALTriggerPatch::SetPeak(Int_t x, Int_t y, Int_t sizeX, Int_t sizeY)
{
- printf("]> Patch at (%2d , %2d) w/ sum %3d\n",
- (int)fPosition->X(),(int)fPosition->Y(),fSum);
+ //
+ if (sizeX * sizeY > 31) AliError("32b limit exceeded!");
+
+ fPeaks = (fPeaks | (1 << (y * sizeX + x)));
}
-//________________
-void AliEMCALTriggerPatch::GetAbsCellIdsFromPatchPosition( TVector2& pSize, TVector2& sSize, TArrayI& absid )
+//____________
+void AliEMCALTriggerPatch::Print(const Option_t*) const
{
- AliRunLoader* runLoader = AliRunLoader::Instance();
- AliEMCALGeometry* geom = dynamic_cast<AliEMCAL*>(runLoader->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
-
- Int_t nTowersinpatch = (Int_t) (pSize.X() * pSize.Y() * sSize.X() * sSize.Y() * 4);
-
- absid.Set( nTowersinpatch );
-
- // fPosition: patch position in the STU region
- Int_t ix = (Int_t)(( fPosition->X() + pSize.X() ) * sSize.X());
- Int_t iy = (Int_t)(( fPosition->Y() + pSize.Y() ) * sSize.Y());
-
- Int_t it = 0;
-
- for (Int_t i=(Int_t) (fPosition->X() * sSize.X()); i<ix; i++) // Loop over subregions FastOR
- {
- for (Int_t j=(Int_t) (fPosition->Y() * sSize.Y()); j<iy; j++)
- {
- Int_t nSupMod = int(i/24) + 2 * int(j/12);
-
- Int_t nModule = 0;
-
- if ( nSupMod<10 )
- nModule = ( i < 24 ) ? 12 * ( 23 - i ) + 11 - j%12 : 12 * ( i%24 ) + 11 - j%12;
- else
- nModule = ( i < 24 ) ? 6 * ( 23 - i ) + 5 - j%12 : 6 * ( i%24 ) + 5 - j;
-
- // Convert (TRU,eta,phi) to Id
- for (Int_t k=0;k<2;k++)
- {
- for (Int_t l=0;l<2;l++)
- {
- Int_t iphi, ieta;
- geom->GetCellPhiEtaIndexInSModule(nSupMod, nModule, k, l, iphi, ieta);
-
- absid.SetAt( geom->GetAbsCellIdFromCellIndexes(nSupMod, iphi, ieta) , it++ );
- }
- }
- }
- }
+ //
+ printf("]> Patch at (%2d , %2d) w/ sum %3d time %2d\n",
+ (int)fPosition->X(), (int)fPosition->Y(), fSum, fTime);
}
public:
AliEMCALTriggerPatch(); // default ctor
AliEMCALTriggerPatch(const AliEMCALTriggerPatch& other); // copy ctor
- AliEMCALTriggerPatch(Int_t i, Int_t j, Int_t e);
+ AliEMCALTriggerPatch(Int_t i, Int_t j, Int_t e = 0, Int_t t = 0);
virtual ~AliEMCALTriggerPatch();
- void Position(TVector2& pos) const {pos = *fPosition;}
- TVector2* Position( ) const {return fPosition;}
- Int_t Sum() const {return fSum;} // in ADC counts
+ void SetPosition(Int_t px, Int_t py) {fPosition->Set(float(px), float(py));}
+ void SetPosition(const TVector2& pos) {*fPosition = pos;}
+ void SetSum(Int_t sum) {fSum = sum;}
+ void SetTime(Int_t time) {fTime = time;}
+ void SetPeak(Int_t x, Int_t y, Int_t sizeX, Int_t sizeY);
+
+ void Position(TVector2& pos ) const {pos = *fPosition;}
+ void Position(Int_t& px, Int_t& py) const {px = fPosition->X(); py = fPosition->Y();}
+ TVector2* Position( ) const {return fPosition;}
+ Int_t Sum() const {return fSum;} // in ADC counts
+ Int_t Time() const {return fTime;}
+ Int_t Peaks() const {return fPeaks;}
+
void Print(const Option_t*) const;
- void GetAbsCellIdsFromPatchPosition(TVector2& psize, TVector2& ssize, TArrayI& absid);
private:
TVector2* fPosition;
Int_t fSum;
+ Int_t fTime;
+ Int_t fPeaks;
ClassDef(AliEMCALTriggerPatch,1)
};
--- /dev/null
+/**************************************************************************
+ * 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. *
+ **************************************************************************/
+
+/*
+
+
+
+ Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
+*/
+
+// --- ROOT system ---AliEMCALTriggerRawDigit
+#include <Riostream.h>
+#include <TMath.h>
+
+#include "AliEMCALTriggerRawDigit.h"
+#include "AliLog.h"
+
+ClassImp(AliEMCALTriggerRawDigit)
+
+//____________________________________________________________________________
+AliEMCALTriggerRawDigit::AliEMCALTriggerRawDigit() : AliEMCALRawDigit(),
+fL0Trigger(0),
+fNL0Times(0),
+fL0Times(),
+fL1TimeSum(-1)
+{
+ // default ctor
+ for (Int_t i = 0; i < 10; i++) fL0Times[i] = -1;
+}
+
+//____________________________________________________________________________
+AliEMCALTriggerRawDigit::AliEMCALTriggerRawDigit(Int_t id, Int_t timeSamples[], Int_t nSamples) : AliEMCALRawDigit(id, timeSamples, nSamples),
+fL0Trigger(0),
+fNL0Times(0),
+fL0Times(),
+fL1TimeSum(-1)
+{
+ //
+ for (Int_t i = 0; i < 10; i++) fL0Times[i] = -1;
+}
+
+//____________________________________________________________________________
+AliEMCALTriggerRawDigit::~AliEMCALTriggerRawDigit()
+{
+ //
+ //delete [] fL0Times;
+}
+
+//____________________________________________________________________________
+Bool_t AliEMCALTriggerRawDigit::SetL0Time(const Int_t i)
+{
+ //
+ for (Int_t j = 0; j < fNL0Times; j++)
+ {
+ if (i == fL0Times[j])
+ {
+ AliWarning("L0 time already there! Won't add it twice");
+ return kFALSE;
+ }
+ }
+
+ fNL0Times++;
+
+ if (fNL0Times > 9)
+ {
+ AliError("More than 10 L0 times!");
+ return kFALSE;
+ }
+
+ fL0Times[fNL0Times - 1] = i;
+
+ return kTRUE;
+}
+
+//____________________________________________________________________________
+Bool_t AliEMCALTriggerRawDigit::GetL0Time(const Int_t i, Int_t& time) const
+{
+ //
+ if (i < 0 || i > fNL0Times)
+ {
+ AliError("Bad index!");
+ return kFALSE;
+ }
+
+ time = fL0Times[i];
+
+ return kTRUE;
+}
+
+//____________________________________________________________________________
+Bool_t AliEMCALTriggerRawDigit::GetL0Times(Int_t times[]) const
+{
+ //
+ if (sizeof(times) < (sizeof(Int_t) * fNL0Times))
+ {
+ AliError("Array size too small!");
+ return kFALSE;
+ }
+
+ for (Int_t i = 0; i < fNL0Times; i++) times[i] = fL0Times[i];
+
+ return kTRUE;
+}
+
+//____________________________________________________________________________
+Int_t AliEMCALTriggerRawDigit::GetL0TimeSum(const Int_t time) const
+{
+ //
+
+ Int_t value = 0;
+
+ for (Int_t i = 0; i < fNSamples; i++)
+ {
+ Int_t timeBin, amp;
+ GetTimeSample(i, timeBin, amp);
+
+ if (timeBin >= time && timeBin < time + 4) value += amp;
+ }
+
+ return value;
+}
+
+//____________________________________________________________________________
+void AliEMCALTriggerRawDigit::Print(const Option_t* /*opt*/) const
+{
+ //
+ printf("===\n| Digit id: %4d / %d Time Samples: \n",fId,fNSamples);
+ for (Int_t i=0; i < fNSamples; i++)
+ {
+ Int_t timeBin, amp;
+ GetTimeSample(i, timeBin, amp);
+ printf("| (%d,%d) ",timeBin,amp);
+ }
+ printf("\n");
+ printf("| L0: %4d / %d Time(s): \n",fL0Trigger,fNL0Times);
+ for (Int_t i = 0; i < fNL0Times; i++)
+ {
+ Int_t time;
+ if (GetL0Time(i, time)) printf("| %d ",time);
+ }
+ printf("\n");
+ printf("| Time sum: %d\n", fL1TimeSum);
+}
+
--- /dev/null
+#ifndef ALIEMCALTRIGGERRAWDIGIT_H
+#define ALIEMCALTRIGGERRAWDIGIT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/*
+
+
+ Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
+*/
+
+#include "AliEMCALRawDigit.h"
+
+class AliEMCALTriggerRawDigit : public AliEMCALRawDigit
+{
+public:
+
+ AliEMCALTriggerRawDigit();
+ AliEMCALTriggerRawDigit(Int_t id, Int_t timeSamples[], Int_t nSamples);
+
+ virtual ~AliEMCALTriggerRawDigit();
+
+ void SetL0Trigger(Int_t v) {fL0Trigger = v;}
+ Bool_t SetL0Time( Int_t i);
+
+ Int_t GetL0Trigger( ) const {return fL0Trigger;}
+ Bool_t GetL0Time(const Int_t i, Int_t& time) const;
+ Bool_t GetL0Times(Int_t times[] ) const;
+ Int_t GetNL0Times( ) const {return fNL0Times;}
+
+ Int_t GetL0TimeSum(const Int_t time) const;
+
+ void SetL1TimeSum(Int_t ts) {fL1TimeSum = ts;}
+ Int_t GetL1TimeSum( ) const {return fL1TimeSum;}
+
+ virtual void Print(const Option_t* opt) const;
+
+private:
+
+ AliEMCALTriggerRawDigit(const AliEMCALTriggerRawDigit &cd); // Not implemented
+ AliEMCALTriggerRawDigit &operator=(const AliEMCALTriggerRawDigit &cd); // Not implemented
+
+ Int_t fL0Trigger;
+ Int_t fNL0Times;
+ Int_t fL0Times[10];
+
+ Int_t fL1TimeSum;
+
+ ClassDef(AliEMCALTriggerRawDigit,1)
+};
+#endif
+
--- /dev/null
+/**************************************************************************
+ * 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. *
+ **************************************************************************/
+
+/*
+
+
+
+
+Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
+*/
+
+#include "AliEMCALTriggerRawDigitMaker.h"
+#include "AliEMCALTriggerSTURawStream.h"
+#include "AliCaloRawAnalyzerFakeALTRO.h"
+#include "AliEMCALTriggerRawDigit.h"
+#include "AliCaloRawStreamV3.h"
+#include "AliRun.h"
+#include "AliRunLoader.h"
+#include "AliEMCAL.h"
+#include "AliCaloBunchInfo.h"
+#include "AliRawReader.h"
+#include "AliEMCALTriggerDCSConfigDB.h"
+#include "AliEMCALTriggerData.h"
+#include "AliEMCALTriggerPatch.h"
+#include "AliLog.h"
+
+#include "AliRawDataHeader.h"
+#include "AliRawVEvent.h"
+#include "AliRawEventHeaderBase.h"
+#include "AliRawEvent.h"
+#include "AliRawVEquipment.h"
+#include "AliRawEquipmentHeader.h"
+
+namespace
+{
+ const Int_t kSTUEqId = 4652;
+}
+
+ClassImp(AliEMCALTriggerRawDigitMaker)
+
+//_______________
+AliEMCALTriggerRawDigitMaker::AliEMCALTriggerRawDigitMaker() : TObject(),
+fGeometry(0x0),
+fRawReader(0x0),
+fCaloRawStream(0x0),
+fSTURawStream(0x0),
+fRawDigits(0x0),
+fRawAnalyzer(0x0),
+fDCSConfig(0x0),
+fTriggerData(0x0)
+{
+ // def ctor
+
+ AliRunLoader* rl = AliRunLoader::Instance();
+ if (rl && rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL"))
+ fGeometry = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
+ else
+ {
+ AliDebug(1, Form("Using default geometry"));
+ fGeometry = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
+ }
+
+ fRawAnalyzer = new AliCaloRawAnalyzerFakeALTRO();
+
+ fDCSConfig = AliEMCALTriggerDCSConfigDB::Instance();
+
+ for (Int_t i=0; i<3072; i++) fRawDigitIndex[i] = -1;
+}
+
+//_______________
+AliEMCALTriggerRawDigitMaker::~AliEMCALTriggerRawDigitMaker()
+{
+ // dtor
+}
+
+//_______________
+void AliEMCALTriggerRawDigitMaker::SetIO(AliRawReader* reader, AliCaloRawStreamV3& in, AliEMCALTriggerSTURawStream& inSTU, TClonesArray* digits, AliEMCALTriggerData* data)
+{
+ //
+ fRawReader = reader;
+ fCaloRawStream = ∈
+ fRawDigits = digits;
+ fSTURawStream = &inSTU;
+ fTriggerData = data;
+}
+
+//_______________
+void AliEMCALTriggerRawDigitMaker::Add(const std::vector<AliCaloBunchInfo> &bunchlist)
+{
+ //
+ Int_t hwAdd = fCaloRawStream->GetHWAddress();
+ UShort_t iRCU = fCaloRawStream->GetDDLNumber() % 2; // 0/1
+ UShort_t iBranch = ( hwAdd >> 11 ) & 0x1; // 0/1
+
+ // TRU id
+ Int_t iTRU = ( (iRCU << 1) | iBranch ) - 1; // 0..2
+
+ iTRU = (fCaloRawStream->GetModule() % 2) ? 2 * (2 - iTRU) + 1 : 2 * iTRU;
+
+ iTRU += 6 * int(fCaloRawStream->GetModule()/2);
+
+ if (AliDebugLevel())
+ {
+ printf("===\n");
+ printf("| Hw Adress: 0x%x => SM# %2d / RCU# %d / Branch# %d / TRU# %2d / ADC# %2d\n",
+ hwAdd, fCaloRawStream->GetModule(), iRCU, iBranch, iTRU, fCaloRawStream->GetColumn());
+ }
+
+ Int_t idx;
+
+ AliEMCALTriggerRawDigit* dig = 0x0;
+
+ Int_t timeSamples[256]; for (Int_t j=0; j<256; j++) timeSamples[j] = 0;
+ Int_t nSamples = 0;
+
+ UInt_t iBin = bunchlist.at(0).GetStartBin();
+ Int_t iBunch = 0;
+
+ for (UInt_t i = 0; i < bunchlist.size(); i++)
+ {
+ AliCaloBunchInfo bunch = bunchlist.at(i);
+
+ if (iBin > bunch.GetStartBin())
+ {
+ iBin = bunch.GetStartBin();
+ iBunch = i;
+ }
+
+ if (fCaloRawStream->GetColumn() < 96)
+ {
+ const UShort_t* sig = bunch.GetData();
+ Int_t startBin = bunch.GetStartBin();
+
+ for (Int_t iS = 0; iS < bunch.GetLength(); iS++)
+ {
+ Int_t time = startBin--;
+ Int_t amp = sig[iS];
+
+ if (amp) timeSamples[nSamples++] = ((time << 12) & 0xFF000) | (amp & 0xFFF);
+
+ if (AliDebugLevel())
+ {
+ printf("ADC# %2d / time: %2d amplitude: %d\n", fCaloRawStream->GetColumn(), time, amp);
+ }
+ }
+ }
+ }
+
+ if (fCaloRawStream->GetColumn() > 95 && fCaloRawStream->GetColumn() < 106)
+ {
+ Int_t nBits = (fCaloRawStream->GetColumn() == 105) ? 6 : 10;
+
+ const UShort_t* sig = bunchlist.at(iBunch).GetData();
+
+ if (AliDebugLevel()) printf("| L0 id in F-ALTRO => bunch length is: %d\n", bunchlist.at(iBunch).GetLength());
+
+ for (Int_t i = 0; i < bunchlist.at(iBunch).GetLength(); i++)
+ {
+ if (AliDebugLevel()) printf("| sig[%3d]: %x\n",i,sig[i]);
+
+ for (Int_t j = 0; j < nBits; j++)
+ {
+ if (sig[i] & ( 1 << j ))
+ {
+ if (AliDebugLevel())
+ {
+ printf("| Add L0 patch index in TRU# %2d position %2d\n",iTRU,(fCaloRawStream->GetColumn() - 96) * 10 + j);
+ }
+
+ if (fGeometry->GetAbsFastORIndexFromTRU(iTRU, (fCaloRawStream->GetColumn() - 96) * 10 + j, idx))
+ {
+ if (fRawDigitIndex[idx] >= 0)
+ {
+ dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
+ }
+ else
+ {
+ AliError("L0: Trying to update trigger info of a non-existent digit!");
+
+ fRawDigitIndex[idx] = fRawDigits->GetEntriesFast();
+ new((*fRawDigits)[fRawDigits->GetEntriesFast()]) AliEMCALTriggerRawDigit(idx, 0x0, 0);
+
+ dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
+ }
+
+ dig->SetL0Trigger(1);
+ dig->SetL0Time(iBin);
+ }
+ }
+ }
+
+ if (fCaloRawStream->GetColumn() == 105 && (sig[i] & (1 << 6)))
+ {
+ fTriggerData->SetL0Trigger(1, iTRU, 1);
+
+ if (AliDebugLevel()) printf("=======TRU# %2d has issued a L0\n",iTRU);
+ }
+
+ iBin--;
+ }
+ }
+ else
+ {
+ if (nSamples && fGeometry->GetAbsFastORIndexFromTRU(iTRU, fCaloRawStream->GetColumn(), idx))
+ {
+ if (fRawDigitIndex[idx] < 0)
+ {
+ fRawDigitIndex[idx] = fRawDigits->GetEntriesFast();
+ new((*fRawDigits)[fRawDigits->GetEntriesFast()]) AliEMCALTriggerRawDigit(idx, timeSamples, nSamples);
+ }
+ else
+ {
+ dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
+ dig->SetTimeSamples(timeSamples, nSamples);
+ }
+
+ if (AliDebugLevel())
+ {
+ printf("| Add TRG digit of id# %4d from TRU# %2d ADC# %2d\n", idx, iTRU, fCaloRawStream->GetColumn());
+
+ dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
+ dig->Print("");
+
+ Int_t iSm, iTru, iEta, iPhi, iD[4], iFor;
+ if (fGeometry->GetPositionInTRUFromAbsFastORIndex(idx, iTru, iEta, iPhi))
+ {
+ printf("| Position => TRU: %2d Eta: %2d Phi: %2d\n", iTru, iEta, iPhi);
+ }
+
+ if (fGeometry->GetPositionInSMFromAbsFastORIndex(idx, iSm, iEta, iPhi))
+ {
+ printf("| Position => SM: %2d Eta: %2d Phi: %2d\n", iSm, iEta, iPhi);
+ }
+
+ if (fGeometry->GetCellIndexFromFastORIndex(idx, iD))
+ {
+ printf("| tower iDs: ");
+ for (Int_t i = 0; i < 4; i++)
+ {
+ printf("%5d ",iD[i]);
+ }
+ printf("\n");
+
+ for (Int_t i = 0; i < 4; i++)
+ {
+ if (fGeometry->GetFastORIndexFromCellIndex(iD[i], iFor))
+ {
+ printf("| tower %d to F-OR %d\n",iD[i],iFor);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+//_______________
+void AliEMCALTriggerRawDigitMaker::PostProcess()
+{
+ //
+ Int_t idx;
+
+ AliEMCALTriggerRawDigit* dig = 0x0;
+
+ Int_t sizeL1gsubr[2], sizeL1gpatch[2], sizeL1jsubr[2], sizeL1jpatch[2];
+
+ fDCSConfig->GetSTUSegmentation(sizeL1gsubr, sizeL1gpatch, sizeL1jsubr, sizeL1jpatch);
+
+ fRawReader->Reset();
+ fRawReader->Select("EMCAL",44);
+
+ Bool_t STUin = kFALSE;
+
+ Int_t nSubEv = fRawReader->GetEvent()->GetNSubEvents();
+
+ for ( Int_t iSubEv=0; iSubEv<nSubEv; iSubEv++)
+ {
+ AliRawVEvent *SubEv = ((AliRawEvent*)fRawReader->GetEvent())->GetSubEvent(iSubEv);
+ if ( !SubEv ) continue;
+
+ for (Int_t iEquip = 0; iEquip < SubEv->GetNEquipments(); iEquip++)
+ {
+ Int_t eqId = SubEv->GetEquipment(iEquip)->GetEquipmentHeader()->GetId();
+
+ if (eqId == kSTUEqId) STUin = kTRUE;
+ }
+ }
+
+ fRawReader->Reset();
+
+ if (STUin && fSTURawStream && fSTURawStream->ReadPayLoad())
+ {
+ fTriggerData->SetL1GammaThreshold(fSTURawStream->GetL1GammaThreshold());
+ fTriggerData->SetL1JetThreshold( fSTURawStream->GetL1JetThreshold() );
+
+ Int_t iTRU, x, y;
+
+ if (fSTURawStream->GetRawData())
+ {
+ if (AliDebugLevel()) printf("| STU => TRU raw data are there!\n");
+
+ for (Int_t i = 0; i < 32; i++)
+ {
+ iTRU = fGeometry->GetTRUIndexFromSTUIndex(i);
+
+ UInt_t adc[96]; for (Int_t j = 0; j < 96; j++) adc[j] = 0;
+
+ fSTURawStream->GetADC(i, adc);
+
+ for (Int_t j = 0; j < 96; j++)
+ {
+ if (adc[j] < 5) continue;
+
+ if (AliDebugLevel()) printf("| STU => TRU# %2d raw data: ADC# %2d: %d\n", iTRU, j, adc[j]);
+
+ fGeometry->GetAbsFastORIndexFromTRU(iTRU, j, idx);
+
+ if (fRawDigitIndex[idx] >= 0)
+ {
+ dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
+
+ if (!dig->GetNSamples())
+ AliWarning(Form("TRG digit of id: %4d found in STU but has 0 sample in F-ALTRO!",idx));
+
+ dig->SetL1TimeSum(adc[j]);
+ }
+ else
+ {
+ AliWarning(Form("TRG digit of id: %4d found in STU but not in F-ALTRO! Create a new digit!",idx));
+
+ fRawDigitIndex[idx] = fRawDigits->GetEntriesFast();
+ new((*fRawDigits)[fRawDigits->GetEntriesFast()]) AliEMCALTriggerRawDigit(idx, 0x0, 0);
+
+ dig = (AliEMCALTriggerRawDigit*)fRawDigits->At(fRawDigitIndex[idx]);
+ dig->SetL1TimeSum(adc[j]);
+ }
+ }
+ }
+ }
+
+ // List of patches in EMCal coordinate system
+ TClonesArray* patches = new TClonesArray("AliEMCALTriggerPatch", 96);
+
+ for (Int_t i = 0; i < fSTURawStream->GetNL0GammaPatch(); i++)
+ {
+ fSTURawStream->GetL0GammaPatch(i, iTRU, x);
+
+ iTRU = fGeometry->GetTRUIndexFromSTUIndex(iTRU);
+
+ if (AliDebugLevel()) printf("| STU => Found L0 patch id: %2d in TRU# %2d\n", x, iTRU);
+
+ const Int_t sizePatchL0 = fDCSConfig->GetTRUSegmentation(i) * fDCSConfig->GetTRUSegmentation(i);
+
+ Int_t* idFastOR = new Int_t[sizePatchL0];
+
+ for (Int_t j = 0; j < sizePatchL0; i++) idFastOR[j] = -1;
+
+ if (fGeometry->GetFastORIndexFromL0Index(iTRU, x, idFastOR, sizePatchL0))
+ {
+ Int_t px, py;
+ if (fGeometry->GetPositionInEMCALFromAbsFastORIndex(idFastOR[1], px, py))
+ {
+ new((*patches)[patches->GetEntriesFast()]) AliEMCALTriggerPatch(px, py);
+
+ if (AliDebugLevel()) printf("| STU => Add L0 patch at (%2d , %2d)\n", px, py);
+ }
+ }
+
+ delete [] idFastOR;
+ }
+
+ fTriggerData->SetPatches(kL0, 1, *patches);
+
+ patches->Delete();
+
+ for (Int_t i = 0; i < fSTURawStream->GetNL1GammaPatch(); i++)
+ {
+ if (fSTURawStream->GetL1GammaPatch(i, iTRU, x, y)) // col (0..23), row (0..3)
+ {
+ iTRU = fGeometry->GetTRUIndexFromSTUIndex(iTRU);
+
+ if (AliDebugLevel()) printf("| STU => Found L1 gamma patch at (%2d , %2d) in TRU# %2d\n", x, y, iTRU);
+
+ Int_t vx = 23 - x, vy = y + 4 * int(iTRU / 2); // Position in EMCal frame
+
+ if (iTRU % 2) vx += 24; // C side
+
+ vx = vx - sizeL1gsubr[0] * sizeL1gpatch[0] + 1;
+
+ if (vx >= 0)
+ {
+ new((*patches)[patches->GetEntriesFast()]) AliEMCALTriggerPatch(vx, vy);
+
+ if (AliDebugLevel()) printf("| STU => Add L1 gamma patch at (%2d , %2d)\n", vx, vy);
+ }
+ }
+ }
+
+ fTriggerData->SetPatches(kL1Gamma, 1, *patches);
+
+ patches->Delete();
+
+ for (Int_t i = 0; i < fSTURawStream->GetNL1JetPatch(); i++)
+ {
+ if (fSTURawStream->GetL1JetPatch(i, x, y)) // col (0,15), row (0,11)
+ {
+ if (AliDebugLevel()) printf("| STU => Found L1 jet patch at (%2d , %2d)\n", x, y);
+
+ Int_t ix = sizeL1jsubr[0] * (11 - y - sizeL1jpatch[0] + 1);
+
+ Int_t iy = sizeL1jsubr[1] * (15 - x - sizeL1jpatch[1] + 1);
+
+ // FIXME: x = 0 || y = 0 (Olivier's CS) patches a lost?
+
+ if (ix >= 0 && iy >= 0)
+ {
+ new((*patches)[patches->GetEntriesFast()]) AliEMCALTriggerPatch(ix, iy);
+
+ if (AliDebugLevel()) printf("| STU => Add L1 jet patch at (%2d , %2d)\n", ix, iy);
+ }
+ }
+ }
+
+ fTriggerData->SetPatches(kL1Jet, 1, *patches);
+
+ patches->Delete();
+
+ delete patches;
+ }
+}
+
+//_______________
+void AliEMCALTriggerRawDigitMaker::Reset()
+{
+ //
+ for (Int_t i = 0; i < 3072; i++) fRawDigitIndex[i] = -1;
+}
+
+
--- /dev/null
+#ifndef ALIEMCALTRIGGERRAWDIGITMAKER_H
+#define ALIEMCALTRIGGERRAWDIGITMAKER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/*
+
+
+Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
+*/
+
+#include <vector>
+#include <TObject.h>
+
+class AliEMCALGeometry;
+class AliRawReader;
+class AliCaloRawStreamV3;
+class AliEMCALTriggerSTURawStream;
+class AliCaloRawAnalyzerFakeALTRO;
+class AliCaloBunchInfo;
+class TClonesArray;
+class AliEMCALTriggerDCSConfigDB;
+class AliEMCALTriggerData;
+
+class AliEMCALTriggerRawDigitMaker : public TObject
+{
+
+public:
+ AliEMCALTriggerRawDigitMaker();
+ virtual ~AliEMCALTriggerRawDigitMaker();
+
+ virtual void SetIO(AliRawReader* reader, AliCaloRawStreamV3& in, AliEMCALTriggerSTURawStream& inSTU, TClonesArray* digits, AliEMCALTriggerData* data);
+ virtual void Add(const std::vector<AliCaloBunchInfo> &bunchlist);
+ virtual void PostProcess();
+ virtual void Reset();
+
+private:
+
+ AliEMCALTriggerRawDigitMaker(const AliEMCALTriggerRawDigitMaker& rhs); // NOT implemented
+ AliEMCALTriggerRawDigitMaker& operator=(const AliEMCALTriggerRawDigitMaker& rhs); // NOT implemented
+
+protected:
+
+ AliEMCALGeometry* fGeometry;
+ AliRawReader* fRawReader;
+ AliCaloRawStreamV3* fCaloRawStream;
+ AliEMCALTriggerSTURawStream* fSTURawStream;
+ TClonesArray* fRawDigits;
+ AliCaloRawAnalyzerFakeALTRO* fRawAnalyzer;
+ AliEMCALTriggerDCSConfigDB* fDCSConfig;
+ AliEMCALTriggerData* fTriggerData;
+
+ Int_t fRawDigitIndex[3072];
+
+ ClassDef(AliEMCALTriggerRawDigitMaker,1)
+};
+
+#endif
,fDCSConfig(0x0)
{
//
- fV0M[0] = fV0M[1] = 0;
}
//_______________
,fDCSConfig(dcsConf)
{
//
- fV0M[0] = fV0M[1] = 0;
}
//_______________
}
//_______________
-void AliEMCALTriggerSTU::BuildMap( Int_t iTRU, Int_t** M, const TVector2* rSize )
+Int_t AliEMCALTriggerSTU::GetRawData() const
{
//
- if ( iTRU == 31 ) iTRU = 35;
+ return fDCSConfig->GetRawData();
+}
+
+//_______________
+void AliEMCALTriggerSTU::Build( TString& str, Int_t iTRU, Int_t** M, const TVector2* rSize )
+{
+ //
+ str.ToLower();
+
+ Int_t ix = (iTRU % 2) ? 24 : 0;
+
+ Int_t iy = iTRU / 2;
- Int_t i2y = iTRU / 3 / 2;
+ Int_t** v = 0x0;
- if ( ( iTRU / 3 ) % 2 ) // odd (z<0) C side
+ if (str.Contains("map"))
{
- Int_t i1y = 2 - ( iTRU - int( iTRU / 3 ) * 3 ); // 0 1 2 w/ increasing phi
-
- for (Int_t i=0; i<rSize->X(); i++)
- for (Int_t j=0; j<rSize->Y(); j++) fMap[24+i][j + i1y * 4 + i2y * 12] = M[i][j];
+ v = fMap;
}
- else // A side
+ else if (str.Contains("region"))
{
- Int_t i1y = iTRU - int( iTRU / 3 ) * 3;
-
- for (Int_t i=0; i<rSize->X(); i++)
- for (Int_t j=0; j<rSize->Y(); j++) fMap[ i][j + i1y * 4 + i2y * 12] = M[i][j];
- }
+ v = fRegion;
+ }
+ else
+ {
+ AliError("Operation not allowed: STU won't be configured properly!");
+ }
+
+ for (Int_t i=0; i<rSize->X(); i++)
+ for (Int_t j=0; j<rSize->Y(); j++) v[i + ix][j + iy * 4] = M[i][j];
}
//_______________
-void AliEMCALTriggerSTU::L1( L1TriggerType_t type )
+void AliEMCALTriggerSTU::L1(TriggerType_t type)
{
//
- SlidingWindow( type, GetThreshold( type ) );
+ TVector2 s1, s2, s3, s4;
+ fDCSConfig->GetSegmentation(s1, s2, s3, s4);
+
+ switch (type)
+ {
+ case kL1Gamma:
+ SetSubRegionSize(s1);
+ SetPatchSize(s2);
+ break;
+ case kL1Jet:
+ SetSubRegionSize(s3);
+ SetPatchSize(s4);
+ break;
+ default:
+ AliError("Not supported L1 trigger type");
+ return;
+ break;
+ }
+
+ SlidingWindow(type, GetThreshold(type));
}
//________________
-void AliEMCALTriggerSTU::PrintADC( L1TriggerType_t type, TVector2& pos, TVector2& idx )
+void AliEMCALTriggerSTU::PrintADC( TriggerType_t type, TVector2& pos, TVector2& idx )
{
//
- Int_t ix = (Int_t) (( pos.X() + fPatchSize->X() ) * fSubRegionSize->X());
- Int_t iy = (Int_t) (( pos.Y() + fPatchSize->Y() ) * fSubRegionSize->Y());
+ Int_t ix = (Int_t) (( pos.X() + fPatchSize->X() ) * fSubRegionSize->X());
+
+ Int_t iy = (Int_t) (( pos.Y() + fPatchSize->Y() ) * fSubRegionSize->Y());
TString subRegionADC[] = {"0->15", "16->31", "32->47", "48->63", "64->79", "80->95"};
switch ( type )
{
- case kGamma:
+ case kL1Gamma:
{
Int_t iTRU = ( (ix-1) < 24 ) ? 31 - int(pos.Y() / 4) : 15 - int(pos.Y() / 4);
cout << endl;
}
break;
- case kJet:
+ case kL1Jet:
{
//Int_t jTRU = ( (ix-1) < 24 ) ? 31 - (iy-1) / 4 : 15 - (iy-1) / 4;
printf("jet found at row : %d and col : %d",int(idx.X()),int(idx.Y()));
- Char_t* vPair = 0x0;
+ Char_t vPair[100];
Int_t nSubRegion = 0;
for (Int_t i=(Int_t)(pos.X() * fSubRegionSize->X());i<ix;i++)
if (!isFound)
{
nSubRegion++;
- vPair = (Char_t*)realloc(vPair, nSubRegion * sizeof(Char_t));
- if (vPair == NULL) {AliError("Error (re)allocating PrintADC() memory");}
vPair[nSubRegion-1] = value;
}
}
cout << endl;
- if (vPair) delete[] vPair;
}
break;
default:
}
}
-//________________
-void AliEMCALTriggerSTU::FetchFOR( Int_t iTRU, Int_t **R, const TVector2* rSize )
-{
- // L1 triggers run over the whole EMCal surface
- // STU builds its own fRegion aggregating TRU fRegion into one
-
- // STU I from TRUs O in Olivier's coordinate system
-
- if ( iTRU == 31 ) iTRU = 35;
-
- Int_t i2y = iTRU / 3 / 2;
-
- if ( ( iTRU / 3 ) % 2 ) // C side odd (z<0)
- {
- Int_t i1y = 2 - ( iTRU - int( iTRU / 3 ) * 3 ); // 0 1 2 w/ increasing phi
-
- for (Int_t i=0; i<rSize->X(); i++) // 0:23 0:4
- for (Int_t j=0; j<rSize->Y(); j++) fRegion[24+i][j + i1y * 4 + i2y * 12] = R[i][j];
- }
- else // A side
- {
- Int_t i1y = iTRU - int( iTRU / 3 ) * 3;
-
- for (Int_t i=0; i<rSize->X(); i++)
- for (Int_t j=0; j<rSize->Y(); j++) fRegion[ i][j + i1y * 4 + i2y * 12] = R[i][j];
- }
-}
-
//___________
void AliEMCALTriggerSTU::PatchGenerator(const TClonesArray* lpos, Int_t val)
{
}
//___________
-void AliEMCALTriggerSTU::SetV0Multiplicity(const Int_t M[], Int_t n)
+void AliEMCALTriggerSTU::ComputeThFromV0(const Int_t M[])
{
//
- for (Int_t i=0;i<n;i++) fV0M[i] = M[i];
+ if (!(M[0] + M[1])) AliWarning("V0A + V0C is null!"); // 0/1: V0C/V0A
- Int_t sumV0 = fV0M[0] + fV0M[1];
- if (!sumV0) AliWarning("V0A + V0C is null!");
+ fGammaTh = fDCSConfig->GetGA()*(M[0] + M[1])*(M[0] + M[1]) + fDCSConfig->GetGB()*(M[0] + M[1]) + fDCSConfig->GetGC();
- fGammaTh = fDCSConfig->GetGA()*sumV0*sumV0+fDCSConfig->GetGB()*sumV0+fDCSConfig->GetGC();
-
- fJetTh = fDCSConfig->GetJA()*sumV0*sumV0+fDCSConfig->GetJB()*sumV0+fDCSConfig->GetJC();
+ fJetTh = fDCSConfig->GetJA()*(M[0] + M[1])*(M[0] + M[1]) + fDCSConfig->GetJB()*(M[0] + M[1]) + fDCSConfig->GetJC();
+}
+
+//___________
+void AliEMCALTriggerSTU::SetThreshold(TriggerType_t type, Int_t v)
+{
+ switch (type)
+ {
+ case kL1Gamma:
+ fGammaTh = v;
+ break;
+ case kL1Jet:
+ fJetTh = v;
+ break;
+ default:
+ AliError("AliEMCALTriggerSTU::SetThreshold(): Undefined trigger type, pls check!");
+ }
}
//___________
-Int_t AliEMCALTriggerSTU::GetThreshold( L1TriggerType_t type )
+Int_t AliEMCALTriggerSTU::GetThreshold(TriggerType_t type)
{
// Compute threshold FIXME: need an access to the OCDB
// to get f(V0) parameters depending on trigger type
- switch ( type )
+
+ switch (type)
{
- case kGamma:
+ case kL1Gamma:
return fGammaTh;
break;
- case kJet:
+ case kL1Jet:
return fJetTh;
break;
default:
AliEMCALTriggerSTU(AliEMCALTriggerSTUDCSConfig *dcsConf, const TVector2& rsize);
virtual ~AliEMCALTriggerSTU();
- virtual void FetchFOR(Int_t i, Int_t** Region, const TVector2* rSize);
- virtual void BuildMap(Int_t i, Int_t** Map, const TVector2* rSize);
- virtual void PrintADC(L1TriggerType_t type, TVector2& pos, TVector2& idx);
- virtual void L1(L1TriggerType_t type);//, TTree& treeV0);
+ virtual void Build(TString& str, Int_t i, Int_t** Map, const TVector2* rSize);
+ virtual void PrintADC(TriggerType_t type, TVector2& pos, TVector2& idx);
+ virtual void L1(TriggerType_t type);
virtual void PatchGenerator(const TClonesArray* lpos, Int_t val);
- virtual const Int_t* V0() const {return fV0M;}
- virtual void SetV0Multiplicity(const Int_t M[], Int_t n);
+
+ virtual void ComputeThFromV0(const Int_t M[]);
+
+ virtual void SetThreshold(TriggerType_t type, Int_t v);
+
+ virtual Int_t GetThreshold(TriggerType_t type);
+ virtual Int_t GetRawData() const;
+
virtual void Reset();
- virtual Int_t GetThreshold(L1TriggerType_t type);
protected:
- AliEMCALTriggerSTU(const AliEMCALTriggerSTU& rhs);
- AliEMCALTriggerSTU& operator=(const AliEMCALTriggerSTU& rhs);
+
+ AliEMCALTriggerSTU(const AliEMCALTriggerSTU& rhs);
+ AliEMCALTriggerSTU& operator=(const AliEMCALTriggerSTU& rhs);
private:
- Int_t fV0M[2]; //! 0/1: V0C/V0A
Int_t fGammaTh;
Int_t fJetTh;
//
}
+//_____________________________________________________________________________
+void AliEMCALTriggerSTUDCSConfig::GetSegmentation(TVector2& v1, TVector2& v2, TVector2& v3, TVector2& v4) const
+{
+ //
+ switch (fFw)
+ {
+ case 2223:
+ v1.Set(1., 1.);
+ v2.Set(2., 2.);
+ v3.Set(4., 4.);
+ v4.Set(2., 2.);
+ break;
+ }
+}
*/
#include "TObject.h"
+#include "TVector2.h"
class AliEMCALTriggerSTUDCSConfig : public TObject
{
Int_t GetRawData() const { return fGetRawData; }
Int_t GetRegion() const { return fRegion; }
Int_t GetFw() const { return fFw; }
+
+ void GetSegmentation(TVector2& v1, TVector2& v2, TVector2& v3, TVector2& v4) const;
protected:
namespace
{
- const Int_t kPayLoadSize = 944;
+ const Int_t kPayLoadSize = 944;
+ const Int_t kPayLoadSizeWithRawData = 1772;
}
ClassImp(AliEMCALTriggerSTURawStream)
fRawReader(0x0),
fL1JetThreshold(0),
fL1GammaThreshold(0),
-fL0GammaPatchIndex(0x0),
-fL1GammaPatchIndex(0x0),
-fL1JetPatchIndex(0x0),
+fL0GammaPatchIndex(),
+fL1GammaPatchIndex(),
+fL1JetPatchIndex(),
fNL0GammaPatch(0),
fNL1JetPatch(0),
fNL1GammaPatch(0),
-fGetRawData(0),
-fL0(0)
+fGetRawData(0)
{
//
}
fRawReader(rawReader),
fL1JetThreshold(0),
fL1GammaThreshold(0),
-fL0GammaPatchIndex(0x0),
-fL1GammaPatchIndex(0x0),
-fL1JetPatchIndex(0x0),
+fL0GammaPatchIndex(),
+fL1GammaPatchIndex(),
+fL1JetPatchIndex(),
fNL0GammaPatch(0),
fNL1JetPatch(0),
-fNL1GammaPatch(0),
-fGetRawData(0),
-fL0(0)
+fNL1GammaPatch(0),
+fGetRawData(0)
{
//
fRawReader->Reset();
{
//
if (fRawReader) fRawReader->Reset();
-
+
fNL0GammaPatch = 0;
fNL1GammaPatch = 0;
fNL1JetPatch = 0;
-
- delete fL0GammaPatchIndex; fL0GammaPatchIndex = 0x0;
- delete fL1GammaPatchIndex; fL1GammaPatchIndex = 0x0;
- delete fL1JetPatchIndex; fL1JetPatchIndex = 0x0;
}
//_____________________________________________________________________________
// bourrion@lpsc.in2p3.fr
UInt_t word32[1772]; // 32b words
-
+ for (Int_t i=0;i<1772;i++) word32[i] = 0;
+
Int_t iword = 0;
fNL0GammaPatch = 0;
fNL1GammaPatch = 0;
fNL1JetPatch = 0;
- delete fL0GammaPatchIndex; fL0GammaPatchIndex = 0x0;
- delete fL1GammaPatchIndex; fL1GammaPatchIndex = 0x0;
- delete fL1JetPatchIndex; fL1JetPatchIndex = 0x0;
+ Int_t eqId = -1, eqSize = 0;
UInt_t w32;
- while (fRawReader->ReadNextInt(w32)) word32[iword++] = w32;
+ while (fRawReader->ReadNextInt(w32))
+ {
+ if (!iword)
+ {
+ eqId = fRawReader->GetEquipmentId();
+ eqSize = fRawReader->GetEquipmentSize();
+ }
+
+ word32[iword++] = w32;
+ }
- if (iword < kPayLoadSize)
+ if (iword != kPayLoadSize && iword != kPayLoadSizeWithRawData)
{
- AliError(Form("STU raw data size is too small: %d word32 only!", iword));
+ AliError(Form("ERROR: STU payload (eqId: %d, eqSize: %d) doesn't match expected size! %d word32",
+ eqId, eqSize, iword));
return kFALSE;
- }
- else if (iword > kPayLoadSize )
+ }
+ else if (AliDebugLevel())
{
- AliLog::Message(AliLog::kInfo, "TRU raw data in the STU payload enabled","EMCAL","AliEMCALTriggerSTURawStream","ReadPayLoad()","AliEMCALTriggerSTURawStream.cxx",104);
+ AliInfo(Form("STU (eqId: %d, eqSize: %d) payload size: %d word32",
+ eqId, eqSize, iword));
}
-
- fL0 = 0;
fL1JetThreshold = ((word32[0]>>16) & 0xFFF);
fL1GammaThreshold = (word32[0] & 0xFFF);
if (currentrow & (1 << jet_col))
{
fNL1JetPatch++;
- fL1JetPatchIndex = (UShort_t*)realloc(fL1JetPatchIndex, fNL1JetPatch * sizeof(UShort_t));
- if (fL1JetPatchIndex == NULL) {AliError("Error (re)allocating L1 jet patch memory");}
fL1JetPatchIndex[fNL1JetPatch-1] = ((jet_row << 8) & 0xFF00) | (jet_col & 0xFF);
}
{
if ((TRU_L0_indexes[tru_num][index] & (1 << bit_num)))
{
- fL0 = 1;
-
Int_t idx = 12 * index + bit_num;
-
- Int_t col = idx / 3;
- Int_t row = idx % 3;
-
+
fNL0GammaPatch++;
- fL0GammaPatchIndex = (UShort_t*)realloc(fL0GammaPatchIndex, fNL0GammaPatch * sizeof(UShort_t));
-
- if (fL0GammaPatchIndex == NULL) {AliError("Error (re)allocating L0 gamma patch memory");}
- fL0GammaPatchIndex[fNL0GammaPatch-1] = (((row << 10) & 0xC00) | ((col << 5) & 0x3E0) | (tru_num & 0x1F));
+ fL0GammaPatchIndex[fNL0GammaPatch-1] = (((idx << 5) & 0x7E0) | (tru_num & 0x1F));
}
}
}
}
fNL1GammaPatch++;
- fL1GammaPatchIndex = (UShort_t*)realloc(fL1GammaPatchIndex, fNL1GammaPatch * sizeof(UShort_t));
-
- if (fL1GammaPatchIndex == NULL) {AliError("Error (re)allocating L1 gamma patch memory");}
fL1GammaPatchIndex[fNL1GammaPatch-1] = (((indexcopy << 10) & 0xC00) | ((gammacolnum << 5) & 0x3E0) | (tru_num & 0x1F));
}
if ( iword <= kPayLoadSize )
{
fGetRawData = 0;
- return kFALSE;
+ return kTRUE;
}
fGetRawData = 1;
for (Int_t tru_num=16;tru_num<32;tru_num++) // A side
{
- for (Int_t index=0;index<96;index++)
- {
- fADC[tru_num][index] = fADC[tru_num][95-index];
- }
+ Int_t v[96];
+ for (Int_t index=0;index<96;index++) v[index] = fADC[tru_num][95-index];
+
+ for (Int_t index=0;index<96;index++) fADC[tru_num][index] = v[index];
}
- return kFALSE;
+ return kTRUE;
}
//_____________________________________________________________________________
-Bool_t AliEMCALTriggerSTURawStream::GetL0GammaPatch(const Int_t i, Int_t& tru, Int_t& col, Int_t& row) const
+Bool_t AliEMCALTriggerSTURawStream::GetL0GammaPatch(const Int_t i, Int_t& tru, Int_t& idx) const
{
//
if (i > fNL0GammaPatch) return kFALSE;
tru = fL0GammaPatchIndex[i] & 0x1F;
- col = (fL0GammaPatchIndex[i] & 0x3E0) >> 5;
- row = (fL0GammaPatchIndex[i] & 0xC00) >> 10;
+ idx = (fL0GammaPatchIndex[i] & 0x7E0) >> 5;
return kTRUE;
}
TString op = option;
cout << "Jet Threshold: " << fL1JetThreshold << " Gamma threshold: " << fL1GammaThreshold << endl;
+ cout << "Number of L0: " << fNL0GammaPatch << endl;
+ cout << "Number of L1-g: " << fNL1GammaPatch << endl;
+ cout << "Number of L1-j: " << fNL1JetPatch << endl;
Int_t itru, col, row;
-
- Bool_t isOK;
if (op.Contains("L0") || op.Contains("ALL"))
{
for (Int_t i=0;i<fNL0GammaPatch;i++)
{
- isOK = GetL0GammaPatch(i,itru,col,row);
- if (isOK) cout << "> Found L0 gamma in TRU #" << setw(2) << itru
- << " at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
+
+ if (GetL0GammaPatch(i,itru,col))
+ cout << "> Found L0 gamma in TRU #" << setw(2) << itru << " at idx: " << setw(2) << col << endl;
}
}
{
for (Int_t i=0;i<fNL1GammaPatch;i++)
{
- isOK = GetL1GammaPatch(i,itru,col,row);
- if (isOK) cout << "> Found L1 gamma in TRU #" << setw(2) << itru
- << " at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
+ if (GetL1GammaPatch(i,itru,col,row))
+ cout << "> Found L1 gamma in TRU #" << setw(2) << itru << " at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
}
for (Int_t i=0;i<fNL1JetPatch;i++)
{
- isOK = GetL1JetPatch(i,col,row);
- if (isOK) cout << "> Found L1 jet at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
+ if (GetL1JetPatch(i,col,row)) cout << "> Found L1 jet at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
}
}
virtual Int_t GetNL1JetPatch() const {return fNL1JetPatch;}
virtual Int_t GetRawData() const {return fGetRawData;}
- virtual Bool_t GetL0GammaPatch(const Int_t i, Int_t& x, Int_t& y, Int_t& z) const;
+ virtual Bool_t GetL0GammaPatch(const Int_t i, Int_t& x, Int_t& y) const;
virtual Bool_t GetL1GammaPatch(const Int_t i, Int_t& x, Int_t& y, Int_t& z) const;
virtual Bool_t GetL1JetPatch(const Int_t i, Int_t& x, Int_t& y) const;
-
-
- virtual UInt_t L0() {return fL0;}
-
+
private:
AliEMCALTriggerSTURawStream(const AliEMCALTriggerSTURawStream& rhs);
AliRawReader* fRawReader; // object for reading the raw data
- UInt_t fL1JetThreshold;
- UInt_t fL1GammaThreshold;
- UShort_t* fL0GammaPatchIndex; // [fNL0GammaPatch]
- UShort_t* fL1GammaPatchIndex; // [fNL1GammaPatch]
- UShort_t* fL1JetPatchIndex; // [fNL1JetPatch]
+ UInt_t fL1JetThreshold;
+ UInt_t fL1GammaThreshold;
+ UShort_t fL0GammaPatchIndex[3100];
+ UShort_t fL1GammaPatchIndex[3100];
+ UShort_t fL1JetPatchIndex[200];
- Int_t fNL0GammaPatch;
- Int_t fNL1JetPatch;
- Int_t fNL1GammaPatch;
+ Int_t fNL0GammaPatch;
+ Int_t fNL1JetPatch;
+ Int_t fNL1GammaPatch;
Int_t fGetRawData;
- UInt_t fADC[32][96];
- UInt_t fL0;
+ UInt_t fADC[32][96];
ClassDef(AliEMCALTriggerSTURawStream,1) // class for reading EMCAL STU DDL raw data
};
ClassImp(AliEMCALTriggerTRU)
//________________
-AliEMCALTriggerTRU::AliEMCALTriggerTRU() : AliEMCALTriggerBoard()
-,fDCSConfig(0x0)
+AliEMCALTriggerTRU::AliEMCALTriggerTRU() : AliEMCALTriggerBoard(),
+fDCSConfig(0x0)
{
//
for (Int_t i=0;i<96;i++) for (Int_t j=0;j<256;j++) fADC[i][j] = 0;
//________________
AliEMCALTriggerTRU::AliEMCALTriggerTRU(AliEMCALTriggerTRUDCSConfig* dcsConf, const TVector2& rSize, Int_t mapType) :
-AliEMCALTriggerBoard(rSize)
-,fDCSConfig(dcsConf)
+AliEMCALTriggerBoard(rSize),
+fDCSConfig(dcsConf)
{
//
for (Int_t i=0;i<96;i++) for (Int_t j=0;j<256;j++) fADC[i][j] = 0;
- // FIXME: use of class AliEMCALTriggerParam to get size
TVector2 size;
- size.Set( 1. , 1. );
- SetSubRegionSize( size ); // 1 by 1 FOR
-
- size.Set( 2. , 2. );
- SetPatchSize( size ); // 2 by 2 subregions
+ if (dcsConf->GetL0SEL() & 0x0001) // 4-by-4
+ {
+ size.Set( 1. , 1. );
+ SetSubRegionSize( size );
+
+ size.Set( 2. , 2. );
+ SetPatchSize( size );
+ }
+ else // 2-by-2
+ {
+ size.Set( 1. , 1. );
+ SetSubRegionSize( size );
+
+ size.Set( 1. , 1. );
+ SetPatchSize( size );
+ }
for (Int_t ietam=0;ietam<24;ietam++)
{
//________________
AliEMCALTriggerTRU::~AliEMCALTriggerTRU()
{
- // delete TRU digits only used as transient containers
- // to compute FastOR from energy deposit
+ //
}
//________________
// compute the time sum for all the FastOR of a given TRU
// and then move the space window
- AliDebug(1,"=== Running TRU L0 algorithm ===");
+ AliDebug(999,"=== Running TRU L0 algorithm ===");
const Int_t xsize = Int_t(fRegionSize->X());
const Int_t ysize = Int_t(fRegionSize->Y());
const Int_t zsize = kNup+kNdown;
}
}
- for (Int_t i=0; i<fRegionSize->X(); i++) for (Int_t j=0; j<fRegionSize->Y(); j++)
- for (Int_t k=0; k<kNup+kNdown; k++) buffer[i][j][k] = 0;
+ for (Int_t i = 0; i < fRegionSize->X(); i++)
+ for (Int_t j = 0; j < fRegionSize->Y(); j++)
+ for (Int_t k = 0; k < kNup + kNdown; k++) buffer[i][j][k] = 0;
// Time sliding window algorithm
for (Int_t i=0; i<=(kTimeBins-kTimeWindowSize); i++)
{
- AliDebug(1,Form("----------- Time window: %d\n",i));
+ AliDebug(999,Form("----------- Time window: %d\n",i));
for (Int_t j=0; j<fRegionSize->X(); j++)
{
{
for (Int_t l=i; l<i+kTimeWindowSize; l++)
{
-// printf("fRegion[%2d][%2d]: %d += fADC[%2d][%2d]: %d\n",j,k,fRegion[j][k],fMap[j][k],l,fADC[fMap[j][k]][l]);
// [eta][phi][time]
fRegion[j][k] += fADC[fMap[j][k]][l];
}
{
buffer[j][k][i] = fRegion[j][k];
}
-
-/*
- for (Int_t v = 0; v<kNup + kNdown; v++)
- printf("buffer[%2d][%2d][%2d]: %d\n",j,k,v,buffer[j][k][v]);
-*/
// if (kTimeWindowSize > 4) fRegion[j][k] = fRegion[j][k] >> 1; // truncate time sum to fit 14b
}
}
}
-/*
- for (Int_t j=0; j<fRegionSize->X(); j++)
- {
- for (Int_t k=0; k<fRegionSize->Y(); k++)
- {
- printf("peaks[%2d][%2d]: %d\n",j,k,peaks[j][k]);
- }
- }
-*/
- if ( !nPeaks )
+ if (!nPeaks)
{
- //Delete, avoid leak
- for (Int_t x = 0; x < xsize; x++)
- {
- delete [] peaks[x];
- }
- delete [] peaks;
ZeroRegion();
continue;
}
// return the list of patches above threshold
// Theshold checked out from OCDB
- SlidingWindow( kGamma, fDCSConfig->GetGTHRL0() );
+ SlidingWindow(kL0, fDCSConfig->GetGTHRL0(), i);
// for(Int_t j=0; j<fRegionSize->X(); j++)
// for (Int_t k=0; k<fRegionSize->Y(); k++) fRegion[j][k] = fRegion[j][k]>>2; // go to 12b before shipping to STU
idx[index] = fMap[int(v.X()*fSubRegionSize->X())+xx][int(v.Y()*fSubRegionSize->Y())+yy]; // Get current patch FastOR ADC channels
- if (peaks[int(v.X()*fSubRegionSize->X())+xx][int(v.Y()*fSubRegionSize->Y())+yy]) foundPeak++;
+ if (peaks[int(v.X() * fSubRegionSize->X()) + xx][int(v.Y() * fSubRegionSize->Y()) + yy])
+ {
+ foundPeak++;
+
+ p->SetPeak(xx, yy, sizeX, sizeY);
+ }
- if ( AliDebugLevel() ) ShowFastOR(i,idx[index]);
+ if (AliDebugLevel() >= 999) ShowFastOR(i, idx[index]);
}
}
-
- delete [] idx;
if ( !foundPeak )
{
if ( !fPatches->GetEntriesFast() ) // No patch left
ZeroRegion();
- else
+ else // Stop the algo when at least one patch is found ( thres & max )
{
- break; // Stop the algo when at least one patch is found ( thres & max )
- }
+ for (Int_t xx = 0; xx < fRegionSize->X(); xx++)
+ {
+ for (Int_t yy = 0; yy < fRegionSize->Y(); yy++)
+ {
+ // Prepare data to be sent to STU for further L1 processing
+ // Sent time sum (rollback tuning) is the one before L0 is issued (maximum time sum)
+ fRegion[xx][yy] = buffer[xx][yy][1];
+ }
+ }
+
+ break;
+ }
}
//Delete, avoid leak
--- /dev/null
+#ifndef ALIEMCALTRIGGERTYPES_H
+#define ALIEMCALTRIGGERTYPES_H
+
+typedef enum {kL0 = 0, kL1Gamma, kL1Jet, kTriggerTypeEnd} TriggerType_t;
+
+#endif
#pragma link C++ class AliEMCALTriggerTRUDCSConfig+;
#pragma link C++ class AliEMCALTriggerSTUDCSConfig+;
#pragma link C++ class AliEMCALTriggerDCSConfigDB+;
+#pragma link C++ class AliEMCALTriggerRawDigitMaker+;
+#pragma link C++ class AliCaloRawAnalyzerFakeALTRO+;
+#pragma link C++ class AliEMCALTriggerRawDigit+;
#endif
AliEMCALTriggerDCSConfig.cxx \
AliEMCALTriggerTRUDCSConfig.cxx \
AliEMCALTriggerSTUDCSConfig.cxx \
-AliEMCALTriggerDCSConfigDB.cxx
+AliEMCALTriggerDCSConfigDB.cxx \
+AliEMCALTriggerRawDigitMaker.cxx \
+AliCaloRawAnalyzerFakeALTRO.cxx \
+AliEMCALTriggerRawDigit.cxx