FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairTestDetectorTimeRecoTask.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
9 
10 #include "FairLogger.h"
11 #include "FairRootManager.h" // for FairRootManager
12 #include "FairRunAna.h" // for FairRunAna
13 #include "FairTSBufferFunctional.h" // for StopTime
14 #include "FairTestDetectorDigi.h" // for FairTestDetectorDigi
15 #include "FairTestDetectorHit.h" // for FairTestDetectorHit
16 
17 #include <TClonesArray.h> // for TClonesArray
18 #include <TMath.h> // for Sqrt
19 #include <TVector3.h> // for TVector3
20 
22  : FairTask()
23  , fDigiArray(nullptr)
24  , fHitArray(nullptr)
25  , fTime(0.)
26  , fFunctor(nullptr)
27 {}
28 
30  : FairTask()
31  , fDigiArray(nullptr)
32  , fHitArray(nullptr)
33  , fTime(0.)
34  , fFunctor(nullptr)
35 {
36  fVerbose = verbose;
37 }
38 
40 
42 {
44  if (!ioman) {
45  LOG(error) << "FairTestDetectorTimeRecoTask::Init: RootManager not instantiated!";
46  return kFATAL;
47  }
48 
49  fDigiArray = static_cast<TClonesArray*>(ioman->GetObject("FairTestDetectorSortedDigi"));
50  if (!fDigiArray) {
51  LOG(warn) << "FairTestDetectorTimeRecoTask::Init: No Point array!";
52  return kERROR;
53  }
54 
55  fFunctor = new StopTime();
56 
57  // Create and register output array
58  fHitArray = new TClonesArray("FairTestDetectorHit");
59  ioman->Register("FairTestDetectorHit", "FairTestDetector", fHitArray, kTRUE);
60 
61  return kSUCCESS;
62 }
63 
64 void FairTestDetectorTimeRecoTask::Exec(Option_t* /*opt*/)
65 {
66  fHitArray->Delete();
67 
68  fTime += 200;
69  if (FairRunAna::Instance()->IsTimeStamp()) {
70  fDigiArray = FairRootManager::Instance()->GetData("FairTestDetectorSortedDigi", fFunctor, fTime);
71  // LOG(info) << "EventTime: " << FairRootManager::Instance()->GetEntryNr() << " " <<
72  // FairRootManager::Instance()->GetEventTime();
73  }
74 
75  // fill the map
76  // LOG(info) << "NDigis: " << fDigiArray->GetEntries();
77  for (int ipnt = 0; ipnt < fDigiArray->GetEntries(); ipnt++) {
78  FairTestDetectorDigi* digi = static_cast<FairTestDetectorDigi*>(fDigiArray->At(ipnt));
79  if (!digi) {
80  LOG(warn) << "No digi!";
81  continue;
82  }
83 
84  // Double_t timestamp = digi->GetTimeStamp();
85  TVector3 pos(digi->GetX() + 0.5, digi->GetY() + 0.5, digi->GetZ() + 0.5);
86  TVector3 dpos(1 / TMath::Sqrt(12), 1 / TMath::Sqrt(12), 1 / TMath::Sqrt(12));
87 
88  FairTestDetectorHit* hit = new ((*fHitArray)[ipnt]) FairTestDetectorHit(-1, -1, pos, dpos);
89  hit->SetTimeStamp(digi->GetTimeStamp());
91  hit->AddLink(digi->GetEntryNr());
92  hit->AddInterfaceData(digi);
93 
94  fHitArray->Sort();
95  }
96 
97  fDigiArray->Delete();
98 }
99 
InitStatus
Definition: FairTask.h:33
static FairRootManager * Instance()
ClassImp(FairEventBuilder)
TObject * GetObject(const char *BrName)
TClonesArray * GetData(TString branchName, BinaryFunctor *function, Double_t parameter)
Int_t fVerbose
Definition: FairTask.h:100
Double_t GetTimeStampError() const
Definition: FairTimeStamp.h:45
static FairRunAna * Instance()
Definition: FairRunAna.cxx:61
Double_t GetTimeStamp() const
Definition: FairTimeStamp.h:44
void SetTimeStamp(Double_t t)
Definition: FairTimeStamp.h:47
void Register(const char *name, const char *Foldername, TNamed *obj, Bool_t toFile)
void SetTimeStampError(Double_t t)
Definition: FairTimeStamp.h:48
void AddInterfaceData(FairMultiLinkedData_Interface *data)