GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LNL/CrystalWatchers.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 
22 // Watcher definition
23 #ifndef _CrystalWatchers
24 #include "CrystalWatchers.h"
25 #endif
26 
27 #include "TArrow.h"
28 #include "TH2.h"
29 #include "TH3.h"
30 #include "TStyle.h"
31 
32 namespace {
33 static Double_t gArrowL = 1000; // default length for arrow
34 static Double_t gArrowP = 10; // default position for arrow
35 static Double_t gArrowB = 4000; // default value for baseline
36 static Double_t gArrowT = 1000; // default value for threshold, baseline is the ref
37 static Double_t gArrowO = 6000; // default value for Overshoot, baseline is the ref
38 
39 static Double_t gArrowBaselineSigma = 5; // signal if amplitude > (1+gArrowBaselineSigma)*baseline
40 static Double_t gMaxForOneSigna = 10000; // signal if amplitude > (1+gArrowBaselineSigma)*baseline
41 
42 // from CrystalProducer ... later on should be from SandBox so that the same file could be use in any cases
43 UInt_t gRangeforBaseline = 20;
44 Float_t fSpekGain = 1.f; // good for trapezoid risetime 1000
45 Float_t fMinSegAmpli = 500.f; // ~50 (150) keV for high(low) gain range if shaping = 1000
46 UInt_t fRawAmplitude = 0; // don't produce amplitude spectra from raw traces
47 }
48 
49 using namespace ADF;
50 
52 
54 {
55  // check if this trigger is not a zombie
56  if ( ! Watcher::SetTrigger(trigger) )
57  return false;
58 
59  // loop the different input frames to look for a crytal one, whatever the version
60  SharedFP *ffind = 0x0;
61  UInt_t which;
62  for( which = 0u; which < GetTrigger()->GetNbInputFrame(); which++){
63 
64  SharedFP *fp = GetTrigger()->GetInputSharedFP(which);
65  if ( fp == 0x0 )
66  continue;
67 
68  Frame *f = fp->GetFrame();
69  if ( f == 0x0 )
70  continue;
71 
72  // check if the currenet frame is a version of a tracked frame
73  TString ftype = f->GetSignature().GetItemName();
74 
75  if ( ftype.Contains("data") && ftype.Contains("crystal") ) {
76  ffind = fp;
77  break;
78  }
79  }
80  if ( ffind )
81  fFrame = ffind;
82  else
83  fFrame = 0x0;
84 
85  return fFrame != 0x0;
86 }
87 
89 
90 void ShowSignals::SetDefaultArrow(Double_t baseline, Double_t threshold, Double_t overshoot, Double_t pos, Double_t length)
91 {
92  gArrowL = length; // default length for arrow
93  gArrowP = pos; // default position for arrow
94  gArrowB = baseline; // default value for baseline
95  gArrowT = threshold; // default value for threshold, baseline is the ref
96  gArrowO = overshoot; // default value for Overshoot, baseline is the ref
97 }
98 
99 ShowSignals::ShowSignals(const char *name, const char *title) :
100  CrystalWatcher(name,title),
101  fCurrentSig(0),
102  fProcessingAlgo("basic"),
103  fEnergies(0x0),
104  fSeg( new TObjArray(CrystalInterface::kNbSegments) ),
105  fCor( new TObjArray(CrystalInterface::kNbCores) ),
106  fVMin(0),
107  fVMax(10000),
108  fHMin(0),
109  fHMax(100),
110  fBaseLines ( new TObjArray(CrystalInterface::kNbCores+CrystalInterface::kNbSegments) ),
111  fAmplitudes( new TObjArray(CrystalInterface::kNbCores+CrystalInterface::kNbSegments) ),
112  fFromSignal(5),
113  fHThreshold(0x0),
114  fHOvershoot(0x0),
115  fCoincThreshold(CrystalInterface::kNbCores+CrystalInterface::kNbSegments),
116  fCoincOverShoot(CrystalInterface::kNbCores+CrystalInterface::kNbSegments),
117  fCoinc(0x0),
118  fCoreCoinc(0x0),
119  fBaseLinesArrows(CrystalInterface::kNbCores+CrystalInterface::kNbSegments),
120  fThresholdArrows(CrystalInterface::kNbCores+CrystalInterface::kNbSegments),
121  fOvershootArrows(CrystalInterface::kNbCores+CrystalInterface::kNbSegments)
122 {
123  Color_t color[6] = {1, 4, 2, 8 , 27, 6}; TArrow *arrow; TString hname, htitle; TH1 *h;
124  // energie as read in the ADF Frame. It comes from the digitizers
125  fEnergies = MakeTH2<TH2F>("ADC","ADC for Core and Segments",
126  CrystalInterface::kNbCores+CrystalInterface::kNbSegments,0,CrystalInterface::kNbCores+CrystalInterface::kNbSegments,16384,0,8192);
127  fEnergies->GetXaxis()->SetTitle("bin [0,1] for Core and [2,38] for Segments");
128 
129  // per core/segment
130  fCor->SetOwner();
131  fSeg->SetOwner();
132 
133  for (Int_t i = 0; i < CrystalInterface::kNbCores; i++ ) {
134 
135  // baseline distribution
136  hname = Form("BaseLine_Core%d",i);
137  h = MakeTH1<TH1F>(hname.Data(),hname.Data(), 16384,0,16384);
138  h->GetXaxis()->SetTitle("Baseline Position");
139  h->GetYaxis()->SetTitle("Counts");
140  h->SetLineColor(kRed);
141  h->SetFillColor(kRed);
142  fBaseLines->AddAt(h,i);
143  // amplitudes distribution
144  hname = Form("Amplitude_Core%d",i);
145  h = MakeTH1<TH1F>(hname.Data(),hname.Data(), 16384,0,16384);
146  h->GetXaxis()->SetTitle("Signal Amplitude");
147  h->GetYaxis()->SetTitle("Counts");
148  h->SetLineColor(kRed);
149  h->SetFillColor(kRed);
150  fAmplitudes->AddAt(h,i);
151 
152  TObjArray *SigArray = new TObjArray(gkNB_SIG);
153  fCor->AddAt(SigArray,i);
154 
155  for (Int_t j = 0; j < gkNB_SIG; j++ ) {
156  hname = Form("Core%d_Sig%d",i,j);
157  h = MakeTH1<TH1F>(hname.Data(),hname.Data(),
158  CrystalInterface::kDefaultLength,0,CrystalInterface::kDefaultLength,"LastSignals");
159  h->GetXaxis()->SetTitle("RawValue");
160  h->GetYaxis()->SetTitle("Counts");
161 
162  h->SetStats(kFALSE);
163  h->SetLineColor(kRed);
164  ((TObjArray*)fCor->At(i))->AddAt(h,j);
165  }
166  arrow = new TArrow(gArrowP,gArrowB,gArrowP,gArrowB+gArrowL,0.05,"<|" );
167  arrow->SetAngle(45);
168  arrow->SetArrowSize(0.015);
169  arrow->SetLineColor(kRed);
170  arrow->SetFillColor(kRed);
171  fBaseLinesArrows.Add( arrow );
172 
173  arrow = new TArrow(gArrowP+10,gArrowB+gArrowT,gArrowP+10,gArrowB+gArrowT+gArrowL,0.05,"<|>" );
174  arrow->SetAngle(45);
175  arrow->SetArrowSize(0.015);
176  arrow->SetLineColor(kRed);
177  arrow->SetFillColor(kRed);
178  fThresholdArrows.Add( arrow );
179 
180  arrow = new TArrow(gArrowP+20,gArrowB-gArrowL+gArrowO,gArrowP+20,gArrowB+gArrowO,0.05,"|>" );
181  arrow->SetAngle(45);
182  arrow->SetArrowSize(0.015);
183  arrow->SetLineColor(kRed);
184  arrow->SetFillColor(kRed);
185  fOvershootArrows.Add( arrow );
186  }
187  for (Int_t i = 0; i < CrystalInterface::kNbSegments; i++ ) {
188 
189  // baseline distribution
190  hname = Form("BaseLine_Seg%d",i);
191  h = MakeTH1<TH1F>(hname.Data(),hname.Data(), 16384,0,16384);
192  h->GetXaxis()->SetTitle("Baseline Position");
193  h->GetYaxis()->SetTitle("Counts");
194  h->SetLineColor(color[i%6]);
195  h->SetFillColor(color[i%6]);
196  fBaseLines->AddAt(h,CrystalInterface::kNbCores+i); TagOn(h);
197 
198  // amplitudes distribution
199  hname = Form("Amplitude_Seg%d",i);
200  h = MakeTH1<TH1F>(hname.Data(),hname.Data(), 16384,0,16384);
201  h->GetXaxis()->SetTitle("Signal Amplitude");
202  h->GetYaxis()->SetTitle("Counts");
203  h->SetLineColor(color[i%6]);
204  h->SetFillColor(color[i%6]);
205  fAmplitudes->AddAt(h,CrystalInterface::kNbCores+i);
206 
207  TObjArray *SigArray = new TObjArray(gkNB_SIG);
208  fSeg->AddAt(SigArray,i);
209 
210  for (Int_t j = 0; j < gkNB_SIG; j++ ) {
211  hname = Form("Segment%d_Sig%d",i,j);
212  htitle = Form("Seg #color[1]{%d} #color[4]{%d} #color[2]{%d} #color[8]{%d} #color[27]{%d} #color[6]{%d}",
213  i, i+1, i+2, i+3, i+4, i+5);
214  h = MakeTH1<TH1F>(hname.Data(),htitle.Data(),
215  CrystalInterface::kDefaultLength,0,CrystalInterface::kDefaultLength,"LastSignals");
216  h->GetXaxis()->SetTitle("Time");
217  h->GetYaxis()->SetTitle("Amplitude");
218 
219  h->SetStats(kFALSE);
220  h->SetLineColor(color[i%6]);
221  ((TObjArray*)fSeg->At(i))->AddAt(h,j);
222 
223  }
224  arrow = new TArrow(gArrowP,gArrowB,gArrowP,gArrowB+gArrowL,0.05,"<|" );
225  arrow->SetAngle(45);
226  arrow->SetArrowSize(0.015);
227  arrow->SetLineColor(color[i%6]);
228  arrow->SetFillColor(color[i%6]);
229  fBaseLinesArrows.Add( arrow );
230 
231  arrow = new TArrow(gArrowP+10,gArrowB+gArrowT,gArrowP+10,gArrowB+gArrowT+gArrowL,0.05,"<|>" );
232  arrow->SetAngle(45);
233  arrow->SetArrowSize(0.015);
234  arrow->SetLineColor(color[i%6]);
235  arrow->SetFillColor(color[i%6]);
236  fThresholdArrows.Add( arrow );
237 
238  arrow = new TArrow(gArrowP+20,gArrowB-gArrowL+gArrowO,gArrowP+20,gArrowB+gArrowO,0.05,"|>" );
239  arrow->SetAngle(45);
240  arrow->SetArrowSize(0.015);
241  arrow->SetLineColor(color[i%6]);
242  arrow->SetFillColor(color[i%6]);
243  fOvershootArrows.Add( arrow );
244  }
245  fHThreshold = MakeTH3<TH3F>("Threshold3D","Signals that are greater that threshold",
246  CrystalInterface::kNbCores+CrystalInterface::kNbSegments,0,CrystalInterface::kNbCores+CrystalInterface::kNbSegments,
247  CrystalInterface::kNbCores+CrystalInterface::kNbSegments,0,CrystalInterface::kNbCores+CrystalInterface::kNbSegments,
248  15,0,15);
249  fHOvershoot = MakeTH3<TH3F>("Overshoot","Signals that are greater that overshoot",
250  CrystalInterface::kNbCores+CrystalInterface::kNbSegments,0,CrystalInterface::kNbCores+CrystalInterface::kNbSegments,
251  CrystalInterface::kNbCores+CrystalInterface::kNbSegments,0,CrystalInterface::kNbCores+CrystalInterface::kNbSegments,
252  15,0,15);
253 
254  fCoinc = MakeTH2<TH2F>("Threshold2D","Signals that are greater that threshold",
255  CrystalInterface::kNbSegments,0,CrystalInterface::kNbSegments,
256  CrystalInterface::kNbSegments,0,CrystalInterface::kNbSegments);
257  fCoinc->GetXaxis()->SetTitle("Segment #");
258  fCoinc->GetYaxis()->SetTitle("Segment #");
259 
260  fCoreCoinc = MakeTH2<TH2F>("Core0_Core1","Core high gain versus low gain", 4096,0,4096,4096,0,4096);
261 }
262 
264 {
265  if ( fSeg )
266  delete fSeg;
267  if ( fCor )
268  delete fCor;
269  delete fSeg;
270  if ( fBaseLines )
271  delete fBaseLines;
272 }
273 
274 /*
275 char * ShowSignals::GetObjectInfo(Int_t px, Int_t py) const
276 {
277  static char info[50];
278  info[0] = 0;
279  snprintf(info,50,"To Work on Signals");
280 
281  return info;
282 }
283  */
284 
285 void ShowSignals::SetVRange(Int_t min, Int_t max)
286 {
287  fVMin = min; fVMax = max;
288 }
289 
290 void ShowSignals::SetHRange(Double_t min, Double_t max)
291 {
292  fHMin = min; fHMax = max;
293 }
294 
295 void ShowSignals::ProcessSignalBasic(Signal *sig, TH1 *fill_h)
296 {
297  Double_t baseline_value, net_signal_value; // Bool_t is_thr, is_over;
298  //
299  fFromSignal[0] = 0.0; // baseline position
300  fFromSignal[1] = 0.0; // net charge [from end of signal]
301  fFromSignal[2] = 0.0; // amplitude - baseline
302  fFromSignal[3] = 0.0;
303  fFromSignal[4] = 0.0;
304 
305  UInt_t range_for_baseline = sig->GetLength()/5, range_for_net_charge;
306 
307  range_for_baseline = TMath::Max(UInt_t(1), range_for_baseline); range_for_net_charge = sig->GetLength() - range_for_baseline;
308 
309  // baseline ... as mean value of the gRangeforBaseline first value
310  baseline_value = 0; net_signal_value = 0; // is_over = false; is_thr = false;
311 
312  // in principle should also check if the length is compatible
313  if ( sig->GetLength() == UInt_t(fill_h->GetNbinsX()) ) {
314  fill_h->Reset("ICE");
315  }
316  else {
317  fill_h->SetBins(sig->GetLength(),0,sig->GetLength());
318  }
319 
320  int Nvalforfaseline = 0, Nvalfornetcharge = 0;
321 
322  for (UInt_t j = 0; j < sig->GetLength(); j++ ) {
323 
324  // fill histogram
325  Short_t val = 0; val = sig->Get(val,j);
326  if( fill_h ) {
327 
328  fill_h->Fill(j,val);
329  }
330 
331  // compute baseline, overshoot etc ...
332  if ( j < range_for_baseline ) {
333  baseline_value += val;
334  Nvalforfaseline++;
335  }
336  if ( j > range_for_net_charge ) {
337  net_signal_value += val;
338  Nvalfornetcharge++;
339  }
340  }
341 
342  if ( Nvalforfaseline )
343  baseline_value = baseline_value / ((double)Nvalforfaseline);
344 
345  if ( Nvalfornetcharge )
346  net_signal_value = net_signal_value / ((double)Nvalfornetcharge);
347 
348  fFromSignal[0] = baseline_value;
349  fFromSignal[1] = net_signal_value;
350 }
351 
352 void ShowSignals::ProcessSignal(Signal *sig, TH1 *fill_h)
353 {
354  if ( fProcessingAlgo == "basic" ) {
356  }
358 }
359 
360 void ShowSignals::ShowArrow(Int_t which_sig)
361 {
362  if ( which_sig < fBaseLinesArrows.GetEntries() && fBaseLinesArrows[which_sig] ) {
363  fBaseLinesArrows[which_sig]->Draw();
364  }
365  if ( which_sig < fThresholdArrows.GetEntries() && fThresholdArrows[which_sig] ) {
366  fThresholdArrows[which_sig]->Draw();
367  }
368  if ( which_sig < fOvershootArrows.GetEntries() && fOvershootArrows[which_sig] ) {
369  fOvershootArrows[which_sig]->Draw();
370  }
371 }
372 
373 void ShowSignals::DoCanvas(TCanvas *c, Option_t *o)
374 {
375  TString opt = o; TH1 *h;
376 
377  if ( opt.Contains("sig") ) {
378  c->Divide(4,2,0.0001,0.0001);
379 
380  for (Int_t i = 0; i < 8; i++ ) {
381  c->cd(i+1);
382  if (i == 0) {
383  h = (TH1*)((TObjArray*)fCor->At(0))->At(0);
384  h->Draw();
385  for (Int_t j = 0; j < gkNB_SIG; j++ ) {
386  h = (TH1F *)((TObjArray*)fCor->At(0))->At(j);
387  h->Draw("same");
388  }
389  h = (TH1*)((TObjArray*)fCor->At(0))->At(0);
390  }
391  if (i == 1) {
392  h = (TH1*)((TObjArray*)fSeg->At(0))->At(0);
393  h->Draw();
394  for (Int_t j = 0; j < gkNB_SIG; j++ )
395  {
396  for(int k=0 ; k<6 ; k++)
397  {
398  h = (TH1*)((TObjArray*)fSeg->At(k))->At(j);
399  h->Draw("same");
400  }
401  }
402  }
403  if (i == 2) {
404  h = (TH1*)((TObjArray*)fSeg->At(6))->At(0);
405  h->Draw();
406  for (Int_t j = 0; j < gkNB_SIG; j++ )
407  {
408  for(int k=6 ; k<12 ; k++)
409  {
410  h = (TH1*)((TObjArray*)fSeg->At(k))->At(j);
411  h->Draw("same");
412  }
413  }
414  }
415  if (i == 3) {
416  h = (TH1*)((TObjArray*)fSeg->At(12))->At(0);
417  h->Draw();
418  for (Int_t j = 0; j < gkNB_SIG; j++ )
419  {
420  for(int k=12 ; k<18 ; k++)
421  {
422  h = (TH1*)((TObjArray*)fSeg->At(k))->At(j);
423  h->Draw("same");
424  }
425  }
426  }
427  if (i == 4) {
428  h = (TH1*)((TObjArray*)fCor->At(1))->At(0);
429  h->Draw();
430  for (Int_t j = 0; j < gkNB_SIG; j++ ) {
431  h = (TH1F *)((TObjArray*)fCor->At(1))->At(j);
432  h->Draw("same");
433  }
434  }
435  if (i == 5) {
436  h = (TH1*)((TObjArray*)fSeg->At(18))->At(0);
437  h->Draw();
438  for (Int_t j = 0; j < gkNB_SIG; j++ )
439  {
440  for(int k=18 ; k<24 ; k++)
441  {
442  h = (TH1*)((TObjArray*)fSeg->At(k))->At(j);
443  h->Draw("same");
444  }
445  }
446  }
447  if (i == 6) {
448  h = (TH1*)((TObjArray*)fSeg->At(24))->At(0);
449  h->Draw();
450  for (Int_t j = 0; j < gkNB_SIG; j++ )
451  {
452  for(int k=24 ; k<30 ; k++)
453  {
454  h = (TH1*)((TObjArray*)fSeg->At(k))->At(j);
455  h->Draw("same");
456  }
457  }
458  }
459  if (i == 7) {
460  h = (TH1*)((TObjArray*)fSeg->At(30))->At(0);
461  h->Draw();
462  for (Int_t j = 0; j < gkNB_SIG; j++ )
463  {
464  for(int k=30 ; k<36 ; k++)
465  {
466  h = (TH1*)((TObjArray*)fSeg->At(k))->At(j);
467  h->Draw("same");
468  }
469  }
470  }
471  }
472  return;
473  }
474  if ( opt.Contains("amp") ) {
475 
476  c->Divide(6,6,0.0001,0.0001);
477 
478  for(Int_t j = 0; j < CrystalInterface::kNbSegments; j++ ) {
479  c->cd(j+1);
480  fAmplitudes->At(CrystalInterface::kNbCores+j)->Draw();
481  }
482  return;
483  }
484  if ( opt.Contains("base") ) {
485 
486  c->Divide(6,6,0.0001,0.0001);
487 
488  for(Int_t j = 0; j < CrystalInterface::kNbSegments; j++ ) {
489  c->cd(j+1);
490  fBaseLines->At(CrystalInterface::kNbCores+j)->Draw();
491  // get tagged to display also
492  TString tmp = fBaseLines->At(CrystalInterface::kNbCores+j)->GetName();
493  tmp += "_Ref";
494  TObject *tag_object = GetReference().FindObject(tmp.Data());
495  if ( tag_object ) {
496  tag_object->Draw("same");
497  }
498  }
499  return;
500  }
501  c->Divide(2,2,0.0001,0.0001);
502  c->cd(1);
503  fEnergies->Draw("col");
504  c->cd(2);
505  //fCoinc->Draw("col");
506  fAmplitudes->At(0)->Draw();
507  c->cd(3);
508  fBaseLines->Draw("col");
509  c->cd(4);
510  fCoreCoinc->Draw("col");
511 }
512 
514 {
515  TCanvas *c = 0x0; TVirtualPad *current = TVirtualPad::Pad();
516 
517  if ( (c = (TCanvas *)gROOT->GetListOfCanvases()->FindObject("ShowSignals::ShowLastOnes")) ) {
518  }
519  else {
520  c = new TCanvas("ShowSignals::ShowLastOnes","ShowSignals::ShowLastOnes");
521  c->cd();
522  }
523  if ( c == 0x0 )
524  return;
525 
526  c->Clear();
527  c->Divide(6,6,0.001,0.001);
528 
529  c->SetCrosshair(true);
530 
531  // change current style
532  Float_t c_bot = gStyle->GetPadBottomMargin(); gStyle->SetPadBottomMargin(0.005);
533  Float_t c_top = gStyle->GetPadTopMargin(); gStyle->SetPadTopMargin(0.005);
534  Float_t c_lef = gStyle->GetPadLeftMargin(); gStyle->SetPadLeftMargin(0.005);
535  Float_t c_rig = gStyle->GetPadRightMargin(); gStyle->SetPadRightMargin(0.005);
536 
537  for (Int_t i = 0; i < CrystalInterface::kNbSegments; i++ ) {
538 
539  TH1 *h = (TH1 *)((TObjArray*)fSeg->At(i))->At(fCurrentSig), *hc = 0x0;
540  c->cd(i+1);
541  hc = h->DrawCopy();
542  hc->SetTitle(Form("Segment# %d",i));
543 
544  TVirtualPad::Pad()->UseCurrentStyle(); hc->SetStats(false); TVirtualPad::Pad()->SetEditable(kFALSE);
545  }
546 
547  // back to current style
548  gStyle->SetPadBottomMargin(c_bot);
549  gStyle->SetPadTopMargin(c_top);
550  gStyle->SetPadLeftMargin(c_lef);
551  gStyle->SetPadRightMargin(c_rig);
552 
553  if ( current )
554  current->cd();
555  c->Update();
556 }
557 
558 void ShowSignals::Exec(Option_t */*option*/)
559 {
560  // Frame by Frame action
561  TH1 *h; Double_t e[CrystalInterface::kNbCores];
562 
563  // be sure the frame has been set properly
564  if ( fFrame == 0x0 || !fFrame->IsValid() ) {
566  return;
567  }
568  if ( gDebug > 3 )
569  printf("ShowSignals::Exec is called \n");
570 
571  // to have access to the data content
572  CrystalInterface *data = GetDataPointer<CrystalInterface>(fFrame);
573 
574  // now fill histograms
575  fCoincThreshold.clear(); fCoincOverShoot.clear();
576  // core
577  for (Int_t i = 0; i < CrystalInterface::kNbCores; i++ ) {
578 
579  // get signal and histo to be filled
580  Signal *sig = data->GetCore(i)->GetSignal(); h = (TH1F *)((TObjArray*)fCor->At(i))->At(fCurrentSig);
581 
582  // process signal and fill histo
583  ProcessSignal(sig,h);
584 
585  // energy spectra
586  e[i] = data->GetCore(i)->GetE();
587  fEnergies->Fill(i,e[i]);
588 
589  // From the baseline distribution, compute mean value
590  TH1 *hbaseline = (TH1*)(fBaseLines->At(i));
591  hbaseline->Fill(fFromSignal[0]);
592  ((TH1*)(fAmplitudes->At(i)))->Fill(fFromSignal[1]-fFromSignal[0]);
593 
594  Double_t mean = hbaseline->GetMean();
595  Double_t rms = gArrowBaselineSigma*hbaseline->GetRMS();
596 
597  ((TArrow *)fBaseLinesArrows.At(i))->SetY1(mean);
598  ((TArrow *)fBaseLinesArrows.At(i))->SetY2(mean+rms);
599  ((TArrow *)fBaseLinesArrows.At(i))->SetY1(mean+rms);
600 
601  if ( fFromSignal[1] > (fFromSignal[0]+rms) ) {
602  if ( fFromSignal[1] > gMaxForOneSigna ) {
603  fCoincOverShoot.push_back(i);
604  }
605  else {
606  fCoincThreshold.push_back(i);
607  }
608  }
609 
610  // from signal
611  ((TH1*)(fBaseLines->At(i)))->Fill(fFromSignal[0]); ((TH1*)(fAmplitudes->At(i)))->Fill(fFromSignal[1]);
612 
613  // just for display
614  h->SetMinimum(fVMin); h->SetMaximum(fVMax);
615  h->SetAxisRange( TMath::Max(fHMin,h->GetXaxis()->GetXmin()),TMath::Min(fHMax,h->GetXaxis()->GetXmax()) );
616  }
617  fCoreCoinc->Fill(e[0],e[1]);
618 
619  // Segment
620  std::pair <Int_t,Double_t> unique_seg(0,0); Int_t nb_seg_fired = 0;
621  for (Int_t i = 0; i < CrystalInterface::kNbSegments; i++ ) {
622 
623  // get signal and histo to be filled
624  Signal *sig = data->GetSegment(i)->GetSignal(); h = (TH1F *)((TObjArray*)fSeg->At(i))->At(fCurrentSig);
625 
626  // process signal and fill histo
627  ProcessSignal(sig,h);
628 
629  fEnergies->Fill(i+CrystalInterface::kNbCores,data->GetSegment(i)->GetE());
630  //fTimes->Fill(i+CrystalInterface::kNbCores,data->GetCore(i)->GetT());
631 
632  // From the baseline distribution, compute mean value
633  TH1 *hbaseline = (TH1*)(fBaseLines->At(CrystalInterface::kNbCores+i));
634  hbaseline->Fill(fFromSignal[0]);
635  ((TH1*)(fAmplitudes->At(CrystalInterface::kNbCores+i)))->Fill(fFromSignal[1]);
636 
637  Double_t mean = hbaseline->GetMean();
638  Double_t rms = gArrowBaselineSigma*hbaseline->GetRMS();
639 
640  ((TArrow *)fBaseLinesArrows.At(CrystalInterface::kNbCores+i))->SetY1(mean);
641  ((TArrow *)fBaseLinesArrows.At(CrystalInterface::kNbCores+i))->SetY2(mean+rms);
642  ((TArrow *)fBaseLinesArrows.At(CrystalInterface::kNbCores+i))->SetY1(mean+rms);
643 
644  if ( fFromSignal[1] > (fFromSignal[0]+rms) ) {
645  if ( fFromSignal[1] > gMaxForOneSigna ) {
646  fCoincOverShoot.push_back(CrystalInterface::kNbCores+i);
647  }
648  else {
649  fCoincThreshold.push_back(CrystalInterface::kNbCores+i);
650  }
651  unique_seg.first = i;
652  unique_seg.second = fFromSignal[1];
653 
654  nb_seg_fired++;
655  }
656  h->SetMinimum(fVMin); h->SetMaximum(fVMax);
657  h->SetAxisRange( TMath::Max(fHMin,h->GetXaxis()->GetXmin()),TMath::Min(fHMax,h->GetXaxis()->GetXmax()) );
658  }
659  if ( nb_seg_fired == 1 ) {
660  ((TH1*)(fAmplitudes->At(CrystalInterface::kNbCores+unique_seg.first)))->Fill(unique_seg.second);
661  }
662 
663  // now fill coin spectra
664  for (size_t i = 0; i < fCoincThreshold.size(); i++) {
665  for (size_t j = i+1; j < fCoincThreshold.size(); j++) {
666  if ( i == j ) {
667  continue;
668  }
669  if ( fCoincThreshold[i] > 1 && fCoincThreshold[j] > 1 ) {
670  fCoinc->Fill(fCoincThreshold[i]-2,fCoincThreshold[j]-2);
671  fCoinc->Fill(fCoincThreshold[j]-2,fCoincThreshold[i]-2);
672  }
673  // std::cout << " th " << fCoincThreshold.size() << " " << fCoincThreshold[i] << " " << fCoincThreshold[j] << std::endl;
676  }
677  }
678  for (size_t i = 0; i < fCoincOverShoot.size(); i++) {
679  for (size_t j = i+1; j < fCoincOverShoot.size(); j++) {
680  if ( i == j ) {
681  continue;
682  }
683  // std::cout << " ov " << fCoincOverShoot.size() << " " << fCoincOverShoot[i] << " " << fCoincOverShoot[i] << std::endl;
684  fHOvershoot->Fill(fCoincOverShoot[i],fCoincOverShoot[j],fCoincOverShoot.size());
685  fHOvershoot->Fill(fCoincOverShoot[j],fCoincOverShoot[i],fCoincOverShoot.size());
686  }
687  }
688 
689  // next signal in the queue
690  fCurrentSig++;
691  if ( fCurrentSig == gkNB_SIG )
692  fCurrentSig = 0;
693 
694 }
695 
696 
virtual Double_t GetE() const
Definition: CrystalFrame.h:64
virtual Bool_t IsValid() const
true if it is a valid pointer
Definition: Frame.h:616
printf("******************************************************************** \n")
virtual Frame * GetFrame() const
Definition: Frame.h:625
static const Short_t gkNB_SIG
TH2 * fCoreCoinc
Core correlation core0 versus core1.
virtual GeCore * GetCore(UShort_t)=0
to get each core
TObjArray fThresholdArrows
TObjArray * fSeg
Array of last gkNB_SIG signals for core and segments.
Base class for a Frame.
Definition: Frame.h:73
virtual UShort_t Get(UShort_t, UInt_t) const =0
Method to get the value for a particular bin of the signal.
std::vector< Double_t > fFromSignal
Some characteritics extracted from the signal.
Int_t fVMin
to change the range to diplay signals
virtual GeSegment * GetSegment(UShort_t)=0
to get individual segment
virtual Signal * GetSignal()
Definition: CrystalFrame.h:56
TObjArray fOvershootArrows
std::vector< Int_t > fCoincOverShoot
TObjArray * fAmplitudes
virtual TObjArray & GetReference()
Definition: Watchers.h:318
TH2 * fEnergies
Energie for the different channels core and segments.
Data produced fro a Crystal.
Definition: CrystalFrame.h:106
void ShowLastOnes()
do get the last signal in a detector like view
virtual UInt_t GetLength() const =0
virtual void Exec(Option_t *option="")
change for that signal baseline, threshold and overshoot
Base class for a Signal.
Definition: Signals.h:39
void SetLastExecStatus(Short_t s=0)
reset last status. 0 means no error, 0 < means error, > 0 means ok with conditions ...
Definition: Watchers.h:294
static void SetDefaultArrow(Double_t baseline, Double_t threshold, Double_t overshoot, Double_t pos=10, Double_t length=1000)
overwritten to add some help
Base Watcher working for any kind of crystal Frame (Frame interface)
To work on Signals.
virtual Bool_t SetTrigger(ADF::DFTrigger *=0x0)
Set the trigger attached to this watcher.
TObjArray * fBaseLines
Baseline for the different channels core and segments.
void SetVRange(Int_t min=0, Int_t max=10000)
change vertical range
void ProcessSignalBasic(Signal *, TH1 *h=0x0)
void ProcessSignal(Signal *, TH1 *h=0x0)
Extract from signal some quantities Baseline, Amplitude, T0.
A Shared Frame Pointer.
Definition: Frame.h:597
void TagOn(TObject *)
Add this histogram to the list of tagged histograms.
Definition: Watchers.cpp:901
void SetHRange(Double_t min=0, Double_t max=100)
change horizontal range
Base class for a trigger on a data flow.
Definition: Trigger.h:155
virtual void DoCanvas(TCanvas *c, Option_t *)
To be overwritten by real implementation if a canvas is produced.
ShowSignals(const char *name="ShowSignals", const char *title="Display the signals for one crystal")
std::vector< Int_t > fCoincThreshold
to keep event by event the list of signals and overshoot
ClassImp(CrystalWatcher)
TObjArray fBaseLinesArrows
contains arrows corresponding respectively to baseline, threshold and overshoot for all detector ...
TH2 * fCoinc
Coincidence between segments [signals above the threshold].
TH3 * fHThreshold
keep statistcis for threshold and overshoot
const std::string & GetItemName() const
Definition: FactoryItem.h:78
void ShowArrow(Int_t which_sig=0)
display the different current levels (baseline,thresold, overshoot) for the corresponding signal ...
const FactoryItem & GetSignature() const
Signature of that frame.
Definition: Frame.h:127