KaliVeda
Toolkit for HIC analysis
KVSignal.cpp
1 //Created by KVClassFactory on Mon Dec 22 15:46:46 2014
2 //Author: ,,,
3 
4 #include "KVSignal.h"
5 #include "KVString.h"
6 #include "TMath.h"
7 #include "KVDigitalFilter.h"
8 #include "KVDataSet.h"
9 #include "KVEnv.h"
10 
11 #include "TMatrixD.h"
12 #include "TMatrixF.h"
13 #include "TClass.h"
14 
15 #define LOG2 (double)6.93147180559945286e-01
16 # define M_PI 3.14159265358979323846 /* pi */
17 
19 
20 // BEGIN_HTML <!--
22 /* -->
23 <h2>KVSignal</h2>
24 <h4>Base class for FAZIA signal processing</h4>
25 <!-- */
26 // --> END_HTML
27 //
28 // SIGNAL NAME
29 // ===========
30 // KVSignal::GetName() returns the name of the signal as defined in FAZIA
31 // raw data, e.g. "T1-Q3-B001-QH1"
32 //
33 // SIGNAL TYPE
34 // ===========
35 // KVSignal::GetType() returns one of: "QH1", "QL1", "Q2", "Q3", "I1", "I2"
37 
38 
39 
41 void KVSignal::init()
42 {
43  fPSAIsDone = kFALSE;
44  fChannel = kUNKDT;
45  fYmin = fYmax = 0;
46  fAmplitude = 0;
47  fRiseTime = 0;
48  fIMax = 0;
49  fTMax = 0;
50  fBaseLine = 0;
51  fSigmaBase = 0;
52 
53  fChannelWidth = -1;
54  fChannelWidthInt = -1;
55  fFirstBL = -1;
56  fLastBL = -1;
57  fTauRC = -1;
58  fTrapRiseTime = -1;
59  fTrapFlatTop = -1;
60  fSemiGaussSigma = -1;
61  fWithPoleZeroCorrection = kFALSE;
62  fWithInterpolation = kFALSE;
63  fMinimumValueForAmplitude = 0;
64 
65  //DeduceFromName();
66  ResetIndexes();
67 
68  SetDefaultValues();
69 }
70 
71 
72 
74 
76 {
77  fIndex = 0;
78  fDetName = "";
80 }
81 
82 
83 
86 
88 {
89  // Default constructor
90  init();
91 }
92 
93 
94 
95 
98 
99 KVSignal::KVSignal(const char* name, const char* title) : TGraph()
100 {
101  // Write your code here
102  SetNameTitle(name, title);
103  init();
104 }
105 
106 
107 
108 
110 
111 KVSignal::KVSignal(const TString& name, const TString& title) : TGraph()
112 {
113  SetNameTitle(name, title);
114  init();
115 
116 }
117 
118 
119 
122 
124 {
125  // Destructor
126 }
127 
128 
129 
131 
133 {
134  KVSignal* sig = 0;
135  TClass* cl = TClass::GetClass(Form("KV%s", type));
136  if (cl) {
137  sig = (KVSignal*)cl->New();
138  sig->SetData(this->GetN(), this->GetX(), this->GetY());
139  sig->LoadPSAParameters();
140  }
141  return sig;
142 }
143 
144 
145 
147 
149 {
150  if (fLastBL > GetN()) return kFALSE;
151  else return kTRUE;
152 }
153 
154 
155 
156 
157 
167 
169 {
170  // This method copies the current state of 'this' object into 'obj'
171  // You should add here any member variables, for example:
172  // (supposing a member variable KVSignal::fToto)
173  // CastedObj.fToto = fToto;
174  // or
175  // CastedObj.SetToto( GetToto() );
176 
177  //TGraph::Copy((TGraph&)obj);
178  //KVSignal& CastedObj = (KVSignal&)obj;
179 }
180 
181 
182 
184 
186 {
187  return (GetN() > fLastBL + 10);
188 }
189 
190 
191 
193 
195 {
196  fPSAIsDone = kFALSE;
197  TGraph::Set(n);
198  fAdc.Set(GetN());
199 
200 }
201 
202 
203 
205 
207 {
208  Set(nn);
209  if (nn == 0) {
210  Info("SetData", "called with points number=%d", nn);
211  return;
212  }
213  Int_t np = 0;
214  fYmin = fYmax = yy[np];
215  SetPoint(np, xx[np], yy[np]);
216  for (np = 1; np < nn; np += 1) {
217  SetPoint(np, xx[np], yy[np]);
218  if (yy[np] < fYmin) fYmin = yy[np];
219  if (yy[np] > fYmax) fYmax = yy[np];
220  }
221  SetADCData();
222 }
223 
224 
225 
227 
229 {
230 
232  fAdc.Set(GetN());
233  for (int ii = 0; ii < GetN(); ii++) fAdc.AddAt(fY[ii], ii);
234 
235 }
236 
237 
238 
239 
241 
243 {
244  TString stit = GetTitle();
245  stit.ToUpper();
246 
247  KVString tmp = GetName();
248  KVString part = "";
249  if (tmp.BeginsWith("B")) {
250  tmp.Begin("-");
251  part = tmp.Next();
252  part.ReplaceAll("B", "");
253  Int_t bb = part.Atoi();
254  part = tmp.Next();
255  part.ReplaceAll("Q", "");
256  Int_t qq = part.Atoi();
257  part = tmp.Next();
258  part.ReplaceAll("T", "");
259  Int_t tt = part.Atoi();
260  fType = tmp.Next();
261 
262  fIndex = 100 * bb + 10 * qq + tt;
263  fDetName.Form("%s-%d", stit.Data(), fIndex);
264  }
265  else if (tmp.BeginsWith("RUTH")) {
266  //Old FAZIA telescope denomination
267  // Rutherford telescope case for FAZIASYM experiment
268  tmp.Begin("-");
269  part = tmp.Next();
270  fType = tmp.Next();
271 
272  TString stit = GetTitle();
273  stit.ToUpper();
274 
275  fDetName.Form("%s-RUTH", stit.Data());
276  }
277 }
278 
279 
280 
286 
288 {
289  //methods used to identify to from which detector/telescope/quartet/block
290  //the signal is associated
291  //it is assumed that the name of the signal is defined as it is in the raw data
292  //generated by fazia_reader which convert raw acquisition file in raw ROOT files
293 
294  ResetIndexes();
295  KVString tmp = GetName();
296  KVString part = "";
297  if (tmp.BeginsWith("B") || tmp.BeginsWith("RUTH")) {
298  //Old FAZIA telescope denomination
299  //Info("DeduceFromName","Old format %s",GetName());
301  }
302  else {
303 
304  if (tmp.GetNValues("-") == 2) {
305  //new general denomination
306  //in KaliVeda :
307  // signal name : [signal_type]-[index]
308  // if index is digit (number), it is the telescope number : 100*b+10*q+t
309  // if index is a string of character, we kept it as it is
310  // for example RUTH for the FAZIASYM dataset
311  TString stit = GetTitle();
312  stit.ToUpper();
313  //new format
314  //Info("DeduceFromName", "New format %s", GetName());
315  tmp.Begin("-");
316  fType = tmp.Next();
317  KVString ss = tmp.Next();
318 
319  if (ss.IsDigit()) {
320  fIndex = ss.Atoi();
321  fDetName.Form("%s-%d", stit.Data(), fIndex);
322  }
323  else {
324  fDetName.Form("%s-%s", stit.Data(), ss.Data());
325  }
326  }
327  else {
328  Warning("DeduceFromName", "Unkown format %s", GetName());
329  }
330  }
331 
332 
333 }
334 
335 
336 
339 
341 {
342 
343  //DeduceFromName has to be called before
344 
345  Double_t lval = -1;
346  KVString spar;
347  spar.Form("%s.%s", GetType(), parname);
348  if (gDataSet) lval = gDataSet->GetDataSetEnv(spar.Data(), 0.0);
349  else lval = gEnv->GetValue(spar.Data(), 0.0);
350  return lval;
351 
352 }
353 
354 
355 
357 
359 {
360  for (Int_t ii = 0; ii < par->GetParameters()->GetNpar(); ii += 1) {
361  TString nameat(par->GetParameters()->GetNameAt(ii));
362  if (nameat == "BaseLineLength") SetBaseLineLength(par->GetParameters()->GetDoubleValue(ii));
363  else if (nameat == "ChannelWidth") SetChannelWidth(par->GetParameters()->GetDoubleValue(ii));
364  else if (nameat == "ShaperRiseTime") SetShaperRiseTime(par->GetParameters()->GetDoubleValue(ii));
365  else if (nameat == "ShaperFlatTop") SetShaperFlatTop(par->GetParameters()->GetDoubleValue(ii));
366  else if (nameat == "TauRC") SetTauRC(par->GetParameters()->GetDoubleValue(ii));
367  else if (nameat == "MinimumAmplitude") SetAmplitudeTriggerValue(par->GetParameters()->GetDoubleValue(ii));
368  else if (nameat == "InterpolatedChannelWidth") SetInterpolatedChannelWidth(par->GetParameters()->GetDoubleValue(ii));
369  else if (nameat == "Interpolation") SetInterpolation((par->GetParameters()->GetDoubleValue(ii) == 1));
370  else if (nameat == "PZCorrection") SetPoleZeroCorrection((par->GetParameters()->GetDoubleValue(ii) == 1));
371  else {
372  if (nameat == "Detector" || nameat == "Signal" || nameat == "RunRange") {
373 
374  }
375  else {
376  Warning("UpdatePSAParameter", "Not supported PSA parameter : %d %s\n", ii, nameat.Data());
377  }
378  }
379  }
380 }
381 
382 
383 
385 
387 {
388  Info("LoadPSAParameters", "To be defined in child class");
389 }
390 
391 
392 
395 
397 {
398  //To be defined in child class
399 }
400 
401 
402 
404 
406 {
407  Info("TreateSignal", "To be defined in child class");
408 }
409 
410 
411 
413 
415 {
416  Info("Print", "\nName: %s - Title: %s", GetName(), GetTitle());
417  if (fDetName != "") {
418  printf("\tAssociated to the detector %s\n", fDetName.Data());
419  }
420  printf("################\nPSA parameters:\n");
421  printf("\tBaseLine: length: %lf first: %lf\n", GetBLLength(), GetBLFirst());
422  printf("\tChannelWidth: %lf\n", GetChannelWidth());
423  printf("\tTauRC: %lf\n", GetTauRC());
424  printf("\tShaperRiseTime: %lf\n", GetShaperRiseTime());
425  printf("\tShaperFlatTop: %lf\n", GetShaperFlatTop());
426  printf("\tWith Interpolation: %d", Int_t(fWithInterpolation));
427  if (fWithInterpolation)
428  printf(" %1.2lf", GetInterpolatedChannelWidth());
429  printf("\n");
430  printf("\tWith PoleZero correction: %d\n", Int_t(fWithPoleZeroCorrection));
431 
432 }
433 
434 
435 
436 
438 
440 {
441  Double_t xx, yy;
442  Int_t np = 0;
443  GetPoint(np++, xx, yy);
444  fYmin = fYmax = yy;
445 
446  for (np = 1; np < GetN(); np += 1) {
447  GetPoint(np, xx, yy);
448  if (yy < fYmin) fYmin = yy;
449  if (yy > fYmax) fYmax = yy;
450  }
451 }
452 
453 
454 
456 
458 {
459  Double_t x0, x1, y0, y1;
460 
461  GetPoint(0, x0, y0);
462  GetPoint(1, x1, y1);
463 
464  Double_t actual_width = x1 - x0;
465  return ((actual_width == GetChannelWidth()));
466 }
467 
468 
469 
470 
472 
474 {
475  Double_t xx, yy;
476  for (Int_t ii = 0; ii < GetN(); ii += 1) {
477  GetPoint(ii, xx, yy);
478  SetPoint(ii, ii * newwidth, yy);
479  }
480 }
481 
482 
483 
484 
485 
489 
491 {
492  //compute mean value of the signal and the rms between
493  // limits defined by fFirstBL and fLastBL
494  if (fLastBL >= GetN()) {
495  fBaseLine = -1;
496  fSigmaBase = -1;
497  return -1;
498  }
500  return fBaseLine;
501 }
502 
503 
504 
507 
509 {
510  // calculate the time during which the signal is higher than th*fAmplitude
511  if (fAmplitude <= 0) {
512  SetADCData();
514  }
515 
516  Multiply(-1);
517  fAmplitude *= -1;
518  Double_t qstart = FindTzeroCFDCubic(th, 3);
520  Double_t qend = FindTzeroCFDCubic(th, 3);
522  Multiply(-1);
523  fAmplitude *= -1;
524 
525  //printf("qstart=%lf - qend=%lf\n",qstart,qend);
526  if (qend < qstart || qstart <= 0 || qend <= 0)
527  return -1;
528  //Double_t deltat = GetN() * fChannelWidth - qstart - qend;
529  Double_t deltat = ((GetN() * fChannelWidth - qend) - qstart);
530  return deltat;
531 }
532 
533 
534 
537 
539 {
540  // calculate the time during which the signal is higher than th*fAmplitude
541  if (fAmplitude <= 0) {
542  SetADCData();
544  }
545 
546  Multiply(-1);
547  fAmplitude *= -1;
548 
549  Double_t qstart = FindTzeroCFDCubic(threshold, 3);
550 
551  Multiply(-1);
552  fAmplitude *= -1;
553 
554  return qstart;
555 }
556 
557 
558 
562 
564 {
565  //same as ComputeBaseLine method but made on the end of the signal
566  //in the same length as for the base line
567  if ((fLastBL - fFirstBL) >= GetN()) {
568  fEndLine = -1;
569  fSigmaEnd = -1;
570  }
572  return fEndLine;
573 }
574 
575 
576 
579 
581 {
582  //ComputeBaseLine and ComputeEndLine methods have to be called before
583 
585  return kTRUE;
586  return kFALSE;
587 }
588 
589 
590 
592 
594 {
595 
596  Add(-1.*ComputeBaseLine());
598 
599 }
600 
601 
602 
604 
606 {
607  TArrayF copy(fAdc);
608  Int_t np = fAdc.GetSize();
609 
610  for (int i = 0; i < np; i++) fAdc.AddAt(copy.GetAt(np - i - 1), i);
611 }
612 
613 
614 
617 
619 {
620  //Compute and return the absolute value of the signal amplitude
621  int i_max = 0;
622  for (int i = 0; i < fAdc.GetSize(); i++) {
623  if (fAdc.At(i_max) < fAdc.At(i)) i_max = i;
624  }
625  fIMax = i_max;
627  fAmplitude = fAdc.At(i_max);
628  return fAmplitude;
629 }
630 
631 
632 
634 
636 {
637  Multiply(-1);
638  fAmplitude *= -1;
639  Double_t qt70 = FindTzeroCFDCubic(0.7, 3);
640  Double_t qt20 = FindTzeroCFDCubic_rev(0.2, qt70, 3);
641  Double_t qtrise72 = qt70 - qt20;
642  Multiply(-1);
643  fAmplitude *= -1;
644  fRiseTime = qtrise72;
645  return fRiseTime;
646 }
647 
648 
649 
652 
654 {
655  //time of passage of the threshold
656 
657  Double_t rtime = GetRiseTime();
658  if (!(tdelay < (1 - threshold)*rtime))
659  return -1;
660 
661  rtime *= 2;
662  double time = GetAmplitude() / ((1 - threshold) * (rtime / tdelay));
663  Multiply(-1);
664  double re = FindTzeroLeadingEdgeCubic(time, 3);
665  Multiply(-1);
666 
667  return re;
668 
669 }
670 
671 
672 
674 
675 double KVSignal::FindTzeroLeadingEdgeCubic(double LEVEL, int Nrecurr)
676 {
677 
678  int i = 0;
679  float* data = fAdc.GetArray();
680  for (; i < fAdc.GetSize() - 1; i++)
681  if (-data[i] > LEVEL && -data[i + 1] > LEVEL) //to skip noise.
682  break;
683  if (i >= fAdc.GetSize() - 3) return -1;
684  i--;
685 
686  return CubicInterpolation(data, i, - LEVEL, Nrecurr);
687 }
688 
689 
690 
691 //----------------------------------
693 //----------------------------------
694 
695 
703 {
704  //compute mean value and sigma values
705  //between "start" point included and "stop" point excluded
706  //for example :
707  // ComputeMeanAndSigma(0,50,mean,sigma)
708  // compute values for the first 50 points
709  //
710  Int_t np = 0;
711  Double_t xx;
712  mean = 0;
713  Double_t mean2 = 0;
714  if (stop > GetN()) {
715  Warning("ComputeMeanAndSigma",
716  "stop position greater than number of samples %d/%d, set stop to %d", GetN(), stop, GetN());
717  stop = GetN();
718  }
719  if (start < 0) {
720  Warning("ComputeMeanAndSigma",
721  "start position unrealistic %d, set start to 0", start);
722  start = 0;
723  }
724 
725  for (Int_t ii = start; ii < stop; ii += 1) {
726  xx = fAdc.At(ii);
727  mean += xx;
728  mean2 += xx * xx;
729  np += 1;
730  }
731 
732  if (np == 0) {
733  Error("ComputeMeanAndSigma", "values cannot be computed with 0 sample");
734  return kFALSE;
735  }
736  mean /= np;
737  mean2 /= np;
738  sigma = TMath::Sqrt(mean2 - mean * mean);
739  return kTRUE;
740 }
741 
742 
743 //----------------------------------
745 //----------------------------------
746 
747 
755 {
756  //
757  //assuming that X axis is in time unit (ms)
758  //divide the X values by the fChannelWidth value which allow to set the Xaxis in time units
759  //compute mean value and sigma values
760  //between "start" and "stop" point included
761  //
763 }
764 
765 
766 // double KVSignal::FindMedia(double tsta, double tsto)
767 // {
768 // Info("FindMedia(double tsta, double tsto)","Appel ...");
769 // int n1 = (int)(tsta / fChannelWidth); // Non molto preciso, ma tant'e'...
770 // int n2 = (int)(tsto / fChannelWidth);
771 //
772 // return FindMedia(n1, n2);
773 // }
774 //
775 // double KVSignal::FindMedia(int tsta, int tsto)
776 // {
777 // // Calcolo della media nel tratto tra tsta e tsto.
778 // // NOTA: questo ha senso solo se il segnale e' piatto in quella regione!!
779 //
780 // int n1 = (int)(tsta);
781 // int n2 = (int)(tsto);
782 //
783 // int N = n2 - n1 + 1;
784 // //// printf("n1=%d, n2=%d, n=%d, fChannelWidth=%e \n",n1, n2, N, fChannelWidth);
785 // if (n1 < 0 || n1 >= fAdc.GetSize() ||
786 // n2 < n1 || n2 >= fAdc.GetSize() ||
787 // N <= 0 || N >= fAdc.GetSize()) {
788 // printf("--- FSignal::FindMedia: tsta=%d, tsto=%d ?? (%d)\n", tsta, tsto, fAdc.GetSize());
789 // return -1E10;//non cambiare, serve a FindSigma2!!
790 // }
791 // double media = 0;
792 // for (int i = n1; i <= n2; i++)
793 // media += fAdc.At(i);
794 //
795 // media /= N;
796 // return media;
797 // }
798 //
799 // double KVSignal::FindSigma2(double tsta, double tsto)
800 // {
801 // // Calcolo della varianza nel tratto tra tsta e tsto.
802 // // NOTA: questo ha senso solo se il segnale e' piatto in quella regione!!
803 //
804 // int n1 = (int)(tsta / fChannelWidth); // Non molto preciso, ma tant'e'...
805 // int n2 = (int)(tsto / fChannelWidth);
806 //
807 // return FindSigma2(n1, n2);
808 // }
809 //
810 // double KVSignal::FindSigma2(int tsta, int tsto)
811 // {
812 // // Calcolo della varianza nel tratto tra tsta e tsto.
813 // // NOTA: questo ha senso solo se il segnale e' piatto in quella regione!!
814 //
815 // int n1 = (int)(tsta);
816 // int n2 = (int)(tsto);
817 //
818 // int N = n2 - n1 + 1;
819 // double sigma2 = 0;
820 // double media = FindMedia(tsta, tsto);
821 // if (media == -1E10) {
822 // printf("--- FSignal::FindSigma2(double tsta, double tsto) ---: errore nella media\n");
823 // return -1;
824 // }
825 //
826 // for (int i = n1; i <= n2; i++)
827 // sigma2 += (media - fAdc.At(i)) * (media - fAdc.At(i));
828 //
829 // sigma2 /= N-1;
830 //
831 // return sigma2;
832 // }
833 
834 
835 
837 
838 void KVSignal::FIR_ApplyTrapezoidal(double trise, double tflat) // trise=sqrt(12)*tausha di CR-RC^4 se tflat=trise/2
839 {
840  if (tflat < 0) tflat = trise / 2.;
841  int irise = (int)(1e3 * trise / fChannelWidth);
842  int iflat = (int)(1e3 * tflat / fChannelWidth);
843 
844 // Info("FIR_ApplyTrapezoidal","irise %d iflat %d chw %lf",irise,iflat, fChannelWidth);
845 
846  TArrayF sorig(fAdc);
847  float* data = fAdc.GetArray();
848  float* datao = sorig.GetArray();
849  int N = sorig.GetSize();
850 
851  // 1
852  for (int i = irise; i < N; i++) data[i] -= datao[i - irise];
853  for (int i = irise + iflat; i < N; i++) data[i] -= datao[i - irise - iflat];
854  for (int i = 2 * irise + iflat; i < N; i++) data[i] += datao[i - 2 * irise - iflat];
855 
856  // normalizzazione
857  double amp = 1e3 * trise / fChannelWidth;
858  data[0] /= amp;
859  for (int i = 1; i < N; i++) data[i] = data[i] / amp + data[i - 1];
860 }
861 
862 
863 
864 //Double_t KVSignal::GetAmplitude()
865 //{
866 // //Compute and return the absolute value of the signal amplitude
867 // int i_max=0;
868 // for(int i=0;i<fAdc.GetSize();i++)
869 // {
870 // if(fAdc.At(i_max) < fAdc.At(i) ) i_max = i;
871 // }
872 // fIMax = i_max;
873 // fTMax = fIMax*fChannelWidth;
874 // fAmplitude = fAdc.At(i_max);
875 // return fAmplitude;
876 //}
877 
878 
879 
883 
884 Double_t KVSignal::FindTzeroCFDCubic(double level, int Nrecurr)
885 {
886  // recurr=1 means: linear + 1 approx
887  // recurr=0 == FindTzeroCFD
888  float* data = fAdc.GetArray();
889  int NSamples = fAdc.GetSize();
890  double fmax = level * fAmplitude;
891  /**** 1) ricerca del punto x2 tale che x2 e' il precedente di tcfd ****/
892  int x2 = 0;
893  for (; x2 < NSamples; x2++) if (data[x2] < fmax) break;
894  x2--;
895 
896  return CubicInterpolation(data, x2, fmax, Nrecurr);
897 }
898 
899 
900 /***************************************************************************************************/
901 
903 
904 inline unsigned int ReverseBits(unsigned int p_nIndex, unsigned int p_nBits)
905 {
906 
907  unsigned int i, rev;
908 
909  for (i = rev = 0; i < p_nBits; i++) {
910  rev = (rev << 1) | (p_nIndex & 1);
911  p_nIndex >>= 1;
912  }
913 
914  return rev;
915 
916 }
917 
918 
919 
920 /***************************************************************************************************/
921 
924 
925 void KVSignal::ApplyWindowing(int window_type) // 0: barlett, 1:hanning, 2:hamming, 3: blackman
926 {
927  // vedi pag. 468 oppenheim-shafer
928  int N = fAdc.GetSize() - 1;
929  switch (window_type) {
930  case 0:/*-------------------- BARLETT ----------------------*/
931  for (int n = 0; n <= N; n++)
932  fAdc.GetArray()[n] *= (n < N / 2 ? 2.*n / (double)N : 2. - 2.*n / (double)N);
933  break;
934  case 1:/*-------------------- HANNING ----------------------*/
935  for (int n = 0; n <= N; n++)
936  fAdc.GetArray()[n] *= 0.5 - 0.5 * cos(2 * M_PI * n / (double)N);
937  break;
938  case 2:/*-------------------- HAmmING ----------------------*/
939  for (int n = 0; n <= N; n++)
940  fAdc.GetArray()[n] *= 0.54 - 0.46 * cos(2 * M_PI * n / (double)N);
941  break;
942  case 3:/*-------------------- BLACKMAN --------------------*/
943  for (int n = 0; n <= N; n++)
944  fAdc.GetArray()[n] *= 0.42 - 0.5 * cos(2 * M_PI * n / (double)N) + 0.08 * cos(4 * M_PI * n / (double)N);
945  break;
946  default:
947  printf("ERROR in %s: windowtype %d not valid!\n", __PRETTY_FUNCTION__, window_type);
948  };
949 }
950 
951 
952 
953 
954 
955 /***************************************************************************************************/
956 
960 
961 int KVSignal::FFT(unsigned int p_nSamples, bool p_bInverseTransform,
962  double* p_lpRealIn, double* p_lpImagIn,
963  double* p_lpRealOut, double* p_lpImagOut)
964 {
965  // copiata e adattata da: http://www.codeproject.com/audio/waveInFFT.asp
966  // l'unico vettore che puo' essere NULL e' p_lpImagIn
967 
968  if (!p_lpRealIn || !p_lpRealOut || !p_lpImagOut) {
969  printf("ERROR in %s: NULL vectors!\n", __PRETTY_FUNCTION__);
970  return -1;
971  }
972 
973 
974  unsigned int NumBits;
975  unsigned int i, j, k, n;
976  unsigned int BlockSize, BlockEnd;
977 
978  double angle_numerator = 2.0 * M_PI;
979  double tr, ti;
980 
981  // if( !IsPowerOfTwo(p_nSamples) )
982  // {
983  // return;
984  // }
985  if (p_nSamples < 2 || p_nSamples & (p_nSamples - 1)) {
986  printf("ERROR in %s: %d not a power of two!\n", __PRETTY_FUNCTION__, p_nSamples);
987  return -1;
988  }
989 
990  if (p_bInverseTransform) angle_numerator = -angle_numerator;
991 
992  NumBits = 0; // NumberOfBitsNeeded ( p_nSamples );
993  for (NumBits = 0; ; NumBits++) {
994  if (p_nSamples & (1 << NumBits)) break;
995  }
996 
997  for (i = 0; i < p_nSamples; i++) {
998  j = ReverseBits(i, NumBits);
999  p_lpRealOut[j] = p_lpRealIn[i];
1000  p_lpImagOut[j] = (p_lpImagIn == NULL) ? 0.0 : p_lpImagIn[i];
1001  }
1002 
1003 
1004  BlockEnd = 1;
1005  for (BlockSize = 2; BlockSize <= p_nSamples; BlockSize <<= 1) {
1006  double delta_angle = angle_numerator / (double)BlockSize;
1007  double sm2 = sin(-2 * delta_angle);
1008  double sm1 = sin(-delta_angle);
1009  double cm2 = cos(-2 * delta_angle);
1010  double cm1 = cos(-delta_angle);
1011  double w = 2 * cm1;
1012  double ar[3], ai[3];
1013 
1014  for (i = 0; i < p_nSamples; i += BlockSize) {
1015 
1016  ar[2] = cm2;
1017  ar[1] = cm1;
1018 
1019  ai[2] = sm2;
1020  ai[1] = sm1;
1021 
1022  for (j = i, n = 0; n < BlockEnd; j++, n++) {
1023 
1024  ar[0] = w * ar[1] - ar[2];
1025  ar[2] = ar[1];
1026  ar[1] = ar[0];
1027 
1028  ai[0] = w * ai[1] - ai[2];
1029  ai[2] = ai[1];
1030  ai[1] = ai[0];
1031 
1032  k = j + BlockEnd;
1033  tr = ar[0] * p_lpRealOut[k] - ai[0] * p_lpImagOut[k];
1034  ti = ar[0] * p_lpImagOut[k] + ai[0] * p_lpRealOut[k];
1035 
1036  p_lpRealOut[k] = p_lpRealOut[j] - tr;
1037  p_lpImagOut[k] = p_lpImagOut[j] - ti;
1038 
1039  p_lpRealOut[j] += tr;
1040  p_lpImagOut[j] += ti;
1041 
1042  }
1043  }
1044 
1045  BlockEnd = BlockSize;
1046 
1047  }
1048 
1049 
1050  if (p_bInverseTransform) {
1051  double denom = (double)p_nSamples;
1052 
1053  for (i = 0; i < p_nSamples; i++) {
1054  p_lpRealOut[i] /= denom;
1055  p_lpImagOut[i] /= denom;
1056  }
1057  }
1058  return 0;
1059 }
1060 
1061 
1062 
1063 
1064 
1065 
1066 
1069 
1070 int KVSignal::FFT(bool p_bInverseTransform, double* p_lpRealOut, double* p_lpImagOut)
1071 {
1072  // returns the lenght of FFT( power of 2)
1073  static double* buffer = NULL;
1074  static int bufflen = 0;
1075  int NSA = fAdc.GetSize();
1076  int ibits = (int)ceil(log((double)NSA) / LOG2);
1077  NSA = 1 << ibits;
1078 
1079  if (buffer != NULL && bufflen < NSA) {
1080  delete [] buffer;
1081  buffer = NULL;
1082  }
1083 
1084 
1085  if (buffer == NULL) {
1086  bufflen = NSA;
1087  buffer = new double [NSA];
1088  }
1089  unsigned int N = fAdc.GetSize();
1090  float* data = fAdc.GetArray();
1091  for (unsigned int i = 0; i < N; i++)
1092  buffer[i] = data[i];
1093  // 0 padding
1094  memset(buffer + N, 0, (NSA - N)*sizeof(double));
1095  int r = FFT(NSA, p_bInverseTransform, buffer, NULL, p_lpRealOut, p_lpImagOut);
1096  if (r < 0) return r;
1097  return NSA;
1098 }
1099 
1100 
1102 
1103 TH1* KVSignal::FFT2Histo(int output, TH1* hh) // 0 modulo, 1 modulo db (normalized), 2, re, 3 im
1104 {
1105  unsigned int N = fAdc.GetSize();
1106  double* re = new double [2 * N];
1107  double* im = new double [2 * N];
1108  int NFFT = FFT(0, re, im);
1109  if (NFFT < 0) {
1110  printf("ERROR in %s: FFT returned %d!\n", __PRETTY_FUNCTION__, NFFT);
1111  delete [] re;
1112  delete [] im;
1113  return NULL;
1114  }
1115  int NF = NFFT / 2;
1116  TH1* h = 0;
1117  if (!hh) h = new TH1F("hfft", "FFT of FSignal", NF, 0, 1. / fChannelWidth * 1000 / 2);
1118  else h = hh;
1119 
1120  h->SetStats(kFALSE);
1121  for (int i = 0; i < NF; i++) {
1122  switch (output) {
1123  case 0: // modulo
1124  h->Fill(h->GetBinCenter(i + 1), sqrt(re[i]*re[i] + im[i]*im[i]));
1125  break;
1126  case 1: // modulo db
1127  h->Fill(h->GetBinCenter(i + 1), log(sqrt(re[i]*re[i] + im[i]*im[i])) * 8.68588963806503500e+00); // numero=20./log(10.)
1128  break;
1129  case 2:
1130  h->Fill(h->GetBinCenter(i + 1), re[i]);
1131  break;
1132  case 3:
1133  h->Fill(h->GetBinCenter(i + 1), im[i]);
1134  break;
1135  default:
1136  printf("ERROR in %s: output=%d not valid!!\n", __PRETTY_FUNCTION__, output);
1137  break;
1138  }
1139  }
1140 // h->GetXaxis()->SetTitle("Frequency");
1141  delete [] re;
1142  delete [] im;
1143 
1144  if (output != 1) return h;
1145  /*** normalizzazione a 0 db ****/
1146  int imax = 0;
1147  for (int i = 1; i < NF; i++)
1148  if (h->GetBinContent(i + 1) > h->GetBinContent(imax + 1))
1149  imax = i;
1150  double dbmax = h->GetBinContent(imax + 1);
1151  for (int i = 0; i < NF; i++)
1152  h->SetBinContent(i + 1, h->GetBinContent(i + 1) - dbmax);
1153  h->GetYaxis()->SetTitle("Modulo (dB)");
1154  return h;
1155 }
1156 
1157 
1161 
1162 Double_t KVSignal::CubicInterpolation(float* data, int x2, double fmax, int Nrecurr)
1163 {
1164  /*
1165  NOTA: tutti i conti fatti con i tempi in "canali". aggiungero' il *fChannelWidth
1166  solo nel return.
1167  */
1168  /**** 2) normal CFD ***************************************************/
1169  double xi0 = (fmax - data[x2]) / (data[x2 + 1] - data[x2]);
1170  if (Nrecurr <= 0) return fChannelWidth * (x2 + xi0);
1171 
1172  /**** 3) approx successive. *******************************************/
1173  // scrivo il polinomio come a3*xi**3+a2*xi**2+a1*xi+a0
1174  // dove xi=tcfd-x2 (ovvero 0<xi<1)
1175  // con maple:
1176  // 3
1177  // (1/2 y2 - 1/6 y1 + 1/6 y4 - 1/2 y3) xi
1178  //
1179  // 2
1180  // + (-y2 + 1/2 y3 + 1/2 y1) xi
1181  //
1182  // + (- 1/2 y2 - 1/6 y4 + y3 - 1/3 y1) xi + y2
1183 
1184  double a3 = 0.5 * data[x2] - (1. / 6.) * data[x2 - 1] + (1. / 6.) * data[x2 + 2] - 0.5 * data[x2 + 1];
1185  double a2 = (-data[x2] + 0.5 * data[x2 + 1] + 0.5 * data[x2 - 1]);
1186  double a1 = (- 0.5 * data[x2] - 1. / 6. *data[x2 + 2] + data[x2 + 1] - 1. / 3.* data[x2 - 1]);
1187  double a0 = data[x2];
1188  double xi = xi0;
1189  for (int rec = 0; rec < Nrecurr; rec++) {
1190  xi += (fmax - a0 - a1 * xi - a2 * xi * xi - a3 * xi * xi * xi) / (a1 + 2 * a2 * xi + 3 * a3 * xi * xi);
1191  }
1192  return fChannelWidth * (x2 + xi);
1193 }
1194 
1195 
1196 
1197 
1199 
1200 double KVSignal::GetDataInter(double t)
1201 {
1202  if (fAdc.GetSize() <= 0) return 1E10;
1203 
1204  int n = (int)(floor(t / fChannelWidth));
1205  if (n <= 0) return fAdc.At(0);
1206  if (n > fAdc.GetSize() - 2) return fAdc.At(fAdc.GetSize() - 1);
1207  if (n * fChannelWidth == t) return fAdc.At(n);
1208  double y1 = fAdc.At(n);
1209  double y2 = fAdc.At(n + 1); //quello prima e quello dopo.
1210  double x1 = fChannelWidth * n;
1211 
1212  return (t - x1) / fChannelWidth * (y2 - y1) + y1;
1213 }
1214 
1215 
1216 
1218 
1220 {
1221  int x2 = (int)(t / fChannelWidth);
1222  if (x2 < 1 || x2 > fAdc.GetSize() - 2) return GetDataInter(t);
1223  float* data = fAdc.GetArray();
1224  /***** CUT & PASTE DA CubicInterpolation *****/
1225 
1226  double a3 = 0.5 * data[x2] - (1. / 6.) * data[x2 - 1] + (1. / 6.) * data[x2 + 2] - 0.5 * data[x2 + 1];
1227  double a2 = (-data[x2] + 0.5 * data[x2 + 1] + 0.5 * data[x2 - 1]);
1228  double a1 = (- 0.5 * data[x2] - 1. / 6. *data[x2 + 2] + data[x2 + 1] - 1. / 3.* data[x2 - 1]);
1229  double a0 = data[x2];
1230  double xi = (t / fChannelWidth - x2);
1231  return a3 * xi * xi * xi + a2 * xi * xi + a1 * xi + a0;
1232 }
1233 
1234 
1235 /***********************************************/
1236 
1239 
1241 {
1242  // see HSIEH S.HOU IEEE Trans. Acoustic Speech, vol. ASSP-26, NO.6, DECEMBER 1978
1244  Double_t xk = floor(t / h) * h;
1245  int xk_index = (int)(t / h);
1246  Double_t s = (t - xk) / h;
1247 
1248  float* data = fAdc.GetArray();
1249  int N = fAdc.GetSize();
1250  int dimensione = 18; //dimensione della matrice dei campioni.!!!!deve essere pari!!!!
1251  float cm1, cNm1;
1252 
1253 
1254  TMatrixD e(dimensione, dimensione);
1255  TArrayD data_e(dimensione * dimensione);
1256  for (int k = 0, i = 0; i < dimensione; i++) {
1257  data_e[k] = 4.;
1258  if ((k + 1) < pow(dimensione, 2)) data_e[k + 1] = 1.;
1259  if ((k - 1) > 0) data_e[k - 1] = 1.;
1260  k += dimensione + 1;
1261  }
1262  e.SetMatrixArray(data_e.GetArray());
1263  e *= 1. / 6 / h;
1264  e.Invert();
1265 
1266  double dati_b[] = { -1, 3, -3, 1, 3, -6, 3, 0, -3, 0, 3, 0, 1, 4, 1, 0};
1267  TMatrixD delta(4, 4, dati_b);
1268 
1269 
1270  TMatrixF samples(dimensione, 1);
1271  TMatrixF coeff(dimensione, 1);
1272  TMatrixF b(4, 1);
1273  TMatrixF coefficienti(4, 1);
1274 
1275  if (xk_index < (dimensione / 2 - 1)) {
1276  samples.SetMatrixArray(data);//prendiamo i dati a partire dal primo
1277  }
1278  else if (xk_index > (N - dimensione / 2 - 1)) {
1279  samples.SetMatrixArray(data + N - dimensione); //prendiamo 18 dati partendo dalla fine
1280  }
1281  else {
1282  samples.SetMatrixArray(data + xk_index - (dimensione / 2 - 1)); //perche l'interp deve avvenire tra i campioni centrali della matrice
1283  }
1284  float* samples_interp = samples.GetMatrixArray();
1285 
1286  // coeff=e*samples;
1287  coeff.Mult(e, samples);
1288  float* ck = coeff.GetMatrixArray();
1289 
1290  if (xk_index < (dimensione / 2 - 1)) {
1291  if (xk_index == 0) {
1292  cm1 = (*samples_interp) * 6 * h - ((*ck) * 4 + (*(ck + 1)));
1293  float caso_zero[4] = {cm1, *ck, *(ck + 1), *(ck + 2)};
1294  coefficienti.SetMatrixArray(caso_zero);
1295  }
1296  else coefficienti.SetMatrixArray(ck + xk_index - 1);
1297  }
1298  else if (xk_index > (N - dimensione / 2 - 1)) {
1299  if (xk_index == N - 2) {
1300  cNm1 = (*(samples_interp + dimensione - 1)) * 6 * h - (*(ck + dimensione - 1) * 4 + (*(ck + dimensione - 2)));
1301  float casoN[4] = {*(ck + dimensione - 3), *(ck + dimensione - 2), *(ck + dimensione - 1), cNm1};
1302  coefficienti.SetMatrixArray(casoN);
1303  }
1304  else coefficienti.SetMatrixArray(ck + dimensione - (N - xk_index + 1));
1305  }
1306  else {
1307  coefficienti.SetMatrixArray(ck + (dimensione / 2 - 2));
1308  }
1309 
1310  // b=delta*coefficienti;
1311  b.Mult(delta, coefficienti);
1312  float* b_interp = b.GetMatrixArray();
1313  float a0 = *b_interp;
1314  float a1 = *(b_interp + 1);
1315  float a2 = *(b_interp + 2);
1316  float a3 = *(b_interp + 3);
1317 
1318  return (1. / 6 / h * (a3 + a2 * s + a1 * s * s + a0 * s * s * s));
1319 }
1320 
1321 
1322 
1323 /***********************************************/
1324 
1326 
1328 {
1329  const int Nsa = fAdc.GetSize();
1330  const double tau = fChannelWidth;
1331 
1332  fChannelWidthInt = taufinal;
1333  TArrayF interpo;
1334  interpo.Set((int)(Nsa * tau / taufinal));
1335  int nlast = interpo.GetSize() - (int)(3 * tau / taufinal);
1336  if (nlast <= 0) return;
1337 
1338  for (int i = 0; i < interpo.GetSize(); i++) interpo.AddAt(GetDataCubicSpline(i * taufinal), i);
1339  fAdc.Set(0);
1340  fAdc.Set(interpo.GetSize());
1341  for (int i = 0; i < interpo.GetSize(); i++) fAdc.AddAt(interpo.At(i), i);
1342  for (int i = nlast; i < interpo.GetSize(); i++) fAdc.AddAt(interpo.At(nlast), i);
1343 
1344 }
1345 
1346 /***********************************************/
1347 
1349 
1351 {
1353 }
1354 
1355 
1356 
1357 
1358 /***********************************************/
1359 
1361 
1362 void KVSignal::BuildCubicSignal(double taufinal)
1363 {
1364  const int Nsa = fAdc.GetSize();
1365  const double tau = fChannelWidth;
1366 
1367  fChannelWidthInt = taufinal;
1368  TArrayF interpo;
1369  interpo.Set((int)(Nsa * tau / taufinal));
1370  int nlast = interpo.GetSize() - (int)(3 * tau / taufinal);
1371  if (nlast <= 0) return;
1372 
1373  for (int i = 0; i < interpo.GetSize(); i++) interpo.AddAt(GetDataInterCubic(i * taufinal), i);
1374  fAdc.Set(0);
1375  fAdc.Set(interpo.GetSize());
1376  for (int i = 0; i < nlast; i++) fAdc.AddAt(interpo.At(i), i);
1377  for (int i = nlast; i < interpo.GetSize(); i++) fAdc.AddAt(interpo.At(nlast), i);
1378 
1379 }
1380 
1381 /***********************************************/
1382 
1384 
1386 {
1388 }
1389 
1390 
1391 /***********************************************/
1392 
1394 
1395 void KVSignal::BuildSmoothingSplineSignal(double taufinal, double l, int nbits)
1396 {
1397  const int Nsa = fAdc.GetSize();
1398  const double tau = fChannelWidth;
1399 
1400  KVSignal coeff;
1401  ApplyModifications(&coeff);
1402  coeff.SetADCData();
1403  if (coeff.FIR_ApplySmoothingSpline(l, nbits) != 0) return;
1404 
1405  fChannelWidthInt = taufinal;
1406  TArrayF interpo;
1407  interpo.Set((int)(Nsa * tau / taufinal));
1408  int nlast = interpo.GetSize() - (int)(3 * tau);
1409  if (nlast <= 0) return;
1410 
1411  for (int i = 0; i < interpo.GetSize() - (int)(53 * tau / taufinal); i++) interpo.AddAt(coeff.GetDataSmoothingSplineLTI(i * taufinal), i);
1412  fAdc.Set(0);
1413  fAdc.Set(interpo.GetSize());
1414  for (int i = 0; i < nlast; i++) fAdc.AddAt(interpo.At(i), i);
1415  for (int i = nlast; i < interpo.GetSize(); i++) fAdc.AddAt(interpo.At(nlast), i);
1416 
1417 }
1418 
1419 /***********************************************/
1420 
1422 
1424 {
1426 }
1427 
1428 /***********************************************/
1429 
1430 
1435 
1436 int KVSignal::FIR_ApplySmoothingSpline(double l, int nbits)
1437 {
1438  // This method is never called with nbits>2, therefore nmax=50 ALWAYS
1439  // and dynamic arrays xvec & yvec can safely be of fixed size
1440  // If ever we want to use nbits>2, this will have to be changed
1441 
1442  if (l < 0.1) return -1;
1443  int i;
1444  double x0 = ApplyNewton(l, 1000);
1445  double r = sqrt(x0);
1446  double a = (1 - 24 * l) / (6 * l);
1447  double cphi = -a * r / (2 * (r * r + 1));
1448  if ((cphi < -1) || (cphi > 1) || (l < 0.1)) {
1449  printf("Error Aborting on FIR_ApplySmoothingSpline\n");
1450  return -1;
1451  }
1452  double sphi = sqrt(1 - cphi * cphi);
1453  double Re = sqrt(x0) * cphi;
1454  double Im = sqrt(x0) * sphi;
1455  double a1, a2, b1, b2, t;
1456  t = 4 * Re * Re * (x0 - 1) / (x0 + 1) + 1 - x0 * x0;
1457  b2 = 1 / (l * t);
1458  a2 = -2 * Re * x0 * b2 / (1 + x0);
1459  b1 = -x0 * x0 * b2;
1460  a1 = -a2;
1461  double czr, czi;
1462  czr = a1 / 2;
1463  czi = (-a1 * Re - b1) / (2 * Im);
1464  double phib, phiz;
1465  phiz = atan2(sphi, cphi);
1466  phib = atan2(czi, czr);
1467  double roB;
1468  roB = sqrt(czr * czr + czi * czi);
1469  double roZ = sqrt(x0);
1470  int nfloat = 0;
1471  int nmax(50);
1472  double imax, fmax;
1473  if (nbits > 2) {
1474  //Determination of best notation
1475  //1 bit always for the sign
1476  //#integer bit depends on output evaluated in 0//
1477  //#fixed to 0, l>0.1
1478  nfloat = nbits - 1;
1479  //1 represented as 2^(nfloats)...//
1480  imax = ((nbits + 1) * log(2) + log(roB)) / log(roZ) - 1.;
1481  nmax = floor(imax);
1482  do {
1483  fmax = std::abs(-2 * roB * cos(phib - (nmax + 1) * phiz) / pow(roZ, nmax + 1));
1484  if (fmax * pow(2, nfloat + 1) < 1) nmax--;
1485  }
1486  while (fmax * pow(2, nfloat + 1) < 1);
1487  }
1488  double* xvec = new double[2 * nmax + 1];
1489  double* yvec = new double[2 * nmax + 1];
1490  if (nbits > 2) {
1491  for (i = 0; i <= nmax; i++) {
1492  yvec[nmax + i] = yvec[nmax - i] = 0;
1493  xvec[nmax + i] = xvec[nmax - i] = ((double)floor(-2 * roB * cos(phib - (i + 1) * phiz) / pow(roZ, i + 1) * pow(2, nfloat) + 0.5)) / pow(2, nfloat);
1494  }
1495  }
1496  else {
1497  for (i = 0; i <= nmax; i++) {
1498  yvec[nmax + i] = yvec[nmax - i] = 0;
1499  xvec[nmax + i] = xvec[nmax - i] = -2 * roB * cos(phib - (i + 1) * phiz) / pow(roZ, i + 1);
1500  }
1501  }
1502  FIR_ApplyRecursiveFilter(0, 2 * nmax + 1, xvec, yvec, 0);
1503  ShiftLeft(nmax * fChannelWidth);
1504  delete [] xvec;
1505  delete [] yvec;
1506  return 0;
1507 }
1508 
1509 
1510 /***********************************************/
1511 
1513 
1514 double KVSignal::ApplyNewton(double l, double X0)
1515 {
1516  double a = (1 - 24 * l) / (6 * l);
1517  double b = (4 + 36 * l) / (6 * l);
1518  double A = 2 - b;
1519  double B = 2 + a * a - 2 * b;
1520  Double_t x1, x0, x2, x3;
1521  double der, fx;
1522  double fxold1;
1523  x0 = X0;
1524  x1 = X0;
1525  x2 = x0;
1526  fx = pow(x1, 4) + A * pow(x1, 3) + B * pow(x1, 2) + A * x1 + 1;
1527  fxold1 = fx + 1;
1528  int fexit = 0;
1529  int loopcount = 0;
1530  do {
1531  der = 4 * pow(x1, 3) + 3 * A * pow(x1, 2) + 2 * B * x1 + A;
1532  x3 = x2;
1533  x2 = x0;
1534  x0 = x1;
1535  x1 = x0 - fx / der;
1536  if (x1 == x2) {
1537  x1 = (x1 + x0) / 2.;
1538  loopcount++;
1539  }
1540  else if (x1 == x3) {
1541  x1 = (x1 + x0 + x2) / 3.;
1542  loopcount++;
1543  }
1544  if ((x1 == x0) && (x1 == x2) && (x1 == x3)) fexit = 1;
1545  if (loopcount == 100) fexit = 1;
1546  fxold1 = fx;
1547  fx = pow(x1, 4) + A * pow(x1, 3) + B * pow(x1, 2) + A * x1 + 1;
1548  }
1549  while (((fx > 0.000000001) || (fxold1 != fx)) && (fexit == 0));
1550  return x1;
1551 }
1552 
1553 /***********************************************/
1554 
1556 
1558 {
1559  double tsamp = t / fChannelWidth;
1560  int n0 = floor(tsamp);
1561  double tres = tsamp - n0;
1562  double res = 0;
1563  if (n0 == 0)return 0;
1564  else {
1565  for (int i = -1; i < 3; i++) {
1566  res += fAdc.At(n0 + i) * EvalCubicSpline(tres - i);
1567  }
1568  }
1569  return res;
1570 }
1571 
1572 /***********************************************/
1573 
1575 
1577 {
1578  double ax = TMath::Abs(X);
1579  if (ax > 2) return 0;
1580  else if (ax > 1) return pow(2 - ax, 3) / 6.;
1581  else return pow(ax, 3) / 2. - ax * ax + 2. / 3.;
1582 }
1583 
1584 /***********************************************/
1585 
1589 
1590 double KVSignal::FindTzeroCFDCubic_rev(double level, double tend, int Nrecurr)
1591 {
1592  // recurr=1 means: linear + 1 approx
1593  // recurr=0 == FindTzeroCFD
1594  /**************************************/
1595  float* data = fAdc.GetArray();
1596  int NSamples = fAdc.GetSize();
1597  double fmax = level * fAmplitude;
1598  /**** 1) ricerca del punto x2 tale che x2 e' il precedente di tcfd ****/
1599  int x2 = (int)(tend / fChannelWidth);
1600  if (x2 <= 0 || x2 >= NSamples) return -1;
1601  for (; x2 > 0 ; x2--)
1602  if (data[x2] > fmax)
1603  break;
1604  // x2--;
1605  return CubicInterpolation(data, x2, fmax, Nrecurr);
1606 }
1607 
1608 
1609 
1611 
1612 void KVSignal::FIR_ApplySemigaus(double tau_usec)
1613 {
1614  FIR_ApplyRCLowPass(tau_usec);
1615  FIR_ApplyRCLowPass(tau_usec);
1616  FIR_ApplyRCLowPass(tau_usec);
1617  FIR_ApplyRCLowPass(tau_usec);
1618 
1619  FIR_ApplyRCHighPass(tau_usec);
1620 
1621  Multiply(1. / (32. / 3.*TMath::Exp(-4.))); // normalizzazione
1622 }
1623 
1624 
1625 
1626 
1630 
1631 void KVSignal::FIR_ApplyRCLowPass(double time_usec, int reverse)
1632 {
1633  // f=1/(2*pi*tau) se tau[ns] allora f->[GHz]
1634  // fsampling=1/fChannelWidth [GHz]
1635 #define DUEPI 6.28318530717958623
1636  // printf("fChannelWidth=%f\n",fChannelWidth);
1637  double f = 1. / (DUEPI * time_usec * 1000.) * fChannelWidth;
1638  double x = TMath::Exp(-DUEPI * f);
1639  double a0 = 1 - x;
1640  double b = x;
1641  double a = 0;
1642  // printf("f=%f, x=%f\n",x,f);
1643  FIR_ApplyRecursiveFilter(a0, 1, &a, &b, reverse);
1644 }
1645 
1646 
1647 
1652 
1653 void KVSignal::FIR_ApplyRCHighPass(double time_usec, int reverse)
1654 {
1655  // f=1/(2*pi*tau) se tau[ns] allora f->[GHz]
1656  // fsampling=1/fChannelWidth [GHz]
1657 
1658  // printf("fChannelWidth=%f\n",fChannelWidth);
1659  double f = 1. / (DUEPI * time_usec * 1000.) * fChannelWidth;
1660  double x = TMath::Exp(-DUEPI * f);
1661  double a0 = (1 + x) / 2.;
1662  double a1 = -(1 + x) / 2.;
1663  double b1 = x;
1664  // printf("f=%f, x=%f\n",x,f);
1665  FIR_ApplyRecursiveFilter(a0, 1, &a1, &b1, reverse);
1666 }
1667 
1668 #undef DUEPI
1669 
1670 
1673 
1674 void KVSignal::FIR_ApplyRecursiveFilter(double a0, int N, double* a, double* b, int reverse)
1675 {
1676  // signal will be: y[n]=a0*x[n]+sum a[k] x[k] + sum b[k] y[k]
1677  int NSamples = fAdc.GetSize();
1678  double* datay = new double[NSamples];
1679  float* datax = fAdc.GetArray();
1680  // memset(datay, 0, NSamples*sizeof(float)); //azzero l'array.
1681  /*----------------------------------------------*/
1682  int i = 0, k = 0;
1683  switch (reverse) {
1684  case 0:// direct
1685  for (i = 0; i < N; i++) { // primo loop su Npunti
1686  datay[i] = a0 * datax[i];
1687  for (k = 0; k < i; k++)
1688  datay[i] += a[k] * datax[i - k - 1] + b[k] * datay[i - k - 1];
1689  }
1690  for (i = N; i < NSamples; i++) { //secondo loop. cambia l'indice interno.
1691  datay[i] = a0 * datax[i];
1692  for (k = 0; k < N; k++)
1693  datay[i] += a[k] * datax[i - k - 1] + b[k] * datay[i - k - 1];
1694  }
1695  break; // end of direct
1696  case 1: //reverse: cut & paste from direct and NSamples-1-
1697  for (i = 0; i < N; i++) { // primo loop su Npunti
1698  datay[NSamples - 1 - i] = a0 * datax[NSamples - 1 - i];
1699  for (k = 0; k < i; k++)
1700  datay[NSamples - 1 - i] += a[k] * datax[NSamples - 1 - (i - k - 1)]
1701  + b[k] * datay[NSamples - 1 - (i - k - 1)];
1702  }
1703  for (i = N; i < NSamples; i++) { //secondo loop. cambia l'indice interno.
1704  datay[NSamples - 1 - i] = a0 * datax[NSamples - 1 - i];
1705  for (k = 0; k < N; k++)
1706  datay[NSamples - 1 - i] += a[k] * datax[NSamples - 1 - (i - k - 1)]
1707  + b[k] * datay[NSamples - 1 - (i - k - 1)];
1708  }
1709  break;
1710  case -1: // bidirectional
1711  FIR_ApplyRecursiveFilter(a0, N, a, b, 0);
1712  FIR_ApplyRecursiveFilter(a0, N, a, b, 1);
1713  delete [] datay;
1714  return;
1715  default:
1716  printf("ERROR in %s: reverse=%d not supported\n", __PRETTY_FUNCTION__, reverse);
1717  }// end of reverse switch.
1718  /*----------------------------------------------*/
1719  // void *memcpy(void *dest, const void *src, size_t n);
1721  for (int i = 0; i < NSamples; i++)
1722  datax[i] = (float)datay[i];
1723  delete [] datay;
1724 }
1725 
1726 
1727 
1729 
1730 void KVSignal::FIR_ApplyMovingAverage(int npoints) // causal moving average
1731 {
1732  TArrayF sorig = fAdc;
1733  float* data = fAdc.GetArray();
1734  float* datao = sorig.GetArray();
1735 
1736  for (int n = npoints; n < GetNSamples(); n++)
1737  data[n] = data[n - 1] + (datao[n] - datao[n - npoints]) / npoints;
1738  for (int n = 0; n < npoints; n++) data[n] = data[npoints]; // first npoints samples are put equal to first good value
1739 
1740 }
1741 
1742 
1743 
1744 
1746 
1748 {
1749 
1750  KVDigitalFilter deconv_pa1, lp1, int1;
1753  deconv_pa1 = KVDigitalFilter::CombineStagesMany(&lp1, &int1);
1754 
1755  deconv_pa1.ApplyTo(this);
1756  Multiply(fChannelWidth / tauRC / 1000.);
1757 }
1758 
1759 
1760 
1763 
1765 {
1766 // Info("ApplyModifications","called with %d",((newSignal==0)?0:1));
1767  if (!newSignal) newSignal = this;
1768 
1769  Int_t nn = fAdc.GetSize();
1770  if (nsa > 0 && nsa < nn) nn = nsa;
1771  if (newSignal->InheritsFrom("KVSignal"))((KVSignal*)newSignal)->SetChannelWidth(fChannelWidthInt);
1772  for (int ii = 0; ii < nn; ii++) newSignal->SetPoint(ii, ii * fChannelWidthInt, fAdc.At(ii));
1773 }
1774 
1775 
1776 
1777 
1779 
1781 {
1782  for (int i = 0; i < fAdc.GetSize(); i++) fAdc.AddAt(fAdc.At(i)*fact, i);
1783 }
1784 
1785 
1786 
1788 
1790 {
1791  for (int i = 0; i < fAdc.GetSize(); i++) fAdc.AddAt(fAdc.At(i) + fact, i);
1792 }
1793 
1794 
1795 /***************************************************************************/
1796 
1798 
1799 void KVSignal::ShiftLeft(double tshift)//shift is in ns
1800 {
1801  if (fAdc.GetSize() <= 0) return;
1802  if (tshift < 0) {
1803  ShiftRight(-tshift);
1804  return;
1805  }
1806 
1807  int shift = (int)floor(tshift / fChannelWidth);
1808  if (shift == 0) return;
1809  for (int i = 0; i < fAdc.GetSize() - shift; i++)
1810  fAdc.AddAt(fAdc.At(i + shift), i);
1811  fAdc.Set(fAdc.GetSize() - shift);
1812 }
1813 
1814 /***************************************************************************/
1815 
1817 
1818 void KVSignal::ShiftRight(double tshift)//shift is in ns
1819 {
1820  if (fAdc.GetSize() <= 0) return;
1821  if (tshift < 0) {
1822  ShiftLeft(-tshift);
1823  return;
1824  }
1825 
1826  int shift = (int)floor(tshift / fChannelWidth);
1827  if (shift == 0) return;
1828 
1829  fAdc.Set(fAdc.GetSize() + shift);
1830  for (int i = fAdc.GetSize() - 1; i >= shift; i--)
1831  fAdc.AddAt(fAdc.At(i - shift), i);
1832  for (int i = 0; i < shift; i++)
1833  fAdc.AddAt(fAdc.At(shift), i);
1834 }
1835 
1836 /***************************************************************************/
1837 
1839 
1841 {
1842  this->Draw();
1843  getchar();
1844 }
1845 
1846 
1847 
1850 
1851 KVSignal* KVSignal::MakeSignal(const char* sig_type)
1852 {
1853  // Create new KVSignal instance corresponding to sig_type
1854 
1855  TPluginHandler* ph = KVBase::LoadPlugin("KVSignal", sig_type);
1856  if (!ph) {
1857  ::Error("KVSignal::MakeSignal", "No plugin found for : %s", sig_type);
1858  return nullptr;
1859  }
1860  KVSignal* sig = (KVSignal*)ph->ExecPlugin(0);
1861  return sig;
1862 }
1863 
1864 
1865 
int Int_t
ROOT::R::TRInterface & r
#define f(i)
#define e(i)
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
const char Option_t
#define X(type, name)
R__EXTERN TEnv * gEnv
#define N
winID w
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t b
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char y1
char name[80]
char * Form(const char *fmt,...)
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Definition: KVBase.cpp:772
To store calibration parameters in a database ,.
KVNameValueList * GetParameters()
ValType GetDataSetEnv(const Char_t *type, const ValType &defval) const
Definition: KVDataSet.h:268
static KVDigitalFilter BuildRCLowPassDeconv(const double &tau_usec, const double &tau_clk)
void ApplyTo(double *data, const int N, int reverse=0) const
static KVDigitalFilter BuildIntegrator(const double &tau_clk)
static KVDigitalFilter CombineStagesMany(const KVDigitalFilter *f1, const KVDigitalFilter *f2, const KVDigitalFilter *f3=NULL, const KVDigitalFilter *f4=NULL, const KVDigitalFilter *f5=NULL, const KVDigitalFilter *f6=NULL, const KVDigitalFilter *f7=NULL, const KVDigitalFilter *f8=NULL, const KVDigitalFilter *f9=NULL, const KVDigitalFilter *f10=NULL)
se ne devi combinare + di 1 IN CASCATA!
Double_t GetDoubleValue(const Char_t *name) const
const Char_t * GetNameAt(Int_t idx) const
void SetTauRC(Int_t taurc)
Definition: KVSignal.h:296
Double_t ComputeCFDThreshold(Double_t threshold=0.5)
calculate the time during which the signal is higher than th*fAmplitude
Definition: KVSignal.cpp:538
void FIR_ApplyMovingAverage(int npoints)
Definition: KVSignal.cpp:1730
Double_t CubicInterpolation(float *data, int x2, double fmax, int Nrecurr)
Definition: KVSignal.cpp:1162
void Add(Double_t fact)
Definition: KVSignal.cpp:1789
const Char_t * GetType() const
Definition: KVSignal.h:98
Bool_t IsLongEnough() const
Definition: KVSignal.cpp:185
TString fType
string to identify the signal type : "QH1", "I2" etc ...
Definition: KVSignal.h:31
void ChangeChannelWidth(Double_t newwidth)
Definition: KVSignal.cpp:473
Double_t GetShaperRiseTime() const
Definition: KVSignal.h:267
virtual void UpdatePSAParameter(KVDBParameterList *par)
Definition: KVSignal.cpp:358
virtual Double_t ComputeDuration(Double_t th=0.2)
calculate the time during which the signal is higher than th*fAmplitude
Definition: KVSignal.cpp:508
static int FFT(unsigned int p_nSamples, bool p_bInverseTransform, double *p_lpRealIn, double *p_lpImagIn, double *p_lpRealOut, double *p_lpImagOut)
Definition: KVSignal.cpp:961
void SetInterpolation(Bool_t with=kTRUE)
Definition: KVSignal.h:308
void ApplyModifications(TGraph *newSignal=0, Int_t nsa=-1)
apply modifications of fAdc to the original signal
Definition: KVSignal.cpp:1764
virtual void RemoveBaseLine()
Definition: KVSignal.cpp:593
Double_t fEndLine
mean value of the signal line at the end
Definition: KVSignal.h:44
Double_t fYmax
raw min/max of the signal
Definition: KVSignal.h:41
void SetShaperRiseTime(Double_t rise)
Definition: KVSignal.h:259
void FIR_ApplyRCLowPass(double time_usec, int reverse=0)
Definition: KVSignal.cpp:1631
Double_t fAmplitude
results of signal treatement
Definition: KVSignal.h:37
double FindTzeroCFDCubic_rev(double level, double tend, int Nrecurr)
Definition: KVSignal.cpp:1590
virtual void TreateSignal()
Definition: KVSignal.cpp:405
virtual Double_t ComputeBaseLine()
Definition: KVSignal.cpp:490
virtual void BuildCubicSplineSignal()
Definition: KVSignal.cpp:1350
void Set(Int_t n) override
Definition: KVSignal.cpp:194
Bool_t ComputeMeanAndSigma(Int_t start, Int_t stop, Double_t &mean, Double_t &sigma)
compute mean value and rms of a subset of samples
Definition: KVSignal.cpp:692
Double_t GetPSAParameter(const Char_t *parname)
DeduceFromName has to be called before.
Definition: KVSignal.cpp:340
virtual double EvalCubicSpline(double X)
Definition: KVSignal.cpp:1576
Double_t fSigmaBase
base line rms
Definition: KVSignal.h:43
virtual double GetDataInter(double t)
Definition: KVSignal.cpp:1200
void SetData(Int_t nn, Double_t *xx, Double_t *yy)
operation on data arrays
Definition: KVSignal.cpp:206
void SetInterpolatedChannelWidth(double width)
Definition: KVSignal.h:312
virtual double GetDataCubicSpline(double t)
see HSIEH S.HOU IEEE Trans. Acoustic Speech, vol. ASSP-26, NO.6, DECEMBER 1978
Definition: KVSignal.cpp:1240
void ApplyWindowing(int window_type=3)
fast fourier transform and windowing of the signal (modify only fAdc)
Definition: KVSignal.cpp:925
Int_t GetNSamples() const
Definition: KVSignal.h:184
virtual void LoadPSAParameters()
Definition: KVSignal.cpp:386
TString fDetName
name of the detector, the signal is linked to, needed to find it in the KVMultiDetector
Definition: KVSignal.h:30
Int_t fFPGAOutputNumbers
ASsociated FPGA energy outputs.
Definition: KVSignal.h:33
Double_t GetAmplitude() const
Definition: KVSignal.h:246
void SetPoleZeroCorrection(Bool_t with=kTRUE)
Definition: KVSignal.h:292
Bool_t fWithInterpolation
use of interpolation or not
Definition: KVSignal.h:58
Double_t fChannelWidth
channel width in ns
Definition: KVSignal.h:50
Int_t fFirstBL
Definition: KVSignal.h:52
Double_t GetBLFirst() const
Definition: KVSignal.h:197
virtual bool IsOK()
Definition: KVSignal.cpp:148
Double_t fYmin
Definition: KVSignal.h:41
static KVSignal * MakeSignal(const char *sig_type)
Create new KVSignal instance corresponding to sig_type.
Definition: KVSignal.cpp:1851
void ShiftLeft(double)
---------------— OPERATORI ------------------—//
Definition: KVSignal.cpp:1799
Double_t fSigmaEnd
rms value of the signal line at the end
Definition: KVSignal.h:45
Double_t fBaseLine
base line mean value
Definition: KVSignal.h:42
Double_t ARC_CFD(Double_t threshold=0.3, Double_t tdelay=10)
Interpolations.
Definition: KVSignal.cpp:653
Double_t fChannelWidthInt
internal parameter channel width of interpolated signal in ns
Definition: KVSignal.h:64
void SetBaseLineLength(Int_t length, Int_t first=0)
Definition: KVSignal.h:192
Double_t fIMax
position of the maximum in channel
Definition: KVSignal.h:39
virtual double GetDataInterCubic(double t)
Definition: KVSignal.cpp:1219
Double_t ComputeAmplitude()
Compute and return the absolute value of the signal amplitude.
Definition: KVSignal.cpp:618
KVSignal()
Default constructor.
Definition: KVSignal.cpp:87
void Multiply(Double_t fact)
multiply the signal (modify only fAdc)
Definition: KVSignal.cpp:1780
virtual void BuildSmoothingSplineSignal()
Definition: KVSignal.cpp:1423
void init()
Definition: KVSignal.cpp:41
void FIR_ApplyRCHighPass(double time_usec, int reverse=0)
Definition: KVSignal.cpp:1653
void Copy(TObject &obj) const override
Definition: KVSignal.cpp:168
virtual double GetDataSmoothingSplineLTI(double t)
Definition: KVSignal.cpp:1557
void SetShaperFlatTop(Double_t flat)
Definition: KVSignal.h:263
int FIR_ApplySmoothingSpline(double l, int nbits=-1)
Definition: KVSignal.cpp:1436
Int_t fLastBL
first and last channel number to compute the base line
Definition: KVSignal.h:52
TArrayF fAdc
Definition: KVSignal.h:35
void TestDraw()
Definition: KVSignal.cpp:1840
void Print(Option_t *chopt="") const override
Definition: KVSignal.cpp:414
Bool_t IsFired()
ComputeBaseLine and ComputeEndLine methods have to be called before.
Definition: KVSignal.cpp:580
void SetADCData()
Definition: KVSignal.cpp:228
void SetChannelWidth(double width)
Definition: KVSignal.h:163
Int_t fIndex
index deduced from block, quartet and telescope numbering
Definition: KVSignal.h:27
Double_t GetBLLength() const
Definition: KVSignal.h:201
void DeduceFromName()
Definition: KVSignal.cpp:287
Double_t GetShaperFlatTop() const
Definition: KVSignal.h:271
Double_t ComputeRiseTime()
Definition: KVSignal.cpp:635
Double_t fTMax
position of the maximum in ns
Definition: KVSignal.h:40
Double_t GetInterpolatedChannelWidth() const
Definition: KVSignal.h:316
void FIR_ApplyTrapezoidal(double trise, double tflat)
different shapers (modify only fAdc)
Definition: KVSignal.cpp:838
virtual void SetDefaultValues()
To be defined in child class.
Definition: KVSignal.cpp:396
void ShiftRight(double)
Definition: KVSignal.cpp:1818
void FIR_ApplyRecursiveFilter(double a0, int N, double *a, double *b, int reverse)
signal will be: y[n]=a0*x[n]+sum a[k] x[k] + sum b[k] y[k]
Definition: KVSignal.cpp:1674
KVSignal * ConvertTo(const Char_t *type)
Definition: KVSignal.cpp:132
double ApplyNewton(double l, double x0)
Definition: KVSignal.cpp:1514
virtual void ComputeRawAmplitude(void)
Definition: KVSignal.cpp:439
Double_t FindTzeroCFDCubic(double level, int Nrecurr)
Definition: KVSignal.cpp:884
void FIR_ApplySemigaus(double tau_usec)
Definition: KVSignal.cpp:1612
Bool_t fWithPoleZeroCorrection
use or nor pole zero correction
Definition: KVSignal.h:57
double FindTzeroLeadingEdgeCubic(double LEVEL, int Nrecurr)
Definition: KVSignal.cpp:675
Double_t fRiseTime
rise time of the signal
Definition: KVSignal.h:38
void TreateOldSignalName()
Definition: KVSignal.cpp:242
Bool_t fPSAIsDone
indicate if PSA has been done
Definition: KVSignal.h:63
TH1 * FFT2Histo(int output, TH1 *hh=0)
Definition: KVSignal.cpp:1103
void PoleZeroSuppression(Double_t tauRC)
Definition: KVSignal.cpp:1747
virtual void BuildCubicSignal()
Definition: KVSignal.cpp:1385
void BuildReverseTimeSignal()
Definition: KVSignal.cpp:605
Double_t GetTauRC() const
Definition: KVSignal.h:300
Bool_t TestWidth() const
Definition: KVSignal.cpp:457
virtual ~KVSignal()
Destructor.
Definition: KVSignal.cpp:123
virtual Double_t ComputeEndLine()
Definition: KVSignal.cpp:563
Double_t GetRiseTime() const
Definition: KVSignal.h:237
void ResetIndexes()
Definition: KVSignal.cpp:75
Double_t GetChannelWidth() const
Definition: KVSignal.h:168
void SetAmplitudeTriggerValue(Double_t val)
Definition: KVSignal.h:343
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
void Begin(TString delim) const
Definition: KVString.cpp:565
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition: KVString.cpp:695
Int_t GetNValues(TString delim) const
Definition: KVString.cpp:886
Double_t * GetArray()
Float_t * GetArray()
Double_t GetAt(Int_t i) const override
Float_t At(Int_t i) const
void AddAt(Float_t c, Int_t i)
void Set(Int_t n) override
Int_t GetSize() const
static TClass * GetClass(Bool_t load=kTRUE, Bool_t silent=kFALSE)
virtual const char * GetValue(const char *name, const char *dflt) const
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Double_t * GetY() const
Int_t GetN() const
Double_t * fY
Double_t * GetX() const
void Draw(Option_t *chopt="") override
void SetNameTitle(const char *name="", const char *title="") override
virtual void Set(Int_t n)
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y) const
virtual Double_t GetBinCenter(Int_t bin) const
TAxis * GetYaxis()
virtual Int_t Fill(const char *name, Double_t w)
virtual void SetBinContent(Int_t bin, Double_t content)
virtual Double_t GetBinContent(Int_t bin) const
virtual void SetStats(Bool_t stats=kTRUE)
virtual TMatrixTBase< Element > & SetMatrixArray(const Element *data, Option_t *option="")
const Element * GetMatrixArray() const override
void Mult(const TMatrixT< Element > &a, const TMatrixT< Element > &b)
virtual void SetTitle(const char *title="")
const char * GetName() const override
const char * GetTitle() const override
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual Bool_t InheritsFrom(const char *classname) const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
Longptr_t ExecPlugin(int nargs)
Int_t Atoi() const
const char * Data() const
Bool_t IsDigit() const
void ToUpper()
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
void Form(const char *fmt,...)
TString & ReplaceAll(const char *s1, const char *s2)
Expr< UnaryOp< Sqrt< T >, SMatrix< T, D, D2, R >, T >, T, D, D2, R > sqrt(const SMatrix< T, D, D2, R > &rhs)
RVec< PromoteType< T > > cos(const RVec< T > &v)
RVec< PromoteType< T > > floor(const RVec< T > &v)
RVec< PromoteTypes< T0, T1 > > pow(const T0 &x, const RVec< T1 > &v)
RVec< PromoteType< T > > ceil(const RVec< T > &v)
RVec< PromoteType< T > > log(const RVec< T > &v)
RVec< PromoteTypes< T0, T1 > > atan2(const T0 &x, const RVec< T1 > &v)
RVec< PromoteType< T > > sin(const RVec< T > &v)
const Double_t sigma
Double_t x[n]
const Int_t n
TH1 * h
rec
start
Int_t Nint(T x)
Double_t Exp(Double_t x)
Double_t Sqrt(Double_t x)
Double_t Abs(Double_t d)
Double_t Max(Double_t a, Double_t b)
TLine l
TArc a
auto * tt
ClassImp(TPyArg)