28#include "FairRuntimeDb.h"
30#include "TClonesArray.h"
34#include "FairEventHeader.h"
35#include "FairMCEventHeader.h"
36#include "FairRunAna.h"
37#include "FairRunSim.h"
54using std::setprecision;
68 , fDiffusionCoefficient()
78 , fCurrentTotalCharge()
79 , fCurrentParticleMass()
80 , fCurrentParticleMomentum()
81 , fCurrentParticlePdg()
90 , fLandauRandom(new TRandom3())
108 , fPixelChargeShort()
109 , fPixelScanAccelerator()
135 LOG(debug) <<
"Starting CbmMvdSensorDigitizerTBTask::CbmMvdSensorDigitizerTBTask() ";
198 if (!sensorData) {
return kERROR; }
229 Int_t nInputs = inputStream->GetEntriesFast();
230 while (nInputs > i) {
259 for (Int_t iPoint = 0; iPoint <
fInputPoints->GetEntriesFast(); iPoint++) {
264 LOG(warning) <<
GetName() <<
":: Exec:";
265 LOG(warning <<
" -received bad MC-Point. Ignored.";
269 LOG(warning) << GetName() <<
":: Exec:";
270 LOG(warning) <<
" -received bad MC-Point which doesn't belong here. Ignored.";
275 if (TMath::Abs(point->
GetZOut() - point->GetZ()) < 0.9 *
fEpiTh) {
276 LOG(debug) <<
"hit not on chip with thickness " << 0.9 * 2 * fSensor->GetDZ();
277 LOG(debug) <<
"hit not on chip with length " << TMath::Abs(point->GetZOut() - point->GetZ());
281 if (point->
GetPdgCode() > 100000) { continue; }
286 for (Int_t i = 0; i <
fPixelCharge->GetEntriesFast(); ++i) {
309 std::pair<Int_t, Int_t> thispoint = std::make_pair(pixel->
GetX(), pixel->
GetY());
310 std::pair<std::pair<Int_t, Int_t>, Double_t> thisTimePoint = std::make_pair(thispoint, pixel->
GetTime());
337 eventNr = FairRootManager::Instance()->GetEntryNr();
340 if (FairRunAna::Instance()) {
341 FairEventHeader*
event = FairRunAna::Instance()->GetEventHeader();
342 inputNr =
event->GetInputFileId();
343 eventTime =
event->GetEventTime();
348 if (!FairRunSim::Instance()) LOG(fatal) <<
GetName() <<
": neither SIM nor ANA run.";
363 Double_t globalPositionIn[3] = {point->GetX(), point->GetY(), point->GetZ()};
366 Double_t localPositionIn[3] = {0, 0, 0};
368 Double_t localPositionOut[3] = {0, 0, 0};
373 Int_t pixelX, pixelY;
378 Double_t entryX = localPositionIn[0];
379 Double_t exitX = localPositionOut[0];
380 Double_t entryY = localPositionIn[1];
381 Double_t exitY = localPositionOut[1];
382 Double_t entryZ = localPositionIn[2];
383 Double_t exitZ = localPositionOut[2];
404 Double_t entryZepi = -
fEpiTh / 2;
405 Double_t exitZepi =
fEpiTh / 2;
408 TVector3 a(entryX, entryY, entryZ);
409 TVector3 b(exitX, exitY, exitZ);
417 Double_t scale1 = (entryZepi - entryZ) / (exitZ - entryZ);
418 Double_t scale2 = (exitZepi - entryZ) / (exitZ - entryZ);
424 TVector3 entryEpiCoord;
425 TVector3 exitEpiCoord;
427 entryEpiCoord = d + a;
428 exitEpiCoord = e + a;
432 Double_t entryXepi = entryEpiCoord.X();
433 Double_t entryYepi = entryEpiCoord.Y();
434 entryZepi = entryEpiCoord.Z();
437 Double_t exitXepi = exitEpiCoord.X();
438 Double_t exitYepi = exitEpiCoord.Y();
439 exitZepi = exitEpiCoord.Z();
442 Double_t lx = -(entryXepi - exitXepi);
443 Double_t ly = -(entryYepi - exitYepi);
444 Double_t lz = -(entryZepi - exitZepi);
450 Double_t rawLength =
sqrt(lx * lx + ly * ly + lz * lz);
451 Double_t trackLength = 0;
453 if (rawLength < 1.0e+3) { trackLength = rawLength; }
456 LOG(warning) <<
GetName() <<
" : rawlength > 1.0e+3 : " << rawLength;
457 trackLength = 1.0e+3;
471 dEmean = dEmean * ((Double_t) trackLength /
fEpiTh);
491 LOG(warning) <<
GetName() <<
" Length of track in detector (z-direction) is 0!!!";
495 Double_t
x = 0,
y = 0, z = 0;
497 Double_t xDebug = 0, yDebug = 0, zDebug = 0;
498 Float_t totalSegmentCharge = 0;
517 sPoint->
eloss = dEmean;
526 totalSegmentCharge = totalSegmentCharge + charge;
538 pair<Int_t, Int_t> thispoint;
539 pair<pair<Int_t, Int_t>, Double_t> thisTimePoint;
541 Double_t xCentre, yCentre, sigmaX, sigmaY, xLo, xUp, yLo, yUp;
557 Fatal(
"-E- CbmMvdDigitizer: ",
"fNumberOfSegments < 2, this makes no sense, check parameters.");
565 Int_t ixLo, ixUp, iyLo, iyUp;
568 Double_t minCoord[] = {xLo, yLo};
569 Double_t maxCoord[] = {xUp, yUp};
576 if (lowerXArray[0] < 0) lowerXArray[0] = 0;
577 if (lowerYArray[0] < 0) lowerYArray[0] = 0;
581 ixLo = lowerXArray[0];
582 iyLo = lowerYArray[0];
583 ixUp = upperXArray[0];
584 iyUp = upperYArray[0];
601 if (lowerXArray[i] < 0) lowerXArray[i] = 0;
602 if (lowerYArray[i] < 0) lowerYArray[i] = 0;
607 if (ixLo > lowerXArray[i]) { ixLo = lowerXArray[i]; }
608 if (ixUp < upperXArray[i]) { ixUp = upperXArray[i]; }
609 if (iyLo > lowerYArray[i]) { iyLo = lowerYArray[i]; }
610 if (iyUp < upperYArray[i]) { iyUp = upperYArray[i]; }
616 for (ix = ixLo; ix < ixUp + 1; ix++) {
617 for (iy = iyLo; iy < iyUp + 1; iy++) {
622 if (ix < lowerXArray[i] || iy < lowerYArray[i] || ix > upperXArray[i] || iy > upperYArray[i]) {
continue; }
633 Float_t maxCount = TMath::Max(1.e-10, (((Current[0] - xCentre) * (Current[0] - xCentre))
634 + ((Current[1] - yCentre) * (Current[1] - yCentre)))
638 Float_t totCharge = (numerator / maxCount +
fPar2);
640 if (totCharge < 1) {
continue; }
642 thispoint = std::make_pair(ix, iy);
643 thisTimePoint = std::make_pair(thispoint, ROTime);
646 pixel =
new ((*fPixelCharge)[
fPixelCharge->GetEntriesFast()])
648 (point->GetX() + point->
GetXOut()) / 2, (point->GetY() + point->
GetXOut()) / 2, ROTime);
664 std::vector<CbmMvdPixelCharge*>::size_type vectorSize =
fPixelChargeShort.size();
666 for (ULong64_t f = 0; f < vectorSize; f++) {
671 point->GetTrackID());
674 LOG(warning) <<
"Warning working on broken pixel ";
678 delete[] lowerXArray;
679 delete[] upperXArray;
680 delete[] lowerYArray;
681 delete[] upperYArray;
694 fDigis =
new TClonesArray(
"CbmMvdDigi", 10000);
695 fDigiMatch =
new TClonesArray(
"CbmMatch", 10000);
700 fPixelCharge =
new TClonesArray(
"CbmMvdPixelCharge", 100000);
703 Fatal(
GetName(),
"Fatal error: Init(CbmMvdSensor*) called without valid pointer, "
704 "don't know how to proceed.");
ClassImp(CbmMvdSensorDigitizerTBTask)
friend fvec sqrt(const fvec &a)
void AddLink(const CbmLink &newLink)
Short_t GetNContributors()
std::vector< Double_t > & GetTime()
void DigestCharge(Float_t pointX, Float_t pointY, Double_t time, Int_t PointId, Int_t trackId, Int_t inputNr, Int_t eventNr)
void AddCharge(Float_t charge)
std::vector< Int_t > & GetPointID()
std::vector< Int_t > & GetTrackID()
std::vector< Float_t > & GetPointWeight()
std::vector< Float_t > & GetCharge()
int32_t GetPointId() const
int32_t GetStationNr() const
int32_t GetPdgCode() const
virtual Double_t GetEpiThickness()
virtual Double_t GetLorentzPar1()
virtual Int_t GetNPixelsX()
virtual Double_t GetPixelPitchX()
virtual Double_t GetLandauMPV()
virtual Int_t GetNPixelsY()
virtual Double_t GetPixelPitchY()
virtual Double_t GetLandauSigma()
virtual Double_t GetChargeThreshold()
virtual Double_t GetLandauGain()
virtual Double_t GetLorentzPar0()
virtual Double_t GetLorentzPar2()
Double_t fCurrentTotalCharge
void SetInputArray(TClonesArray *inputStream)
Double_t fElectronsPerKeV
TClonesArray * fDigiMatch
SignalPointVec fSignalPoints
void ProduceIonisationPoints(CbmMvdPoint *point)
CbmMvdSensorDigitizerTBTask()
void ProducePixelCharge(CbmMvdPoint *point)
TClonesArray * fPixelCharge
TClonesArray * fInputPoints
Double_t fCurrentParticleMomentum
Double_t fCurrentParticleMass
virtual void InitTask(CbmMvdSensor *mySensor)
virtual ~CbmMvdSensorDigitizerTBTask()
std::map< std::pair< std::pair< Int_t, Int_t >, Double_t >, CbmMvdPixelCharge * >::iterator fChargeMapIt
Double_t fDiffusionCoefficient
std::map< std::pair< std::pair< Int_t, Int_t >, Double_t >, CbmMvdPixelCharge * > fChargeMap
void GetEventInfo(Int_t &inputNr, Int_t &eventNr, Double_t &eventTime)
std::vector< CbmMvdPixelCharge * > fPixelChargeShort
TObjArray * fPixelScanAccelerator
virtual void ReInit(CbmMvdSensor *mySensor)
InitStatus ReadSensorInformation()
virtual TClonesArray * GetOutputArray()
CbmMvdSensorPlugin * fPreviousPlugin
virtual const char * GetName() const
TClonesArray * fOutputBuffer
void TopToLocal(Double_t *lab, Double_t *local)
Int_t GetSensorNr() const
void PixelToLocal(Int_t pixelNumberX, Int_t pixelNumberY, Double_t *local)
void LocalToPixel(Double_t *local, Int_t &pixelNumberX, Int_t &pixelNumberY)
Double_t GetIntegrationtime() const
Double_t GetReadoutTime(Double_t absoluteTime) const
CbmMvdSensorDataSheet * GetDataSheet()