X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MONITOR%2FAliMonitorProcess.cxx;h=a6375eb55552fa77ff5d64820da6e1a2c0cab2d7;hb=f2421e8457c1d9e57855c05f4aadc8cda1871b4d;hp=8ea2378e06a348343a82819a3901c242c3559751;hpb=c4bd737cb50b8181042b5b2edf69c67401e1dcf0;p=u%2Fmrichter%2FAliRoot.git diff --git a/MONITOR/AliMonitorProcess.cxx b/MONITOR/AliMonitorProcess.cxx index 8ea2378e06a..a6375eb5555 100644 --- a/MONITOR/AliMonitorProcess.cxx +++ b/MONITOR/AliMonitorProcess.cxx @@ -31,6 +31,7 @@ #include "AliMonitorITS.h" #include "AliMonitorV0s.h" #include "AliMonitorHLT.h" +#include "AliMonitorHLTHough.h" #include "AliRawReaderRoot.h" #include "AliLoader.h" #include "AliRun.h" @@ -51,6 +52,16 @@ #ifdef ALI_HLT #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif ClassImp(AliMonitorProcess) @@ -60,17 +71,31 @@ const Int_t AliMonitorProcess::fgkPort = 9327; //_____________________________________________________________________________ -AliMonitorProcess::AliMonitorProcess(const char* alienDir, +AliMonitorProcess::AliMonitorProcess( +#if ROOT_VERSION_CODE <= 199169 // 3.10/01 + const char* /*alienHost*/, +#else + const char* alienHost, +#endif + const char* alienDir, const char* fileNameGalice) { // initialize the monitoring process and the monitor histograms +#if ROOT_VERSION_CODE <= 199169 // 3.10/01 fGrid = TGrid::Connect("alien", gSystem->Getenv("USER")); +#else + fGrid = TGrid::Connect(alienHost, gSystem->Getenv("USER")); +#endif if (!fGrid || fGrid->IsZombie() || !fGrid->IsConnected()) { delete fGrid; Fatal("AliMonitorProcess", "could not connect to alien"); } +#if ROOT_VERSION_CODE <= 199169 // 3.10/01 fGrid->cd(alienDir); +#else + fAlienDir = alienDir; +#endif fLogicalFileName = ""; fFileName = ""; @@ -103,7 +128,7 @@ AliMonitorProcess::AliMonitorProcess(const char* alienDir, fRunNumber = 0; fSubRunNumber = 0; fNEvents = 0; - fNEventsMin = 2; + fNEventsMin = 1; fWriteHistoList = kFALSE; fTopFolder = new TFolder("Monitor", "monitor histograms"); @@ -114,6 +139,7 @@ AliMonitorProcess::AliMonitorProcess(const char* alienDir, fMonitors.Add(new AliMonitorV0s); #ifdef ALI_HLT fMonitors.Add(new AliMonitorHLT(fTPCParam)); + fMonitors.Add(new AliMonitorHLTHough(fTPCParam)); #endif for (Int_t iMonitor = 0; iMonitor < fMonitors.GetEntriesFast(); iMonitor++) { @@ -144,6 +170,9 @@ AliMonitorProcess::AliMonitorProcess(const char* alienDir, SetStatus(kStopped); fStopping = kFALSE; + + fInterruptHandler = new AliMonitorInterruptHandler(this); + gSystem->AddSignalHandler(fInterruptHandler); } //_____________________________________________________________________________ @@ -174,7 +203,9 @@ AliMonitorProcess::~AliMonitorProcess() fSockets.Delete(); delete fDisplaySocket; +#if ROOT_VERSION_CODE <= 199169 // 3.10/01 fGrid->Close(); +#endif delete fGrid; fFile->Close(); @@ -183,7 +214,11 @@ AliMonitorProcess::~AliMonitorProcess() #ifdef ALI_HLT delete fHLT; + delete fHLTHough; #endif + + gSystem->RemoveSignalHandler(fInterruptHandler); + delete fInterruptHandler; } @@ -268,12 +303,33 @@ Bool_t AliMonitorProcess::CheckForNewFile() { // check whether a new file was registered in alien +#if ROOT_VERSION_CODE <= 199169 // 3.10/01 TGridResult* result = fGrid->Ls(); +#else + 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", + dirName); + return kFALSE; + } + TGridResult* result = fGrid->CreateGridResult(handle); +#endif Long_t maxDate = -1; Long_t maxTime = -1; TString fileName; +#if ROOT_VERSION_CODE <= 199169 // 3.10/01 while (const char* entry = result->Next()) { +#else + 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(entryCopy.Data()); @@ -292,12 +348,34 @@ Bool_t AliMonitorProcess::CheckForNewFile() } } + delete result; if (maxDate < 0) return kFALSE; // no files found if (fLogicalFileName.CompareTo(fileName) == 0) return kFALSE; // no new file fLogicalFileName = fileName; - TGridResult* result2 = fGrid->GetPhysicalFileNames(fLogicalFileName.Data()); - fFileName = result2->Next(); +#if ROOT_VERSION_CODE <= 199169 // 3.10/01 + result = fGrid->GetPhysicalFileNames(fLogicalFileName.Data()); + fFileName = result->Next(); +#else + fileName = dirName + ("/" + fLogicalFileName); + handle = fGrid->GetPhysicalFileNames(fileName.Data()); + if (!handle) { + Error("CheckForNewFile", "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()); + return kFALSE; + } + fFileName = resultEntry->name2.c_str(); + fFileName.ReplaceAll("castor:/", "rfio:/"); +#endif + delete result; return kTRUE; } @@ -314,10 +392,12 @@ Bool_t AliMonitorProcess::ProcessFile() nEvents, fFileName.Data()); #ifdef ALI_HLT CreateHLT(fFileName); + CreateHLTHough(fFileName); #endif // loop over the events for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) { + CheckForConnections(); SetStatus(kReading); fRunLoader->SetEventNumber(0); AliRawReaderRoot rawReader(fFileName, iEvent); @@ -332,26 +412,41 @@ Bool_t AliMonitorProcess::ProcessFile() if (fStopping) break; } + // monitor only central physics events + if (rawReader.GetType() != 7) continue; + if ((rawReader.GetAttributes()[0] & 0x02) == 0) continue; + Info("ProcessFile", "run: %d event: %d %d\n", rawReader.GetRunNumber(), + rawReader.GetEventId()[0], rawReader.GetEventId()[1]); + + CheckForConnections(); if (!ReconstructTPC(&rawReader)) return kFALSE; if (fStopping) break; + CheckForConnections(); if (!ReconstructITS(&rawReader)) return kFALSE; if (fStopping) break; + CheckForConnections(); if (!ReconstructV0s()) return kFALSE; if (fStopping) break; + CheckForConnections(); if (!ReconstructHLT(iEvent)) return kFALSE; if (fStopping) break; + CheckForConnections(); + if (!ReconstructHLTHough(iEvent)) return kFALSE; + if (fStopping) break; if (fDisplaySocket) fDisplaySocket->Send("new event"); Info("ProcessFile", "filling histograms..."); - SetStatus(kFilling); for (Int_t iMonitor = 0; iMonitor < fMonitors.GetEntriesFast(); iMonitor++) { + CheckForConnections(); + SetStatus(kFilling); ((AliMonitor*) fMonitors[iMonitor])->FillHistos(fRunLoader, &rawReader); if (fStopping) break; } if (fStopping) break; Info("ProcessFile", "updating histograms..."); + CheckForConnections(); SetStatus(kUpdating); TIterator* iFolder = fTopFolder->GetListOfFolders()->MakeIterator(); while (TFolder* folder = (TFolder*) iFolder->Next()) { @@ -474,7 +569,12 @@ Bool_t AliMonitorProcess::ReconstructTPC(AliRawReader* rawReader) tpcLoader->LoadTracks("recreate"); { AliTPCtrackerMI tracker(fTPCParam); + tracker.SetIO(); + tracker.LoadClusters(); tracker.Clusters2Tracks(); + tracker.WriteTracks(); + tracker.UnloadClusters(); + tpcLoader->WriteTracks("OVERWRITE"); } tpcLoader->UnloadRecPoints(); @@ -574,19 +674,19 @@ void AliMonitorProcess::CreateHLT(const char* fileName) fHLT = new AliLevel3(name); fHLT->Init("./", AliLevel3::kRaw, 1); - fHLT->SetClusterFinderParam(0, 0, kTRUE); + fHLT->SetClusterFinderParam(-1, -1, kTRUE); Int_t phiSegments = 50; Int_t etaSegments = 100; Int_t trackletlength = 3; - Int_t tracklength = 40;//40 or 5 + Int_t tracklength = 20;//40 or 5 Int_t rowscopetracklet = 2; - Int_t rowscopetrack = 2; + Int_t rowscopetrack = 10; Double_t minPtFit = 0; - Double_t maxangle = 1.31; + Double_t maxangle = 0.1745; Double_t goodDist = 5; - Double_t maxphi = 100; - Double_t maxeta = 100; + Double_t maxphi = 0.1; + Double_t maxeta = 0.1; Double_t hitChi2Cut = 15;//100 or 15 Double_t goodHitChi2 = 5;//20 or 5 Double_t trackChi2Cut = 10;//50 or 10 @@ -598,6 +698,27 @@ void AliMonitorProcess::CreateHLT(const char* fileName) fHLT->WriteFiles("./hlt/"); } + +//_____________________________________________________________________________ +void AliMonitorProcess::CreateHLTHough(const char* fileName) +{ + +// create the HLT Hough transform (L3Hough) object + + if (fHLTHough) delete fHLTHough; + + char name[256]; + strcpy(name, fileName); + + fHLTHough = new AliL3Hough(); + fHLTHough->SetThreshold(4); + fHLTHough->SetTransformerParams(140,150,0.5,-1); + fHLTHough->SetPeakThreshold(9000,-1);// or 6000 + fHLTHough->Init("./", kFALSE, 50, kFALSE,0,name); + fHLTHough->SetAddHistograms(); + // fHLTHough->GetMaxFinder()->SetThreshold(14000); + +} #endif //_____________________________________________________________________________ @@ -638,6 +759,114 @@ Bool_t AliMonitorProcess::ReconstructHLT( #endif } +//_____________________________________________________________________________ +Bool_t AliMonitorProcess::ReconstructHLTHough( +#ifdef ALI_HLT + Int_t iEvent +#else + Int_t /* iEvent */ +#endif +) +{ +// 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"); + gSystem->MakeDirectory("hlt/fitter"); + if (!fHLTHough) return kFALSE; + + // fHLTHough->Process(0, 35); + // Loop over TPC sectors and process the data + for(Int_t i=0; i<=35; i++) + { + fHLTHough->ReadData(i,iEvent); + fHLTHough->Transform(); + // if(fHLTHough->fAddHistograms) + fHLTHough->AddAllHistograms(); + fHLTHough->FindTrackCandidates(); + fHLTHough->AddTracks(); + } + fHLTHough->WriteTracks("./hlt/hough"); + + // Run cluster fitter + AliL3ClusterFitter *fitter = new AliL3ClusterFitter("./hlt"); + + // Set debug flag for the cluster fitter + // fitter->Debug(); + + // Setting fitter parameters + 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}; + + // Takes input from global hough tracks produced by HT + fitter->LoadSeeds(rowrange,kFALSE,iEvent); + + UInt_t ndigits; + + for(Int_t islice = 0; islice <= 35; islice++) + { + for(Int_t ipatch = 0; ipatch < AliL3Transform::GetNPatches(); ipatch++) + { + // Read digits + fHLTHough->GetMemHandler(ipatch)->Free(); + fHLTHough->GetMemHandler(ipatch)->Init(islice,ipatch); + AliL3DigitRowData *digits = (AliL3DigitRowData *)fHLTHough->GetMemHandler(ipatch)->AliAltroDigits2Memory(ndigits,iEvent); + + fitter->Init(islice,ipatch); + fitter->SetInputData(digits); + fitter->FindClusters(); + fitter->WriteClusters(); + } + } + + // Refit of the clusters + AliL3Vertex vertex; + //The seeds are the input tracks from circle HT + AliL3TrackArray *tracks = fitter->GetSeeds(); + AliL3Fitter *ft = new AliL3Fitter(&vertex,1); + + ft->LoadClusters("./hlt/fitter/",iEvent,kFALSE); + for(Int_t i=0; iGetNTracks(); i++) + { + AliL3Track *track = tracks->GetCheckedTrack(i); + if(!track) continue; + if(track->GetNHits() < 20) continue; + ft->SortTrackClusters(track); + ft->FitHelix(track); + track->UpdateToFirstPoint(); + } + delete ft; + + //Write the final tracks + fitter->WriteTracks(20); + + delete fitter; + + // remove the event number from the file names + char command[256]; + sprintf(command, "rename tracks_%d tracks hlt/hough/*.raw", iEvent); + gSystem->Exec(command); + sprintf(command, "rename tracks_%d tracks hlt/fitter/*.raw", iEvent); + gSystem->Exec(command); + sprintf(command, "rename points_%d points hlt/fitter/*.raw", iEvent); + gSystem->Exec(command); + return kTRUE; +#endif +} //_____________________________________________________________________________ Bool_t AliMonitorProcess::WriteHistos() @@ -733,46 +962,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()); + Error("CheckForConnections", "no socket type received - " + "disconnect client:\n %s (%s), port %d\n", + adr.GetHostName(), adr.GetHostAddress(), adr.GetPort()); + delete socket; + continue; } + } + if (strcmp(socketType, "client") == 0) { + fSockets.Add(socket); + TInetAddress adr = socket->GetInetAddress(); + Info("CheckForConnections", "new client:\n %s (%s), port %d\n", + 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()); + } else { + TInetAddress adr = socket->GetInetAddress(); + Error("CheckForConnections", "unknown socket type %s - " + "disconnect client:\n %s (%s), port %d\n", 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", + "disconnect client:\n %s (%s), port %d\n", adr.GetHostName(), adr.GetHostAddress(), adr.GetPort()); delete fSockets.RemoveAt(iSocket); continue; @@ -781,8 +1020,9 @@ 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()); + Error("CheckForConnections", + "disconnect invalid client:\n %s (%s), port %d\n", + adr.GetHostName(), adr.GetHostAddress(), adr.GetPort()); delete fSockets.RemoveAt(iSocket); } } @@ -790,7 +1030,7 @@ void AliMonitorProcess::CheckForConnections() } //_____________________________________________________________________________ -void AliMonitorProcess::BroadcastHistos() +void AliMonitorProcess::BroadcastHistos(TSocket* toSocket) { // send the monitor histograms to the clients @@ -801,16 +1041,94 @@ void AliMonitorProcess::BroadcastHistos() 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(); + Error("BroadcastHistos", "connection to client failed - " + "disconnect client:\n %s (%s), port %d\n", + 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(); + Error("BroadcastHistos", "no response from client - " + "disconnect client:\n %s (%s), port %d\n", + adr.GetHostName(), adr.GetHostAddress(), adr.GetPort()); + delete fSockets.RemoveAt(iSocket); + continue; + } + if (strcmp(controlMessage, "ok") != 0) { + TInetAddress adr = socket->GetInetAddress(); + Error("BroadcastHistos", "no \"ok\" message from client - " + "disconnect client:\n %s (%s), port %d\n", + 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()); + Error("BroadcastHistos", "sending histograms failed - " + "disconnect client:\n %s (%s), port %d\n", + 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 +} + +//_____________________________________________________________________________ +AliMonitorProcess::AliMonitorInterruptHandler::AliMonitorInterruptHandler + (const AliMonitorInterruptHandler& handler): + TSignalHandler(handler) +{ +// copy constructor + + Fatal("AliMonitorInterruptHandler", "copy constructor not implemented"); +} + +//_____________________________________________________________________________ +AliMonitorProcess::AliMonitorInterruptHandler& + AliMonitorProcess::AliMonitorInterruptHandler::operator = + (const AliMonitorInterruptHandler& /*handler*/) +{ +// assignment operator + + Fatal("operator =", "assignment operator not implemented"); + return *this; +} + +//_____________________________________________________________________________ +Bool_t AliMonitorProcess::AliMonitorInterruptHandler::Notify() +{ +// interrupt signal -> stop process + + Info("Notify", "the monitoring process will be stopped."); + fProcess->Stop(); + return kTRUE; +}