FairRoot/PandaRoot
PndLmdStripClusterTask.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndLmdStripClusterTask source file -----
3 // ----- modified for Lmd by M. Michel & A.Karavdina -----
4 // -------------------------------------------------------------------------
5 
6 // LUMI
8 #include "PndLmdAlignPar.h"
9 #include "PndLmdContFact.h"
10 // PANDA
16 #include "PndSdsTotDigiPar.h"
17 // FAIR
18 #include "FairBaseParSet.h"
19 #include "FairRun.h"
20 #include "FairRunAna.h"
21 #include "FairRuntimeDb.h"
22 // ROOT
23 #include "TDatabasePDG.h"
24 #include "TList.h"
25 #include "TLorentzVector.h"
26 // ----- Default constructor -------------------------------------------
27 
29  : PndSdsStripClusterTask("LMD Strip Clusterisation Task") {
31  // fAlignParamList = new TList();
32  flagMS = true;
33 }
34 
35 // ----- Destructor ----------------------------------------------------
37  // if(0!=fGeoH) delete fGeoH;
38  // if(0!=fChargeAlgos) delete fChargeAlgos;
39 }
40 // -------------------------------------------------------------------------
41 
42 // ----- Public method Init --------------------------------------------
44  FairBaseParSet* par =
45  (FairBaseParSet*)(rtdb->findContainer("FairBaseParSet"));
46  fPbeam = par->GetBeamMom();
47 
49 
50  FairRootManager* ioman = FairRootManager::Instance();
51  if (!ioman) {
52  std::cout << "-E- PndSdsStripClusterTask::Init: "
53  << "RootManager not instantiated!" << std::endl;
54  return kFATAL;
55  }
56 
57  fFunctor = new TimeGap();
58 
59  // Get input array
60  fDigiArray = (TClonesArray*)ioman->GetObject(fInBranchName);
61  //
62  if (!fDigiArray) {
63  std::cout << "-W- PndSdsStripClusterTask::Init: "
64  << "No SDSDigi array!" << std::endl;
65  return kERROR;
66  }
67  // set output arrays
68 
69  fClusterArray = ioman->Register(fClustBranchName, "PndSdsClusterStrip",
71 
72  // fHitArray = new TClonesArray("PndSdsHit");
73  fHitArray =
74  ioman->Register(fOutBranchName, "PndSdsHit", fFolderName, GetPersistency());
75 
76  SetInBranchId();
77 
79 
80  // fPath = getenv("VMCWORKDIR");
81  // fPath += "/macro/params/interstrippos_vs_eta_histos.root";
82 
83  // etahistofile = new TFile(fPath,"READ");
84  // eta_rect = (TH1F*)etahistofile->Get("posvseta rect");
85  // eta_trap = (TH1F*)etahistofile->Get("posvseta trap");
86 
87  Info("Init", "Initialisation successfull");
88  return kSUCCESS;
89 }
90 // -------------------------------------------------------------------------
91 
93  TString outHitBranchname,
94  TString outClustBranchname,
95  TString folderName) {
96  fInBranchName = inBranchname;
97  fOutBranchName = outHitBranchname;
98  fClustBranchName = outClustBranchname;
99  fFolderName = folderName;
100 }
101 
103  fInBranchName = "LMDStripDigis";
104  fOutBranchName = "LMDHitsStrip";
105  fClustBranchName = "LMDStripClusterCand";
106  fFolderName = "PndLmd";
107 }
108 
109 // ----- Initialization of Parameter Containers -------------------------
111  // called from the FairRun::Init()
112  // Caution: The Parameter Set is not filled from the DB IO, yet.
113  // This will be done just before this Tasks Init() is called.
114  ana = FairRun::Instance();
115  rtdb = ana->GetRuntimeDb();
116 
117  PndLmdContFact* themvdcontfact =
118  (PndLmdContFact*)rtdb->getContFactory("PndLmdContFact");
119  TList* theContNames = themvdcontfact->GetDigiParNames();
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")) {
127  PndSdsStripDigiPar* digipar =
128  (PndSdsStripDigiPar*)(rtdb->getContainer(parsetname.Data()));
129  if (!digipar)
130  Fatal("SetParContainers", "No DIGI parameter found: %s",
131  parsetname.Data());
132  fDigiParameterList->Add(digipar);
133  }
134  if (parsetname.BeginsWith("SDSStripTotDigiPar")) {
135  PndSdsTotDigiPar* totdigipar =
136  (PndSdsTotDigiPar*)(rtdb->getContainer(parsetname.Data()));
137  if (!totdigipar)
138  Fatal("SetParContainers", "No TOT parameter found: %s",
139  parsetname.Data());
140  fChargeDigiParameterList->Add(totdigipar);
141  }
142  } // while
143 
144  // //read params for lumi alignment
145  // TList* theAlignLMDContNames = themvdcontfact->GetAlignParNames();
146  // Info("SetParContainers()","AlignLMD The container names list contains %i
147  // entries",theAlignLMDContNames->GetEntries());
148  // TIter cfAlIter(theAlignLMDContNames);
149  // while (TObjString* contname = (TObjString*)cfAlIter()) {
150  // TString parsetname = contname->String();
151  // Info("SetParContainers()",parsetname.Data());
152  // PndLmdAlignPar *lmdalignpar =
153  // (PndLmdAlignPar*)(rtdb->getContainer(parsetname.Data()));
154  // if(!lmdalignpar) Fatal("SetParContainers","No ALIGN parameter found:
155  // %s",parsetname.Data());
156  // fAlignParamList->Add(lmdalignpar);
157  // }
159 }
160 
162  Info("SetCalculators", "lmd");
164  TIter params(fDigiParameterList);
165  TIter totparams(fChargeDigiParameterList);
166  while (PndSdsStripDigiPar* digipar = (PndSdsStripDigiPar*)params()) {
167  PndSdsTotDigiPar* totdigipar = (PndSdsTotDigiPar*)totparams();
168  if (0 == digipar) continue;
169  const char* senstype = digipar->GetSensType();
170  if (digipar->GetChargeConvMethod() == 1) {
171  if (fVerbose > 0)
172  Info("SetCalculators()", "Use Tot charge conversion for %s sensors",
173  senstype);
175  totdigipar->GetChargingTime(), totdigipar->GetConstCurrent(),
176  digipar->GetThreshold(), totdigipar->GetClockFrequency(), fVerbose);
177  } else {
178  if (fVerbose > 0)
179  Info("SetCalculators()", "Use Ideal charge conversion for %s sensors",
180  senstype);
182  }
183 
184  Int_t ClusterMod = digipar->GetClusterMod();
185  Int_t RadChannel = digipar->GetRadChannel();
186  Int_t RadTime = digipar->GetRadTime();
187  if (0 == ClusterMod) {
189  fInBranchId, RadChannel); // search radius in channel no.
190  } else if (1 == ClusterMod) {
191  fClusterFinderList[senstype] =
192  new PndSdsStripAdvClusterFinder(fInBranchId, RadChannel, RadTime);
193  }
194  }
195 
196  // TIter alignparams(fAlignParamList);
197  // PndLmdAlignPar* lmdalignpar=(PndLmdAlignPar*)alignparams();
198  // if(0==lmdalignpar) {
199  // Error("PndLmdStripClusterTask::SetCalculators()","A ALIGN Parameter Set
200  // does not exist properly.");
201  // }
202  // else{
203  // // lmdalignpar->Print();
204  // for(int ik=0;ik<32;ik++){
205  // fShiftX[ik] = lmdalignpar->GetShiftX(ik);
206  // fShiftY[ik] = lmdalignpar->GetShiftY(ik);
207  // fShiftZ[ik] = lmdalignpar->GetShiftZ(ik);
208  // fRotateX[ik] = lmdalignpar->GetRotateX(ik);
209  // fRotateY[ik] = lmdalignpar->GetRotateY(ik);
210  // fRotateZ[ik] = lmdalignpar->GetRotateZ(ik);
211  // if (fVerbose > 2) cout<<"fShiftX["<<ik<<"]="<<fShiftX[ik]<<"
212  // fRotateX["<<ik<<"]="<<fRotateX[ik]
213  // <<" fRotateY["<<ik<<"]="<<fRotateY[ik]<<"
214  // fRotateZ["<<ik<<"]="<<fRotateZ[ik]<<endl;
215  // }
216  // }
217  // lmdalignpar->Print();
218 }
219 
220 TVector3 PndLmdStripClusterTask::AddMSErr(TVector3 hpos, TVector3 hposerr) {
221  if (fVerbose > 0)
222  Info("AddMSErr",
223  "calculation additional errors due to multiple scaterring");
224 
225  // Calculation of ThetaMS -------------------------------------
226  // Charge & mass of particle
227  Int_t PDGCode = -2212;
228  TDatabasePDG* fdbPDG = TDatabasePDG::Instance();
229  TParticlePDG* fParticle = fdbPDG->GetParticle(PDGCode);
230  Double_t fMass = fParticle->Mass();
231 
232  Double_t Ebeam = TMath::Hypot(fPbeam, fMass);
233  TLorentzVector LorMom(0, 0, fPbeam, Ebeam);
234  Double_t beta = LorMom.Beta();
235  Double_t X = 0.015;
236  Double_t X0 = 9.37;
237  // Double_t thetaMS =
238  // 13.6*1e-3*TMath::Sqrt(X/X0)*(1+0.038*TMath::Log(X/X0))/(beta*fPbeam);
239  Double_t thetaMS = 13.6 * 1e-3 * TMath::Sqrt(X / X0) / (beta * fPbeam);
240  // cout<<"thetaMS = "<<thetaMS<<" fPbeam = "<<fPbeam<<endl;
241  //-----------------------------------------------------------
242 
243  // TO DO: use parameters from geometry info for LUMI
244  Double_t d = 10.;
245 
246  double xerr, yerr;
247  double zhit = hpos.Z();
248  // const double Z0 = 1100.;
249  const double Z0 = 1099.;
250  // const double Z0 = 0.;
251  int num = (zhit - Z0) / d;
252  // double numd = (zhit-Z0)/10.;
253  // cout<<"num = "<<num<<endl;
254  xerr = hposerr.X();
255  yerr = hposerr.Y();
256  // cout<<"Plane #"<<num<<" before: zhit="<<zhit<<" xerr = "<<xerr<<" yerr =
257  // "<<yerr<<endl;
258  // Double_t sigmaMSplane = 0.5*X*thetaMS; //TEST
259  Double_t sigmaMSplane = X * thetaMS;
260  // cout<<"sigmaMSplane = "<<sigmaMSplane<<" um"<<endl;
261  if (num == 0) {
262  xerr = TMath::Hypot(xerr, sigmaMSplane);
263  yerr = TMath::Hypot(yerr, sigmaMSplane);
264  }
265  // double xhit = hpos.X(); //[R.K. 01/2017] unused variable
266 
267  // Double_t l = 10./cos(2.326*TMath::Pi()/180.);
268  double sigmaMS;
269  for (int j = 0; j < num; j++) {
270  // sigmaMS = 2*(j+1)*d*thetaMS;
271  sigmaMS = (j + 1) * d * thetaMS;
272  // cout<<"sigmaMS = "<<sigmaMS<<" xerr="<<xerr<<" yerr="<<yerr<<endl;
273  // sigmaMS = j*d*thetaMS;
274  xerr = TMath::Hypot(xerr, sigmaMS);
275  yerr = TMath::Hypot(yerr, sigmaMS);
276  }
277  if (fVerbose > 2)
278  cout << " num:" << num << "(Z=" << zhit << ") xerr=" << xerr
279  << " yerr=" << yerr << endl;
280  TVector3 res(xerr, yerr, hposerr.Z());
281  return res;
282 };
283 
284 // ----- Public method Exec --------------------------------------------
286  if (fVerbose > 2)
287  std::cout << " **Starting PndLmdStripClusterTask::Exec()**" << std::endl;
288  std::vector<PndSdsDigiStrip> digiStripArray;
289  // Reset output array
290  fClusterArray =
291  FairRootManager::Instance()->GetTClonesArray(fClustBranchName);
292  if (!fClusterArray) Fatal("Exec", "No ClusterArray");
293  fClusterArray->Delete();
294 
295  fHitArray = FairRootManager::Instance()->GetTClonesArray(fOutBranchName);
296  if (!fHitArray) Fatal("Exec", "No HitArray");
297  fHitArray->Delete();
298 
299  // Get input array
300 
301  if (FairRunAna::Instance()->IsTimeStamp()) {
302  fDigiArray->Clear();
303  fDigiArray = FairRootManager::Instance()->GetData(
305  FairRootManager::Instance()->GetEventTime() +
306  10); // FairRootManager::Instance()->GetEventTime() +
307  if (fVerbose > 1)
308  std::cout << "-I- PndLmdStripClusterTask::Exec Digis: "
309  << fDigiArray->GetEntries() << std::endl;
310  } else
311  fDigiArray =
312  (TClonesArray*)FairRootManager::Instance()->GetObject(fInBranchName);
313 
314  if (!fDigiArray) {
315  std::cout << "-W- PndLmdStripClusterTask::Init: "
316  << "No LMDDigi array!" << std::endl;
317  return;
318  }
319 
320  // when we have no digis, we can end the event here.
321  if (fDigiArray->GetEntriesFast() == 0) return;
323 
324  // Setup
326 
327  std::vector<PndSdsClusterStrip*> clusters;
328  std::vector<Int_t> topclusters; // contains index to fClusterArray
329  std::vector<Int_t> botclusters; // contains index to fClusterArray
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;
334  // Int_t detID = FairRootManager::Instance()->GetBranchId(fInBranchName);
335  // //[R.K. 01/2017] unused variable
336  Int_t clDetID = FairRootManager::Instance()->GetBranchId(fClustBranchName);
337  Double_t mycharge;
338  TVector2 meantopPoint, meanbotPoint, onsensorPoint;
339  TVector3 hitPos, hitErr;
340  TMatrixD hitCov(3, 3);
341  Int_t clusterOffset = 0;
342  PndSdsHit* tmphit;
343 
344  // ------- SEARCH ------
345  TIter parsetiter(fDigiParameterList);
346  while (PndSdsStripDigiPar* digipar = (PndSdsStripDigiPar*)
347  parsetiter()) { // loop over all parameter sets and their filled
348  // finders (representing sensor types)
349  SetCurrentCalculators(digipar);
350 
352  // fetch ids in 'clusters' to the top and bot side
353  topclusters = fCurrentClusterfinder->GetTopClusterIDs();
354  botclusters = fCurrentClusterfinder->GetBotClusterIDs();
355  if (fVerbose > 2) {
356  leftDigis = fCurrentClusterfinder->GetLeftDigiIDs();
357  if (0 < leftDigis.size()) {
358  std::cout << "There are " << leftDigis.size()
359  << " Digis not assigned to"
360  << " clusters:\n";
361  for (unsigned int s = 0; s < leftDigis.size(); s++) {
362  std::cout << leftDigis[s] << "|";
363  }
364  std::cout << std::endl;
365  } else
366  std::cout << "All Digis assigned to clusters" << std::endl;
367  }
368  // Fill the ClonesArray for output TODO: do this better, don't copy objects
369  // around
370  // save array size before we fill
371  clusterOffset = fClusterArray->GetEntriesFast();
372  for (std::vector<PndSdsClusterStrip*>::iterator clit = clusters.begin();
373  clit != clusters.end(); ++clit) {
374  clindex = fClusterArray->GetEntriesFast();
375  PndSdsClusterStrip* myCluster =
376  new ((*fClusterArray)[clindex]) PndSdsClusterStrip(*(*clit));
377 
378  if (FairRunAna::Instance()->IsTimeStamp()) {
379  myCluster->ResetLinks();
380  for (Int_t i = 0; i < myCluster->GetClusterSize(); i++) {
381  PndSdsDigiStrip* tempDigi =
382  (PndSdsDigiStrip*)fDigiArray->At(myCluster->GetDigiIndex(i));
383  myCluster->AddLink(FairLink(tempDigi->GetEntryNr()));
384  }
385  }
386  }
387 
388  // printout for checking
389  if (fVerbose > 2) {
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 << " | ";
394  }
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 << " | ";
400  }
401  std::cout << std::endl;
402  }
403 
404  // begin the hit reconstruction
405  // loop structure:
406  //
407  // top clusters
408  // |-calculate chargeweighted mean
409  // |-bot clusters
410  // |-|-calc chargew. mean
411  // |-|-calc the crossing strip points
412  // |-|-fill hit array
413 
414  // ----- merge top/bot clusters to hits -----
415  // loop on clusters from the top side
416  for (std::vector<Int_t>::iterator itTop = topclusters.begin();
417  itTop != topclusters.end(); ++itTop) {
418  topIndex = *itTop + clusterOffset; // index in fClusterArray
419  Double_t topcharge = 0., meantopstrip = 0., meantoperr = 0.,
420  timestamp = 0., timestampError = 0.;
421  PndSdsClusterStrip* aTopCluster = clusters[*itTop];
422  oneclustertop = aTopCluster->GetClusterList();
423  if (oneclustertop.size() < 1) continue;
424  PndSdsDigiStrip* atopDigi =
425  ((PndSdsDigiStrip*)fDigiArray->At(oneclustertop[0]));
426  Int_t sensorIDtop = atopDigi->GetSensorID();
427 
428  // if (kFALSE==SelectSensorParams(detName)) continue; // Invalid
429  // parameters, skip here.
430  CalcMeanCharge(aTopCluster, meantopstrip, meantoperr, topcharge,
431  timestamp, timestampError);
432 
433  if (oneclustertop.size() == 1 &&
434  topcharge < fSingleStripChargeThreshold) {
435  std::cout << "-W- PndLmdStripClusterTask::Exec: Single strip charge ("
436  << topcharge << " e-) falls below the threshold of "
437  << fSingleStripChargeThreshold << "e- : skipping. " << endl;
438  continue;
439  }
440  if (topcharge <= 0) { // not a sane charge
441  Error("Exec() - Hit combination",
442  "Not a sane top charge (%f) calculated, skip cluster %i",
443  topcharge, *itTop);
444  continue;
445  }
446  if (meantopstrip < 0) { // not a sane strip number
447  Error("Exec() - Hit combination",
448  "Not a sane top mean (%f) calculated, skip cluster %i",
449  meantopstrip, *itTop);
450  continue;
451  }
452  fCurrentStripCalcTop->CalcStripPointOnLine(meantopstrip, meantopPoint);
453  // loop on bottom side
454  for (std::vector<Int_t>::iterator itBot = botclusters.begin();
455  itBot != botclusters.end(); ++itBot) {
456  botIndex = *itBot + clusterOffset; // index in fClusterArray
457  Double_t botcharge = 0., meanbotstrip = 0., meanboterr = 0.;
458  PndSdsClusterStrip* aBotCluster = clusters[*itBot];
459  oneclusterbot = aBotCluster->GetClusterList();
460  if (oneclusterbot.size() < 1) continue;
461  PndSdsDigiStrip* abotDigi =
462  ((PndSdsDigiStrip*)fDigiArray->At(oneclusterbot[0]));
463  Int_t sensorIDbot = abotDigi->GetSensorID();
464 
465  // go to the next cluster if we didn't hit the same sensor
466  if (sensorIDbot != sensorIDtop) continue;
467 
468  CalcMeanCharge(aBotCluster, meanbotstrip, meanboterr, botcharge,
469  timestamp, timestampError);
470 
471  if (oneclusterbot.size() == 1 &&
472  botcharge < fSingleStripChargeThreshold) {
473  std::cout << "-W- PndLmdStripClusterTask::Exec: Single strip charge ("
474  << botcharge << " e-) falls below the threshold of "
475  << fSingleStripChargeThreshold << "e- : skipping. " << endl;
476  continue;
477  }
478  if (botcharge <= 0) { // not a sane charge
479  Error("Exec() - Hit combination",
480  "Not a sane bot charge (%f) calculated, skip cluster %i",
481  botcharge, *itBot);
482  continue;
483  }
484  if (meanbotstrip < 0) { // not a sane strip number
485  Error("Exec() - Hit combination",
486  "Not a sane bot mean (%f) calculated, skip cluster %i",
487  meanbotstrip, *itBot);
488  continue;
489  }
490 
491  if (fVerbose > 2) {
492  std::cout << "Charges: Ctop = " << topcharge
493  << " | Cbot = " << botcharge
494  << " | difference bot-top = " << botcharge - topcharge
495  << " | Cut at " << fChargeCut << std::endl;
496  }
497 
498  if (fChargeCut > 0 &&
499  fabs(botcharge - topcharge) <
500  fChargeCut) { // look if the charges are not too differently
501  mycharge = (botcharge + topcharge) / 2.;
503  meanbotPoint);
504  mcindex = -1; // reset
505  for (Int_t mcI = 0; mcI < atopDigi->GetNIndices(); mcI++) {
506  if (atopDigi->GetIndex(mcI) > -1) {
507  for (Int_t mcIb = 0; mcIb < abotDigi->GetNIndices(); mcIb++) {
508  if (abotDigi->GetIndex(mcIb) == atopDigi->GetIndex(mcI)) {
509  mcindex = abotDigi->GetIndex(mcIb);
510  break;
511  }
512  }
513  }
514  }
515  Bool_t test = Backmap(meantopPoint, meantoperr, meanbotPoint,
516  meanboterr, hitPos, hitCov, sensorIDtop);
517  if (kFALSE == test) continue;
518 
519  // --- add hit to list ---
520  Int_t i = fHitArray->GetEntriesFast();
521  hitErr.SetXYZ(sqrt(hitCov[0][0]), sqrt(hitCov[1][1]),
522  sqrt(hitCov[2][2]));
523  tmphit = new ((*fHitArray)[i]) PndSdsHit(
524  clDetID, sensorIDtop, hitPos, hitErr, topIndex, mycharge,
525  oneclusterbot.size() + oneclustertop.size(), mcindex);
526  tmphit->SetBotIndex(botIndex);
527  tmphit->SetLink(FairLink(fClusterType, topIndex));
528  tmphit->AddLink(FairLink(fClusterType, botIndex));
529  tmphit->SetCov(hitCov);
530  tmphit->SetTimeStamp(timestamp);
531  tmphit->SetTimeStampError(timestampError);
532  if (fVerbose > 1) tmphit->Print();
533  } else if (fVerbose > 2)
534  std::cout << "Strip charge contents too different" << std::endl;
535  } // loop bot clusters
536  } // loop top clusters
537  } // loop finders
538 
539  if (fVerbose > 1)
540  std::cout << "-I- PndLmdStripClusterTask: "
541  << fClusterArray->GetEntriesFast() << " Lmd Clusters and "
542  << fHitArray->GetEntriesFast() << " Hits calculated."
543  << " out of " << fDigiArray->GetEntriesFast() << " Digis"
544  << std::endl;
545  return;
546 }
548  // do the transformation from lab frame to LUMI frame (with z-axis perp. to
549  // lumi planes)
550  // const Double_t kHalfFoilThickness = 0.0075; // Thickness of sensitive
551  // foil (cm) //[R.K. 01/2017] unused variable
552  const Double_t kTransZ = 1100.; //(cm) //move at z-position
553  const Double_t kRotUmZ = 476.03; //(cm) //z-point to rotate
554  // const Double_t kTransX = 25; //(cm) //move at x-position //[R.K. 01/2017]
555  // unused variable
556  const Double_t kRot =
557  0.040596358401388; // 2.326 degree = 4.05963584013881024e-02 rad
558  TVector3 LumiTrans(0, 0, kRotUmZ);
559  hitPos -= LumiTrans;
560  hitPos.RotateY(-kRot);
561  LumiTrans = TVector3(0, 0, kTransZ - kRotUmZ);
562  hitPos -= LumiTrans;
563  // cout<<"!!! NEW HIT position in LUMI frame!!! "<<endl;
564  // hitPos.Print();
565 }
566 
568  TMatrixD hitMtx(3, 3);
569  hitMtx[0][0] = hitPos[0];
570  hitMtx[1][0] = hitPos[1];
571  hitMtx[2][0] = hitPos[2];
572  TMatrixD res = rotateToLumiFrame(hitMtx);
573  hitPos = TVector3(hitMtx(0, 0), hitMtx(1, 0), hitMtx(2, 0));
574 }
576  Double_t theta = 2.326;
577  Double_t degrad = TMath::Pi() / 180.;
578  Double_t sintheta = TMath::Sin(degrad * theta);
579  Double_t costheta = TMath::Cos(degrad * theta);
580  TMatrixD rot(3, 3); // Rotation around Y axis
581  rot[0][0] = costheta;
582  rot[0][1] = 0;
583  rot[0][2] = sintheta;
584  rot[1][0] = 0;
585  rot[1][1] = 1;
586  rot[1][2] = 0;
587  rot[2][0] = -sintheta;
588  rot[2][1] = 0;
589  rot[2][2] = costheta;
590  TMatrixD result = rot;
591  result.T();
592  result *= hitCov;
593  hitCov = result;
594  result *= rot;
595  return result;
596 }
597 
598 // //Correction to hit position due to misalignment of sensor
599 // //TO DO: find a way do it in global and not hit by hit.
600 // void PndLmdStripClusterTask::alignmentCorr(TVector3& hitPos, int sensID){
601 // TVector3 hitPos_loc(hitPos.X(),hitPos.Y(),0.);
602 // hitPos_loc -=TVector3(fShiftX[sensID],fShiftY[sensID],fShiftZ[sensID]);
603 // double xnew =
604 // hitPos_loc.X()+fRotateZ[sensID]*hitPos_loc.Y()-fRotateY[sensID]*hitPos_loc.Z();
605 // double ynew =
606 // hitPos_loc.Y()-fRotateZ[sensID]*hitPos_loc.X()+fRotateX[sensID]*hitPos_loc.Z();
607 // double znew =
608 // hitPos_loc.Z()-fRotateY[sensID]*hitPos_loc.X()-fRotateX[sensID]*hitPos_loc.Y();
609 // hitPos = TVector3(xnew,ynew,hitPos.Z()+znew);
610 // }
611 
613  Double_t meantoperr,
614  TVector2 meanbotPoint,
615  Double_t meanboterr, TVector3& hitPos,
616  TMatrixD& hitCov, Int_t& sensorID) {
617  // BACKMAPPING
618  // get the backmapped point
619  // cout<<"PndLmdStripClusterTask::BACKMAP"<<endl;
620  // Info("Backmap","Sensor ID is %s",sensorID);
621  TVector3 localpos;
622  TMatrixD locCov(3, 3);
623  Double_t t, b;
624  // cout<<"sensorID = "<<sensorID<<endl;
625  // cout<<"fGeoH = "<<fGeoH<<endl;
626  Double_t errZ =
627  2. * fGeoH->GetSensorDimensionsShortId(sensorID).Z() / TMath::Sqrt(12.0);
628  // cout<<"fGeoH->GetSensorDimensionsShortId(sensorID).Z() =
629  // "<<fGeoH->GetSensorDimensionsShortId(sensorID).Z()<<endl;
630  // Double_t errZ =
631  // fGeoH->GetSensorDimensionsShortId(sensorID).Z()/TMath::Sqrt(12.0);//TEST!!!
632  // cout<<"errZ = "<<errZ<<endl;
633 
634  TVector2 onsensorPoint =
636  meanbotPoint, fCurrentStripCalcBot->GetStripDirection());
637  // // here we assume the sensor system to be in the _Middle_ of the volume
638  localpos.SetXYZ(onsensorPoint.X(), onsensorPoint.Y(), 0.);
639  // here we assume the sensor system to be in the _surface_ of the volume
640  // localpos.SetXYZ( onsensorPoint.X(),
641  // onsensorPoint.Y(),-(fGeoH->GetSensorDimensionsShortId(sensorID).Z()));
642  // let's see if we're still on the sensor (cut combinations with noise off)
643  if (fabs(localpos.X()) > fabs(fCurrentDigiPar->GetTopAnchor().X()))
644  return kFALSE;
645  if (fabs(localpos.Y()) > fabs(fCurrentDigiPar->GetTopAnchor().Y()))
646  return kFALSE;
647 
648  // do the transformation from sensor to lab frame
649  hitPos = fGeoH->LocalToMasterShortId(localpos, sensorID);
650 
652  // // //do the transformation from lab frame to LUMI frame (with z-axis perp.
653  // to lumi planes)
654  // combitransToLumiFrame(hitPos);
655 
656  // //do correction due to misalignemt of sensor
657  // alignmentCorr(hitPos,sensorID);
658 
659  // calculate the errors corresponding to a skewed system!
660  t = meantoperr * fCurrentDigiPar->GetTopPitch() *
662  b = meanboterr * fCurrentDigiPar->GetBotPitch() *
664  locCov[0][0] = t * t + b * b +
665  2 * fabs(t * b * cos(fCurrentDigiPar->GetSkew())); // TEST
666  t = meantoperr * fCurrentDigiPar->GetTopPitch() *
668  b = meanboterr * fCurrentDigiPar->GetBotPitch() *
670  locCov[1][1] = t * t + b * b +
671  2 * fabs(t * b * cos(fCurrentDigiPar->GetSkew())); // TEST
672  locCov[2][2] = errZ * errZ;
673 
674  if (flagMS) {
675  // //Add uncertanty due to multiple scattering
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);
681  }
682 
683  // do the transformation from sensor to lab frame
684  hitCov = fGeoH->LocalToMasterErrorsShortId(locCov, sensorID);
685 
687  // //transformation to LUMI frame
688  // hitCov = rotateToLumiFrame(hitCov);
689 
690  return kTRUE;
691 }
692 
int fVerbose
Definition: poormantracks.C:24
std::vector< Int_t > GetClusterList() const
Definition: PndSdsCluster.h:38
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:112
Int_t GetClusterSize() const
Definition: PndSdsCluster.h:39
Int_t GetSensorID() const
Definition: PndSdsDigi.h:59
virtual void Print(const Option_t *opt=0) const
Definition: PndSdsHit.cxx:66
Int_t fInBranchId
Definition: PndSdsTask.h:43
TObjArray * d
Int_t res
Definition: anadigi.C:166
TString fOutBranchName
Definition: PndSdsTask.h:40
int num[96]
Definition: ranlxd.cxx:381
Int_t i
Definition: run_full.C:25
TTree * b
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
static T Sqrt(const T &x)
Definition: PndCAMath.h:37
Int_t GetIndex(int i=0) const
Definition: PndSdsDigi.h:63
PndSdsCalcStrip * fCurrentStripCalcTop
friend F32vec4 sin(const F32vec4 &a)
Definition: P4_F32vec4.h:111
TLorentzVector s
Definition: Pnd2DStar.C:50
static T Sin(const T &x)
Definition: PndCAMath.h:42
Class for digitised strip hits.
Double_t par[3]
std::vector< Int_t > GetLeftDigiIDs() const
static T Cos(const T &x)
Definition: PndCAMath.h:43
const TVector2 GetStripDirection() const
Charge Digitization Parameter Class for SDS.
void rotateToLumiFrame(TVector3 &hitPos)
Double_t GetOrient() const
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.
Int_t * fParticle
Definition: run_full.C:24
TMatrixD LocalToMasterErrorsShortId(const TMatrixD &local, const Int_t &shortId)
Int_t GetDigiIndex(Int_t i) const
Definition: PndSdsCluster.h:40
std::vector< Int_t > GetBotClusterIDs() const
Double_t GetSkew() const
Double_t
TVector3 AddMSErr(TVector3 hit, TVector3 hiterr)
TString fInBranchName
Definition: PndSdsTask.h:39
void combitransToLumiFrame(TVector3 &hitPos)
Digitization Parameter Class for MVD-Strip part.
Double_t xerr[nsteps]
Definition: dedx_bands.C:114
virtual Bool_t Backmap(TVector2 meantopPoint, Double_t meantoperr, TVector2 meanbotPoint, Double_t meanboterr, TVector3 &hitPos, TMatrixD &hitCov, Int_t &sensorID)
TString fFolderName
Definition: PndSdsTask.h:41
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
std::vector< Int_t > GetTopClusterIDs() const
void SetBotIndex(Int_t id)
Definition: PndSdsHit.h:86
static PndGeoHandling * Instance()
void SetCurrentCalculators(PndSdsStripDigiPar *digipar)
void SetVerbose(Int_t v)
double X
Definition: anaLmdDigi.C:68
TList * GetDigiParNames()
PndSdsStripDigiPar * fCurrentDigiPar
virtual std::vector< PndSdsClusterStrip * > SearchClusters()=0
std::map< const char *, PndSdsChargeConversion * > fChargeConverter
Double_t GetChargingTime() const
Double_t GetBotPitch() const
ClassImp(PndAnaContFact)
TVector3 LocalToMasterShortId(const TVector3 &local, const Int_t &shortId)
TGeoRotation rot
TTree * t
Definition: bump_analys.C:13
Int_t GetNIndices() const
Definition: PndSdsDigi.h:64
TVector2 GetTopAnchor() const
TList * fDigiParameterList
Digitization Parameters.
void SetCov(TMatrixD cov)
Definition: PndSdsHit.cxx:70
PndSdsCalcStrip * fCurrentStripCalcBot
Double_t Pi
void CalcMeanCharge(PndSdsClusterStrip *onecluster, Double_t &meanstrip, Double_t &meanerr, Double_t &charge, Double_t &timestamp, Double_t &timestampError)
Double_t GetTopPitch() const
PndSdsStripClusterer * fCurrentClusterfinder
Geometry name handling.
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52
TVector2 CalcLineCross(TVector2 point1, TVector2 dir1, TVector2 point2, TVector2 dir2) const
void CalcStripPointOnLine(const Double_t strip, TVector2 &point) const