42 TNamed(
"AGCondition",
"x"),
45 fExpectedResult(true),
59 fExpectedResult(true),
73 while ( (obj = next()) ) {
93 Style_t hash_style = 1;
99 while ( (obj = next()) ) {
100 if ( obj->InheritsFrom(
"TAttLine") ) {
101 dynamic_cast<TAttLine *
>(obj)->SetLineColor(29);
102 dynamic_cast<TAttLine *
>(obj)->SetLineWidth(2);
103 dynamic_cast<TAttLine *
>(obj)->SetLineStyle(hash_style);
119 while ( (obj = next()) ) {
155 Gw::PeakCreator *pc = 0x0; TVirtualPad *c_pad = 0x0; TString which_canvas(c_name);
157 if ( which_canvas ==
"" )
158 c_pad = TVirtualPad::Pad();
160 c_pad = (TVirtualPad *)gROOT->GetListOfCanvases()->FindObject(c_name);
189 while ( (obj = next()) ) {
199 TVirtualPad *c_pad = TVirtualPad::Pad();
207 while ( (obj = next()) ) {
208 if ( c_pad->GetListOfPrimitives()->FindObject(obj) == 0x0 )
209 c_pad->GetListOfPrimitives()->Add(obj,
"lg");
220 TString option(opt); Double_t xmin = TMath::Min(min,max), xmax = TMath::Max(min,max);
222 if ( !option.Contains(
"+") )
226 p->
SetPeak((xmin+xmax)/2., 1., (xmax-xmin) );
231 p->SetBit(kCanDelete,
false);
232 p->SetBit(kMustCleanup,
false);
239 gROOT->GetListOfSpecials()->Add(p);
253 Bool_t is_inside =
false;
258 Double_t w = peak->
GetFWHM()/2.;
259 if ( x >= (p-w) && x <= (p+w) ) {
272 TString wh(what), origin(from), option(opt),
tmp, obj_name; Short_t result = 0; TDirectory *dir_to_search = gDirectory;
274 Bool_t wildcard =
false;
275 if ( wh.Contains(
"*") )
277 TRegexp rexp(Form(
"%s",what),wildcard);
280 if ( !option.Contains(
"+") )
284 if ( !origin.Contains(
":") ) {
285 if ( origin ==
"gdir" || origin ==
"gpad" ) {
288 else origin.Prepend(
"file:");
290 if ( origin.BeginsWith(
"file:") ||
291 origin.BeginsWith(
"root:") ||
292 origin.BeginsWith(
"roots:") ||
293 origin.BeginsWith(
"rootk:") ||
294 origin.BeginsWith(
"http:") )
296 TString rname = origin;
297 if ( origin.BeginsWith(
"file:") )
298 rname.Replace(0,origin.First(
":")+1,
"");
306 if ( !origin.EndsWith(
".root") ) {
307 rname.Append(
".root"); origin.Append(
".root");
310 if ( gROOT->GetListOfFiles()->FindObject(rname.Data()) ) {
311 std::cout <<
"Import CUTS from OPEN FILE " << rname.Data() <<
std::endl ;
312 f = (TFile *)gROOT->GetListOfFiles()->FindObject(rname.Data());
315 std::cout <<
"Import CUTS from NEW FILE " << origin.Data() <<
std::endl;
316 f = TFile::Open(origin.Data(),
"READ");
319 dir_to_search = f; origin =
"gdir";
321 else origin =
"FAIL";
324 if ( origin ==
"gdir" ) {
327 TString class_name; TObject *obj_in_file = 0x0; TKey *key_in_file; TList new_cuts; TCut *cut;
Gw::Peak1D *peak;
328 new_cuts.SetOwner(
true);
331 TIter it_keys(dir_to_search->GetListOfKeys());
332 while ( (key_in_file = static_cast<TKey *>(it_keys())) ) {
333 class_name = key_in_file->GetClassName();
334 obj_name = key_in_file->GetName();
336 if ( class_name ==
"TCut" && obj_name.Contains(rexp) &&
fListOfConditions.FindObject(obj_name.Data()) == 0x0 ) {
337 if ( !new_cuts.FindObject(obj_name.Data()) ) {
339 key_in_file->ReadObj();
340 new_cuts.Add(obj_in_file);
344 TIter it_cuts(&new_cuts);
345 while ( (cut = static_cast<TCut *>(it_cuts())) ) {
349 obj_name = peak->GetName();
350 if ( !obj_name.BeginsWith(GetName()) ) {
351 peak->SetName(Form(
"%s_%s",GetName(),obj_name.Data()));
362 peak->SetBit(kCanDelete,
false);
363 peak->SetBit(kMustCleanup,
false);
373 std::cout <<
" Cannot convert " << cut->GetName() <<
" to peak " <<
std::endl;
377 if ( origin ==
"gpad" ) {
378 TSeqCollection *l_to_seach = 0x0;
379 if ( TVirtualPad::Pad() ) {
380 l_to_seach = TVirtualPad::Pad()->GetListOfPrimitives();
383 TIter next(l_to_seach);
384 while ( (obj = next()) ) {
385 if ( obj->InheritsFrom(
"Gw::Peak1D") ) {
386 tmp = obj->GetName();
387 if ( tmp.Contains(rexp) ) {
390 printf(
"%s ALREADY IN THE LIST \n", obj->GetName());
396 if ( !tmp.BeginsWith(GetName()) ) {
397 ((
Gw::Peak1D*)obj)->SetName(Form(
"%s_%s",GetName(),tmp.Data()));
407 obj->SetBit(kCanDelete,
false);
408 obj->SetBit(kMustCleanup,
false);
430 Gw::Peak1D *p = 0x0; Double_t min, max; std::string name_leaf1, name_leaf2; TString
tmp(cut->GetTitle());
433 if ( !
tmp.Contains(
"(") || !
tmp.Contains(
")") || !
tmp.Contains(
"&&") ||
tmp.CountChar(
'>') != 1 ||
tmp.CountChar(
'<') != 1 || (
tmp.CountChar(
'<') >
tmp.First(
'>')) ) {
437 tmp.ReplaceAll(
"(",
"");
438 tmp.ReplaceAll(
")",
"");
439 tmp.ReplaceAll(
">",
"");
440 tmp.ReplaceAll(
"<",
"");
441 tmp.ReplaceAll(
"=",
"");
442 tmp.ReplaceAll(
"&&",
"");
446 std::istringstream decode(
tmp.Data());
448 decode >> name_leaf1 >> min >> name_leaf2 >> max ;
449 if ( decode.good() ) {
450 if ( name_leaf1 == name_leaf2 ) {
452 p =
new Gw::Peak1D(cut->GetName(),name_leaf1.data());
454 Double_t xmin = TMath::Min(min,max), xmax = TMath::Max(min,max);
455 p->
SetPeak((xmin+xmax)/2., 1., (xmax-xmin) );
470 cut =
new TCut( peak->GetName(),Form(
"(%s <= %f && %s >= %f)",fVarX.Data(),min,fVarX.Data(),max) );
479 if ( fVarX == p->GetTitle() ) {
480 p->SetTitle(GetTitle());
482 else {
delete p; p = 0x0; }
491 TString wh(what), destination(to), option(opt),
tmp(
"ROOT"), rname;
492 TDirectory *directory = gDirectory;
493 Short_t result = 0; TObject* obj = 0x0;
495 if ( !destination.Contains(
":") ) {
496 if ( destination !=
"gdir" ) {
497 destination.Prepend(
"file:");
500 if ( destination.BeginsWith(
"file:") ||
501 destination.BeginsWith(
"root:") ||
502 destination.BeginsWith(
"roots:") ||
503 destination.BeginsWith(
"rootk:") ||
504 destination.BeginsWith(
"http:") )
506 TString rname = destination;
507 if ( destination.BeginsWith(
"file:") )
508 rname.Replace(0,destination.First(
":")+1,
"");
516 if ( !destination.EndsWith(
".root") ) {
517 rname.Append(
".root"); destination.Append(
".root");
520 if ( gROOT->GetListOfFiles()->FindObject(rname.Data()) ) {
521 std::cout <<
"SAVE CUTS in OPEN FILE " << rname.Data() <<
std::endl ;
522 f = (TFile *)gROOT->GetListOfFiles()->FindObject(rname.Data());
525 std::cout <<
"SAVE CUTS in OPEN FILE " << destination.Data() <<
std::endl;
526 f = TFile::Open(destination.Data(),
"UPDATE");
534 if (
tmp ==
"ROOT" ) {
536 Bool_t wildcard =
false;
537 if ( wh.Contains(
"*") )
539 TRegexp rexp(Form(
"%s",what),wildcard);
542 while ( (obj = next()) ) {
543 tmp = obj->GetName();
544 if (
tmp.Contains(rexp) ) {
547 tmp = cut->GetName();
548 if ( !
tmp.BeginsWith(GetName()) ) {
549 cut->SetName(Form(
"%s_%s",GetName(),cut->GetName()));
552 directory->WriteTObject(cut,
"",option.Data());
600 Double_t xxmin = TMath::Min(xmin,xmax), xxmax = TMath::Max(xmin,xmax), yymin = TMath::Min(ymin,ymax), yymax = TMath::Max(ymin,ymax), xx[5], yy[5];
602 xx[0] = xxmin; yy[0] = yymin;
603 xx[1] = xxmax; yy[1] = yymin;
604 xx[2] = xxmax; yy[2] = yymax;
605 xx[3] = xxmin; yy[3] = yymax;
606 xx[4] = xxmin; yy[4] = yymin;
609 if ( !option.Contains(
"+") )
614 p->SetTitle(GetTitle());
615 p->SetVarX(fVarX.Data());
616 p->SetVarY(fVarY.Data());
632 p->SetBit(kCanDelete,
false);
633 p->SetBit(kMustCleanup,
false);
635 gROOT->GetListOfSpecials()->Add(p);
645 TVirtualPad *c_pad = TVirtualPad::Pad();
650 Style_t hash_style = 1;
657 while ( (obj = next()) ) {
658 if ( c_pad->GetListOfPrimitives()->FindObject(obj) == 0x0 ) {
660 dynamic_cast<TAttLine *
>(obj)->SetLineColor(29);
661 dynamic_cast<TAttLine *
>(obj)->SetLineWidth(2);
662 dynamic_cast<TAttLine *
>(obj)->SetLineStyle(hash_style);
664 c_pad->GetListOfPrimitives()->Add(obj,
"LP");
680 Bool_t is_inside =
false;
684 if ( cut->IsInside(x,y) ) {
696 TString wh(what), origin(from), option(opt),
tmp, obj_name;TDirectory *dir_to_search = gDirectory; Short_t result = 0;
698 Bool_t wildcard =
false;
699 if ( wh.Contains(
"*") )
701 TRegexp rexp(Form(
"%s",what),wildcard);
704 if ( !option.Contains(
"+") )
708 if ( !origin.Contains(
":") ) {
709 if ( origin ==
"gdir" || origin ==
"gpad" ) {
712 else origin.Prepend(
"file:");
714 if ( origin.BeginsWith(
"file:") ||
715 origin.BeginsWith(
"root:") ||
716 origin.BeginsWith(
"roots:") ||
717 origin.BeginsWith(
"rootk:") ||
718 origin.BeginsWith(
"http:") )
720 TString rname = origin;
721 if ( origin.BeginsWith(
"file:") )
722 rname.Replace(0,origin.First(
":")+1,
"");
730 if ( !origin.EndsWith(
".root") ) {
731 rname.Append(
".root"); origin.Append(
".root");
734 if ( gROOT->GetListOfFiles()->FindObject(rname.Data()) ) {
735 std::cout <<
"Import CUTS from OPEN FILE " << rname.Data() <<
std::endl ;
736 f = (TFile *)gROOT->GetListOfFiles()->FindObject(rname.Data());
739 std::cout <<
"Import CUTS from NEW FILE " << origin.Data() <<
std::endl;
740 f = TFile::Open(origin.Data(),
"READ");
743 dir_to_search = f; origin =
"gdir";
745 else origin =
"FAIL";
749 if ( origin ==
"gdir" ) {
752 TString class_name; TObject *obj_in_file = 0x0; TKey *key_in_file; TList new_cuts; TCutG *cut;
755 TIter it_keys(dir_to_search->GetListOfKeys());
756 while ( (key_in_file = static_cast<TKey *>(it_keys())) ) {
757 class_name = key_in_file->GetClassName();
758 obj_name = key_in_file->GetName();
760 if ( class_name ==
"TCutG" && obj_name.Contains(rexp) &&
fListOfConditions.FindObject(obj_name.Data()) == 0x0 ) {
761 if ( !new_cuts.FindObject(obj_name.Data()) ) {
763 key_in_file->ReadObj();
764 new_cuts.Add(obj_in_file);
768 TIter it_cuts(&new_cuts);
769 while ( (cut = static_cast<TCutG *>(it_cuts())) ) {
772 obj_name = cut->GetName();
773 if ( !obj_name.BeginsWith(GetName()) ) {
774 cut->SetName(Form(
"%s_%s",GetName(),obj_name.Data()));
783 cut->SetBit(kCanDelete,
false);
784 cut->SetBit(kMustCleanup,
false);
786 gROOT->GetListOfSpecials()->Remove(cut);
789 std::cout <<
"Add TCutG " << cut <<
std::endl;
795 std::cout <<
" Cannot convert " << cut->GetName() <<
" to peak " <<
std::endl;
800 if ( origin ==
"gpad" ) {
801 TSeqCollection *l_to_seach = 0x0;
802 if ( TVirtualPad::Pad() ) {
803 l_to_seach = TVirtualPad::Pad()->GetListOfPrimitives();
806 TIter next(l_to_seach);
807 while ( (obj = next()) ) {
808 if ( obj->InheritsFrom(
"TCutG") ) {
809 tmp = obj->GetName();
810 if ( tmp.Contains(rexp) ) {
813 printf(
"%s ALREADY IN THE LIST \n", obj->GetName());
818 if ( option.Contains(
"r") )
819 ((TCutG*)obj)->SetNameTitle( Form(
"%s_%d",GetName(),
fListOfConditions.GetEntries()), GetTitle() );
821 ((TCutG*)obj)->SetNameTitle( Form(
"%s_%s",GetName(), obj->GetName()), GetTitle() );
826 obj->SetBit(kCanDelete,
false);
827 obj->SetBit(kMustCleanup,
false);
829 gROOT->GetListOfSpecials()->Remove(obj);
896 TString wh(what), destination(to), option(opt),
tmp(
"ROOT"), rname;
897 TDirectory *directory = gDirectory;
898 Short_t result = 0; TObject* obj = 0x0;
900 Bool_t wildcard =
false;
901 if ( wh.Contains(
"*") )
903 TRegexp rexp(Form(
"%s",what),wildcard);
905 if ( !destination.Contains(
":") ) {
906 if ( destination !=
"gdir" ) {
907 destination.Prepend(
"file:");
910 if ( destination.BeginsWith(
"gdir") ) {
913 if ( destination.BeginsWith(
"file:") ||
914 destination.BeginsWith(
"root:") ||
915 destination.BeginsWith(
"roots:") ||
916 destination.BeginsWith(
"rootk:") ||
917 destination.BeginsWith(
"http:") )
919 TString rname = destination;
920 if ( destination.BeginsWith(
"file:") )
921 rname.Replace(0,destination.First(
":")+1,
"");
929 if ( !destination.EndsWith(
".root") ) {
930 rname.Append(
".root"); destination.Append(
".root");
933 if ( gROOT->GetListOfFiles()->FindObject(rname.Data()) ) {
934 std::cout <<
"SAVE CUTS in OPEN FILE " << rname.Data() <<
std::endl ;
935 f = (TFile *)gROOT->GetListOfFiles()->FindObject(rname.Data());
938 std::cout <<
"SAVE CUTS in NEW FILE " << destination.Data() <<
std::endl;
939 f = TFile::Open(destination.Data(),
"UPDATE");
947 if (
tmp ==
"ROOT" ) {
950 while ( (obj = next()) ) {
951 tmp = obj->GetName();
952 if (
tmp.Contains(rexp) ) {
954 tmp = obj->GetName();
955 if ( !
tmp.BeginsWith(GetName()) ) {
956 ((TCutG*)obj)->SetName(Form(
"%s_%s",GetName(),obj->GetName()));
959 directory->WriteTObject(obj,
"",option.Data());
970 gROOT->SetEditorMode(
"CutG");
BasePeak * DefaultPeak()
access to the peak used to create other peaks (through the Clone method)
TObjArray fListOfConditions
printf("******************************************************************** \n")
virtual void UseAsAnti(Bool_t r=false)
need to be redefined since Peak does not inherits from TAttFill
header file for PeakCreator.cpp
Base for a Graphical condition 2D.
void SetPeak(Double_t pos, Double_t height, Double_t fwhm, Double_t intensity=0)
Set peak members.
static void AddRMimeType()
check mime type and add those proper to gw
virtual Bool_t IsPassed(Double_t, Double_t) const
returns true if the condition is passed with success
static const Style_t gAnticStyle
Gw::Peak1D * CutToPeak(TCut *)
virtual void Enable()
toggle on/off the cut. if off returns always passed
virtual Short_t Export(const char *what="*", const char *to="MyCuts", Option_t *opt="") const
Export 1D conditions.
void Draw(Option_t *option="")
virtual Short_t Export(const char *what="*", const char *to="MyCuts", Option_t *opt="") const
virtual Short_t Import(const char *what="*", const char *from="gpad", Option_t *opt="+")
Import 2D conditions.
virtual void SetFillStylePeak(Style_t style)
static PeakCreator * AddPeakCreator(TVirtualPad *pad=0x0)
add a peak creator to the given pad. Current pad if argument is 0x0
void Draw(Option_t *option="")
Gw::PeakCreator * WindowGCreator(const char *c_name="")
add to the current canvas the way to add graphically 1D gates (type h after in the canvas to get list...
static Gw::Peak1D * TCutToPeak(TCut *)
TCut * PeakToCut(const Gw::Peak1D *) const
TCutG * AddWindow(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, Option_t *opt="+")
Add a window to the list of conditions.
virtual Bool_t IsPassed(Double_t, Double_t=0.0) const
returns true if the condition is passed with success
void SetGateMode(Bool_t ngate=true)
if true, peak are collected on key board actions (type h for help)
virtual void WindowGCreator(const char *c_name="")
prepare current canvas to draw a TCutG.
virtual Double_t GetFWHM(Option_t *axis="X") const
Get FWHM of peak.
virtual Short_t Import(const char *what="*", const char *from="gpad", Option_t *opt="+")
Import 1D conditions.
virtual Double_t GetPosition(Option_t *axis="X") const
Get position of peak.
virtual void Delete(Option_t *option="")
delete all object from fListOfConditions
Base for a Graphical condition 1D.
header file for a general 1D peak
virtual void Print(Option_t *option="") const
overwritte print method ... should be to gw log system
ADF::LogMessage & endl(ADF::LogMessage &log)
to get information about the gammaware configuration
static PeakCreator * IsPeakCreator(TVirtualPad *pad=0x0)
Check whether or not a PeakCreator is in this canvas.
Gw::Peak1D * AddWindow(Double_t, Double_t, Option_t *opt="+")
Add a window to the list of conditions.
A graphical interface for placing schematic peak onto a 1D histogram with a given position...
std::vector< Bool_t > fHasPassed_
virtual void SetDrawAs(EDrawAs d)
Set drawing flag.
virtual void UseAsAnti(Bool_t r=false)
to change gate into an anti gate
static const Style_t gCoincStyle
Base for a Graphical condition on a spectrum (1D, 2D)