]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/EveDet/AliEveTPCLoader.cxx
Merge changes from branches/dev/EVE. This branch was following development in ROOT...
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveTPCLoader.cxx
index 7c4a598097864279ecdcbc231dbcd0c4dd37f3ad..28f80d351754d55ae7b824c655be3042c65858b8 100644 (file)
 
 #include <TSystem.h>
 
+//==============================================================================
+//==============================================================================
+// AliEveTPCLoader
+//==============================================================================
 
 //______________________________________________________________________________
-// AliEveTPCLoader
 //
+// Front-end for stand-alone inspection of TPC raw-data.
+// GUI is implemented in AliEveTPCLoaderEditor class.
 
 ClassImp(AliEveTPCLoader)
 
@@ -43,11 +48,15 @@ AliEveTPCLoader::AliEveTPCLoader(const Text_t* n, const Text_t* t) :
   fSetInitSectorParams(kFALSE),
   fInitMinTime(0), fInitMaxTime(460), fInitThreshold(5), fInitMaxVal(128)
 {
+  // Constructor.
+
   fData = new AliEveTPCData;
 }
 
 AliEveTPCLoader::~AliEveTPCLoader()
 {
+  // Destructor.
+
   delete fReader;
   delete fData;
 }
@@ -56,15 +65,22 @@ AliEveTPCLoader::~AliEveTPCLoader()
 
 void AliEveTPCLoader::RemoveElementLocal(TEveElement* el)
 {
-  for(Int_t i=0; i<36; ++i) {
-    if(fSec2Ds[i] == el) fSec2Ds[i] = 0;
-    if(fSec3Ds[i] == el) fSec3Ds[i] = 0;
+  // Local removal an element, virtual from TEveElement.
+  // Need to search for it in visual sector representations and remove
+  // it there as well.
+
+  for (Int_t i=0; i<36; ++i) {
+    if (fSec2Ds[i] == el) fSec2Ds[i] = 0;
+    if (fSec3Ds[i] == el) fSec3Ds[i] = 0;
   }
 }
 
 void AliEveTPCLoader::RemoveElementsLocal()
 {
-  for(Int_t i=0; i<36; ++i) {
+  // Local removal of all elements, virtual from TEveElement.
+  // Must remove all visual sector representations.
+
+  for (Int_t i=0; i<36; ++i) {
     fSec2Ds[i] = 0;
     fSec3Ds[i] = 0;
   }
@@ -74,6 +90,8 @@ void AliEveTPCLoader::RemoveElementsLocal()
 
 void AliEveTPCLoader::SetData(AliEveTPCData* d)
 {
+  // Set external TPC-data container. The old one is deleted.
+
   delete fData;
   fData = d;
 }
@@ -82,10 +100,15 @@ void AliEveTPCLoader::SetData(AliEveTPCData* d)
 
 void AliEveTPCLoader::OpenFile()
 {
-  static const TEveException eH("AliEveTPCLoader::OpenFile ");
+  // Open the raw-data file, as set in fFile data-member.
+  // Raw-reader is also created and attached to the file.
+  // First event is loaded and all sectors for which the data-exists
+  // are created.
 
-  if(gSystem->AccessPathName(fFile, kReadPermission))
-      throw(eH + "can not read '" + fFile + "'.");
+  static const TEveException kEH("AliEveTPCLoader::OpenFile ");
+
+  if (gSystem->AccessPathName(fFile, kReadPermission))
+      throw(kEH + "can not read '" + fFile + "'.");
 
   fData->DeleteAllSectors();
 
@@ -94,7 +117,7 @@ void AliEveTPCLoader::OpenFile()
   fEvent  = -1;
 
   fReader = new AliRawReaderRoot(fFile);
-  if(fTPCEquipementMap != "")
+  if (fTPCEquipementMap != "")
     fReader->LoadEquipmentIdsMap
       (gSystem->ExpandPathName(fTPCEquipementMap.Data()));
 
@@ -105,10 +128,12 @@ void AliEveTPCLoader::OpenFile()
 
 void AliEveTPCLoader::LoadEvent()
 {
-  static const TEveException eH("AliEveTPCLoader::LoadEvent ");
+  // Load an event.
+
+  static const TEveException kEH("AliEveTPCLoader::LoadEvent ");
 
-  if(fReader == 0)
-    throw(eH + "data file not opened.");
+  if (fReader == 0)
+    throw(kEH + "data file not opened.");
 
   printf("Now loading event %d\n", fEvent);
   fReader->Reset();
@@ -122,38 +147,44 @@ void AliEveTPCLoader::LoadEvent()
 
 void AliEveTPCLoader::NextEvent(Bool_t rewindOnEnd)
 {
-  static const TEveException eH("AliEveTPCLoader::NextEvent ");
+  // Go o the next event.
+  // When the last event is reached and rewindOnEnd is true, the file
+  // is rewound back to the first event. Otherwise an exception is thrown.
 
-  if(fReader == 0)
-    throw(eH + "data file not opened.");
+  static const TEveException kEH("AliEveTPCLoader::NextEvent ");
 
-  if(fReader->NextEvent() == kTRUE) {
+  if (fReader == 0)
+    throw(kEH + "data file not opened.");
+
+  if (fReader->NextEvent() == kTRUE) {
     ++fEvent;
   } else {
-    if(fEvent == -1)
-      throw(eH + "no events available.");
-    if(rewindOnEnd) {
+    if (fEvent == -1)
+      throw(kEH + "no events available.");
+    if (rewindOnEnd) {
       printf("Reached end of stream (event=%d), rewinding to first event.\n", fEvent);
       fReader->RewindEvents();
       fReader->NextEvent();
       fEvent = 0;
     } else {
-      throw(eH + "last event reached.");
+      throw(kEH + "last event reached.");
     }
   }
 }
 
 void AliEveTPCLoader::GotoEvent(Int_t event)
 {
-  static const TEveException eH("AliEveTPCLoader::GotoEvent ");
+  // Go to specified event.
+
+  static const TEveException kEH("AliEveTPCLoader::GotoEvent ");
 
-  if(fReader == 0)
-    throw(eH + "data file not opened.");
+  if (fReader == 0)
+    throw(kEH + "data file not opened.");
 
-  if(event == fEvent)
+  if (event == fEvent)
     return;
   Bool_t checkEnd;
-  if(event < fEvent) {
+  if (event < fEvent) {
     fReader->RewindEvents();
     fEvent = -1;
     checkEnd = kFALSE;
@@ -162,13 +193,17 @@ void AliEveTPCLoader::GotoEvent(Int_t event)
   }
   do {
     NextEvent();
-  } while(fEvent != event && !(checkEnd == kTRUE && fEvent == 0));
+  } while (fEvent != event && !(checkEnd == kTRUE && fEvent == 0));
   LoadEvent();
   UpdateSectors();
 }
 
 void* AliEveTPCLoader::LoopEvent(AliEveTPCLoader* loader)
 {
+  // Loop to next event on given loader. Static member to be used for
+  // external control during animations.
+  // Calls NextEvent(), LoadEvent() and UpdateSectors().
+
   loader->NextEvent();
   loader->LoadEvent();
   loader->UpdateSectors();
@@ -181,13 +216,17 @@ void* AliEveTPCLoader::LoopEvent(AliEveTPCLoader* loader)
 
 void AliEveTPCLoader::UpdateSectors(Bool_t dropNonPresent)
 {
+  // Update visual representations of sectors.
+  // If dropNonPresent is true, the sectors for which there is no data in
+  // the current event are removed.
+
   gEve->DisableRedraw();
-  for(Int_t i=0; i<=35; ++i)
+  for (Int_t i=0; i<=35; ++i)
   {
     AliEveTPCSectorData* sd = fData->GetSectorData(i);
 
     // 2D sectors
-    if(fSec2Ds[i] != 0)
+    if (fSec2Ds[i] != 0)
     {
       if (dropNonPresent && sd == 0) {
        gEve->RemoveElement(fSec2Ds[i], this);
@@ -199,16 +238,16 @@ void AliEveTPCLoader::UpdateSectors(Bool_t dropNonPresent)
     }
     else
     {
-      if(sd != 0) {
+      if (sd != 0) {
        AliEveTPCSector2D* s = new AliEveTPCSector2D(Form("Sector2D %d", i));
        fSec2Ds[i] = s;
        s->SetSectorID(i);
        s->SetDataSource(fData);
 
-       if(fDoubleSR)
+       if (fDoubleSR)
          s->SetMaxTime(1023);
 
-        if(fSetInitSectorParams) {
+        if (fSetInitSectorParams) {
           s->SetMinTime(fInitMinTime);
           s->SetMaxTime(fInitMaxTime);
           s->SetThreshold(fInitThreshold);
@@ -223,7 +262,7 @@ void AliEveTPCLoader::UpdateSectors(Bool_t dropNonPresent)
     }
 
     // 3D sectors
-    if(fSec3Ds[i] != 0)
+    if (fSec3Ds[i] != 0)
     {
       if (dropNonPresent && sd == 0) {
        gEve->RemoveElement(fSec3Ds[i], this);
@@ -240,24 +279,28 @@ void AliEveTPCLoader::UpdateSectors(Bool_t dropNonPresent)
 
 void AliEveTPCLoader::ReloadSectors()
 {
+  // Reload current event and update sectors.
+
   LoadEvent();
   UpdateSectors();
 }
 
 void AliEveTPCLoader::CreateSectors3D()
 {
+  // Create 3D representations of sectors.
+
   gEve->DisableRedraw();
-  for(Int_t i=0; i<=35; ++i) {
+  for (Int_t i=0; i<=35; ++i) {
     AliEveTPCSectorData* sd = fData->GetSectorData(i);
-    if(sd != 0 && fSec3Ds[i] == 0) {
+    if (sd != 0 && fSec3Ds[i] == 0) {
       AliEveTPCSector3D* s = new AliEveTPCSector3D(Form("Sector3D %d", i));
       fSec3Ds[i] = s;
       s->SetSectorID(i);
       s->SetDataSource(fData);
 
-      if(fDoubleSR)
+      if (fDoubleSR)
        s->SetDriftVel(2.273);
-      if(fSec2Ds[i] != 0)
+      if (fSec2Ds[i] != 0)
        s->CopyVizParams(*fSec2Ds[i]);
 
       s->SetAutoTrans(kTRUE);
@@ -271,10 +314,12 @@ void AliEveTPCLoader::CreateSectors3D()
 
 void AliEveTPCLoader::DeleteSectors3D()
 {
+  // Delete 3D representations of sectors.
+
   gEve->DisableRedraw();
-  for(Int_t i=0; i<=35; ++i) {
+  for (Int_t i=0; i<=35; ++i) {
     TEveElement* re = fSec3Ds[i];
-    if(re != 0) {
+    if (re != 0) {
       gEve->RemoveElement(re, this);
       // delete re; // Done automatically.
       fSec3Ds[i] = 0;
@@ -287,6 +332,8 @@ void AliEveTPCLoader::DeleteSectors3D()
 
 void AliEveTPCLoader::SetInitParams(Int_t mint, Int_t maxt, Int_t thr, Int_t maxval)
 {
+  // Set initial viualization parameters for 2D and 3D sector representations.
+
   fSetInitSectorParams = kTRUE;
   fInitMinTime   = mint;
   fInitMaxTime   = maxt;