Presentation is loading. Please wait.

Presentation is loading. Please wait.

V0.02 The ROOT Collection Classes. V0.02 2 Collection Classes Group of related objects TObjects or descendants from TObject Abstract base class TCollection.

Similar presentations


Presentation on theme: "V0.02 The ROOT Collection Classes. V0.02 2 Collection Classes Group of related objects TObjects or descendants from TObject Abstract base class TCollection."— Presentation transcript:

1 V0.02 The ROOT Collection Classes

2 V0.02 2 Collection Classes Group of related objects TObjects or descendants from TObject Abstract base class TCollection http://root.cern.ch/root/html/TCollection.html

3 V0.02 3 Collection Classes (cont.) Ordered Collections (Sequences) Sorted Collections Unordered Collections

4 V0.02 4 TClonesArray Array of Identical Objects. Memory for the Objects stored is allocated only once. Use TClonesArray to store heterogeneous object arrays in a TTree.

5 V0.02 5 Iterators Declare an iterator for a collection “()”operator

6 V0.02 6 Collection Example Scenario: use a collection of nine histograms and draw them on nine sub pads on a canvas myTree.DrawHistograms();

7 V0.02 7 Collection Example (cont.) 1. Download needed files. 2. Decide what type of collection we need. 3. Add the collection to the class

8 V0.02 8 Collection Example (cont.) 4. Change the Loop() to fill the histograms 5. Fill the Array 6. Declare the method to draw the histograms: voidDrawHistograms(void);

9 V0.02 9 Collection Example (cont.) 7. Implement DrawHistograms(). Create a canvas and divide it into 9 sub-pads. 8. Use the iterator to draw each histogram in a sub-pad.

10 V0.02 10 Collection Example (cont.) 9. Load and run

11 V0.02 11 Collection Example:TMap Scenario: Add a method that takes up to nine names of histograms as parameters and draws them in order. myTree.DrawHistograms ("Px", "Py", "Xfirst", "Xlast")

12 V0.02 12 Collection Example:TMap (cont.) 1. Decide what type of collection we need. 2. Add the collection to the class

13 V0.02 13 Collection Example:TMap (cont.) 3. Build the map from the array. fHistoMap.Add( new TObjString( theHisto->GetName()),theHisto);

14 V0.02 14 Collection Example:TMap (cont.) 4. Declare the method to draw the histograms: voidDrawHistograms(char * name1, char * name2 = 0...); 5. Create a TObjArray of names.

15 V0.02 15 Collection Example:TMap (cont.) 6. Find the histograms in the Map and draw them.

16 V0.02 16 Collection Example:TMap (cont.) 7. Load and run

17 V0.02 17 Exercise 4 Add a method to the ABC class with the following signature: void MakeHistos(char * n1, char * n2, char * n3, char * n4) MakeHistos will: –draw the histograms specified in the list of names –save the histograms to a file called ABC_histos.root


Download ppt "V0.02 The ROOT Collection Classes. V0.02 2 Collection Classes Group of related objects TObjects or descendants from TObject Abstract base class TCollection."

Similar presentations


Ads by Google