* full copyright notice. *
**************************************************************************/
+#include "TVector.h"
+#include "TLinearFitter.h"
+#include "TEveTrans.h"
+
#include "AliEveTRDData.h"
#include "AliEveTRDModuleImp.h"
#include "AliLog.h"
+#include "AliPID.h"
+#include "AliTrackPointArray.h"
+
#include "AliTRDhit.h"
#include "AliTRDcluster.h"
-#include "AliTRDcalibDB.h"
+#include "AliTRDseedV1.h"
+#include "AliTRDtrackV1.h"
+#include "AliTRDtrackerV1.h"
#include "AliTRDpadPlane.h"
-#include "AliTRDgeometry.h"
#include "AliTRDdigitsManager.h"
+#include "AliTRDdataArrayDigits.h"
+#include "AliTRDSignalIndex.h"
+#include "AliTRDgeometry.h"
+#include "AliTRDtransform.h"
+#include "AliTRDReconstructor.h"
+#include "AliTRDrecoParam.h"
ClassImp(AliEveTRDHits)
ClassImp(AliEveTRDDigits)
ClassImp(AliEveTRDClusters)
+ClassImp(AliEveTRDTracklet)
+ClassImp(AliEveTRDTrack)
///////////////////////////////////////////////////////////
///////////// AliEveTRDDigits /////////////////////
//______________________________________________________________________________
AliEveTRDDigits::AliEveTRDDigits(AliEveTRDChamber *p) :
TEveQuadSet("digits", ""), fParent(p), fBoxes(), fData()
-{}
+{
+ // Constructor.
+}
//______________________________________________________________________________
-void AliEveTRDDigits::SetData(AliTRDdigitsManager *digits)
+AliEveTRDDigits::~AliEveTRDDigits()
{
-
- fData.Allocate(fParent->fRowMax, fParent->fColMax, fParent->fTimeMax);
- // digits->Expand();
- for (Int_t row = 0; row < fParent->fRowMax; row++)
- for (Int_t col = 0; col < fParent->fColMax; col++)
- for (Int_t time = 0; time < fParent->fTimeMax; time++) {
- if(digits->GetDigitAmp(row, col, time, fParent->GetID()) < 0) continue;
- fData.SetDataUnchecked(row, col, time, digits->GetDigitAmp(row, col, time, fParent->GetID()));
- }
+// AliInfo(GetTitle());
}
//______________________________________________________________________________
// - digits threshold
// - digits apparence (quads/boxes)
- TEveQuadSet::Reset(TEveQuadSet::kQT_FreeQuad, kTRUE, 64);
- // MT fBoxes.fBoxes.clear();
+ if(!fData.HasData()){
+ return;
+ }
- Double_t colSize, rowSize, scale;
- Double_t x, y, z;
+ TEveQuadSet::Reset(TEveQuadSet::kQT_RectangleYZ, kTRUE, 64);
- Int_t charge;
- Float_t t0;
- Float_t timeBinSize;
+ Double_t scale, dy, dz;
+ Int_t q, color;
+ Int_t nrows = fData.GetNrow(),
+ ncols = fData.GetNcol(),
+ ntbs = fData.GetNtime(),
+ det = fParent->GetID();
+ Float_t threshold = fParent->GetDigitsThreshold();
- AliTRDcalibDB* calibration = AliTRDcalibDB::Instance();
- Double_t cloc[4][3], cglo[3];
- Int_t color, dimension;
+ AliTRDtransform transform(det);
+ AliTRDgeometry *geo = fParent->fGeo;
+ AliTRDpadPlane *pp = geo->GetPadPlane(geo->GetLayer(det), geo->GetStack(det));
+
+ // express position in tracking coordinates
fData.Expand();
- for (Int_t row = 0; row < fParent->fRowMax; row++) {
- rowSize = .5 * fParent->fPadPlane->GetRowSize(row);
- z = fParent->fPadPlane->GetRowPos(row) - rowSize;
-
- for (Int_t col = 0; col < fParent->fColMax; col++) {
- colSize = .5 * fParent->fPadPlane->GetColSize(col);
- y = fParent->fPadPlane->GetColPos(col) - colSize;
- t0 = calibration->GetT0(fParent->fDet, col, row);
- timeBinSize = calibration->GetVdrift(fParent->fDet, col, row)/fParent->fSamplingFrequency;
-
- for (Int_t time = 0; time < fParent->fTimeMax; time++) {
- charge = fData.GetDataUnchecked(row, col, time);
- if (charge < fParent->GetDigitsThreshold()) continue;
-
- x = fParent->fX0 - (time+0.5-t0)*timeBinSize;
- scale = fParent->GetDigitsLog() ? TMath::Log(float(charge))/TMath::Log(1024.) : charge/1024.;
- color = 50+int(scale*50.);
-
- cloc[0][2] = z - rowSize * scale;
- cloc[0][1] = y - colSize * scale;
- cloc[0][0] = x;
-
- cloc[1][2] = z - rowSize * scale;
- cloc[1][1] = y + colSize * scale;
- cloc[1][0] = x;
-
- cloc[2][2] = z + rowSize * scale;
- cloc[2][1] = y + colSize * scale;
- cloc[2][0] = x;
-
- cloc[3][2] = z + rowSize * scale;
- cloc[3][1] = y - colSize * scale;
- cloc[3][0] = x;
-
- Float_t* p = 0;
- if( fParent->GetDigitsBox()){
- // MT fBoxes.fBoxes.push_back(Box());
- // MT fBoxes.fBoxes.back().color[0] = (UChar_t)color;
- // MT fBoxes.fBoxes.back().color[1] = (UChar_t)color;
- // MT fBoxes.fBoxes.back().color[2] = (UChar_t)color;
- // MT fBoxes.fBoxes.back().color[3] = (UChar_t)color;
- // MT p = fBoxes.fBoxes.back().vertices;
- dimension = 2;
- } else {
- AddQuad((Float_t*)0);
- QuadColor(color);
- p = ((QFreeQuad_t*) fLastDigit)->fVertices;
- dimension = 1;
- }
-
- for(int id=0; id<dimension; id++)
- for (Int_t ic = 0; ic < 4; ic++) {
- cloc[ic][0] -= .5 * id * timeBinSize;
- fParent->fGeo->RotateBack(fParent->fDet,cloc[ic],cglo);
- p[0] = cglo[0]; p[1] = cglo[1]; p[2] = cglo[2];
- p+=3;
- }
+ for (Int_t ir = 0; ir < nrows; ir++) {
+ dz = pp->GetRowSize(ir);
+ for (Int_t ic = 0; ic < ncols; ic++) {
+ dy = pp->GetColSize(ic);
+ for (Int_t it = 0; it < ntbs; it++) {
+ q = fData.GetDataUnchecked(ir, ic, it);
+ if (q < threshold) continue;
+
+ Double_t x[6] = {0., 0., Double_t(q), 0., 0., 0.};
+ Int_t roc[3] = {ir, ic, 0};
+ Bool_t out = kTRUE;
+ transform.Transform(&x[0], &roc[0], UInt_t(it), out, 0);
+
+ scale = q < 512 ? q/512. : 1.;
+ color = 50+int(scale*50.);
+
+ AddQuad(x[1]-.45*dy, x[2]-.5*dz*scale, x[0], .9*dy, dz*scale);
+ QuadValue(q);
+ QuadColor(color);
+ QuadId(new TNamed(Form("Charge%d", q), "dummy title"));
} // end time loop
} // end col loop
} // end row loop
fData.Compress(1);
+
+ // rotate to global coordinates
+ //RefitPlex();
+ TEveTrans& t = RefMainTrans();
+ t.SetRotByAngles((geo->GetSector(det)+.5)*AliTRDgeometry::GetAlpha(), 0.,0.);
}
+//______________________________________________________________________________
+void AliEveTRDDigits::SetData(AliTRDdigitsManager *digits)
+{
+ // Set data source.
+
+ Int_t det = fParent->GetID();
+ AliTRDdataArrayDigits *data = digits->GetDigits(det);
+ if(!data->HasData()) return;
+ data->Expand();
+
+ AliTRDSignalIndex *indexes = digits->GetIndexes(det);
+ if(!indexes->IsAllocated()) digits->BuildIndexes(det);
+
+ if(!fData.HasData()) fData.Allocate(data->GetNrow(), data->GetNcol(), data->GetNtime());
+ fData.Expand();
+
+ Int_t row, col, time, adc;
+ indexes->ResetCounters();
+ while (indexes->NextRCIndex(row, col)){
+ indexes->ResetTbinCounter();
+ while (indexes->NextTbinIndex(time)){
+ if(data->IsPadCorrupted(row, col, time)){
+ // we should mark this position
+ break;
+ }
+ adc = data->GetData(row, col, time);
+ if(adc <= 1) continue;
+ fData.SetDataUnchecked(row, col, time, adc);
+ //fIndex->AddIndexTBin(row,col,time);
+ //printf("\tr[%d] c[%d] t[%d] ADC[%d]\n", row, col, time, adc);
+ }
+ }
+ fData.Compress(1);
+}
+
+
//______________________________________________________________________________
void AliEveTRDDigits::Paint(Option_t *option)
{
+ // Paint the object.
+
if(fParent->GetDigitsBox()) fBoxes.Paint(option);
else TEveQuadSet::Paint(option);
}
//______________________________________________________________________________
void AliEveTRDDigits::Reset()
{
- TEveQuadSet::Reset(TEveQuadSet::kQT_FreeQuad, kTRUE, 64);
+ // Reset raw and visual data.
+
+ TEveQuadSet::Reset(TEveQuadSet::kQT_RectangleYZ, kTRUE, 64);
// MT fBoxes.fBoxes.clear();
fData.Reset();
}
///////////////////////////////////////////////////////////
//______________________________________________________________________________
-AliEveTRDHits::AliEveTRDHits(AliEveTRDChamber *p) :
- TEvePointSet("hits", 20), fParent(p)
-{}
+AliEveTRDHits::AliEveTRDHits() : TEvePointSet("hits", 20)
+{
+ // Constructor.
+ SetMarkerSize(.1);
+ SetMarkerColor(2);
+ SetOwnIds(kTRUE);
+}
+
+//______________________________________________________________________________
+AliEveTRDHits::~AliEveTRDHits()
+{
+ //AliInfo(GetTitle());
+}
//______________________________________________________________________________
void AliEveTRDHits::PointSelected(Int_t n)
{
- fParent->SpawnEditor();
+ // Handle an individual point selection from GL.
+
AliTRDhit *h = dynamic_cast<AliTRDhit*>(GetPointId(n));
printf("\nDetector : %d\n", h->GetDetector());
printf("Region of production : %c\n", h->FromAmplification() ? 'A' : 'D');
///////////////////////////////////////////////////////////
-///////////// AliEveTRDHits /////////////////////
+///////////// AliEveTRDClusters /////////////////////
///////////////////////////////////////////////////////////
//______________________________________________________________________________
-AliEveTRDClusters::AliEveTRDClusters(AliEveTRDChamber *p):AliEveTRDHits(p)
-{}
+AliEveTRDClusters::AliEveTRDClusters():AliEveTRDHits()
+{
+ // Constructor.
+ SetName("clusters");
+
+ SetMarkerSize(.4);
+ SetMarkerStyle(24);
+ SetMarkerColor(kGray);
+ SetOwnIds(kTRUE);
+}
//______________________________________________________________________________
void AliEveTRDClusters::PointSelected(Int_t n)
{
- fParent->SpawnEditor();
+ // Handle an individual point selection from GL.
+
AliTRDcluster *c = dynamic_cast<AliTRDcluster*>(GetPointId(n));
printf("\nDetector : %d\n", c->GetDetector());
printf("Charge : %f\n", c->GetQ());
}
///////////////////////////////////////////////////////////
-///////////// AliEveTRDHitsEditor /////////////////////
+///////////// AliEveTRDTracklet /////////////////////
///////////////////////////////////////////////////////////
-AliEveTRDHitsEditor::AliEveTRDHitsEditor(const TGWindow* p, Int_t width, Int_t height,
- UInt_t options, Pixel_t back) :
- TGedFrame(p, width, height, options, back),
- fM(0)
-{
- MakeTitle("TRD Hits");
+//______________________________________________________________________________
+AliEveTRDTracklet::AliEveTRDTracklet(AliTRDseedV1 *trklt):TEveLine()
+ ,fClusters(0x0)
+{
+ // Constructor.
+ SetName("tracklet");
+
+ SetUserData(trklt);
+ Int_t det = -1, sec;
+ Float_t g[3];
+ AliTRDcluster *c = 0x0;
+ AddElement(fClusters = new AliEveTRDClusters());
+ for(Int_t ic=0; ic<35; ic++){
+ if(!(c = trklt->GetClusters(ic))) continue;
+ det = c->GetDetector();
+ c->GetGlobalXYZ(g);
+ Int_t id = fClusters->SetNextPoint(g[0], g[1], g[2]);
+ fClusters->SetPointId(id, new AliTRDcluster(*c));
+ }
+
+ SetTitle(Form("Det[%d] Plane[%d] P[%7.3f]", det, trklt->GetPlane(), trklt->GetMomentum()));
+ SetLineColor(kRed);
+ //SetOwnIds(kTRUE);
+
+ sec = det/30;
+ Double_t alpha = AliTRDgeometry::GetAlpha() * (sec<9 ? sec + .5 : sec - 17.5);
+ Double_t x0 = trklt->GetX0(),
+ y0f = trklt->GetYfit(0),
+ ysf = trklt->GetYfit(1),
+ z0r = trklt->GetZref(0),
+ zsr = trklt->GetZref(1);
+ Double_t xg = x0 * TMath::Cos(alpha) - y0f * TMath::Sin(alpha);
+ Double_t yg = x0 * TMath::Sin(alpha) + y0f * TMath::Cos(alpha);
+ SetPoint(0, xg, yg, z0r);
+ //SetPointId(0, new AliTRDseedV1(*trackletObj));
+ Double_t x1 = x0-3.5,
+ y1f = y0f - ysf*3.5,
+ z1r = z0r - zsr*3.5;
+ xg = x1 * TMath::Cos(alpha) - y1f * TMath::Sin(alpha);
+ yg = x1 * TMath::Sin(alpha) + y1f * TMath::Cos(alpha);
+ SetPoint(1, xg, yg, z1r);
}
-AliEveTRDHitsEditor::~AliEveTRDHitsEditor()
-{}
-
-void AliEveTRDHitsEditor::SetModel(TObject* obj)
+//______________________________________________________________________________
+void AliEveTRDTracklet::ProcessData()
{
- fM = dynamic_cast<AliEveTRDHits*>(obj);
-
- // Float_t x, y, z;
- // for(int ihit=0; ihit<fM->GetN(); ihit++){
- // fM->GetPoint(ihit, x, y, z);
- // printf("%3d : x=%6.3f y=%6.3f z=%6.3f\n", ihit, x, y, z);
- // }
+ AliTRDseedV1 *tracklet = (AliTRDseedV1*)GetUserData();
+ tracklet->Print();
}
///////////////////////////////////////////////////////////
-///////////// AliEveTRDDigitsEditor /////////////////////
+///////////// AliEveTRDTrack /////////////////////
///////////////////////////////////////////////////////////
-AliEveTRDDigitsEditor::AliEveTRDDigitsEditor(const TGWindow* p, Int_t width, Int_t height,
- UInt_t options, Pixel_t back) :
- TGedFrame(p, width, height, options, back),
- fM(0)
-{
- MakeTitle("TRD Digits");
+//______________________________________________________________________________
+AliEveTRDTrack::AliEveTRDTrack(AliTRDtrackV1 *trk) : TEveLine()
+{
+ // Constructor.
+ SetName("track");
+
+ SetUserData(trk);
+
+ AliTRDtrackerV1::SetNTimeBins(24);
+ AliTrackPoint points[AliTRDtrackV1::kMAXCLUSTERSPERTRACK];
+ Int_t nc = 0, sec = -1; Float_t alpha = 0.;
+ AliTRDcluster *c = 0x0;
+ AliTRDseedV1 *tracklet = 0x0;
+ for(Int_t il=0; il<AliTRDgeometry::kNlayer; il++){
+ if(!(tracklet = trk->GetTracklet(il))) continue;
+ if(!tracklet->IsOK()) continue;
+ AddElement(fTracklet[il] = new AliEveTRDTracklet(tracklet));
+
+ for(Int_t ic=34; ic>=0; ic--){
+ if(!(c = tracklet->GetClusters(ic))) continue;
+ if(sec<0){
+ sec = c->GetDetector()/30;
+ alpha = AliTRDgeometry::GetAlpha() * (sec<9 ? sec + .5 : sec - 17.5);
+ }
+ points[nc].SetXYZ(c->GetX(),0.,0.);
+ nc++;
+ }
+ }
+
+ //AliTRDtrackerV1::FitRiemanTilt(trk, 0x0, kTRUE, nc, points);
+ //AliTRDtrackerV1::FitKalman(trk, 0x0, kFALSE, nc, points);
+ AliTRDtrackerV1::FitLine(trk, 0x0, kFALSE, nc, points);
+
+ Float_t global[3];
+ for(Int_t ip=0; ip<nc; ip++){
+ points[ip].Rotate(-alpha).GetXYZ(global);
+ SetNextPoint(global[0], global[1], global[2]);
+ }
+
+ SetMarkerColor(kBlack);
+ SetLineColor(kBlack);
+ SetSmooth(kTRUE);
}
-AliEveTRDDigitsEditor::~AliEveTRDDigitsEditor()
-{}
-
-void AliEveTRDDigitsEditor::SetModel(TObject* obj)
+//______________________________________________________________________________
+void AliEveTRDTrack::ProcessData()
{
- fM = dynamic_cast<AliEveTRDDigits*>(obj);
- fM->fParent->SpawnEditor();
-
- // printf("Chamber %d", fM->fParent->GetID());
- // for (Int_t row = 0; row < fM->fParent->GetRowMax(); row++)
- // for (Int_t col = 0; col < fM->fParent->GetColMax(); col++)
- // for (Int_t time = 0; time < fM->fParent->GetTimeMax(); time++) {
- // printf("\tA(%d %d %d) = %d\n", row, col, time, fM->fData.GetDataUnchecked(row, col, time));
- // }
+ AliTRDtrackV1 *track = (AliTRDtrackV1*)GetUserData();
+ AliInfo(Form("Clusters[%d]", track->GetNumberOfClusters()));
+
+ const AliTRDrecoParam *rec = 0x0;
+ if(!(rec = AliTRDReconstructor::GetRecoParam())){
+ AliWarning("TRD reco param missing.");
+ return;
+ }
+ // rec->SetPIDMethod(AliTRDrecoParam::kLQPID);
+ track->CookPID();
+ printf("PIDLQ : "); for(int is=0; is<AliPID::kSPECIES; is++) printf("%s[%5.2f] ", AliPID::ParticleName(is), 1.E2*track->GetPID(is)); printf("\n");
+
+ // rec->SetPIDMethod(AliTRDrecoParam::kNNPID);
+ // track->CookPID();
+ // printf("PIDNN : "); for(int is=0; is<AliPID::kSPECIES; is++) printf("%s[%5.2f] ", AliPID::ParticleName(is), 1.E2*track->GetPID(is)); printf("\n");
}
+