]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MONITOR/AliMonitorProcess.cxx
corrections from Alberto
[u/mrichter/AliRoot.git] / MONITOR / AliMonitorProcess.cxx
index 1bc5f0c24a38d016bbf5deb4824883e56cce79bc..0eae4742479dd49152b445a1587669668d0443cc 100644 (file)
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
+#include <TFile.h>
+#include <TGrid.h>
+#include <TGridResult.h>
+#include <TMessage.h>
+#include <TROOT.h>
+#include <TServerSocket.h>
+#include <TSocket.h>
 
+#include "AliLog.h"
+#include "AliESD.h"
+#include "AliITSclustererV2.h"
+#include "AliITSgeom.h"
+#include "AliITStrackerV2.h"
+#include "AliLoader.h"
+#include "AliMonitorHLT.h"
+#include "AliMonitorHLTHough.h"
+#include "AliMonitorITS.h"
 #include "AliMonitorProcess.h"
 #include "AliMonitorTPC.h"
-#include "AliMonitorITS.h"
 #include "AliMonitorV0s.h"
-#include "AliMonitorHLT.h"
-#include "AliMonitorHLTHough.h"
 #include "AliRawReaderRoot.h"
-#include "AliLoader.h"
 #include "AliRun.h"
 #include "AliTPC.h"
 #include "AliTPCclustererMI.h"
 #include "AliTPCtrackerMI.h"
-#include "AliITS.h"
-#include "AliITSclustererV2.h"
-#include "AliITStrackerV2.h"
-#include "AliITSLoader.h"
 #include "AliV0vertexer.h"
-#include <TGrid.h>
-#include <TSocket.h>
-#include <TServerSocket.h>
-#include <TMessage.h>
-#include <TGridResult.h>
-#include <TROOT.h>
-#ifdef ALI_HLT
+
+#include <AliHLTStandardIncludes.h>
+#include <AliHLTMemHandler.h>
+#include <AliHLTClusterFitter.h>
+#include <AliHLTFitter.h>
+#include <AliHLTHough.h>
+#include <AliHLTHoughBaseTransformer.h>
+#include <AliHLTStandardIncludes.h>
+#include <AliHLTTrack.h>
+#include <AliHLTTrackArray.h>
+#include <AliHLTTransform.h>
+#include <AliHLTVertex.h>
 #include <AliLevel3.h>
-#include <AliL3Transform.h>
-#include <AliL3Track.h>
-#include <AliL3TrackArray.h>
-#include <AliL3StandardIncludes.h>
-#include <AliL3HoughMaxFinder.h>
-#include <AliL3HoughBaseTransformer.h>
-#include <AliL3Hough.h>
-#include <AliL3ClusterFitter.h>
-#include <AliL3Vertex.h>
-#include <AliL3Fitter.h>
-#include <AliL3DDLDataFileHandler.h>
-#endif
 
-ClassImp(AliMonitorProcess) 
+ClassImp(AliMonitorProcess)
 
 
 const Int_t AliMonitorProcess::fgkPort = 9327;
