StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ClearRoot.C
1 // This macro being called at the end of ROOT session cleares all the
2 // ROOT lists. In result, no ROOT objects will be deleted after ".q"
3 // It is made especially to avoid deleting of TGeoManager which, due to bad
4 // design, often leads to crash, which in its turn, is not always acceptable (VP)
5 
6 void ClearRoot()
7 {
8 TCollection *C[50]={0};
9 int i = 0;
10 C[i++] = gROOT->GetListOfBrowsables() ;
11 C[i++] = gROOT->GetListOfBrowsers() ;
12 C[i++] = gROOT->GetListOfCanvases() ;
13 //C[i++] = gROOT->GetListOfClasses() ;
14 //C[i++] = gROOT->GetListOfClassGenerators() ;
15 C[i++] = gROOT->GetListOfCleanups() ;
16 C[i++] = gROOT->GetListOfColors() ;
17 C[i++] = gROOT->GetListOfDataSets() ;
18 C[i++] = gROOT->GetListOfFiles() ;
19 C[i++] = gROOT->GetListOfFunctions() ;
20 C[i++] = gROOT->GetListOfGeometries() ;
21 // C[i++] = gROOT->GetListOfGlobalFunctions();
22 C[i++] = gROOT->GetListOfGlobals();
23 C[i++] = gROOT->GetListOfKeys() ;
24 C[i++] = gROOT->GetListOfMappedFiles() ;
25 C[i++] = gROOT->GetListOfMessageHandlers() ;
26 C[i++] = gROOT->GetListOfProofs() ;
27 C[i++] = gROOT->GetListOfSecContexts() ;
28 C[i++] = gROOT->GetListOfSockets() ;
29 C[i++] = gROOT->GetListOfSpecials() ;
30 C[i++] = gROOT->GetListOfStreamerInfo() ;
31 C[i++] = gROOT->GetListOfStyles() ;
32 C[i++] = gROOT->GetListOfTasks() ;
33 C[i++] = gROOT->GetListOfTypes();
34 if (gGeoManager) {
35 C[i++] = gGeoManager->GetListOfGShapes() ;
36 C[i++] = gGeoManager->GetListOfGVolumes() ;
37 C[i++] = gGeoManager->GetListOfMaterials() ;
38 C[i++] = gGeoManager->GetListOfMatrices() ;
39 C[i++] = gGeoManager->GetListOfMedia() ;
40 C[i++] = gGeoManager->GetListOfNavigators() ;
41 C[i++] = gGeoManager->GetListOfNodes();
42 C[i++] = gGeoManager->GetListOfOverlaps();
43 C[i++] = gGeoManager->GetListOfPhysicalNodes();
44 C[i++] = gGeoManager->GetListOfShapes() ;
45 C[i++] = gGeoManager->GetListOfTracks() ;
46 C[i++] = gGeoManager->GetListOfUVolumes() ;
47 C[i++] = gGeoManager->GetListOfVolumes() ;
48 }
49  for (int j=0;j<i;j++) { if (C[j]) C[j]->Clear();}
50  for (int j=0;j<i;j++) { if (C[j]) C[j]->ls();}
51 }