24 #include <TClonesArray.h>
26 #include <TMathBase.h>
31 :
FairTask(
"Missallign Hit Producer for the TutorialDet")
32 , fPointArray(nullptr)
43 , fDoMisalignment(kFALSE)
49 LOG(info) <<
"Set tutdet missallign parameters";
81 LOG(fatal) <<
"RootManager not instantised!";
86 fPointArray =
static_cast<TClonesArray*
>(ioman->
GetObject(
"TutorialDetPoint"));
88 LOG(fatal) <<
"No TutorialDetPoint array!";
93 fHitArray =
new TClonesArray(
"FairTutorialDet4Hit");
94 ioman->
Register(
"TutorialDetHit",
"TutorialDet", fHitArray, kTRUE);
96 LOG(info) <<
"HitProducerIdealMissallign: Initialisation successfull";
106 if (isGlobalCoordinateSystem) {
107 LOG(fatal) <<
"Task can only work with local coordinates.";
135 Int_t nPoints = fPointArray->GetEntriesFast();
136 for (Int_t iPoint = 0; iPoint < nPoints; iPoint++) {
148 if (fDoMisalignment) {
150 Float_t cosAlpha = TMath::Cos(fRotZ.At(detID));
151 Float_t sinAlpha = TMath::Sin(fRotZ.At(detID));
154 x = (point->
GetX() * cosAlpha + point->
GetY() * sinAlpha) - fShiftX.At(detID);
155 y = (-point->
GetX() * sinAlpha + point->
GetY() * cosAlpha) - fShiftY.At(detID);
158 LOG(debug) <<
"Pos before misalignment: " << point->
GetX() <<
", " << point->
GetY() <<
", "
160 LOG(debug) <<
"Pos after misalignment: " << x <<
", " << y <<
", " << z;
162 x = x + GetHitErr(0.1);
163 y = y + GetHitErr(0.1);
165 LOG(debug2) <<
"Missallign hit by " << fShiftX.At(detID) <<
" cm in x- and " << fShiftY.At(detID)
166 <<
" cm in y-direction.";
173 dpos.SetXYZ(dx, dx, 0.);
182 LOG(info) <<
"Position: " << x <<
", " << y <<
", " << z;
184 Double_t local[3] = {x, y, z};
189 x = global[0] + GetHitErr(0.1);
190 y = global[1] + GetHitErr(0.1);
193 LOG(info) <<
"Position: " << x <<
", " << y <<
", " << z;
200 dpos.SetXYZ(dx, dx, 0.);
206 LOG(debug) <<
"Create " << nHits <<
" TutorialDetHits out of " << nPoints <<
" TutorilaDetPoints created.";
209 Double_t FairTutorialDet4HitProducerIdealMisalign::GetHitErr(Double_t sigma)
211 Double_t err = gRandom->Gaus(0, sigma);
212 return (TMath::Abs(err) < 3 * sigma) ? err : (err > 0) ? 3 * sigma : -3 * sigma;
list of container factories
virtual InitStatus Init()
static FairRootManager * Instance()
ClassImp(FairEventBuilder)
TObject * GetObject(const char *BrName)
FairParSet * getContainer(const Text_t *)
virtual InitStatus ReInit()
static FairRunAna * Instance()
Bool_t IsGlobalCoordinateSystem()
FairRuntimeDb * GetRuntimeDb(void)
void Register(const char *name, const char *Foldername, TNamed *obj, Bool_t toFile)
FairTutorialDet4HitProducerIdealMisalign()
virtual void SetParContainers()
void LocalToGlobal(Double_t *local, Double_t *global, Int_t detID)
Int_t GetDetectorID() const
virtual void Exec(Option_t *opt)