X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MONITOR%2FAliMonitorProcess.cxx;h=9cfe950da8ce7e0b3d52d58c26d07be5bc58b4a5;hb=7ff7e09234c11fa18f60a9e678190a6e49b3954b;hp=2c231eb9a4c3422febd6c55a62ab13f4e61fdb8d;hpb=54a4175599fd6ff438fc7fe50ba8be48f1808ad0;p=u%2Fmrichter%2FAliRoot.git diff --git a/MONITOR/AliMonitorProcess.cxx b/MONITOR/AliMonitorProcess.cxx index 2c231eb9a4c..9cfe950da8c 100644 --- a/MONITOR/AliMonitorProcess.cxx +++ b/MONITOR/AliMonitorProcess.cxx @@ -25,94 +25,149 @@ // // /////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include +#include "AliLog.h" +#include "AliESDEvent.h" +#include "AliITSclustererV2.h" +#include "AliITSgeom.h" +#include "AliITStrackerV2.h" +#include "AliLoader.h" +// Matthias 2007-10-03 HLT legacy code disabled +// everything encapsulated by ENABLE_ALIMONITORPROCESS_HLT +// set the define in the header file to include the code +#ifdef ENABLE_ALIMONITORPROCESS_HLT +#include "AliMonitorHLT.h" +#include "AliMonitorHLTHough.h" +#endif // ENABLE_ALIMONITORPROCESS_HLT +#include "AliMonitorITS.h" #include "AliMonitorProcess.h" #include "AliMonitorTPC.h" -#include "AliMonitorITS.h" #include "AliMonitorV0s.h" -#include "AliMonitorHLT.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 -#include -#include -#include -#include -#ifdef ALI_HLT -#include -#endif -ClassImp(AliMonitorProcess) +#ifdef ENABLE_ALIMONITORPROCESS_HLT +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // ENABLE_ALIMONITORPROCESS_HLT + +ClassImp(AliMonitorProcess) -const Int_t AliMonitorProcess::kgPort = 9327; +const Int_t AliMonitorProcess::fgkPort = 9327; //_____________________________________________________________________________ -AliMonitorProcess::AliMonitorProcess(const char* alienDir, - const char* fileNameGalice) +AliMonitorProcess::AliMonitorProcess( +#if ROOT_VERSION_CODE <= 199169 // 3.10/01 + const char* /*alienHost*/, +#else + const char* alienHost, +#endif + const char* alienDir, + 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 + fGrid = TGrid::Connect(alienHost, gSystem->Getenv("USER")); +#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); - fLogicalFileName = ""; - fFileName = ""; +#endif 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(fileNameGalice),kTRUE); + if (!gAlice) AliFatal("no gAlice object found"); + fITSgeom = (AliITSgeom*)gDirectory->Get("AliITSgeom"); + if (!fITSgeom) AliFatal("could not load ITS geometry"); + +#ifdef ENABLE_ALIMONITORPROCESS_HLT + // Init TPC parameters for HLT + Bool_t isinit=AliHLTTransform::Init(const_cast(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 = 2; - fWriteHistoList = kFALSE; +#endif // ENABLE_ALIMONITORPROCESS_HLT 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)); -#endif + if (IsSelected("TPC")) fMonitors.Add(new AliMonitorTPC(fTPCParam)); + if (IsSelected("ITS")) fMonitors.Add(new AliMonitorITS(fITSgeom)); + if (IsSelected("V0s")) fMonitors.Add(new AliMonitorV0s); +#ifdef ENABLE_ALIMONITORPROCESS_HLT + if (IsSelected("HLTConfMap")) fMonitors.Add(new AliMonitorHLT(fTPCParam)); + if (IsSelected("HLTHough")) fMonitors.Add(new AliMonitorHLTHough(fTPCParam)); +#endif // ENABLE_ALIMONITORPROCESS_HLT for (Int_t iMonitor = 0; iMonitor < fMonitors.GetEntriesFast(); iMonitor++) { ((AliMonitor*) fMonitors[iMonitor])->CreateHistos(fTopFolder); @@ -124,7 +179,7 @@ AliMonitorProcess::AliMonitorProcess(const char* alienDir, 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++) { @@ -132,16 +187,59 @@ AliMonitorProcess::AliMonitorProcess(const char* alienDir, } gROOT->cd(); - fServerSocket = new TServerSocket(kgPort, kTRUE); + 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), + + 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) + +{ + AliFatal("copy constructor not implemented"); +} + +//_____________________________________________________________________________ +AliMonitorProcess& AliMonitorProcess::operator = (const AliMonitorProcess& + /*process*/) +{ + AliFatal("assignment operator not implemented"); + return *this; } //_____________________________________________________________________________ @@ -157,16 +255,22 @@ AliMonitorProcess::~AliMonitorProcess() fSockets.Delete(); delete fDisplaySocket; +#if ROOT_VERSION_CODE <= 199169 // 3.10/01 fGrid->Close(); +#endif delete fGrid; fFile->Close(); delete fFile; gSystem->Unlink("monitor_tree.root"); -#ifdef ALI_HLT +#ifdef ENABLE_ALIMONITORPROCESS_HLT delete fHLT; -#endif + delete fHLTHough; +#endif // ENABLE_ALIMONITORPROCESS_HLT + + gSystem->RemoveSignalHandler(fInterruptHandler); + delete fInterruptHandler; } @@ -180,6 +284,8 @@ const char* AliMonitorProcess::GetRevision() //_____________________________________________________________________________ void AliMonitorProcess::SetStatus(EStatus status) { +// set the current status and process system events + fStatus = status; gSystem->ProcessEvents(); } @@ -188,7 +294,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; @@ -229,8 +335,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; } @@ -249,12 +355,34 @@ 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 + 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) { + AliError(Form("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()); @@ -273,13 +401,37 @@ 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) { + 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) { + 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; } @@ -291,14 +443,16 @@ 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); -#endif + AliDebug(1, Form("found %d event(s) in file %s", + nEvents, fFileName.Data())); +#ifdef ENABLE_ALIMONITORPROCESS_HLT + if (IsSelected("HLTConfMap")) CreateHLT(fFileName); + if (IsSelected("HLTHough")) CreateHLTHough(fFileName); +#endif // ENABLE_ALIMONITORPROCESS_HLT // loop over the events for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) { + CheckForConnections(); SetStatus(kReading); fRunLoader->SetEventNumber(0); AliRawReaderRoot rawReader(fFileName, iEvent); @@ -313,26 +467,55 @@ Bool_t AliMonitorProcess::ProcessFile() if (fStopping) break; } - 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; + // 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])); + + AliESDEvent 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; + } +#ifdef ENABLE_ALIMONITORPROCESS_HLT + if (IsSelected("HLTConfMap")) { + CheckForConnections(); + if (!ReconstructHLT(iEvent)) return kFALSE; + if (fStopping) break; + } + if (IsSelected("HLTHough")) { + CheckForConnections(); + if (!ReconstructHLTHough(iEvent)) return kFALSE; + if (fStopping) break; + } +#endif // ENABLE_ALIMONITORPROCESS_HLT 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()) { @@ -345,10 +528,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(); @@ -356,10 +539,16 @@ Bool_t AliMonitorProcess::ProcessFile() if (fStopping) break; } -#ifdef ALI_HLT - delete fHLT; - fHLT = NULL; -#endif +#ifdef ENABLE_ALIMONITORPROCESS_HLT + if (fHLT) { + delete fHLT; + fHLT = NULL; + } + if (fHLTHough) { + delete fHLTHough; + fHLTHough = NULL; + } +#endif // ENABLE_ALIMONITORPROCESS_HLT return kTRUE; } @@ -377,7 +566,7 @@ void AliMonitorProcess::Reset() //_____________________________________________________________________________ -UInt_t AliMonitorProcess::GetEventPeriodNumber() +UInt_t AliMonitorProcess::GetEventPeriodNumber() const { // get the period number from the event id @@ -385,7 +574,7 @@ UInt_t AliMonitorProcess::GetEventPeriodNumber() } //_____________________________________________________________________________ -UInt_t AliMonitorProcess::GetEventOrbitNumber() +UInt_t AliMonitorProcess::GetEventOrbitNumber() const { // get the orbit number from the event id @@ -393,7 +582,7 @@ UInt_t AliMonitorProcess::GetEventOrbitNumber() } //_____________________________________________________________________________ -UInt_t AliMonitorProcess::GetEventBunchNumber() +UInt_t AliMonitorProcess::GetEventBunchNumber() const { // get the bunch number from the event id @@ -401,7 +590,7 @@ UInt_t AliMonitorProcess::GetEventBunchNumber() } //_____________________________________________________________________________ -Int_t AliMonitorProcess::GetNumberOfEvents(const char* fileName) +Int_t AliMonitorProcess::GetNumberOfEvents(const char* fileName) const { // determine the number of events in the given raw data file @@ -409,14 +598,14 @@ Int_t AliMonitorProcess::GetNumberOfEvents(const char* fileName) 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(); } @@ -427,7 +616,7 @@ Int_t AliMonitorProcess::GetNumberOfEvents(const char* fileName) } //_____________________________________________________________________________ -Bool_t AliMonitorProcess::ReconstructTPC(AliRawReader* rawReader) +Bool_t AliMonitorProcess::ReconstructTPC(AliRawReader* rawReader, AliESDEvent* esd) { // find TPC clusters and tracks @@ -435,14 +624,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(); @@ -451,20 +639,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, AliESDEvent* esd) { // find ITS clusters and tracks @@ -472,77 +658,46 @@ 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); + AliITSclustererV2 clusterer(0); itsLoader->MakeRecPointsContainer(); clusterer.Digits2Clusters(rawReader); // track finder - Info("ReconstructITS", "reconstructing tracks..."); - itsLoader->LoadTracks("recreate"); - itsLoader->MakeTracksContainer(); - tpcLoader->LoadTracks(); - AliITStrackerV2 tracker(fITSgeom); + AliDebug(1, "reconstructing tracks..."); + AliITStrackerV2 tracker(0); 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(AliESDEvent* 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 ENABLE_ALIMONITORPROCESS_HLT //_____________________________________________________________________________ -#ifdef ALI_HLT void AliMonitorProcess::CreateHLT(const char* fileName) { @@ -555,50 +710,63 @@ void AliMonitorProcess::CreateHLT(const char* fileName) fHLT = new AliLevel3(name); fHLT->Init("./", AliLevel3::kRaw, 1); - fHLT->SetClusterFinderParam(0, 0, kTRUE); - - Int_t phi_segments = 50; - Int_t eta_segments = 100; + 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; - Double_t min_pt_fit = 0; - Double_t maxangle = 1.31; + Int_t rowscopetrack = 10; + Double_t minPtFit = 0; + 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 - fHLT->SetTrackerParam(phi_segments, eta_segments, + fHLT->SetTrackerParam(phiSegments, etaSegments, trackletlength, tracklength, rowscopetracklet, rowscopetrack, - min_pt_fit, maxangle, goodDist, hitChi2Cut, + minPtFit, maxangle, goodDist, hitChi2Cut, goodHitChi2, trackChi2Cut, 50, maxphi, maxeta, kTRUE); - - fHLT->WriteFiles("./hlt/"); + + fHLT->WriteFiles("./hlt/"); } -#endif +#endif // ENABLE_ALIMONITORPROCESS_HLT +#ifdef ENABLE_ALIMONITORPROCESS_HLT //_____________________________________________________________________________ -Bool_t AliMonitorProcess::ReconstructHLT( -#ifdef ALI_HLT - Int_t iEvent -#else - /* Int_t iEvent */ -#endif -) +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 AliHLTHough(); + 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 // ENABLE_ALIMONITORPROCESS_HLT + +#ifdef ENABLE_ALIMONITORPROCESS_HLT +//_____________________________________________________________________________ +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; @@ -616,14 +784,112 @@ Bool_t AliMonitorProcess::ReconstructHLT( sprintf(command, "rename tracks_%d tracks hlt/*.raw", iEvent); gSystem->Exec(command); return kTRUE; -#endif } +#endif // ENABLE_ALIMONITORPROCESS_HLT + +#ifdef ENABLE_ALIMONITORPROCESS_HLT +//_____________________________________________________________________________ +Bool_t AliMonitorProcess::ReconstructHLTHough(Int_t iEvent) +{ +// run the HLT Hough transformer + SetStatus(kRecHLT); + + 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 + AliHLTClusterFitter *fitter = new AliHLTClusterFitter("./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,AliHLTTransform::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 < AliHLTTransform::GetNPatches(); ipatch++) + { + // Read digits + fHLTHough->GetMemHandler(ipatch)->Free(); + fHLTHough->GetMemHandler(ipatch)->Init(islice,ipatch); + AliHLTDigitRowData *digits = (AliHLTDigitRowData *)fHLTHough->GetMemHandler(ipatch)->AliAltroDigits2Memory(ndigits,iEvent); + + fitter->Init(islice,ipatch); + fitter->SetInputData(digits); + fitter->FindClusters(); + fitter->WriteClusters(); + } + } + + // Refit of the clusters + AliHLTVertex vertex; + //The seeds are the input tracks from circle HT + AliHLTTrackArray *tracks = fitter->GetSeeds(); + AliHLTFitter *ft = new AliHLTFitter(&vertex,1); + + ft->LoadClusters("./hlt/fitter/",iEvent,kFALSE); + for(Int_t i=0; iGetNTracks(); i++) + { + AliHLTTrack *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 // ENABLE_ALIMONITORPROCESS_HLT //_____________________________________________________________________________ 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_[_].root" // if at least fNEventsMin events were monitored @@ -648,7 +914,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++) { @@ -678,7 +944,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(); @@ -714,47 +980,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; } @@ -762,8 +1037,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); } } @@ -771,27 +1046,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; +}