@@ -78,10 +79,43 @@ AliMonitorProcess::AliMonitorProcess(
                                     const char* alienHost,
 #endif
                                     const char* alienDir,
-                                    const char* fileNameGalice)
+                                    const char* selection,
+                                    const char* fileNameGalice):
+  fSelection(selection),
+  fGrid(NULL),
+  fAlienDir(alienDir),
+  fRunLoader(NULL),
+  fTPCParam(NULL),
+  fITSgeom(NULL),
+  fLogicalFileName(""),
+  fFileName(""),
+  fHLT(NULL),
+  fHLTHough(NULL),
+
+  fRunNumber(0),
+  fSubRunNumber(0),
+  fNEvents(0),
+  fNEventsMin(1),
+  fWriteHistoList(kFALSE),
+
+  fTopFolder(NULL),
+  fMonitors(),
+  fFile(NULL),
+  fTree(NULL),
+
+  fServerSocket(NULL),
+  fSockets(),
+  fDisplaySocket(NULL),
+
+  fStatus(kStopped),
+  fStopping(kFALSE),
+
+  fInterruptHandler(NULL)
 {
 // initialize the monitoring process and the monitor histograms
 
+  fSelection = selection;
+
 #if ROOT_VERSION_CODE <= 199169   // 3.10/01
   fGrid = TGrid::Connect("alien", gSystem->Getenv("USER"));
 #else
@@ -89,58 +123,40 @@ AliMonitorProcess::AliMonitorProcess(
 #endif
   if (!fGrid || fGrid->IsZombie() || !fGrid->IsConnected()) {
     delete fGrid;
-    Fatal("AliMonitorProcess", "could not connect to alien");
+    AliFatal("could not connect to alien");
   }
 #if ROOT_VERSION_CODE <= 199169   // 3.10/01
   fGrid->cd(alienDir);
-#else
-  fAlienDir = alienDir;
 #endif
-  fLogicalFileName = "";
-  fFileName = "";
 
   fRunLoader = AliRunLoader::Open(fileNameGalice);
-  if (!fRunLoader) Fatal("AliMonitorProcess", 
-                        "could not get run loader from file %s", 
-                        fileNameGalice);
+  if (!fRunLoader) AliFatal(Form("could not get run loader from file %s",
+                                fileNameGalice));
 
   fRunLoader->CdGAFile();
   fTPCParam = AliTPC::LoadTPCParam(gFile);
-  if (!fTPCParam) Fatal("AliMonitorProcess", "could not load TPC parameters");
+  if (!fTPCParam) AliFatal("could not load TPC parameters");
 
   fRunLoader->LoadgAlice();
   gAlice = fRunLoader->GetAliRun();
-  if (!gAlice) Fatal("AliMonitorProcess", "no gAlice object found");
-  AliITS* its = (AliITS*) gAlice->GetModule("ITS");
-  if (!its) Fatal("AliMonitorProcess", "no ITS detector found");
-  fITSgeom = its->GetITSgeom();
-  if (!fITSgeom) Fatal("AliMonitorProcess", "could not load ITS geometry");
-
-#ifdef ALI_HLT
-// Init TPC parameters for HLT
-  Bool_t isinit=AliL3Transform::Init(const_cast<char*>(fileNameGalice),kTRUE);
+  if (!gAlice) AliFatal("no gAlice object found");
+  fITSgeom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
+  if (!fITSgeom) AliFatal("could not load ITS geometry");
+
+  // Init TPC parameters for HLT
+  Bool_t isinit=AliHLTTransform::Init(const_cast<char*>(fileNameGalice),kTRUE);
   if(!isinit){
-    cerr << "Could not create transform settings, please check log for error messages!" << endl;
-    return;
+    AliFatal("Could not create transform settings, please check log for error messages!");
   }
-#endif
-
-  fRunNumber = 0;
-  fSubRunNumber = 0;
-  fNEvents = 0;
-  fNEventsMin = 1;
-  fWriteHistoList = kFALSE;
 
   fTopFolder = new TFolder("Monitor", "monitor histograms");
   fTopFolder->SetOwner(kTRUE);
 
-  fMonitors.Add(new AliMonitorTPC(fTPCParam));
-  fMonitors.Add(new AliMonitorITS(fITSgeom));
-  fMonitors.Add(new AliMonitorV0s);
-#ifdef ALI_HLT
-  fMonitors.Add(new AliMonitorHLT(fTPCParam));
-  fMonitors.Add(new AliMonitorHLTHough(fTPCParam));
-#endif
+  if (IsSelected("TPC")) fMonitors.Add(new AliMonitorTPC(fTPCParam));
+  if (IsSelected("ITS")) fMonitors.Add(new AliMonitorITS(fITSgeom));
+  if (IsSelected("V0s")) fMonitors.Add(new AliMonitorV0s);
+  if (IsSelected("HLTConfMap")) fMonitors.Add(new AliMonitorHLT(fTPCParam));
+  if (IsSelected("HLTHough")) fMonitors.Add(new AliMonitorHLTHough(fTPCParam));
 
   for (Int_t iMonitor = 0; iMonitor < fMonitors.GetEntriesFast(); iMonitor++) {
     ((AliMonitor*) fMonitors[iMonitor])->CreateHistos(fTopFolder);
@@ -152,7 +168,7 @@ AliMonitorProcess::AliMonitorProcess(
 
   fFile = TFile::Open("monitor_tree.root", "RECREATE");
   if (!fFile || !fFile->IsOpen()) {
-    Fatal("AliMonitorProcess", "could not open file for tree");
+    AliFatal("could not open file for tree");
   }
   fTree = new TTree("MonitorTree", "tree for monitoring");
   for (Int_t iMonitor = 0; iMonitor < fMonitors.GetEntriesFast(); iMonitor++) {
@@ -162,28 +178,56 @@ AliMonitorProcess::AliMonitorProcess(
 
   fServerSocket = new TServerSocket(fgkPort, kTRUE);
   fServerSocket->SetOption(kNoBlock, 1);
-  fDisplaySocket = NULL;
   CheckForConnections();
-#ifdef ALI_HLT
-  fHLT = NULL;
-#endif
 
-  SetStatus(kStopped);
-  fStopping = kFALSE;
+  fInterruptHandler = new AliMonitorInterruptHandler(this);
+  gSystem->AddSignalHandler(fInterruptHandler);
 }
 
 //_____________________________________________________________________________
 AliMonitorProcess::AliMonitorProcess(const AliMonitorProcess& process) :
-  TObject(process)
+  TObject(process),
+
+  fSelection(""),
+  fGrid(NULL),
+  fAlienDir(""),
+  fRunLoader(NULL),
+  fTPCParam(NULL),
+  fITSgeom(NULL),
+  fLogicalFileName(""),
+  fFileName(""),
+  fHLT(NULL),
+  fHLTHough(NULL),
+
+  fRunNumber(0),
+  fSubRunNumber(0),
+  fNEvents(0),
+  fNEventsMin(1),
+  fWriteHistoList(kFALSE),
+
+  fTopFolder(NULL),
+  fMonitors(),
+  fFile(NULL),
+  fTree(NULL),
+
+  fServerSocket(NULL),
+  fSockets(),
+  fDisplaySocket(NULL),
+
+  fStatus(kStopped),
+  fStopping(kFALSE),
+
+  fInterruptHandler(NULL)
+
 {
-  Fatal("AliMonitorProcess", "copy constructor not implemented");
+  AliFatal("copy constructor not implemented");
 }
 
 //_____________________________________________________________________________
-AliMonitorProcess& AliMonitorProcess::operator = (const AliMonitorProcess& 
+AliMonitorProcess& AliMonitorProcess::operator = (const AliMonitorProcess&
                                                  /*process*/)
 {
-  Fatal("operator =", "assignment operator not implemented");
+  AliFatal("assignment operator not implemented");
   return *this;
 }
 
@@ -209,10 +253,11 @@ AliMonitorProcess::~AliMonitorProcess()
   delete fFile;
   gSystem->Unlink("monitor_tree.root");
 
-#ifdef ALI_HLT
   delete fHLT;
   delete fHLTHough;
-#endif
+
+  gSystem->RemoveSignalHandler(fInterruptHandler);
+  delete fInterruptHandler;
 }
 
 
@@ -236,7 +281,7 @@ void AliMonitorProcess::SetStatus(EStatus status)
 //_____________________________________________________________________________
 void AliMonitorProcess::Run()
 {
-// run the monitor process: 
+// run the monitor process:
 //  check for a raw data file, process the raw data file and delete it
 
   fStopping = kFALSE;
@@ -277,8 +322,8 @@ void AliMonitorProcess::ProcessFile(const char* fileName)
 // create a file with monitor histograms for a single file
 
   if (GetStatus() != kStopped) {
-    Error("ProcessFile", "ProcessFile can not be called"
-         " while the monitor process is running");
+    AliError("ProcessFile can not be called"
+            " while the monitor process is running");
     return;
   }
 
@@ -297,13 +342,19 @@ Bool_t AliMonitorProcess::CheckForNewFile()
 {
 // check whether a new file was registered in alien
 
+#if ROOT_VERSION_CODE < ROOT_VERSION(5,0,0)
 #if ROOT_VERSION_CODE <= 199169   // 3.10/01
   TGridResult* result = fGrid->Ls();
 #else
-  Grid_ResultHandle_t handle = fGrid->OpenDir(fAlienDir);
+  TDatime datime;
+  char dirName[256];
+  sprintf(dirName, "%s/adc-%d", fAlienDir.Data(), datime.GetDate());
+  char findName[256];
+  sprintf(findName, "*.root");
+  Grid_ResultHandle_t handle = fGrid->Find(dirName, findName);
   if (!handle) {
-    Error("CheckForNewFile", "could not open alien directory %s", 
-         fAlienDir.Data());
+    AliError(Form("could not open alien directory %s",
+                 dirName));
     return kFALSE;
   }
   TGridResult* result = fGrid->CreateGridResult(handle);
@@ -318,6 +369,7 @@ Bool_t AliMonitorProcess::CheckForNewFile()
   while (Grid_Result_t* resultEntry = result->Next()) {
     const char* entry = resultEntry->name.c_str();
 #endif
+    if (strrchr(entry, '/')) entry = strrchr(entry, '/')+1;
     // entry = host_date_time.root
     TString entryCopy(entry);
     char* p = const_cast<char*>(entryCopy.Data());
@@ -345,26 +397,28 @@ Bool_t AliMonitorProcess::CheckForNewFile()
   result = fGrid->GetPhysicalFileNames(fLogicalFileName.Data());
   fFileName = result->Next();
 #else
-  fileName = fAlienDir + "/" + fLogicalFileName;
+  fileName = dirName + ("/" + fLogicalFileName);
   handle = fGrid->GetPhysicalFileNames(fileName.Data());
   if (!handle) {
-    Error("CheckForNewFile", "could not get physical file names for %s", 
-         fileName.Data());
+    AliError(Form("could not get physical file names for %s",
+                 fileName.Data()));
     return kFALSE;
   }
   result = fGrid->CreateGridResult(handle);
   result->Reset();
   Grid_Result_t* resultEntry = result->Next();
   if (!resultEntry) {
-    Error("CheckForNewFile", "could not get physical file names for %s", 
-         fileName.Data());
+    AliError(Form("could not get physical file names for %s",
+                 fileName.Data()));
     return kFALSE;
   }
   fFileName = resultEntry->name2.c_str();
   fFileName.ReplaceAll("castor:/", "rfio:/");
 #endif
   delete result;
-
+#else
+  Error("CheckForNewFile", "needs to be ported to new TGrid");
+#endif
   return kTRUE;
 }
 
@@ -376,15 +430,14 @@ Bool_t AliMonitorProcess::ProcessFile()
 
   Int_t nEvents = GetNumberOfEvents(fFileName);
   if (nEvents <= 0) return kFALSE;
-  Info("ProcessFile", "found %d event(s) in file %s", 
-       nEvents, fFileName.Data());
-#ifdef ALI_HLT
-  CreateHLT(fFileName);
-  CreateHLTHough(fFileName);
-#endif
+  AliDebug(1, Form("found %d event(s) in file %s",
+                  nEvents, fFileName.Data()));
+  if (IsSelected("HLTConfMap")) CreateHLT(fFileName);
+  if (IsSelected("HLTHough")) CreateHLTHough(fFileName);
 
   // loop over the events
   for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
+    CheckForConnections();
     SetStatus(kReading);
     fRunLoader->SetEventNumber(0);
     AliRawReaderRoot rawReader(fFileName, iEvent);
@@ -402,29 +455,50 @@ Bool_t AliMonitorProcess::ProcessFile()
     // monitor only central physics events
     if (rawReader.GetType() != 7) continue;
     if ((rawReader.GetAttributes()[0] & 0x02) == 0) continue;
+    AliInfo(Form("run: %d  event: %d %d\n", rawReader.GetRunNumber(),
+                rawReader.GetEventId()[0], rawReader.GetEventId()[1]));
 
-    if (!ReconstructTPC(&rawReader)) return kFALSE;
-    if (fStopping) break;
-    if (!ReconstructITS(&rawReader)) return kFALSE;
-    if (fStopping) break;
-    if (!ReconstructV0s()) return kFALSE;
-    if (fStopping) break;
-    if (!ReconstructHLT(iEvent)) return kFALSE;
-    if (fStopping) break;
-    if (!ReconstructHLTHough(iEvent)) return kFALSE;
-    if (fStopping) break;
+    AliESD esd;
+    if (IsSelected("TPC")) {
+      CheckForConnections();
+      if (!ReconstructTPC(&rawReader, &esd)) return kFALSE;
+      if (fStopping) break;
+    }
+    if (IsSelected("ITS")) {
+      CheckForConnections();
+      if (!ReconstructITS(&rawReader, &esd)) return kFALSE;
+      if (fStopping) break;
+    }
+    if (IsSelected("V0s")) {
+      CheckForConnections();
+      if (!ReconstructV0s(&esd)) return kFALSE;
+      if (fStopping) break;
+    }
+    if (IsSelected("HLTConfMap")) {
+      CheckForConnections();
+      if (!ReconstructHLT(iEvent)) return kFALSE;
+      if (fStopping) break;
+    }
+    if (IsSelected("HLTHough")) {
+      CheckForConnections();
+      if (!ReconstructHLTHough(iEvent)) return kFALSE;
+      if (fStopping) break;
+    }
 
     if (fDisplaySocket) fDisplaySocket->Send("new event");
 
-    Info("ProcessFile", "filling histograms...");
-    SetStatus(kFilling);
+    AliDebug(1, "filling histograms...");
     for (Int_t iMonitor = 0; iMonitor < fMonitors.GetEntriesFast(); iMonitor++) {
-      ((AliMonitor*) fMonitors[iMonitor])->FillHistos(fRunLoader, &rawReader);
+      CheckForConnections();
+      SetStatus(kFilling);
+      ((AliMonitor*) fMonitors[iMonitor])->FillHistos(fRunLoader, &rawReader,
+                                                     &esd);
       if (fStopping) break;
     }
     if (fStopping) break;
 
-    Info("ProcessFile", "updating histograms...");
+    AliDebug(1, "updating histograms...");
+    CheckForConnections();
     SetStatus(kUpdating);
     TIterator* iFolder = fTopFolder->GetListOfFolders()->MakeIterator();
     while (TFolder* folder = (TFolder*) iFolder->Next()) {
@@ -437,10 +511,10 @@ Bool_t AliMonitorProcess::ProcessFile()
     delete iFolder;
     if (fStopping) break;
 
-    Info("ProcessFile", "filling the tree...");
+    AliDebug(1, "filling the tree...");
     fTree->Fill();
 
-    Info("ProcessFile", "broadcasting histograms...");
+    AliDebug(1, "broadcasting histograms...");
     CheckForConnections();
     BroadcastHistos();
 
@@ -448,10 +522,14 @@ Bool_t AliMonitorProcess::ProcessFile()
     if (fStopping) break;
   }
 
-#ifdef ALI_HLT
-  delete fHLT;
-  fHLT = NULL;
-#endif
+  if (fHLT) {
+    delete fHLT;
+    fHLT = NULL;
+  }
+  if (fHLTHough) {
+    delete fHLTHough;
+    fHLTHough = NULL;
+  }
 
   return kTRUE;
 }
@@ -501,14 +579,14 @@ Int_t AliMonitorProcess::GetNumberOfEvents(const char* fileName) const
 
   TFile* file = TFile::Open(fileName);
   if (!file || !file->IsOpen()) {
-    Error("GetNumberOfEvents", "could not open file %s", fileName);
+    AliError(Form("could not open file %s", fileName));
     if (file) delete file;
     return -1;
   }
 
   TTree* tree = (TTree*) file->Get("RAW");
   if (!tree) {
-    Error("GetNumberOfEvents", "could not find tree with raw data");
+    AliError("could not find tree with raw data");
   } else {
     nEvents = (Int_t) tree->GetEntries();
   }
@@ -519,7 +597,7 @@ Int_t AliMonitorProcess::GetNumberOfEvents(const char* fileName) const
 }
 
 //_____________________________________________________________________________
-Bool_t AliMonitorProcess::ReconstructTPC(AliRawReader* rawReader)
+Bool_t AliMonitorProcess::ReconstructTPC(AliRawReader* rawReader, AliESD* esd)
 {
 // find TPC clusters and tracks
 
@@ -527,14 +605,13 @@ Bool_t AliMonitorProcess::ReconstructTPC(AliRawReader* rawReader)
 
   AliLoader* tpcLoader = fRunLoader->GetLoader("TPCLoader");
   if (!tpcLoader) {
-    Error("ReconstructTPC", "no TPC loader found");
+    AliError("no TPC loader found");
     return kFALSE;
   }
   gSystem->Unlink("TPC.RecPoints.root");
-  gSystem->Unlink("TPC.Tracks.root");
 
   // cluster finder
-  Info("ReconstructTPC", "reconstructing clusters...");
+  AliDebug(1, "reconstructing clusters...");
   tpcLoader->LoadRecPoints("recreate");
   AliTPCclustererMI clusterer(fTPCParam);
   tpcLoader->MakeRecPointsContainer();
@@ -543,20 +620,18 @@ Bool_t AliMonitorProcess::ReconstructTPC(AliRawReader* rawReader)
   tpcLoader->WriteRecPoints("OVERWRITE");
 
   // track finder
-  Info("ReconstructTPC", "reconstructing tracks...");
-  tpcLoader->LoadTracks("recreate");
-  {
-    AliTPCtrackerMI tracker(fTPCParam);
-    tracker.Clusters2Tracks();
-  }
-
+  AliDebug(1, "reconstructing tracks...");
+  AliTPCtrackerMI tracker(fTPCParam);
+  tracker.LoadClusters(tpcLoader->TreeR());
+  tracker.Clusters2Tracks(esd);
+  tracker.UnloadClusters();
   tpcLoader->UnloadRecPoints();
-  tpcLoader->UnloadTracks();
+
   return kTRUE;
 }
 
 //_____________________________________________________________________________
-Bool_t AliMonitorProcess::ReconstructITS(AliRawReader* rawReader)
+Bool_t AliMonitorProcess::ReconstructITS(AliRawReader* rawReader, AliESD* esd)
 {
 // find ITS clusters and tracks
 
@@ -564,77 +639,45 @@ Bool_t AliMonitorProcess::ReconstructITS(AliRawReader* rawReader)
 
   AliLoader* itsLoader = fRunLoader->GetLoader("ITSLoader");
   if (!itsLoader) {
-    Error("ReconstructITS", "no ITS loader found");
-    return kFALSE;
-  }
-  AliLoader* tpcLoader = fRunLoader->GetLoader("TPCLoader");
-  if (!tpcLoader) {
-    Error("ReconstructITS", "no TPC loader found");
+    AliError("no ITS loader found");
     return kFALSE;
   }
   gSystem->Unlink("ITS.RecPoints.root");
-  gSystem->Unlink("ITS.Tracks.root");
 
   // cluster finder
-  Info("ReconstructITS", "reconstructing clusters...");
+  AliDebug(1, "reconstructing clusters...");
   itsLoader->LoadRecPoints("recreate");
   AliITSclustererV2 clusterer(fITSgeom);
   itsLoader->MakeRecPointsContainer();
   clusterer.Digits2Clusters(rawReader);
 
   // track finder
-  Info("ReconstructITS", "reconstructing tracks...");
-  itsLoader->LoadTracks("recreate");
-  itsLoader->MakeTracksContainer();
-  tpcLoader->LoadTracks();
+  AliDebug(1, "reconstructing tracks...");
   AliITStrackerV2 tracker(fITSgeom);
   tracker.LoadClusters(itsLoader->TreeR());
-  tracker.Clusters2Tracks(tpcLoader->TreeT(), itsLoader->TreeT());
+  tracker.Clusters2Tracks(esd);
   tracker.UnloadClusters();
-  itsLoader->WriteTracks("OVERWRITE");
 
   itsLoader->UnloadRecPoints();
-  itsLoader->UnloadTracks();
-  tpcLoader->UnloadTracks();
   return kTRUE;
 }
 
 //_____________________________________________________________________________
-Bool_t AliMonitorProcess::ReconstructV0s()
+Bool_t AliMonitorProcess::ReconstructV0s(AliESD* esd)
 {
 // find V0s
 
   SetStatus(kRecV0s);
 
-  AliITSLoader* itsLoader = (AliITSLoader*) fRunLoader->GetLoader("ITSLoader");
-  if (!itsLoader) {
-    Error("ReconstructV0", "no ITS loader found");
-    return kFALSE;
-  }
-  gSystem->Unlink("ITS.V0s.root");
-
   // V0 finder
-  Info("ReconstructV0s", "reconstructing V0s...");
-  itsLoader->LoadTracks("read");
-  itsLoader->LoadV0s("recreate");
+  AliDebug(1, "reconstructing V0s...");
   AliV0vertexer vertexer;
-  TTree* tracks = itsLoader->TreeT();
-  if (!tracks) {
-    Error("ReconstructV0s", "no ITS tracks tree found");
-    return kFALSE;
-  }
-  if (!itsLoader->TreeV0()) itsLoader->MakeTree("V0");
-  TTree* v0s = itsLoader->TreeV0();
-  vertexer.Tracks2V0vertices(tracks, v0s);
-  itsLoader->WriteV0s("OVERWRITE");
+  vertexer.Tracks2V0vertices(esd);
 
-  itsLoader->UnloadTracks();
-  itsLoader->UnloadV0s();
   return kTRUE;
 }
 
 //_____________________________________________________________________________
-#ifdef ALI_HLT
 void AliMonitorProcess::CreateHLT(const char* fileName)
 {
 
@@ -648,7 +691,7 @@ void AliMonitorProcess::CreateHLT(const char* fileName)
   fHLT->Init("./", AliLevel3::kRaw, 1);
 
   fHLT->SetClusterFinderParam(-1, -1, kTRUE);
-  
+
   Int_t phiSegments = 50;
   Int_t etaSegments = 100;
   Int_t trackletlength = 3;
@@ -663,13 +706,13 @@ void AliMonitorProcess::CreateHLT(const char* fileName)
   Double_t hitChi2Cut = 15;//100 or 15
   Double_t goodHitChi2 = 5;//20 or 5
   Double_t trackChi2Cut = 10;//50 or 10
-  fHLT->SetTrackerParam(phiSegments, etaSegments, 
+  fHLT->SetTrackerParam(phiSegments, etaSegments,
                        trackletlength, tracklength,
                        rowscopetracklet, rowscopetrack,
                        minPtFit, maxangle, goodDist, hitChi2Cut,
                        goodHitChi2, trackChi2Cut, 50, maxphi, maxeta, kTRUE);
-  
-  fHLT->WriteFiles("./hlt/");  
+
+  fHLT->WriteFiles("./hlt/");
 }
 
 //_____________________________________________________________________________
@@ -683,7 +726,7 @@ void AliMonitorProcess::CreateHLTHough(const char* fileName)
   char name[256];
   strcpy(name, fileName);
 
-  fHLTHough = new AliL3Hough();
+  fHLTHough = new AliHLTHough();
   fHLTHough->SetThreshold(4);
   fHLTHough->SetTransformerParams(140,150,0.5,-1);
   fHLTHough->SetPeakThreshold(9000,-1);// or 6000
@@ -692,26 +735,14 @@ void AliMonitorProcess::CreateHLTHough(const char* fileName)
   //  fHLTHough->GetMaxFinder()->SetThreshold(14000);
 
 }
-#endif
 
 //_____________________________________________________________________________
-Bool_t AliMonitorProcess::ReconstructHLT(
-#ifdef ALI_HLT
-  Int_t iEvent
-#else
-  Int_t /* iEvent */
-#endif
-)
+Bool_t AliMonitorProcess::ReconstructHLT(Int_t iEvent)
 {
 // run the HLT cluster and track finder
 
   SetStatus(kRecHLT);
 
-#ifndef ALI_HLT
-  Warning("ReconstructHLT", "the code was compiled without HLT support");
-  return kTRUE;
-
-#else
   gSystem->Exec("rm -rf hlt");
   gSystem->MakeDirectory("hlt");
   if (!fHLT) return kFALSE;
@@ -729,27 +760,15 @@ Bool_t AliMonitorProcess::ReconstructHLT(
   sprintf(command, "rename tracks_%d tracks hlt/*.raw", iEvent);
   gSystem->Exec(command);
   return kTRUE;
-#endif
 }
 
 //_____________________________________________________________________________
-Bool_t AliMonitorProcess::ReconstructHLTHough(
-#ifdef ALI_HLT
-  Int_t iEvent
-#else
-  Int_t /* iEvent */
-#endif
-)
+Bool_t AliMonitorProcess::ReconstructHLTHough(Int_t iEvent)
 {
 // run the HLT Hough transformer
 
   SetStatus(kRecHLT);
 
-#ifndef ALI_HLT
-  Warning("ReconstructHLTHough", "the code was compiled without HLT support");
-  return kTRUE;
-
-#else
   gSystem->Exec("rm -rf hlt/hough");
   gSystem->MakeDirectory("hlt/hough");
   gSystem->Exec("rm -rf hlt/fitter");
@@ -770,7 +789,7 @@ Bool_t AliMonitorProcess::ReconstructHLTHough(
   fHLTHough->WriteTracks("./hlt/hough");
 
   // Run cluster fitter
-  AliL3ClusterFitter *fitter = new AliL3ClusterFitter("./hlt");
+  AliHLTClusterFitter *fitter = new AliHLTClusterFitter("./hlt");
 
   // Set debug flag for the cluster fitter
   //  fitter->Debug();
@@ -779,11 +798,11 @@ Bool_t AliMonitorProcess::ReconstructHLTHough(
   fitter->SetInnerWidthFactor(1,1.5);
   fitter->SetOuterWidthFactor(1,1.5);
   fitter->SetNmaxOverlaps(5);
-  
+
   //fitter->SetChiSqMax(5,kFALSE); //isolated clusters
   fitter->SetChiSqMax(5,kTRUE);  //overlapping clusters
 
-  Int_t rowrange[2] = {0,AliL3Transform::GetNRows()-1};
+  Int_t rowrange[2] = {0,AliHLTTransform::GetNRows()-1};
 
   // Takes input from global hough tracks produced by HT
   fitter->LoadSeeds(rowrange,kFALSE,iEvent);
@@ -792,12 +811,12 @@ Bool_t AliMonitorProcess::ReconstructHLTHough(
 
   for(Int_t islice = 0; islice <= 35; islice++)
     {
-      for(Int_t ipatch = 0; ipatch < AliL3Transform::GetNPatches(); ipatch++)
+      for(Int_t ipatch = 0; ipatch < AliHLTTransform::GetNPatches(); ipatch++)
        {
          // Read digits
          fHLTHough->GetMemHandler(ipatch)->Free();
          fHLTHough->GetMemHandler(ipatch)->Init(islice,ipatch);
-         AliL3DigitRowData *digits = (AliL3DigitRowData *)fHLTHough->GetMemHandler(ipatch)->AliAltroDigits2Memory(ndigits,iEvent);
+         AliHLTDigitRowData *digits = (AliHLTDigitRowData *)fHLTHough->GetMemHandler(ipatch)->AliAltroDigits2Memory(ndigits,iEvent);
 
          fitter->Init(islice,ipatch);
          fitter->SetInputData(digits);
@@ -807,23 +826,23 @@ Bool_t AliMonitorProcess::ReconstructHLTHough(
     }
 
   // Refit of the clusters
-  AliL3Vertex vertex;
+  AliHLTVertex vertex;
   //The seeds are the input tracks from circle HT
-  AliL3TrackArray *tracks = fitter->GetSeeds();
-  AliL3Fitter *ft = new AliL3Fitter(&vertex,1);
+  AliHLTTrackArray *tracks = fitter->GetSeeds();
+  AliHLTFitter *ft = new AliHLTFitter(&vertex,1);
 
   ft->LoadClusters("./hlt/fitter/",iEvent,kFALSE);
   for(Int_t i=0; i<tracks->GetNTracks(); i++)
     {
-      AliL3Track *track = tracks->GetCheckedTrack(i);
+      AliHLTTrack *track = tracks->GetCheckedTrack(i);
       if(!track) continue;
       if(track->GetNHits() < 20) continue;
       ft->SortTrackClusters(track);
       ft->FitHelix(track);
-      ft->UpdateTrack(track);
+      track->UpdateToFirstPoint();
     }
   delete ft;
-        
+
   //Write the final tracks
   fitter->WriteTracks(20);
 
@@ -838,13 +857,12 @@ Bool_t AliMonitorProcess::ReconstructHLTHough(
   sprintf(command, "rename points_%d points hlt/fitter/*.raw", iEvent);
   gSystem->Exec(command);
   return kTRUE;
-#endif
 }
 
 //_____________________________________________________________________________
 Bool_t AliMonitorProcess::WriteHistos()
 {
-// write the monitor tree and the monitor histograms to the file 
+// write the monitor tree and the monitor histograms to the file
 // "monitor_<run number>[_<sub_run_number>].root"
 // if at least fNEventsMin events were monitored
 
@@ -869,7 +887,7 @@ Bool_t AliMonitorProcess::WriteHistos()
 
   fFile = TFile::Open("monitor_tree.root", "RECREATE");
   if (!fFile || !fFile->IsOpen()) {
-    Fatal("WriteHistos", "could not open file for tree");
+    AliFatal("could not open file for tree");
   }
   fTree = new TTree("MonitorTree", "tree for monitoring");
   for (Int_t iMonitor = 0; iMonitor < fMonitors.GetEntriesFast(); iMonitor++) {
@@ -899,7 +917,7 @@ Bool_t AliMonitorProcess::WriteHistos()
   }
   TFile* file = TFile::Open(fileName, "recreate");
   if (!file || !file->IsOpen()) {
-    Error("WriteHistos", "could not open file %s", fileName);
+    AliError(Form("could not open file %s", fileName));
     result = kFALSE;
   } else {
     fTopFolder->Write();
@@ -935,47 +953,56 @@ void AliMonitorProcess::CheckForConnections()
 {
 // check if new clients want to connect and add them to the list of sockets
 
-  TMessage message(kMESS_OBJECT);
-  message.WriteObject(fTopFolder); 
-  SetStatus(kConnecting);
-
   TSocket* socket;
   while ((socket = fServerSocket->Accept()) != (TSocket*)-1) {
     socket->SetOption(kNoBlock, 1);
     char socketType[256];
-    if (!socket->Recv(socketType, 255)) continue;
-    if (strcmp(socketType, "client") == 0) {
-      if ((fNEvents == 0) || (socket->Send(message) >= 0)) {
-       fSockets.Add(socket);
+    if (socket->Recv(socketType, 255) <= 0) {
+      gSystem->Sleep(1000);
+      if (socket->Recv(socketType, 255) <= 0) {
        TInetAddress adr = socket->GetInetAddress();
-       Info("CheckForConnections", "new client:\n %s (%s), port %d\n",
-            adr.GetHostName(), adr.GetHostAddress(), adr.GetPort());
+       AliError(Form("no socket type received - "
+                     "disconnect client: %s (%s), port %d",
+                     adr.GetHostName(), adr.GetHostAddress(), adr.GetPort()));
+       delete socket;
+       continue;
       }
+    }
+    if (strcmp(socketType, "client") == 0) {
+      fSockets.Add(socket);
+      TInetAddress adr = socket->GetInetAddress();
+      AliInfo(Form("new client: %s (%s), port %d",
+                  adr.GetHostName(), adr.GetHostAddress(), adr.GetPort()));
+      if (fNEvents > 0) BroadcastHistos(socket);
     } else if (strcmp(socketType, "display") == 0) {
       if (fDisplaySocket) {
        fDisplaySocket->Close();
        delete fDisplaySocket;
       }
       fDisplaySocket = socket;
-      fDisplaySocket->SetOption(kNoBlock, 1);
       TInetAddress adr = socket->GetInetAddress();
-      Info("CheckForConnections", "new display:\n %s (%s), port %d\n",
-          adr.GetHostName(), adr.GetHostAddress(), adr.GetPort());
+      AliInfo(Form("new display: %s (%s), port %d",
+                  adr.GetHostName(), adr.GetHostAddress(), adr.GetPort()));
+    } else {
+      TInetAddress adr = socket->GetInetAddress();
+      AliError(Form("unknown socket type %s - "
+                   "disconnect client: %s (%s), port %d", socketType,
+                   adr.GetHostName(), adr.GetHostAddress(), adr.GetPort()));
+      delete socket;
+      continue;
     }
   }
 
+  // remove finished or invalid clients
   for (Int_t iSocket = 0; iSocket < fSockets.GetEntriesFast(); iSocket++) {
     socket = (TSocket*) fSockets[iSocket];
     if (!socket) continue;
-    // remove finished client
-    char str[256];
-    if (socket->Recv(str, 255)) {
-      TString socketMessage(str);
-      if(socketMessage.CompareTo("Finished") == 0) {
+    char controlMessage[256];
+    if (socket->Recv(controlMessage, 255)) {
+      if (strcmp(controlMessage, "disconnect") == 0) {
        TInetAddress adr = socket->GetInetAddress();
-       Info("CheckForConnections",
-            "disconnect finished client:\n %s (%s), port %d\n",
-            adr.GetHostName(), adr.GetHostAddress(), adr.GetPort());
+       AliInfo(Form("disconnect client: %s (%s), port %d",
+                    adr.GetHostName(), adr.GetHostAddress(), adr.GetPort()));
        delete fSockets.RemoveAt(iSocket);
        continue;
       }
@@ -983,8 +1010,8 @@ void AliMonitorProcess::CheckForConnections()
     if (!socket->IsValid()) {
       // remove invalid sockets from the list
       TInetAddress adr = socket->GetInetAddress();
-      Info("BroadcastHistos", "disconnect client:\n %s (%s), port %d\n",
-          adr.GetHostName(), adr.GetHostAddress(), adr.GetPort());
+      AliError(Form("disconnect invalid client: %s (%s), port %d",
+                   adr.GetHostName(), adr.GetHostAddress(), adr.GetPort()));
       delete fSockets.RemoveAt(iSocket);
     }
   }
@@ -992,27 +1019,84 @@ void AliMonitorProcess::CheckForConnections()
 }
 
 //_____________________________________________________________________________
-void AliMonitorProcess::BroadcastHistos()
+void AliMonitorProcess::BroadcastHistos(TSocket* toSocket)
 {
 // send the monitor histograms to the clients
 
   SetStatus(kBroadcasting);
   TMessage message(kMESS_OBJECT);
-  message.WriteObject(fTopFolder); 
+  message.WriteObject(fTopFolder);
 
   for (Int_t iSocket = 0; iSocket < fSockets.GetEntriesFast(); iSocket++) {
     TSocket* socket = (TSocket*) fSockets[iSocket];
     if (!socket) continue;
+    if (toSocket && (socket != toSocket)) continue;
+
+    // send control message
+    if (!socket->IsValid() || (socket->Send("histograms") <= 0)) {
+      TInetAddress adr = socket->GetInetAddress();
+      AliError(Form("connection to client failed - "
+                   "disconnect client: %s (%s), port %d",
+                   adr.GetHostName(), adr.GetHostAddress(), adr.GetPort()));
+      delete fSockets.RemoveAt(iSocket);
+    }
+
+    // receive control message
+    char controlMessage[256];
+    Int_t result = socket->Recv(controlMessage, 255);
+    if (result <= 0) {
+      gSystem->Sleep(1000);  // wait one second and try again
+      result = socket->Recv(controlMessage, 255);
+    }
+    if (result <= 0) {
+      TInetAddress adr = socket->GetInetAddress();
+      AliError(Form("no response from client - "
+                   "disconnect client: %s (%s), port %d",
+                   adr.GetHostName(), adr.GetHostAddress(), adr.GetPort()));
+      delete fSockets.RemoveAt(iSocket);
+      continue;
+    }
+    if (strcmp(controlMessage, "ok") != 0) {
+      TInetAddress adr = socket->GetInetAddress();
+      AliError(Form("no \"ok\" message from client - "
+                   "disconnect client: %s (%s), port %d",
+                   adr.GetHostName(), adr.GetHostAddress(), adr.GetPort()));
+      delete fSockets.RemoveAt(iSocket);
+      continue;
+    }
+
     socket->SetOption(kNoBlock, 0);
-    if (!socket->IsValid() || (socket->Send(message) < 0)) {
+    if (socket->Send(message) < 0) {
       // remove the socket from the list if there was an error
       TInetAddress adr = socket->GetInetAddress();
-      Info("BroadcastHistos", "disconnect client:\n %s (%s), port %d\n",
-          adr.GetHostName(), adr.GetHostAddress(), adr.GetPort());
+      AliError(Form("sending histograms failed - "
+                   "disconnect client: %s (%s), port %d",
+                   adr.GetHostName(), adr.GetHostAddress(), adr.GetPort()));
       delete fSockets.RemoveAt(iSocket);
     } else {
+      gSystem->Sleep(100);
       socket->SetOption(kNoBlock, 1);
     }
   }
   fSockets.Compress();
 }
+
+
+//_____________________________________________________________________________
+AliMonitorProcess::AliMonitorInterruptHandler::AliMonitorInterruptHandler
+  (AliMonitorProcess* process):
+  TSignalHandler(kSigUser1, kFALSE),
+  fProcess(process)
+{
+// constructor: set process
+}
+
+//_____________________________________________________________________________
+Bool_t AliMonitorProcess::AliMonitorInterruptHandler::Notify()
+{
+// interrupt signal -> stop process
+
+  AliInfo("the monitoring process will be stopped.");
+  fProcess->Stop();
+  return kTRUE;
+}