KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVIDGraph.cpp
1/*
2$Id: KVIDGraph.cpp,v 1.9 2009/04/28 09:07:47 franklan Exp $
3$Revision: 1.9 $
4$Date: 2009/04/28 09:07:47 $
5*/
6
7//Created by KVClassFactory on Mon Apr 14 13:42:47 2008
8//Author: franklan
9
10#include "KVIDGraph.h"
11#include "TObjString.h"
12#include "TObjArray.h"
13#include "TRandom.h"
14#include "TClass.h"
15#include "TCanvas.h"
16#include "TSystem.h"
17#include "TROOT.h"
18#include "KVIDGridManager.h"
19#include "KVBase.h"
20#include "TEnv.h"
21#include "TPluginManager.h"
22#include "TTree.h"
23#include "TROOT.h"
24#include "KVIdentificationResult.h"
25
26using namespace std;
27
29
30
31
32
33void KVIDGraph::ResetPad()
34{
35 cout << "The pad showing graph " << GetName() << " has been closed !" << endl;
36
37 if (fPad) {
38 fPad->Disconnect("Closed()", this, "ResetPad()");
39 if (fPad->GetCanvas()) fPad->GetCanvas()->Disconnect("Cleared(TVirtualPad*)", this, "ClearPad(TVirtualPad*)");
40 }
41 fPad = 0;
42
43}
44
45
46
48
50{
51 if (fPad == pad) {
52 cout << "The pad showing graph " << GetName() << " has been cleared" << endl;
53 fPad->Disconnect("Closed()", this, "ResetPad()");
54 if (fPad->GetCanvas()) fPad->GetCanvas()->Disconnect("Cleared(TVirtualPad*)", this, "ClearPad(TVirtualPad*)");
55 fPad = 0;
56 }
57}
58
59
61
62
66
68{
69 // Initialisations, used by constructors
70 // All graphs are added to gIDGridManager (if it exists).
71
75 fXmin = fYmin = fXmax = fYmax = 0;
76 fLastScaleX = 1.0;
77 fLastScaleY = 1.0;
79 fPad = 0;
80 SetName("");
82 if (fAutoAddGridManager && gIDGridManager) gIDGridManager->AddGrid(this);
83 fMassFormula = 0;
84 fLastSavedVersion = NULL;
85}
86
87
88
89// void KVIDGraph::Browse(TBrowser* b)
90// {
91// // This method is executed when an object is double-clicked in a browser
92// // such as the list of grids in KVIDGridManagerGUI
93// //
94// // Overrides default TGraph::Browse (which calls Draw()) in order to open
95// // the grid in the KVIDGridEditor canvas (if one exists).
96// // If no KVIDGridEditor exists, we perform the default action (Draw()).
97// //
98//
99// if( gIDGridEditor ){
100// // avant d'editer la grille, on en fait une copie pour
101// // pouvoir revenir en arriere
102// UpdateLastSavedVersion();
103// if(gIDGridEditor->IsClosed()) gIDGridEditor->StartViewer();
104// gIDGridEditor->SetGrid(this);
105// }
106// else
107// TGraph::Browse(b);
108// }
109
110
111
114
115void KVIDGraph::Copy(TObject& obj) const
116{
117 //Copy this to 'obj'
118 TNamed::Copy(obj);
122 ((TCutG&)obj).SetVarX(GetVarX());
123 ((TCutG&)obj).SetVarY(GetVarY());
124 KVIDGraph& grid = (KVIDGraph&) obj;
125 grid.fOnlyZId = const_cast <KVIDGraph*>(this)->fOnlyZId;
126 grid.SetPattern(fPattern);
127 //as in WriteAsciiFile, we need to remove any scaling factors from the coordinates
128 //before copying the coordinates, then we set the scaling factors at the end
129
130 //remove scaling if there is one
131 if (fLastScaleX != 1 || fLastScaleY != 1)
132 const_cast < KVIDGraph* >(this)->Scale(1. / fLastScaleX,
133 1. / fLastScaleY);
134
136 fCuts.Copy(grid.fCuts);
138 // set mass formula of grid (and identifiers)
140 //copy all parameters EXCEPT scaling parameters
141 KVNamedParameter* par = 0;
142 for (int i = 0; i < fPar.GetNpar(); i++) { //loop over all parameters
143 par = fPar.GetParameter(i);
144 TString parname(par->GetName());
145 if (!parname.Contains("ScaleFactor"))
146 grid.fPar.SetValue(*par);
147 }
148 //restore scaling to this grid if there was one, and apply it to the copied grid
149 if (fLastScaleX != 1 || fLastScaleY != 1) {
150 const_cast < KVIDGraph* >(this)->Scale(fLastScaleX, fLastScaleY);
153 }
154}
155
156
157
158KVIDGraph::KVIDGraph() : fRunList(""), fDyName(""), fPattern("")
159
160
163
164{
165 // Default constructor
166 init();
167}
168
169
170
171
174
175KVIDGraph::KVIDGraph(const KVIDGraph& grid) : TCutG(), fRunList(""), fDyName(""), fPattern("")
176{
177 //Copy constructor
178 init();
179 grid.Copy(*this);
180}
181
182
183
187
189{
190 // Destructor
191 // remove from grid manager
192 if (gIDGridManager) gIDGridManager->GetGrids()->RecursiveRemove(this);
193}
194
195
196
197
202
204{
205 // reset the grid (destroying any previously defined identifiers) ready to start anew.
206 // resets axis limits
207 // scaling factors (if any) are removed
208
210 fCuts.Delete();
212 fXmin = fYmin = fXmax = fYmax = 0;
215 Modified();
216}
217
218
220
221
225
227{
228 //Set scaling factor for X-axis - rescales all objects with this factor
229 //SetXScaleFactor() or SetXScaleFactor(0) removes scale factor
230 if (s > 0) {
231 fPar.SetValue("XScaleFactor", s);
232 Scale(s / fLastScaleX);
233 fLastScaleX = s;
234 }
235 else {
236 fPar.RemoveParameter("XScaleFactor");
237 Scale(1.0 / fLastScaleX);
238 fLastScaleX = 1.0;
239 }
240}
241
242
244
245
249
251{
252 //Set scaling factor for Y-axis - rescales all objects with this factor
253 //SetYScaleFactor() or SetYScaleFactor(0) removes scale factor
254 if (s > 0) {
255 fPar.SetValue("YScaleFactor", s);
256 Scale(-1.0, s / fLastScaleY);
257 fLastScaleY = s;
258 }
259 else {
260 fPar.RemoveParameter("YScaleFactor");
261 Scale(-1.0, 1.0 / fLastScaleY);
262 fLastScaleY = 1.0;
263 }
264}
265
266
268
269
273
275{
276 //Return scaling factor for X-axis
277 //If factor not defined, returns 1
278 Double_t s = fPar.GetDoubleValue("XScaleFactor");
279 if (s > 0)
280 return s;
281 return 1.0;
282}
283
284
286
287
291
293{
294 //Return scaling factor for Y-axis
295 //If factor not defined, returns 1
296 Double_t s = fPar.GetDoubleValue("YScaleFactor");
297 if (s > 0)
298 return s;
299 return 1.0;
300}
301
302
304
305
309
311{
312 // Return pointer to identifier with atomic number Z and mass number A.
313 // If this is a 'OnlyZId()' graph we ignore A.
314
315 KVIDentifier* id = 0;
316 if (!IsOnlyZId()) {
317 unique_ptr<KVSeqCollection> isotopes(fIdentifiers.GetSubListWithMethod(Form("%d", Z), "GetZ"));
318 TIter next(isotopes.get());
319 while ((id = (KVIDentifier*)next())) if (id->GetA() == A) break;
320 }
321 else {
322 TIter next(&fIdentifiers);
323 while ((id = (KVIDentifier*)next())) if (id->GetZ() == Z) break;
324 }
325 return id;
326}
327
328
330
331
334
336{
337 // Remove and destroy identifier
339 delete id;
340 Modified();
341}
342
343
345
346
349
351{
352 // Remove and destroy cut
353 fCuts.Remove(cut);
354 delete cut;
355 Modified();
356}
357
358
359
362
364{
365 // Remove and destroy cut
366 fInfoZones.Remove(info);
367 delete info;
368 Modified();
369}
370
371
373
374
381
383{
384 // Fill parameter "IDTelescopes" with list of names of telescopes associated
385 // with this grid, ready to write in ascii file
386
387 // if list of telescope pointers is empty, do nothing
388 // this is in case there are telescope names already in the IDTelescopes parameter
389 // but they are not telescopes in the current multi det array
390 if (!fTelescopes.GetEntries()) return;
391 fPar.SetValue("IDTelescopes", "");
392 KVString tel_list = GetNamesOfIDTelescopes();
393 fPar.SetValue("IDTelescopes", tel_list);
394}
395
396
398
399
400
403
405{
406 //Open, write and close ascii file containing this grid.
407
408 ofstream gridfile(filename);
409 WriteToAsciiFile(gridfile);
410 gridfile.close();
411}
412
413
414
415
441
442void KVIDGraph::WriteToAsciiFile(ofstream& gridfile)
443{
444 //Write info on this grid in already-open ascii file stream 'gridfile'.
445 //This begins with the line
446 //++ClassName
447 //where '"ClassName'" is the name of the class of the actual instance of this object
448 //followed by informations on the grid and its objects.
449 //
450 //The names associated to the X & Y axis of the identification map are written
451 //on lines beginning with
452 //<VARX>
453 //<VARY>
454 //Any associated parameters are written before the objects, starting with
455 //<PARAMETER>
456 //then the name of the parameter and its value
457 //e.e.
458 //<PARAMETER> ChIo pressure=45.5
459 //A single '!' on a line by itself signals the end of the informations for this grid.
460 //
461 //Scaling factors
462 //Any scaling factors are written in the file as
463 //<PARAMETER> XScaleFactor=...
464 //<PARAMETER> YScaleFactor=...
465 //However the coordinates written in the file are the unscaled factors
466 //When the file is read back again, the unscaled coordinates are read in and
467 //then the scaling is applied.
468
469 gridfile << "# ASCII file generated by " << ClassName() <<
470 "::WriteToAsciiFile" << endl;
471 gridfile << "# ID Graph Name : " << GetName() << endl;
472 gridfile << "# This file can be read using " << ClassName() <<
473 "::ReadFromAsciiFile" << endl;
474 gridfile << "# " << endl;
475 gridfile << "++" << ClassName() << endl;
476
477 // write name if given
478 if (fName != "") gridfile << "<NAME> " << fName.Data() << endl;
479 //write X & Y axis names
480 gridfile << "<VARX> " << GetVarX() << endl;
481 gridfile << "<VARY> " << GetVarY() << endl;
482 //write parameters
484 KVNamedParameter* par = 0;
485 for (int i = 0; i < fPar.GetNpar(); i++) { //loop over all parameters
486 par = fPar.GetParameter(i);
487 gridfile << "<PARAMETER> " << par->GetName() << "=" << par->GetString() << endl;
488 }
489
490 //write fOnlyZId & mass formula
491 if (IsOnlyZId()) gridfile << "OnlyZId " << GetMassFormula() << endl;
492
493 //remove scaling if there is one
494 if (fLastScaleX != 1 || fLastScaleY != 1)
495 Scale(1. / fLastScaleX, 1. / fLastScaleY);
496
497 //Write identifiers
498 TIter next_IDline(&fIdentifiers);
500 while ((line = (KVIDentifier*) next_IDline())) {
501 line->WriteAsciiFile(gridfile, "ID");
502 }
503 //Write cuts
504 TIter next_OKline(&fCuts);
505 while ((line = (KVIDentifier*) next_OKline())) {
506 line->WriteAsciiFile(gridfile, "OK");
507 }
508 //Write cuts
509 TIter next_INFOline(&fInfoZones);
510 while ((line = (KVIDentifier*) next_INFOline())) {
511 line->WriteAsciiFile(gridfile, "INFO");
512 }
513// //Write info zones
514// TIter next_OKline(fInfoZones);
515// while ((line = (KVIDentifier*) next_OKline())) {
516// line->WriteAsciiFile(gridfile, "INFO");
517// }
518 gridfile << "!" << endl;
519
520 //restore scaling if there is one
521 if (fLastScaleX != 1 || fLastScaleY != 1)
523
524 // if a back-up copy had previously been created (by starting the editor)
525 // we replace it by the version read from file
527}
528
529
530
533
535{
536 //update last saved version. mkae copy of current state of graph.
537 if (!fLastSavedVersion) {
538 SetAutoAdd(kFALSE); // disable auto add to grid manager - or we'll have every grid appearing twice!
540 SetAutoAdd(); // re-enable auto add
541 }
543 fLastSavedVersion->GetIdentifiers()->Execute("SetLineColor", "kBlack");
544 fLastSavedVersion->GetIdentifiers()->Execute("SetMarkerColor", "kBlack");
545}
546
547
548
554
556{
557 // Revert to last saved version of grid
558 // this will destroy any existing lines in the grid and replace them with
559 // copies of the lines as they were at the last moment the grid was saved
560 // If the grid is (was) visible in a pad, we redraw the new lines.
561
562 if (!fLastSavedVersion) {
563 Info("RevertToLastSavedVersion", "No saved version to revert to! (Sorry)");
564 return;
565 }
566 Bool_t wasDrawn = kFALSE;
567 if (fPad) {
568 // if grid was visible, remove it from pad before modifying (deleting) lines
569 wasDrawn = kTRUE;
570 fPad->cd();// make sure pad with grid is active (gPad) pad
571 UnDraw();
572 }
573 Clear();
574 fLastSavedVersion->Copy(*this);
575 if (wasDrawn) {
576 // if grid was visible, redraw it with new lines
577 Draw();
578 }
579}
580
581
582
583
600
601void KVIDGraph::ReadFromAsciiFile(ifstream& gridfile)
602{
603 //Read info from already open ascii file stream containing each line of this grid.
604 //Any previous lines in the grid are destroyed.
605 //Comment lines begin with #
606 //Grid info begins with
607 //++ClassName
608 //where ClassName is actual class name of instance of this object
609 //The names associated to the X & Y axis of the identification map are written
610 //on lines beginning with
611 //<VARX>
612 //<VARY>
613 //Parameter lines begin with <PARAMETER>
614 //New lines begin with +name_of_class
615 //'!' signals end of grid info
616 //Any scaling factors are applied once the coordinates have been read
617
618 //reset grid - destroy old lines, axis limits...
619 Clear();
620 //clear parameters
621 fPar.Clear();
622
623 KVString s;
624 int line_no = 0; // counter for lines read
626 Int_t mass_formula = -1;
627
628 while (gridfile.good()) {
629 //read a line
630 s.ReadLine(gridfile);
631 if (s.BeginsWith('!')) {
632 //end of grid signalled
633 break;
634 }
635 else if (s.BeginsWith("++")) { //will only happen if we are reading a file using ReadAsciiFile(const char*)
636 //check classname
637 s.Remove(0, 2);
638 s.Remove(TString::kBoth, ' '); //remove whitespace
639 if (s != ClassName())
640 Warning("ReadFromAsciiFile(ofstream&)",
641 "Class name in file %s does not correspond to this class (%s)",
642 s.Data(), ClassName());
643 }
644 else if (s.BeginsWith("<NAME>")) {
645 //name of grid
646 s.Remove(0, 7);
647 s.Remove(TString::kBoth, ' '); //remove whitespace
648 SetName(s.Data());
649 }
650 else if (s.BeginsWith("<VARX>")) {
651 //x-axis definition
652 s.Remove(0, 7);
653 s.Remove(TString::kBoth, ' '); //remove whitespace
654 SetVarX(s.Data());
655 }
656 else if (s.BeginsWith("<VARY>")) {
657 //y-axis definition
658 s.Remove(0, 7);
659 s.Remove(TString::kBoth, ' '); //remove whitespace
660 SetVarY(s.Data());
661 }
662 else if (s.BeginsWith("<PARAMETER>")) {
663 //parameter definition
664 s.Remove(0, 11);
665 //split into tokens separated by '='
666 TObjArray* toks = s.Tokenize('=');
667 if (toks->GetEntries() > 1) {
668 TString name =
669 ((TObjString*) toks->At(0))->GetString().
670 Strip(TString::kBoth);
671 KVString value(((TObjString*) toks->At(1))->GetString());
672 value.Remove(TString::kBoth, ' '); //remove whitespace
673 if (name != "" && value != "") {
674 if (value.IsFloat())
675 fPar.SetValue(name.Data(), value.Atof());
676 else if (value.IsDigit())
677 fPar.SetValue(name.Data(), value.Atoi());
678 else
679 fPar.SetValue(name.Data(), value.Data());
680 }
681 }
682 delete toks; //must clean up
683 }
684 else if (s.BeginsWith("<LIST>")) { // number list definition
685 s.Remove(0, 6); // get rid of "<LIST>"
686 //split into tokens separated by '='
687 TObjArray* toks = s.Tokenize('=');
688 if (toks->GetEntries() > 1) {
689 TString name =
690 ((TObjString*) toks->At(0))->GetString().
691 Strip(TString::kBoth);
692 TString list(((TObjString*) toks->At(1))->GetString());
693 //set appropriate list
694 if (name == "Runs")
695 SetRuns(list.Data());
696 else
697 fPar.SetValue(name.Data(), list.Data());
698 }
699 delete toks; //must clean up
700 }
701 else if (s.BeginsWith("OnlyZId")) {
703 s.ReplaceAll("OnlyZId", "");
704 s.Remove(TString::kBoth, ' ');
705 if (s != "") { //older versions did not write mass formula after OnlyZId
706 mass_formula = s.Atoi();
707 if (mass_formula > -1) SetMassFormula(mass_formula);
708 }
709 }
710 else if (s.BeginsWith('+')) {
711 //New line
712 line_no++;
713 //Get name of class by stripping off the '+' at the start of the line
714 s.Remove(0, 1);
715 TString lineclass = s;
716 //next line is type ("ID" or "OK") followed by ':', followed by name of line
717 s.ReadLine(gridfile);
718 //split into tokens separated by ':'
719 TObjArray* toks = s.Tokenize(':');
720 TString type = ((TObjString*) toks->At(0))->GetString();
721 TString name = "";
722 // make sure the line actually has a name !
723 if (toks->GetEntries() > 1) name = ((TObjString*) toks->At(1))->GetString();
724 else {
725 // print warning allowing to find nameless line in file
726 Warning("ReadFromAsciiFile",
727 "In graph : %s\nIdentifier with no name. Identifier type = %s. Line number in graph = %d",
728 GetName(), type.Data(), line_no);
729 }
730 delete toks; //must clean up
731 ReadIdentifierFromAsciiFile(name, type, lineclass, gridfile);
732 }
733 }
736 if (fLastScaleX != 1 || fLastScaleY != 1) {
738 }
740 //set runlist
741 if (fPar.HasParameter("Runlist")) SetRuns(fPar.GetStringValue("Runlist"));
742 else SetRuns("");
743
744 // if a back-up copy had previously been created (by starting the editor)
745 // we replace it by the version read from file
747}
748
749
750
751
754
755void KVIDGraph::ReadIdentifierFromAsciiFile(TString& name, TString& type, TString& cl, ifstream& gridfile)
756{
757 // Read in new identifier object from file
758
759 KVIDentifier* line = New(cl.Data());
760 line->SetName(name.Data());
761 Add(type, line);
762 //now use ReadAscii method of class to read coordinates and other informations
763 line->ReadAsciiFile(gridfile);
764}
765
766
767
768
778
779void KVIDGraph::ReadAsciiFile(const Char_t* filename)
780{
781 //Open, read and close ascii file containing this grid.
782 //Any previous lines in the grid are destroyed.
783 //Comment lines begin with #
784 //Grid info begins with
785 //++ClassName
786 //where ClassName is actual class name of instance of this object
787 //New lines begin with +name_of_class
788 //'!' signals end of grid
789
790 ifstream gridfile(filename);
791
792 if (gridfile.good()) {
793 ReadFromAsciiFile(gridfile);
794 }
795 else {
796 Warning("ReadAsciiFile", "Could not find file %s. Check filename.", filename);
797 }
798 gridfile.close();
799}
800
801
802
803
806
808{
809 //Create new object of class "id_class" which derives from KVIDentifier
810
811 KVIDentifier* line = 0;
812 TClass* clas = TClass::GetClass(id_class);
813 if (!clas) {
814 Error("New",
815 "%s is not a valid classname. No known class.", id_class);
816 }
817 else {
818 if (!clas->InheritsFrom(KVIDentifier::Class())) {
819 Error("New",
820 "%s is not a valid class deriving from KVIDentifier",
821 id_class);
822 }
823 else {
824 line = (KVIDentifier*) clas->New();
825 }
826 }
827 return line;
828}
829
830
831
832
837
839{
840 // Add the object to the list of cuts or identifiers:
841 // type = "ID" --> calls AddIdentifier(id)
842 // type = "OK" or "cut" --> calls AddCut(id)
843
844 type.ToUpper();
845 if (type == "ID") AddIdentifier(id);
846 else if (type == "OK" || type == "CUT") AddCut(id);
847 else if (type == "INFO") AddInfo(id);
848}
849
850
851
852
857
859{
860 // Create and add the object to the list of cuts or identifiers:
861 // type = "ID" --> calls AddIdentifier(id)
862 // type = "OK" or "cut" --> calls AddCut(id)
863
864 type.ToUpper();
865 KVIDentifier* id = New(classname);
866 if (!id) return 0;
867 if (type == "ID") AddIdentifier(id);
868 else if (type == "OK" || type == "CUT") AddCut(id);
869 else if (type == "INFO") AddInfo(id);
870 return id;
871}
872
873
874
875
887
889{
890 //Draw all objects in graph on the current display, if one exists: i.e. in order to superimpose the grid
891 //on a 2D display of data, use KVIDGraph::Draw() (no option "same" needed).
892 //
893 //If no TCanvas exists, or if one exists but it is empty, a frame large enough to display all
894 //the objects in the graph will be generated.
895 //
896 //The title of the canvas is set to the name of the graph
897 //
898 //If the graph is already displayed (i.e. if fPad!=0), we call UnDraw() in order to remove it from the display.
899 //This is so that double-clicking a graph in the IDGridManagerGUI list makes it disappear if it is already drawn.
900
901 if (fPad) { /* graph already displayed. undraw it! */
902 UnDraw();
903 return;
904 }
905
906 if (!gPad) {
907 fPad = new TCanvas("c1", GetName());
908 }
909 else {
910 fPad = (TPad*)gPad;
911 gPad->SetTitle(GetName());
912 }
913 if (!gPad->GetListOfPrimitives()->GetSize()) {
914 //calculate size of pad necessary to show graph
915 if (GetXmin() == GetXmax())
916 const_cast < KVIDGraph* >(this)->FindAxisLimits();
917 gPad->DrawFrame(GetXmin(), GetYmin(), GetXmax(), GetYmax());
918 }
919 {
920 fIdentifiers.R__FOR_EACH(KVIDentifier, Draw)("PL");
921 }
922 {
923 fCuts.R__FOR_EACH(KVIDentifier, Draw)("PL");
924 }
925 {
926 fInfoZones.R__FOR_EACH(KVIDentifier, Draw)("PL");
927 }
928 gPad->Modified();
929 gPad->Update();
930 // connect canvas' Closed() signal to KVIDGraph::ResetPad so that if the
931 // canvas GUI is closed (thereby deleting the fPad object), we reset fPad
932 // and do not try to Undraw in a non-existent canvas
933// fPad->Connect("Closed()", "KVIDGraph", this, "ResetPad()");
934// if (fPad->GetCanvas()) fPad->GetCanvas()->Connect("Cleared(TVirtualPad*)", "KVIDGraph", this, "ClearPad(TVirtualPad*)");
935}
936
937
938
939
965
967{
968 //Make the graph disappear from the current canvas/pad
969 //In case any objects have (accidentally) been drawn more than once, we keep calling
970 //gPad->GetListOfPrimitives()->Remove() as long as gPad->GetListOfPrimitives()->FindObject()
971 //returns kTRUE for each identifier.
972
973// if (!fPad) {
974// Error("UnDraw", "Cannot undraw, no pad stored ??");
975// return;
976// }
977// TIter next_id(fIdentifiers);
978// KVIDentifier* line;
979// //remove the rest of the lines
980// while ((line = (KVIDentifier*) next_id())) {
981// while (fPad->GetListOfPrimitives()->FindObject(line))
982// fPad->GetListOfPrimitives()->Remove(line);
983// }
984// TIter next_ok(fCuts);
985// while ((line = (KVIDentifier*) next_ok())) {
986// while (fPad->GetListOfPrimitives()->FindObject(line))
987// fPad->GetListOfPrimitives()->Remove(line);
988// }
989// fPad->Modified();
990// fPad->Update();
991// fPad->Disconnect("Closed()", this, "ResetPad()");
992// if (fPad->GetCanvas()) fPad->GetCanvas()->Disconnect("Cleared(TVirtualPad*)", this, "ClearPad(TVirtualPad*)");
993 fPad = 0;
994}
995
996
997
998
1002
1004{
1005 // In case the graph can no longer be drawn/undrawn (because fPad contains address of a canvas
1006 // which died unexpectedly), use this method to reset fPad=0 and hopefully start afresh.
1007 fPad = 0;
1008}
1009
1010
1011
1016
1018{
1019 // Extend the first segment of each identification line back to new coordinate newX
1020 //
1021 // See KVIDentifier::ExtendLine()
1022
1023 fIdentifiers.R__FOR_EACH(KVIDentifier, ExtendLine)(true, newX, Direction);
1024}
1025
1026
1027
1032
1034{
1035 // Extend the last segment of each identification line to new coordinate newX
1036 //
1037 // See KVIDentifier::ExtendLine()
1038 fIdentifiers.R__FOR_EACH(KVIDentifier, ExtendLine)(false, newX, Direction);
1039}
1040
1041
1042
1043
1046
1048{
1049 //Print out all objects in graph
1050
1051 cout << ClassName() << " : " << GetName() << endl;
1052 cout << "Title : " << GetTitle() << endl;
1053 //print list of parameters
1054 fPar.Print();
1055 KVIDentifier* line = 0;
1056 TIter nextOK(&fCuts);
1057 while ((line = (KVIDentifier*) nextOK()))
1058 line->ls();
1059 TIter nextID(&fIdentifiers);
1060 while ((line = (KVIDentifier*) nextID()))
1061 line->ls();
1062 TIter nextInfo(&fInfoZones);
1063 while ((line = (KVIDentifier*) nextInfo()))
1064 line->ls();
1065}
1066
1067
1068
1069
1072
1074{
1075 //Calculate X/Y min/max of all objects in graph
1076
1078 Double_t x, y, xmin, ymin, xmax, ymax;
1079 xmax = ymax = -999999;
1080 xmin = ymin = 999999;
1081 TIter nextOK(&fCuts);
1082 while ((line = (KVIDentifier*) nextOK())) {
1083 for (int i = 0; i < line->GetN(); i++) {
1084 line->GetPoint(i, x, y);
1085 xmin = (x < xmin ? x : xmin);
1086 xmax = (x > xmax ? x : xmax);
1087 ymin = (y < ymin ? y : ymin);
1088 ymax = (y > ymax ? y : ymax);
1089 }
1090 }
1091 TIter nextID(&fIdentifiers);
1092 while ((line = (KVIDentifier*) nextID())) {
1093 for (int i = 0; i < line->GetN(); i++) {
1094 line->GetPoint(i, x, y);
1095 xmin = (x < xmin ? x : xmin);
1096 xmax = (x > xmax ? x : xmax);
1097 ymin = (y < ymin ? y : ymin);
1098 ymax = (y > ymax ? y : ymax);
1099 }
1100 }
1101 fXmin = xmin;
1102 fYmin = ymin;
1103 fXmax = xmax;
1104 fYmax = ymax;
1105 // Info("FindAxisLimits()", "Xmin=%f Ymin=%f Xmax=%f Ymax=%f", GetXmin(), GetYmin(), GetXmax(), GetYmax());
1106}
1107
1108
1109
1110
1117
1119{
1120 // Rescale coordinates of every object in graph according to arbitrary functions
1121 // of the coordinates (sx & sy can be 1-dimensional or 2-dimensional functions).
1122 //
1123 // If sy is a TF1 function f(x), then the 'x' in this function refers to the y-coordinate.
1124 // If sy is a TF2 function f(x,y), 'x' and 'y' refer to the x & y-coordinates.
1125
1126 if (!sx && !sy)
1127 return;
1128 if (GetNumberOfIdentifiers() > 0) {
1129 fIdentifiers.R__FOR_EACH(KVIDentifier, Scale)(sx, sy);
1130 }
1131 if (GetNumberOfCuts() > 0) {
1132 fCuts.R__FOR_EACH(KVIDentifier, Scale)(sx, sy);
1133 }
1134 if (GetNumberOfInfos() > 0) {
1135 fInfoZones.R__FOR_EACH(KVIDentifier, Scale)(sx, sy);
1136 }
1137 Modified();
1138}
1139
1140
1141
1142
1145
1147{
1148 // Called by SetX/YScaleFactor methods to rescale every point of every object in the grid
1149
1150 if (TMath::Abs(sx) == 1 && TMath::Abs(sy) == 1)
1151 return;
1152 if (GetNumberOfIdentifiers() > 0) {
1153 fIdentifiers.R__FOR_EACH(KVIDentifier, Scale)(sx, sy);
1154 }
1155 if (GetNumberOfCuts() > 0) {
1156 fCuts.R__FOR_EACH(KVIDentifier, Scale)(sx, sy);
1157 }
1158 if (GetNumberOfInfos() > 0) {
1159 fInfoZones.R__FOR_EACH(KVIDentifier, Scale)(sx, sy);
1160 }
1161}
1162
1163
1164
1165
1173
1174void KVIDGraph::DrawAndAdd(const Char_t* Type, const Char_t* Classname)
1175{
1176 //Use this method to add objects to a grid which is drawn in the current pad gPad.
1177 //We wait for the user to draw the line with the graphical editor
1178 //(we put the pad automatically into this mode,
1179 //there is no need to use the Editor toolbar).
1180 //Then we retrieve this TGraph, create a new KVIDentifier-derived object of
1181 //class "classname", and add it to the "type" list (= "OK"/"cut" or "ID").
1182
1183 if (!fPad && !gPad) return;
1184 // if grid already drawn somewhere, make grid's pad active
1185 if (fPad && fPad != gPad) {
1186 fPad->cd();
1187 Warning("DrawAndAdd", "Changed active pad to pad containing this graph");
1188 }
1189 if (!fPad) fPad = gPad;
1190
1191 TString type(Type);
1192 TString classname(Classname);
1193 //create new ID line
1194 KVIDentifier* line = New(classname);
1195 //wait for user to draw object
1196 line->WaitForPrimitive();
1197 //add line to list
1198 Add(type, line);
1199 Modified();
1200}
1201
1202
1203
1204
1205
1206
1218
1220 KVIDGraph* g2, Int_t id2_min, Int_t id2_max)
1221{
1222 //Static method taking lines id1_min to id2_min from grid g1 and lines id2_min to id2_max from
1223 //grid g2 and making a new grid containing them. Returns the pointer to the new grid.
1224 //
1225 //It is assumed that g1 and g2 are grids of the same class. The new grid will be an object of the
1226 //same class as g1.
1227 //
1228 //Any scaling factors are applied to the line coordinates as they are copied from their parent grids.
1229 //As scaling may be different in g1 and g2, the resulting grid has no scaling factor, but the coordinates
1230 //of all its lines result from application of the different scaling factors of the two grids.
1231
1232 //make new grid
1233 KVIDGraph* merger = (KVIDGraph*) g1->IsA()->New();
1234
1235 //loop over lines in first grid
1236 TIter next_id1(g1->GetIdentifiers());
1238 while ((line = (KVIDentifier*) next_id1())) {
1239 if (line->GetID() >= id1_min && line->GetID() <= id1_max)
1240 merger->Add("ID", (KVIDentifier*) line->Clone()); //add clone of lines with right ID
1241 }
1242
1243 //loop over lines in second grid
1244 TIter next_id2(g2->GetIdentifiers());
1245 while ((line = (KVIDentifier*) next_id2())) {
1246 if (line->GetID() >= id2_min && line->GetID() <= id2_max)
1247 merger->Add("ID", (KVIDentifier*) line->Clone());
1248 }
1249
1250 //just in case any of the lines were highlighted...
1251 merger->SetLineColor(kBlack);
1252
1253 return merger;
1254}
1255
1256
1257
1258
1268
1270{
1271 // Default method for deciding if point (x,y) corresponds to an identifiable
1272 // particle or not: we loop over the list of cuts and test the
1273 // point with the method TestPoint(x,y).
1274 //
1275 // If the point is accepted by all cuts, then (x,y) is identifiable (return kTRUE).
1276 //
1277 // If the point is rejected by a cut we return kFALSE.
1278 // If rejected_by contains a valid pointer, we set it to the name of the rejecting cut.
1279
1280 TIter next(&fCuts);
1281 KVIDentifier* id = 0;
1282 if (rejected_by) *rejected_by = "";
1283 while ((id = (KVIDentifier*)next())) {
1284 if (!id->TestPoint(x, y)) {
1285 if (rejected_by) *rejected_by = id->GetName();
1286 return kFALSE;
1287 }
1288 }
1289 return kTRUE;
1290}
1291
1292
1293
1296
1298{
1299 // loop over KVIDGraph::fInfoZones to set flags in KVIdentificationResult
1300
1301 TIter next(&fInfoZones);
1302 KVIDentifier* id = 0;
1303 while ((id = (KVIDentifier*)next())) {
1304 if (id->TestPoint(x, y)) {
1305 idr->AddFlag(GetName(), id->GetName());
1306 }
1307 }
1308}
1309
1310
1311
1312
1315
1317{
1318 // Set list of runs for which grid is valid
1319 fRunList = runs;
1320 fPar.SetValue("Runlist", fRunList.AsString());
1321 Modified();
1322}
1323
1324
1325
1326
1331
1333{
1334 // If name of grid is not set explicitly with SetName(const Char_t*),
1335 // we return the name of the first ID telescope in the list of telescopes
1336 // with which this grid is associated.
1337
1338 if (fName != "") return fName;
1339 fDyName = "";
1340 if (fTelescopes.At(0)) fDyName = fTelescopes.At(0)->GetName();
1341 else {
1342 if (fPar.HasParameter("IDTelescopes")) {
1343 KVString tel_list = fPar.GetStringValue("IDTelescopes");
1344 tel_list.Begin(",");
1345 fDyName = tel_list.Next();
1346 }
1347 }
1348 return fDyName;
1349}
1350
1351
1352
1353
1360
1362{
1363 // Called after reading a grid from an ascii file.
1364 // Tries to convert information written by an old version of the class:
1365 //
1366 //<PARAMETER> First run=... ----> <PARAMETER> Runlist=...
1367 //<PARAMETER> Last run=...
1368
1369 if (fPar.HasParameter("Runlist")) return;
1370 if (fPar.HasParameter("First run") && fPar.HasParameter("Last run")) {
1371 fRunList.SetMinMax(fPar.GetIntValue("First run"), fPar.GetIntValue("Last run"));
1372 fPar.SetValue("Runlist", fRunList.AsString());
1373 fPar.RemoveParameter("First run");
1374 fPar.RemoveParameter("Last run");
1375 }
1376}
1377
1378
1386
1388{
1389 // ecriture des grilles avec version suivant un modele de fichier (fPattern)
1390 // fPattern_v%d.grid
1391 // le modele doit etre initialiser par la methode SetPattern(TString)
1392 // la valeur par default version=-1 permet l ecriture de la derniere version
1393 // apres un check des versions existantes (methode CheckVersion)
1394 // la premiere version est indexee v0
1395 Int_t vv = 0;
1396 if (version == -1) vv = CheckVersion(version) + 1;
1397 WriteAsciiFile(fPattern + "_v" + Form("%d", vv) + ".grid");
1398}
1399
1400
1403
1405{
1406 // lecture des grilles avec version suivant un modele de fichier
1407 Int_t vv = CheckVersion(version);
1408 if (vv == -1) {
1409 if (version == -1) cout << "no file " + fPattern + "_v%d.grid" << endl;
1410 else cout << "no file " + fPattern + Form("_v%d.grid", version) << endl;
1411 }
1412 else ReadAsciiFile(fPattern + "_v" + Form("%d", vv) + ".grid");
1413}
1414
1415
1422
1424{
1425 // version>=0 check si la version demandee du fichier grille existe
1426 // version-1 renvoie la derniere version existante
1427 // si la version demandee n existe pas return -1
1428 // creation d un fichier tampon dans le repertoire ou se situe les fichiers grilles
1429 // efface a la fin de la methode
1430 Int_t temoin = -1;
1431 TString pbis = fPattern, chemin = "";
1432 TObjArray* tok = NULL;
1433 if (fPattern.Contains("/")) { // prise en compte de fPattern contenant un chemin pour les fichiers
1434 tok = fPattern.Tokenize("/");
1435 Int_t nb = tok->GetEntries();
1436 pbis = ((TObjString*)(*tok)[nb - 1])->GetString();
1437 chemin = "";
1438 for (Int_t ii = 0; ii < nb - 1; ii += 1) chemin += ((TObjString*)(*tok)[ii])->GetString();
1439 chemin += "/";
1440 }
1441 gROOT->ProcessLine(".! ls " + fPattern + "_v*.grid >> " + chemin + "listKVIDGraph_" + pbis);
1442 ifstream f_in(chemin + "listKVIDGraph_" + pbis);
1443 TString line = "";
1444 Int_t num = -2;
1445 while (f_in.good() && num != version) {
1446 line.ReadLine(f_in);
1447 if (line.Contains(fPattern + "_v") && line.Contains(".grid")) {
1448 tok = line.Tokenize(".");
1449 line = ((TObjString*)(*tok)[0])->GetString();
1450 line.ReplaceAll(fPattern + "_v", "template");
1451 tok = line.Tokenize("template");
1452 num = ((TObjString*)(*tok)[0])->GetString().Atoi();
1453 if (num > temoin) temoin = num;
1454 }
1455 }
1456 f_in.close();
1457 gROOT->ProcessLine(".! rm -f " + chemin + "listKVIDGraph_" + pbis);
1458 delete tok;
1459 if (version == -1) return temoin;
1460 else if (temoin != version) {
1461 return -1;
1462 }
1463 else return temoin;
1464}
1465
1466
1467
1468
1472
1474{
1475 // Set mass formula for all identifiers if graph has OnlyZId()=kTRUE.
1476 // This will change the mass (A) of each identifier.
1477
1478 fMassFormula = mass;
1479 if (IsOnlyZId()) {
1480 if (GetNumberOfIdentifiers() > 0) {
1481 fIdentifiers.R__FOR_EACH(KVIDentifier, SetMassFormula)(mass);
1482 }
1483 }
1484 Modified();
1485}
1486
1487
1488
1489
1495
1497{
1498 // Use this method if the graph is only to be used for Z identification
1499 // (no isotopic information). Default is to identify both Z & A
1500 // (fOnlyZid = kFALSE). Note that setting fOnlyZid=kTRUE changes the way line
1501 // widths are calculated (see KVIDGrid::CalculateLineWidths)
1502 fOnlyZId = yes;
1503 if (GetNumberOfIdentifiers() > 0) {
1504 fIdentifiers.R__FOR_EACH(KVIDentifier, SetOnlyZId)(yes);
1505 }
1506 Modified();
1507}
1508
1509
1510
1511
1512
1515
1517{
1518 // Associate this graph with all ID telescopes in list
1519
1520 TIter next(tels);
1521 KVBase* tel;
1522 while ((tel = (KVBase*)next())) AddIDTelescope(tel);
1523 Modified();
1524 if (gIDGridManager) gIDGridManager->Modified();
1525}
1526
1527
1528
1529//void KVIDGraph::SetIDTelescopes()
1530//{
1531// // Opens dialog box to view and/or choose ID telescopes associated with this
1532// // identification graph
1533
1534// Bool_t cancel;
1535// TString old_label = GetIDTelescopeLabel();
1536// new KVIDGUITelescopeChooserDialog(gMultiDetArray, &fTelescopes, &cancel,
1537// gClient->GetRoot(), gClient->GetRoot());
1538// if(!cancel){
1539// // if type of associated id telescope has changed, we need to
1540// // update the grid manager and associated gui (grid will appear
1541// // on a different tab).
1542// if(old_label != GetIDTelescopeLabel()) gIDGridManager->Modified();
1543// else // same type; just the grid changes
1544// Modified();
1545// }
1546//}
1547
1548
1549
1555
1557{
1558 // Static function which will create and 'Build' the identification graph of
1559 // class 'class_name', one of the plugins defined in either $KVROOT/KVFiles/.kvrootrc,
1560 // or in the user's .kvrootrc file.
1561
1562 //check and load plugin library
1563 TPluginHandler* ph;
1564 if (!(ph = KVBase::LoadPlugin("KVIDGraph", class_name)))
1565 return 0;
1566
1567 //execute constructor/macro for graph - assumed without arguments
1568 KVIDGraph* gr = (KVIDGraph*) ph->ExecPlugin(0);
1569 return gr;
1570}
1571
1572
1573
1574
1581
1583{
1584 // Toggles 'editable' status of all lines/contours in graph
1585 // If editable = kTRUE this makes it possible to modify the graph
1586 // we then take a snapshot of the graph before editing begins
1587 // and store it in fLastSavedVersion. we can always revert to
1588 // this version if we want
1589
1590 if (editable && !GetEditable()) UpdateLastSavedVersion();
1591
1592 TCutG::SetEditable(editable);
1593 if (GetNumberOfIdentifiers() > 0) {
1594 fIdentifiers.R__FOR_EACH(KVIDentifier, SetEditable)(editable);
1595 }
1596 if (GetNumberOfCuts() > 0) {
1597 fCuts.R__FOR_EACH(KVIDentifier, SetEditable)(editable);
1598 }
1599 if (GetNumberOfInfos() > 0) {
1600 fInfoZones.R__FOR_EACH(KVIDentifier, SetEditable)(editable);
1601 }
1602}
1603
1604
1605
1606
1610
1612{
1613 // Returns a comma-separated list of the names of all ID telescopes for which
1614 // this grid is valid.
1615
1616 static TString tel_list;
1617 if (!fTelescopes.GetEntries()) {
1618 // case of grid with "unknown" ID telescopes
1619 // we return the value of the IDTelescopes parameter (if defined)
1620 if (fPar.HasParameter("IDTelescopes")) {
1621 tel_list = fPar.GetStringValue("IDTelescopes");
1622 return tel_list.Data();
1623 }
1624 }
1625 TIter next(&fTelescopes);
1626 TObject* id = next();
1627 if (id) tel_list = id->GetName();
1628 while ((id = next())) tel_list += Form(",%s", id->GetName());
1629 return tel_list;
1630}
1631
1632
1633
1634
1638
1639void KVIDGraph::Streamer(TBuffer& R__b)
1640{
1641 // Stream an object of class KVIDGraph.
1642 // Resets the 'fParent' pointer of each KVIDentifier after reading them in.
1643
1644 if (R__b.IsReading()) {
1645 R__b.ReadClassBuffer(KVIDGraph::Class(), this);
1646 TIter nxt_id(&fIdentifiers);
1648 while ((id = (KVIDentifier*)nxt_id())) id->fParent = this;
1649 TIter nxt_cut(&fCuts);
1650 while ((id = (KVIDentifier*)nxt_cut())) id->fParent = this;
1651 TIter nxt_info(&fInfoZones);
1652 while ((id = (KVIDentifier*)nxt_info())) id->fParent = this;
1653 }
1654 else {
1655 R__b.WriteClassBuffer(KVIDGraph::Class(), this);
1656 }
1657}
1658
1659
1660
1662
1666
1670 void fill(const char* name, double x, double y = 0., double w = 0.)
1671 {
1673 if (h) {
1674 if (w > 0)((TH2*)h)->Fill(x, y, w);
1675 else h->Fill(x, y);
1676 }
1677 }
1678};
1679
1680
1681
1706
1708{
1709 //This method allows to test the identification capabilities of the grid using data in a TH2F.
1710 //We assume that 'data' contains an identification map, whose 'x' and 'y' coordinates correspond
1711 //to this grid. Then we loop over every bin of the histogram, perform the identification (if
1712 //IsIdentifiable() returns kTRUE) and fill the histograms with the results of the identification
1713 //
1714 //The "identification" or PID we represent is the result of the KVReconstructedNucleus::GetPID()
1715 //method for the identified nucleus.
1716 //
1717 // The KVHashList contains histograms to be filled with results
1718 // The KVNameValueList histo_names contains the name of each histogram passed in the KVHashList
1719 // i.e. it may have any of the following parameters
1720 //
1721 // "ID_REAL"="[name of histo to fill with PID spectrum]"
1722 // "ID_REAL_AIDENT"="[name of histo to fill with PID spectrum]" Z&A identification
1723 // "ID_REAL_ZIDENT"="[name of histo to fill with PID spectrum]" Only Z identification
1724 // "ID_REAL_VS_ERES" - PID vs. Eres (X) histo
1725 // "ID_REAL_VS_DE" - PID vs. DeltaE (Y) histo
1726 // "ID_REAL_VS_ERES_AIDENT" - PID vs. Eres histo, Z&A identification
1727 // "ID_REAL_VS_ERES_ZIDENT" - PID vs. Eres histo, only Z identification
1728 // - only for isotopic identificiation:
1729 // "Z_A_REAL" - 2D map (nuclear chart)
1730 // "ZADIST_AIDENT" - integer A vs. integer Z distribution for isotopically-identified particles
1731
1732 //Initialize the grid: calculate line widths etc.
1733 Initialize();
1734
1735 kvidgraph_idresult_filler idresults(histos, histo_names);
1736
1737 // reset contents of all histos
1738 histos.Execute("Reset", "");
1739
1740 Int_t tot_events = (Int_t) data->GetSum();
1741 Int_t events_read = 0;
1742 Int_t percent = 0, cumul = 0;
1743
1745
1746 for (int i = 1; i <= data->GetNbinsX(); ++i) {
1747 for (int j = 1; j <= data->GetNbinsY(); j++) {
1748
1749 Stat_t poids = data->GetBinContent(i, j);
1750 if (poids == 0)
1751 continue;
1752
1753 Axis_t x0 = data->GetXaxis()->GetBinCenter(i);
1754 Axis_t y0 = data->GetYaxis()->GetBinCenter(j);
1755 Axis_t wx = data->GetXaxis()->GetBinWidth(i);
1756 Axis_t wy = data->GetYaxis()->GetBinWidth(j);
1757 //If bin content ('poids') is <=20, we perform the identification 'poids' times, each time with
1758 //randomly-drawn x and y coordinates inside this bin
1759 //If 'poids'>20, we perform the identification 20 times and we fill the histograms with
1760 //a weight poids/20
1761 Int_t kmax = (Int_t) TMath::Min(20., poids);
1762 Double_t weight = (kmax == 20 ? poids / 20. : 1.);
1763 for (int k = 0; k < kmax; k++) {
1764 double x = gRandom->Uniform(x0 - .5 * wx, x0 + .5 * wx);
1765 double y = gRandom->Uniform(y0 - .5 * wy, y0 + .5 * wy);
1766 if (IsIdentifiable(x, y)) {
1767 idr.Clear();
1768 Identify(x, y, &idr);
1769 if (AcceptIDForTest(idr)) {
1770 Float_t PID = idr.PID;
1771 if (idr.Aident) PID = (idr.Z + 0.1 * (idr.PID - 2. * idr.Z));
1772 Float_t RealA, RealZ;
1773 RealA = (idr.Aident ? idr.PID : (Float_t)idr.A);
1774 RealZ = (idr.Aident ? (Float_t)idr.Z : idr.PID);
1775 idresults.fill("ID_REAL", PID, weight);
1776 idresults.fill("ID_REAL_VS_DE", y, PID, weight);
1777 idresults.fill("ID_REAL_VS_ERES", x, PID, weight);
1778 if (idr.Aident) {
1779 idresults.fill("Z_A_REAL", RealA - RealZ, gRandom->Gaus(RealZ, 0.15), weight);
1780 idresults.fill("ZADIST_AIDENT", idr.Z, idr.A, weight);
1781 idresults.fill("ID_REAL_AIDENT", PID, weight);
1782 idresults.fill("ID_REAL_VS_DE_AIDENT", y, PID, weight);
1783 idresults.fill("ID_REAL_VS_ERES_AIDENT", x, PID, weight);
1784 }
1785 else if (idr.Zident) {
1786 idresults.fill("ID_REAL_ZIDENT", PID, weight);
1787 idresults.fill("ID_REAL_VS_DE_ZIDENT", y, PID, weight);
1788 idresults.fill("ID_REAL_VS_ERES_ZIDENT", x, PID, weight);
1789 }
1790 }
1791 }
1792 }
1793 events_read += (Int_t) poids;
1794 percent = (1. * events_read / tot_events) * 100.;
1795 if (percent > cumul) {
1796 Increment((Float_t) events_read); //sends signal to GUI progress bar
1798 cumul = percent;
1799 }
1800
1801 }
1802 }
1803}
1804
1805
int Int_t
bool Bool_t
char Char_t
float Float_t
double Axis_t
constexpr Bool_t kFALSE
double Double_t
double Stat_t
constexpr Bool_t kTRUE
const char Option_t
kBlack
winID w
winID h TVirtualViewer3D vv
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint percent
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
float xmin
float ymin
float xmax
float ymax
#define gROOT
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
char * Strip(const char *str, char c=' ')
R__EXTERN TSystem * gSystem
#define gPad
Base class for KaliVeda framework.
Definition KVBase.h:142
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Definition KVBase.cpp:793
Extended version of ROOT THashList.
Definition KVHashList.h:29
Base class for particle identification in a 2D map.
Definition KVIDGraph.h:32
KVNumberList fRunList
runs for which grid is valid
Definition KVIDGraph.h:49
void Add(TString, KVIDentifier *)
Axis_t GetYmax() const
Definition KVIDGraph.h:397
Double_t GetYScaleFactor()
TString fDyName
dynamically generated name
Definition KVIDGraph.h:51
virtual void ReadAsciiFile_WP(Int_t version=-1)
lecture des grilles avec version suivant un modele de fichier
KVIDGraph * fLastSavedVersion
copy of last save version of grid, used for 'undo'
Definition KVIDGraph.h:54
Int_t GetNumberOfCuts() const
Definition KVIDGraph.h:332
void ExtendBeginningAllIdentLines(Double_t, Option_t *="")
KVNameValueList fPar
parameters associated to grid
Definition KVIDGraph.h:45
virtual void SetVarX(const char *v)
Definition KVIDGraph.h:525
void ReadAsciiFile(const Char_t *filename)
void RemoveIdentifier(KVIDentifier *)
Remove and destroy identifier.
Double_t GetXScaleFactor()
virtual void TestIdentification(TH2F *data, KVHashList &histos, KVNameValueList &histo_names)
KVList fCuts
cuts used to define area in which identification is possible
Definition KVIDGraph.h:41
KVList fIdentifiers
list of identification objects
Definition KVIDGraph.h:40
Double_t fLastScaleY
last applied scaling factor on Y
Definition KVIDGraph.h:47
Double_t fLastScaleX
last applied scaling factor on X
Definition KVIDGraph.h:46
void UpdateLastSavedVersion()
update last saved version. mkae copy of current state of graph.
virtual void SetName(const char *name)
Definition KVIDGraph.h:140
Axis_t GetXmax() const
Definition KVIDGraph.h:393
void Scale(Double_t sx=-1, Double_t sy=-1)
Called by SetX/YScaleFactor methods to rescale every point of every object in the grid.
void ExtendEndAllIdentLines(Double_t, Option_t *="")
void RemoveInfo(KVIDentifier *)
Remove and destroy cut.
virtual void WriteToAsciiFile(std::ofstream &gridfile)
static void SetAutoAdd(Bool_t yes=kTRUE)
Definition KVIDGraph.h:100
void init()
Definition KVIDGraph.cpp:67
virtual void AddInfo(KVIDentifier *info)
Definition KVIDGraph.h:364
void Increment(Float_t x)
Definition KVIDGraph.h:249
void Draw(Option_t *opt="")
void AddIDTelescope(KVBase *t)
Definition KVIDGraph.h:407
Int_t GetNumberOfIdentifiers() const
Definition KVIDGraph.h:328
virtual void Copy(TObject &) const
Copy this to 'obj'.
virtual void ReadIdentifierFromAsciiFile(TString &name, TString &type, TString &cl, std::ifstream &gridfile)
Read in new identifier object from file.
Axis_t fXmin
Definition KVIDGraph.h:43
Bool_t IsOnlyZId() const
Definition KVIDGraph.h:57
Int_t GetMassFormula() const
Definition KVIDGraph.h:438
void RevertToLastSavedVersion()
void UnDraw()
virtual void ReadFromAsciiFile(std::ifstream &gridfile)
void ClearPad(TVirtualPad *)
Definition KVIDGraph.cpp:49
void WriteParameterListOfIDTelescopes()
virtual void Identify(Double_t, Double_t, KVIdentificationResult *) const =0
TString fPattern
pattern of filenames used to write or read grid
Definition KVIDGraph.h:52
void SetLineColor(Color_t lcolor)
Definition KVIDGraph.h:187
void Print(Option_t *opt="") const
Print out all objects in graph.
virtual void WriteAsciiFile_WP(Int_t version=-1)
KVIDentifier * GetIdentifier(Int_t Z, Int_t A) const
virtual ~KVIDGraph()
virtual Bool_t IsIdentifiable(Double_t, Double_t, TString *rejected_by=nullptr) const
void FindAxisLimits()
Calculate X/Y min/max of all objects in graph.
Axis_t GetYmin() const
Definition KVIDGraph.h:389
const KVList * GetIdentifiers() const
Definition KVIDGraph.h:298
virtual void SetVarY(const char *v)
Definition KVIDGraph.h:529
static KVIDGraph * AddGraphs(KVIDGraph *g1, Int_t id1_min, Int_t id1_max, KVIDGraph *g2, Int_t id2_min, Int_t id2_max)
virtual void DrawAndAdd(const Char_t *type="ID", const Char_t *classname="KVIDentifier")
virtual void AddCut(KVIDentifier *cut)
Definition KVIDGraph.h:353
void SetMassFormula(Int_t)
const Char_t * GetName() const
TList fTelescopes
ID telescopes for which grid is valid.
Definition KVIDGraph.h:50
static Bool_t fAutoAddGridManager
if =kTRUE, grids are automatically added to ID grid manager on creation (default)
Definition KVIDGraph.h:55
void WriteAsciiFile(const Char_t *filename)
Open, write and close ascii file containing this grid.
virtual KVIDentifier * New(const Char_t *)
Create new object of class "id_class" which derives from KVIDentifier.
virtual void BackwardsCompatibilityFix()
void AddIDTelescopes(const TList *)
Associate this graph with all ID telescopes in list.
virtual void AddIdentifier(KVIDentifier *id)
Definition KVIDGraph.h:340
virtual void SetInfos(Double_t, Double_t, KVIdentificationResult *) const
loop over KVIDGraph::fInfoZones to set flags in KVIdentificationResult
static KVIDGraph * MakeIDGraph(const Char_t *)
const Char_t * GetNamesOfIDTelescopes() const
Axis_t GetXmin() const
Definition KVIDGraph.h:385
void SetXScaleFactor(Double_t=0)
Int_t GetNumberOfInfos() const
Definition KVIDGraph.h:336
TVirtualPad * fPad
pad in which graph is drawn
Definition KVIDGraph.h:48
virtual Bool_t AcceptIDForTest(const KVIdentificationResult &idr)
Definition KVIDGraph.h:75
Axis_t fYmax
min/max Y coordinates of graph
Definition KVIDGraph.h:44
void SetRuns(const KVNumberList &nl)
Set list of runs for which grid is valid.
virtual Int_t CheckVersion(Int_t version)
virtual void SetEditable(Bool_t editable=kTRUE)
void SetYScaleFactor(Double_t=0)
virtual void Initialize()=0
Axis_t fXmax
min/max X coordinates of graph
Definition KVIDGraph.h:43
Bool_t fOnlyZId
set to kTRUE when only to be used to give Z identification of nuclei, no mass info
Definition KVIDGraph.h:39
virtual void Clear(Option_t *opt="")
Int_t fMassFormula
OPTION={GetMethod="GetMassFormula";SetMethod="SetMassFormula";Items=(0="Beta-stability",...
Definition KVIDGraph.h:53
void ResetDraw()
void SetPattern(TString pattern)
Definition KVIDGraph.h:235
Axis_t fYmin
Definition KVIDGraph.h:44
void RemoveCut(KVIDentifier *)
Remove and destroy cut.
KVList fInfoZones
contours/lines used to add info to particles (ex: punch-through)
Definition KVIDGraph.h:42
virtual void SetOnlyZId(Bool_t yes=kTRUE)
void Modified()
Definition KVIDGraph.h:255
KVList * GetGrids()
void AddGrid(KVIDGraph *)
Add a grid to the collection. It will be deleted by the manager.
Base class for graphical cuts used in particle identification.
Full result of one attempted particle identification.
void AddFlag(std::string grid_name, TString flag)
void Clear(Option_t *opt="")
Reset to initial values.
Bool_t Aident
= kTRUE if A of particle established
Double_t PID
= "real" Z if Zident==kTRUE and Aident==kFALSE, "real" A if Zident==Aident==kTRUE
Int_t A
A of particle found (if Aident==kTRUE)
Int_t Z
Z of particle found (if Zident==kTRUE)
Bool_t Zident
=kTRUE if Z of particle established
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
virtual void Print(Option_t *opt="") const
KVNamedParameter * GetParameter(Int_t idx) const
return the parameter object with index idx
Int_t GetIntValue(const Char_t *name) const
Double_t GetDoubleValue(const Char_t *name) const
void SetValue(const Char_t *name, value_type value)
void RemoveParameter(const Char_t *name)
virtual void Clear(Option_t *opt="")
Int_t GetNpar() const
return the number of stored parameters
const Char_t * GetStringValue(const Char_t *name) const
Bool_t HasParameter(const Char_t *name) const
A generic named parameter storing values of different types.
const Char_t * GetString() const
Strings used to represent a set of ranges of values.
void SetMinMax(Int_t min, Int_t max, Int_t pas=1)
Set list with all values from 'min' to 'max'.
const Char_t * AsString(Int_t maxchars=0) const
virtual void Copy(TObject &obj) const
KVSeqCollection * GetSubListWithMethod(const Char_t *retvalue, const Char_t *method) const
virtual void Execute(const char *method, const char *params, Int_t *error=0)
virtual void SetCleanup(Bool_t enable=kTRUE)
T * get_object(const TString &name) const
virtual TObject * Remove(TObject *obj)
Remove object from list.
virtual void Delete(Option_t *option="")
virtual void RecursiveRemove(TObject *obj)
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition KVString.h:73
void Begin(TString delim) const
Definition KVString.cpp:565
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition KVString.cpp:695
virtual void Streamer(TBuffer &)
void Copy(TAttFill &attfill) const
static TClass * Class()
void Copy(TAttLine &attline) const
void Copy(TAttMarker &attmarker) const
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
Bool_t IsReading() const
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Bool_t InheritsFrom(const char *cl) const override
virtual Int_t GetEntries() const
const char * GetVarX() const
TClass * IsA() const override
const char * GetVarY() const
Bool_t GetEditable() const
virtual void SetEditable(Bool_t editable=kTRUE)
virtual Int_t Fill(const char *name, Double_t w)
void ls(Option_t *option="") const override
TObject * At(Int_t idx) const override
void Copy(TObject &named) const override
const char * GetName() const override
const char * GetTitle() const override
TString fName
Int_t GetEntries() const override
TObject * At(Int_t idx) const override
virtual const char * GetName() const
virtual TObject * Clone(const char *newname="") const
virtual const char * ClassName() const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
Longptr_t ExecPlugin(int nargs)
Bool_t Disconnect(const char *signal=nullptr, void *receiver=nullptr, const char *slot=nullptr)
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
virtual Double_t Uniform(Double_t x1, Double_t x2)
const char * Data() const
TObjArray * Tokenize(const TString &delim) const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual Bool_t ProcessEvents()
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
virtual TCanvas * GetCanvas() const=0
TLine * line
Type
Double_t y[n]
Double_t x[n]
const Int_t n
TGraphErrors * gr
TH1 * h
Double_t Min(Double_t a, Double_t b)
Double_t Abs(Double_t d)
void fill(const char *name, double x, double y=0., double w=0.)
KVNameValueList & histo_names
kvidgraph_idresult_filler(KVHashList &h, KVNameValueList &n)
ClassImp(TPyArg)