23 #ifndef _CrystalWatchers
33 static Double_t gArrowL = 1000;
34 static Double_t gArrowP = 10;
35 static Double_t gArrowB = 4000;
36 static Double_t gArrowT = 1000;
37 static Double_t gArrowO = 6000;
39 static Double_t gArrowBaselineSigma = 5;
40 static Double_t gMaxForOneSigna = 10000;
43 UInt_t gRangeforBaseline = 20;
44 Float_t fSpekGain = 1.f;
45 Float_t fMinSegAmpli = 500.f;
46 UInt_t fRawAmplitude = 0;
56 if ( ! Watcher::SetTrigger(trigger) )
62 for( which = 0u; which < GetTrigger()->GetNbInputFrame(); which++){
64 SharedFP *fp = GetTrigger()->GetInputSharedFP(which);
75 if ( ftype.Contains(
"data") && ftype.Contains(
"crystal") ) {
102 fProcessingAlgo(
"basic"),
123 Color_t color[6] = {1, 4, 2, 8 , 27, 6}; TArrow *arrow; TString hname, htitle; TH1 *h;
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");
133 for (Int_t i = 0; i < CrystalInterface::kNbCores; i++ ) {
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);
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);
152 TObjArray *SigArray =
new TObjArray(
gkNB_SIG);
153 fCor->AddAt(SigArray,i);
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");
163 h->SetLineColor(kRed);
164 ((TObjArray*)
fCor->At(i))->AddAt(h,j);
166 arrow =
new TArrow(gArrowP,gArrowB,gArrowP,gArrowB+gArrowL,0.05,
"<|" );
168 arrow->SetArrowSize(0.015);
169 arrow->SetLineColor(kRed);
170 arrow->SetFillColor(kRed);
173 arrow =
new TArrow(gArrowP+10,gArrowB+gArrowT,gArrowP+10,gArrowB+gArrowT+gArrowL,0.05,
"<|>" );
175 arrow->SetArrowSize(0.015);
176 arrow->SetLineColor(kRed);
177 arrow->SetFillColor(kRed);
180 arrow =
new TArrow(gArrowP+20,gArrowB-gArrowL+gArrowO,gArrowP+20,gArrowB+gArrowO,0.05,
"|>" );
182 arrow->SetArrowSize(0.015);
183 arrow->SetLineColor(kRed);
184 arrow->SetFillColor(kRed);
187 for (Int_t i = 0; i < CrystalInterface::kNbSegments; i++ ) {
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]);
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);
207 TObjArray *SigArray =
new TObjArray(gkNB_SIG);
208 fSeg->AddAt(SigArray,i);
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");
220 h->SetLineColor(color[i%6]);
221 ((TObjArray*)
fSeg->At(i))->AddAt(h,j);
224 arrow =
new TArrow(gArrowP,gArrowB,gArrowP,gArrowB+gArrowL,0.05,
"<|" );
226 arrow->SetArrowSize(0.015);
227 arrow->SetLineColor(color[i%6]);
228 arrow->SetFillColor(color[i%6]);
231 arrow =
new TArrow(gArrowP+10,gArrowB+gArrowT,gArrowP+10,gArrowB+gArrowT+gArrowL,0.05,
"<|>" );
233 arrow->SetArrowSize(0.015);
234 arrow->SetLineColor(color[i%6]);
235 arrow->SetFillColor(color[i%6]);
238 arrow =
new TArrow(gArrowP+20,gArrowB-gArrowL+gArrowO,gArrowP+20,gArrowB+gArrowO,0.05,
"|>" );
240 arrow->SetArrowSize(0.015);
241 arrow->SetLineColor(color[i%6]);
242 arrow->SetFillColor(color[i%6]);
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,
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,
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 #");
260 fCoreCoinc = MakeTH2<TH2F>(
"Core0_Core1",
"Core high gain versus low gain", 4096,0,4096,4096,0,4096);
297 Double_t baseline_value, net_signal_value;
305 UInt_t range_for_baseline = sig->
GetLength()/5, range_for_net_charge;
307 range_for_baseline = TMath::Max(UInt_t(1), range_for_baseline); range_for_net_charge = sig->
GetLength() - range_for_baseline;
310 baseline_value = 0; net_signal_value = 0;
313 if ( sig->
GetLength() == UInt_t(fill_h->GetNbinsX()) ) {
314 fill_h->Reset(
"ICE");
320 int Nvalforfaseline = 0, Nvalfornetcharge = 0;
322 for (UInt_t j = 0; j < sig->
GetLength(); j++ ) {
325 Short_t val = 0; val = sig->
Get(val,j);
332 if ( j < range_for_baseline ) {
333 baseline_value += val;
336 if ( j > range_for_net_charge ) {
337 net_signal_value += val;
342 if ( Nvalforfaseline )
343 baseline_value = baseline_value / ((double)Nvalforfaseline);
345 if ( Nvalfornetcharge )
346 net_signal_value = net_signal_value / ((double)Nvalfornetcharge);
354 if ( fProcessingAlgo ==
"basic" ) {
375 TString opt = o; TH1 *h;
377 if ( opt.Contains(
"sig") ) {
378 c->Divide(4,2,0.0001,0.0001);
380 for (Int_t i = 0; i < 8; i++ ) {
383 h = (TH1*)((TObjArray*)
fCor->At(0))->At(0);
385 for (Int_t j = 0; j <
gkNB_SIG; j++ ) {
386 h = (TH1F *)((TObjArray*)
fCor->At(0))->At(j);
389 h = (TH1*)((TObjArray*)
fCor->At(0))->At(0);
392 h = (TH1*)((TObjArray*)
fSeg->At(0))->At(0);
394 for (Int_t j = 0; j <
gkNB_SIG; j++ )
396 for(
int k=0 ; k<6 ; k++)
398 h = (TH1*)((TObjArray*)
fSeg->At(k))->At(j);
404 h = (TH1*)((TObjArray*)
fSeg->At(6))->At(0);
406 for (Int_t j = 0; j <
gkNB_SIG; j++ )
408 for(
int k=6 ; k<12 ; k++)
410 h = (TH1*)((TObjArray*)
fSeg->At(k))->At(j);
416 h = (TH1*)((TObjArray*)
fSeg->At(12))->At(0);
418 for (Int_t j = 0; j <
gkNB_SIG; j++ )
420 for(
int k=12 ; k<18 ; k++)
422 h = (TH1*)((TObjArray*)
fSeg->At(k))->At(j);
428 h = (TH1*)((TObjArray*)
fCor->At(1))->At(0);
430 for (Int_t j = 0; j <
gkNB_SIG; j++ ) {
431 h = (TH1F *)((TObjArray*)
fCor->At(1))->At(j);
436 h = (TH1*)((TObjArray*)
fSeg->At(18))->At(0);
438 for (Int_t j = 0; j <
gkNB_SIG; j++ )
440 for(
int k=18 ; k<24 ; k++)
442 h = (TH1*)((TObjArray*)
fSeg->At(k))->At(j);
448 h = (TH1*)((TObjArray*)
fSeg->At(24))->At(0);
450 for (Int_t j = 0; j <
gkNB_SIG; j++ )
452 for(
int k=24 ; k<30 ; k++)
454 h = (TH1*)((TObjArray*)
fSeg->At(k))->At(j);
460 h = (TH1*)((TObjArray*)
fSeg->At(30))->At(0);
462 for (Int_t j = 0; j <
gkNB_SIG; j++ )
464 for(
int k=30 ; k<36 ; k++)
466 h = (TH1*)((TObjArray*)
fSeg->At(k))->At(j);
474 if ( opt.Contains(
"amp") ) {
476 c->Divide(6,6,0.0001,0.0001);
478 for(Int_t j = 0; j < CrystalInterface::kNbSegments; j++ ) {
480 fAmplitudes->At(CrystalInterface::kNbCores+j)->Draw();
484 if ( opt.Contains(
"base") ) {
486 c->Divide(6,6,0.0001,0.0001);
488 for(Int_t j = 0; j < CrystalInterface::kNbSegments; j++ ) {
490 fBaseLines->At(CrystalInterface::kNbCores+j)->Draw();
492 TString
tmp =
fBaseLines->At(CrystalInterface::kNbCores+j)->GetName();
494 TObject *tag_object =
GetReference().FindObject(tmp.Data());
496 tag_object->Draw(
"same");
501 c->Divide(2,2,0.0001,0.0001);
515 TCanvas *c = 0x0; TVirtualPad *current = TVirtualPad::Pad();
517 if ( (c = (TCanvas *)gROOT->GetListOfCanvases()->FindObject(
"ShowSignals::ShowLastOnes")) ) {
520 c =
new TCanvas(
"ShowSignals::ShowLastOnes",
"ShowSignals::ShowLastOnes");
527 c->Divide(6,6,0.001,0.001);
529 c->SetCrosshair(
true);
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);
537 for (Int_t i = 0; i < CrystalInterface::kNbSegments; i++ ) {
539 TH1 *h = (TH1 *)((TObjArray*)
fSeg->At(i))->At(fCurrentSig), *hc = 0x0;
542 hc->SetTitle(Form(
"Segment# %d",i));
544 TVirtualPad::Pad()->UseCurrentStyle(); hc->SetStats(
false); TVirtualPad::Pad()->SetEditable(kFALSE);
548 gStyle->SetPadBottomMargin(c_bot);
549 gStyle->SetPadTopMargin(c_top);
550 gStyle->SetPadLeftMargin(c_lef);
551 gStyle->SetPadRightMargin(c_rig);
561 TH1 *h; Double_t e[CrystalInterface::kNbCores];
569 printf(
"ShowSignals::Exec is called \n");
577 for (Int_t i = 0; i < CrystalInterface::kNbCores; i++ ) {
594 Double_t mean = hbaseline->GetMean();
595 Double_t rms = gArrowBaselineSigma*hbaseline->GetRMS();
615 h->SetAxisRange( TMath::Max(
fHMin,h->GetXaxis()->GetXmin()),TMath::Min(
fHMax,h->GetXaxis()->GetXmax()) );
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++ ) {
633 TH1 *hbaseline = (TH1*)(
fBaseLines->At(CrystalInterface::kNbCores+i));
637 Double_t mean = hbaseline->GetMean();
638 Double_t rms = gArrowBaselineSigma*hbaseline->GetRMS();
641 ((TArrow *)
fBaseLinesArrows.At(CrystalInterface::kNbCores+i))->SetY2(mean+rms);
642 ((TArrow *)
fBaseLinesArrows.At(CrystalInterface::kNbCores+i))->SetY1(mean+rms);
651 unique_seg.first = i;
657 h->SetAxisRange( TMath::Max(
fHMin,h->GetXaxis()->GetXmin()),TMath::Min(
fHMax,h->GetXaxis()->GetXmax()) );
659 if ( nb_seg_fired == 1 ) {
660 ((TH1*)(
fAmplitudes->At(CrystalInterface::kNbCores+unique_seg.first)))->Fill(unique_seg.second);
691 if ( fCurrentSig == gkNB_SIG )
virtual Double_t GetE() const
virtual Bool_t IsValid() const
true if it is a valid pointer
printf("******************************************************************** \n")
virtual Frame * GetFrame() const
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.
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()
TObjArray fOvershootArrows
std::vector< Int_t > fCoincOverShoot
virtual TObjArray & GetReference()
TH2 * fEnergies
Energie for the different channels core and segments.
Data produced fro a Crystal.
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
void SetLastExecStatus(Short_t s=0)
reset last status. 0 means no error, 0 < means error, > 0 means ok with conditions ...
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)
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.
void TagOn(TObject *)
Add this histogram to the list of tagged histograms.
void SetHRange(Double_t min=0, Double_t max=100)
change horizontal range
Base class for a trigger on a data flow.
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
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
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.