18 #include "FairBaseParSet.h"
20 #include "FairRunAna.h"
21 #include "FairRuntimeDb.h"
23 #include "TDatabasePDG.h"
25 #include "TLorentzVector.h"
45 (FairBaseParSet*)(
rtdb->findContainer(
"FairBaseParSet"));
46 fPbeam = par->GetBeamMom();
50 FairRootManager* ioman = FairRootManager::Instance();
52 std::cout <<
"-E- PndSdsStripClusterTask::Init: "
53 <<
"RootManager not instantiated!" << std::endl;
63 std::cout <<
"-W- PndSdsStripClusterTask::Init: "
64 <<
"No SDSDigi array!" << std::endl;
87 Info(
"Init",
"Initialisation successfull");
114 ana = FairRun::Instance();
120 Info(
"SetParContainers()",
"The container names list contains %i entries",
121 theContNames->GetEntries());
122 TIter cfIter(theContNames);
123 while (TObjString* contname = (TObjString*)cfIter()) {
124 TString parsetname = contname->String();
125 Info(
"SetParContainers()",
"%s", parsetname.Data());
126 if (parsetname.BeginsWith(
"SDSStripDigiPar")) {
130 Fatal(
"SetParContainers",
"No DIGI parameter found: %s",
134 if (parsetname.BeginsWith(
"SDSStripTotDigiPar")) {
138 Fatal(
"SetParContainers",
"No TOT parameter found: %s",
162 Info(
"SetCalculators",
"lmd");
168 if (0 == digipar)
continue;
169 const char* senstype = digipar->GetSensType();
170 if (digipar->GetChargeConvMethod() == 1) {
172 Info(
"SetCalculators()",
"Use Tot charge conversion for %s sensors",
179 Info(
"SetCalculators()",
"Use Ideal charge conversion for %s sensors",
184 Int_t ClusterMod = digipar->GetClusterMod();
185 Int_t RadChannel = digipar->GetRadChannel();
186 Int_t RadTime = digipar->GetRadTime();
187 if (0 == ClusterMod) {
190 }
else if (1 == ClusterMod) {
223 "calculation additional errors due to multiple scaterring");
227 Int_t PDGCode = -2212;
228 TDatabasePDG* fdbPDG = TDatabasePDG::Instance();
229 TParticlePDG*
fParticle = fdbPDG->GetParticle(PDGCode);
233 TLorentzVector LorMom(0, 0,
fPbeam, Ebeam);
247 double zhit = hpos.Z();
249 const double Z0 = 1099.;
251 int num = (zhit - Z0) / d;
259 Double_t sigmaMSplane = X * thetaMS;
262 xerr = TMath::Hypot(xerr, sigmaMSplane);
263 yerr = TMath::Hypot(yerr, sigmaMSplane);
269 for (
int j = 0; j <
num; j++) {
271 sigmaMS = (j + 1) * d * thetaMS;
274 xerr = TMath::Hypot(xerr, sigmaMS);
275 yerr = TMath::Hypot(yerr, sigmaMS);
278 cout <<
" num:" << num <<
"(Z=" << zhit <<
") xerr=" << xerr
279 <<
" yerr=" << yerr << endl;
280 TVector3
res(xerr, yerr, hposerr.Z());
287 std::cout <<
" **Starting PndLmdStripClusterTask::Exec()**" << std::endl;
288 std::vector<PndSdsDigiStrip> digiStripArray;
296 if (!
fHitArray) Fatal(
"Exec",
"No HitArray");
301 if (FairRunAna::Instance()->IsTimeStamp()) {
303 fDigiArray = FairRootManager::Instance()->GetData(
305 FairRootManager::Instance()->GetEventTime() +
308 std::cout <<
"-I- PndLmdStripClusterTask::Exec Digis: "
312 (TClonesArray*)FairRootManager::Instance()->GetObject(
fInBranchName);
315 std::cout <<
"-W- PndLmdStripClusterTask::Init: "
316 <<
"No LMDDigi array!" << std::endl;
321 if (
fDigiArray->GetEntriesFast() == 0)
return;
327 std::vector<PndSdsClusterStrip*> clusters;
328 std::vector<Int_t> topclusters;
329 std::vector<Int_t> botclusters;
330 std::vector<Int_t> oneclustertop;
331 std::vector<Int_t> oneclusterbot;
332 std::vector<Int_t> leftDigis;
333 Int_t mcindex, clindex, botIndex, topIndex;
338 TVector2 meantopPoint, meanbotPoint, onsensorPoint;
339 TVector3 hitPos, hitErr;
341 Int_t clusterOffset = 0;
357 if (0 < leftDigis.size()) {
358 std::cout <<
"There are " << leftDigis.size()
359 <<
" Digis not assigned to"
361 for (
unsigned int s = 0;
s < leftDigis.size();
s++) {
362 std::cout << leftDigis[
s] <<
"|";
364 std::cout << std::endl;
366 std::cout <<
"All Digis assigned to clusters" << std::endl;
372 for (std::vector<PndSdsClusterStrip*>::iterator clit = clusters.begin();
373 clit != clusters.end(); ++clit) {
378 if (FairRunAna::Instance()->IsTimeStamp()) {
379 myCluster->ResetLinks();
383 myCluster->AddLink(FairLink(tempDigi->GetEntryNr()));
390 std::cout <<
"Check.. Offset: " << clusterOffset <<
"Top Clusters: ";
391 for (std::vector<Int_t>::iterator itTop = topclusters.begin();
392 itTop != topclusters.end(); ++itTop) {
393 std::cout << *itTop <<
" | ";
395 std::cout << std::endl;
396 std::cout <<
"Bot Clusters: ";
397 for (std::vector<Int_t>::iterator itBot = botclusters.begin();
398 itBot != botclusters.end(); ++itBot) {
399 std::cout << *itBot <<
" | ";
401 std::cout << std::endl;
416 for (std::vector<Int_t>::iterator itTop = topclusters.begin();
417 itTop != topclusters.end(); ++itTop) {
418 topIndex = *itTop + clusterOffset;
419 Double_t topcharge = 0., meantopstrip = 0., meantoperr = 0.,
420 timestamp = 0., timestampError = 0.;
423 if (oneclustertop.size() < 1)
continue;
431 timestamp, timestampError);
433 if (oneclustertop.size() == 1 &&
435 std::cout <<
"-W- PndLmdStripClusterTask::Exec: Single strip charge ("
436 << topcharge <<
" e-) falls below the threshold of "
440 if (topcharge <= 0) {
441 Error(
"Exec() - Hit combination",
442 "Not a sane top charge (%f) calculated, skip cluster %i",
446 if (meantopstrip < 0) {
447 Error(
"Exec() - Hit combination",
448 "Not a sane top mean (%f) calculated, skip cluster %i",
449 meantopstrip, *itTop);
454 for (std::vector<Int_t>::iterator itBot = botclusters.begin();
455 itBot != botclusters.end(); ++itBot) {
456 botIndex = *itBot + clusterOffset;
457 Double_t botcharge = 0., meanbotstrip = 0., meanboterr = 0.;
460 if (oneclusterbot.size() < 1)
continue;
466 if (sensorIDbot != sensorIDtop)
continue;
469 timestamp, timestampError);
471 if (oneclusterbot.size() == 1 &&
473 std::cout <<
"-W- PndLmdStripClusterTask::Exec: Single strip charge ("
474 << botcharge <<
" e-) falls below the threshold of "
478 if (botcharge <= 0) {
479 Error(
"Exec() - Hit combination",
480 "Not a sane bot charge (%f) calculated, skip cluster %i",
484 if (meanbotstrip < 0) {
485 Error(
"Exec() - Hit combination",
486 "Not a sane bot mean (%f) calculated, skip cluster %i",
487 meanbotstrip, *itBot);
492 std::cout <<
"Charges: Ctop = " << topcharge
493 <<
" | Cbot = " << botcharge
494 <<
" | difference bot-top = " << botcharge - topcharge
499 fabs(botcharge - topcharge) <
501 mycharge = (botcharge + topcharge) / 2.;
505 for (Int_t mcI = 0; mcI < atopDigi->
GetNIndices(); mcI++) {
507 for (Int_t mcIb = 0; mcIb < abotDigi->
GetNIndices(); mcIb++) {
515 Bool_t test =
Backmap(meantopPoint, meantoperr, meanbotPoint,
516 meanboterr, hitPos, hitCov, sensorIDtop);
517 if (kFALSE == test)
continue;
521 hitErr.SetXYZ(
sqrt(hitCov[0][0]),
sqrt(hitCov[1][1]),
524 clDetID, sensorIDtop, hitPos, hitErr, topIndex, mycharge,
525 oneclusterbot.size() + oneclustertop.size(), mcindex);
530 tmphit->SetTimeStamp(timestamp);
531 tmphit->SetTimeStampError(timestampError);
534 std::cout <<
"Strip charge contents too different" << std::endl;
540 std::cout <<
"-I- PndLmdStripClusterTask: "
542 <<
fHitArray->GetEntriesFast() <<
" Hits calculated."
543 <<
" out of " <<
fDigiArray->GetEntriesFast() <<
" Digis"
558 TVector3 LumiTrans(0, 0, kRotUmZ);
560 hitPos.RotateY(-kRot);
561 LumiTrans = TVector3(0, 0, kTransZ - kRotUmZ);
569 hitMtx[0][0] = hitPos[0];
570 hitMtx[1][0] = hitPos[1];
571 hitMtx[2][0] = hitPos[2];
573 hitPos = TVector3(hitMtx(0, 0), hitMtx(1, 0), hitMtx(2, 0));
581 rot[0][0] = costheta;
583 rot[0][2] = sintheta;
587 rot[2][0] = -sintheta;
589 rot[2][2] = costheta;
614 TVector2 meanbotPoint,
615 Double_t meanboterr, TVector3& hitPos,
616 TMatrixD& hitCov, Int_t& sensorID) {
634 TVector2 onsensorPoint =
638 localpos.SetXYZ(onsensorPoint.X(), onsensorPoint.Y(), 0.);
664 locCov[0][0] = t * t + b * b +
670 locCov[1][1] = t * t + b * b +
672 locCov[2][2] = errZ * errZ;
676 TVector3 hitErr(
sqrt(locCov[0][0]),
sqrt(locCov[1][1]),
sqrt(locCov[2][2]));
677 TVector3 hitErrMSadd =
AddMSErr(hitPos, hitErr);
678 locCov[0][0] = TMath::Power(hitErrMSadd.X(), 2);
679 locCov[1][1] = TMath::Power(hitErrMSadd.Y(), 2);
680 locCov[2][2] = TMath::Power(hitErrMSadd.Z(), 2);
std::vector< Int_t > GetClusterList() const
friend F32vec4 cos(const F32vec4 &a)
Int_t GetClusterSize() const
Int_t GetSensorID() const
virtual void Print(const Option_t *opt=0) const
virtual void SetInBranchId()
friend F32vec4 sqrt(const F32vec4 &a)
static T Sqrt(const T &x)
Int_t GetIndex(int i=0) const
PndSdsCalcStrip * fCurrentStripCalcTop
friend F32vec4 sin(const F32vec4 &a)
TClonesArray * fDigiArray
Class for digitised strip hits.
std::vector< Int_t > GetLeftDigiIDs() const
const TVector2 GetStripDirection() const
Charge Digitization Parameter Class for SDS.
void rotateToLumiFrame(TVector3 &hitPos)
Double_t GetOrient() const
TClonesArray * fClusterArray
Double_t GetConstCurrent() const
TVector3 GetSensorDimensionsShortId(Int_t shortId)
std::map< const char *, PndSdsStripClusterer * > fClusterFinderList
Double_t GetClockFrequency() const
Find Clusters on a strip sensor in two dimensions.
TMatrixD LocalToMasterErrorsShortId(const TMatrixD &local, const Int_t &shortId)
Int_t GetDigiIndex(Int_t i) const
std::vector< Int_t > GetBotClusterIDs() const
virtual void SetCalculators()
TVector3 AddMSErr(TVector3 hit, TVector3 hiterr)
void combitransToLumiFrame(TVector3 &hitPos)
Digitization Parameter Class for MVD-Strip part.
virtual Bool_t Backmap(TVector2 meantopPoint, Double_t meantoperr, TVector2 meanbotPoint, Double_t meanboterr, TVector3 &hitPos, TMatrixD &hitCov, Int_t &sensorID)
friend F32vec4 fabs(const F32vec4 &a)
std::vector< Int_t > GetTopClusterIDs() const
void SetBotIndex(Int_t id)
static PndGeoHandling * Instance()
TList * fChargeDigiParameterList
virtual void SetParContainers()
virtual void SetCalculators()
void SetCurrentCalculators(PndSdsStripDigiPar *digipar)
TList * GetDigiParNames()
PndSdsStripDigiPar * fCurrentDigiPar
virtual std::vector< PndSdsClusterStrip * > SearchClusters()=0
std::map< const char *, PndSdsChargeConversion * > fChargeConverter
Double_t GetChargingTime() const
Double_t GetBotPitch() const
virtual void SetBranchNames()
void FillClusterFinders()
TVector3 LocalToMasterShortId(const TVector3 &local, const Int_t &shortId)
virtual ~PndLmdStripClusterTask()
Int_t GetNIndices() const
TVector2 GetTopAnchor() const
TList * fDigiParameterList
Digitization Parameters.
void SetCov(TMatrixD cov)
PndSdsCalcStrip * fCurrentStripCalcBot
void CalcMeanCharge(PndSdsClusterStrip *onecluster, Double_t &meanstrip, Double_t &meanerr, Double_t &charge, Double_t ×tamp, Double_t ×tampError)
Double_t GetTopPitch() const
PndSdsStripClusterer * fCurrentClusterfinder
Geometry name handling.
TMatrixT< double > TMatrixD
Double_t fSingleStripChargeThreshold
virtual void SetParContainers()
TVector2 CalcLineCross(TVector2 point1, TVector2 dir1, TVector2 point2, TVector2 dir2) const
void CalcStripPointOnLine(const Double_t strip, TVector2 &point) const