GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ILLWatchers.C
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2010 by Olivier Stezowski *
3  * stezow(AT)ipnl.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
21 // Watcher definition
22 #include "ILLWatchers.h"
23 #include "DefaultKeyFactory.h"
24 
25 #include "TSystem.h"
26 #include "TH2.h"
27 #include "TLine.h"
28 #include "TMath.h"
29 #include "TGraphErrors.h"
30 
31 #include "TSpectrum.h"
32 #include "PeakCreator.h"
33 #include <iostream>
34 
35 using namespace ADF;
36 
38 
40 {
41  if ( ! Watcher::SetTrigger(trigger) ){
42  fFrame = 0x0;
43  return false;
44  }
45 
46  // set the unique frame to be watched
47  fFrame = GetTrigger()->GetInputSharedFP();
48 
49  if ( fFrame->GetFrame()->GetSignature().GetVersion().GetMinor() == 1 )
50  fIsEvent = true;
51 
52  NOMADEvent sub;
53  for (UInt_t i = 0; i < 100; i++)
54  fEvent.push_back(sub);
55 
56  return true;
57 }
58 
59 Bool_t BaseEXOILLWatcher::LoadConfig(const Char_t *fname)
60 {
61  return fMap.Load(fname);
62 }
63 
64 void BaseEXOILLWatcher::Exec(Option_t * option)
65 {
66  BufferIO &buf = ((RawFrame *)fFrame->GetFrame())->RawBuffer(); UIDKey *key = (UIDKey *)fFrame->GetFrame()->GetKey();
67 
68  // get number of sub-events
69  if ( fIsEvent )
70  fNbSubEvent = key->GetDataLength() / 10;
71  else
72  fNbSubEvent = 1;
73 
74  // get id, e from the frame and TS from the key
75  buf.SetOffset();
76 
77  fCurrentTS = key->GetUID();
78  //
79  fGEEvent.clear();
80  fACEvent.clear();
81  fLAEvent.clear();
82  for (UInt_t i = 0; i < fNbSubEvent; i++) {
83  if ( fIsEvent ) {
84  Int_t dts;
85  buf >> dts; fEvent[i].DTS = dts;
86  }
87  else
88  fEvent[i].DTS = 0L;
89 
90  buf >> fEvent[i].UID >> fEvent[i].E;
91 
92  fEvent[i].TS = fCurrentTS + fEvent[i].DTS;
93 
94  switch ( fMap.allDigitizer[fEvent[i].UID].Family ) {
95  case 0:
96  fGEEvent.push_back(&fEvent[i]);
97  break;
98  case 1:
99  fACEvent.push_back(&fEvent[i]);
100  break;
101  case 2:
102  fLAEvent.push_back(&fEvent[i]);
103  break;
104  default:
105  break;
106  }
107 // std::cout << " BaseExec " << fEvent[i].UID << " " << fCurrentTS << " " << fEvent[i].DTS << std::endl ;
108  }
109 }
110 
112 
113 DoEXOILLCalib::DoEXOILLCalib(const char *name, const char *title) :
114  BaseEXOILLWatcher(name,title),
115 // fTimelineUID(time_depth),
116  fTimelineUID(),
117  fTimeline(kMaxUShort,0UL),
118  fUIDDistri(0x0),
119  fFoldDistri(0x0),
120  fADCSpectra(),
121  fESpectra(),
122  fSigma(2.0),
123  fThreshold(0.05)
124 {
125  const Char_t *hname; TH1 *h;
126 
128 
129  fUIDDistri = MakeTH1<TH1F>("UID","Unique ID distribution", fMap.maxUID,0,fMap.maxUID);
130  TagOn(fUIDDistri);
131  fFoldDistri = MakeTH1<TH1F>("Fold","Fold distribution",20,0,20);
132  TagOn(fFoldDistri);
133 
134  fTimelineUID.resize(fMap.maxUID,0);
135 
136  for (Int_t i = 0; i < fMap.maxUID; i++ ) {
137 
138  if ( fMap.tsShift.At(i) ) {
139  hname = Form("ADC_%s",fMap.tsShift.At(i)->GetName());
140  h = MakeTH1<TH1F>(hname,"uncalibrated spectrum", 2*4096,0,2*4096);
141  fADCSpectra.Add(h);
142  TagOn(h);
143 
144  hname = Form("E_%s",fMap.tsShift.At(i)->GetName());
145  h = MakeTH1<TH1F>(hname,"calibrated spectrum", 2*4096,0,10000);
146  fESpectra.Add(h);
147 
148  hname = Form("TS_%s",fMap.tsShift.At(i)->GetName());
149  h = MakeTH2<TH2F>(hname,"TS alignment", fMap.maxUID,0,fMap.maxUID,400,-200,200);
150  fTSSpectra.Add(h);
151  }
152  else {
153  fADCSpectra.Add(0x0); fESpectra.Add(0x0); fTSSpectra.Add(0x0);
154  }
155  }
156 
157  }
158 }
159 
160 void DoEXOILLCalib::SearchParameters(Double_t sig, Double_t thre)
161 {
162  fSigma = sig; fThreshold = thre;
163 
164  // change also FWHM for calib
166  if ( f ) {
167  f->SetParameter(0,sig*2.35482);
168  }
169 }
170 
171 void DoEXOILLCalib::SaveMAP(const Char_t *fname, Option_t *opt)
172 {
173  fMap.Save(fname,opt);
174 }
175 
176 void DoEXOILLCalib::Exec(Option_t * option)
177 {
178  const Int_t time_depth_c = 0, time_depth_s = 0; // have to be even
179 
180  TH1 *h; TH2 *hh;
181 
183 
184 // printf("CALLED %d \n", fTimeline.size());
185  fFoldDistri->Fill(fNbSubEvent);
186 
187  for (UInt_t i = 0; i < fNbSubEvent; i++ ) {
188 
189  fUIDDistri->Fill(fEvent[i].UID);
190 
191  h = (TH1 *)fADCSpectra.At(fEvent[i].UID);
192  h->Fill(fEvent[i].E);
193  h = (TH1 *)fESpectra.At(fEvent[i].UID);
194  h->Fill( ((TF1 *)fMap.adcCalib.At(fEvent[i].UID))->Eval(fEvent[i].E) );
195 
196  // to do ... rates using
197  // fEvent[i].TS - fTimelineUID[fEvent[i].UID]
198 
199  fTimelineUID[fEvent[i].UID] = fEvent[i].TS;
200 
201  /*
202  if ( fTimelineUID.size() == time_depth ) {
203 // time_depth_c++;
204 // if ( time_depth_s == time_depth ) {
205 
206  Int_t ref = time_depth%2; hh = (TH2 *)fTSSpectra.At(fTimelineUID[ref].first);
207 
208  for (Int_t j = 0; j < ref ; j++ ) {
209  hh->Fill(fTimelineUID[j].first, fTimelineUID[ref].second - fTimelineUID[j].second );
210  }
211  for (Int_t j = ref + 1; j < time_depth ; j++ ) {
212  hh->Fill(fTimelineUID[j].first, -Float_t(fTimelineUID[j].second - fTimelineUID[ref].second) );
213  }
214  fTimelineUID.pop_front();
215  }
216 */
217 
218  if ( fTimeline.first != kMaxUShort ) {
219 
220  hh = (TH2 *)fTSSpectra.At(fTimeline.first);
221  hh->Fill(fEvent[i].UID, fCurrentTS - fTimeline.second);
222 
223  hh = (TH2 *)fTSSpectra.At(fEvent[i].UID);
224  hh->Fill(fTimeline.first, -Float_t(fCurrentTS - fTimeline.second));
225 
226 // std::cout << " Exec " << fEvent[i].UID << " " << fCurrentTS << " " << fEvent[i].DTS << std::endl ;
227 // std::cout << " Exec " << fTimeline.first << " " << fTimeline.second << std::endl ;
228 
229  }
230  fTimeline.first = fEvent[i].UID; fTimeline.second = fCurrentTS + fEvent[i].DTS;
231 
232  }
233 }
234 
235 /*
236 void DoEXOILLCalib::AlignTS(UInt_t which_ref, Option_t *opt)
237 {
238  TH1 *h; TH2 *hh;
239 
240  // the reference
241  hh = (TH2 *)fTSSpectra.At(which_ref);
242  if ( hh == 0x0 ) {
243  fLog << warning << " reference " << which_ref << " not known " << dolog;
244  return;
245  }
246  else std::cout << " Detector used for TS alignment " << hh->GetName() << std::endl;
247 
248  TCanvas *check = 0x0;
249  if ( gROOT->GetListOfCanvases()->FindObject("EXOILLCALIB") ) {
250  check = (TCanvas *)gROOT->GetListOfCanvases()->FindObject("EXOILLCALIB");
251  }
252  else check = new TCanvas("EXOILLCALIB","EXOILLCALIB");
253 
254  check->Draw();
255  check->cd();
256  hh->Draw("col");
257  //
258  TLine l; l.SetLineColor(kRed); l.SetLineWidth(2);
259  //
260  for (UInt_t i = 0u; i < fMap.maxUID; i++ ) {
261 
262  if ( i == which_ref )
263  continue;
264 
265  h = hh->ProjectionY("_py",i+1,i+2);
266 
267  if ( h ) {
268  h->SetDirectory(0);
269  if ( h->Integral() ) {
270  Int_t bin_to_center_on = h->GetMaximumBin();
271  Double_t val_to_center_on = h->GetBinCenter( bin_to_center_on ) ;
272  Int_t val_int_to_center_on = Int_t ( val_to_center_on + 0.5 );
273 
274  Double_t val_to_center_on = h->GetMean( ) ; Int_t val_int_to_center_on = Int_t ( val_to_center_on + 0.5 );
275 
276  l.DrawLine(i,val_int_to_center_on,i+1,val_int_to_center_on);
277 
278 
279  TParameter<Int_t> *tsoffset =
280  (TParameter<Int_t> *)fMap.tsShift.At(i);
281  tsoffset->SetVal(val_int_to_center_on);
282  std::cout << " DrawLine " << val_int_to_center_on << std::endl;
283  }
284  delete h;
285 
286  }
287  }
288 }
289 */
290 
291 
292 void DoEXOILLCalib::AlignTS(Option_t *opt, Option_t *algo)
293 {
294  TH1 *h; TH2 *hh = 0x0; TObject *obj; Int_t which_ref; TString option = opt, algo_used = algo; TObjArray alllines;
295 
296  // to collect lines in the current pad and avoid alllines to delete them
297  alllines.SetOwner(false);
298 
299  // look for the reference used to align TS spectra
300  if ( TVirtualPad::Pad() == 0x0 ) {
301  fLog << warning << " Display the matrix to be used for alignment first" << dolog;
302  return;
303  }
304  else {
305  // look for a bidim in the current pad that belongs to fTSSpectra
306  TIter next(TVirtualPad::Pad()->GetListOfPrimitives());
307  while ( (obj = next()) ) {
308  if ( obj->InheritsFrom("TH2") && fTSSpectra.FindObject(obj) ) {
309  hh = (TH2 *)obj;
310  which_ref = (UInt_t)fTSSpectra.IndexOf(obj);
311  }
312  if ( obj->InheritsFrom("TLine") )
313  alllines.Add(obj);
314  }
315  }
316  if ( hh == 0x0 ) {
317  fLog << warning << " Cannot find a TS matrix" << dolog;
318  return;
319  }
320  else std::cout << " Reference Detector used for TS alignment " << hh->GetName() << std::endl;
321 
322  //
323  TLine ld, *l; ld.SetLineColor(kRed); ld.SetLineWidth(2); Double_t val_to_center_on; Int_t val_int_to_center_on;
324  //
325  for (Int_t i = 0; i < fMap.maxUID; i++ ) {
326 
327  if ( i == which_ref ) {
328  TParameter<Int_t> *tsoffset =
329  (TParameter<Int_t> *)fMap.tsShift.At(i);
330  tsoffset->SetVal(0);
331  continue;
332  }
333 
334  h = hh->ProjectionY("_py",i+1,i+2);
335 
336  if ( h ) {
337  h->SetDirectory(0);
338  // check if a line exists covering the range. if yes, take it otherwise compute one using mean
339 
340  TParameter<Int_t> *tsoffset =
341  (TParameter<Int_t> *)fMap.tsShift.At(i);
342 
343  if ( h->Integral() ) {
344  TIter next(&alllines); l = 0x0;
345  while ( (obj = next()) ) {
346  if ( obj->InheritsFrom("TLine") ) {
347  l = (TLine *)obj;
348  if ( l->GetX1() >= i && l->GetX2() <= i+1 )
349  break;
350  l = 0x0;
351  }
352  }
353  if ( l == 0x0 ) {
354  if ( algo_used.Contains("mean") ) {
355  val_to_center_on = h->GetMean( );
356  if ( val_to_center_on < 0 )
357  val_int_to_center_on = Int_t ( val_to_center_on - 0.5 );
358  else
359  val_int_to_center_on = Int_t ( val_to_center_on + 0.5 );
360  }
361  else {
362  Int_t bin_to_center_on = h->GetMaximumBin(), nb_val_mean = 0; Double_t weight = 0.0;
363  val_to_center_on = 0;
364  for (Int_t k = bin_to_center_on - 2; k < bin_to_center_on + 3; k++) {
365  if ( k < 1 || k > h->GetNbinsX() )
366  continue;
367  weight += h->GetBinContent(k);
368  val_to_center_on += h->GetBinContent(k)*h->GetBinCenter(k);
369  }
370  if ( weight )
371  val_to_center_on /= weight;
372  else
373  val_to_center_on = h->GetMean();
374 
375  if ( val_to_center_on < 0 )
376  val_int_to_center_on = Int_t ( val_to_center_on - 0.5 );
377  else
378  val_int_to_center_on = Int_t ( val_to_center_on + 0.5 );
379  }
380 
381  l = ld.DrawLine(i+0.1,val_int_to_center_on,i+0.9,val_int_to_center_on);
382  std::cout << " DrawLine for Detector " << tsoffset->GetName() << " " << val_int_to_center_on << std::endl;
383  }
384  else {
385  val_to_center_on = l->GetY1();
386  if ( val_to_center_on < 0 )
387  val_int_to_center_on = Int_t ( val_to_center_on - 0.5 );
388  else
389  val_int_to_center_on = Int_t ( val_to_center_on + 0.5 );
390  }
391 
392  if ( !option.Contains("dry") ) {
393  tsoffset->SetVal(val_int_to_center_on);
394  }
395  }
396  delete h;
397  }
398  }
399 }
400 
401 
402 void DoEXOILLCalib::DisplayPeaks(Option_t *opt, Option_t *fit) //Method created to be able to find the energies, the energy differences, the areas and the errors associated when calib method (in task) does not have to be used (efficiency, calibration checks...)
403 {
404  TString source(opt);
405 
406 
407  if(source.Contains("Co60"))
408  {
409  const Int_t np_peaks = 2;
410  const Double_t peaks[np_peaks] = { 1173.228, 1332.492 };
411  ProcessDisplayPeaks(np_peaks,peaks,fit);
412  }
413  else
414  {
415  if(source.Contains("Eu152"))
416  {
417  const Int_t np_peaks = 7;
418  const Double_t peaks[np_peaks] = { 121.7824, 244.692, 344.276, 778.903, 964.131, 1112.116, 1408.011 };
419  ProcessDisplayPeaks(np_peaks,peaks,fit);
420  }
421  else
422  {
423  if(source.Contains("BaCl"))
424  {
425  const Int_t np_peaks = 10;
426  const Double_t peaks[np_peaks] = { 1131.244, 1327.396, 1601.065, 2311.493, 3116.087, 4979.888, 5715.356, 6110.980, 7414.086, 7790.454 };
427  ProcessDisplayPeaks(np_peaks,peaks,fit);
428  }
429  else
430  {
431  ifstream file(source,ios::in);
432  if(file)
433  {
434  std::vector<Double_t> peaks;
435  Int_t np_peaks=0;
436 
437  std::string str_val;
438 
439  while(getline(file, str_val))
440  {
441  if(np_peaks>=100)
442  {
443  fLog << warning << "Input file reading broken due to more than 100 entries !" << dolog;
444  break;
445  }
446  if(np_peaks>(Int_t)peaks.capacity())
447  {
448  fLog << warning << "Input file reading broken due to number of entries greater than vector capacity !" << dolog;
449  break;
450  }
451  peaks.push_back(atof(str_val.c_str()));
452  np_peaks++;
453  }
454  file.close();
455 
456  ProcessDisplayPeaks(np_peaks,peaks.data(),fit);
457 
458  }
459  else
460  {
461  fLog << warning << "Invalid input file!" << dolog;
462  }
463  }
464  }
465  }
466 }
467 
468 void DoEXOILLCalib::ProcessDisplayPeaks(Int_t np_peaks, const Double_t peaks[], Option_t *fit)
469 {
470  // add peak creator
471  Gw::PeakCreator *pc = Gw::PeakCreator::AddPeakCreator(TVirtualPad::Pad()); Gw::Peak1D *p;
472 
473  // collect all peaks
474  TIter next(TVirtualPad::Pad()->GetListOfPrimitives()); TObject *obj; TList list_of_peaks;
475  list_of_peaks.SetOwner(false);
476 
477  TF1 *tfit = 0x0; TList list_of_fit; TH1 *h = 0x0;
478  TString do_fit(fit);
479  //
480  while ( (obj=next()) )
481  {
482  if ( obj->InheritsFrom("Gw::Peak1D") ) {
483  p = (Gw::Peak1D *)obj;
484  list_of_peaks.Add(p);
485  tfit = p->GetSigFunction();
486  list_of_fit.Add(tfit);
487  }
488  if ( obj->InheritsFrom("TH1") ) {
489  h = (TH1 *)obj;
490  }
491  }
492  if ( h == 0x0 ) {
493  fLog << warning << " Cannot find any spectrum in the current pad " << nline;
494  return;
495  }
496 
497  if ( list_of_peaks.GetSize() == 0 ) {
498 
499  for (Int_t i = 0 ; i < np_peaks; i++) {
500 
501  p = (Gw::Peak1D *)pc->CreatePeak(h, peaks[i], "bg apt");
502  p->SetName( Form("%f",peaks[i]) );
503  p->SetSignalFunction();
504 
505  list_of_peaks.Add(p);
506 
507 
508  if(do_fit.Contains("fitted"))
509  {
510  p->Fit(h, "RN", "pol1");
511  }
512  tfit = p->GetSigFunction();
513  list_of_fit.Add(tfit);
514  }
515 
516  list_of_peaks.Draw();
517  }
518 
519  // Check difference between tabulated and final fit
520 // std::cout << " [+] – In DoEXOILLCalib::ProcessDisplayPeaks : Check peak position - "<< std::endl;
521 // std::cout << " # of Peaks used " << np_peaks << " E[tabulated] \t E[Calib] \t DELTA = E[tabulated] - E[Calib] \t FWHM (keV) \t Peak Area (counts nbr) \t Error Area"<< std::endl;
522 
523  if(do_fit.Contains("sto"))
524  {
525  Double_t PeakArea[np_peaks];
526  Double_t diff[np_peaks];
527  Double_t ErrorArea[np_peaks];
528 
529  ofstream fichier("PeaksPositions.txt", ios::app);
530  //contains (if "fitted") position_tabulee position_mesureee erreur_sur_position_mesuree difference_tabulee-mesuree FWHM aire erreur_sur_laire
531  // (else) position_tabulee position_mesureee difference_tabulee-mesuree
532  if(fichier)
533  {
534  if(do_fit.Contains("fitted"))
535  {
536  fichier << h->GetName() << "\t" << do_fit <<": Etab Emeas d_Emeas Etab-Emeas FWHM d_FWHM area sqrt(area)"<< std::endl;
537  }
538  else
539  {
540  fichier << h->GetName() << "\t" << do_fit <<": Etab Emeas Etab-Emeas"<< std::endl;
541  }
542  for (Int_t i = 0; i < list_of_peaks.GetSize(); i++)
543  {
544  p = (Gw::Peak1D *)list_of_peaks.At(i);
545  tfit = (TF1* )list_of_fit.At(i);
546 
547  diff[i] = atof(p->GetName()) - p->GetPosition();
548  Double_t fwhm = p->GetFWHM();
549 
550  p->Area("f");
551  PeakArea[i] = p->GetPeakIntegral();
552  ErrorArea[i]=sqrt(PeakArea[i]);
553 
554  if(do_fit.Contains("fitted"))
555  {
556  fichier<< p->GetName() << "\t" << p->GetPosition() << "\t" << tfit->GetParError(1) << "\t" << diff[i]<< "\t" << fwhm << "\t" << tfit->GetParError(2) << "\t" << PeakArea[i] << "\t" << ErrorArea[i] << std::endl;
557  }
558  else
559  {
560  fichier<<p->GetName() << "\t"<<p->GetPosition() << "\t" << diff[i]<<std::endl;
561  }
562 
563 
564  } //fin boucle for
565 
566  fichier.close();
567  } //fin if
568  }
569 }
570 
571 
572 void DoEXOILLCalib::Calibrate(TH1 *h, TF1 *function, const TList & peaks)
573 {
574  TArrayD *raw = 0x0, *tabulated = 0x0 ; raw = new TArrayD(peaks.GetSize()); tabulated = new TArrayD(peaks.GetSize()); TObject *obj ; Gw::Peak1D *p;
575  //
576  TIter next(&peaks); Int_t nb_peaks = 0;
577  while ( (obj=next()) ) {
578  p = (Gw::Peak1D *)obj;
579  raw->SetAt(p->GetPosition(),nb_peaks); tabulated->SetAt(atof(p->GetName()),nb_peaks); nb_peaks++;
580  }
581 
582  TGraphErrors *graph =
583  new TGraphErrors(nb_peaks,raw->GetArray(),tabulated->GetArray());
584  graph->Fit(function,"","",h->GetXaxis()->GetXmin(),h->GetXaxis()->GetXmax());
585 
586  // Check difference between tabulated and final fit
587  std::cout << " [+] – In DoEXOILLCalib::Calibrate : Check calibration - "<< std::endl;
588  std::cout << " # of Peaks used " << tabulated->GetSize() << " E[tabulated] \t E[Calib] \t DELTA = E[tabulated] - E[Calib] \t FWHM (keV)" << std::endl;
589  for (Int_t i = 0; i < tabulated->GetSize(); i++) {
590  Double_t diff = tabulated->GetAt(i) - function->Eval(raw->GetAt(i));
591  p = (Gw::Peak1D *)peaks.At(i);
592  Double_t fwhm = function->Eval(raw->GetAt(i)+p->GetFWHM()/2) - function->Eval(raw->GetAt(i)-p->GetFWHM()/2);
593  std::cout << tabulated->GetAt(i) << "\t" << function->Eval(raw->GetAt(i)) << "\t" << diff << "\t" << fwhm << std::endl;
594  }
595  std::cout << " [-] -----–--------------------------------------------- "<< std::endl;
596 
597  // apply calib to spectra to check
598  Int_t slot = fADCSpectra.IndexOf(h); TH1 *hc = (TH1 *)fESpectra.At(slot);
599  hc->Reset();
600  hc->SetBins(h->GetNbinsX(),function->Eval(h->GetXaxis()->GetXmin()),function->Eval(h->GetXaxis()->GetXmax()));
601  for (Int_t i = 0; i < hc->GetNbinsX() + 1; i++) {
602  hc->SetBinContent(i,h->GetBinContent(i));
603  }
604  delete graph; delete raw; delete tabulated;
605 }
606 
607 void DoEXOILLCalib::FindCo60(TH1 *h, TList &list_of_peaks)
608 {
609  TSpectrum spectrum; Int_t NbPeaks = spectrum.Search(h,fSigma,"goff",fThreshold);
610  if (NbPeaks <= 1) {
611  fLog << warning << " Number of Peaks found < 2 " << dolog;
612  return;
613  }
614 
615  Float_t *tab_X = spectrum.GetPositionX();
616  Float_t *tab_Y = spectrum.GetPositionY();
617  Int_t *index = new Int_t[NbPeaks];
618  TMath::Sort(NbPeaks,tab_Y,index,1);
619 
620  Gw::BasePeak *p; Gw::PeakCreator *pc = Gw::PeakCreator::AddPeakCreator(TVirtualPad::Pad());
621 
622  if ( tab_X[index[0]] < tab_X[index[1]] ) {
623  p = pc->CreatePeak(h, tab_X[index[0]], "bg apt");
624  p->SetName("1173.228");
625  p->SetSignalFunction();
626  list_of_peaks.Add(p);
627  p->Fit(h, "RN", "pol1");
628 
629  p = pc->CreatePeak(h, tab_X[index[1]], "bg apt");
630  p->SetName("1332.492");
631  p->SetSignalFunction();
632  list_of_peaks.Add(p);
633  p->Fit(h, "RN", "pol1");
634  }
635  else {
636  p = pc->CreatePeak(h, tab_X[index[1]], "bg apt");
637  p->SetName("1332.492");
638  p->SetSignalFunction();
639  list_of_peaks.Add(p);
640  p->Fit(h, "RN", "pol1");
641 
642  p = pc->CreatePeak(h, tab_X[index[0]], "bg apt");
643  p->SetName("1173.228");
644  p->SetSignalFunction();
645  list_of_peaks.Add(p);
646  p->Fit(h, "RN", "pol1");
647  }
648 
649  delete [] index;
650 }
651 
652 void DoEXOILLCalib::FindEu152(TH1 *h, TList &list_of_peaks, const TF1 *fcalib)
653 {
654  static const Int_t eu_np_peaks = 7;
655  static const Double_t eu_peaks[eu_np_peaks] = { 121.7824, 244.692, 344.276, 778.903, 964.131, 1112.116, 1408.011 };
656 
657  // two cases for algo :
658  // 0 - default - no pre calibration. Then algo is to set the peaks at highest energy to 1408
659  // 1 - pre calibration from the map. use it to guess the peaks
660 
661  TSpectrum spectrum; Int_t NbPeaks = spectrum.Search(h,fSigma,"goff",fThreshold);
662  if (NbPeaks <= 1) {
663  fLog << warning << " Number of Peaks found < 2 " << dolog;
664  return;
665  }
666 
667  Float_t *tab_X = spectrum.GetPositionX();
668  Float_t *tab_Y = spectrum.GetPositionY();
669  Int_t *index = new Int_t[NbPeaks];
670 
671  TMath::Sort(NbPeaks,tab_X,index,1); // to get the highest first with a simple
672 
673  Gw::BasePeak *p; Gw::PeakCreator *pc = Gw::PeakCreator::AddPeakCreator(TVirtualPad::Pad());
674 
675  Int_t algo = 0;
676  if ( fcalib )
677  algo = 1;
678 
679  switch (algo) {
680  case 1:
681  for (Int_t i = 0 ; i < eu_np_peaks; i++) {
682 
683  Int_t which_ref = -1; Double_t what_ref = kMaxULong64;
684 
685  for (Int_t j = 0; j < NbPeaks ; j++) {
686  if ( TMath::Abs( fcalib->Eval(tab_X[j]) - eu_peaks[i] ) < what_ref ) {
687  which_ref = j;
688  what_ref = TMath::Abs( fcalib->Eval(tab_X[j]) - eu_peaks[i] );
689  }
690  }
691 
692  if ( which_ref == -1 ) {
693  fLog << warning << " Cannot find peak " << eu_peaks[i] << nline;
694  continue;
695  }
696 
697  p = pc->CreatePeak(h, tab_X[which_ref], "bg apt");
698  p->SetName( Form("%f",eu_peaks[i]) );
699  p->SetSignalFunction();
700 
701  list_of_peaks.Add(p);
702 
703  p->Fit(h, "RN", "pol1");
704  }
705  break;
706  default:
707  // take highest as 1408 and lowest as 121 as a rough calibration
708  Double_t slope = (1408.011-121.7824) / (tab_X[index[0]] - tab_X[index[NbPeaks-1]]) ;
709  Double_t offset = (1408.011 - slope*tab_X[index[0]]);
710 
711  for (Int_t i = 0 ; i < eu_np_peaks; i++) {
712 
713  Int_t which_ref = -1; Double_t what_ref = kMaxULong64;
714 
715  for (Int_t j = 0; j < NbPeaks ; j++) {
716  if ( TMath::Abs( (slope*tab_X[j]+offset) - eu_peaks[i] ) < what_ref ) {
717  which_ref = j;
718  what_ref = TMath::Abs ( (slope*tab_X[j]+offset) - eu_peaks[i] );
719  }
720  }
721 
722  if ( which_ref == -1 ) {
723  fLog << warning << " Cannot find peak " << eu_peaks[i] << nline;
724  continue;
725  }
726 
727  p = pc->CreatePeak(h, tab_X[which_ref], "bg apt");
728  p->SetName( Form("%f",eu_peaks[i]) );
729  p->SetSignalFunction();
730 
731  list_of_peaks.Add(p);
732 
733  p->Fit(h, "RN", "pol1");
734  }
735  break;
736  }
737 
738  delete [] index;
739 }
740 
741 void DoEXOILLCalib::FindBaCl2(TH1 *h, TList &list_of_peaks, const TF1 *fcalib)
742 {
743  static const Int_t nb_ref_peaks = 3;
744  static const Double_t ref_peaks[nb_ref_peaks] = { 1164.860, 6110.98, 7790.454 };
745 
746  // two cases for algo :
747  // 0 - default - no pre calibration. Then algo is to set the peaks at highest energy to 1408
748  // 1 - pre calibration from the map. use it to guess the peaks
749  // pre-calib mandatory
750 
751  TSpectrum spectrum; Int_t NbPeaks = spectrum.Search(h,fSigma,"goff",fThreshold);
752  if (NbPeaks <= 1) {
753  fLog << warning << " Number of Peaks found < 2 " << dolog;
754  return;
755  }
756 
757  Float_t *tab_X = spectrum.GetPositionX();
758  Float_t *tab_Y = spectrum.GetPositionY();
759  Int_t *index = new Int_t[NbPeaks];
760 
761  TMath::Sort(NbPeaks,tab_X,index,1); // to get the highest first with a simple
762 
763  Gw::BasePeak *p; Gw::PeakCreator *pc = Gw::PeakCreator::AddPeakCreator(TVirtualPad::Pad());
764 
765  Int_t algo = 0;
766  if ( fcalib )
767  algo = 1;
768 
769  switch (algo) {
770  case 1:
771  for (Int_t i = 0 ; i < nb_ref_peaks; i++) {
772 
773  Int_t which_ref = -1; Double_t what_ref = kMaxULong64;
774 
775  for (Int_t j = 0; j < NbPeaks ; j++) {
776  if ( TMath::Abs( fcalib->Eval(tab_X[j]) - ref_peaks[i] ) < what_ref ) {
777  which_ref = j;
778  what_ref = TMath::Abs( fcalib->Eval(tab_X[j]) - ref_peaks[i] );
779  }
780  }
781  if ( (which_ref == -1 ) || (what_ref > 2*fSigma*2.35482)){
782  fLog << warning << " Cannot find peak " << ref_peaks[i] << nline;
783  continue;
784  }
785 
786  p = pc->CreatePeak(h, tab_X[which_ref], "bg apt");
787  p->SetName( Form("%f",ref_peaks[i]) );
788  p->SetSignalFunction();
789 
790  list_of_peaks.Add(p);
791 
792  p->Fit(h, "RN", "pol1");
793  }
794  break;
795  default:
796  break;
797  }
798 
799  delete [] index;
800 }
801 
802 void DoEXOILLCalib::Calib(const Char_t *what_source, Option_t * opt, Option_t* DefFileName)
803 {
804  TString option(opt);
805  TString FileName(DefFileName);
806 
807  // add peak creator so that the
808  Gw::PeakCreator *pc = Gw::PeakCreator::AddPeakCreator(TVirtualPad::Pad());
809 
810  // collect all peaks
811  TIter next(TVirtualPad::Pad()->GetListOfPrimitives()); TObject *obj; TList list_of_peaks; TH1 *h = 0x0;
812  list_of_peaks.SetOwner(false);
813  //
814  while ( (obj=next()) )
815  {
816  if ( obj->InheritsFrom("Gw::Peak1D") ) {
817  list_of_peaks.Add(obj);
818  }
819  if ( obj->InheritsFrom("TH1") ) {
820  h = (TH1 *)obj;
821  }
822  }
823  if ( h == 0x0 ) {
824  fLog << warning << " Cannot find any spectrum in the current pad " << nline;
825  return;
826  }
827  TString tmp = h->GetName();
828  tmp.Remove(0,4);
829  TF1 *f = (TF1 *)fMap.adcCalib.FindObject(tmp.Data());
830 
831  // if no peak, it means it tries to guess
832  TString source(what_source);
833  if ( source.Contains("Co60") ) {
834  if ( list_of_peaks.GetSize() != 2 ) {
835  FindCo60(h, list_of_peaks);
836  list_of_peaks.Draw();
837  }
838  }
839  if ( source.Contains("Eu152") ) {
840  if ( option.Contains("dry") ) {
841  if ( TMath::Abs(f->Eval(1000)-1000) < 0.4 && TMath::Abs(f->Eval(100)-100) < 0.4 ) {
842  FindEu152(h, list_of_peaks, 0); // means f is identify, no pre calibration
843  }
844  else {
845  FindEu152(h, list_of_peaks, f);
846  }
847 
848  list_of_peaks.Draw();
849  }
850  }
851  if ( source.Contains("BaCl") ) {
852  if ( option.Contains("dry") ) {
853  FindBaCl2(h, list_of_peaks, f);
854  list_of_peaks.Draw();
855  }
856  }
857  if ( !option.Contains("dry") ) {
858  // no dry -> 4 cases
859  // sto use -> reading file and use of temp peak list, then writing in file, then adding temp peak list to list_of_peaks for calibration
860  // sto no use -> wrinting in file without calibration
861  // no sto use -> reading file to add peaks to list_of_peaks, then calibration
862  // no sto no use -> calibration
863  if(option.Contains("sto"))
864  {
865  if(option.Contains("use"))
866  {
867  //ici on relie le fichier et on stock les valeurs dans une variable temporaire
868  TList temp_peak_list;
869  ifstream fichier(FileName, ios::in);
870  if(fichier)
871  {
872  TString contenu;
873  while(true != fichier.eof())
874  {
875  fichier >> contenu;
876  bool done=false;
877  while(false == done)
878  {
879  done = true;
880  if(contenu == tmp)
881  {
882  done = false;
883  TString name;
884  TString position;
885  TString FWHM;
886  fichier>>name;
887  while(name.IsFloat())
888  {
889  fichier>>position>>FWHM;
890  Gw::Peak1D* p;
891  p=new Gw::Peak1D(name, name);
892  p->SetPosition(position.Atof());
893  p->SetFWHM(FWHM.Atof());
894  temp_peak_list.Add(p);
895  fichier>>name;
896  }
897  contenu = name;
898  }
899  }
900  }
901  fichier.close();
902  }
903  else
904  {
905  fLog << warning << " Cannot open storage file for reading " << nline;
906  return;
907  }
908 
909 
910 
911  //ici on écrit dans le fichier
912  ofstream fichier2(FileName, ios::app);
913  if(fichier2)
914  {
915  fichier2<< tmp <<std::endl;
916  for(Int_t IterPeak = 0; IterPeak< list_of_peaks.GetSize(); IterPeak++)
917  {
918  Gw::Peak1D *p;
919  p = (Gw::Peak1D *)list_of_peaks.At(IterPeak);
920  fichier2 << p->GetName()<<" "<<p->GetPosition()<<" "<<p->GetFWHM()<<std::endl;
921  }
922  fichier2.close();
923  }
924  else
925  {
926  fLog << warning << " Cannot open storage file for writing " << nline;
927  return;
928  }
929 
930 
931 
932  //ici on add ce qui est dans la variable temporaire a la liste de peak
933  for(Int_t temp = 0; temp< temp_peak_list.GetSize(); temp++)
934  {
935  list_of_peaks.Add(temp_peak_list.At(temp));
936  }
937  Calibrate(h, f, list_of_peaks);
938  }
939  else
940  {
941  //ici on écrit dans le fichier
942  ofstream fichier(FileName, ios::app);
943  if(fichier)
944  {
945  fichier<< tmp <<std::endl;
946  for(Int_t IterPeak = 0; IterPeak< list_of_peaks.GetSize(); IterPeak++)
947  {
948  Gw::Peak1D *p;
949  p = (Gw::Peak1D *)list_of_peaks.At(IterPeak);
950  fichier << p->GetName()<<" "<<p->GetPosition()<<" "<<p->GetFWHM()<<std::endl;
951  }
952  fichier.close();
953  }
954  else
955  {
956  fLog << warning << " Cannot open storage file for writing " << nline;
957  return;
958  }
959  }
960  }
961  else
962  {
963  if(option.Contains("use"))
964  {
965  //ici on relie le ficher
966  ifstream fichier(FileName, ios::in);
967  if(fichier)
968  {
969  TString contenu;
970  while(true != fichier.eof())
971  {
972  fichier >> contenu;
973  bool done=false;
974  while(false == done)
975  {
976  done = true;
977  if(contenu == tmp)
978  {
979  done = false;
980  TString name;
981  TString position;
982  TString FWHM;
983  fichier>>name;
984  while(name.IsFloat())
985  {
986  fichier>>position>>FWHM;
987  Gw::Peak1D* p;
988  p=new Gw::Peak1D(name, name);
989  p->SetPosition(position.Atof());
990  p->SetFWHM(FWHM.Atof());
991  list_of_peaks.Add(p);
992  fichier>>name;
993  }
994  contenu=name;
995  }
996  }
997  }
998  }
999  else
1000  {
1001  fLog << warning << " Cannot open storage file for reading " << nline;
1002  return;
1003  }
1004  Calibrate(h, f, list_of_peaks);
1005  }
1006  else
1007  {
1008  Calibrate(h, f, list_of_peaks);
1009  }
1010  }
1011  }
1012 }
1013 
1015 
1016 RawMatrices::RawMatrices(const char *name, const char *title) :
1017  BaseEXOILLWatcher(name,title),
1018  fFoldDistri(0x0),
1019  fGG(0x0),
1020  fGT(0x0),
1021  fUIDT(0x0),
1022  fUIDUID(0x0),
1023  fGeELaE(0x0),
1024  fGeELaT(0x0)
1025 {
1027 
1028  fFoldDistri = MakeTH1<TH1F>("Fold","Fold distribution",20,0,20);
1029  TagOn(fFoldDistri);
1030 
1031  fGG = MakeTH2<TH2F>(Form("ExE_%s",name),"Gamma Gamma Matrix",4000,0,4000,4000,0,4000);
1032  fGT = MakeTH2<TH2F>(Form("TxE_%s",name),"Time Energy Matrix",100,-50,+50,4000,0,4000);
1033 
1034  fUIDT = MakeTH2<TH2F>(Form("UIDxT_%s",name),"Time Diff per Detector",fMap.maxUID,0,+fMap.maxUID,100,-50,+50);
1035  fUIDUID = MakeTH2<TH2F>(Form("UIDxUID_%s",name),"Correlation between detector",fMap.maxUID,0,+fMap.maxUID,fMap.maxUID,0,+fMap.maxUID);
1036 
1037  fGeELaE = MakeTH2<TH2F>(Form("GeExLaE_%s",name),"Correlation between detector",4000,0,4000,200,0,20000);
1038  fGeELaT = MakeTH2<TH2F>(Form("GeExLaT_%s",name),"Correlation between detector",4000,0,4000,200,0,20000);
1039 
1040 
1041  }
1042 }
1043 
1044 void RawMatrices::Exec(Option_t * option)
1045 {
1046  BaseEXOILLWatcher::Exec(option);
1047 
1048  fFoldDistri->Fill(fNbSubEvent);
1049 
1050  for (UInt_t i = 0; i < fGEEvent.size(); i++ ) {
1051  for (UInt_t j = i+1; j < fGEEvent.size(); j++ ) {
1052  fGG->Fill(fGEEvent[i]->E,fGEEvent[j]->E);
1053  fGG->Fill(fGEEvent[j]->E,fGEEvent[i]->E);
1054  }
1055  if ( fGEEvent.size() > 1 ) {
1056  fGT->Fill(fGEEvent[i]->DTS, fGEEvent[i]->E); fUIDT->Fill(fGEEvent[i]->UID,fGEEvent[i]->DTS);
1057  }
1058  for (UInt_t j = 0; j < fLAEvent.size(); j++ ) {
1059  if ( fMap.allDigitizer[fGEEvent[i]->UID].Item == 0 ) {
1060  fGeELaE->Fill(fGEEvent[i]->E,fLAEvent[j]->E);
1061  }
1062  else
1063  fGeELaT->Fill(fGEEvent[i]->E,fLAEvent[j]->E);
1064  }
1065  }
1066 
1067  for (UInt_t i = 0; i < fNbSubEvent; i++ ) {
1068  for (UInt_t j = i+1; j < fNbSubEvent; j++ ) {
1069  fUIDUID->Fill(fEvent[i].UID,fEvent[j].UID);
1070  fUIDUID->Fill(fEvent[j].UID,fEvent[i].UID);
1071  }
1072  }
1073 
1074  /*
1075  for (UInt_t i = 0; i < fLAEvent.size(); i++ ) {
1076  for (UInt_t j = 0; j < fLAEvent.size(); j++ ) {
1077  if ( i == j ) {
1078  continue;
1079  }
1080  fLaELaT->Fill(fLAEvent[i].E,);
1081  }
1082  }
1083  */
1084 
1085 
1086 }
1087 
1088 ClassImp(GatedGG);
1089 
1090 GatedGG::GatedGG(const char *name, const char *title) :
1091  BaseEXOILLWatcher(name,title),
1092  fGG(0x0)
1093 {
1095 
1096  fGG = MakeTH2<TH2F>(Form("ExE_%s",name),"Gated Gamma Gamma Matrix",4000,0,4000,4000,0,4000);
1097 
1098  // TO BE DONE, reading of file containing gates and fill fListOfGtes
1099  std::string tmp; std::ifstream filein(Form("%s.gate",name));
1100  if ( filein.is_open() == true ) {
1101  getline(filein,tmp);
1102  tmp += " ";
1103  while ( filein.good() && !filein.eof() ) { // read input stream line by line
1104  if ( tmp[0] == '#' ) {
1105  getline(filein,tmp);
1106  tmp += " ";
1107  continue;
1108  } // this line is a comment
1109 
1110  std::istringstream decode(tmp); std::pair<Float_t, Float_t> g; decode >> g.first >> g.second;
1111 
1112  if( decode.good() ) {
1113  fListOfGates.push_back(g);
1114  fLog << info << " add gate to gate the matrix " << g.first << " " << g.second << nline;
1115  }
1116  getline(filein,tmp);
1117  tmp += " ";
1118  }
1119  filein.close();
1120  }
1121  fLog << dolog;
1122  }
1123 }
1124 
1125 void GatedGG::Exec(Option_t * option)
1126 {
1127  Int_t nb_cond_filled;
1128 
1129  BaseEXOILLWatcher::Exec(option);
1130 
1131  nb_cond_filled = 0;
1132  for (UInt_t i = 0; i < fGEEvent.size(); i++ ) {
1133 
1134  // use UID to know if the energy is inside a gate or not to avoid allocated an additional array
1135  // should be done in case UID is required later on !
1136  fGEEvent[i]->UID = 0;
1137  for (size_t gg = 0; gg < fListOfGates.size(); gg++) {
1138  if ( fGEEvent[i]->E < fListOfGates[gg].first ) {
1139  continue;
1140  }
1141  if ( fGEEvent[i]->E > fListOfGates[gg].second ) {
1142  continue;
1143  }
1144  nb_cond_filled++; fGEEvent[i]->UID = 1;
1145  break;
1146  }
1147  }
1148  if ( nb_cond_filled ) {
1149  switch (nb_cond_filled) {
1150  case 1:
1151  // add only non fired
1152  for (UInt_t i = 0; i < fGEEvent.size(); i++ ) {
1153  if ( fGEEvent[i]->UID == 1)
1154  continue;
1155  for (UInt_t j = 0; j < fGEEvent.size(); j++ ) {
1156  if ( fGEEvent[j]->UID == 1 )
1157  continue;
1158  if ( i == j )
1159  continue;
1160  fGG->Fill(fGEEvent[i]->E,fGEEvent[j]->E);
1161  }
1162  }
1163  break;
1164  case 2:
1165  // add only non fired and one fired
1166  for (UInt_t i = 0; i < fGEEvent.size(); i++ ) {
1167  for (UInt_t j = 0; j < fGEEvent.size(); j++ ) {
1168  if ( fGEEvent[i]->UID + fGEEvent[j]->UID > 1 )
1169  continue;
1170  if ( i == j )
1171  continue;
1172  fGG->Fill(fGEEvent[i]->E,fGEEvent[j]->E);
1173  }
1174  }
1175  break;
1176  default:
1177  // all
1178  for (UInt_t i = 0; i < fGEEvent.size(); i++ ) {
1179  for (UInt_t j = 0; j < fGEEvent.size(); j++ ) {
1180  if ( i == j )
1181  continue;
1182  fGG->Fill(fGEEvent[i]->E,fGEEvent[j]->E);
1183  }
1184  }
1185  break;
1186  }
1187  }
1188 }
1189 
1191 
1192 MyILLTree::MyILLTree(const char *name, const char *title, TTree *tree) :
1193  BaseEXOILLWatcher(name,title),
1194  TTreeBuilder(name,title,tree)
1195 {
1196  if ( GetTree() ) { // just add the branch for that watcher
1197  SetBranches();
1198  }
1199 }
1200 
1202 {
1203  GetTree()->Branch("TS", &TS, "TS/l");
1204  GetTree()->Branch("FOLD",&FOLD,"FOLD/I");
1205 
1206  GetTree()->Branch("E", E, "E[FOLD]/F");
1207  GetTree()->Branch("DT",DT, "DT[FOLD]/I");
1208  GetTree()->Branch("ID", ID, "ID[FOLD]/I");
1209 }
1210 
1211 void MyILLTree::Exec(Option_t * option)
1212 {
1213  BaseEXOILLWatcher::Exec(option);
1214 
1215  TS = fCurrentTS; FOLD = fNbSubEvent;
1216 
1217  for (UInt_t i = 0; i < fNbSubEvent; i++ ) {
1218  DT[i] = fEvent[i].DTS;
1219  E[i] = fEvent[i].E;
1220  ID[i] = fEvent[i].UID;
1221  }
1222 }
1223 
1224 
1225 
1226 
1227 
1228 
virtual void Exec(Option_t *option="")
Definition: ILLWatchers.C:1211
header file for PeakCreator.cpp
virtual TF1 * SetSignalFunction(const char *nameFunc="gaus", TH1 *h=0x0)=0
Set pre-defined function to fit the signal.
header file for DefaultKeyFactory.cpp
virtual Bool_t LoadConfig(const Char_t *fname="EXOILLWatcher.conf")
Definition: ILLWatchers.C:59
virtual void Fit(TH1 *h, Option_t *optFit="RN", Option_t *optBkg="lin")=0
Fit peak with background.
RawMatrices(const char *name, const char *title)
Definition: ILLWatchers.C:1016
MyILLTree(const char *name, const char *title, TTree *tree=0x0)
Definition: ILLWatchers.C:1192
LogMessage & warning(LogMessage &)
void FindEu152(TH1 *h, TList &list_of_peaks, const TF1 *fcalib)
Definition: ILLWatchers.C:652
virtual void SetPosition(const Double_t position, Option_t *axis="X")
Set Position of peak.
Definition: Peak1D.cpp:546
virtual void Exec(Option_t *option="")
Definition: ILLWatchers.C:1044
virtual void SetFWHM(const Double_t FWHM, Option_t *axis="X")
Set FWHM of peak.
Definition: Peak1D.cpp:555
virtual UInt_t GetDataLength() const
Definition: Key.h:134
LogMessage & nline(LogMessage &)
static PeakCreator * AddPeakCreator(TVirtualPad *pad=0x0)
add a peak creator to the given pad. Current pad if argument is 0x0
Double_t GetPeakIntegral() const
Get integral of peak after calling area method.
Definition: Peak1D.h:261
Base class for a watcher for EXOGAM.
Definition: ILLWatchers.h:47
GatedGG(const char *name, const char *title)
Definition: ILLWatchers.C:1090
void SaveMAP(const Char_t *fname="NOMADMap.conf.new", Option_t *opt="")
Save current mapping.
Definition: ILLWatchers.C:171
void Calibrate(TH1 *h, TF1 *function, const TList &peaks)
Definition: ILLWatchers.C:572
LogMessage & info(LogMessage &)
manipulator to modify the LogMessage
Base class for a Watcher that fill a TTree or some branches of a TTree.
Definition: TTreeWatchers.h:51
LogMessage fLog
Definition: Watchers.h:86
std::vector< NOMADEvent * > fGEEvent
subevent per type
Definition: ILLWatchers.h:68
virtual void Fit(TH1 *histo, Option_t *optFit="RN", Option_t *optBkg="pol1")
Fit peak with background.
Definition: Peak1D.cpp:1406
A RawFrame gives direct access to the underlying buffer.
Definition: Frame.h:557
virtual Double_t GetFWHM(Option_t *axis="X") const
Get FWHM of peak.
Definition: Peak1D.cpp:962
ULong64_t fCurrentTS
Global TS for the current event.
Definition: ILLWatchers.h:62
virtual void Exec(Option_t *option="")
Definition: ILLWatchers.C:176
virtual ULong64_t GetUID() const =0
Get unique ID. Could be event number / timestamp for instance.
LogMessage & dolog(LogMessage &)
virtual Double_t GetPosition(Option_t *axis="X") const
Get position of peak.
Definition: Peak1D.cpp:955
Base Key for frames assoeciated with a id which could be event # or Timestamp (32 bits) ...
void Calib(const Char_t *what_source="Co60", Option_t *opt="dry", Option_t *DefFileName="CalibStorage.txt")
apply calibration for the spectrum in the current pad
Definition: ILLWatchers.C:802
Base class for building control spectra and calibrate.
Definition: ILLWatchers.h:106
Built some correlation matrices.
Definition: ILLWatchers.h:173
void TagOn(TObject *)
Add this histogram to the list of tagged histograms.
Definition: Watchers.cpp:901
void DisplayPeaks(Option_t *opt="BaCl", Option_t *fit="fitted")
Display some peaks on the spectrum in the current pad.
Definition: ILLWatchers.C:402
void FindCo60(TH1 *h, TList &list_of_peaks)
Definition: ILLWatchers.C:607
virtual Bool_t SetTrigger(ADF::DFTrigger *=0x0)
Set the Frame to be watched.
Definition: ILLWatchers.C:39
std::vector< NOMADEvent * > fLAEvent
Definition: ILLWatchers.h:70
Base class for a trigger on a data flow.
Definition: Trigger.h:155
ADF::LogMessage & endl(ADF::LogMessage &log)
virtual void Area(Option_t *opt="h")
to get the Area (+bkg) of this peak
Definition: Peak1D.cpp:1031
void SearchParameters(Double_t sig=2.0, Double_t thre=0.05)
Parameters required by the search method.
Definition: ILLWatchers.C:160
A BasePeak is defined by a height, intensity and a dimension of the peak.
Definition: BasePeak.h:19
Shows how to save data in a TTree.
Definition: ILLWatchers.h:233
virtual void Exec(Option_t *option="")
Definition: ILLWatchers.C:1125
ClassImp(BaseEXOILLWatcher)
A graphical interface for placing schematic peak onto a 1D histogram with a given position...
Definition: Peak1D.h:79
build a gated matrix
Definition: ILLWatchers.h:208
static TF1 * GetGlobalPeakFWHM()
virtual void SetBranches()
Definition: ILLWatchers.C:1201
virtual TF1 * SetSignalFunction(const char *nameFunc="gaus", TH1 *h=0x0)
Set pre-defined function to fit the signal.
Definition: Peak1D.cpp:716
std::vector< NOMADEvent > fEvent
subevents
Definition: ILLWatchers.h:66
UInt_t fNbSubEvent
number of subevents read from fFrame
Definition: ILLWatchers.h:64
void ProcessDisplayPeaks(Int_t np_peaks, const Double_t peaks[], Option_t *fit)
Definition: ILLWatchers.C:468
virtual void Exec(Option_t *option="")
Definition: ILLWatchers.C:64
void AlignTS(Option_t *opt="dry", Option_t *algo="mean")
align all time spectra using which_ref as a reference.
Definition: ILLWatchers.C:292
virtual TF1 * GetSigFunction()
Get signal function.
Definition: Peak1D.h:222
virtual BasePeak * CreatePeak(const TH1 *h, Double_t x, Option_t *opt="")
It creates a peak at position x for the 1D spectra.
void FindBaCl2(TH1 *h, TList &list_of_peaks, const TF1 *fcalib)
Definition: ILLWatchers.C:741
DoEXOILLCalib(const char *name, const char *title)
Definition: ILLWatchers.C:113
UInt_t SetOffset(UInt_t off=0u) const
change the current position.
Definition: BufferIO.cpp:122
TTree * GetTree()
to get the current Tree