Loop over marked events added to Event Display.
authorjniedzie <jeremi.niedziela@cern.ch>
Wed, 29 Oct 2014 13:03:59 +0000 (14:03 +0100)
committerjniedzie <jeremi.niedziela@cern.ch>
Wed, 29 Oct 2014 13:03:59 +0000 (14:03 +0100)
EVE/EveBase/AliEveEventManager.cxx
EVE/EveBase/AliEveEventManager.h
EVE/EveBase/AliEveEventManagerEditor.cxx
EVE/EveBase/AliEveEventManagerEditor.h
EVE/macros/alieve_online_new.C
MONITOR/alistoragemanager/AliStorageAdministratorPanel.cxx
MONITOR/alistoragemanager/AliStorageEventManager.cxx

index 844fbf9..356c46d 100644 (file)
@@ -132,7 +132,7 @@ AliEveEventManager::AliEveEventManager(const TString& name, Int_t ev) :
     fESDfriend (0), fESDfriendExists(kFALSE),
     fAODFile   (0), fAODTree (0), fAOD (0),
     fRawReader (0), fEventInfo(),
-    fAutoLoad  (kFALSE), fAutoLoadTime (5),      fAutoLoadTimer(0),
+    fAutoLoad  (kFALSE),fLoopMarked(kFALSE), fAutoLoadTime (5),      fAutoLoadTimer(0),
     fIsOpen    (kFALSE), fHasEvent     (kFALSE), fExternalCtrl (kFALSE),
     fGlobal    (0), fGlobalReplace (kTRUE), fGlobalUpdate (kTRUE),
     fExecutor    (0), fTransients(0), fTransientLists(0),
@@ -223,19 +223,74 @@ AliEveEventManager::~AliEveEventManager()
 void AliEveEventManager::GetNextEvent()
 {
 #ifdef ZMQ
-    AliStorageEventManager *eventManager =
-    AliStorageEventManager::GetEventManagerInstance();
+    AliStorageEventManager *eventManager = AliStorageEventManager::GetEventManagerInstance();
     eventManager->CreateSocket(EVENTS_SERVER_SUB);
+    eventManager->CreateSocket(SERVER_COMMUNICATION_REQ);
     
     fCurrentEvent[0]=0;
     fCurrentEvent[1]=0;
-    fCurrentTree[0]=0;
-    fCurrentTree[1]=0;
+
     AliESDEvent *tmpEvent = NULL;
     
+    // get list of marked events:
+    struct listRequestStruct list;
+
+    list.runNumber[0]=0;
+    list.runNumber[1]=999999;
+    list.eventNumber[0]=0;
+    list.eventNumber[1]=999999;
+    list.marked[0]=1;
+    list.marked[1]=1;
+    list.multiplicity[0]=1;
+    list.multiplicity[1]=999999;
+    strcpy(list.system[0],"p-p");
+    strcpy(list.system[1],"A-A");
+    
+    struct serverRequestStruct *requestMessage = new struct serverRequestStruct;
+    requestMessage->messageType = REQUEST_LIST_EVENTS;
+    requestMessage->list = list;
+    
+    eventManager->Send(requestMessage,SERVER_COMMUNICATION_REQ);
+    vector<serverListStruct> receivedList = eventManager->GetServerListVector(SERVER_COMMUNICATION_REQ);
+    
+    cout<<"EVENT DISPLAY -- received list of marked events"<<endl;
+    
+    for(int i=0;i<receivedList.size();i++)
+    {
+        cout<<"ev:"<<receivedList[i].eventNumber<<endl;
+    }
+    
+    int iter=0;
     while(!fFinished)
     {
-        tmpEvent = eventManager->GetEvent(EVENTS_SERVER_SUB);
+        if(!fLoopMarked)
+        {
+            cout<<"taking event from reco server"<<endl;
+            tmpEvent = eventManager->GetEvent(EVENTS_SERVER_SUB,5);
+            if(!tmpEvent){sleep(1);}
+        }
+        else
+        {
+            cout<<"taking event from storage manager"<<endl;
+            if(iter<receivedList.size())
+            {
+                struct eventStruct mark;
+                mark.runNumber = receivedList[iter].runNumber;
+                mark.eventNumber = receivedList[iter].eventNumber;
+             
+                struct serverRequestStruct *requestMessage = new struct serverRequestStruct;
+                requestMessage->messageType = REQUEST_GET_EVENT;
+                requestMessage->event = mark;
+                
+                eventManager->Send(requestMessage,SERVER_COMMUNICATION_REQ);
+                tmpEvent = eventManager->GetEvent(SERVER_COMMUNICATION_REQ);
+                
+                iter++;
+                sleep(1);
+            }
+            else{iter=0;}
+        }
+        
         if(tmpEvent)
         {
             if(tmpEvent->GetRunNumber()>=0)
@@ -243,7 +298,7 @@ void AliEveEventManager::GetNextEvent()
                 fMutex->Lock();
                 if(fEventInUse == 0){fWritingToEventIndex = 1;}
                 else if(fEventInUse == 1){fWritingToEventIndex = 0;}
-                cout<<"Received new event"<<endl;
+                cout<<"Received new event:"<<tmpEvent->GetEventNumberInFile()<<endl;
                 if(fCurrentEvent[fWritingToEventIndex])
                 {
                     delete fCurrentEvent[fWritingToEventIndex];
@@ -255,7 +310,13 @@ void AliEveEventManager::GetNextEvent()
                 fMutex->UnLock();
             }
         }
+        else
+        {
+            cout<<"didn't receive new event"<<endl;
+        }
     }
+    delete requestMessage;
+    
 #endif
 }
 
