**************************************************************************/
#include "AliEveEventManager.h"
+#include "AliEveEventSelector.h"
#include "AliEveMacroExecutor.h"
+
+#include <THashList.h>
+#include <TEveElement.h>
#include <TEveManager.h>
+#include <TEveViewer.h>
+#include <AliLog.h>
#include <AliRunLoader.h>
#include <AliRun.h>
#include <AliESDRun.h>
#include <AliESDfriend.h>
#include <AliAODEvent.h>
+#include <AliRecoParam.h>
+#include <AliCentralTrigger.h>
+#include <AliCDBEntry.h>
+#include <AliTriggerClass.h>
+#include <AliTriggerConfiguration.h>
+#include <AliTriggerCluster.h>
+#include <AliDetectorRecoParam.h>
+
#include <AliDAQ.h>
#include <AliRawEventHeaderBase.h>
#include <AliRawReaderRoot.h>
#include <AliMagF.h>
#include <AliCDBManager.h>
#include <AliCDBStorage.h>
-#include <AliCDBEntry.h>
#include <AliGRPObject.h>
#include <AliHeader.h>
#include <AliGeomManager.h>
+#include <AliGRPManager.h>
+#include <AliSysInfo.h>
#include <TFile.h>
#include <TTree.h>
#include <TTimeStamp.h>
#include <TPRegexp.h>
#include <TError.h>
+#include <TEnv.h>
+#include <TString.h>
+#include <TMap.h>
//==============================================================================
//==============================================================================
TString AliEveEventManager::fgESDFileName("AliESDs.root");
TString AliEveEventManager::fgAODFileName("AliAOD.root");
TString AliEveEventManager::fgRawFileName("raw.root");
-TString AliEveEventManager::fgCdbUri("local://$ALICE_ROOT/OCDB");
+TString AliEveEventManager::fgCdbUri;
TList* AliEveEventManager::fgAODfriends = 0;
-AliGRPObject* AliEveEventManager::fgGRPData = 0;
-AliMagF* AliEveEventManager::fgMagField = 0;
-Bool_t AliEveEventManager::fgUniformField = kFALSE;
+Bool_t AliEveEventManager::fgRawFromStandardLoc = kFALSE;
+
+Bool_t AliEveEventManager::fgGRPLoaded = kFALSE;
+AliMagF* AliEveEventManager::fgMagField = 0;
+AliRecoParam* AliEveEventManager::fgRecoParam = 0;
+Bool_t AliEveEventManager::fgUniformField = kFALSE;
AliEveEventManager* AliEveEventManager::fgMaster = 0;
AliEveEventManager* AliEveEventManager::fgCurrent = 0;
fAutoLoadTimer = new TTimer;
fAutoLoadTimer->Connect("Timeout()", "AliEveEventManager", this, "AutoLoadNextEvent()");
+ fAutoLoadTimer->Connect("Timeout()", "AliEveEventManager", this, "Timeout()");
fExecutor = new AliEveMacroExecutor;
fTransientLists = new TEveElementList("Transient Lists", "Containers of transient elements.");
fTransientLists->IncDenyDestroy();
gEve->AddToListTree(fTransientLists, kFALSE);
+
+ fPEventSelector = new AliEveEventSelector(this);
+
+ fGlobal = new TMap; fGlobal->SetOwnerKeyValue();
}
AliEveEventManager::AliEveEventManager(const TString& name) :
fESDFile (0), fESDTree (0), fESD (0),
fESDfriend (0), fESDfriendExists(kFALSE),
fAODFile (0), fAODTree (0), fAOD (0),
- fRawReader (0),
+ fRawReader (0), fEventInfo(),
fAutoLoad (kFALSE), fAutoLoadTime (5.), fAutoLoadTimer(0),
fIsOpen (kFALSE), fHasEvent (kFALSE), fExternalCtrl (kFALSE),
- fSelectOnTriggerType(kFALSE), fTriggerType(""),
+ fGlobal (0), fGlobalReplace (kTRUE), fGlobalUpdate (kTRUE),
fExecutor (0), fTransients(0), fTransientLists(0),
+ fPEventSelector(0),
fSubManagers (0),
fAutoLoadTimerRunning(kFALSE)
{
fESDFile (0), fESDTree (0), fESD (0),
fESDfriend (0), fESDfriendExists(kFALSE),
fAODFile (0), fAODTree (0), fAOD (0),
- fRawReader (0),
+ fRawReader (0), fEventInfo(),
fAutoLoad (kFALSE), fAutoLoadTime (5), fAutoLoadTimer(0),
fIsOpen (kFALSE), fHasEvent (kFALSE), fExternalCtrl (kFALSE),
- fSelectOnTriggerType(kFALSE), fTriggerType(""),
+ fGlobal (0), fGlobalReplace (kTRUE), fGlobalUpdate (kTRUE),
fExecutor (0), fTransients(0), fTransientLists(0),
+ fPEventSelector(0),
fSubManagers (0),
fAutoLoadTimerRunning(kFALSE)
{
AliEveEventManager::~AliEveEventManager()
{
// Destructor.
+ fAutoLoadTimer->Stop();
+ fAutoLoadTimer->Disconnect("Timeout");
delete fSubManagers;
fTransientLists->DecDenyDestroy();
fTransientLists->Destroy();
+
+ //delete fExecutor;
}
/******************************************************************************/
fgAODfriends = new TList;
fgAODfriends->SetOwner(kTRUE);
}
- fgAODfriends->Add(new TObjString(friendFileName));
+ if (fgAODfriends->FindObject(friendFileName) == 0)
+ {
+ fgAODfriends->Add(new TObjString(friendFileName));
+ }
}
void AliEveEventManager::SetRawFileName(const TString& raw)
void AliEveEventManager::SetCdbUri(const TString& cdb)
{
- // Set path to CDB, default "local://$ALICE_ROOT/OCDB".
+ // Set path to CDB, there is no default.
if ( ! cdb.IsNull()) fgCdbUri = cdb;
}
fgAssertRaw = assertRaw;
}
+void AliEveEventManager::SearchRawForCentralReconstruction()
+{
+ // Enable searching of raw data in standard location. The path passed to
+ // Open() is expected to point to a centrally reconstructed run, e.g.:
+ // "alien:///alice/data/2009/LHC09c/000101134/ESDs/pass1/09000101134018.10".
+
+ fgRawFromStandardLoc = kTRUE;
+}
+
/******************************************************************************/
void AliEveEventManager::Open()
// Open ESD and ESDfriends
TString esdPath(Form("%s/%s", fPath.Data(), fgESDFileName.Data()));
+ if (fPath.EndsWith(".zip")) esdPath.Form("%s#%s",fPath.Data(),fgESDFileName.Data());
if ((fESDFile = TFile::Open(esdPath)))
{
fESD = new AliESDEvent();
// We use TFile::Open() instead of gSystem->AccessPathName
// as it seems to work better when attachine alieve to a
// running reconstruction process with auto-save on.
- // There was also a problem with TTree::Refresh() - it didn't
- // save the friend branch on a separate file, fixed in 5.22.2 -
- // so we might want to try the old way again soon.
TString p(Form("%s/AliESDfriends.root", fPath.Data()));
+ if (fPath.EndsWith(".zip")) p.Form("%s#AliESDfriends.root",fPath.Data());
TFile *esdFriendFile = TFile::Open(p);
if (esdFriendFile)
{
// Open AOD and registered friends
TString aodPath(Form("%s/%s", fPath.Data(), fgAODFileName.Data()));
+ if (fPath.EndsWith(".zip")) aodPath.Form("%s#%s",fPath.Data(),fgAODFileName.Data());
if ((fAODFile = TFile::Open(aodPath)))
{
fAOD = new AliAODEvent();
while ((name = (TObjString*) friends()) != 0)
{
TString p(Form("%s/%s", fPath.Data(), name->GetName()));
+ if (fPath.EndsWith(".zip")) p.Form("%s#%s",fPath.Data(),name->GetName());
if (gSystem->AccessPathName(p, kReadPermission) == kFALSE)
{
fAODTree->AddFriend("aodTree", name->GetName());
// Open RunLoader from galice.root
TString gaPath(Form("%s/galice.root", fPath.Data()));
+ if (fPath.EndsWith(".zip")) gaPath.Form("%s#%s",fPath.Data(),"galice.root");
// If i use open directly, we get fatal.
// Is AccessPathName check ok for xrootd / alien? Yes, not for http.
- if (gSystem->AccessPathName(gaPath, kReadPermission) == kFALSE)
- {
+ // Seems not to work for alien anymore.
+ // Fixed in ROOT on 27.10.2009, rev 30888.
+ // To revert after we move to root-5.26.
+ TFile *gafile = TFile::Open(gaPath);
+ if (gafile)
+ {
+ gafile->Close();
+ delete gafile;
+ // if (gSystem->AccessPathName(gaPath, kReadPermission) == kFALSE)
+ // {
fRunLoader = AliRunLoader::Open(gaPath, GetName());
if (fRunLoader)
{
// Open raw-data file
- TString rawPath(Form("%s/%s", fPath.Data(), fgRawFileName.Data()));
+ TString rawPath;
+ if (fgRawFromStandardLoc)
+ {
+ if (!fPath.BeginsWith("alien:"))
+ throw kEH + "Standard raw search requested, but the directory is not in AliEn.";
+ if (!fPath.Contains("/ESDs/"))
+ throw kEH + "Standard raw search requested, but does not contain 'ESDs' directory.";
+
+ TPMERegexp chunk("/([\\d\\.])+/?$");
+ Int_t nm = chunk.Match(fPath);
+ if (nm != 2)
+ throw kEH + "Standard raw search requested, but the path does not end with chunk-id directory.";
+
+ TPMERegexp esdstrip("/ESDs/.*");
+ rawPath = fPath;
+ esdstrip.Substitute(rawPath, "/raw/");
+ rawPath += chunk[0];
+ rawPath += ".root";
+
+ Info(kEH, "Standard raw search requested, using the following path:\n %s\n", rawPath.Data());
+ }
+ else
+ {
+ rawPath.Form("%s/%s", fPath.Data(), fgRawFileName.Data());
+ }
// If i use open directly, raw-reader reports an error but i have
// no way to detect it.
// Is this (AccessPathName check) ok for xrootd / alien? Yes, not for http.
if (fgAssertRaw)
{
throw (kEH + "raw-data not initialized. Its precence was requested.");
- } else {
+ }
+ else
+ {
Warning(kEH, "raw-data not initialized.");
}
}
{
if (fRawReader)
{
- fRawReader->NextEvent();
+ if ( ! fRawReader->NextEvent())
+ {
+ throw (kEH + "can not go to first event in raw-reader to determine run-id.");
+ }
runNo = fRawReader->GetRunNumber();
Info(kEH, "Determining run-no from raw ... run=%d.", runNo);
fRawReader->RewindEvents();
- } else {
+ }
+ else
+ {
throw (kEH + "unknown run number.");
}
}
}
else
{
- cdb->SetDefaultStorage(fgCdbUri);
+ if (fgCdbUri.IsNull())
+ {
+ gEnv->SetValue("Root.Stacktrace", "no");
+ Fatal("Open()", "OCDB path was not specified.");
+ }
+
+ // Handle some special cases for MC (should be in OCDBManager).
+ if (fgCdbUri == "mcideal://")
+ cdb->SetDefaultStorage("MC", "Ideal");
+ else if (fgCdbUri == "mcresidual://")
+ cdb->SetDefaultStorage("MC", "Residual");
+ else if (fgCdbUri == "mcfull://")
+ cdb->SetDefaultStorage("MC", "Full");
+ else if (fgCdbUri == "local://") {
+ fgCdbUri = "local://$ALICE_ROOT/OCDB";
+ cdb->SetDefaultStorage(fgCdbUri);
+ } else
+ cdb->SetDefaultStorage(fgCdbUri);
+
+ cdb->SetRun(runNo);
+
if (cdb->IsDefaultStorageSet() == kFALSE)
- throw (kEH + "CDB initialization failed.");
+ throw kEH + "CDB initialization failed for '" + fgCdbUri + "'.";
+ }
+
+ if (fgCdbUri.BeginsWith("local://"))
+ {
+ TString grp = "GRP/GRP/Data";
+ TString grppath = fPath + "/" + grp;
+ if (gSystem->AccessPathName(grppath, kReadPermission) == kFALSE)
+ {
+ if (cdb->GetSpecificStorage(grp))
+ {
+ Warning(kEH, "Local GRP exists, but the specific storage is already set.");
+ }
+ else
+ {
+ Info(kEH, "Setting CDB specific-storage for GRP from event directory.");
+ TString lpath("local://");
+ lpath += fPath;
+ cdb->SetSpecificStorage(grp, lpath);
+ }
+ }
}
- cdb->SetRun(runNo);
}
fIsOpen = kTRUE;
if (fAutoLoad) StartAutoLoadTimer();
}
-Int_t AliEveEventManager::GetMaxEventId(Bool_t /*refreshESD*/) const
+Int_t AliEveEventManager::GetMaxEventId(Bool_t refreshESD) const
{
// Returns maximum available event id.
// If under external control or event is not opened -1 is returned.
if (fESDTree)
{
- // Refresh crashes with root-5.21.1-alice.
- // Fixed by Philippe 5.8.2008 r25053, can be reactivated
- // when we move to a newer root.
- // if (refreshESD)
- // fESDTree->Refresh();
+ if (refreshESD)
+ {
+ fESDTree->Refresh();
+ fPEventSelector->Update();
+ }
return fESDTree->GetEntries() - 1;
}
else if (fAODTree)
throw (kEH + "Event-files not opened.");
}
+ fEventInfo.Reset();
+
fHasEvent = kFALSE;
Int_t maxEvent = 0;
if (fESDTree)
{
- // Refresh crashes with root-5.21.1-alice.
- // Fixed by Philippe 5.8.2008 r25053, can be reactivated
- // when we move to a newer root.
- // fESDTree->Refresh();
+ if (event >= fESDTree->GetEntries())
+ fESDTree->Refresh();
maxEvent = fESDTree->GetEntries() - 1;
if (event < 0)
event = fESDTree->GetEntries() + event;
event, 0, maxEvent));
}
+ TString sysInfoHeader;
+ sysInfoHeader.Form("AliEveEventManager::GotoEvent(%d) - ", event);
+ AliSysInfo::AddStamp(sysInfoHeader + "Start");
+
TEveManager::TRedrawDisabler rd(gEve);
gEve->Redraw3D(kFALSE, kTRUE); // Enforce drop of all logicals.
// !!! MT this is somewhat brutal; at least optionally, one could be
// a bit gentler, checking for objs owning their external refs and having
// additinal parents.
+ gEve->GetViewers()->DeleteAnnotations();
fTransients->DestroyElements();
for (TEveElement::List_i i = fTransientLists->BeginChildren();
i != fTransientLists->EndChildren(); ++i)
}
DestroyElements();
+ AliSysInfo::AddStamp(sysInfoHeader + "PostDestroy");
+
if (fESDTree) {
if (fESDTree->GetEntry(event) <= 0)
throw (kEH + "failed getting required event from ESD.");
ElementChanged();
}
+ AliSysInfo::AddStamp(sysInfoHeader + "PostLoadEvent");
+
AfterNewEventLoaded();
+
+ AliSysInfo::AddStamp(sysInfoHeader + "PostUserActions");
+}
+
+void AliEveEventManager::Timeout()
+{
+ Emit("Timeout()");
}
void AliEveEventManager::NextEvent()
// so here we should do it in SetEvent().
DestroyElements();
- gSystem->ExitLoop();
+
}
- else
+ else if (fESDTree)
{
- Int_t nexteventbytrigger=0;
- if (fSelectOnTriggerType)
+ Int_t nextevent=0;
+ if (fPEventSelector->FindNext(nextevent))
{
- if (FindNextByTrigger(nexteventbytrigger)) //if not found do nothing
- GotoEvent(nexteventbytrigger);
+ GotoEvent(nextevent);
}
- else if (fEventId < GetMaxEventId(kTRUE))
- GotoEvent(fEventId + 1);
- else
- GotoEvent(0);
+ }
+ else if (fEventId < GetMaxEventId(kTRUE))
+ {
+ GotoEvent(fEventId + 1);
}
}
void AliEveEventManager::PrevEvent()
{
// Loads previous event.
-
+
static const TEveException kEH("AliEveEventManager::PrevEvent ");
if (fAutoLoadTimerRunning)
{
throw (kEH + "Event-loop is under external control.");
}
- Int_t nexteventbytrigger=0;
- if (fSelectOnTriggerType)
+
+ if (fESDTree)
{
- if (FindPrevByTrigger(nexteventbytrigger))
- GotoEvent(nexteventbytrigger);
+ Int_t nextevent=0;
+ if (fPEventSelector->FindPrev(nextevent))
+ {
+ GotoEvent(nextevent);
+ }
}
- else
+ else if (fEventId > 0)
+ {
GotoEvent(fEventId - 1);
+ }
}
void AliEveEventManager::Close()
if (fESDTree) {
delete fESD; fESD = 0;
- delete fESDfriend; fESDfriend = 0;
+ // delete fESDfriend; // friend tree is deleted with the tree
+ fESDfriend = 0;
fESDfriendExists = kFALSE;
delete fESDTree; fESDTree = 0;
// Static convenience functions, mainly used from macros.
//------------------------------------------------------------------------------
+Int_t AliEveEventManager::CurrentEventId()
+{
+ // Return current event-id.
+
+ static const TEveException kEH("AliEveEventManager::CurrentEventId ");
+
+ if (fgCurrent == 0 || fgCurrent->fHasEvent == kFALSE)
+ throw (kEH + "ALICE event not ready.");
+ return fgCurrent->GetEventId();
+}
+
Bool_t AliEveEventManager::HasRunLoader()
{
// Check if AliRunLoader is initialized.
if (fgMagField)
return fgMagField;
- if (fgGRPData == 0)
+ if (TGeoGlobalMagField::Instance()->GetField())
+ {
+ fgMagField = dynamic_cast<AliMagF*>(TGeoGlobalMagField::Instance()->GetField());
+ if (fgMagField == 0)
+ throw kEH + "Global field set, but it is not AliMagF.";
+ return fgMagField;
+ }
+
+ if (!fgGRPLoaded)
{
InitGRP();
}
- if (TGeoGlobalMagField::Instance())
+ if (TGeoGlobalMagField::Instance()->GetField())
{
fgMagField = dynamic_cast<AliMagF*>(TGeoGlobalMagField::Instance()->GetField());
if (fgMagField == 0)
return gGeoManager;
}
+AliRecoParam* AliEveEventManager::AssertRecoParams()
+{
+ if(!fgRecoParam)
+ InitRecoParam();
+
+ return fgRecoParam;
+}
+
+Bool_t AliEveEventManager::InitRecoParam()
+{
+// This is mostly a reap-off from reconstruction
+// The method accesses OCDB and retrieves all
+// the available reco-param objects from there.
+
+ fgRecoParam = new AliRecoParam;
+ const Int_t kNDetectors = 14;
+
+ static const TEveException kEH("AliEveEventManager::InitRecoParam ");
+
+ Bool_t isOK = kTRUE;
+
+ if (fgRecoParam->GetDetRecoParamArray(kNDetectors)) {
+ ::Info(kEH, "Using custom GRP reconstruction parameters");
+ }
+ else {
+ ::Info(kEH, "Loading GRP reconstruction parameter objects");
+
+ AliCDBPath path("GRP","Calib","RecoParam");
+ AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
+ if(!entry){
+ ::Warning(kEH, "Couldn't find GRP RecoParam entry in OCDB");
+ isOK = kFALSE;
+ }
+ else {
+ TObject *recoParamObj = entry->GetObject();
+ if (dynamic_cast<TObjArray*>(recoParamObj)) {
+ // GRP has a normal TobjArray of AliDetectorRecoParam objects
+ // Registering them in AliRecoParam
+ fgRecoParam->AddDetRecoParamArray(kNDetectors,dynamic_cast<TObjArray*>(recoParamObj));
+ }
+ else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
+ // GRP has only onse set of reco parameters
+ // Registering it in AliRecoParam
+ ::Info(kEH, "Single set of GRP reconstruction parameters found");
+ dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
+ fgRecoParam->AddDetRecoParam(kNDetectors,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
+ }
+ else {
+ ::Error(kEH, "No valid GRP RecoParam object found in the OCDB");
+ isOK = kFALSE;
+ }
+ entry->SetOwner(0);
+ }
+ }
+
+ const char* fgkDetectorName[kNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE" };
+
+
+ for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
+
+ if (fgRecoParam->GetDetRecoParamArray(iDet)) {
+ ::Info(kEH, Form("Using custom reconstruction parameters for detector %s",fgkDetectorName[iDet]));
+ continue;
+ }
+
+ ::Info(kEH, Form("Loading reconstruction parameter objects for detector %s",fgkDetectorName[iDet]));
+
+ AliCDBPath path(fgkDetectorName[iDet],"Calib","RecoParam");
+ AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
+ if(!entry){
+ ::Warning(kEH, Form("Couldn't find RecoParam entry in OCDB for detector %s",fgkDetectorName[iDet]));
+ isOK = kFALSE;
+ }
+ else {
+ TObject *recoParamObj = entry->GetObject();
+ if (dynamic_cast<TObjArray*>(recoParamObj)) {
+ // The detector has a normal TobjArray of AliDetectorRecoParam objects
+ // Registering them in AliRecoParam
+ fgRecoParam->AddDetRecoParamArray(iDet,dynamic_cast<TObjArray*>(recoParamObj));
+ }
+ else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
+ // The detector has only onse set of reco parameters
+ // Registering it in AliRecoParam
+ ::Info(kEH, Form("Single set of reconstruction parameters found for detector %s",fgkDetectorName[iDet]));
+ dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
+ fgRecoParam->AddDetRecoParam(iDet,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
+ }
+ else {
+ ::Error(kEH, Form("No valid RecoParam object found in the OCDB for detector %s",fgkDetectorName[iDet]));
+ isOK = kFALSE;
+ }
+ entry->SetOwner(0);
+
+ }
+ }
+
+ if(!isOK) {
+ delete fgRecoParam;
+ fgRecoParam = 0;
+ }
+
+ return isOK;
+}
+
+
//------------------------------------------------------------------------------
AliEveEventManager* AliEveEventManager::AddDependentManager(const TString& name, const TString& path)
}
}
+void AliEveEventManager::SetTrigSel(Int_t trig)
+{
+ static const TEveException kEH("AliEveEventManager::SetTrigSel ");
+
+ if (!fRawReader)
+ {
+ Warning(kEH, "No Raw-reader exists. Ignoring the call.");
+ return;
+ }
+ else
+ {
+ ULong64_t trigMask = 0;
+ if (trig >= 0) trigMask = (1ull << trig);
+ Info(kEH,"Trigger selection: 0x%llx",trigMask);
+ fRawReader->SelectEvents(-1,trigMask,NULL);
+ }
+}
+
void AliEveEventManager::StartAutoLoadTimer()
{
// Start the auto-load timer.
StartAutoLoadTimer();
}
-
-//------------------------------------------------------------------------------
-// Event selection by trigger
-//------------------------------------------------------------------------------
-
-Bool_t AliEveEventManager::FindNextByTrigger(Int_t& event)
-{
- // Find next event that matches the trigger.
- // If a matching event is not found, we loop around and eventually
- // end up at the same event.
-
- static const TEveException kEH("AliEveEventManager::FindNextByTrigger ");
-
- if (!fESDTree) return kFALSE;
- TString firedtrclasses;
- for (Int_t i = fEventId+1; i<GetMaxEventId(kTRUE)+1; i++)
- {
- if (fESDTree->GetEntry(i) <= 0)
- throw (kEH + "failed getting required event from ESD.");
- firedtrclasses = fESD->GetFiredTriggerClasses();
- if (firedtrclasses.Contains(fTriggerType))
- {
- event=i;
- return kTRUE;
- }
- }
- for (Int_t i = 0; i<fEventId+1; i++)
- {
- if (fESDTree->GetEntry(i) <= 0)
- throw (kEH + "failed getting required event from ESD.");
- firedtrclasses = fESD->GetFiredTriggerClasses();
- if (firedtrclasses.Contains(fTriggerType))
- {
- event=i;
- return kTRUE;
- }
- }
- return kFALSE;
-}
-
-Bool_t AliEveEventManager::FindPrevByTrigger(Int_t& event)
-{
- // Find previous event that matches the trigger.
-
- static const TEveException kEH("AliEveEventManager::FindPrevByTrigger ");
-
- if (!fESDTree) return kFALSE;
- TString firedtrclasses;
- for (Int_t i = fEventId-1; i>=0; i--)
- {
- if (fESDTree->GetEntry(i) <= 0)
- throw (kEH + "failed getting required event from ESD.");
- firedtrclasses = fESD->GetFiredTriggerClasses();
- if (firedtrclasses.Contains(fTriggerType))
- {
- event=i;
- return kTRUE;
- }
- }
- for (Int_t i = GetMaxEventId(kTRUE); i>fEventId-1; i--)
- {
- if (fESDTree->GetEntry(i) <= 0)
- throw (kEH + "failed getting required event from ESD.");
- firedtrclasses = fESD->GetFiredTriggerClasses();
- if (firedtrclasses.Contains(fTriggerType))
- {
- event=i;
- return kTRUE;
- }
- }
- return kFALSE;
-}
-
-
//------------------------------------------------------------------------------
// Post event-loading functions
//------------------------------------------------------------------------------
static const TEveException kEH("AliEveEventManager::AfterNewEventLoaded ");
+ NewEventDataLoaded();
+
if (fExecutor)
fExecutor->ExecMacros();
}
}
+void AliEveEventManager::NewEventDataLoaded()
+{
+ // Emit NewEventDataLoaded signal.
+
+ Emit("NewEventDataLoaded()");
+}
+
void AliEveEventManager::NewEventLoaded()
{
// Emit NewEventLoaded signal.
// Event info dumpers
//------------------------------------------------------------------------------
+const AliEventInfo* AliEveEventManager::GetEventInfo()
+{
+ // Fill the event info object
+
+ AliCentralTrigger *aCTP = NULL;
+ if (fRawReader) {
+ fEventInfo.SetEventType(fRawReader->GetType());
+
+ ULong64_t mask = fRawReader->GetClassMask();
+ fEventInfo.SetTriggerMask(mask);
+ UInt_t clmask = fRawReader->GetDetectorPattern()[0];
+ fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(clmask));
+
+ aCTP = new AliCentralTrigger();
+ TString configstr("");
+ if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB
+ AliError("No trigger configuration found in OCDB! The trigger configuration information will not be used!");
+ delete aCTP;
+ return 0;
+ }
+ aCTP->SetClassMask(mask);
+ aCTP->SetClusterMask(clmask);
+
+ if (fRunLoader) {
+ AliCentralTrigger* rlCTP = fRunLoader->GetTrigger();
+ if (rlCTP) {
+ rlCTP->SetClassMask(mask);
+ rlCTP->SetClusterMask(clmask);
+ }
+ }
+ }
+ else {
+ fEventInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
+
+ if (fRunLoader && (!fRunLoader->LoadTrigger())) {
+ aCTP = fRunLoader->GetTrigger();
+ fEventInfo.SetTriggerMask(aCTP->GetClassMask());
+ // get inputs from actp - just get
+ AliESDHeader* esdheader = fESD->GetHeader();
+ esdheader->SetL0TriggerInputs(aCTP->GetL0TriggerInputs());
+ esdheader->SetL1TriggerInputs(aCTP->GetL1TriggerInputs());
+ esdheader->SetL2TriggerInputs(aCTP->GetL2TriggerInputs());
+ fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(aCTP->GetClusterMask()));
+ }
+ else {
+ AliWarning("No trigger can be loaded! The trigger information will not be used!");
+ return 0;
+ }
+ }
+
+ AliTriggerConfiguration *config = aCTP->GetConfiguration();
+ if (!config) {
+ AliError("No trigger configuration has been found! The trigger configuration information will not be used!");
+ if (fRawReader) delete aCTP;
+ return 0;
+ }
+
+ TString declTriggerClasses;
+
+ // Load trigger aliases and declare the trigger classes included in aliases
+ AliCDBEntry * entry = AliCDBManager::Instance()->Get("GRP/CTP/Aliases");
+ if (entry) {
+ THashList * lst = dynamic_cast<THashList*>(entry->GetObject());
+ if (lst) {
+ lst->Sort(kSortDescending); // to avoid problems with substrings
+ if (fRawReader) fRawReader->LoadTriggerAlias(lst);
+ // Now declare all the triggers present in the aliases
+ TIter iter(lst);
+ TNamed *nmd = 0;
+ while((nmd = dynamic_cast<TNamed*>(iter.Next()))){
+ declTriggerClasses += " ";
+ declTriggerClasses += nmd->GetName();
+ }
+ }
+ else {
+ AliError("Cannot cast the object with trigger aliases to THashList!");
+ }
+ }
+ else {
+ AliError("No OCDB entry for the trigger aliases!");
+ }
+
+ // Load trigger classes for this run
+ UChar_t clustmask = 0;
+ TString trclasses;
+ ULong64_t trmask = fEventInfo.GetTriggerMask();
+ const TObjArray& classesArray = config->GetClasses();
+ Int_t nclasses = classesArray.GetEntriesFast();
+ for( Int_t iclass=0; iclass < nclasses; iclass++ ) {
+ AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
+ if (trclass && trclass->GetMask()>0) {
+ Int_t trindex = TMath::Nint(TMath::Log2(trclass->GetMask()));
+ if (fESD) fESD->SetTriggerClass(trclass->GetName(),trindex);
+ if (fRawReader) fRawReader->LoadTriggerClass(trclass->GetName(),trindex);
+ if (trmask & (1ull << trindex)) {
+ trclasses += " ";
+ trclasses += trclass->GetName();
+ trclasses += " ";
+ clustmask |= trclass->GetCluster()->GetClusterMask();
+ }
+ }
+ }
+ fEventInfo.SetTriggerClasses(trclasses);
+
+ if (!aCTP->CheckTriggeredDetectors()) {
+ if (fRawReader) delete aCTP;
+ return 0;
+ }
+
+ if (fRawReader) delete aCTP;
+
+// everything went ok, return pointer
+ return (&fEventInfo);
+}
+
+
TString AliEveEventManager::GetEventInfoHorizontal() const
{
// Dumps the event-header contents in vertical formatting.
static const TEveException kEH("AliEveEventManager::InitGRP ");
- AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
-
- if (entry)
- {
- TMap* m = dynamic_cast<TMap*>(entry->GetObject()); // old GRP entry
-
- if (m)
- {
- ::Info(kEH, "Found a TMap in GRP/GRP/Data, converting it into an AliGRPObject");
- fgGRPData = new AliGRPObject();
- fgGRPData->ReadValuesFromMap(m);
- }
- else
- {
- ::Info(kEH, "Found an AliGRPObject in GRP/GRP/Data, reading it");
- fgGRPData = dynamic_cast<AliGRPObject*>(entry->GetObject()); // new GRP entry
- entry->SetOwner(0);
- }
-
- AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data");
- }
-
- if (!fgGRPData)
- {
- ::Error(kEH, "No GRP entry found in OCDB!");
+ AliGRPManager grpMgr;
+ if (!grpMgr.ReadGRPEntry()) {
return kFALSE;
}
-
- TString lhcState = fgGRPData->GetLHCState();
- if (lhcState==AliGRPObject::GetInvalidString())
- {
- ::Error(kEH, "GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN");
- lhcState = "UNKNOWN";
- }
-
- TString beamType = fgGRPData->GetBeamType();
- if (beamType==AliGRPObject::GetInvalidString())
- {
- ::Error(kEH, "GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN");
- beamType = "UNKNOWN";
- }
-
- Float_t beamEnergy = fgGRPData->GetBeamEnergy();
- if (beamEnergy==AliGRPObject::GetInvalidFloat())
- {
- ::Error(kEH, "GRP/GRP/Data entry: missing value for the beam energy ! Using 0");
- beamEnergy = 0;
- }
- beamEnergy /= 120E3; // energy is provided in MeV*120
-
- TString runType = fgGRPData->GetRunType();
- if (runType==AliGRPObject::GetInvalidString())
- {
- ::Error(kEH, "GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN");
- runType = "UNKNOWN";
- }
-
- Int_t activeDetectors = fgGRPData->GetDetectorMask();
- if (activeDetectors==AliGRPObject::GetInvalidUInt())
- {
- ::Error(kEH, "GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399");
- activeDetectors = 1074790399;
+ fgGRPLoaded = kTRUE;
+ if (!grpMgr.SetMagField()) {
+ throw kEH + "Setting of field failed!";
}
-
- // Might become useful.
- /*
- fRunInfo = new AliRunInfo(lhcState, beamType, beamEnergy, runType, activeDetectors);
- printf("AliRunInfo - %s %s %f %s %d\n", lhcState.Data(), beamType.Data(), beamEnergy, runType.Data(), activeDetectors);
- fRunInfo->Dump();
-
-
- // Process the list of active detectors
- if (activeDetectors) {
- UInt_t detMask = activeDetectors;
- fRunLocalReconstruction = MatchDetectorList(fRunLocalReconstruction,detMask);
- fRunTracking = MatchDetectorList(fRunTracking,detMask);
- fFillESD = MatchDetectorList(fFillESD,detMask);
- fQADetectors = MatchDetectorList(fQADetectors,detMask);
- fLoadCDB.Form("%s %s %s %s",
- fRunLocalReconstruction.Data(),
- fRunTracking.Data(),
- fFillESD.Data(),
- fQADetectors.Data());
- fLoadCDB = MatchDetectorList(fLoadCDB,detMask);
- if (!((detMask >> AliDAQ::DetectorID("ITSSPD")) & 0x1)) {
- // switch off the vertexer
- ::Info(kEH, "SPD is not in the list of active detectors. Vertexer switched off.");
- fRunVertexFinder = kFALSE;
- }
- if (!((detMask >> AliDAQ::DetectorID("TRG")) & 0x1)) {
- // switch off the reading of CTP raw-data payload
- if (fFillTriggerESD) {
- ::Info(kEH, "CTP is not in the list of active detectors. CTP data reading switched off.");
- fFillTriggerESD = kFALSE;
- }
- }
- }
-
- ::Info(kEH, "===================================================================================");
- ::Info(kEH, "Running local reconstruction for detectors: %s",fRunLocalReconstruction.Data());
- ::Info(kEH, "Running tracking for detectors: %s",fRunTracking.Data());
- ::Info(kEH, "Filling ESD for detectors: %s",fFillESD.Data());
- ::Info(kEH, "Quality assurance is active for detectors: %s",fQADetectors.Data());
- ::Info(kEH, "CDB and reconstruction parameters are loaded for detectors: %s",fLoadCDB.Data());
- ::Info(kEH, "===================================================================================");
- */
-
- //*** Dealing with the magnetic field map
- if (TGeoGlobalMagField::Instance()->IsLocked())
- {
- ::Info(kEH, "Running with externally locked B field!");
- }
- else
- {
- // Construct the field map out of the information retrieved from GRP.
-
- Float_t l3Current = fgGRPData->GetL3Current((AliGRPObject::Stats)0);
- if (l3Current == AliGRPObject::GetInvalidFloat())
- throw kEH + "GRPData entry: missing value for the L3 current!";
-
- Char_t l3Polarity = fgGRPData->GetL3Polarity();
- if (l3Polarity == AliGRPObject::GetInvalidChar())
- throw kEH + "GRPData entry: missing value for the L3 polarity!";
-
- Float_t diCurrent = fgGRPData->GetDipoleCurrent((AliGRPObject::Stats)0);
- if (diCurrent == AliGRPObject::GetInvalidFloat())
- throw kEH + "GRPData entry: missing value for the dipole current!";
-
- Char_t diPolarity = fgGRPData->GetDipolePolarity();
- if (diPolarity == AliGRPObject::GetInvalidChar())
- throw kEH + "GRPData entry: missing value for the dipole polarity!";
-
- if (!SetFieldMap(l3Current, diCurrent, l3Polarity ? -1:1, diPolarity ? -1:1))
- throw kEH + "Failed to create B field map!";
-
- ::Info(kEH, "Running with the B field constructed from GRP.");
- }
-
//*** Get the diamond profiles from OCDB
// Eventually useful.
return kTRUE;
}
-Bool_t AliEveEventManager::SetFieldMap(Float_t l3Cur, Float_t diCur,
- Float_t l3Pol, Float_t diPol,
- Float_t beamenergy,
- const Char_t *beamtype,
- const Char_t *path)
-{
- //------------------------------------------------
- // The magnetic field map, defined externally...
- // L3 current 30000 A -> 0.5 T
- // L3 current 12000 A -> 0.2 T
- // dipole current 6000 A
- // The polarities must be the same
- //------------------------------------------------
-
- static const TEveException kEH("AliEveEventManager::SetFieldMap ");
-
- const Float_t l3NominalCurrent1 = 30000.0; // (A)
- const Float_t l3NominalCurrent2 = 12000.0; // (A)
- const Float_t diNominalCurrent = 6000.0; // (A)
-
- const Float_t tolerance = 0.03; // relative current tolerance
- const Float_t zero = 77.0; // "zero" current (A)
-
- TString s = (l3Pol < 0) ? "L3: -" : "L3: +";
-
- AliMagF::BMap_t map = AliMagF::k5kG;
-
- double fcL3, fcDip;
-
- l3Cur = TMath::Abs(l3Cur);
- if (TMath::Abs(l3Cur-l3NominalCurrent1)/l3NominalCurrent1 < tolerance)
- {
- fcL3 = l3Cur/l3NominalCurrent1;
- map = AliMagF::k5kG;
- s += "0.5 T; ";
- }
- else if (TMath::Abs(l3Cur-l3NominalCurrent2)/l3NominalCurrent2 < tolerance)
- {
- fcL3 = l3Cur/l3NominalCurrent2;
- map = AliMagF::k2kG;
- s += "0.2 T; ";
- }
- else if (l3Cur <= zero)
- {
- fcL3 = 0;
- map = AliMagF::k5kGUniform;
- s += "0.0 T; ";
- fgUniformField = kTRUE; // track with the uniform (zero) B field
- }
- else
- {
- ::Error(kEH, "Wrong L3 current (%f A)!", l3Cur);
- return kFALSE;
- }
-
- diCur = TMath::Abs(diCur);
- if (TMath::Abs(diCur-diNominalCurrent)/diNominalCurrent < tolerance)
- {
- // 3% current tolerance...
- fcDip = diCur/diNominalCurrent;
- s += "Dipole ON";
- }
- else if (diCur <= zero)
- { // some small current..
- fcDip = 0.;
- s += "Dipole OFF";
- }
- else
- {
- ::Error(kEH, "Wrong dipole current (%f A)!", diCur);
- return kFALSE;
- }
+//------------------------------------
+// Global variables management
+//------------------------------------
- if (l3Pol != diPol && (map==AliMagF::k5kG || map==AliMagF::k2kG) && fcDip != 0)
- {
- ::Error(kEH, "L3 and Dipole polarities must be the same");
- return kFALSE;
- }
-
- if (l3Pol<0) fcL3 = -fcL3;
- if (diPol<0) fcDip = -fcDip;
-
- AliMagF::BeamType_t btype = AliMagF::kNoBeamField;
- TString btypestr = beamtype;
- btypestr.ToLower();
-
- TPRegexp protonBeam("(proton|p)\\s*-?\\s*\\1");
- TPRegexp ionBeam ("(lead|pb|ion|a)\\s*-?\\s*\\1");
-
- if (btypestr.Contains(ionBeam))
- btype = AliMagF::kBeamTypeAA;
- else if (btypestr.Contains(protonBeam))
- btype = AliMagF::kBeamTypepp;
- else
- ::Info(kEH, "Cannot determine the beam type from %s, assume no LHC magnet field",
- beamtype);
+Bool_t AliEveEventManager::InsertGlobal(const TString& tag, TEveElement* model)
+{
+ // Insert a new visualization-parameter database entry with the default
+ return InsertGlobal(tag, model, fGlobalReplace, fGlobalUpdate);
+}
- AliMagF* fld = new AliMagF("MagneticFieldMap", s.Data(), 2, fcL3, fcDip, 10., map, path,
- btype,beamenergy);
- TGeoGlobalMagField::Instance()->SetField(fld);
- TGeoGlobalMagField::Instance()->Lock();
+Bool_t AliEveEventManager::InsertGlobal(const TString& tag, TEveElement* model,
+ Bool_t replace, Bool_t update)
+{
+ TPair* pair = (TPair*) fGlobal->FindObject(tag);
+ if (pair)
+ {
+ if (replace)
+ {
+ model->IncDenyDestroy();
+ model->SetRnrChildren(kFALSE);
+
+ TEveElement* old_model = dynamic_cast<TEveElement*>(pair->Value());
+ if(!old_model) AliFatal("old_model == 0, dynamic cast failed\n");
+ while (old_model->HasChildren())
+ {
+ TEveElement *el = old_model->FirstChild();
+ el->SetVizModel(model);
+ if (update)
+ {
+ el->CopyVizParams(model);
+ el->PropagateVizParamsToProjecteds();
+ }
+ }
+ old_model->DecDenyDestroy();
+
+ pair->SetValue(dynamic_cast<TObject*>(model));
+ return kTRUE;
+ }
+ else
+ {
+ return kFALSE;
+ }
+ }
+ else
+ {
+ model->IncDenyDestroy();
+ model->SetRnrChildren(kFALSE);
+ fGlobal->Add(new TObjString(tag), dynamic_cast<TObject*>(model));
+ return kTRUE;
+ }
+}
- return kTRUE;
+TEveElement* AliEveEventManager::FindGlobal(const TString& tag)
+{
+ return dynamic_cast<TEveElement*>(fGlobal->GetValue(tag));
}