14 #include "PndLmdStrips.h"
24 fAnchor = TVector2(0,0);
39 fAnchor = firstStripAnchor;
46 fRNG =
new TRandom3();
48 fStripDir.Set(
cos(fOrient),
sin(fOrient));
49 fOrthoDir.Set(
sin(fOrient),
cos(fOrient));
62 fStripDir.Set(
cos(fOrient),
sin(fOrient));
63 fOrthoDir.Set(-
sin(fOrient),
cos(fOrient));
65 else if(segment==kRIGHT)
72 fStripDir.Set(
cos(fOrient),
sin(fOrient));
73 fOrthoDir.Set(
sin(fOrient),-
cos(fOrient));
81 fRNG =
new TRandom3();
107 TVector2 in(inx,iny);
108 TVector2
out(outx, outy);
109 TVector2 tpath= out-in;
112 std::vector<PndLmdStrips> strips;
118 std::cout<<
"-w- PndLmdCalStrip::GetStrips: No Trajectory inside sensor!"<<tpath.Mod()<<std::endl;
121 Double_t nuIn = CalStripFromPoint(inx,iny);
122 Double_t nuOut= CalStripFromPoint(outx,outy);
123 cout<<
"The nuIn strip is :"<<nuIn<<endl;
124 cout<<
"The outIn strip is :"<<nuOut<<endl;
126 Double_t Q = ChargeFromEloss(eLoss);
129 Int_t inStrip = Int_t(nuIn);
130 Int_t outStrip = Int_t(nuOut);
133 if(nuIn<0.&& nuOut<0.|| nuIn>
Double_t(fNrStrips)&&nuOut>
Double_t(fNrStrips)){
134 std::cout<<
"-i- warning: Hit outside active area."<<std::endl;
139 Double_t dir = (inStrip<outStrip) ? 1:-1;
143 Q *= (nuOut)/(nuOut-nuIn);
145 }
else if(nuIn>(
Double_t(fNrStrips))){
146 Q *=((
Double_t)fNrStrips-nuIn)/(nuOut-nuIn);
152 Q *=(nuIn)/(-nuOut+nuIn);
154 }
else if(nuOut>(
Double_t(fNrStrips))){
155 Q *=((
Double_t)fNrStrips-nuIn)/(nuOut-nuIn);
160 if(inStrip==outStrip){
162 strips.push_back(PndLmdStrips(inStrip,path,Q));
171 Int_t nextIn = Int_t(nuIn+0.5+0.5*dir);
176 strips.push_back(PndLmdStrips(inStrip,path1,Q1));
181 Int_t prevOut = Int_t(nuOut+0.5+0.5*dir);
185 strips.push_back(PndLmdStrips(outStrip,path2,Q2));
190 nextIn = Int_t(nextIn-0.5+0.5*dir);
191 prevOut = Int_t(prevOut-0.5+0.5*dir);
192 for(Int_t
n = nextIn;
n != prevOut;
n +=Int_t(dir)){
194 strips.push_back(PndLmdStrips(
n,dPath,dQ));
215 std::vector<PndLmdStrips> strips = GetStrips(inx, iny, inz, outx, outy,outz,eLoss);
216 cout<<
" Number of strips initially fired :"<<strips.size()<<endl;
219 Double_t total_Q = ChargeFromEloss(eLoss);
222 Double_t nuIn = CalStripFromPoint(inx,iny);
223 Double_t nuOut= CalStripFromPoint(outx,outy);
228 Int_t inStrip = Int_t(nuIn);
229 Int_t outStrip = Int_t(nuOut);
232 Double_t dir = (nuIn<nuOut)? 1 : -1;
235 Double_t Path1 = (nuIn-inStrip) * fPitch;
236 Double_t Path2 = (nuOut-outStrip) * fPitch;
240 Int_t size = strips.size();
245 PndLmdStrips
strip = strips.at(0);
246 Double_t path_real = strip.GetPath();
248 Int_t index = strip.GetIndex();
253 Double_t charge1, charge2, dQ, dQR, dQL;
258 Double_t QL = ChargeDiffusion(0,Path1,path,dir,Q);
259 Double_t QR = Q - ChargeDiffusion(fPitch,Path1,path,dir,Q);
269 cout<<
"the QL was smeared by noise :"<<dQL<<endl;
270 cout<<
"the QR was smeared by noise :"<<dQR<<endl;
274 if(dQL<fThreshold && dQR<fThreshold){
277 strips.push_back(PndLmdStrips(index,path_real,dQ));
286 charge1 = ChargeDiffusion((i-1)*fPitch,Path1,path,dir,Q);
287 charge2 = ChargeDiffusion(i*fPitch,Path1,path,dir,Q);
288 q_head = charge2 - charge1;
290 dQ = AddNoise(q_head);
292 strips.push_back(PndLmdStrips(
id,0,dQ));
297 charge1 = ChargeDiffusion(j*fPitch,Path1,path,dir,Q);
298 charge2 = ChargeDiffusion((j+1)*fPitch,Path1,path,dir,Q);
299 q_tail = charge2 - charge1;
301 dQ = AddNoise(q_tail);
303 strips.push_back(PndLmdStrips(
id,0,dQ));
307 Double_t restQ = ChargeDiffusion(fPitch,Path1,path,dir,Q) - ChargeDiffusion(0,Path1,path,dir,Q);
308 strips.push_back(PndLmdStrips(index,path_real,AddNoise(restQ)));
316 std::vector<PndLmdStrips> strip_head;
317 std::vector<PndLmdStrips> strip_tail;
318 std::vector<PndLmdStrips> strip_middle;
319 PndLmdStrips str_head;
320 PndLmdStrips str_tail;
321 PndLmdStrips str_middle;
323 if(inStrip<outStrip){
324 str_head = strips.at(0);
325 str_tail = strips.at(size-1);
327 tail_Path = Path2+(size-1)*fPitch;
329 for(Int_t
i = 1;
i<size-1;
i++)
330 {str_middle = strips.at(
i);}
332 str_tail = strips.at(0);
333 str_head = strips.at(size-1);
335 tail_Path = Path1+(size-1)*fPitch;
337 for(Int_t
i = size-2;
i>0;
i--)
338 {str_middle = strips.at(
i);}
341 strips.erase(strips.begin(),strips.begin()+size);
344 Int_t index_head = str_head.GetIndex();
345 Double_t path_head = str_head.GetPath();
348 Int_t index_tail = str_tail.GetIndex();
349 Double_t path_tail = str_tail.GetPath();
358 Double_t dq_head = ChargeDiffusion(0,head_Path,path,dir,total_Q);
359 Double_t dq_tail = total_Q- ChargeDiffusion(size*fPitch,tail_Path,path,(-1)*dir,total_Q);
360 Double_t q_head = ChargeDiffusion(fPitch,head_Path,path,dir,total_Q);
361 Double_t q_tail = ChargeDiffusion(size*fPitch,tail_Path,path,(-1)*dir,total_Q)
362 -ChargeDiffusion((size-1)*fPitch,tail_Path,path,(-1)*dir,total_Q);
364 Double_t dQ_head = AddNoise(dq_head);
365 Double_t dQ_tail = AddNoise(dq_tail);
369 if(dQ_head>fThreshold) {
371 strip_head.push_back(PndLmdStrips(
id,0,dQ_head));}
372 if(Q_head>fThreshold) {
374 strip_head.push_back(PndLmdStrips(
id,path_head,Q_head));}
375 strips.insert(strips.begin(),strip_head.begin(),strip_head.end());
377 if(dQ_tail>fThreshold) {
379 strip_tail.push_back(PndLmdStrips(
id,0,dQ_tail));}
380 if(Q_tail>fThreshold) {
382 strip_head.push_back(PndLmdStrips(
id,path_tail,Q_tail));}
383 strips.insert(strips.end(),strip_tail.begin(),strip_tail.end());
387 charge1 = ChargeDiffusion(
i*fPitch,head_Path,path,dir,total_Q);
388 charge2 = ChargeDiffusion((
i+1)*fPitch,head_Path,path,dir,total_Q);
389 dQ = charge2 - charge1;
390 std::vector<PndLmdStrips>::iterator iter_ii=strip_middle.begin();
391 id = iter_ii->GetIndex();
392 ipath = iter_ii->GetPath();
393 if(dQ>fThreshold) strip_middle.push_back(PndLmdStrips(
id,ipath,dQ));
396 strips.insert(strips.begin()+strip_head.size(),strip_middle.begin(),strip_middle.begin()+strip_middle.size());
409 {
return ((x-fAnchor.X())*fOrthoDir.X()+(y-fAnchor.Y())*fOrthoDir.Y())/fPitch;}
412 {
return (
std::sqrt((x-fAnchor.X())*(x-fAnchor.X())+(y-fAnchor.Y())*(y-fAnchor.Y()))-30.0)/fPitch;}
415 {
return stripNr%fNrFEChannels;}
418 {
return stripNr/fNrFEChannels;}
423 Double_t smeared = fRNG->Gaus(charge,fNoise);
439 Delta = 0.5 *(1+TMath::Erf((u-a)/fSigma*
std::sqrt(2.)));
444 for(
Double_t da=a;da<=a+path;da+=Npath)
446 Delta = 0.5*(1+TMath::Erf((u-da)/fSigma*
std::sqrt(2.)));
454 Delta = 0.5*(1+TMath::Erf((u-da)/fSigma*
std::sqrt(2.)));
465 std::cout<<
"-I- PndLmdCalStrip Info :"<<std::endl;
466 std::cout<<
" pitch = "<<fPitch*10000.<<
" um"<<std::endl;
467 std::cout<<
" orientation angle = "<<fOrient/
TMath::Pi()*180.<<
" deg"<<std::endl;
468 std::cout<<
" nr of strips = "<<fNrStrips<<std::endl;
469 std::cout<<
" nr of channels per FE = "<<fNrFEChannels<<std::endl;
470 std::cout<<
" nr of frontends = "<<fNrStrips/fNrFEChannels<<std::endl;
471 std::cout<<
" anchor point = ("<<fAnchor.X()<<
","<<fAnchor.Y()<<
")"<<std::endl;
472 std::cout<<
" strip-direction vector = ("<<fStripDir.X()<<
","<<fStripDir.Y()<<
")"<<std::endl;
friend F32vec4 cos(const F32vec4 &a)
Double_t GetNoise() const
Int_t GetNrRightFe() const
Double_t ChargeDiffusion(Double_t u, Double_t a, Double_t path, Double_t dir, Double_t Q)
friend F32vec4 sqrt(const F32vec4 &a)
Double_t GetGausSigma() const
friend F32vec4 sin(const F32vec4 &a)
Double_t AddNoise(Double_t charge)
std::vector< PndLmdStrips > DigiStripFromPoint(Double_t inx, Double_t iny, Double_t inz, Double_t outx, Double_t outy, Double_t outz, Double_t eloss)
std::vector< PndLmdStrips > GetStrips(Double_t inx, Double_t iny, Double_t inz, Double_t outx, Double_t outy, Double_t outz, Double_t eloss)
Double_t GetThreshold() const
Double_t ChargeFromEloss(Double_t eloss) const
Double_t CalCurveStripFromPoint(Double_t x, Double_t y)
TVector2 GetRightAnchor() const
Int_t CalFeFromStrip(Int_t stripNr)
friend F32vec4 fabs(const F32vec4 &a)
Double_t GetRightOrient() const
Double_t GetLeftPitch() const
Int_t GetNrFeChannels() const
Int_t CalChannelFromStrip(Int_t stripNr)
Int_t GetNrLeftFe() const
Double_t GetLeftOrient() const
TVector2 GetLeftAnchor() const
Double_t CalStripFromPoint(Double_t x, Double_t y)
Double_t GetRightPitch() const