LCOV - code coverage report
Current view: top level - TPC/TPCrec - AliTPCReconstructor.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 56 138 40.6 %
Date: 2016-06-14 17:26:59 Functions: 14 20 70.0 %

          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$ */
      17             : 
      18             : //--------------------------------------------------------------------
      19             : //          Options for the TPC Reconstruction in rec.C
      20             : //
      21             : //  4 options can be set to change the input for TPC reconstruction
      22             : //  which overwrites the usage of fUseHLTClusters of the AliTPCRecoParam
      23             : //
      24             : //  1) useRAW        - use RAW, if not present -> do nothing
      25             : //  2) useRAWorHLT   - use RAW, if not present -> use HLT clusters
      26             : //  3) useHLT        - use HLT clusters, if not present -> do nothing
      27             : //  4) useHLTorRAW   - use HLT clusters, if not present -> use RAW
      28             : //
      29             : //  -> The current default is useHLTorRAW
      30             : //--------------------------------------------------------------------
      31             : 
      32             : ///////////////////////////////////////////////////////////////////////////////
      33             : //                                                                           //
      34             : // class for TPC reconstruction                                              //
      35             : //                                                                           //
      36             : ///////////////////////////////////////////////////////////////////////////////
      37             : 
      38             : #include <TObject.h>
      39             : #include <TString.h>
      40             : #include <TObjString.h>
      41             : #include <TObjArray.h>
      42             : #include <TFile.h>
      43             : 
      44             : #include <AliLog.h>
      45             : #include <AliPID.h>
      46             : #include <AliESDpid.h>
      47             : #include <AliTPCPIDResponse.h>
      48             : #include "AliTPCReconstructor.h"
      49             : #include "AliRunLoader.h"
      50             : #include "AliRun.h"
      51             : #include "AliRawReader.h"
      52             : #include "AliTPCclusterer.h"
      53             : #include "AliTPCtracker.h"
      54             : #include "AliTPCParam.h"
      55             : #include "AliTPCParamSR.h"
      56             : #include "AliTPCcalibDB.h"
      57             : #include "AliTracker.h"
      58             : #include "AliMagF.h"
      59             : #include "TTreeStream.h"
      60             : 
      61          16 : ClassImp(AliTPCReconstructor)
      62             : 
      63             : 
      64             : Int_t    AliTPCReconstructor::fgStreamLevel     = 0;             // stream (debug) level
      65             : AliTPCAltroEmulator *  AliTPCReconstructor::fAltroEmulator=0;    // ALTRO emulator
      66             : TTreeSRedirector    *  AliTPCReconstructor::fgDebugStreamer=0;                          // NOTE -  AliTPCReconstructor is not an owner of the streamer
      67          16 : TString                AliTPCReconstructor::fgPIDRespnonsePath="$ALICE_PHYSICS/OADB/COMMON/PID/data/TPCPIDResponse.root";
      68             :  
      69             : TVectorD *  AliTPCReconstructor::fSystematicErrors=0;
      70             : TVectorD *  AliTPCReconstructor::fSystematicErrorClusters=0;
      71             : TVectorD *  AliTPCReconstructor::fgExtendedRoads=0;
      72             : TVectorD *  AliTPCReconstructor::fgPrimaryDCACut=0;
      73             : Double_t    AliTPCReconstructor::fgPrimaryZ2XCut = 0;
      74             : Double_t    AliTPCReconstructor::fgZOutSectorCut = 0;
      75             : Bool_t      AliTPCReconstructor::fgCompactClusters = kFALSE;
      76             : 
      77             : AliTPCReconstructor::AliTPCReconstructor():
      78           2 : AliReconstructor(),
      79           2 : fClusterer(NULL),
      80           2 : fArrSplines(NULL)
      81          10 : {
      82             :   //
      83             :   // default constructor
      84             :   //
      85             :   //
      86             :   //
      87           2 :   AliTPCcalibDB * calib = AliTPCcalibDB::Instance();
      88           4 :   const AliMagF * field = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
      89           2 :   calib->SetExBField(field);
      90           2 :   AliTPCParam* param = GetTPCParam();
      91           2 :   if (!param) {
      92           0 :     AliWarning("Loading default TPC parameters !");
      93           0 :     param = new AliTPCParamSR;
      94           0 :   }
      95           6 :   fClusterer = new AliTPCclusterer(param);
      96           4 : }
      97             : 
      98             : AliTPCReconstructor::AliTPCReconstructor(const AliTPCReconstructor& /*rec*/):
      99           0 : AliReconstructor(),
     100           0 : fClusterer(NULL),
     101           0 : fArrSplines(NULL)
     102           0 : {
     103             :   //
     104             :   // Dummy copu constructor
     105             :   //
     106           0 : }
     107             : 
     108             : AliTPCReconstructor& AliTPCReconstructor::operator=(const AliTPCReconstructor&){
     109             :   //
     110             :   // dummy operator
     111             :   //
     112           0 :   return *this;
     113             : }
     114             : 
     115             : //_____________________________________________________________________________
     116             : AliTPCReconstructor::~AliTPCReconstructor()
     117          12 : {
     118           6 :   if (fClusterer)   delete fClusterer;
     119           2 :   delete fArrSplines;
     120           6 :   delete AliTPCcalibDB::Instance();
     121           6 : }
     122             : 
     123             : //_____________________________________________________________________________
     124             : void AliTPCReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const {
     125             :   // single event local reconstruction
     126             :   // of TPC data
     127           8 :   fClusterer->SetInput(digitsTree);
     128           4 :   fClusterer->SetOutput(clustersTree);
     129           4 :   fClusterer->Digits2Clusters();
     130           4 : }
     131             : 
     132             : //_____________________________________________________________________________
     133             : void AliTPCReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const {
     134             :   // single event local reconstruction
     135             :   // of TPC data starting from raw data
     136             : 
     137           8 :   fClusterer->SetOutput(clustersTree);
     138           4 :   fClusterer->Digits2Clusters(rawReader);
     139           4 : }
     140             : 
     141             : //_____________________________________________________________________________
     142             : AliTracker* AliTPCReconstructor::CreateTracker() const
     143             : {
     144             : // create a TPC tracker
     145             : 
     146           4 :   AliTPCParam* param = GetTPCParam();
     147           2 :   if (!param) {
     148           0 :     AliWarning("Loading default TPC parameters !");
     149           0 :     param = new AliTPCParamSR;
     150           0 :   }
     151           2 :   param->ReadGeoMatrices();
     152             :   
     153           2 :   AliTPCtracker* tracker = new AliTPCtracker(param);
     154             : 
     155           2 :   ParseOptions(tracker);
     156             : 
     157           2 :   return tracker;
     158           0 : }
     159             : 
     160             : //_____________________________________________________________________________
     161             : void AliTPCReconstructor::FillESD(TTree */*digitsTree*/, TTree */*clustersTree*/,
     162             :                                   AliESDEvent* /*esd*/) const
     163             : {
     164             : // make PID
     165             : /*  Now done in AliESDpid
     166             :   Double_t parTPC[] = {50., 0.07, 5.};  // MIP nnormalized to channel 50 -MI
     167             :   AliTPCpidESD tpcPID(parTPC);
     168             :   tpcPID.MakePID(esd);
     169             : */
     170          32 : }
     171             : 
     172             : 
     173             : //_____________________________________________________________________________
     174             : AliTPCParam* AliTPCReconstructor::GetTPCParam() const
     175             : {
     176             : // get the TPC parameters
     177             : 
     178           8 :   AliTPCParam* param = AliTPCcalibDB::Instance()->GetParameters();
     179             : 
     180           4 :   return param;
     181             : }
     182             : 
     183             : //_____________________________________________________________________________
     184             : void AliTPCReconstructor::SetSplinesFromOADB(const char* tmplt, AliESDpid *esdPID)
     185             : {
     186             :   //
     187             :   //  load splines from the OADB using 'template'
     188             :   //
     189             : 
     190             :   // only load splines if not already set
     191           0 :   if (!fArrSplines) {
     192           0 :     fArrSplines=new TObjArray(Int_t(AliPID::kSPECIES));
     193           0 :     fArrSplines->SetOwner();
     194           0 :     TString stemplate(tmplt);
     195             : 
     196           0 :     TFile f(GetPIDRespnonsePath());
     197             : 
     198             :     TObjArray *arrPidResponseMaster=0x0;
     199             : 
     200           0 :     if (f.IsOpen() && !f.IsZombie()){
     201           0 :       arrPidResponseMaster=dynamic_cast<TObjArray*>(f.Get("TPCPIDResponse"));
     202           0 :     }
     203           0 :     f.Close();
     204             : 
     205           0 :     if (!arrPidResponseMaster){
     206           0 :       AliError("PID response array not found, cannot assign proper splines");
     207           0 :       return;
     208             :     }
     209             : 
     210           0 :     for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec)
     211             :     {
     212             :       Int_t ispec2=ispec;
     213           0 :       if (ispec==Int_t(AliPID::kMuon)) ispec2=Int_t(AliPID::kPion);
     214             : 
     215           0 :       TString particle=AliPID::ParticleName(ispec2);
     216           0 :       particle.ToUpper();
     217             : 
     218           0 :       TString splineName;
     219           0 :       splineName.Form(stemplate.Data(),particle.Data());
     220           0 :       TObject *spline=arrPidResponseMaster->FindObject(splineName.Data());
     221           0 :       if (!spline) {
     222           0 :         AliError(Form("No spline found for '%s'", splineName.Data()));
     223           0 :         continue;
     224             :       };
     225           0 :       AliInfo(Form("Adding Response function %d:%s",ispec,splineName.Data()));
     226           0 :       fArrSplines->AddAt(spline->Clone(), ispec);
     227           0 :     }    
     228           0 :     arrPidResponseMaster->Delete();
     229           0 :     delete arrPidResponseMaster;
     230           0 :     if (fArrSplines->GetEntries()!=Int_t(AliPID::kSPECIES)) {
     231           0 :       AliError("Splines not found for all species, cannot use proper PID");
     232           0 :       delete fArrSplines;
     233           0 :       fArrSplines=NULL;
     234           0 :       return;
     235             :     }
     236           0 :   }
     237             : 
     238           0 :   for (Int_t ispec=0; ispec<AliPID::kSPECIES; ++ispec)
     239             :   {
     240           0 :     esdPID->GetTPCResponse().SetResponseFunction( (AliPID::EParticleType)ispec, fArrSplines->UncheckedAt(ispec) );
     241             :   }
     242             : 
     243           0 :   esdPID->GetTPCResponse().SetUseDatabase(kTRUE);
     244           0 : }
     245             : 
     246             : //_____________________________________________________________________________
     247             : void AliTPCReconstructor::GetPidSettings(AliESDpid *esdPID)
     248             : {
     249             :   //
     250             :   // Get TPC pid splines. They should be written to the OCDB during the CPass
     251             :   // the splines themselves are owned by the OCDB object
     252             :   //
     253             : 
     254             :   // parse options
     255          16 :   TString allopt(GetOption());
     256          24 :   TObjArray *optArray=allopt.Tokenize(";");
     257             : 
     258             :   // defines whether the pid was set via a specific option in the rec.C
     259             :   Bool_t pidSetInOptions = kFALSE;
     260             :   
     261          24 :   for (Int_t iopt=0; iopt<optArray->GetEntriesFast(); ++iopt){
     262           0 :     if (!optArray->At(iopt)) continue;
     263           0 :     TString option(static_cast<TObjString*>(optArray->At(iopt))->GetString().Strip(TString::kBoth,' '));
     264             : 
     265           0 :     if (!option.BeginsWith("PID.")) continue;
     266             : 
     267             :     // remove 'PID.' identifyer
     268           0 :     option.Remove(0,4);
     269             : 
     270             :     // parse PID type
     271           0 :     if (option.BeginsWith("Static=")){
     272           0 :       option.Remove(0,option.First('=')+1);
     273           0 :       if (option.Contains("LHC13b2_fix_PID")) {
     274           0 :         esdPID->GetTPCResponse().SetBetheBlochParameters(0.0320981, 19.9768, 2.52666e-16, 2.72123, 6.08092);
     275           0 :         esdPID->GetTPCResponse().SetMip(53.4968);
     276             :         pidSetInOptions=kTRUE;
     277           0 :       }
     278             :       
     279           0 :     } else if (option.BeginsWith("OADB=")) {
     280           0 :       option.Remove(0,option.First('=')+1);
     281           0 :       AliInfo(Form("Setting splines From OADB using template: '%s'",option.Data()));
     282           0 :       SetSplinesFromOADB(option, esdPID);
     283             :       pidSetInOptions=kTRUE;
     284           0 :     } else if (option.BeginsWith("OCDB=")){
     285           0 :       option.Remove(0,option.First('=')+1);
     286             :       // not yet implemented
     287             :     }
     288             :     
     289           0 :   }
     290             : 
     291          16 :   delete optArray;
     292             : 
     293             :   //
     294             :   // Initialisation of BB parameters from the OCDB.
     295             :   // They are stored in the AliTPCParam
     296             :   //
     297           8 :   if (!pidSetInOptions) {
     298          16 :     AliTPCParam* param = AliTPCcalibDB::Instance()->GetParameters();
     299           8 :     if (param) {
     300           8 :       TVectorD *paramBB=param->GetBetheBlochParameters();
     301           8 :       if (paramBB){
     302          48 :         esdPID->GetTPCResponse().SetBetheBlochParameters((*paramBB)(0),(*paramBB)(1),(*paramBB)(2),(*paramBB)(3),(*paramBB)(4));
     303          64 :         AliInfo(Form("Setting BB parameters from OCDB (AliTPCParam): %.2g, %.2g, %.2g, %.2g, %.2g",
     304             :                      (*paramBB)(0),(*paramBB)(1),(*paramBB)(2),(*paramBB)(3),(*paramBB)(4)));
     305             :       } else {
     306           0 :         AliError("Couldn't get BB parameters from OCDB, the old default values will be used instead");
     307             :       }
     308           8 :     } else {
     309           0 :       AliError("Couldn't get TPC parameters");
     310             :     }
     311           8 :   }
     312             :   
     313             : /*
     314             :   AliTPCcalibDB * calib = AliTPCcalibDB::Instance();
     315             :   
     316             :   //Get pid splines array
     317             :   TObjArray *arrSplines=calib->GetPidResponse();
     318             :   if (!arrSplines) return;
     319             :   AliTPCPIDResponse &tpcPID=esdPID->GetTPCResponse();
     320             :   tpcPID.SetUseDatabase(kTRUE);
     321             : 
     322             :   // check if parametrisations are already set.
     323             :   // since this is uniq for one run, we don't have to reload them
     324             :   if (tpcPID.GetResponseFunction(AliPID::kPion)) return;
     325             : 
     326             :   // get the default object
     327             :   TObject *defaultPID=arrSplines->At(AliPID::kUnknown);
     328             :   
     329             :   // loop over all particle species and set the response functions
     330             :   for (Int_t ispec=0; ispec<AliPID::kUnknown; ++ispec){
     331             :     TObject *pidSpline=arrSplines->At(ispec);
     332             :     if (!pidSpline) pidSpline=defaultPID;
     333             :     tpcPID.SetResponseFunction((AliPID::EParticleType)ispec,pidSpline);
     334             :   }
     335             :  */ 
     336           8 : }
     337             : 
     338             : //_____________________________________________________________________________
     339             : void AliTPCReconstructor::ParseOptions( AliTPCtracker* tracker ) const
     340             : {
     341             : // parse options from rec.C and set in clusterer and tracker
     342             :   
     343           4 :   TString option = GetOption();
     344             :   
     345             :   Int_t useHLTClusters = 3;
     346             : 
     347           4 :   if (option.Contains("use")) {
     348             :     
     349           0 :     AliInfo(Form("Overide TPC RecoParam with option %s",option.Data()));
     350             :     
     351           0 :     if (option.Contains("useRAW")) {
     352             :       useHLTClusters = 1;
     353           0 :       if (option.Contains("useRAWorHLT"))
     354           0 :         useHLTClusters = 2;
     355             :     }
     356           0 :     else if (option.Contains("useHLT")) {
     357             :       useHLTClusters = 3;
     358           0 :       if (option.Contains("useHLTorRAW"))
     359           0 :         useHLTClusters = 4;
     360             :     }
     361             :   }
     362             :   else {
     363           2 :     const AliTPCRecoParam* param = GetRecoParam();
     364           2 :     useHLTClusters = param->GetUseHLTClusters();
     365             :   }
     366             : 
     367           6 :   AliInfo(Form("Usage of HLT clusters in TPC reconstruction : %d", useHLTClusters));
     368             : 
     369           2 :   fClusterer->SetUseHLTClusters(useHLTClusters);
     370           2 :   tracker->SetUseHLTClusters(useHLTClusters);
     371             : 
     372             :   return;
     373           2 : }
     374             : 
     375             : //_____________________________________________________________________________
     376             : void AliTPCReconstructor::SetSystematicErrorCluster( TVectorD *vec ) 
     377             : { 
     378             :   // set clusters syst.errors which will override persistent data member from AliTPCRecoParam::fSystematicErrors
     379           0 :   fSystematicErrorClusters=vec;
     380           0 :   AliTPCRecoParam::SetSystematicErrorClusterCustom(vec);
     381           0 : }
     382             : 
     383             : //_____________________________________________________________________________
     384             : void AliTPCReconstructor::SetPrimaryDCACut( TVectorD *dcacut ) 
     385             : { 
     386             :   // set clusters syst.errors which will override persistent data member from AliTPCRecoParam::fSystematicErrors
     387           0 :   fgPrimaryDCACut=dcacut;
     388           0 :   AliTPCRecoParam::SetPrimaryDCACut(dcacut);
     389           0 : }

Generated by: LCOV version 1.11