@@ -794,7 +855,7 @@ void AliEveEventManager::SetEvent(AliRunLoader *runLoader, AliRawReader *rawRead
 
     AfterNewEventLoaded();
 
-    if (fAutoLoad) StartAutoLoadTimer();
+    if (fAutoLoad || fLoopMarked) StartAutoLoadTimer();
     
 }
 
@@ -1788,6 +1849,14 @@ void AliEveEventManager::SetAutoLoad(Bool_t autoLoad)
     }
 }
 
+void AliEveEventManager::SetLoopMarked(Bool_t loopMarked)
+{
+    // Set the automatic event loading mode
+    fLoopMarked = loopMarked;
+    if (fLoopMarked){StartAutoLoadTimer();}
+    else{StopAutoLoadTimer();}
+}
+
 void AliEveEventManager::SetTrigSel(Int_t trig)
 {
     static const TEveException kEH("AliEveEventManager::SetTrigSel ");
@@ -1841,7 +1910,7 @@ void AliEveEventManager::AutoLoadNextEvent()
 
        StopAutoLoadTimer();
        NextEvent();
-       if (fAutoLoad)
+       if (fAutoLoad || fLoopMarked)
                StartAutoLoadTimer();
 }
 
index 34cae3b..e6b391a 100644 (file)
@@ -125,8 +125,10 @@ public:
 
     Double_t      GetAutoLoadTime()        const { return fAutoLoadTime; }
     Bool_t        GetAutoLoad()            const { return fAutoLoad;     }
+    Bool_t        GetLoopMarked()            const { return fLoopMarked;     }
     void          SetAutoLoadTime(Float_t time);
     void          SetAutoLoad(Bool_t autoLoad);
+    void          SetLoopMarked(Bool_t loopMarked);
     void          SetTrigSel(Int_t trig);
     void          AutoLoadNextEvent();
 
@@ -173,6 +175,7 @@ protected:
     AliEventInfo       fEventInfo;             // Current Event Info
 
     Bool_t        fAutoLoad;              // Automatic loading of events (online)
+    Bool_t        fLoopMarked;            // Automatic loading of marked events
     Float_t       fAutoLoadTime;          // Auto-load time in seconds
     TTimer       *fAutoLoadTimer;         // Timer for automatic event loading
 
index 3f2bdbf..7aef66b 100644 (file)
@@ -123,6 +123,7 @@ AliEveEventManagerWindow::AliEveEventManagerWindow(AliEveEventManager* mgr) :
   fEventId      (0),
   fInfoLabel    (0),
   fAutoLoad     (0),
+  fLoopMarked   (0),
   fAutoLoadTime (0),
   fTrigSel      (0),
   fEventInfo    (0)
