#include "AliLHCData.h"
#include "ARVersion.h"
#include <RVersion.h>
+#include <unistd.h>
+#include <sys/resource.h>
ClassImp(AliReconstruction)
//_____________________________________________________________________________
+const char* AliReconstruction::fgkStopEvFName = "_stopEvent_";
const char* AliReconstruction::fgkDetectorName[AliReconstruction::kNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE"
// #ifdef MFT_UPGRADE
// , "MFT"
fRunLocalReconstruction("ALL"),
fRunTracking("ALL"),
fFillESD("ALL"),
+ fDeleteRecPoints(""),
+ fDeleteDigits(""),
fLoadCDB(""),
fUseTrackingErrorsForAlignment(""),
fGAliceFileName(gAliceFilename),
fAnalysisMacro(),
fAnalysis(0),
fRecoHandler(0),
- fDeclTriggerClasses("")
+ fDeclTriggerClasses(""),
+ fStopped(kFALSE),
+ fMaxRSS(0),
+ fMaxVMEM(0)
{
// create reconstruction object with default parameters
gGeoManager = NULL;
fRunLocalReconstruction(rec.fRunLocalReconstruction),
fRunTracking(rec.fRunTracking),
fFillESD(rec.fFillESD),
+ fDeleteRecPoints(""),
+ fDeleteDigits(""),
fLoadCDB(rec.fLoadCDB),
fUseTrackingErrorsForAlignment(rec.fUseTrackingErrorsForAlignment),
fGAliceFileName(rec.fGAliceFileName),
fAnalysisMacro(rec.fAnalysisMacro),
fAnalysis(0),
fRecoHandler(0),
- fDeclTriggerClasses(rec.fDeclTriggerClasses)
+ fDeclTriggerClasses(rec.fDeclTriggerClasses),
+ fStopped(kFALSE),
+ fMaxRSS(0),
+ fMaxVMEM(0)
{
// copy constructor
fRunLocalReconstruction = rec.fRunLocalReconstruction;
fRunTracking = rec.fRunTracking;
fFillESD = rec.fFillESD;
+ fDeleteRecPoints = rec.fDeleteRecPoints;
+ fDeleteDigits = rec.fDeleteDigits;
fLoadCDB = rec.fLoadCDB;
fUseTrackingErrorsForAlignment = rec.fUseTrackingErrorsForAlignment;
fGAliceFileName = rec.fGAliceFileName;
AliSysInfo::AddStamp("InitCDB");
}
+//_____________________________________________________________________________
+void AliReconstruction::SetCDBSnapshotMode(const char* snapshotFileName) {
+ AliCDBManager::Instance()->SetSnapshotMode(snapshotFileName);
+}
+
//_____________________________________________________________________________
void AliReconstruction::SetDefaultStorage(const char* uri) {
// Store the desired default CDB storage location
fRunTracking = MatchDetectorList(fRunTracking,detMask);
fFillESD = MatchDetectorList(fFillESD,detMask);
fQADetectors = MatchDetectorList(fQADetectors,detMask);
+ fDeleteRecPoints = MatchDetectorList(fDeleteRecPoints,detMask);
+ fDeleteDigits = MatchDetectorList(fDeleteDigits,detMask);
fLoadCDB.Form("%s %s %s %s",
fRunLocalReconstruction.Data(),
fRunTracking.Data(),
Int_t iEvent = 0;
while ((iEvent < fRunLoader->GetNumberOfEvents()) ||
(fRawReader && fRawReader->NextEvent())) {
+ //
+ // check if process has enough resources
+ if (!HasEnoughResources(iEvent)) break;
if (!ProcessEvent(iEvent)) {
Abort("ProcessEvent",TSelector::kAbortFile);
return kFALSE;
return;
}
+ if(fFromCDBSnapshot){
+ AliDebug(2,"Initializing from a CDB snapshot");
+ if(!AliCDBManager::Instance()->InitFromSnapshot(fSnapshotFileName.Data()))
+ AliFatal("Was not able to initialize from the snapshot!");
+ }
// Set CDB lock: from now on it is forbidden to reset the run number
// or the default storage or to activate any further storage!
SetCDBLock();
AliSysInfo::AddStamp("CheckGeom");
}
- Bool_t loadedFromSnapshot=kFALSE;
Bool_t toCDBSnapshot=kFALSE;
TString snapshotFileOut(""); // we could use fSnapshotFileName if we are not interested
// in reading from and writing to a snapshot file at the same time
else
snapshotFileOut="OCDB.root";
}
- if(fFromCDBSnapshot){
- AliDebug(2,"Initializing from a CDB snapshot");
- loadedFromSnapshot = AliCDBManager::Instance()->InitFromSnapshot(fSnapshotFileName.Data());
- }
if (!MisalignGeometry(fLoadAlignData)) {
Abort("MisalignGeometry", TSelector::kAbortProcess);
AliSysInfo::AddStamp("InitGRP");
if(!toCDBSnapshot) AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
- if(!loadedFromSnapshot){
+ if(!fFromCDBSnapshot){
if (!LoadCDB()) {
Abort("LoadCDB", TSelector::kAbortProcess);
return;
AliSysInfo::AddStamp("InitRecoParams");
if(toCDBSnapshot)
- AliCDBManager::Instance()->DumpToSnapshotFile(snapshotFileOut.Data());
+ AliCDBManager::Instance()->DumpToSnapshotFile(snapshotFileOut.Data(),kFALSE);
AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
currTree->SetBranchAddress("rawevent",&event);
currTree->GetEntry(entry);
fRawReader = new AliRawReaderRoot(event);
+ // check if process has enough resources
+ if (!HasEnoughResources(entry)) return kFALSE;
fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents());
delete fRawReader;
fRawReader = NULL;
const Double_t kRadius = 2.8; //something less than the beam pipe radius
TObjArray trkArray;
- UShort_t *selectedIdx=new UShort_t[ntracks];
+ UShort_t selectedIdx[ntracks];
for (Int_t itrack=0; itrack<ntracks; itrack++){
const Double_t kMaxStep = 1; //max step over the material
AliSysInfo::AddStamp(Form("VtxTPC_%d",iEvent), 0,0,iEvent);
}
- delete[] selectedIdx;
-
+
if(fDiamondProfile && fDiamondProfile->GetXRes()<kRadius) fesd->SetDiamond(fDiamondProfile);
else fesd->SetDiamond(fDiamondProfileSPD);
// get cuts for V0vertexer from AliGRPRecoParam
if (grpRecoParam) {
Int_t nCutsV0vertexer = grpRecoParam->GetVertexerV0NCuts();
- Double_t *cutsV0vertexer = new Double_t[nCutsV0vertexer];
+ Double_t cutsV0vertexer[nCutsV0vertexer];
grpRecoParam->GetVertexerV0Cuts(cutsV0vertexer);
vtxer.SetCuts(cutsV0vertexer);
- delete [] cutsV0vertexer; cutsV0vertexer = NULL;
}
vtxer.Tracks2V0vertices(fesd);
AliSysInfo::AddStamp(Form("V0Finder_%d",iEvent), 0,0,iEvent);
// get cuts for CascadeVertexer from AliGRPRecoParam
if (grpRecoParam) {
Int_t nCutsCascadeVertexer = grpRecoParam->GetVertexerCascadeNCuts();
- Double_t *cutsCascadeVertexer = new Double_t[nCutsCascadeVertexer];
+ Double_t cutsCascadeVertexer[nCutsCascadeVertexer];
grpRecoParam->GetVertexerCascadeCuts(cutsCascadeVertexer);
cvtxer.SetCuts(cutsCascadeVertexer);
- delete [] cutsCascadeVertexer; cutsCascadeVertexer = NULL;
}
cvtxer.V0sTracks2CascadeVertices(fesd);
AliSysInfo::AddStamp(Form("CascadeFinder_%d",iEvent), 0,0,iEvent);
AliSysInfo::AddStamp(Form("Analysis_%d",iEvent), 0,0,iEvent);
}
//
- if (fWriteESDfriend)
- fesd->GetESDfriend(fesdf);
-
- ftree->Fill();
- if (fWriteESDfriend) {
- WriteESDfriend();
- }
- // Auto-save the ESD tree in case of prompt reco @P2
- if (fRawReader && fRawReader->UseAutoSaveESD()) {
- ftree->AutoSave("SaveSelf");
- if (fWriteESDfriend) ftreeF->AutoSave("SaveSelf");
- }
-
+ if (fWriteESDfriend) {
+ fesd->GetESDfriend(fesdf);
+ AliSysInfo::AddStamp(Form("CreateFriend_%d",iEvent), 0,0,iEvent);
+
+ }
+ //
+ ftree->Fill();
+ AliSysInfo::AddStamp(Form("ESDFill_%d",iEvent), 0,0,iEvent);
+ //
+ if (fWriteESDfriend) {
+ WriteESDfriend();
+ AliSysInfo::AddStamp(Form("WriteFriend_%d",iEvent), 0,0,iEvent);
+ }
+ //
+ //
+ // Auto-save the ESD tree in case of prompt reco @P2
+ if (fRawReader && fRawReader->UseAutoSaveESD()) {
+ ftree->AutoSave("SaveSelf");
+ if (fWriteESDfriend) ftreeF->AutoSave("SaveSelf");
+ }
// write HLT ESD
fhlttree->Fill();
- AliSysInfo::AddStamp(Form("WriteESDs_%d",iEvent), 0,0,iEvent);
-
// call AliEVE
if (fRunAliEVE) RunAliEVE();
//
if (fRunQA || fRunGlobalQA)
AliQAManager::QAManager()->Increment() ;
- return kTRUE;
+ DeleteRecPoints(fDeleteRecPoints);
+ DeleteDigits(fDeleteDigits);
+ //
+ return kTRUE;
}
//_____________________________________________________________________________
esdheader->AddTriggerIR(input.GetIR(i));
}
AliCentralTrigger* rlCTP = fRunLoader->GetTrigger();
- rlCTP->SetL0TriggerInputs(input.GetL0Inputs());
- rlCTP->SetL1TriggerInputs(input.GetL1Inputs());
- rlCTP->SetL2TriggerInputs(input.GetL2Inputs());
+ if (rlCTP) {
+ rlCTP->SetL0TriggerInputs(input.GetL0Inputs());
+ rlCTP->SetL1TriggerInputs(input.GetL1Inputs());
+ rlCTP->SetL2TriggerInputs(input.GetL2Inputs());
+ }
}
if (fIsNewRunLoader) fRunLoader->TreeCT()->Fill();
}
aCTP->SetClusterMask(clmask);
AliCentralTrigger* rlCTP = fRunLoader->GetTrigger();
- rlCTP->SetClassMask(mask);
- rlCTP->SetClusterMask(clmask);
+ if (rlCTP) {
+ rlCTP->SetClassMask(mask);
+ rlCTP->SetClusterMask(clmask);
+ }
}
else {
fEventInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
new (fesdf) AliESDfriend(); // Reset...
fesdf->SetSkipBit(kTRUE);
}
-
+ //
ftreeF->Fill();
}
+
+//_________________________________________________________________
+void AliReconstruction::DeleteDigits(const TString& detectors)
+{
+ // delete requested digit files produced at current event
+ static int iEvent = 0;
+ if (detectors.IsNull()) return;
+ TString detStr = detectors;
+ AliInfo(Form("Deleting Digits: %s",detectors.Data()));
+
+ for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
+ gSystem->Exec(Form("if [ -e %s.Digits.root ]; then\nrm %s.Digits.root\nfi",
+ fgkDetectorName[iDet],fgkDetectorName[iDet]));
+ }
+ AliSysInfo::AddStamp(Form("DelDigits_%d",iEvent), 0,0,iEvent);
+ iEvent++;
+}
+
+//_________________________________________________________________
+void AliReconstruction::DeleteRecPoints(const TString& detectors)
+{
+ // delete requested recpoint files produced at current event
+ static int iEvent = 0;
+ if (detectors.IsNull()) return;
+ TString detStr = detectors;
+ AliInfo(Form("Deleting Recpoints: %s",detectors.Data()));
+ //
+ for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
+ gSystem->Exec(Form("if [ -e %s.RecPoints.root ]; then\nrm %s.RecPoints.root\nfi",
+ fgkDetectorName[iDet],fgkDetectorName[iDet]));
+ }
+ AliSysInfo::AddStamp(Form("DelRecPoints_%d",iEvent), 0,0,iEvent);
+ iEvent++;
+}
+
+//_________________________________________________________________
+void AliReconstruction::SetStopOnResourcesExcess(Int_t vRSS,Int_t vVMEM)
+{
+ // require checking the resources left and stopping on excess
+ // if 0 : no check is done
+ // if >0 : stop reconstruction if exceeds this value
+ // if <0 : use as margin to system limits
+ //
+ const int kKB2MB = 1024;
+ const int kInfMem = 9999999;
+ //
+ struct rlimit r;
+ int pgSize = getpagesize();
+ //
+ if (vRSS>0) {
+ fMaxRSS = vRSS;
+ AliInfo(Form("Setting max. RSS usage to user value %d MB",fMaxRSS));
+ }
+ else if (vRSS<0) {
+ getrlimit(RLIMIT_RSS,&r);
+ fMaxRSS = r.rlim_max==RLIM_INFINITY ? kInfMem : int(r.rlim_max*pgSize/kKB2MB/kKB2MB) + vRSS;
+ AliInfo(Form("Setting max. RSS usage to system hard limit %d%s MB (%d margin)",fMaxRSS,r.rlim_max==RLIM_INFINITY ? "(inf)":"",-vRSS));
+ }
+ else {AliInfo("No check on RSS memory usage will be applied");}
+ //
+ if (vVMEM>0) {
+ fMaxVMEM = vVMEM;
+ AliInfo(Form("Setting max. VMEM usage to user value %d MB",fMaxVMEM));
+ }
+ else if (vVMEM<0) {
+ getrlimit(RLIMIT_AS,&r);
+ fMaxVMEM = r.rlim_max==RLIM_INFINITY ? kInfMem : int(r.rlim_max*pgSize/kKB2MB/kKB2MB) + vVMEM;
+ AliInfo(Form("Setting max. VMEM usage to system hard limit %d%s MB (%d margin)",fMaxVMEM,r.rlim_max==RLIM_INFINITY ? "(inf)":"",-vVMEM));
+ }
+ else {AliInfo("No check on RSS memory usage will be applied");}
+ //
+}
+
+//_________________________________________________________________
+Bool_t AliReconstruction::HasEnoughResources(int ev)
+{
+ // check if process consumed more than allowed resources
+ const int kKB2MB = 1024;
+ Bool_t res = kTRUE;
+ if (!fMaxRSS && !fMaxVMEM) return res;
+ //
+ ProcInfo_t procInfo;
+ gSystem->GetProcInfo(&procInfo);
+ if (procInfo.fMemResident/kKB2MB > fMaxRSS) res = kFALSE;
+ if (procInfo.fMemVirtual/kKB2MB > fMaxVMEM) res = kFALSE;
+ //
+ if (!res) {
+ AliInfo(Form("Job exceeded allowed limits: RSS:%d (%d) VMEM:%d (%d), will stop",
+ int(procInfo.fMemResident/kKB2MB),fMaxRSS,
+ int(procInfo.fMemVirtual/kKB2MB) ,fMaxVMEM));
+ //
+ gSystem->Exec(Form("if [ -e %s ]; then\nrm %s\nfi\necho %d > %s",fgkStopEvFName,fgkStopEvFName,ev,fgkStopEvFName));
+ fStopped = kTRUE;
+ }
+ return res;
+}