LCOV - code coverage report
Current view: top level - TOF/TOFrec - AliTOFReconstructor.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 80 105 76.2 %
Date: 2016-06-14 17:26:59 Functions: 12 13 92.3 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       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             :  **************************************************************************/
      15             : 
      16             : /* $Id: AliTOFReconstructor.cxx 59948 2012-12-12 11:05:59Z fnoferin $ */
      17             : 
      18             : ///////////////////////////////////////////////////////////////////////////////
      19             : //                                                                           //
      20             : // class for TOF reconstruction                                              //
      21             : //                                                                           //
      22             : ///////////////////////////////////////////////////////////////////////////////
      23             : 
      24             : #include <cstdlib>
      25             : #include "TObjArray.h"
      26             : #include "TString.h"
      27             : 
      28             : #include "AliLog.h"
      29             : #include "AliESDEvent.h"
      30             : #include "AliESDpid.h"
      31             : #include "AliRawReader.h"
      32             : #include "AliTOFHeader.h"
      33             : 
      34             : #include "AliTOFClusterFinder.h"
      35             : #include "AliTOFClusterFinderV1.h"
      36             : #include "AliTOFcalib.h"
      37             : #include "AliTOFtrackerMI.h"
      38             : #include "AliTOFtracker.h"
      39             : #include "AliTOFtrackerV1.h"
      40             : #include "AliTOFtrackerV2.h"
      41             : #include "AliTOFT0maker.h"
      42             : #include "AliTOFReconstructor.h"
      43             : #include "AliTOFTriggerMask.h"
      44             : #include "AliTOFTrigger.h"
      45             : #include "AliCTPTimeParams.h"
      46             : #include "AliCDBManager.h"
      47             : #include "AliCDBEntry.h"
      48             : 
      49             : class TTree;
      50             : 
      51          26 : ClassImp(AliTOFReconstructor)
      52             : 
      53             : Double_t AliTOFReconstructor::fgExtraTolerance = 0;
      54             : Int_t AliTOFReconstructor::fgCTPtriggerLatency = -1;
      55             : 
      56             :  //____________________________________________________________________
      57             : AliTOFReconstructor::AliTOFReconstructor() :
      58           2 :   AliReconstructor(),
      59           2 :   fTOFcalib(0),
      60             :   /*fTOFT0maker(0),*/
      61           2 :   fNumberOfTofClusters(0),
      62           2 :   fNumberOfTofTrgPads(0),
      63           2 :   fClusterFinder(0),
      64           2 :   fClusterFinderV1(0)
      65          10 : {
      66             : //
      67             : // ctor
      68             : //
      69             :   
      70             :   //Retrieving the TOF calibration info  
      71           6 :   fTOFcalib = new AliTOFcalib();
      72           2 :   fTOFcalib->Init();
      73           6 :   fClusterFinder = new AliTOFClusterFinder(fTOFcalib);
      74           6 :   fClusterFinderV1 = new AliTOFClusterFinderV1(fTOFcalib);
      75             : 
      76           4 :   TString optionString = GetOption();
      77           4 :   if (optionString.Contains("DecoderV0")) {
      78           0 :     fClusterFinder->SetDecoderVersion(0);
      79           0 :     fClusterFinderV1->SetDecoderVersion(0);
      80           0 :   }
      81           4 :   else if (optionString.Contains("DecoderV1")) {
      82           2 :     fClusterFinder->SetDecoderVersion(1);
      83           0 :     fClusterFinderV1->SetDecoderVersion(1);
      84           0 :   }
      85             :   else {
      86           2 :     fClusterFinder->SetDecoderVersion(2);
      87           2 :     fClusterFinderV1->SetDecoderVersion(2);
      88             :   }
      89             : 
      90             : 
      91             : 
      92             : #if 0
      93             :   fTOFcalib->CreateCalObjects();
      94             : 
      95             :   if(!fTOFcalib->ReadParOnlineDelayFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
      96             :   if(!fTOFcalib->ReadParOnlineStatusFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
      97             : 
      98             :   if(!fTOFcalib->ReadParOfflineFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
      99             : 
     100             : 
     101             :   if(!fTOFcalib->ReadDeltaBCOffsetFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
     102             :   if(!fTOFcalib->ReadCTPLatencyFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
     103             :   if(!fTOFcalib->ReadT0FillFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
     104             :   if(!fTOFcalib->ReadRunParamsFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
     105             : #endif
     106             : 
     107           4 : }
     108             : 
     109             : //_____________________________________________________________________________
     110             : AliTOFReconstructor::~AliTOFReconstructor() 
     111          12 : {
     112             : //
     113             : // dtor
     114             : //
     115             : 
     116           4 :   delete fTOFcalib;
     117             : 
     118             :   //delete fTOFT0maker;
     119           2 :   fNumberOfTofClusters = 0;
     120           2 :   fNumberOfTofTrgPads = 0;
     121             : 
     122           4 :   delete fClusterFinder;
     123           4 :   delete fClusterFinderV1;
     124           6 : }
     125             : void AliTOFReconstructor::GetPidSettings(AliESDpid *esdPID){
     126          16 :   Float_t tofResolution = GetRecoParam()->GetTimeResolution();// TOF time resolution in ps
     127           8 :   AliInfo(Form(" TOF resolution set in PIDResponse to %f ps",tofResolution));
     128             :   
     129           8 :   esdPID->GetTOFResponse().SetTimeResolution(tofResolution);
     130             : 
     131             :   return;
     132           8 : }
     133             : 
     134             : //_____________________________________________________________________________
     135             : void AliTOFReconstructor::Reconstruct(AliRawReader *rawReader,
     136             :                                       TTree *clustersTree) const
     137             : {
     138           8 :   AliInfo(Form("TOF Reconstruct"));
     139             :  
     140             :   //
     141             :   // reconstruct clusters from Raw Data
     142             :   //
     143             : 
     144           4 :   TString optionString = GetOption();
     145             : 
     146             :   // use V1 cluster finder if selected
     147           8 :   if (optionString.Contains("ClusterizerV1")) {
     148             :     /*
     149             :     AliTOFClusterFinderV1 tofClus(fTOFcalib);
     150             : 
     151             :     // decoder version option
     152             :     if (optionString.Contains("DecoderV0")) {
     153             :       tofClus.SetDecoderVersion(0);
     154             :     }
     155             :     else if (optionString.Contains("DecoderV1")) {
     156             :       tofClus.SetDecoderVersion(1);
     157             :     }
     158             :     else {
     159             :       tofClus.SetDecoderVersion(2);
     160             :     }
     161             : 
     162             :     tofClus.Digits2RecPoints(rawReader, clustersTree);
     163             :     */
     164             : 
     165           0 :     fClusterFinderV1->Digits2RecPoints(rawReader, clustersTree);    
     166             :   }
     167             :   else {
     168             :     /*
     169             :     AliTOFClusterFinder tofClus(fTOFcalib);
     170             :       
     171             :     // decoder version option
     172             :     if (optionString.Contains("DecoderV0")) {
     173             :       tofClus.SetDecoderVersion(0);
     174             :     }
     175             :     else if (optionString.Contains("DecoderV1")) {
     176             :       tofClus.SetDecoderVersion(1);
     177             :     }
     178             :     else {
     179             :       tofClus.SetDecoderVersion(2);
     180             :     }
     181             : 
     182             :     tofClus.Digits2RecPoints(rawReader, clustersTree);
     183             : 
     184             :     */
     185             : 
     186           4 :     fClusterFinder->Digits2RecPoints(rawReader, clustersTree);
     187             :   }
     188             : 
     189             : 
     190           4 :   if(fgCTPtriggerLatency < 0){ // read from OCDB
     191           1 :     AliCDBManager *man = AliCDBManager::Instance();
     192           1 :     Int_t run = man->GetRun();
     193           1 :     if(run > 244335){
     194           0 :       fgCTPtriggerLatency = 12800; // run-2 value
     195           0 :     }
     196             :     else
     197           1 :       fgCTPtriggerLatency = 13600; // run-1 value
     198             : 
     199           3 :     AliInfo(Form("CTP latency used for run %i to select bunch ID = %i",run,fgCTPtriggerLatency));
     200           1 :   }
     201             : 
     202             : 
     203           4 :   AliTOFTrigger::PrepareTOFMapFromRaw(rawReader,fgCTPtriggerLatency); // 13600 +/- 400 is the value to select the richt bunch crossing (in future from OCDB)
     204           4 : }
     205             : 
     206             : //_____________________________________________________________________________
     207             : void AliTOFReconstructor::Reconstruct(TTree *digitsTree,
     208             :                                       TTree *clustersTree) const
     209             : {
     210             :   //
     211             :   // reconstruct clusters from digits
     212             :   //
     213             : 
     214          16 :   AliDebug(2,Form("Global Event loop mode: Creating Recpoints from Digits Tree")); 
     215             : 
     216           4 :   TString optionString = GetOption();
     217             :   // use V1 cluster finder if selected
     218           8 :   if (optionString.Contains("ClusterizerV1")) {
     219             :     /*
     220             :     AliTOFClusterFinderV1 tofClus(fTOFcalib);
     221             : 
     222             :     // decoder version option
     223             :     if (optionString.Contains("DecoderV0")) {
     224             :       tofClus.SetDecoderVersion(0);
     225             :     }
     226             :     else if (optionString.Contains("DecoderV1")) {
     227             :       tofClus.SetDecoderVersion(1);
     228             :     }
     229             :     else {
     230             :       tofClus.SetDecoderVersion(2);
     231             :     }
     232             :     
     233             :     tofClus.Digits2RecPoints(digitsTree, clustersTree);
     234             :     */
     235           0 :     fClusterFinderV1->Digits2RecPoints(digitsTree, clustersTree);
     236             :   }
     237             :   else {
     238             :     /*
     239             :     AliTOFClusterFinder tofClus(fTOFcalib);
     240             : 
     241             :     // decoder version option
     242             :     if (optionString.Contains("DecoderV0")) {
     243             :       tofClus.SetDecoderVersion(0);
     244             :     }
     245             :     else if (optionString.Contains("DecoderV1")) {
     246             :       tofClus.SetDecoderVersion(1);
     247             :     }
     248             :     else {
     249             :       tofClus.SetDecoderVersion(2);
     250             :     }
     251             :     
     252             :     tofClus.Digits2RecPoints(digitsTree, clustersTree);
     253             :     */
     254             : 
     255           4 :     fClusterFinder->Digits2RecPoints(digitsTree, clustersTree);
     256           4 :     AliTOFTrigger::PrepareTOFMapFromDigit(digitsTree);
     257             : 
     258             :   }
     259             : 
     260           4 : }
     261             : //_____________________________________________________________________________
     262             :   void AliTOFReconstructor::ConvertDigits(AliRawReader* reader, TTree* digitsTree) const
     263             : {
     264             : // reconstruct clusters from digits
     265             : 
     266           0 :   AliDebug(2,Form("Global Event loop mode: Converting Raw Data to a Digits Tree")); 
     267             : 
     268           0 :   TString optionString = GetOption();
     269             :   // use V1 cluster finder if selected
     270           0 :   if (optionString.Contains("ClusterizerV1")) {
     271             :     /*
     272             :     AliTOFClusterFinderV1 tofClus(fTOFcalib);
     273             : 
     274             :     // decoder version option
     275             :     if (optionString.Contains("DecoderV0")) {
     276             :       tofClus.SetDecoderVersion(0);
     277             :     }
     278             :     else if (optionString.Contains("DecoderV1")) {
     279             :       tofClus.SetDecoderVersion(1);
     280             :     }
     281             :     else {
     282             :       tofClus.SetDecoderVersion(2);
     283             :     }
     284             :     
     285             :     tofClus.Raw2Digits(reader, digitsTree);
     286             :     */
     287             : 
     288           0 :     fClusterFinderV1->Digits2RecPoints(reader, digitsTree);
     289             :   }
     290             :   else {
     291             :     /*
     292             :     AliTOFClusterFinder tofClus(fTOFcalib);
     293             : 
     294             :     // decoder version option
     295             :     if (optionString.Contains("DecoderV0")) {
     296             :       tofClus.SetDecoderVersion(0);
     297             :     }
     298             :     else if (optionString.Contains("DecoderV1")) {
     299             :       tofClus.SetDecoderVersion(1);
     300             :     }
     301             :     else {
     302             :       tofClus.SetDecoderVersion(2);
     303             :     }
     304             :     
     305             :     tofClus.Raw2Digits(reader, digitsTree);
     306             :     */
     307             : 
     308           0 :     fClusterFinder->Digits2RecPoints(reader, digitsTree);
     309             : 
     310             :   }
     311             : 
     312           0 : }
     313             : 
     314             : //_____________________________________________________________________________
     315             : AliTracker* AliTOFReconstructor::CreateTracker() const
     316             : {
     317             : 
     318             :   // 
     319             :   // create a TOF tracker using 
     320             :   // TOF Reco Param collected by STEER
     321             :   //
     322             : 
     323           4 :   TString selectedTracker = GetOption();
     324             :  
     325             :   AliTracker *tracker;
     326             :   // use MI tracker if selected
     327           4 :   if (selectedTracker.Contains("TrackerMI")) {
     328           0 :     tracker = new AliTOFtrackerMI();
     329           0 :   }
     330             :   // use V1 tracker if selected
     331           4 :   else if (selectedTracker.Contains("TrackerV1")) {
     332           0 :     tracker =  new AliTOFtrackerV1();
     333           0 :   }
     334           4 :   else if (selectedTracker.Contains("TrackerV2")) {
     335           0 :     tracker =  new AliTOFtrackerV2();
     336           0 :   }
     337             :   else {
     338           6 :     tracker = new AliTOFtracker();
     339             :   }
     340             :   return tracker;
     341             : 
     342           2 : }
     343             : 
     344             : //_____________________________________________________________________________
     345             : void AliTOFReconstructor::FillEventTimeWithTOF(AliESDEvent *event, AliESDpid *esdPID)
     346             : {
     347             :   //
     348             :   // Fill AliESDEvent::fTOFHeader variable
     349             :   // It contains the event_time estiamted by the TOF combinatorial algorithm
     350             :   //
     351             : 
     352             : 
     353             :   // Set here F. Noferini
     354          16 :   AliTOFTriggerMask *mapTrigger = AliTOFTrigger::GetTOFTriggerMap();
     355             : 
     356             : 
     357           8 :   TString optionString = GetOption();
     358          16 :   if (optionString.Contains("ClusterizerV1")) {
     359           0 :     fNumberOfTofClusters=fClusterFinderV1->GetNumberOfTOFclusters();
     360           0 :     fNumberOfTofTrgPads=fClusterFinderV1->GetNumberOfTOFtrgPads();
     361           0 :     AliInfo(Form(" Number of TOF cluster readout = %d ",fNumberOfTofClusters));
     362           0 :     AliInfo(Form(" Number of TOF cluster readout in trigger window = %d ",fNumberOfTofTrgPads));
     363             :   } else {
     364           8 :     fNumberOfTofClusters=fClusterFinder->GetNumberOfTOFclusters();
     365           8 :     fNumberOfTofTrgPads=fClusterFinder->GetNumberOfTOFtrgPads();
     366          24 :     AliInfo(Form(" Number of TOF cluster readout = %d ",fNumberOfTofClusters));
     367          24 :     AliInfo(Form(" Number of TOF cluster readout in trigger window = %d ",fNumberOfTofTrgPads));
     368             :   }
     369             : 
     370          16 :   if (!GetRecoParam()) AliFatal("cannot get TOF RECO params");
     371             : 
     372          16 :   AliTOFT0maker *tofT0maker = new AliTOFT0maker(esdPID);
     373             :   //Float_t tofResolution = GetRecoParam()->GetTimeResolution();// TOF time resolution in ps
     374             :   //tofT0maker->SetTimeResolution(tofResolution); // setting performed now in GetPidSetting in AliReconstructor
     375           8 :   tofT0maker->ComputeT0TOF(event);
     376           8 :   tofT0maker->WriteInESD(event);
     377           8 :   tofT0maker->~AliTOFT0maker();
     378          16 :   delete tofT0maker;
     379             : 
     380          16 :   esdPID->SetTOFResponse(event,(AliESDpid::EStartTimeType_t)GetRecoParam()->GetStartTimeType());
     381             : 
     382             : 
     383          16 :   event->GetTOFHeader()->SetNumberOfTOFclusters(fNumberOfTofClusters);
     384          16 :   event->GetTOFHeader()->SetNumberOfTOFtrgPads(fNumberOfTofTrgPads);
     385          24 :   if(mapTrigger)  event->GetTOFHeader()->SetTriggerMask(mapTrigger);
     386          48 :   AliInfo(Form(" Number of readout cluster in trigger window = %d ; number of trgPads from Trigger map = %d",
     387             :                event->GetTOFHeader()->GetNumberOfTOFtrgPads(),
     388             :                event->GetTOFHeader()->GetNumberOfTOFmaxipad()));
     389             : 
     390           8 :   fClusterFinderV1->ResetDigits();
     391           8 :   fClusterFinderV1->ResetRecpoint();
     392           8 :   fClusterFinder->ResetRecpoint();
     393           8 :   fClusterFinderV1->Clear();
     394           8 :   fClusterFinder->Clear();
     395             : 
     396           8 : }
     397             : 
     398             : //_____________________________________________________________________________
     399             : void 
     400             : AliTOFReconstructor::FillESD(TTree *, TTree *, AliESDEvent * /*esdEvent*/) const
     401             : {
     402             :   //
     403             :   // correct Texp 
     404             :   // 
     405             :   //
     406             : 
     407             :   //  fTOFcalib->CalibrateTExp(esdEvent);
     408          16 : }

Generated by: LCOV version 1.11