@@ -173,6 +174,11 @@ AliEveEventManagerWindow::AliEveEventManagerWindow(AliEveEventManager* mgr) :
     fAutoLoad->SetToolTipText("Automatic event loading.");
     fAutoLoad->Connect("Toggled(Bool_t)", cls, this, "DoSetAutoLoad()");
 
+    fLoopMarked = new TGCheckButton(f, "Loop Marked");
+    f->AddFrame(fLoopMarked, new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0));
+    fLoopMarked->SetToolTipText("Automatic marked events loading.");
+    fLoopMarked->Connect("Toggled(Bool_t)", cls, this, "DoSetLoopMarked()");
+      
     fAutoLoadTime = new TEveGValuator(f, "Time: ", 110, 0);
     f->AddFrame(fAutoLoadTime);
     fAutoLoadTime->SetShowSlider(kFALSE);
@@ -308,6 +314,14 @@ void AliEveEventManagerWindow::DoSetAutoLoad()
 }
 
 //______________________________________________________________________________
+void AliEveEventManagerWindow::DoSetLoopMarked()
+{
+    // Set the auto-load flag
+    fM->SetLoopMarked(fLoopMarked->IsOn());
+//    Update(fM->NewEventAvailable());
+}
+
+//______________________________________________________________________________
 void AliEveEventManagerWindow::DoSetAutoLoadTime()
 {
   // Set the auto-load time in seconds
index d5dd612..1353585 100644 (file)
@@ -81,6 +81,7 @@ public:
 
   void DoRefresh();
   void DoSetAutoLoad();
+  void DoSetLoopMarked();
   void DoSetAutoLoadTime();
   void DoSetTrigSel();
 
@@ -103,6 +104,7 @@ protected:
   TGLabel              *fInfoLabel;    // Display last available event id
 
   TGCheckButton        *fAutoLoad;     // Check-box for automatic loading of events
+  TGCheckButton        *fLoopMarked;     // Check-box for automatic loading of events
   TEveGValuator        *fAutoLoadTime; // Time for automatic loading of events
 
   TGComboBox           *fTrigSel;      // Trigger selection combo box
index 83eb3c2..4674644 100644 (file)
@@ -245,13 +245,8 @@ void alieve_online_on_new_event()
     if (++g_pic_id >= g_pic_max)
       g_pic_id = 0;
     g_pic_prev.Set();
-<<<<<<< HEAD
-  }
-  AliSysInfo::AddStamp("on_new_event_end");
-=======
   }*/
-       AliSysInfo::AddStamp("on_new_event_end");
->>>>>>> Fixing bugs in Event Display
+  AliSysInfo::AddStamp("on_new_event_end");
 }
 
 void alieve_init_import_macros()
