6 #include "TClonesArray.h"
8 #include "TGeoManager.h"
10 #include "FairRootManager.h"
14 #include "FairRuntimeDb.h"
15 #include "FairGeoNode.h"
16 #include "FairGeoNode.h"
17 #include "FairGeoVector.h"
18 #include "FairRunAna.h"
19 #include "FairEventHeader.h"
30 #if (ROOT_VERSION_CODE >= ROOT_VERSION(5,34,10))
31 #include "FairMultiLinkedData_Interface.h"
39 fDigiPixelMCInfo(kFALSE),
45 fChargeConverter(NULL),
58 fOverwriteParams(kFALSE),
59 fTimeOrderedDigi(kFALSE),
62 if(
fVerbose>0) Info(
"PndSdsHybridHitProducer",
"SDS Hybrid Digi Producer created, Parameters will be taken from RTDB");
69 fDigiPixelMCInfo(kFALSE),
75 fChargeConverter(NULL),
88 fOverwriteParams(kFALSE),
89 fTimeOrderedDigi(kFALSE),
92 if(
fVerbose>0) Info(
"PndSdsHybridHitProducer",
"%s created, Parameters will be taken from RTDB",name);
98 PndSdsTask(
"SDS Hybrid Digi Producer (PndSdsHybridHitProducer)"),
99 fDigiPixelMCInfo(kFALSE),
105 fChargeConverter(NULL),
106 fMCEventHeader(NULL),
110 fthreshold(threshold),
118 fOverwriteParams(kTRUE),
119 fTimeOrderedDigi(kFALSE),
123 if(
fVerbose>0) Info(
"PndSdsHybridHitProducer",
"SDS Hybrid Digi Producer created, Parameters will be overwritten in RTDB");
144 if( !
fDigiPar) Fatal(
"SetParContainers",
"No digitiztion parameters specified.");
145 if(
fVerbose>1) Info(
"SetParContainers",
"done.");
160 FairRun* ana = FairRun::Instance();
161 FairRootManager* ioman = FairRootManager::Instance();
164 std::cout <<
"-E- PndSdsHybridHitProducer::Init: "
165 <<
"RootManager not instantiated!" << std::endl;
173 std::cout <<
"-W- PndSdsHybridHitProducer::Init: "
174 <<
"No SDSPoint array!" << std::endl;
197 fDigiPar->setInputVersion(ana->GetRunId(),1);
199 if(
fVerbose>0) Info(
"Init",
"RTDB updated");
219 if(
fVerbose>3) Info(
"Exec",
"Start");
225 Double_t EventTime = FairRootManager::Instance()->GetEventTime();
229 std::cout << std::endl;
230 std::cout <<
"-I- PndSdsHybridHitProducer::Exec EventTime: " << EventTime <<
" event: " << FairRootManager::Instance()->GetEntryNr() << std::endl;
247 if(
fVerbose>3) Info(
"Exec",
"Begin loop for %i points",nPoints);
248 for (Int_t iPoint = 0; iPoint < nPoints; iPoint++)
252 std::cout<<
"No Point!" << std::endl;
256 std::cout <<
"****Global Point: " << std::endl;
259 FairGeoVector posInL, posOutL;
263 std::cout <<
"posOutL: " << std::endl;
264 std::cout << posInL.X() <<
" " << posInL.Y() <<
" " << posInL.Z() << std::endl;
265 std::cout << posOutL.X() <<
" " << posOutL.Y() <<
" " << posOutL.Z() << std::endl;
269 FairGeoVector meanPosL = posInL + posOutL;
272 std::cout <<
"Energy: " << point->GetEnergyLoss() << std::endl;
275 std::cout <<
"Time since Event started: " << point->GetTime() << std::endl;
277 std::vector<PndSdsPixel> myFePixels;
284 std::vector<PndSdsPixel> myPixels;
289 myPixels = PixelCalc.
GetPixels (posInL.getX(), posInL.getY(),
290 posOutL.getX(), posOutL.getY(),
291 point->GetEnergyLoss());
296 myPixels = PixelCalc.
GetPixels (posInL.getX(), posInL.getY(),
297 posOutL.getX(), posOutL.getY(),
298 point->GetEnergyLoss());
300 if (myPixels.size() == 0){
301 if (
fVerbose > 1) std::cout <<
"Deposited charge below threshold" << std::endl;
304 if (
fVerbose > 1) std::cout <<
"SensorPixels: " << std::endl;
305 for(UInt_t
i = 0;
i < myPixels.size();
i++)
308 if (
fVerbose > 1) std::cout << myPixels[
i] << std::endl;
314 std::cout <<
"FePixels: " << myFePixels.size() << std::endl;
315 for(UInt_t
i = 0;
i < myFePixels.size();
i++){
316 std::cout << myFePixels[
i] << std::endl;
329 for (
unsigned int iPix = 0; iPix <
fPixelList.size(); iPix++)
359 std::cout <<
"TimeStampCalc: EventTime: " << EventTime <<
" ToF " << point->GetTime() <<
" charge " << smearedChargeInE <<
" TW: " << timewalk <<
" CorrectedTS: " << correctedTimeStamp << std::endl;
360 std::cout <<
"Diff TimeStamp - EventTime " << correctedTimeStamp - EventTime << std::endl;
364 smearedCharge, correctedTimeStamp);
367 tempPixel->ResetLinks();
368 std::vector<int> indices =
fPixelList[iPix].GetMCIndex();
369 FairEventHeader* evtHeader = (FairEventHeader*)FairRootManager::Instance()->GetObject(
"EventHeader.");
370 for (
int i = 0;
i < (int)indices.size();
i++){
371 tempPixel->SetInsertHistory(
true);
372 tempPixel->AddLink(FairLink(evtHeader->GetInputFileId(), evtHeader->GetMCEntryNumber(),
fInBranchId, indices[
i]));
374 tempPixel->AddLinks(*(myPoint->GetPointerToLinks()));
376 tempPixel->AddLink(FairLink(-1,
fEventNr,
"EventHeader.", -1));
380 std::cout <<
"PixelDigi: " << (tempPixel) << std::endl;
381 #if (ROOT_VERSION_CODE >= ROOT_VERSION(5,34,10))
382 std::cout <<
"Links in Digi: " << (FairMultiLinkedData_Interface*)(tempPixel) << std::endl;
384 std::cout <<
"Links in Digi: " << (FairMultiLinkedData)(*tempPixel) << std::endl;
399 std::cout <<
"-I- PndSdsHybridHitProducer: " << nPoints <<
" PndSdsMCPoints, "
400 <<
fPixelHits <<
" Digi created." <<
" " << iFePixel
401 <<
" (event "<<
fEventNr <<
")"<< std::endl;
406 if(
fVerbose>3) Info(
"Exec",
"Loop MC points");
413 std::cout <<
"GetLocalHitPoints" << std::endl;
421 posIn[0] = myPoint->GetX();
422 posIn[1] = myPoint->GetY();
423 posIn[2] = myPoint->GetZ();
425 posOut[0] = myPoint->
GetXOut();
426 posOut[1] = myPoint->
GetYOut();
427 posOut[2] = myPoint->
GetZOut();
430 for (Int_t
i = 0;
i < 3;
i++)
431 std::cout <<
"posIn "<<
i <<
": " << posIn[
i] << std::endl;
436 trans.MasterToLocal(posIn, posInLocal);
437 trans.MasterToLocal(posOut, posOutLocal);
440 for (Int_t
i = 0;
i < 3;
i++){
441 std::cout <<
"posInLocal "<<
i <<
": " << posInLocal[
i] << std::endl;
442 std::cout <<
"posOutLocal "<<
i <<
": " << posOutLocal[
i] << std::endl;
453 std::cout <<
"SensorDimension for: " << myPoint->
GetSensorID() << std::endl;
454 std::cout << offset.X() <<
" " << offset.Y() <<
" " << offset.Z() << std::endl;
457 posInLocal[0] += offset.x();
458 posInLocal[1] += offset.y();
461 posOutLocal[0] += offset.x();
462 posOutLocal[1] += offset.y();
466 myHitIn.setVector(posInLocal);
467 myHitOut.setVector(posOutLocal);
475 TGeoHMatrix* transMat =
gGeoManager->GetCurrentMatrix();
485 TGeoVolume* actVolume =
gGeoManager->GetCurrentVolume();
486 TGeoBBox* actBox = (TGeoBBox*)(actVolume->GetShape());
488 result.SetX(actBox->GetDX());
489 result.SetY(actBox->GetDY());
490 result.SetZ(actBox->GetDZ());
499 for (UInt_t
i = 0;
i < hits->size();
i++){
502 if (
fVerbose > 1) std::cout <<
"Size of fPixelList: " <<
fPixelList.size() << std::endl;
508 if(
fVerbose > 1) std::cout <<
"Adding Hits to PixelList with mcIndex: " << mcIndex << std::endl;
518 <<
" FE/col/row " << hit.
GetFE()
520 <<
"/" << hit.
GetRow() <<
" already hit!"<< std::endl;
virtual InitStatus ReInit()
std::vector< PndSdsPixel > GetPixels(Double_t inx, Double_t iny, Double_t outx, Double_t outy, Double_t energy)
Main function to calculate the vector<PndSdsPixel> of fired pixel.
Double_t GetXPitch() const
PndSdsChargeConversion * fChargeConverter
virtual Double_t GetTimeStep()
Int_t GetSensorID() const
virtual void SetParContainers()
void SetXPitch(Double_t x)
TClonesArray * fPointArray
void SetPersistency(Bool_t val=kTRUE)
virtual Double_t GetTimeStamp(Double_t tof, Double_t charge, Double_t MCEventTime)=0
absolute time stamp of a hit in ns (clock is taken into account)
TClonesArray * fPixelMCArray
TGeoManager * gGeoManager
Int_t GetSensorID() const
PndSdsHybridHitProducer()
Double_t GetQCloudSigma() const
TString GetPath(Int_t shortID)
for a given shortID the path is returned
Bool_t fTimeOrderedDigi
set to kTRUE to use the time ordering of the output data.
virtual Double_t DigiValueToCharge(Double_t digi)=0
Converts a given digitized charge into charge in electrons.
Double_t GetNoise() const
void SetThreshold(Double_t x)
void SetNoise(Double_t x)
virtual ~PndSdsHybridHitProducer()
TVector3 GetSensorDimensions(Int_t sensorID)
virtual void Exec(Option_t *opt)
virtual void FinishTask()
std::vector< PndSdsPixel > GetPixels(Double_t inx, Double_t iny, Double_t outx, Double_t outy, Double_t energy)
Main function to calculate the vector<PndSdsPixel> of fired pixel.
virtual InitStatus Init()
void AddHits(std::vector< PndSdsPixel > *hitList, int mcIndex)
virtual void SetParContainers()
virtual void SetBranchNames()=0
Double_t GetYPitch() const
virtual void EndExecute()
void GetLocalHitPoints(PndSdsMCPoint *myPoint, FairGeoVector &myHitIn, FairGeoVector &myHitOut)
static PndGeoHandling * Instance()
std::vector< PndSdsPixel > fPixelList
virtual void StartExecute()
void AddHit(PndSdsPixel &hit, int mcIndex)
virtual Double_t ChargeToDigiValue(Double_t Charge)=0
Converts a given charge in electrons into the electronics answer e.g. ToT [ns].
virtual void FinishEvent()
Double_t GetCharge() const
virtual void Print(std::ostream &out=std::cout) const
PndSdsDigiPixelWriteoutBuffer * fDataBuffer
Calculates the pixels (digis) fired from a particle hitting the sensor.
Data class to store the digi output of a pixel module.
virtual Double_t GetTimeWalk(Double_t)
PndSdsPixelDigiPar * fDigiPar
void SetYPitch(Double_t x)
Class to calculate the position of digis on a front-end from the digis on a sensor.
TGeoHMatrix GetTransformation(Int_t sensorID)
std::vector< PndSdsPixel > CalcFEHits(const std::vector< PndSdsPixel > &sensor_hits)
Main function to calculate front-end hits.
virtual void Print(const Option_t *opt=0) const
Double_t GetThreshold() const