]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliTrackMapper.cxx
Introducing Header instead of Log
[u/mrichter/AliRoot.git] / STEER / AliTrackMapper.cxx
index 17ee6812269ffd2e5d9806efdbf5ce67bf88175b..fe360f3ca433bcc239a7a565ff3d02b0e7514332 100644 (file)
@@ -13,9 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-*/
+/* $Header$ */
 
 ////////////////////////////////////////////////////////////////////////
 //
@@ -27,7 +25,7 @@ $Log$
 //
 ////////////////////////////////////////////////////////////////////////
 
-#include <iostream.h>
+#include <Riostream.h>
 
 #include "TTree.h"
 #include "TROOT.h"
@@ -43,34 +41,44 @@ $Log$
 
 ClassImp(AliTrackMapper)
 
-////////////////////////////////////////////////////////////////////////
+//_______________________________________________________________________
+AliTrackMapper::AliTrackMapper(): 
+  fDEBUG(0)
+{
+  //
+  // Default ctor
+  //
+}
+
+
+//_______________________________________________________________________
 void AliTrackMapper::CreateMap(Int_t nEvents, Int_t firstEventNr,
-                           const char* fnMap, const char* fnHits)
+                               const char* fnMap, const char* fnHits)
 {
-//
-// method to create a track map for a given number of events starting 
-// from event firstEventNr. This method just opens and closes files and
-// loops over events, the creation of map is delegated to 
-// CreateMap(Int_t eventNr, TFile* fileMap) method
-//
+  //
+  // method to create a track map for a given number of events starting 
+  // from event firstEventNr. This method just opens and closes files and
+  // loops over events, the creation of map is delegated to 
+  // CreateMap(Int_t eventNr, TFile* fileMap) method
+  //
   TStopwatch timer;
   timer.Start();
   
   TFile *fileMap=TFile::Open(fnMap,"new");
   if (!fileMap->IsOpen()) {cerr<<"Can't open output file "<<fnMap<<"!\n"; return;}
-
+  
   TFile *fileHits=TFile::Open(fnHits);
   if (!fileHits->IsOpen()) {cerr<<"Can't open input file "<<fnHits<<"!\n"; return;}
-  if (!(gAlice=(AliRun*)fileHits->Get("gAlice"))) {
+  if (!(gAlice=dynamic_cast<AliRun*>(fileHits->Get("gAlice")))) {
     cerr<<"gAlice have not been found on galice.root !\n";
     return;
   }
-
+  
   for (Int_t eventNr = firstEventNr; eventNr < firstEventNr+nEvents;
        eventNr++) {
     CreateMap(eventNr,fileMap);
   } // end loop over events
-
+  
   delete gAlice;
   gAlice = 0;
   fileHits->Close();
@@ -81,12 +89,13 @@ void AliTrackMapper::CreateMap(Int_t nEvents, Int_t firstEventNr,
   if (fDEBUG > 0) timer.Print();
 }
 
-////////////////////////////////////////////////////////////////////////
-Int_t  AliTrackMapper::CreateMap(Int_t eventNr, TFile* fileMap) {
-//
-// create an AliTrackMap for a given event
-// correct gAlice must be already present in memory
-//
+//_______________________________________________________________________
+Int_t  AliTrackMapper::CreateMap(Int_t eventNr, TFile* fileMap) 
+{
+  //
+  // create an AliTrackMap for a given event
+  // correct gAlice must be already present in memory
+  //
   Int_t nGenPrimPlusSecParticles = gAlice->GetEvent(eventNr);
   if (fDEBUG > 1) cout<<"nGenPrimPlusSecParticles = "<<nGenPrimPlusSecParticles<<endl;
   if (nGenPrimPlusSecParticles < 1) {
@@ -111,28 +120,25 @@ Int_t  AliTrackMapper::CreateMap(Int_t eventNr, TFile* fileMap) {
   Int_t treeHEntries = static_cast<Int_t>(treeH->GetEntries());
   if (fDEBUG > 1) cout<<"treeHEntries "<<treeHEntries<<endl;
 
-
   TObjArray *modules = gAlice->Detectors();
   if (!modules) {
     cerr<<"TObjArray with modules not found."<<endl;
     return -1;
   }
   Int_t nModules = static_cast<Int_t>(modules->GetEntries());
-  for (Int_t iModule = 0; iModule < nModules; iModule++) {
-//  for (Int_t iModule = nModules-1; iModule >= 0; iModule--) {
-    AliDetector * detector = dynamic_cast<AliDetector*>(modules->At(iModule));
-    if (!detector) continue;
-// process only detectors with shunt = 0
-    if (detector->GetIshunt()) continue; 
-    if (fDEBUG > 0) cerr<<"Processing detector "<<detector->GetName()<<endl;
-
-    AliHit* hit;
-    for (Int_t treeHIndex = 0; treeHIndex < treeHEntries; treeHIndex++) {
-      detector->ResetHits();
-      treeH->GetEvent(treeHIndex);
-      hit=(AliHit*)detector->FirstHit(-1);
+  AliHit* hit;
+  for (Int_t treeHIndex = 0; treeHIndex < treeHEntries; treeHIndex++) {
+    gAlice->ResetHits();
+    treeH->GetEvent(treeHIndex);
+    for (Int_t iModule = 0; iModule < nModules; iModule++) {
+      AliDetector * detector = dynamic_cast<AliDetector*>(modules->At(iModule));
+      if (!detector) continue;
+      // process only detectors with shunt = 0
+      if (detector->GetIshunt()) continue; 
+
+      hit=dynamic_cast<AliHit*>(detector->FirstHit(-1));
       Int_t lastLabel=-1, label;
-      for( ; hit; hit=(AliHit*)detector->NextHit() ) {
+      for( ; hit; hit=dynamic_cast<AliHit*>(detector->NextHit()) ) {
        label=hit->Track();     
        if (lastLabel != label) {
          if (label < 0 || label >= nAllParticles) {
@@ -154,7 +160,7 @@ Int_t  AliTrackMapper::CreateMap(Int_t eventNr, TFile* fileMap) {
     }
   }
 
-  if (fDEBUG > 0) {
+  if (fDEBUG > 2) {
     for (Int_t i = 0; i < nAllParticles; i++) {
       cout<<eventNr<<"\t"<<i<<"\t"<<trackMap[i]<<endl;
     }
@@ -169,37 +175,37 @@ Int_t  AliTrackMapper::CreateMap(Int_t eventNr, TFile* fileMap) {
   return 0;
 }
   
-////////////////////////////////////////////////////////////////////////
+//_______________________________________________________________________
 AliTrackMap* AliTrackMapper::LoadTrackMap(Int_t eventNr, const char* fnMap, TFile* &fileMap) {
-//
-// read an AliTrackMap object for the given event eventNr from 
-// the file fileMap
-//
+  //
+  // read an AliTrackMap object for the given event eventNr from 
+  // the file fileMap
+  //
   fileMap=TFile::Open(fnMap);
   if (!fileMap->IsOpen()) {cerr<<"Can't open file "<<fnMap<<" with map!\n"; return 0;}
   char mapName[20];
   sprintf(mapName,"AliTrackMap_%5.5d",eventNr);
-  AliTrackMap* trackMapObject = (AliTrackMap*)fileMap->Get(mapName);
+  AliTrackMap* trackMapObject = dynamic_cast<AliTrackMap*>(fileMap->Get(mapName));
   if (!trackMapObject) {
     cerr<<"Error: map named "<<mapName<<" not found."<<endl;
     return 0;
   }
   return trackMapObject;
 }
-////////////////////////////////////////////////////////////////////////
+
+//_______________________________________________________________________
 void AliTrackMapper::CheckTrackMap(Int_t eventNr, const char* fnMap) {
-//
-// 
-//
+  //
+  // 
+  //
   TFile *fileMap;
   AliTrackMap* trackMapObject = LoadTrackMap(eventNr, fnMap, fileMap);
   if (!trackMapObject) return;
-
+  
   trackMapObject->PrintValues();
-
+  
   delete trackMapObject;
   fileMap->Close();
   delete fileMap;
 }
-////////////////////////////////////////////////////////////////////////