X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=STEER%2FSTEER%2FAliReconstruction.cxx;h=a488e55d3dcad54c6036e24e22f22914a39a72fa;hb=505082ca8342af96dfa846b99b64d1bc34ef9f1b;hp=3b2a024ace4c48df86f2ee2bac9fb32c501efb72;hpb=91772e6ba2bbd76280f82039bfaec5f0f50aa37d;p=u%2Fmrichter%2FAliRoot.git diff --git a/STEER/STEER/AliReconstruction.cxx b/STEER/STEER/AliReconstruction.cxx index 3b2a024ace4..a488e55d3dc 100644 --- a/STEER/STEER/AliReconstruction.cxx +++ b/STEER/STEER/AliReconstruction.cxx @@ -238,6 +238,8 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) : fDmax(50.), fZmax(50.), + fCosmicAlias("kCosmic"), + fLaserAlias("kCalibLaser"), fRunLocalReconstruction("ALL"), fRunTracking("ALL"), fFillESD("ALL"), @@ -278,7 +280,8 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) : fDiamondProfileSPD(NULL), fDiamondProfile(NULL), fDiamondProfileTPC(NULL), - fListOfCosmicTriggers(NULL), + fListOfCosmicTriggers(NULL), //RS for BWD comp. + fAlias2Trigger(NULL), fGRPData(NULL), @@ -334,7 +337,7 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) : fMaxVMEM(0) { // create reconstruction object with default parameters - gGeoManager = NULL; + AliGeomManager::Destroy(); for (Int_t iDet = 0; iDet < kNDetectors; iDet++) { fReconstructor[iDet] = NULL; @@ -375,6 +378,8 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) : fDmax(rec.fDmax), fZmax(rec.fZmax), + fCosmicAlias(rec.fCosmicAlias), + fLaserAlias(rec.fLaserAlias), fRunLocalReconstruction(rec.fRunLocalReconstruction), fRunTracking(rec.fRunTracking), fFillESD(rec.fFillESD), @@ -415,7 +420,8 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) : fDiamondProfileSPD(rec.fDiamondProfileSPD), fDiamondProfile(rec.fDiamondProfile), fDiamondProfileTPC(rec.fDiamondProfileTPC), - fListOfCosmicTriggers(NULL), + fListOfCosmicTriggers(NULL), //RS for BWD comp. + fAlias2Trigger(NULL), fGRPData(NULL), @@ -530,6 +536,9 @@ AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec) fDmax = rec.fDmax; fZmax = rec.fZmax; + fCosmicAlias = rec.fCosmicAlias; + fLaserAlias = rec.fLaserAlias; + fRunLocalReconstruction = rec.fRunLocalReconstruction; fRunTracking = rec.fRunTracking; fFillESD = rec.fFillESD; @@ -600,6 +609,9 @@ AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec) delete fListOfCosmicTriggers; fListOfCosmicTriggers = NULL; if (rec.fListOfCosmicTriggers) fListOfCosmicTriggers = (THashTable*)((rec.fListOfCosmicTriggers)->Clone()); + // + delete fAlias2Trigger; fAlias2Trigger = NULL; + if (rec.fAlias2Trigger) fAlias2Trigger = (THashList*)((rec.fAlias2Trigger)->Clone()); delete fGRPData; fGRPData = NULL; // if (rec.fGRPData) fGRPData = (TMap*)((rec.fGRPData)->Clone()); @@ -671,6 +683,10 @@ AliReconstruction::~AliReconstruction() fListOfCosmicTriggers->Delete(); delete fListOfCosmicTriggers; } + if (fAlias2Trigger) { + fAlias2Trigger->Delete(); + delete fAlias2Trigger; + } delete fGRPData; delete fRunScalers; delete fCTPTimeParams; @@ -822,8 +838,9 @@ void AliReconstruction::InitCDB() //_____________________________________________________________________________ void AliReconstruction::SetCDBSnapshotMode(const char* snapshotFileName) { + if (!AliCDBManager::Instance()->SetSnapshotMode(snapshotFileName)) + AliFatal("Setting CDB snapshot mode failed."); fCDBSnapshotMode = kTRUE; - AliCDBManager::Instance()->SetSnapshotMode(snapshotFileName); } //_____________________________________________________________________________ @@ -1319,16 +1336,6 @@ Bool_t AliReconstruction::InitGRP() { AliError("No TPC diamond profile found in OCDB!"); } - entry = AliCDBManager::Instance()->Get("GRP/Calib/CosmicTriggers"); - if (entry) { - fListOfCosmicTriggers = dynamic_cast(entry->GetObject()); - entry->SetOwner(0); - } - - if (!fListOfCosmicTriggers) { - AliWarning("Can not get list of cosmic triggers from OCDB! Cosmic event specie will be effectively disabled!"); - } - return kTRUE; } @@ -1359,6 +1366,17 @@ Bool_t AliReconstruction::LoadCDB() AliCDBManager::Instance()->GetAll("TRIGGER/*/*"); AliCDBManager::Instance()->GetAll("HLT/*/*"); + AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/Calib/CosmicTriggers"); + if (entry) { + fListOfCosmicTriggers = dynamic_cast(entry->GetObject()); + entry->SetOwner(0); + } + // + if (!fListOfCosmicTriggers) { + AliWarning("Can not get list of cosmic triggers from OCDB! Cosmic event specie will rely on aliases if defined"); + } + + return kTRUE; } //_____________________________________________________________________________ @@ -1590,7 +1608,9 @@ void AliReconstruction::InitRun(const char* input) // 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(); - + // + ProcessTriggerAliases(); + // } //_____________________________________________________________________________ @@ -1641,15 +1661,34 @@ void AliReconstruction::Begin(TTree *) snapshotFileOut="OCDB.root"; } - if (!MisalignGeometry(fLoadAlignData)) { - Abort("MisalignGeometry", TSelector::kAbortProcess); - return; + TString detStr(fLoadAlignData); + if (!toCDBSnapshot) { + if (!MisalignGeometry(fLoadAlignData)) { + Abort("MisalignGeometry", TSelector::kAbortProcess); + return; + } + } else { + // when creating the snapshot, load the CDB alignment objects without applying them to the geometry + for (Int_t iDet = 0; iDet < kNDetectors; iDet++) { + if (!IsSelected(fgkDetectorName[iDet], detStr)) continue; + if (!strcmp(fgkDetectorName[iDet],"HLT")) continue; + if (AliGeomManager::GetNalignable(fgkDetectorName[iDet]) != 0) + { + TString detAlignPath = fgkDetectorName[iDet]; + detAlignPath += "/Align/Data"; + AliCDBManager::Instance()->Get(detAlignPath); + } + } // end loop over detectors + if(AliGeomManager::GetNalignable("GRP") != 0) + AliCDBManager::Instance()->Get("GRP/Align/Data"); } const TMap* cdbCache = AliCDBManager::Instance()->GetEntryCache(); - if(cdbCache->Contains("GRP/Geometry/Data")) - AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data"); - if(!toCDBSnapshot) AliCDBManager::Instance()->UnloadFromCache("*/Align/*"); + if(!toCDBSnapshot) { + if(cdbCache->Contains("GRP/Geometry/Data")) + AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data"); + AliCDBManager::Instance()->UnloadFromCache("*/Align/*"); + } AliSysInfo::AddStamp("MisalignGeom"); if (!InitGRP()) { @@ -1941,7 +1980,7 @@ Bool_t AliReconstruction::Process(Long64_t entry) AliRawVEvent *event = NULL; currTree->SetBranchAddress("rawevent",&event); currTree->GetEntry(entry); - fRawReader = new AliRawReaderRoot(event); + fRawReader = new AliRawReaderRoot(event,entry); // check if process has enough resources if (!HasEnoughResources(entry)) return kFALSE; fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents()); @@ -1949,6 +1988,8 @@ Bool_t AliReconstruction::Process(Long64_t entry) fRawReader = NULL; delete event; + if (!fStatus) Abort("ProcessEvent",TSelector::kAbortFile); + CleanProcessedEvent(); return fStatus; } @@ -2012,9 +2053,9 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent) oldCPU=procInfo.fCpuUser+procInfo.fCpuSys; } AliInfo(Form("================================= Processing event %d of type %-10s ==================================", iEvent,fRecoParam.PrintEventSpecie())); + fEventInfo.Print(); AliSysInfo::AddStamp(Form("StartReco_%d",iEvent), 0,0,iEvent); - // Set the reco-params { TString detStr = fLoadCDB; @@ -2522,7 +2563,7 @@ void AliReconstruction::CleanProcessedEvent() AliInfo("======================= End Event ==================="); - fEventInfo.Reset(); + for (Int_t iDet = 0; iDet < kNDetectors; iDet++) { if (fReconstructor[iDet]) { fReconstructor[iDet]->SetRecoParam(NULL); @@ -3326,6 +3367,9 @@ Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd) if (esd->GetTriggerMask() != input.GetClassMask()) AliError(Form("Invalid trigger pattern found in CTP raw-data: %llx %llx", input.GetClassMask(),esd->GetTriggerMask())); + if (esd->GetTriggerMaskNext50() != input.GetClassMaskNext50()) + AliError(Form("Invalid trigger pattern found in CTP raw-data Next50: %llx %llx", + input.GetClassMaskNext50(),esd->GetTriggerMaskNext50())); if (esd->GetOrbitNumber() != input.GetOrbitID()) AliError(Form("Invalid orbit id found in CTP raw-data: %x %x", input.GetOrbitID(),esd->GetOrbitNumber())); @@ -3367,6 +3411,12 @@ Bool_t AliReconstruction::FillTriggerScalers(AliESDEvent*& esd) if(scalesd)esdheader->SetTriggerScalersRecord(scalesd); } } + for(Int_t i=0;i<50;i++){ + if((1ull<GetTriggerMaskNext50()){ + AliTriggerScalersESD* scalesd = fRunScalers->GetScalersForEventClass( timestamp, i+51); + if(scalesd)esdheader->SetTriggerScalersRecord(scalesd); + } + } const AliTriggerScalersRecordESD* scalrecEvent = fRunScalers->GetScalersDeltaForEvent( timestamp); const AliTriggerScalersRecordESD* scalrecRun = fRunScalers->GetScalersDeltaForRun(); if (scalrecEvent) esdheader->SetTriggerScalersDeltaEvent(scalrecEvent); @@ -3448,7 +3498,7 @@ Bool_t AliReconstruction::InitRunLoader() for (Int_t iDet = 0; iDet < kNDetectors; iDet++) { TString detName = fgkDetectorName[iDet]; if (libs.Contains("lib" + detName + "base.so")) continue; - gSystem->Load("lib" + detName + "base.so"); + gSystem->Load("lib" + detName + "base"); } fRunLoader = AliRunLoader::Open(fGAliceFileName.Data()); if (!fRunLoader) { @@ -3521,7 +3571,7 @@ AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet) AliDebug(1, Form("defining plugin for %s", recName.Data())); TString libs = gSystem->GetLibraries(); if (libs.Contains("lib" + detName + "base.so") || - (gSystem->Load("lib" + detName + "base.so") >= 0)) { + (gSystem->Load("lib" + detName + "base") >= 0)) { pluginManager->AddHandler("AliReconstructor", detName, recName, detName + "rec", recName + "()"); } else { @@ -3677,6 +3727,7 @@ void AliReconstruction::CleanUp() { // delete trackers and the run loader and close and delete the file for (Int_t iDet = 0; iDet < kNDetectors; iDet++) { + if (fReconstructor[iDet]) fReconstructor[iDet]->SetRecoParam(NULL); delete fReconstructor[iDet]; fReconstructor[iDet] = NULL; fLoader[iDet] = NULL; @@ -4105,13 +4156,16 @@ Bool_t AliReconstruction::GetEventInfo() // Fill the event info object // ... AliCodeTimerAuto("",0) - + AliCentralTrigger *aCTP = NULL; + fEventInfo.Reset(); if (fRawReader) { fEventInfo.SetEventType(fRawReader->GetType()); ULong64_t mask = fRawReader->GetClassMask(); + ULong64_t maskNext50 = fRawReader->GetClassMaskNext50(); fEventInfo.SetTriggerMask(mask); + fEventInfo.SetTriggerMaskNext50(maskNext50); UInt_t clmask = fRawReader->GetDetectorPattern()[0]; fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(clmask)); @@ -4139,6 +4193,7 @@ Bool_t AliReconstruction::GetEventInfo() if (fRunLoader && (!fRunLoader->LoadTrigger())) { aCTP = fRunLoader->GetTrigger(); fEventInfo.SetTriggerMask(aCTP->GetClassMask()); + fEventInfo.SetTriggerMaskNext50(aCTP->GetClassMaskNext50()); // get inputs from actp - just get AliESDHeader* esdheader = fesd->GetHeader(); esdheader->SetL0TriggerInputs(aCTP->GetL0TriggerInputs()); @@ -4159,36 +4214,10 @@ Bool_t AliReconstruction::GetEventInfo() if (fRawReader) delete aCTP; return kFALSE; } - - // Load trigger aliases and declare the trigger classes included in aliases - //PH Why do we do it in each event and not only once in the beginning of the chunk?? - //PH Temporary fix for #99725: AliReconstruction::GetEventInfo bug - fDeclTriggerClasses.Clear(); - AliCDBEntry * entry = AliCDBManager::Instance()->Get("GRP/CTP/Aliases"); - if (entry) { - THashList * lst = dynamic_cast(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(iter.Next()))){ - fDeclTriggerClasses += " "; - fDeclTriggerClasses += nmd->GetName(); - } - } - else { - AliError("Cannot cast the object with trigger aliases to THashList!"); - } - } - else { - AliError("No OCDB ebtry for the trigger aliases!"); - } - // Load trigger classes for this run UChar_t clustmask = 0; TString trclasses; ULong64_t trmask = fEventInfo.GetTriggerMask(); + ULong64_t trmaskNext50 = fEventInfo.GetTriggerMaskNext50(); const TObjArray& classesArray = config->GetClasses(); Int_t nclasses = classesArray.GetEntriesFast(); for( Int_t iclass=0; iclass < nclasses; iclass++ ) { @@ -4196,26 +4225,31 @@ Bool_t AliReconstruction::GetEventInfo() 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(); + if (TriggerMatches2Alias(trclass->GetName(),fCosmicAlias)) fEventInfo.SetCosmicTrigger(kTRUE); + else if (TriggerMatches2Alias(trclass->GetName(),fLaserAlias)) fEventInfo.SetCalibLaserTrigger(kTRUE); + else fEventInfo.SetBeamTrigger(kTRUE); } } - } - fEventInfo.SetTriggerClasses(trclasses); - // Now put the declared trigger classes (not present in the run) - // to 0/false in the event selection - if (!fDeclTriggerClasses.IsNull()) { - TObjArray *tokens = fDeclTriggerClasses.Tokenize(" "); - Int_t ntokens = tokens->GetEntriesFast(); - for (Int_t itoken = 0; itoken < ntokens; ++itoken) { - if (fRawReader) fRawReader->LoadTriggerClass((((TObjString*)tokens->At(itoken))->String()).Data(),-1); + if (trclass && trclass->GetMaskNext50()>0) { + Int_t trindex = TMath::Nint(TMath::Log2(trclass->GetMaskNext50()))+50; + if (fesd) fesd->SetTriggerClass(trclass->GetName(),trindex); + if (trmaskNext50 & (1ull << (trindex-50))) { + trclasses += " "; + trclasses += trclass->GetName(); + trclasses += " "; + clustmask |= trclass->GetCluster()->GetClusterMask(); + if (TriggerMatches2Alias(trclass->GetName(),fCosmicAlias)) fEventInfo.SetCosmicTrigger(kTRUE); + else if (TriggerMatches2Alias(trclass->GetName(),fLaserAlias)) fEventInfo.SetCalibLaserTrigger(kTRUE); + else fEventInfo.SetBeamTrigger(kTRUE); + } } - delete tokens; } + fEventInfo.SetTriggerClasses(trclasses); // Write names of active trigger inputs in ESD Header const TObjArray& inputsArray = config->GetInputs(); @@ -4238,6 +4272,7 @@ Bool_t AliReconstruction::GetEventInfo() // Set the information in ESD if (fesd) { fesd->SetTriggerMask(trmask); + fesd->SetTriggerMaskNext50(trmaskNext50); fesd->SetTriggerCluster(clustmask); } @@ -4250,6 +4285,8 @@ Bool_t AliReconstruction::GetEventInfo() // We have to fill also the HLT decision here!! // ... + // check if event has cosmic or laser alias + return kTRUE; } @@ -4773,3 +4810,124 @@ void AliReconstruction::RectifyCDBurl(TString& url) //url.ToLower(); // } + +//_________________________________________________________ +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(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(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; iAt(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)); + // +}