+
+//_________________________________________________________
+void AliReconstruction::ProcessTriggerAliases()
+{
+ // load trigger aliases, attach them to the reader
+ //
+ fDeclTriggerClasses.Clear();
+ AliCentralTrigger *aCTP = NULL;
+ if (fRawReader) {
+ 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;
+ }
+ }
+ else if (fRunLoader && (!fRunLoader->LoadTrigger())) {
+ aCTP = fRunLoader->GetTrigger();
+ }
+ else {
+ if (fStopOnMissingTriggerFile) AliFatal("No trigger can be loaded! Stopping reconstruction!");
+ AliWarning("No trigger can be loaded! The trigger information will not be used!");
+ return;
+ }
+ //
+ 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;
+ }
+ //
+ // here we have list of active triggers
+ const TObjArray& classesArray = config->GetClasses();
+ Int_t nclasses = classesArray.GetEntriesFast();
+ //
+ fAlias2Trigger = new THashList();
+ //
+ 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 substrungs
+ 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()))) { // account aliases of this trigger >>
+ fDeclTriggerClasses += " ";
+ fDeclTriggerClasses += nmd->GetName();
+ //
+ if (!classesArray.FindObject(nmd->GetName())) continue;
+ TString aliasList(nmd->GetTitle());
+ TObjArray* arrAliases = aliasList.Tokenize(',');
+ Int_t nAliases = arrAliases->GetEntries();
+ // Loop on aliases for the current trigger
+ for(Int_t i=0; i<nAliases; i++){
+ TObjString *alias = (TObjString*) arrAliases->At(i);
+ // Find the current alias in the hash list. If it is not there, add TNamed entry
+ TNamed * inlist = (TNamed*)fAlias2Trigger->FindObject((alias->GetString()).Data());
+ if (!inlist) {
+ inlist = new TNamed((alias->GetString()).Data(),Form(" %s ",nmd->GetName()));
+ fAlias2Trigger->Add(inlist);
+ }
+ else {
+ TString tt(inlist->GetTitle());
+ tt += "||";
+ tt += Form(" %s ",nmd->GetName());
+ inlist->SetTitle(tt.Data());
+ }
+ }
+ delete arrAliases;
+ } // account aliases of this trigger <<
+ }
+ else AliError("Cannot cast the object with trigger aliases to THashList!");
+ }
+ else AliError("No OCDB ebtry for the trigger aliases!");
+ //
+ AliInfo("Aliases defined:");
+ fAlias2Trigger->Print();
+ //
+ if (fRawReader) {
+ // active classes mentioned in the alias will be converted to their masks
+ 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()));
+ fRawReader->LoadTriggerClass(trclass->GetName(),trindex);
+ }
+ if (trclass && trclass->GetMaskNext50()>0) {
+ Int_t trindex = TMath::Nint(TMath::Log2(trclass->GetMaskNext50()))+50;
+ fRawReader->LoadTriggerClass(trclass->GetName(),trindex);
+ }
+ }
+ //
+ // nullify all remaining triggers mentioned in the alias
+ if (!fDeclTriggerClasses.IsNull()) {
+ TObjArray *tokens = fDeclTriggerClasses.Tokenize(" ");
+ Int_t ntokens = tokens->GetEntriesFast();
+ for (Int_t itoken = 0; itoken < ntokens; ++itoken) {
+ fRawReader->LoadTriggerClass((((TObjString*)tokens->At(itoken))->String()).Data(),-1);
+ }
+ delete tokens;
+ }
+ }
+ //
+}
+
+//___________________________________________________
+Bool_t AliReconstruction::TriggerMatches2Alias(const char* trigName, const char* alias)
+{
+ // check if trigger matches to alias
+ TString trName = trigName;
+ if (!fAlias2Trigger) return kFALSE;
+ TNamed* al = (TNamed*)fAlias2Trigger->FindObject(alias);
+ if (!al) return kFALSE;
+ TString altrig = al->GetTitle();
+ return altrig.Contains(Form(" %s ",trigName));
+ //
+}