CbmRoot
CbmMuchHitProducerIdeal.cxx
Go to the documentation of this file.
1 
8 #include "CbmMuchGeoScheme.h"
9 #include "CbmMuchPixelHit.h"
10 #include "CbmMuchPoint.h"
11 #include "FairLogger.h"
12 #include "FairRootManager.h"
13 
14 #include "TClonesArray.h"
15 #include "TFile.h"
16 #include "TRandom.h"
17 #include "TVector3.h"
18 
19 #include <cmath>
20 
21 using std::fabs;
22 
24  Int_t Id)
25  : FairTask("CbmMuchHitProducerIdeal")
26  , fMuchPoints(NULL)
27  , fMuchPixelHits(NULL)
28  , fSigmaX(0.01)
29  , fSigmaY(0.01)
30  , fSigmaZ(0.)
31  , fId(Id)
32  , fDigiFile(digiFileName)
33  , fGeoScheme(NULL) {}
34 
36 
38  FairRootManager* ioman = FairRootManager::Instance();
39  fMuchPoints = static_cast<TClonesArray*>(ioman->GetObject("MuchPoint"));
40  fMuchPixelHits = new TClonesArray("CbmMuchPixelHit", 100);
41  ioman->Register("MuchPixelHit",
42  "MUCH",
44  IsOutputBranchPersistent("MuchPixelHit"));
45 
46  // Initialize GeoScheme
48  TFile* oldfile = gFile;
49  TFile* file = new TFile(fDigiFile);
50  TObjArray* stations = (TObjArray*) file->Get("stations");
51  file->Close();
52  file->Delete();
53  gFile = oldfile;
54  fGeoScheme->Init(stations, fId);
55  return kSUCCESS;
56 }
57 
59  static Int_t eventNo = 0;
60  fMuchPixelHits->Clear();
61  Int_t iHit = 0;
62  Int_t nofMuchPoints = fMuchPoints->GetEntriesFast();
63  for (Int_t iPoint = 0; iPoint < nofMuchPoints; iPoint++) {
64  const CbmMuchPoint* point =
65  static_cast<const CbmMuchPoint*>(fMuchPoints->At(iPoint));
66 
67  // Smear position
68  Double_t dX = gRandom->Gaus(0, fSigmaX);
69  Double_t dY = gRandom->Gaus(0, fSigmaY);
70  Double_t dZ = gRandom->Gaus(0, fSigmaZ);
71 
72  dX = (fabs(dX) < 3 * fSigmaX) ? dX : (dX > 0) ? 3 * fSigmaX : -3 * fSigmaX;
73  dY = (fabs(dY) < 3 * fSigmaY) ? dY : (dY > 0) ? 3 * fSigmaY : -3 * fSigmaY;
74  dZ = (fabs(dZ) < 3 * fSigmaZ) ? dZ : (dZ > 0) ? 3 * fSigmaZ : -3 * fSigmaZ;
75 
76  TVector3 hitPos(
77  point->GetXIn() + dX, point->GetYIn() + dY, point->GetZIn() + dZ);
78  TVector3 hitPosErr(fSigmaX, fSigmaY, fSigmaZ);
79 
80  Int_t address = point->GetDetectorID();
81  Int_t planeId = fGeoScheme->GetLayerSideNr(address);
82 
83  new ((*fMuchPixelHits)[iHit++])
84  CbmMuchPixelHit(address, hitPos, hitPosErr, 0, iPoint, planeId);
85  }
86  eventNo++;
87  LOG(info) << "CbmMuchHitProducerIdeal::Exec: eventNo=" << eventNo
88  << " nofPoints=" << fMuchPoints->GetEntries()
89  << " nofHits=" << fMuchPixelHits->GetEntries();
90 }
91 
93 
CbmMuchHitProducerIdeal::fSigmaZ
Double_t fSigmaZ
Definition: CbmMuchHitProducerIdeal.h:37
CbmMuchHitProducerIdeal::~CbmMuchHitProducerIdeal
virtual ~CbmMuchHitProducerIdeal()
Definition: CbmMuchHitProducerIdeal.cxx:35
CbmMuchHitProducerIdeal::fGeoScheme
CbmMuchGeoScheme * fGeoScheme
Definition: CbmMuchHitProducerIdeal.h:42
CbmMuchHitProducerIdeal::fMuchPoints
TClonesArray * fMuchPoints
Definition: CbmMuchHitProducerIdeal.h:32
CbmMuchPoint
Definition: CbmMuchPoint.h:21
CbmMuchHitProducerIdeal
Definition: CbmMuchHitProducerIdeal.h:17
CbmMuchHitProducerIdeal::Init
InitStatus Init()
Definition: CbmMuchHitProducerIdeal.cxx:37
CbmMuchHitProducerIdeal::Finish
void Finish()
Definition: CbmMuchHitProducerIdeal.cxx:92
CbmMuchGeoScheme::Init
void Init(TObjArray *stations, Int_t flag)
Definition: CbmMuchGeoScheme.cxx:121
CbmMuchHitProducerIdeal::fId
Int_t fId
Definition: CbmMuchHitProducerIdeal.h:39
CbmMuchPoint.h
CbmMuchGeoScheme::Instance
static CbmMuchGeoScheme * Instance()
Definition: CbmMuchGeoScheme.cxx:113
CbmMuchHitProducerIdeal::Exec
void Exec(Option_t *option)
Definition: CbmMuchHitProducerIdeal.cxx:58
CbmMuchPoint::GetZIn
Double_t GetZIn() const
Definition: CbmMuchPoint.h:72
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmMuchHitProducerIdeal::fSigmaY
Double_t fSigmaY
Definition: CbmMuchHitProducerIdeal.h:36
CbmMuchHitProducerIdeal::CbmMuchHitProducerIdeal
CbmMuchHitProducerIdeal(const char *digiFileName, Int_t Id)
Definition: CbmMuchHitProducerIdeal.cxx:23
CbmMuchPoint::GetYIn
Double_t GetYIn() const
Definition: CbmMuchPoint.h:71
fabs
friend F32vec4 fabs(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:60
CbmMuchPixelHit.h
Class for pixel hits in MUCH detector.
CbmMuchPoint::GetXIn
Double_t GetXIn() const
Definition: CbmMuchPoint.h:70
CbmMuchPixelHit
Definition: CbmMuchPixelHit.h:17
CbmMuchHitProducerIdeal::fMuchPixelHits
TClonesArray * fMuchPixelHits
Definition: CbmMuchHitProducerIdeal.h:33
CbmMuchGeoScheme.h
CbmMuchHitProducerIdeal.h
Ideal hit producer for MUon CHambers detector.
CbmMuchHitProducerIdeal::fDigiFile
TString fDigiFile
Definition: CbmMuchHitProducerIdeal.h:41
CbmMuchHitProducerIdeal::fSigmaX
Double_t fSigmaX
Definition: CbmMuchHitProducerIdeal.h:35
CbmMuchGeoScheme::GetLayerSideNr
Int_t GetLayerSideNr(Int_t detId) const
Definition: CbmMuchGeoScheme.cxx:403