CbmRoot
CbmRichHitProducer.cxx
Go to the documentation of this file.
1 
8 #include "CbmRichHitProducer.h"
9 
10 #include "CbmDigiManager.h"
11 #include "CbmEvent.h"
12 #include "CbmRichDetectorData.h" // for CbmRichPmtData, CbmRichPixelData
13 #include "CbmRichDigi.h"
14 #include "CbmRichDigiMapManager.h"
15 #include "CbmRichGeoManager.h"
16 #include "CbmRichHit.h"
17 #include "CbmRichPoint.h"
18 #include "FairLogger.h"
19 #include "TClonesArray.h"
20 
21 
22 #include <iostream>
23 
24 using namespace std;
25 
26 
28  : FairTask("CbmRichHitProducer")
29  , fDigiMan(nullptr)
30  , fRichHits(NULL)
31  , fCbmEvents(NULL)
32  , fEventNum(0)
33  , fRotationNeeded(true)
34  , fHitError(0.6 / sqrt(12.))
35 
36 {}
37 
39  FairRootManager* manager = FairRootManager::Instance();
40  manager->Write();
41 }
42 
44 
46  FairRootManager* manager = FairRootManager::Instance();
47 
48  fCbmEvents = dynamic_cast<TClonesArray*>(manager->GetObject("Event"));
49  if (fCbmEvents == nullptr) {
50  LOG(info) << ": CbmEvent NOT found \n \n \n";
51  } else {
52  LOG(info) << ": CbmEvent found \n \n \n";
53  }
54 
56  fDigiMan->Init();
58  Fatal("CbmRichHitProducer::Init", "No RichDigi array!");
59  }
60 
61  fRichHits = new TClonesArray("CbmRichHit");
62  manager->Register(
63  "RichHit", "RICH", fRichHits, IsOutputBranchPersistent("RichHit"));
64 
65  return kSUCCESS;
66 }
67 
68 void CbmRichHitProducer::Exec(Option_t* /*option*/) {
69  fEventNum++;
70  LOG(info) << "CbmRichHitProducer Event (or TimeSlice) " << fEventNum;
71 
72  fRichHits->Delete();
73 
74  // if CbmEvent does not exist then process standard event.
75  // if CbmEvent exists then proceed all events in time slice.
76  Int_t nUnits = (fCbmEvents != nullptr) ? fCbmEvents->GetEntriesFast() : 1;
77 
78  for (Int_t iUnit = 0; iUnit < nUnits; iUnit++) {
79  CbmEvent* event = (fCbmEvents != nullptr)
80  ? static_cast<CbmEvent*>(fCbmEvents->At(iUnit))
81  : nullptr;
82  ProcessData(event);
83  }
84 }
85 
87  if (event != NULL) {
88  LOG(info) << "CbmRichHitProducer CbmEvent mode. CbmEvent # "
89  << event->GetNumber();
90  Int_t nofDigis = event->GetNofData(ECbmDataType::kRichDigi);
91  LOG(info) << "nofDigis: " << nofDigis;
92 
93  for (Int_t iDigi = 0; iDigi < nofDigis; iDigi++) {
94  Int_t digiIndex = event->GetIndex(ECbmDataType::kRichDigi, iDigi);
95  ProcessDigi(event, digiIndex);
96  }
97 
98  } else {
99  for (Int_t iDigi = 0; iDigi < fDigiMan->GetNofDigis(ECbmModuleId::kRich);
100  iDigi++) {
101  ProcessDigi(event, iDigi);
102  }
103  }
104 }
105 
106 void CbmRichHitProducer::ProcessDigi(CbmEvent* event, Int_t digiIndex) {
107  const CbmRichDigi* digi = fDigiMan->Get<CbmRichDigi>(digiIndex);
108  if (digi == nullptr) return;
109  if (digi->GetAddress() < 0) return;
110  CbmRichPixelData* data =
112  digi->GetAddress());
113  TVector3 posPoint;
114  posPoint.SetXYZ(data->fX, data->fY, data->fZ);
115  TVector3 detPoint;
116 
118  &posPoint, &detPoint, !fRotationNeeded);
119  AddHit(event, detPoint, digi->GetTime(), digiIndex);
120 }
121 
122 
124  TVector3& posHit,
125  Double_t time,
126  Int_t index) {
127  Int_t nofHits = fRichHits->GetEntriesFast();
128  new ((*fRichHits)[nofHits]) CbmRichHit();
129  CbmRichHit* hit = (CbmRichHit*) fRichHits->At(nofHits);
130  hit->SetPosition(posHit);
131  hit->SetDx(fHitError);
132  hit->SetDy(fHitError);
133  hit->SetRefId(index);
134  hit->SetTime(time);
135 
136  if (event != NULL) { event->AddData(ECbmDataType::kRichHit, nofHits); }
137 }
138 
140 
141 
CbmRichPoint.h
CbmRichPixelData
Definition: CbmRichDetectorData.h:17
CbmRichHitProducer::ProcessDigi
void ProcessDigi(CbmEvent *event, Int_t digiIndex)
Definition: CbmRichHitProducer.cxx:106
ECbmDataType::kRichDigi
@ kRichDigi
CbmRichGeoManager::GetInstance
static CbmRichGeoManager & GetInstance()
Definition: CbmRichGeoManager.h:29
CbmRichDigi
Definition: CbmRichDigi.h:25
sqrt
friend F32vec4 sqrt(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:41
CbmDigiManager::Init
InitStatus Init()
Initialisation.
Definition: CbmDigiManager.cxx:71
CbmRichDigiMapManager.h
ECbmDataType::kRichHit
@ kRichHit
CbmDigiManager::GetNofDigis
static Int_t GetNofDigis(ECbmModuleId systemId)
Definition: CbmDigiManager.cxx:62
CbmRichHitProducer::fEventNum
Int_t fEventNum
Definition: CbmRichHitProducer.h:80
CbmRichHitProducer::Init
virtual InitStatus Init()
Inherited from FairTask.
Definition: CbmRichHitProducer.cxx:45
CbmDigiManager::IsPresent
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
Definition: CbmDigiManager.cxx:112
CbmDigiManager::Instance
static CbmDigiManager * Instance()
Static instance.
Definition: CbmDigiManager.h:93
CbmPixelHit::SetDy
void SetDy(Double_t dy)
Definition: CbmPixelHit.h:105
CbmHit::SetRefId
void SetRefId(Int_t refId)
Definition: CbmHit.h:81
CbmRichHitProducer::Exec
virtual void Exec(Option_t *option)
Inherited from FairTask.
Definition: CbmRichHitProducer.cxx:68
CbmRichGeoManager.h
CbmRichDigi.h
CbmEvent.h
CbmRichHitProducer::fDigiMan
CbmDigiManager * fDigiMan
Definition: CbmRichHitProducer.h:76
CbmRichHitProducer
Class for producing RICH hits directly from MCPoints.
Definition: CbmRichHitProducer.h:30
CbmRichDetectorData.h
CbmRichHitProducer::CbmRichHitProducer
CbmRichHitProducer()
Default constructor.
Definition: CbmRichHitProducer.cxx:27
CbmRichHitProducer::fRichHits
TClonesArray * fRichHits
Definition: CbmRichHitProducer.h:77
CbmRichDigi::GetTime
Double_t GetTime() const
Definition: CbmRichDigi.h:61
CbmRichHitProducer::fRotationNeeded
Bool_t fRotationNeeded
Definition: CbmRichHitProducer.h:82
CbmDigiManager::Get
const Digi * Get(Int_t index) const
Get a digi object.
Definition: CbmDigiManager.h:52
CbmRichPixelData::fY
Double_t fY
Definition: CbmRichDetectorData.h:21
CbmRichPixelData::fX
Double_t fX
Definition: CbmRichDetectorData.h:20
CbmRichHitProducer::fHitError
Double_t fHitError
Definition: CbmRichHitProducer.h:84
CbmRichGeoManager::RotatePoint
void RotatePoint(TVector3 *inPos, TVector3 *outPos, Bool_t noTilting=false)
Definition: CbmRichGeoManager.cxx:407
ECbmModuleId::kRich
@ kRich
Ring-Imaging Cherenkov Detector.
CbmRichHitProducer::fCbmEvents
TClonesArray * fCbmEvents
Definition: CbmRichHitProducer.h:78
CbmPixelHit::SetDx
void SetDx(Double_t dx)
Definition: CbmPixelHit.h:104
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmRichHitProducer::~CbmRichHitProducer
virtual ~CbmRichHitProducer()
Destructor.
Definition: CbmRichHitProducer.cxx:38
fDigiMan
CbmDigiManager * fDigiMan
Definition: CbmTofAnaTestbeam.cxx:88
CbmRichDigi::GetAddress
Int_t GetAddress() const
Definition: CbmRichDigi.h:37
CbmHit::SetTime
void SetTime(Double_t time)
Definition: CbmHit.h:84
CbmDigiManager.h
CbmRichHitProducer::SetParContainers
virtual void SetParContainers()
Inherited from FairTask.
Definition: CbmRichHitProducer.cxx:43
CbmRichHitProducer::Finish
virtual void Finish()
Inherited from FairTask.
Definition: CbmRichHitProducer.cxx:139
CbmRichHitProducer.h
Class for producing RICH hits directly from MCPoints.
CbmPixelHit::SetPosition
void SetPosition(const TVector3 &pos)
Sets position of the hit.
Definition: CbmPixelHit.cxx:72
CbmRichHitProducer::AddHit
void AddHit(CbmEvent *event, TVector3 &posHit, Double_t time, Int_t index)
Add hit to the output array (and) CbmEvent if it is not NULL.
Definition: CbmRichHitProducer.cxx:123
CbmEvent
Class characterising one event by a collection of links (indices) to data objects,...
Definition: CbmEvent.h:30
CbmRichHit.h
CbmRichDigiMapManager::GetInstance
static CbmRichDigiMapManager & GetInstance()
Definition: CbmRichDigiMapManager.h:29
CbmRichHitProducer::ProcessData
void ProcessData(CbmEvent *event)
Definition: CbmRichHitProducer.cxx:86
CbmRichHit
Definition: CbmRichHit.h:19
CbmRichDigiMapManager::GetPixelDataByAddress
CbmRichPixelData * GetPixelDataByAddress(Int_t address)
Definition: CbmRichDigiMapManager.cxx:267
CbmRichPixelData::fZ
Double_t fZ
Definition: CbmRichDetectorData.h:22