c88d2bbc3a965d4780eba75113a72a76.ppt
- Количество слайдов: 19
CINTEX: Filling CINT structures from Reflex Applications Area Meeting 19 January 2005 P. Mato / CERN 19/01/05 LCG Application Area Meeting
Contents u Update on Reflex u Current Reflex/ROOT strategy u What is Cintex u Current status u Next steps u Summary 19/01/05 LCG Application Area Meeting 2
Reflex: Main Goals u Reflection is the ability of a language to introspect it’s own structure at runtime and interact with it in a generic way u Enhance C++ with reflection capabilities – Non intrusive, automated u Close to the C++ ISO 14882 standard u Lightweight and standalone system – Minimal dependencies u Small memory footprint u Multi platform – Linux, Windows, Mac OSX, … 19/01/05 LCG Application Area Meeting 3
Reflex Classes User Level Object Type Member Property. List Type. Name Type. Base Scope. Name Prop. List. Impl Scope. Base Template Identification Implementation Member. Base Pointer Enum Data. Member Fundamental Union Func. Member Namespace Typedef Pointer 2 Mem Class Inst. TClass Array Function Inst. TFunction 19/01/05 LCG Application Area Meeting Inst. Template 4
Example: Introspecting types // Get type by its name Type cl = Type: : by. Name(“Particle”); // If class print all data members if ( cl. is. Class() ) { for ( size_t d = 0; d < cl. data. Member. Count(); d++ ) { Member dm = cl. data. Member(d); cout << dm. type(). name(SCOPED) << " " << dm. name() <<"; "; // output comment line if exists if ( dm. property. List(). has. Key("comment") ) { cout <<"//"<< m. property. List(). property. As. String("comment"); } cout << endl; } } 19/01/05 LCG Application Area Meeting 5
Example: Generic Interaction // Get a type by its name Type cl = Type: : by. Name(“Particle”); // Instantiate an instance Object obj = cl. construct(); // Call a method vector
Reflex: Status u Most of the functionality is implemented – Still missing full template support and other bits u Dictionaries are generated with the “lcgdict” command (GCC_XML) --reflex option extended functionality: free functions, typedefs, etc. u (Pre) Released as part of SEAL 1. 6. 0 u Performance and dictionary sizes very reasonable 19/01/05 LCG Application Area Meeting 7
Dictionary Library Sizes u SEAL 19/01/05 ROOT Dictionary: 405 classes LCG Application Area Meeting 8
Reflex/ROOT – (December Plans) 1. Fill CINT data structures (data and methods) from Reflex on demand. 1. This is needed to allow interactive work using CINT (ROOT) for classes for which only the Reflex dictionary exists. The code for this already exists in POOL for the LCG/CINT dictionary gateway. 2. Estimated to 3 -4 months 2. Re-implement the ROOT metaclasses (TClass, TMethod, etc. ) on top of Reflex 1. 3. Estimated to 2 months Adaptation of the CINT interpreter to run on top of Reflex directly is foreseen in principle but detailed planning will only be done after tasks 1 and 2 are completed. 19/01/05 LCG Application Area Meeting 9
Reflex and ROOT Py. Reflex . h lcgdict Python data Reflex API Reflex data CINTex . h 19/01/05 Python Interpreter ROOT Metaclasses CINT data rootcint LCG Application Area Meeting ROOT I/O CINT Interpreter 10
Cintex: Driving Use Case u Be able to write “simple” analysis macros (CINT) accessing an existing file produced by POOL without the need of loading POOL+SEAL+Exp. Framework+… – Cintex and Event classes (Reflex) dictionaries need to be loaded – Event class methods would be available u Some Caveats – Strongly dependent on the “Event Model” design quality – POOL specialized streamers not available – POOL references not available (more work needed to understand) 19/01/05 LCG Application Area Meeting 11
Cintex: Current Functionality u u At loading time, Cintex registers itself to Reflex to get callback when a new classes are defined in Reflex For each class – Calls the appropriate CINT functions to create the class with their data and function members, and inheritance tree. – Creates the necessary namespaces and “forward declares” other types on-the-fly u u u Provides a set of “generic” adapters for the “stub” functions between CINT and Reflex Current functionality quite complete Most of the knowledge (and code) taken from the POOL Root. Storage. Svc (Markus Frank) 19/01/05 LCG Application Area Meeting 12
Load("Seal. CLHEPDict"); // Load any" src="https://present5.com/presentation/c88d2bbc3a965d4780eba75113a72a76/image-13.jpg" alt="Example: Interactive session g. System->Load("lcg_Cintex"); // Load Cintex g. System->Load("Seal. CLHEPDict"); // Load any" /> Example: Interactive session g. System->Load("lcg_Cintex"); // Load Cintex g. System->Load("Seal. CLHEPDict"); // Load any Reflex dictionary using namespace CLHEP; Hep 3 Vector v 1(10. , 20. , 30. ); Hep 3 Vector v 2(v 1); cout << v 2. r() << endl; Ranlux. Engine r; Rand. Flat f(r); Rand. Gauss g(r, 0, 1); TH 1 F hf("hf", "flat distribution", 100, 0, 1); TH 1 F hg("hg", "gauss distribution", 100, -5, 5); for (int i = 0; i < 10000; i ++) { hf. Fill(f. fire()); hg. Fill(g. fire()); } 19/01/05 LCG Application Area Meeting 13
Load("Seal. CLHEPDict"); // Load" src="https://present5.com/presentation/c88d2bbc3a965d4780eba75113a72a76/image-14.jpg" alt="Example: Simple I/O example g. System->Load("lcg_Cintex"); // Load Cintex g. System->Load("Seal. CLHEPDict"); // Load" /> Example: Simple I/O example g. System->Load("lcg_Cintex"); // Load Cintex g. System->Load("Seal. CLHEPDict"); // Load any Reflex dictionary CLHEP: : Hep 3 Vector v 0; CLHEP: : Hep 3 Vector v 1(22, 1, 1); TFile fo("data. root", "RECREATE"); fo. Write. Object. Any(&v 0, "CLHEP: : Hep 3 Vector", "my_v 0"); fo. Write. Object. Any(&v 1, "CLHEP: : Hep 3 Vector", "my_v 1"); fo. Close(); TFile fi("data. root"); CLHEP: : Hep 3 Vector* vp; vp = (CLHEP: : Hep 3 Vector*)fi. Find. Object. Any("my_v 1"); cout << " x = " << vp->x() << " y = " << vp->y() << " z = " << vp->z() << endl; fi. Close(); 19/01/05 LCG Application Area Meeting 14
Cintex: Current Limitations u CINT optimization switched off – In optimize mode the single stub function adapter can not obtain the “context” – g. ROOT->Process. Line(". O 0"); u Virtual inheritance – Not yet there. No major problems foreseen. u I/O problems – Writing seems to work always (spurious messages) – Sometimes data misalignment problems on reading – The main use case in danger! 19/01/05 LCG Application Area Meeting 15
Load("liblcg_Cintex"); g. System->Load("lib. Event." src="https://present5.com/presentation/c88d2bbc3a965d4780eba75113a72a76/image-16.jpg" alt="Example: Accessing POOL files g. ROOT->Process. Line(". O 0"); g. System->Load("liblcg_Cintex"); g. System->Load("lib. Event." /> Example: Accessing POOL files g. ROOT->Process. Line(". O 0"); g. System->Load("liblcg_Cintex"); g. System->Load("lib. Event. Model. Dict"); using namespace pool_tutorial; TFile f("pool_tutorial_1. root"); Hit* h = 0; TTree* tree = (TTree*)f. Get("hits"); tree->Set. Branch. Address("Hit", &h); Unfortunately does not work today int n = tree->Get. Entries(); for ( int i = 0; i < n; i++ ) { tree->Get. Entry(i); cout << "Hit " << i << ": " << h->x() << " " << h->y() << " " << h->z() << " " << h->value() << endl; } f. Close(); 19/01/05 LCG Application Area Meeting 16
Next steps u (Pre) Released as part of SEAL 1. 6. 0 – Requires new Reflex dictionaries + ROOT 4 u Complete the basic functionality – Virtual inheritance, I/O read misalignments, templates, variables, etc. – Some optimization still possible u Try with a “real” use case – E. g. An experiment POOL file – Looking for a contact person from ATLAS and CMS u Defined the roles of Cintex (CINT part) and the Root. Storage. Svc in POOL (I/O part) 19/01/05 LCG Application Area Meeting 17
Cintex and Root. Storage. Svc POOL Root. Storage. Svc Cintex u u ROOT I/O CINT data ROOT Metaclasses CINT Interpreter Root. Storage. Svc gets simple Separation of concerns – POOL should use Cintex as the Reflex/CINT gateway – POOL should interact with ROOT I/O for I/O related issues » Special streamers, object references, optimization, etc. 19/01/05 LCG Application Area Meeting 18
Summary u Reflex is getting better and functionally completed – Reduced the number of “user level” classes – Ready to be integrated in Py. Reflex, POOL, etc. u u Cintex provides the possibility to use CINT (ROOT) for any class with a Reflex dictionary The first task in the Reflex/ROOT convergence is “almost” completed – Requires validation from experiments (ATLAS and CMS) – Requesting contact person to try Cintex in their environment u Next steps – Adaptation of POOL (Root. Storage. Mgr) to Reflex and Cintex – Start implementing second task of Reflex/ROOT convergence plan 19/01/05 LCG Application Area Meeting 19