index 39b3617..6da237c 100644 (file)
@@ -26,7 +26,7 @@ enum TOOLBUTTON{
 enum MENUBAR{
        MENUBAR_CLIENT_SET_PARAMS=1,
        MENUBAR_SERVER_LIST_EVENTS,
-       MENUBAR_SERVER_MARK_EVENT,
+    MENUBAR_SERVER_MARK_EVENT,
        MENUBAR_SERVER_GET_EVENT,
        MENUBAR_SERVER_GET_NEXT_EVENT,
        MENUBAR_SERVER_GET_LAST_EVENT
index 6c3f5c5..350de7b 100644 (file)
@@ -25,81 +25,81 @@ AliStorageEventManager *AliStorageEventManager::fManagerInstance = 0;
 
 AliStorageEventManager::AliStorageEventManager()
 {
-       //read config file
-       TThread::Lock();
-       ifstream configFile (GetConfigFilePath());
+    //read config file
+    TThread::Lock();
+    ifstream configFile (GetConfigFilePath());
     
-       if (configFile.is_open())
-       {
-               string line;
-               int from,to;
-               while(configFile.good())
-               {
-                       getline(configFile,line);
-                       from = line.find("\"")+1;
-                       to = line.find_last_of("\"");
-                       if(line.find("STORAGE_SERVER=")==0)
-                       {
-                               fStorageServer=line.substr(from,to-from);
-                       }
-                       else if(line.find("EVENT_SERVER=")==0)
-                       {
-                               fEventServer=line.substr(from,to-from);
-                       }
-                       else if(line.find("STORAGE_SERVER_PORT=")==0)
-                       {
-                               fStorageServerPort=atoi(line.substr(from,to-from).c_str());
-                       }
-                       else if(line.find("EVENT_SERVER_PORT=")==0)
-                       {
-                               fEventServerPort=atoi(line.substr(from,to-from).c_str());
-                       }
-                       else if(line.find("STORAGE_CLIENT_PORT=")==0)
-                       {
-                               fStorageClientPort=atoi(line.substr(from,to-from).c_str());
-                       }
-                       else if(line.find("XML_SERVER_PORT=")==0)
-                       {
-                               fXmlServerPort=atoi(line.substr(from,to-from).c_str());
-                       }
-               }
-               if(configFile.eof())
-               {
-                       configFile.clear();
-               }
-               configFile.close();
-       }
-       else
-       {
-               cout<<"EVENT MANAGER -- Unable to open config file"<<endl;
-       }
-       TThread::UnLock();
-       
-       for(int i=0;i<NUMBER_OF_SOCKETS;i++)
-       {
-               fContexts[i] = new context_t();
-       }
+    if (configFile.is_open())
+    {
+        string line;
+        int from,to;
+        while(configFile.good())
+        {
+            getline(configFile,line);
+            from = line.find("\"")+1;
+            to = line.find_last_of("\"");
+            if(line.find("STORAGE_SERVER=")==0)
+            {
+                fStorageServer=line.substr(from,to-from);
+            }
+            else if(line.find("EVENT_SERVER=")==0)
+            {
+                fEventServer=line.substr(from,to-from);
+            }
+            else if(line.find("STORAGE_SERVER_PORT=")==0)
+            {
+                fStorageServerPort=atoi(line.substr(from,to-from).c_str());
+            }
+            else if(line.find("EVENT_SERVER_PORT=")==0)
+            {
+                fEventServerPort=atoi(line.substr(from,to-from).c_str());
+            }
+            else if(line.find("STORAGE_CLIENT_PORT=")==0)
+            {
+                fStorageClientPort=atoi(line.substr(from,to-from).c_str());
+            }
+            else if(line.find("XML_SERVER_PORT=")==0)
+            {
+                fXmlServerPort=atoi(line.substr(from,to-from).c_str());
+            }
+        }
+        if(configFile.eof())
+        {
+            configFile.clear();
+        }
+        configFile.close();
+    }
+    else
+    {
+        cout<<"EVENT MANAGER -- Unable to open config file"<<endl;
+    }
+    TThread::UnLock();
+    
+    for(int i=0;i<NUMBER_OF_SOCKETS;i++)
+    {
+        fContexts[i] = new context_t();
+    }
 }
 AliStorageEventManager::~AliStorageEventManager()
 {
-       if(fManagerInstance){delete fManagerInstance;fManagerInstance=0;}
+    if(fManagerInstance){delete fManagerInstance;fManagerInstance=0;}
 }
 
 AliStorageEventManager* AliStorageEventManager::GetEventManagerInstance()
 {
-       TThread::Lock();
-       if(fManagerInstance==0)
-       {
-               fManagerInstance = new AliStorageEventManager();
-       }
-       TThread::UnLock();
-       return fManagerInstance;
+    TThread::Lock();
+    if(fManagerInstance==0)
+    {
+        fManagerInstance = new AliStorageEventManager();
+    }
+    TThread::UnLock();
+    return fManagerInstance;
 }
 
 
 void freeBuff (void *data, void *hint)
 {
-  //  free(data);
+    //  free(data);
 }
 
 bool AliStorageEventManager::CreateSocket(storageSockets socket)
@@ -222,257 +222,267 @@ bool AliStorageEventManager::CreateSocket(storageSockets socket)
 
 void AliStorageEventManager::Send(vector<serverListStruct> list,storageSockets socket)
 {
-       //send size of the struct first
-       int numberOfRecords = list.size();
-       message_t message(20);
-       snprintf ((char *)message.data(), 20 ,"%d",numberOfRecords);
-
-       fSockets[socket]->send(message);
-       if(numberOfRecords==0)return;
+    //send size of the struct first
+    int numberOfRecords = list.size();
+    message_t message(20);
+    snprintf ((char *)message.data(), 20 ,"%d",numberOfRecords);
+    
+    fSockets[socket]->send(message);
+    if(numberOfRecords==0)return;
     message_t *tmpMessage = new message_t();
-       fSockets[socket]->recv(tmpMessage);//empty message just to keep req-rep order
+    fSockets[socket]->recv(tmpMessage);//empty message just to keep req-rep order
     
-       // //prepare message with event's list
-       // char *buffer = reinterpret_cast<char*> (&list[0]);
-       // message_t *reply = new message_t((void*)buffer,
-       //                    sizeof(serverListStruct)*numberOfRecords,0);
-       // fSockets[socket]->send(*reply);
-       // if(reply){delete reply;}
-
-       message_t reply(sizeof(serverListStruct)*numberOfRecords);
-       memcpy(reply.data(), reinterpret_cast<const char*> (&list[0]), sizeof(serverListStruct)*numberOfRecords);
-
-       fSockets[socket]->send(reply);
+    // //prepare message with event's list
+    // char *buffer = reinterpret_cast<char*> (&list[0]);
+    // message_t *reply = new message_t((void*)buffer,
+    //                       sizeof(serverListStruct)*numberOfRecords,0);
+    // fSockets[socket]->send(*reply);
+    // if(reply){delete reply;}
+    
+    message_t reply(sizeof(serverListStruct)*numberOfRecords);
+    memcpy(reply.data(), reinterpret_cast<const char*> (&list[0]), sizeof(serverListStruct)*numberOfRecords);
+    
+    fSockets[socket]->send(reply);
     if(tmpMessage){delete tmpMessage;}
 }
 
 void AliStorageEventManager::Send(struct serverRequestStruct *request,storageSockets socket)
 {
-       char *buffer = (char*)(request);
-       message_t *requestMessage = new message_t((void*)buffer,
-                                          sizeof(struct serverRequestStruct)
-                                          +sizeof(struct listRequestStruct)
-                                          +sizeof(struct eventStruct),freeBuff);
-       fSockets[socket]->send(*requestMessage);
+    char *buffer = (char*)(request);
+    message_t *requestMessage = new message_t((void*)buffer,
+                                              sizeof(struct serverRequestStruct)
+                                              +sizeof(struct listRequestStruct)
+                                              +sizeof(struct eventStruct),freeBuff);
+    fSockets[socket]->send(*requestMessage);
 }
 
 bool AliStorageEventManager::Send(struct clientRequestStruct *request,storageSockets socket,int timeout)
 {
-       pollitem_t items[1] =  {{*fSockets[socket],0,ZMQ_POLLIN,0}} ;
-       
-       
-       char *buffer = (char*)(request);
-       message_t *requestMessage = new message_t((void*)buffer,
-                                                 sizeof(struct clientRequestStruct),freeBuff);
-
-       try
-       {
-               fSockets[socket]->send(*requestMessage);
-       }
-       catch (const zmq::error_t& e)
-       {
-               cout<<"MANAGER -- "<<e.what()<<endl;
-               cout<<e.num()<<endl;
-               if(fSockets[socket]){delete fSockets[socket];fSockets[socket]=0;}
-
-               CreateSocket(socket);
-               delete requestMessage;
-               return 0;
-               
-       }       
-       if(timeout>=0)
-       {
-               if(poll (&items[0], 1, timeout)==0)
-               {
-                 delete requestMessage;
-                       return 0;
-               }
-       }
-       delete requestMessage;          
-       return 1;
+    pollitem_t items[1] =  {{*fSockets[socket],0,ZMQ_POLLIN,0}} ;
+    
+    
+    char *buffer = (char*)(request);
+    message_t *requestMessage = new message_t((void*)buffer,
+                                              sizeof(struct clientRequestStruct),freeBuff);
+    
+    try
+    {
+        fSockets[socket]->send(*requestMessage);
+    }
+    catch (const zmq::error_t& e)
+    {
+        cout<<"MANAGER -- "<<e.what()<<endl;
+        cout<<e.num()<<endl;
+        if(fSockets[socket]){delete fSockets[socket];fSockets[socket]=0;}
+        
+        CreateSocket(socket);
+        delete requestMessage;
+        return 0;
+        
+    }
+    if(timeout>=0)
+    {
+        if(poll (&items[0], 1, timeout)==0)
+        {
+            delete requestMessage;
+            return 0;
+        }
+    }
+    delete requestMessage;
+    return 1;
 }
 
 void AliStorageEventManager::Send(long message,storageSockets socket)
 {
-       stringstream streamBuffer;
-       streamBuffer << message;
-       string stringBuffer = streamBuffer.str();
-       char *buffer = (char*)stringBuffer.c_str();
-       message_t *replyMessage = new message_t((void*)buffer,sizeof(stringBuffer),freeBuff);
+    stringstream streamBuffer;
+    streamBuffer << message;
+    string stringBuffer = streamBuffer.str();
+    char *buffer = (char*)stringBuffer.c_str();
+    message_t *replyMessage = new message_t((void*)buffer,sizeof(stringBuffer),freeBuff);
     
-       fSockets[socket]->send(*replyMessage);
-       delete replyMessage;
-       streamBuffer.str(string());
-       streamBuffer.clear();
+    fSockets[socket]->send(*replyMessage);
+    delete replyMessage;
+    streamBuffer.str(string());
+    streamBuffer.clear();
 }
 
 void AliStorageEventManager::Send(bool message,storageSockets socket)
 {
-       char *buffer;
-       if(message==true)
-       {
-               buffer = (char*)("true");
-       }
-       else
-       {
-               buffer = (char*)("false");
-       }
-       message_t *replyMessage = new message_t((void*)buffer,sizeof(buffer),freeBuff);
-       fSockets[socket]->send(*replyMessage);
-       delete replyMessage;
+    char *buffer;
+    if(message==true)
+    {
+        buffer = (char*)("true");
+    }
+    else
+    {
+        buffer = (char*)("false");
+    }
+    message_t *replyMessage = new message_t((void*)buffer,sizeof(buffer),freeBuff);
+    fSockets[socket]->send(*replyMessage);
+    delete replyMessage;
 }
 
 void AliStorageEventManager::Send(AliESDEvent *event, storageSockets socket)
 {
-       TMessage tmess(kMESS_OBJECT);
-       tmess.Reset();
-       tmess.WriteObject(event);
-       TMessage::EnableSchemaEvolutionForAll(kTRUE);
-
-       int bufsize = tmess.Length();
-       char* buf = (char*) malloc(bufsize * sizeof(char));
-       memcpy(buf, tmess.Buffer(), bufsize);
-       
-       message_t message((void*)buf, bufsize, freeBuff);
-       fSockets[socket]->send(message);
+    TMessage tmess(kMESS_OBJECT);
+    tmess.Reset();
+    tmess.WriteObject(event);
+    TMessage::EnableSchemaEvolutionForAll(kTRUE);
+    
+    int bufsize = tmess.Length();
+    char* buf = (char*) malloc(bufsize * sizeof(char));
+    memcpy(buf, tmess.Buffer(), bufsize);
+    
+    message_t message((void*)buf, bufsize, freeBuff);
+    fSockets[socket]->send(message);
 }
 
 void AliStorageEventManager::SendAsXml(AliESDEvent *event,storageSockets socket)
 {
-       cout<<"SENDING AS XML"<<endl;
-       stringstream bufferStream;
-       bufferStream << "<?xml version=\"1.0\" encoding=\"utf-8\"?>"<<endl;
-       bufferStream << "<ESD xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" << endl;
-       
-       for(int i=0;i<event->GetNumberOfTracks();i++)
-       {
-               AliESDtrack *track = event->GetTrack(i);
-               bufferStream << "\t<track mass=\""<<track->GetMass()<<"\">" <<endl;
-               const AliTrackPointArray *array = track->GetTrackPointArray();
-
-               if(array)
-               {
-                       const float *x = array->GetX();
-                       const float *y = array->GetY();
-                       const float *z = array->GetZ();
-                       int n = array->GetNPoints();
-
-                       for(int j=0;j<n;j++)
-                       {
-                               bufferStream <<"\t\t<point>"<<endl;
-                               bufferStream <<"\t\t\t<x>"<< x[j] <<"</x>"<<endl;
-                               bufferStream <<"\t\t\t<y>"<< y[j] <<"</y>"<<endl;
-                               bufferStream <<"\t\t\t<z>"<< z[j] <<"</z>"<<endl;
-                               bufferStream <<"\t\t</point>"<<endl;
-                       }
-               }
-               else cout<<"no array"<<endl;
-
-               bufferStream << "\t</track>"<<endl;
-       }
-
-       bufferStream << "</ESD>"<<endl;
-
-       string bufferString = bufferStream.str();
-       message_t message(bufferString.size());
-       memcpy (message.data(), bufferString.data(), bufferString.size());      
-       
-       fSockets[socket]->send(message);
-       cout<<"xml sent"<<endl;
+    cout<<"SENDING AS XML"<<endl;
+    stringstream bufferStream;
+    bufferStream << "<?xml version=\"1.0\" encoding=\"utf-8\"?>"<<endl;
+    bufferStream << "<ESD xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" << endl;
+    
+    for(int i=0;i<event->GetNumberOfTracks();i++)
+    {
+        AliESDtrack *track = event->GetTrack(i);
+        bufferStream << "\t<track mass=\""<<track->GetMass()<<"\">" <<endl;
+        const AliTrackPointArray *array = track->GetTrackPointArray();
+        
+        if(array)
+        {
+            const float *x = array->GetX();
+            const float *y = array->GetY();
+            const float *z = array->GetZ();
+            int n = array->GetNPoints();
+            
+            for(int j=0;j<n;j++)
+            {
+                bufferStream <<"\t\t<point>"<<endl;
+                bufferStream <<"\t\t\t<x>"<< x[j] <<"</x>"<<endl;
+                bufferStream <<"\t\t\t<y>"<< y[j] <<"</y>"<<endl;
+                bufferStream <<"\t\t\t<z>"<< z[j] <<"</z>"<<endl;
+                bufferStream <<"\t\t</point>"<<endl;
+            }
+        }
+        else cout<<"no array"<<endl;
+        
+        bufferStream << "\t</track>"<<endl;
+    }
+    
+    bufferStream << "</ESD>"<<endl;
+    
+    string bufferString = bufferStream.str();
+    message_t message(bufferString.size());
+    memcpy (message.data(), bufferString.data(), bufferString.size());
+    
+    fSockets[socket]->send(message);
+    cout<<"xml sent"<<endl;
 }
 
 vector<serverListStruct> AliStorageEventManager::GetServerListVector(storageSockets socket)
 {
-       //get size of the incomming message
-       message_t sizeMessage;
-       fSockets[socket]->recv(&sizeMessage);
-       int numberOfRecords;
-       istringstream iss(static_cast<char*>(sizeMessage.data()));
-       iss >> numberOfRecords;
-
-       if(numberOfRecords==0){cout<<"MANAGER -- list is empty"<<endl;}
-       
-       fSockets[socket]->send(*(new message_t()));//receive empty message just to keep req-rep order
-       
-//get list of events
-       message_t *response = new message_t(sizeof(serverListStruct)*numberOfRecords);
-       fSockets[socket]->recv(response);
-       
-       vector<serverListStruct> receivedList(static_cast<serverListStruct*>(response->data()), static_cast<serverListStruct*>(response->data()) + numberOfRecords);
-
-       if (response) {delete response;}
-       return receivedList;
+    //get size of the incomming message
+    message_t sizeMessage;
+    fSockets[socket]->recv(&sizeMessage);
+    int numberOfRecords;
+    istringstream iss(static_cast<char*>(sizeMessage.data()));
+    iss >> numberOfRecords;
+    
+    if(numberOfRecords==0){cout<<"MANAGER -- list is empty"<<endl;}
+    
+    fSockets[socket]->send(*(new message_t()));//receive empty message just to keep req-rep order
+    
+    //get list of events
+    message_t *response = new message_t(sizeof(serverListStruct)*numberOfRecords);
+    fSockets[socket]->recv(response);
+    
+    vector<serverListStruct> receivedList(static_cast<serverListStruct*>(response->data()), static_cast<serverListStruct*>(response->data()) + numberOfRecords);
+    
+    if (response) {delete response;}
+    return receivedList;
 }
 
 AliESDEvent* AliStorageEventManager::GetEvent(storageSockets socket,int timeout)
 {
-  message_t* message = new message_t();
-
-  try
-  {
-    fSockets[socket]->recv(message);
-  }
-  catch (const zmq::error_t& e)
-  {
-    cout<<"MANAGER -- "<<e.what()<<endl;
-    return NULL;
-  }
-       
-  TBufferFile *mess = new TBufferFile(TBuffer::kRead,
-                                      message->size()+sizeof(UInt_t),
-                                      message->data());
-  mess->InitMap();
-  mess->ReadClass();// get first the class stored in message
-  mess->SetBufferOffset(sizeof(UInt_t) + sizeof(kMESS_OBJECT));
-  mess->ResetMap();
-       
-  AliESDEvent* data = (AliESDEvent*)(mess->ReadObjectAny(AliESDEvent::Class()));
-
-  if (data)
-  {
-    data->GetStdContent();
-    if(message){delete message;}
-    return data;
-  }
-  else
-  {
-    if(message){delete message;}
-    return NULL;
-  }
+    pollitem_t items[1] =  {{*fSockets[socket],0,ZMQ_POLLIN,0}} ;
+    
+    if(timeout>=0)
+    {
+        if(poll (&items[0], 1, timeout)==0)
+        {
+            return NULL;
+        }
+    }
+    
+    message_t* message = new message_t();
+    
+    try
+    {
+        fSockets[socket]->recv(message);
+    }
+    catch (const zmq::error_t& e)
+    {
+        cout<<"MANAGER -- "<<e.what()<<endl;
+        return NULL;
+    }
+    
+    TBufferFile *mess = new TBufferFile(TBuffer::kRead,
+                                        message->size()+sizeof(UInt_t),
+                                        message->data());
+    mess->InitMap();
+    mess->ReadClass();// get first the class stored in message
+    mess->SetBufferOffset(sizeof(UInt_t) + sizeof(kMESS_OBJECT));
+    mess->ResetMap();
+    
+    AliESDEvent* data = (AliESDEvent*)(mess->ReadObjectAny(AliESDEvent::Class()));
+    
+    if (data)
+    {
+        data->GetStdContent();
+        if(message){delete message;}
+        return data;
+    }
+    else
+    {
+        if(message){delete message;}
+        return NULL;
+    }
 }
 
 struct serverRequestStruct* AliStorageEventManager::GetServerStruct(storageSockets socket)
 {
-       struct serverRequestStruct *request = new struct serverRequestStruct;
-       message_t *requestMessage = new message_t();
-       fSockets[socket]->recv(requestMessage);
-       request = static_cast<struct serverRequestStruct*>(requestMessage->data());
-       return request;
+    struct serverRequestStruct *request = new struct serverRequestStruct;
+    message_t *requestMessage = new message_t();
+    fSockets[socket]->recv(requestMessage);
+    request = static_cast<struct serverRequestStruct*>(requestMessage->data());
+    return request;
 }
 
 struct clientRequestStruct* AliStorageEventManager::GetClientStruct(storageSockets socket)
 {
-       struct clientRequestStruct *request = new struct clientRequestStruct;
-       message_t *requestMessage = new message_t();
-       fSockets[socket]->recv(requestMessage);
-       request = static_cast<struct clientRequestStruct*>(requestMessage->data());
-       return request;
+    struct clientRequestStruct *request = new struct clientRequestStruct;
+    message_t *requestMessage = new message_t();
+    fSockets[socket]->recv(requestMessage);
+    request = static_cast<struct clientRequestStruct*>(requestMessage->data());
+    return request;
 }
 
 bool AliStorageEventManager::GetBool(storageSockets socket)
 {
-       message_t *response = new message_t();
-       fSockets[socket]->recv(response);
-       char *result = (char*)response->data();
-       
-       if(!strcmp("true",result)){return true;}
-       else{return false;}
+    message_t *response = new message_t();
+    fSockets[socket]->recv(response);
+    char *result = (char*)response->data();
+    
+    if(!strcmp("true",result)){return true;}
+    else{return false;}
 }
 
 long AliStorageEventManager::GetLong(storageSockets socket)
 {
-       message_t *responseMessage = new message_t();
-       fSockets[socket]->recv(responseMessage);
+    message_t *responseMessage = new message_t();
+    fSockets[socket]->recv(responseMessage);
     
     long result = 0;
     
@@ -481,6 +491,6 @@ long AliStorageEventManager::GetLong(storageSockets socket)
         result = (long)atoi(static_cast<char*>(responseMessage->data()));
         delete responseMessage;
     }
-       return result;
+    return result;
 }