GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GANIL/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 #include "TPavesText.h"
32 
33 namespace {
34 static Double_t gArrowL = 1000; // default length for arrow
35 static Double_t gArrowP = 10; // default position for arrow
36 static Double_t gArrowB = 4000; // default value for baseline
37 static Double_t gArrowT = 1000; // default value for threshold, baseline is the ref
38 static Double_t gArrowO = 6000; // default value for Overshoot, baseline is the ref
39 
40 static Double_t gArrowBaselineSigma = 5; // signal if amplitude > (1+gArrowBaselineSigma)*baseline
41 static Double_t gMaxForOneSigna = 10000; // signal if amplitude > (1+gArrowBaselineSigma)*baseline
42 
43 // from CrystalProducer ... later on should be from SandBox so that the same file could be use in any cases
44 UInt_t gRangeforBaseline = 20;
45 Float_t fSpekGain = 1.f; // good for trapezoid risetime 1000
46 Float_t fMinSegAmpli = 500.f; // ~50 (150) keV for high(low) gain range if shaping = 1000
47 UInt_t fRawAmplitude = 0; // don't produce amplitude spectra from raw traces
48 }
49 
50 using namespace ADF;
51 
52 //ClassImp(CrystalWatcher);
53 
55 {
56  // check if this trigger is not a zombie
57  if ( ! Watcher::SetTrigger(trigger) )
58  return false;
59 
60  // loop the different input frames to look for a crytal one, whatever the version
61  SharedFP *ffind = 0x0;
62  UInt_t which;
63  for( which = 0u; which < GetTrigger()->GetNbInputFrame(); which++){
64 
65  SharedFP *fp = GetTrigger()->GetInputSharedFP(which);
66  if ( fp == 0x0 )
67  continue;
68 
69  Frame *f = fp->GetFrame();
70  if ( f == 0x0 )
71  continue;
72 
73  // check if the currenet frame is a version of a tracked frame
74  TString ftype = f->GetSignature().GetItemName();
75 
76  if ( ftype.Contains("data") && ftype.Contains("crystal") ) {
77  ffind = fp;
78  break;
79  }
80  }
81  if ( ffind )
82  fFrame = ffind;
83  else
84  fFrame = 0x0;
85 
86  return fFrame != 0x0;
87 }
88 
89 //ClassImp(ShowSignals);
90 
91 void ShowSignals::SetDefaultArrow(Double_t baseline, Double_t threshold, Double_t overshoot, Double_t pos, Double_t length)
92 {
93  gArrowL = length; // default length for arrow
94  gArrowP = pos; // default position for arrow
95  gArrowB = baseline; // default value for baseline
96  gArrowT = threshold; // default value for threshold, baseline is the ref
97  gArrowO = overshoot; // default value for Overshoot, baseline is the ref
98 }
99 
100 ShowSignals::ShowSignals(const char *name, const char *title) :
101  CrystalWatcher(name,title),
102  fCurrentSig(0),
103  fProcessingAlgo("basic"),
104  fEnergies(0x0),
105  fSeg( new TObjArray(CrystalInterface::kNbSegments) ),
106  fCor( new TObjArray(CrystalInterface::kNbCores) ),
107  fVMin(0),
108  fVMax(10000),
109  fHMin(0),
110  fHMax(100),
111  fBaseLines ( new TObjArray(CrystalInterface::kNbCores+CrystalInterface::kNbSegments) ),
112  fSpectra( new TObjArray(CrystalInterface::kNbCores+CrystalInterface::kNbSegments) ),
113  fAmplitudes( new TObjArray(CrystalInterface::kNbCores+CrystalInterface::kNbSegments) ),
114  fFromSignal(5),
115  fHThreshold(0x0),
116  fHOvershoot(0x0),
117  fCoincThreshold(CrystalInterface::kNbCores+CrystalInterface::kNbSegments),
118  fCoincOverShoot(CrystalInterface::kNbCores+CrystalInterface::kNbSegments),
119  fCoinc(0x0),
120  fCoreCoinc(0x0),
121  fBaseLinesArrows(CrystalInterface::kNbCores+CrystalInterface::kNbSegments),
122  fThresholdArrows(CrystalInterface::kNbCores+CrystalInterface::kNbSegments),
123  fOvershootArrows(CrystalInterface::kNbCores+CrystalInterface::kNbSegments)
124 {
125  Color_t color[6] = {1, 4, 2, 8 , 27, 6}; TArrow *arrow; TString hname, htitle; TH1 *h;
126  // energie as read in the ADF Frame. It comes from the digitizers
127  fEnergies = MakeTH2<TH2F>("ADC","ADC for Core and Segments",
128  CrystalInterface::kNbCores+CrystalInterface::kNbSegments,0,CrystalInterface::kNbCores+CrystalInterface::kNbSegments,16384,0,8192);
129  fEnergies->GetXaxis()->SetTitle("bin [0,1] for Core and [2,38] for Segments");
130 
131  // per core/segment
132  fCor->SetOwner();
133  fSeg->SetOwner();
134 
135  for (Int_t i = 0; i < CrystalInterface::kNbCores; i++ ) {
136 
137  // baseline distribution
138  hname = Form("BaseLine_Core%d",i);
139  h = MakeTH1<TH1F>(hname.Data(),hname.Data(), 16384,0,16384);
140 // h->GetXaxis()->SetTitle("Baseline Position");
141 // h->GetYaxis()->SetTitle("Counts");
142  h->SetLineColor(kRed);
143  h->SetFillColor(kRed);
144  fBaseLines->AddAt(h,i);
145 
146  // spectra distribution
147  hname = Form("Spectra_Core%d",i);
148  h = MakeTH1<TH1F>(hname.Data(),hname.Data(), 16384,0,16384);
149 // h->GetXaxis()->SetTitle("RawValue");
150 // h->GetYaxis()->SetTitle("Amplitude");
151  h->SetLineColor(kRed);
152  fSpectra->AddAt(h,i);
153 
154  // amplitudes distribution
155  hname = Form("Amplitude_Core%d",i);
156  h = MakeTH1<TH1F>(hname.Data(),hname.Data(), 16384,0,16384);
157 // h->GetXaxis()->SetTitle("Signal Amplitude");
158 // h->GetYaxis()->SetTitle("Counts");
159  h->SetLineColor(kRed);
160  h->SetFillColor(kRed);
161  fAmplitudes->AddAt(h,i);
162 
163  TObjArray *SigArray = new TObjArray(gkNB_SIG);
164  fCor->AddAt(SigArray,i);
165 
166  for (Int_t j = 0; j < gkNB_SIG; j++ ) {
167  hname = Form("Core%d_Sig%d",i,j);
168  h = MakeTH1<TH1F>(hname.Data(),hname.Data(),
169  CrystalInterface::kDefaultLength,0,CrystalInterface::kDefaultLength,"LastSignals");
170  h->GetXaxis()->SetTitle("RawValue");
171  h->GetYaxis()->SetTitle("Counts");
172 
173  h->SetStats(kFALSE);
174  h->SetLineColor(kRed);
175  ((TObjArray*)fCor->At(i))->AddAt(h,j);
176  }
177  arrow = new TArrow(gArrowP,gArrowB,gArrowP,gArrowB+gArrowL,0.05,"<|" );
178  arrow->SetAngle(45);
179  arrow->SetArrowSize(0.015);
180  arrow->SetLineColor(kRed);
181  arrow->SetFillColor(kRed);
182  fBaseLinesArrows.Add( arrow );
183 
184  arrow = new TArrow(gArrowP+10,gArrowB+gArrowT,gArrowP+10,gArrowB+gArrowT+gArrowL,0.05,"<|>" );
185  arrow->SetAngle(45);
186  arrow->SetArrowSize(0.015);
187  arrow->SetLineColor(kRed);
188  arrow->SetFillColor(kRed);
189  fThresholdArrows.Add( arrow );
190 
191  arrow = new TArrow(gArrowP+20,gArrowB-gArrowL+gArrowO,gArrowP+20,gArrowB+gArrowO,0.05,"|>" );
192  arrow->SetAngle(45);
193  arrow->SetArrowSize(0.015);
194  arrow->SetLineColor(kRed);
195  arrow->SetFillColor(kRed);
196  fOvershootArrows.Add( arrow );
197  }
198  for (Int_t i = 0; i < CrystalInterface::kNbSegments; i++ ) {
199 
200  // baseline distribution
201  hname = Form("BaseLine_Seg%d",i);
202  h = MakeTH1<TH1F>(hname.Data(),hname.Data(), 16384,0,16384);
203  h->GetXaxis()->SetTitle("Baseline Position");
204  h->GetYaxis()->SetTitle("Counts");
205  h->SetLineColor(color[i%6]);
206  h->SetFillColor(color[i%6]);
207  fBaseLines->AddAt(h,CrystalInterface::kNbCores+i); TagOn(h);
208 
209  // spectra distribution
210  hname = Form("Spectra_Seg%d",i);
211  h = MakeTH1<TH1F>(hname.Data(),hname.Data(), 16384,0,16384);
212  h->GetXaxis()->SetTitle("RawValue");
213  h->GetYaxis()->SetTitle("Counts");
214  h->SetLineColor(kRed);
215  fSpectra->AddAt(h,CrystalInterface::kNbCores+i);
216 
217  // amplitudes distribution
218  hname = Form("Amplitude_Seg%d",i);
219  h = MakeTH1<TH1F>(hname.Data(),hname.Data(), 16384,0,16384);
220  h->GetXaxis()->SetTitle("Signal Amplitude");
221  h->GetYaxis()->SetTitle("Counts");
222  h->SetLineColor(color[i%6]);
223  h->SetFillColor(color[i%6]);
224  fAmplitudes->AddAt(h,CrystalInterface::kNbCores+i);
225 
226  TObjArray *SigArray = new TObjArray(gkNB_SIG);
227  fSeg->AddAt(SigArray,i);
228 
229  for (Int_t j = 0; j < gkNB_SIG; j++ ) {
230  hname = Form("Segment%d_Sig%d",i,j);
231  htitle = Form("Seg #color[1]{%d} #color[4]{%d} #color[2]{%d} #color[8]{%d} #color[27]{%d} #color[6]{%d}",
232  i, i+1, i+2, i+3, i+4, i+5);
233  h = MakeTH1<TH1F>(hname.Data(),htitle.Data(),
234  CrystalInterface::kDefaultLength,0,CrystalInterface::kDefaultLength,"LastSignals");
235  h->GetXaxis()->SetTitle("Time");
236  h->GetYaxis()->SetTitle("Amplitude");
237 
238  h->SetStats(kFALSE);
239  h->SetLineColor(color[i%6]);
240  ((TObjArray*)fSeg->At(i))->AddAt(h,j);
241 
242  }
243  arrow = new TArrow(gArrowP,gArrowB,gArrowP,gArrowB+gArrowL,0.05,"<|" );
244  arrow->SetAngle(45);
245  arrow->SetArrowSize(0.015);
246  arrow->SetLineColor(color[i%6]);
247  arrow->SetFillColor(color[i%6]);
248  fBaseLinesArrows.Add( arrow );
249 
250  arrow = new TArrow(gArrowP+10,gArrowB+gArrowT,gArrowP+10,gArrowB+gArrowT+gArrowL,0.05,"<|>" );
251  arrow->SetAngle(45);
252  arrow->SetArrowSize(0.015);
253  arrow->SetLineColor(color[i%6]);
254  arrow->SetFillColor(color[i%6]);
255  fThresholdArrows.Add( arrow );
256 
257  arrow = new TArrow(gArrowP+20,gArrowB-gArrowL+gArrowO,gArrowP+20,gArrowB+gArrowO,0.05,"|>" );
258  arrow->SetAngle(45);
259  arrow->SetArrowSize(0.015);
260  arrow->SetLineColor(color[i%6]);
261  arrow->SetFillColor(color[i%6]);
262  fOvershootArrows.Add( arrow );
263  }
264  fHThreshold = MakeTH3<TH3F>("Threshold3D","Signals that are greater that threshold",
265  CrystalInterface::kNbCores+CrystalInterface::kNbSegments,0,CrystalInterface::kNbCores+CrystalInterface::kNbSegments,
266  CrystalInterface::kNbCores+CrystalInterface::kNbSegments,0,CrystalInterface::kNbCores+CrystalInterface::kNbSegments,
267  15,0,15);
268  fHOvershoot = MakeTH3<TH3F>("Overshoot","Signals that are greater that overshoot",
269  CrystalInterface::kNbCores+CrystalInterface::kNbSegments,0,CrystalInterface::kNbCores+CrystalInterface::kNbSegments,
270  CrystalInterface::kNbCores+CrystalInterface::kNbSegments,0,CrystalInterface::kNbCores+CrystalInterface::kNbSegments,
271  15,0,15);
272 
273  fCoinc = MakeTH2<TH2F>("Threshold2D","Signals that are greater that threshold",
274  CrystalInterface::kNbSegments,0,CrystalInterface::kNbSegments,
275  CrystalInterface::kNbSegments,0,CrystalInterface::kNbSegments);
276  fCoinc->GetXaxis()->SetTitle("Segment #");
277  fCoinc->GetYaxis()->SetTitle("Segment #");
278 
279  fCoreCoinc = MakeTH2<TH2F>("Core0_Core1","Core high gain versus low gain", 4096,0,4096,4096,0,4096);
280 }
281 
283 {
284  if ( fSeg )
285  delete fSeg;
286  if ( fCor )
287  delete fCor;
288  if ( fBaseLines )
289  delete fBaseLines;
290  if ( fSpectra )
291  delete fSpectra;
292 }
293 
294 /*
295 char * ShowSignals::GetObjectInfo(Int_t px, Int_t py) const
296 {
297  static char info[50];
298  info[0] = 0;
299  snprintf(info,50,"To Work on Signals");
300 
301  return info;
302 }
303  */
304 
305 void ShowSignals::SetVRange(Int_t min, Int_t max)
306 {
307  fVMin = min; fVMax = max;
308 }
309 
310 void ShowSignals::SetHRange(Double_t min, Double_t max)
311 {
312  fHMin = min; fHMax = max;
313 }
314 
316 {
317  Double_t baseline_value, net_signal_value; // Bool_t is_thr, is_over;
318  //
319  fFromSignal[0] = 0.0; // baseline position
320  fFromSignal[1] = 0.0; // net charge [from end of signal]
321  fFromSignal[2] = 0.0; // amplitude - baseline
322  fFromSignal[3] = 0.0;
323  fFromSignal[4] = 0.0;
324 
325  UInt_t range_for_baseline = sig->GetLength()/5, range_for_net_charge;
326 
327  range_for_baseline = TMath::Max(UInt_t(1), range_for_baseline); range_for_net_charge = sig->GetLength() - range_for_baseline;
328 
329  // baseline ... as mean value of the gRangeforBaseline first value
330  baseline_value = 0; net_signal_value = 0; // is_over = false; is_thr = false;
331 
332  // in principle should also check if the length is compatible
333  if ( sig->GetLength() == UInt_t(fill_h->GetNbinsX()) ) {
334  fill_h->Reset("ICE");
335  }
336  else {
337  fill_h->SetBins(sig->GetLength(),0,sig->GetLength());
338  }
339 
340  int Nvalforfaseline = 0, Nvalfornetcharge = 0;
341 
342  for (UInt_t j = 0; j < sig->GetLength(); j++ ) {
343 
344  // fill histogram
345  Short_t val = 0; val = sig->Get(val,j);
346  if( fill_h ) {
347 
348  fill_h->Fill(j,val);
349  }
350 
351  // compute baseline, overshoot etc ...
352  if ( j < range_for_baseline ) {
353  baseline_value += val;
354  Nvalforfaseline++;
355  }
356  if ( j > range_for_net_charge ) {
357  net_signal_value += val;
358  Nvalfornetcharge++;
359  }
360  }
361 
362  if ( Nvalforfaseline )
363  baseline_value = baseline_value / ((double)Nvalforfaseline);
364 
365  if ( Nvalfornetcharge )
366  net_signal_value = net_signal_value / ((double)Nvalfornetcharge);
367 
368  fFromSignal[0] = baseline_value;
369  fFromSignal[1] = net_signal_value;
370 }
371 
372 void ShowSignals::ProcessSignal(Signal *sig, TH1 *fill_h)
373 {
374  if ( fProcessingAlgo == "basic" ) {
376  }
378 }
379 
380 void ShowSignals::ShowArrow(Int_t which_sig)
381 {
382  if ( which_sig < fBaseLinesArrows.GetEntries() && fBaseLinesArrows[which_sig] ) {
383  fBaseLinesArrows[which_sig]->Draw();
384  }
385  if ( which_sig < fThresholdArrows.GetEntries() && fThresholdArrows[which_sig] ) {
386  fThresholdArrows[which_sig]->Draw();
387  }
388  if ( which_sig < fOvershootArrows.GetEntries() && fOvershootArrows[which_sig] ) {
389  fOvershootArrows[which_sig]->Draw();
390  }
391 }
392 
393 void ShowSignals::DoCanvas(TCanvas *c, Option_t *o)
394 {
395  TString opt = o; TH1 *h;
396 
397  if ( opt.Contains("sig") ) {
398  c->Divide(4,2,0.0001,0.0001);
399 
400  for (Int_t i = 0; i < 8; i++ ) {
401  c->cd(i+1);
402  if (i == 0) {
403  h = (TH1*)((TObjArray*)fCor->At(0))->At(0);
404  h->Draw();
405  for (Int_t j = 0; j < gkNB_SIG; j++ ) {
406  h = (TH1F *)((TObjArray*)fCor->At(0))->At(j);
407  h->Draw("same");
408  }
409  h = (TH1*)((TObjArray*)fCor->At(0))->At(0);
410  }
411  if (i == 1) {
412  h = (TH1*)((TObjArray*)fSeg->At(0))->At(0);
413  h->Draw();
414  for (Int_t j = 0; j < gkNB_SIG; j++ )
415  {
416  for(int k=0 ; k<6 ; k++)
417  {
418  h = (TH1*)((TObjArray*)fSeg->At(k))->At(j);
419  h->Draw("same");
420  }
421  }
422  }
423  if (i == 2) {
424  h = (TH1*)((TObjArray*)fSeg->At(6))->At(0);
425  h->Draw();
426  for (Int_t j = 0; j < gkNB_SIG; j++ )
427  {
428  for(int k=6 ; k<12 ; k++)
429  {
430  h = (TH1*)((TObjArray*)fSeg->At(k))->At(j);
431  h->Draw("same");
432  }
433  }
434  }
435  if (i == 3) {
436  h = (TH1*)((TObjArray*)fSeg->At(12))->At(0);
437  h->Draw();
438  for (Int_t j = 0; j < gkNB_SIG; j++ )
439  {
440  for(int k=12 ; k<18 ; k++)
441  {
442  h = (TH1*)((TObjArray*)fSeg->At(k))->At(j);
443  h->Draw("same");
444  }
445  }
446  }
447  if (i == 4) {
448  h = (TH1*)((TObjArray*)fCor->At(1))->At(0);
449  h->Draw();
450  for (Int_t j = 0; j < gkNB_SIG; j++ ) {
451  h = (TH1F *)((TObjArray*)fCor->At(1))->At(j);
452  h->Draw("same");
453  }
454  }
455  if (i == 5) {
456  h = (TH1*)((TObjArray*)fSeg->At(18))->At(0);
457  h->Draw();
458  for (Int_t j = 0; j < gkNB_SIG; j++ )
459  {
460  for(int k=18 ; k<24 ; k++)
461  {
462  h = (TH1*)((TObjArray*)fSeg->At(k))->At(j);
463  h->Draw("same");
464  }
465  }
466  }
467  if (i == 6) {
468  h = (TH1*)((TObjArray*)fSeg->At(24))->At(0);
469  h->Draw();
470  for (Int_t j = 0; j < gkNB_SIG; j++ )
471  {
472  for(int k=24 ; k<30 ; k++)
473  {
474  h = (TH1*)((TObjArray*)fSeg->At(k))->At(j);
475  h->Draw("same");
476  }
477  }
478  }
479  if (i == 7) {
480  h = (TH1*)((TObjArray*)fSeg->At(30))->At(0);
481  h->Draw();
482  for (Int_t j = 0; j < gkNB_SIG; j++ )
483  {
484  for(int k=30 ; k<36 ; k++)
485  {
486  h = (TH1*)((TObjArray*)fSeg->At(k))->At(j);
487  h->Draw("same");
488  }
489  }
490  }
491  }
492  return;
493  }
494  if ( opt.Contains("amp") ) {
495 
496  c->Divide(6,6,0.0001,0.0001);
497 
498  for(Int_t j = 0; j < CrystalInterface::kNbSegments; j++ ) {
499  c->cd(j+1);
500  fAmplitudes->At(CrystalInterface::kNbCores+j)->Draw();
501  }
502  return;
503  }
504  if ( opt.Contains("base") ) {
505 
506  c->Divide(6,6,0.0001,0.0001);
507 
508  for(Int_t j = 0; j < CrystalInterface::kNbSegments; j++ ) {
509  c->cd(j+1);
510  fBaseLines->At(CrystalInterface::kNbCores+j)->Draw();
511  // get tagged to display also
512  TString tmp = fBaseLines->At(CrystalInterface::kNbCores+j)->GetName();
513  tmp += "_Ref";
514  TObject *tag_object = GetReference().FindObject(tmp.Data());
515  if ( tag_object ) {
516  tag_object->Draw("same");
517  }
518  }
519  return;
520  }
521  c->Divide(2,2,0.0001,0.0001);
522  c->cd(1);
523  fEnergies->Draw("col");
524  c->cd(2);
525  //fCoinc->Draw("col");
526  fAmplitudes->At(0)->Draw();
527  c->cd(3);
528  fBaseLines->Draw("col");
529  c->cd(4);
530  fCoreCoinc->Draw("col");
531 }
532 
534 {
535  TCanvas *c = 0x0; TVirtualPad *current = TVirtualPad::Pad();
536 
537  if ( (c = (TCanvas *)gROOT->GetListOfCanvases()->FindObject("ShowSignals::ShowLastOnes")) ) {
538  }
539  else {
540  c = new TCanvas("ShowSignals::ShowLastOnes","ShowSignals::ShowLastOnes");
541  c->cd();
542  }
543  if ( c == 0x0 )
544  return;
545 
546  c->Clear();
547  c->Divide(6,6,0.001,0.001);
548 
549  c->SetCrosshair(true);
550 
551  // change current style
552  Float_t c_bot = gStyle->GetPadBottomMargin(); gStyle->SetPadBottomMargin(0.005);
553  Float_t c_top = gStyle->GetPadTopMargin(); gStyle->SetPadTopMargin(0.005);
554  Float_t c_lef = gStyle->GetPadLeftMargin(); gStyle->SetPadLeftMargin(0.005);
555  Float_t c_rig = gStyle->GetPadRightMargin(); gStyle->SetPadRightMargin(0.005);
556 
557  for (Int_t i = 0; i < CrystalInterface::kNbSegments; i++ ) {
558 
559  TH1 *h = (TH1 *)((TObjArray*)fSeg->At(i))->At(fCurrentSig), *hc = 0x0;
560  c->cd(i+1);
561  hc = h->DrawCopy();
562  hc->SetTitle(Form("Segment# %d",i));
563 
564  TVirtualPad::Pad()->UseCurrentStyle(); hc->SetStats(false); TVirtualPad::Pad()->SetEditable(kFALSE);
565  }
566 
567  // back to current style
568  gStyle->SetPadBottomMargin(c_bot);
569  gStyle->SetPadTopMargin(c_top);
570  gStyle->SetPadLeftMargin(c_lef);
571  gStyle->SetPadRightMargin(c_rig);
572 
573  if ( current )
574  current->cd();
575  c->Update();
576 }
577 
578 void ShowSignals::Exec(Option_t */*option*/)
579 {
580  // Frame by Frame action
581  TH1 *h; Double_t e[CrystalInterface::kNbCores];
582 
583  // be sure the frame has been set properly
584  if ( fFrame == 0x0 || !fFrame->IsValid() ) {
586  return;
587  }
588  if ( gDebug > 3 )
589  printf("ShowSignals::Exec is called \n");
590 
591  // to have access to the data content
592  CrystalInterface *data = GetDataPointer<CrystalInterface>(fFrame);
593 
594  // now fill histograms
595  fCoincThreshold.clear(); fCoincOverShoot.clear();
596  // core
597  for (Int_t i = 0; i < CrystalInterface::kNbCores; i++ ) {
598 
599  // get signal and histo to be filled
600  Signal *sig = data->GetCore(i)->GetSignal(); h = (TH1F *)((TObjArray*)fCor->At(i))->At(fCurrentSig);
601 
602  // process signal and fill histo
603  ProcessSignal(sig,h);
604 
605  // energy spectra
606  e[i] = data->GetCore(i)->GetE();
607  fEnergies->Fill(i,e[i]);
608  ((TH1*)(fSpectra->At(i)))->Fill(e[i]);
609 
610  // From the baseline distribution, compute mean value
611  TH1 *hbaseline = (TH1*)(fBaseLines->At(i));
612  hbaseline->Fill(fFromSignal[0]);
613  ((TH1*)(fAmplitudes->At(i)))->Fill(fFromSignal[1]-fFromSignal[0]);
614 
615  Double_t mean = hbaseline->GetMean();
616  Double_t rms = gArrowBaselineSigma*hbaseline->GetRMS();
617 
618  ((TArrow *)fBaseLinesArrows.At(i))->SetY1(mean);
619  ((TArrow *)fBaseLinesArrows.At(i))->SetY2(mean+rms);
620  ((TArrow *)fBaseLinesArrows.At(i))->SetY1(mean+rms);
621 
622  if ( fFromSignal[1] > (fFromSignal[0]+rms) ) {
623  if ( fFromSignal[1] > gMaxForOneSigna ) {
624  fCoincOverShoot.push_back(i);
625  }
626  else {
627  fCoincThreshold.push_back(i);
628  }
629  }
630 
631  // from signal
632  ((TH1*)(fBaseLines->At(i)))->Fill(fFromSignal[0]); ((TH1*)(fAmplitudes->At(i)))->Fill(fFromSignal[1]);
633 
634  // just for display
635  h->SetMinimum(fVMin); h->SetMaximum(fVMax);
636  h->SetAxisRange( TMath::Max(fHMin,h->GetXaxis()->GetXmin()),TMath::Min(fHMax,h->GetXaxis()->GetXmax()) );
637  }
638  fCoreCoinc->Fill(e[0],e[1]);
639 
640  // Segment
641  std::pair <Int_t,Double_t> unique_seg(0,0); Int_t nb_seg_fired = 0;
642  for (Int_t i = 0; i < CrystalInterface::kNbSegments; i++ ) {
643 
644  // get signal and histo to be filled
645  Signal *sig = data->GetSegment(i)->GetSignal(); h = (TH1F *)((TObjArray*)fSeg->At(i))->At(fCurrentSig);
646 
647  // process signal and fill histo
648  ProcessSignal(sig,h);
649 
650  fEnergies->Fill(i+CrystalInterface::kNbCores,data->GetSegment(i)->GetE());
651  ((TH1*)(fSpectra->At(CrystalInterface::kNbCores+i)))->Fill(data->GetSegment(i)->GetE());
652 
653  //fTimes->Fill(i+CrystalInterface::kNbCores,data->GetCore(i)->GetT());
654 
655  // From the baseline distribution, compute mean value
656  TH1 *hbaseline = (TH1*)(fBaseLines->At(CrystalInterface::kNbCores+i));
657  hbaseline->Fill(fFromSignal[0]);
658  ((TH1*)(fAmplitudes->At(CrystalInterface::kNbCores+i)))->Fill(fFromSignal[1]);
659 
660  Double_t mean = hbaseline->GetMean();
661  Double_t rms = gArrowBaselineSigma*hbaseline->GetRMS();
662 
663  ((TArrow *)fBaseLinesArrows.At(CrystalInterface::kNbCores+i))->SetY1(mean);
664  ((TArrow *)fBaseLinesArrows.At(CrystalInterface::kNbCores+i))->SetY2(mean+rms);
665  ((TArrow *)fBaseLinesArrows.At(CrystalInterface::kNbCores+i))->SetY1(mean+rms);
666 
667  if ( fFromSignal[1] > (fFromSignal[0]+rms) ) {
668  if ( fFromSignal[1] > gMaxForOneSigna ) {
669  fCoincOverShoot.push_back(CrystalInterface::kNbCores+i);
670  }
671  else {
672  fCoincThreshold.push_back(CrystalInterface::kNbCores+i);
673  }
674  unique_seg.first = i;
675  unique_seg.second = fFromSignal[1];
676 
677  nb_seg_fired++;
678  }
679  h->SetMinimum(fVMin); h->SetMaximum(fVMax);
680  h->SetAxisRange( TMath::Max(fHMin,h->GetXaxis()->GetXmin()),TMath::Min(fHMax,h->GetXaxis()->GetXmax()) );
681  }
682  if ( nb_seg_fired == 1 ) {
683  ((TH1*)(fAmplitudes->At(CrystalInterface::kNbCores+unique_seg.first)))->Fill(unique_seg.second);
684  }
685 
686  // now fill coin spectra
687  for (size_t i = 0; i < fCoincThreshold.size(); i++) {
688  for (size_t j = i+1; j < fCoincThreshold.size(); j++) {
689  if ( i == j ) {
690  continue;
691  }
692  if ( fCoincThreshold[i] > 1 && fCoincThreshold[j] > 1 ) {
693  fCoinc->Fill(fCoincThreshold[i]-2,fCoincThreshold[j]-2);
694  fCoinc->Fill(fCoincThreshold[j]-2,fCoincThreshold[i]-2);
695  }
696  // std::cout << " th " << fCoincThreshold.size() << " " << fCoincThreshold[i] << " " << fCoincThreshold[j] << std::endl;
699  }
700  }
701  for (size_t i = 0; i < fCoincOverShoot.size(); i++) {
702  for (size_t j = i+1; j < fCoincOverShoot.size(); j++) {
703  if ( i == j ) {
704  continue;
705  }
706  // std::cout << " ov " << fCoincOverShoot.size() << " " << fCoincOverShoot[i] << " " << fCoincOverShoot[i] << std::endl;
709  }
710  }
711 
712  // next signal in the queue
713  fCurrentSig++;
714  if ( fCurrentSig == gkNB_SIG )
715  fCurrentSig = 0;
716 
717 }
718 
719 
721 
722 //ClassImp(CrystalSpectra);
723 
724 #include "TH1.h"
725 
726 CrystalSpectra::CrystalSpectra(const char *name, const char *title) :
727  ShowSignals(name,title),
728  CanvasVisu(name,title)
729 {
730  TObjArray *arr = ((TString)GetName()).Tokenize("_");
731 
732  if(((TString)GetName()).EndsWith("_")) fCrystalName = "";
733  else fCrystalName = arr->Last()->GetName();
734 
735  TString RawOrCal_Name="";
736  TString RawOrCal_Title="";
737  TString Type = GetName();
738  Type.ToLower();
739  if(Type.Contains("ccrystal"))
740  {
741  RawOrCal_Name = "CalSpectra";
742  RawOrCal_Title = "calibrated";
743  }
744  else{
745  RawOrCal_Name = "RawSpectra";
746  RawOrCal_Title = "raw";
747  }
748 
749  TH1 *h;
750 
751  for(int i=0 ; i<CrystalInterface::kNbSegments ; i++)
752  {
753  PadPos HistPosition = fHistPositionList[i];
754 
755  h = ((TH1*)fSpectra->At(CrystalInterface::kNbCores + i));
756  TString Name = (TString)"Cry_" + fCrystalName + "_Seg_" + HistPosition.SegName.ReplaceAll(" ","_") + "_" + RawOrCal_Name;
757  h->SetNameTitle(Name,Name);
758  h = ((TH1*)fBaseLines->At(CrystalInterface::kNbCores + i));
759  h->SetName((TString)"Cry_" + fCrystalName + "_Seg_" + HistPosition.SegName.ReplaceAll(" ","_") + "_BaseLine");
760  }
761  for(int i=0 ; i<CrystalInterface::kNbCores ; i++)
762  {
763  PadPos HistPosition = fHistPositionList[CrystalInterface::kNbSegments+i];;
764 
765  h = ((TH1*)fSpectra->At(i));
766  TString Name = (TString)"Cry_" + fCrystalName + "_" + HistPosition.SegName.ReplaceAll(" ","_") + "_" + RawOrCal_Name;
767  h->SetNameTitle(Name,Name);
768  h = ((TH1*)fBaseLines->At(i));
769  h->SetName((TString)"Cry_" + fCrystalName + "_" + HistPosition.SegName.ReplaceAll(" ","_") + "_BaseLine");
770  }
771 
772  fEnergies->SetName(Form("Cry_%s_EvsSegID",fCrystalName.Data()));
773  fEnergies->SetTitle(fEnergies->GetName());
774 
775 }
776 
778 {
779 
780 }
781 
782 void CrystalSpectra::ShowSignalsMap(int NbrOfSignals)
783 {
784  fNbrOfSignals = NbrOfSignals;
785 
786  if(fNbrOfSignals>10)
787  {
788  cout<<"Warning: max number or overimposed signals is 10, NbrOfSignals set to 10"<<endl;
789  fNbrOfSignals = 10;
790  }
791 
792  CrystalInterface *data = GetDataPointer<CrystalInterface>(fFrame);
793  int CrystalID = data->GetUID();
794  TString CrystalName = GetCrystalNameFromID(CrystalID);
795  TString Name = "SignalsMap_" + CrystalName;
796  TString Title = "Mapping of the signals for crystal " + CrystalName;
797 
798  TCanvas *c = CanvasVisu::BuildSegmentedCanvas(Name,Title);
799  if(c == 0x0) return;
800 
801  c->cd();
802 
803  for(int i=0 ; i<CrystalInterface::kNbSegments ; i++)
804  {
805  PadPos HistPosition = fHistPositionList[i];
806 
807  TPad *pad = (TPad*)c->cd(HistPosition.PadNmbr);
808 
809  TH1 *h = 0x0;
810 
811  TPaveText *p = (TPaveText*)pad->GetListOfPrimitives()->FindObject("InfoPad");
812 
813  for (Int_t j = 0; j < fNbrOfSignals; j++ )
814  {
815  h = (TH1*)((TObjArray*)fSeg->At(i))->At(j);
816  h->SetName((TString)"Cry_" + CrystalName + "_Seg_" + HistPosition.SegName + Form("_Sig%d",j+1));
817  h->SetTitle((TString)"Cry_" + CrystalName + "_Seg_" + HistPosition.SegName + Form("_Sig%d",j+1));
818  h->SetLineColor(GetColor(j));
819  h->GetXaxis()->SetLabelSize(0.07);
820  h->GetYaxis()->SetLabelSize(0.07);
821 
822  if(j==0)
823  {
824  h->Draw();
825 // h->SetMinimum(3500);
826 // h->SetMaximum(7000);
827  }
828  else
829  {
830  h->Draw("same");
831  }
832  }
833 
834  if(p)p->Draw();
835  }
836  for(int i=0 ; i<CrystalInterface::kNbCores ; i++)
837  {
838  PadPos HistPosition = fHistPositionList[CrystalInterface::kNbSegments+i];
839 
840  TPad *pad = (TPad*)c->cd(HistPosition.PadNmbr);
841 
842  TH1 *h = 0x0;
843 
844  TPaveText *p = (TPaveText*)pad->GetListOfPrimitives()->FindObject("InfoPad");
845 
846  for (Int_t j = 0; j < fNbrOfSignals; j++ )
847  {
848  h = (TH1*)((TObjArray*)fCor->At(i))->At(j);
849  h->SetName((TString)"Cry_" + CrystalName + "_" + HistPosition.SegName + Form("_Sig%d",j+1));
850  h->SetTitle((TString)"Cry_" + CrystalName + "_" + HistPosition.SegName + Form("_Sig%d",j+1));
851  h->SetLineColor(GetColor(j));
852  h->GetXaxis()->SetLabelSize(0.07);
853  h->GetYaxis()->SetLabelSize(0.07);
854 
855  if(j==0) h->Draw();
856  else h->Draw("same");
857  }
858 
859  if(p)p->Draw();
860  }
861 
862  GlobalAutoRange("xy");
863 
864  new LoupeOnPad(c);
865  SetLoupe(false);
866 
867 }
868 
869 void CrystalSpectra::ShowBaselinesMap(const char *option)
870 {
871  TString opt = (TString)option;
872  TCanvas *c = 0x0;
873 
874  CrystalInterface *data = GetDataPointer<CrystalInterface>(fFrame);
875  int CrystalID = data->GetUID();
876  TString CrystalName = GetCrystalNameFromID(CrystalID);
877 
878  opt.ToLower();
879 
880  if(opt == "same") c = (TCanvas*)gPad->GetCanvas();
881  else
882  {
883  TString Name = "Baselines_" + CrystalName;
884  TString Title = "Mapping of the baselines for crystal " + CrystalName;
885 
886  c = CanvasVisu::BuildSegmentedCanvas(Name,Title);
887  }
888  if(c == 0x0) return;
889 
890  c->cd();
891 
892  for(int i=0 ; i<CrystalInterface::kNbSegments ; i++)
893  {
894  PadPos HistPosition = fHistPositionList[i];
895 
896  TPad *pad = (TPad*)c->cd(HistPosition.PadNmbr);
897 
898  TH1 *h = 0x0;
899 
900  TPaveText *p = (TPaveText*)pad->GetListOfPrimitives()->FindObject("InfoPad");
901 
902  h = ((TH1*)fBaseLines->At(CrystalInterface::kNbCores + i));
903  h->SetName((TString)"Cry_" + CrystalName + "_Seg_" + HistPosition.SegName + "_BaseLine");
904  h->SetTitle((TString)"Cry_" + CrystalName + "_Seg_" + HistPosition.SegName + "_BaseLine");
905  h->GetXaxis()->SetLabelSize(0.07);
906  h->GetYaxis()->SetLabelSize(0.07);
907 
908  int col = 0;
909  for(int k=0 ; k<pad->GetListOfPrimitives()->GetSize() ; k++)
910  {
911  if(pad->GetListOfPrimitives()->At(k)->InheritsFrom("TH1"))col++;
912  }
913 
914  h->SetLineColor(GetColor(col));
915  h->SetFillColor(0);
916  h->SetStats(0);
917  h->Draw(opt);
918  if(col==0) h->GetXaxis()->SetRangeUser(h->GetMean()-75,h->GetMean()+75);
919 
920  if(p)p->Draw();
921 
922  pad->Modified();
923  pad->Update();
924  }
925  for(int i=0 ; i<CrystalInterface::kNbCores ; i++)
926  {
927  PadPos HistPosition = fHistPositionList[CrystalInterface::kNbSegments+i];
928 
929  TPad *pad = (TPad*)c->cd(HistPosition.PadNmbr);
930 
931  TH1 *h = 0x0;
932 
933  TPaveText *p = (TPaveText*)pad->GetListOfPrimitives()->FindObject("InfoPad");
934 
935  h = ((TH1*)fBaseLines->At(i));
936  h->SetName((TString)"Cry_" + CrystalName + "_" + HistPosition.SegName + "_BaseLine");
937  h->SetTitle((TString)"Cry_" + CrystalName + "_" + HistPosition.SegName + "_BaseLine");
938  h->GetXaxis()->SetLabelSize(0.07);
939  h->GetYaxis()->SetLabelSize(0.07);
940 
941  int col = 0;
942  for(int k=0 ; k<pad->GetListOfPrimitives()->GetSize() ; k++)
943  {
944  if(pad->GetListOfPrimitives()->At(k)->InheritsFrom("TH1"))col++;
945  }
946  h->SetLineColor(GetColor(col));
947  h->SetFillColor(0);
948  h->SetStats(0);
949  h->Draw(opt);
950  if(col==0) h->GetXaxis()->SetRangeUser(h->GetMean()-100,h->GetMean()+100);
951 
952  if(p)p->Draw();
953 
954  pad->Modified();
955  pad->Update();
956  }
957 
958  if(!opt.Contains("same"))
959  {
960  new LoupeOnPad(c);
961  SetLoupe(false);
962  }
963 }
964 
965 void CrystalSpectra::ShowSpectraMap(const char *option)
966 {
967  TString opt = (TString)option;
968  TCanvas *c = 0x0;
969 
970  TString RawOrCal_Name="";
971  TString RawOrCal_Title="";
972  TString Type = GetName();
973  Type.ToLower();
974  if(Type.Contains("ccrystal"))
975  {
976  RawOrCal_Name = "CalSpectra";
977  RawOrCal_Title = "calibrated";
978  }
979  else{
980  RawOrCal_Name = "RawSpectra";
981  RawOrCal_Title = "raw";
982  }
983 
984  CrystalInterface *data = GetDataPointer<CrystalInterface>(fFrame);
985  int CrystalID = data->GetUID();
986  TString CrystalName = GetCrystalNameFromID(CrystalID);
987 
988 
989 
990  opt.ToLower();
991 
992  if(opt == "same") c = (TCanvas*)gPad->GetCanvas();
993  else
994  {
995  TString Name = RawOrCal_Name + "_" + CrystalName;
996  TString Title = "Mapping of the " + RawOrCal_Title + " spectra for crystal " + CrystalName;
997 
998  c = CanvasVisu::BuildSegmentedCanvas(Name,Title);
999  }
1000  if(c == 0x0) return;
1001 
1002  c->cd();
1003 
1004  for(int i=0 ; i<CrystalInterface::kNbSegments ; i++)
1005  {
1006  PadPos HistPosition = fHistPositionList[i];
1007 
1008  TPad *pad = (TPad*)c->cd(HistPosition.PadNmbr);
1009 
1010  TH1 *h = 0x0;
1011 
1012  TPaveText *p = (TPaveText*)pad->GetListOfPrimitives()->FindObject("InfoPad");
1013 
1014  h = ((TH1*)fSpectra->At(CrystalInterface::kNbCores + i));
1015 
1016  TString Name = (TString)"Cry_" + CrystalName + "_Seg_" + HistPosition.SegName + "_" + RawOrCal_Name;
1017  h->SetNameTitle(Name,Name);
1018  h->GetXaxis()->SetLabelSize(0.07);
1019  h->GetYaxis()->SetLabelSize(0.07);
1020 
1021  int col = 0;
1022  for(int k=0 ; k<pad->GetListOfPrimitives()->GetSize() ; k++)
1023  {
1024  if(pad->GetListOfPrimitives()->At(k)->InheritsFrom("TH1"))col++;
1025  }
1026  h->SetLineColor(GetColor(col));
1027  h->SetFillColor(0);
1028  h->SetStats(0);
1029  h->Draw(opt);
1030  if(col==0) h->GetXaxis()->SetRangeUser(15,h->GetXaxis()->GetXmax());
1031 
1032  if(p)p->Draw();
1033 
1034  pad->Modified();
1035  pad->Update();
1036  }
1037  for(int i=0 ; i<CrystalInterface::kNbCores ; i++)
1038  {
1039  PadPos HistPosition = fHistPositionList[CrystalInterface::kNbSegments+i];
1040 
1041  TPad *pad = (TPad*)c->cd(HistPosition.PadNmbr);
1042 
1043  TH1 *h = 0x0;
1044 
1045  TPaveText *p = (TPaveText*)pad->GetListOfPrimitives()->FindObject("InfoPad");
1046 
1047  h = ((TH1*)fSpectra->At(i));
1048 
1049  TString Name = (TString)"Cry_" + CrystalName + "_Seg_" + HistPosition.SegName + "_" + RawOrCal_Name;
1050  h->SetNameTitle(Name,Name);
1051  h->GetXaxis()->SetLabelSize(0.07);
1052  h->GetYaxis()->SetLabelSize(0.07);
1053 
1054  int col = 0;
1055  for(int k=0 ; k<pad->GetListOfPrimitives()->GetSize() ; k++)
1056  {
1057  if(pad->GetListOfPrimitives()->At(k)->InheritsFrom("TH1"))col++;
1058  }
1059  h->SetLineColor(GetColor(col));
1060  h->SetFillColor(0);
1061  h->SetStats(0);
1062  h->Draw(opt);
1063  if(col==0) h->GetXaxis()->SetRangeUser(15,h->GetXaxis()->GetXmax());
1064 
1065  if(p)p->Draw();
1066 
1067  pad->Modified();
1068  pad->Update();
1069  }
1070 
1071  if(!opt.Contains("same"))
1072  {
1073  new LoupeOnPad(c);
1074  SetLoupe(false);
1075  }
1076 
1077 }
1078 
1079 void CrystalSpectra::GlobalAutoRange(const char *x_y)
1080 {
1081  TString opt = x_y;
1082  opt.ToLower();
1083 
1084  TCanvas *CurrentCanvas = gPad->GetCanvas();
1085 
1086  double MinY = 100000., MaxY = 1.;
1087  double MinX = 100000., MaxX = 1.;
1088 
1089  double ForceMin = 0.;
1090  if(((TString)CurrentCanvas->GetName()).Contains("RawSpectra")) ForceMin = 15;
1091 
1092  bool OnlySeg = false;
1093 
1094  TString OptToToken = opt;
1095  TObjArray *token = OptToToken.Tokenize(" ");
1096  TObject *an_obj = 0x0;
1097  TIter it(token);
1098  while ( (an_obj = it.Next()) )
1099  {
1100  TString Name = an_obj->GetName();
1101  if(Name.BeginsWith("forcemin=")) ForceMin = Name.ReplaceAll("forcemin=","").Atof();
1102  if(Name.Contains("seg")) OnlySeg = true;
1103  }
1104 
1105  bool signalmap = ((TString)CurrentCanvas->GetName()).Contains("SignalsMap_");
1106 
1107  int NTot = CrystalInterface::kNbSegments + CrystalInterface::kNbCores;
1108  if(OnlySeg) NTot = CrystalInterface::kNbSegments;
1109 
1110  for(int i=0 ; i<NTot; i++)
1111  {
1112  TH1 *baseline_hist = 0x0;
1113  int histnbr = 0;
1114 
1115  if(i<CrystalInterface::kNbSegments) histnbr = CrystalInterface::kNbCores+i;
1116  else histnbr = i-CrystalInterface::kNbSegments;
1117 
1118  TPad *CurrentPad = (TPad*)CurrentCanvas->cd(((PadPos)fHistPositionList[i]).PadNmbr);
1119 
1120  if(signalmap)
1121  {
1122  baseline_hist = (TH1*)fBaseLines->At(histnbr);
1123  if(baseline_hist==0x0) continue;
1124  }
1125 
1126  TIter iter((TList*)CurrentPad->GetListOfPrimitives());
1127  TObject *o;
1128  TH1 *h = 0x0;
1129  while( (o = iter()) )
1130  {
1131  if(o->InheritsFrom("TH1"))
1132  {
1133  h = (TH1*)o;
1134 
1135  double BaseLineMean = 1.;
1136  if(signalmap) BaseLineMean = baseline_hist->GetMean();
1137 
1138  if(!opt.Contains("y"))
1139  {
1140  MinY=h->GetBinLowEdge(h->GetYaxis()->GetFirst());
1141  MaxY=h->GetBinLowEdge(h->GetYaxis()->GetLast());
1142  }
1143  if(!opt.Contains("x"))
1144  {
1145  MinX=h->GetBinLowEdge(h->GetXaxis()->GetFirst());
1146  MaxX=h->GetBinLowEdge(h->GetXaxis()->GetLast());
1147  }
1148 
1149  h->GetXaxis()->UnZoom();
1150  h->GetYaxis()->UnZoom();
1151  h->GetXaxis()->SetRangeUser(ForceMin,h->GetXaxis()->GetXmax());
1152  double SigMax = h->GetBinContent(h->GetMaximumBin());
1153  h->GetXaxis()->UnZoom();
1154 
1155  if(opt.Contains("y"))
1156  {
1157  if(BaseLineMean<MinY && BaseLineMean > 1) MinY = BaseLineMean;
1158  if(SigMax>MaxY) MaxY = SigMax;
1159  }
1160  if(opt.Contains("x"))
1161  {
1162  int LastBin = h->FindLastBinAbove(10);
1163  int FirstBin = h->FindFirstBinAbove(10);
1164  if(h->GetBinLowEdge(LastBin)>MaxX && h->GetBinContent(LastBin-1)>1) MaxX = h->GetBinLowEdge(LastBin);
1165  if(h->GetBinLowEdge(FirstBin)<MinX) MinX = h->GetBinLowEdge(FirstBin);
1166  }
1167  }
1168  }
1169  }
1170 
1171  if(opt.Contains("y")&&signalmap)
1172  {
1173  double shift = TMath::Abs((MaxY-MinY)*0.05);
1174 
1175  SetRange(MinY-shift,MaxY+shift,"y");
1176  SetVRange((Int_t)(MinY-shift),(Int_t)(MaxY+shift));
1177  }
1178  else
1179  {
1180  SetVRange((Int_t)MinY,(Int_t)MaxY);
1181  SetRange(MinY,MaxY,"y");
1182  }
1183  SetHRange(MinX,MaxX);
1184  SetRange(MinX,MaxX,"x");
1185 }
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
virtual void GlobalAutoRange(const char *opt="xy")
TObjArray fThresholdArrows
TString GetCrystalNameFromID(int ID)
Definition: CanvasVisu.C:636
TObjArray * fSeg
Array of last gkNB_SIG signals for core and segments.
Base class for a Frame.
Definition: Frame.h:73
virtual void ShowSignalsMap(int NbrOfSignals=1)
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.
vector< PadPos > fHistPositionList
Definition: CanvasVisu.h:44
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 void ShowSpectraMap(const char *option="")
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
virtual Int_t GetUID() const =0
to get the crystal ID
virtual void ShowBaselinesMap(const char *option="")
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
LoupOnPad, a class to Loupe on a Pad in a Canvas with many pads in it.
Definition: LoupeOnPad.h:76
Base Watcher working for any kind of crystal Frame (Frame interface)
TCanvas * BuildSegmentedCanvas(TString CanvasName, TString CanvasTitle)
Definition: CanvasVisu.C:125
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.
virtual void SetRange(double min, double max, const char *x_y="y")
Color_t GetColor(int i)
Definition: CanvasVisu.h:49
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.
ADF::LogMessage & endl(ADF::LogMessage &log)
ShowSignals(const char *name="ShowSignals", const char *title="Display the signals for one crystal")
virtual void SetHRange(Double_t min, Double_t max)
change horizontal range
std::vector< Int_t > fCoincThreshold
to keep event by event the list of signals and overshoot
virtual void SetLoupe(bool loupeon=true)
virtual void SetVRange(Int_t min, Int_t max)
change vertical range
TObjArray fBaseLinesArrows
contains arrows corresponding respectively to baseline, threshold and overshoot for all detector ...
TObjArray * fSpectra
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
CrystalSpectra(const char *name="CrystalSpectra", const char *title="Display the values for one crystal at the producer level")
Crystal spectra watcher class.
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