1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////////
18 // TRD trigger class //
23 ///////////////////////////////////////////////////////////////////////////////
28 #include <TClonesArray.h>
29 #include <TObjArray.h>
33 //#include "AliLoader.h"
35 #include "AliTRDdigitsManager.h"
36 #include "AliTRDgeometry.h"
37 #include "AliTRDdataArrayI.h"
38 #include "AliTRDcalibDB.h"
39 #include "AliTRDCommonParam.h"
40 #include "AliTRDrawData.h"
41 #include "AliTRDmodule.h"
42 #include "AliTRDmcmTracklet.h"
43 #include "AliTRDgtuTrack.h"
44 #include "AliTRDtrigParam.h"
45 #include "AliTRDmcm.h"
46 #include "AliTRDzmaps.h"
47 #include "AliHLTTRDCalibra.h"
48 #include "Cal/AliTRDCalPIDLQ.h"
50 //#include "AliTRDtrigger.h"
51 #include "AliTRDtriggerHLT.h"
53 ClassImp(AliTRDtriggerHLT)
55 //_____________________________________________________________________________
56 AliTRDtriggerHLT::AliTRDtriggerHLT()
58 fTreeCreatedHere(kFALSE)
61 // AliTRDtriggerHLT default constructor
65 //_____________________________________________________________________________
66 AliTRDtriggerHLT::AliTRDtriggerHLT(const Text_t *name, const Text_t *title)
67 :AliTRDtrigger(name,title),
68 fTreeCreatedHere(kFALSE)
71 // AliTRDtriggerHLT constructor
75 //_____________________________________________________________________________
76 AliTRDtriggerHLT::AliTRDtriggerHLT(const AliTRDtriggerHLT &p)
78 fTreeCreatedHere(kFALSE)
81 // AliTRDtriggerHLT copy constructor
85 ///_____________________________________________________________________________
86 AliTRDtriggerHLT::~AliTRDtriggerHLT()
89 // AliTRDtrigger destructor
93 // fTracklets->Delete();
106 //_____________________________________________________________________________
107 AliTRDtriggerHLT &AliTRDtriggerHLT::operator=(const AliTRDtriggerHLT &p)
110 // Assignment operator
113 if (this != &p) ((AliTRDtriggerHLT &) p).Copy(*this);
118 //_____________________________________________________________________________
119 void AliTRDtriggerHLT::Copy(TObject &) const
125 AliFatal("Not implemented");
129 //_____________________________________________________________________________
130 void AliTRDtriggerHLT::Init()
133 // Init: module, field, geometry, calibDB
136 fModule = new AliTRDmodule(fTrigParam);
138 fField = fTrigParam->GetField();
140 //AliInfo("Recreating default geometry!");
141 AliDebug(1, Form("Recreating default geometry!"));
143 //fGeo = (AliTRDgeometry*)AliTRDgeometry::GetGeometry(fRunLoader);
144 fGeo = new AliTRDgeometry();
146 fCalib = AliTRDcalibDB::Instance();
148 AliError("No instance of AliTRDcalibDB.");
152 fCParam = AliTRDCommonParam::Instance();
154 AliError("No common parameters.");
159 //_____________________________________________________________________________
160 Bool_t AliTRDtriggerHLT::ReadDigits(AliRawReaderMemory* rawReader)
163 // Reads the digits arrays from the ddl file
167 fDigitsManager = raw.Raw2Digits((AliRawReader*)rawReader);
168 //AliInfo(Form("Digits manager at 0x%x", fDigitsManager));
169 AliDebug(1, Form("Digits manager at 0x%x", fDigitsManager));
176 //_____________________________________________________________________________
177 Bool_t AliTRDtriggerHLT::MakeTracklets(Bool_t makeTracks)
180 // Create tracklets from digits
184 Int_t chamEnd = AliTRDgeometry::Ncham();
186 Int_t planEnd = AliTRDgeometry::Nplan();
188 Int_t sectEnd = AliTRDgeometry::Nsect();
190 fTrkTest = new AliTRDmcmTracklet(0,0,0);
191 fMCM = new AliTRDmcm(fTrigParam,0);
200 Int_t iStackPrev = -1;
203 for (Int_t isect = sectBeg; isect < sectEnd; isect++) {
205 for (Int_t icham = chamBeg; icham < chamEnd; icham++) {
207 // Number of ROBs in the chamber
215 for (Int_t iplan = planBeg; iplan < planEnd; iplan++) {
217 idet = fGeo->GetDetector(iplan,icham,isect);
221 iStack = idet / (AliTRDgeometry::Nplan());
222 if (iStackPrev != iStack) {
223 if (iStackPrev == -1) {
227 MakeTracks(idet-AliTRDgeometry::Nplan());
234 Int_t nRowMax = fCParam->GetRowMax(iplan,icham,isect);
235 Int_t nColMax = fCParam->GetColMax(iplan);
236 Int_t nTimeTotal = fCalib->GetNumberOfTimeBins();
239 fDigits = fDigitsManager->GetDigits(idet);
240 if (!fDigits) return kFALSE;
241 // This is to take care of switched off super modules
242 if (fDigits->GetNtime() == 0) {
246 fTrack0 = fDigitsManager->GetDictionary(idet,0);
247 if (!fTrack0) return kFALSE;
249 fTrack1 = fDigitsManager->GetDictionary(idet,1);
250 if (!fTrack1) return kFALSE;
252 fTrack2 = fDigitsManager->GetDictionary(idet,2);
253 if (!fTrack2) return kFALSE;
256 for (Int_t iRob = 0; iRob < fNROB; iRob++) {
258 for (Int_t iMcm = 0; iMcm < kNMCM; iMcm++) {
261 fMCM->SetRobId(iRob);
262 fMCM->SetChaId(idet);
264 SetMCMcoordinates(iMcm);
266 row = fMCM->GetRow();
268 if ((row < 0) || (row >= nRowMax)) {
269 AliError("MCM row number out of range.");
273 fMCM->GetColRange(col1,col2);
275 for (time = 0; time < nTimeTotal; time++) {
276 for (col = col1; col < col2; col++) {
277 if ((col >= 0) && (col < nColMax)) {
278 amp = TMath::Abs(fDigits->GetDataUnchecked(row,col,time));
283 fMCM->SetADC(col-col1,time,amp);
287 if (fTrigParam->GetTailCancelation()) {
288 fMCM->Filter(fTrigParam->GetNexponential(),fTrigParam->GetFilterType());
293 for (Int_t iSeed = 0; iSeed < kMaxTrackletsPerMCM; iSeed++) {
295 if (fMCM->GetSeedCol()[iSeed] < 0) {
299 if (fTrigParam->GetDebugLevel() > 1)
301 //AliInfo(Form("Add tracklet %d in col %02d \n",fNtracklets,fMCM->GetSeedCol()[iSeed]));
302 AliDebug(5, Form("Add tracklet %d in col %02d \n",fNtracklets,fMCM->GetSeedCol()[iSeed]));
305 if (TestTracklet(idet,row,iSeed,0)) {
306 AddTracklet(idet,row,iSeed,fNtracklets++);
307 //AliInfo(Form("TESTED OK tracklet %d in col %02d \n",fNtracklets,fMCM->GetSeedCol()[iSeed]));
308 AliDebug(5, Form("TESTED OK tracklet %d in col %02d \n",fNtracklets,fMCM->GetSeedCol()[iSeed]));
312 //AliInfo(Form("REJECTED tracklet %d in col %02d \n",fNtracklets,fMCM->GetSeedCol()[iSeed]));
313 AliDebug(5, Form("REJECTED tracklet %d in col %02d \n",fNtracklets,fMCM->GetSeedCol()[iSeed]));
325 // Compress the arrays
326 fDigits->Compress(1,0);
327 fTrack0->Compress(1,0);
328 fTrack1->Compress(1,0);
329 fTrack2->Compress(1,0);
331 //WriteTracklets(idet);
340 MakeTracks(idet - AliTRDgeometry::Nplan());
348 //_____________________________________________________________________________
349 Bool_t AliTRDtriggerHLT::ResetTree()
352 // Recreate the cluster tree
356 // if (fTrackletTree != 0)
357 // fTrackletTree->Reset();
358 // well we'd better delete the whole tree and branches
359 delete fTrackletTree;
360 fTrackletTree = NULL;
361 fTrackletTree = new TTree("TRDclusterTree", "TRDclusterTree");
364 fTreeCreatedHere = kTRUE;
365 //AliInfo("Tree Reset Successful");
366 AliDebug(1, Form("Tree Reset Successful"));
370 fTreeCreatedHere = kFALSE;
371 AliError("Reset Tree Error!\n");
374 return fTreeCreatedHere;
377 //_____________________________________________________________________________
378 Bool_t AliTRDtriggerHLT::TreeTracklets(Int_t idet)
381 // Failsafe ::WriteTracklets - recreate the cluster tree if necessary
384 if (fTrackletTree == 0)
386 fTrackletTree = new TTree("TRDtrackletTree", "TRDtrackletTree");
387 fTreeCreatedHere = kTRUE;
392 AliError("Attempt to write tracklet tree on HLT - bad idea!");
393 AliError("HLT does not write any data here!\n");
397 return WriteTracklets(idet);
400 //_____________________________________________________________________________
401 Bool_t AliTRDtriggerHLT::TestTracklet(Int_t det, Int_t row, Int_t seed, Int_t n)
404 // Check first the tracklet pt
407 Int_t nTimeTotal = fCalib->GetNumberOfTimeBins();
409 // Calibration fill 2D
410 AliHLTTRDCalibra *calibra = AliHLTTRDCalibra::Instance();
413 AliError("Could not get Calibra instance\n");
418 fTrkTest->SetDetector(det);
419 fTrkTest->SetRow(row);
422 Int_t iCol, iCol1, iCol2, track[3];
423 iCol = fMCM->GetSeedCol()[seed]; // 0....20 (MCM)
424 fMCM->GetColRange(iCol1,iCol2); // range in the pad plane
427 for (Int_t iTime = 0; iTime < nTimeTotal; iTime++) {
429 amp[0] = fMCM->GetADC(iCol-1,iTime);
430 amp[1] = fMCM->GetADC(iCol ,iTime);
431 amp[2] = fMCM->GetADC(iCol+1,iTime);
433 // extract track contribution only from the central pad
434 track[0] = fTrack0->GetDataUnchecked(row,iCol+iCol1,iTime);
435 track[1] = fTrack1->GetDataUnchecked(row,iCol+iCol1,iTime);
436 track[2] = fTrack2->GetDataUnchecked(row,iCol+iCol1,iTime);
438 if (fMCM->IsCluster(iCol,iTime)) {
440 fTrkTest->AddCluster(iCol+iCol1,iTime,amp,track);
443 else if ((iCol+1+1) < kMcmCol) {
445 amp[0] = fMCM->GetADC(iCol-1+1,iTime);
446 amp[1] = fMCM->GetADC(iCol +1,iTime);
447 amp[2] = fMCM->GetADC(iCol+1+1,iTime);
449 if (fMCM->IsCluster(iCol+1,iTime)) {
451 // extract track contribution only from the central pad
452 track[0] = fTrack0->GetDataUnchecked(row,iCol+1+iCol1,iTime);
453 track[1] = fTrack1->GetDataUnchecked(row,iCol+1+iCol1,iTime);
454 track[2] = fTrack2->GetDataUnchecked(row,iCol+1+iCol1,iTime);
456 fTrkTest->AddCluster(iCol+1+iCol1,iTime,amp,track);
464 fTrkTest->CookLabel(0.8);
466 if (fTrkTest->GetLabel() >= fNPrimary) {
467 Info("AddTracklet","Only primaries are stored!");
472 //AliInfo(Form("Geom at 0x%x Field = %f", fGeo, fField));
473 fTrkTest->MakeTrackletGraph(fGeo,fField);
475 // TRD Online calibration
476 //if (calibra->GetMcmTracking()) {
477 //AliInfo(Form("Updating tracklet histos : %d", calibra->GetMcmTracking()));
478 //calibra->UpdateHistogramcm(fTrkTest);
481 //AliInfo("Updating tracklet histos");
482 AliDebug(2, Form("Updating tracklet histos"));
483 calibra->UpdateHistogramcm(fTrkTest);
485 fTrkTest->MakeClusAmpGraph();
486 //AliInfo("MakeClusAmpGraph Done.");
488 if (TMath::Abs(fTrkTest->GetPt()) < fTrigParam->GetLtuPtCut())
490 //AliInfo(Form("Cut tracklet - pT is %f", TMath::Abs(fTrkTest->GetPt())));
491 AliDebug(5, Form("Cut tracklet - pT is %f", TMath::Abs(fTrkTest->GetPt())));
496 //AliInfo(Form("Tracklet passed - pT is %f", TMath::Abs(fTrkTest->GetPt())));
497 AliDebug(5, Form("Tracklet passed - pT is %f", TMath::Abs(fTrkTest->GetPt())));