]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliReconstruction.cxx
Changes for #81171 Port request- AliReconstruction: ESD friend filtering - Random...
[u/mrichter/AliRoot.git] / STEER / AliReconstruction.cxx
index f51e4b9d102ffa1fade34aa691c1cd2e631d0cfe..eaa48742ca967ffaef75507ba4b5b4dc03ad607d 100644 (file)
@@ -296,13 +296,15 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename) :
   fNspecie(0),
   fSspecie(0),
   fNhighPt(0),
-  fShighPt(0)
+  fShighPt(0),
+  fUpgradeModule("") 
 {
 // create reconstruction object with default parameters
   gGeoManager = NULL;
   
   for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
     fReconstructor[iDet] = NULL;
+    fUpgradeMask[iDet]=kFALSE;
     fLoader[iDet] = NULL;
     fTracker[iDet] = NULL;
   }
@@ -409,7 +411,8 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   fNspecie(0),
   fSspecie(0),
   fNhighPt(0),
-  fShighPt(0)
+  fShighPt(0),
+  fUpgradeModule("")
 {
 // copy constructor
 
@@ -418,6 +421,7 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   }
   for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
     fReconstructor[iDet] = NULL;
+    fUpgradeMask[iDet] = kFALSE;
     fLoader[iDet] = NULL;
     fTracker[iDet] = NULL;
   }  
@@ -511,6 +515,7 @@ AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
   fRecoParam = rec.fRecoParam;
 
   for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
+    fUpgradeMask[iDet] = kFALSE;
     delete fReconstructor[iDet]; fReconstructor[iDet] = NULL;
     delete fLoader[iDet]; fLoader[iDet] = NULL;
     delete fTracker[iDet]; fTracker[iDet] = NULL;
@@ -570,6 +575,7 @@ AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
   fSspecie = 0;
   fNhighPt = 0;
   fShighPt = 0;
+  fUpgradeModule="";
 
   return *this;
 }
@@ -852,6 +858,15 @@ void AliReconstruction::SetCDBLock() {
   AliCDBManager::Instance()->SetLock(1);
 }
 
+//_____________________________________________________________________________
+void AliReconstruction::MatchUpgradeDetector() {
+  // Translates detector name in a boolean.
+  // The boolean is used in GetReconstructor to load the 
+  // upgrade reconstructor instead of the standard one.
+   for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
+    if(fUpgradeModule.Contains(fgkDetectorName[iDet])) fUpgradeMask[iDet]=kTRUE;
+   }
+}
 //_____________________________________________________________________________
 Bool_t AliReconstruction::MisalignGeometry(const TString& detectors)
 {
@@ -1217,7 +1232,7 @@ Bool_t AliReconstruction::LoadTriggerScalersCDB()
        AliInfo("Found an AliTriggerRunScalers in GRP/CTP/Scalers, reading it");
        fRunScalers = dynamic_cast<AliTriggerRunScalers*> (entry->GetObject());
        entry->SetOwner(0);
-       if (fRunScalers->CorrectScalersOverflow() == 0) AliInfo("32bit Trigger counters corrected for overflow");
+       if (fRunScalers && (fRunScalers->CorrectScalersOverflow() == 0)) AliInfo("32bit Trigger counters corrected for overflow");
 
   }
   return kTRUE;
@@ -1256,7 +1271,7 @@ Bool_t AliReconstruction::ReadIntensityInfoCDB()
     AliLHCData* dipData = dynamic_cast<AliLHCData*> (entry->GetObject());
     for (int ib=2;ib--;) {
       double intI,intNI;
-      if (dipData->GetMeanIntensity(ib,intI,intNI)>=0) {
+      if (dipData && (dipData->GetMeanIntensity(ib,intI,intNI)>=0)) {
        fBeamInt[ib][0] = intI;
        fBeamInt[ib][1] = intNI;        
       }
@@ -1700,8 +1715,9 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
 
   if (iEvent >= fRunLoader->GetNumberOfEvents()) {
     fRunLoader->SetEventNumber(iEvent);
-    fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(), 
-                                  iEvent, iEvent);
+    if (fRawReader)
+      fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(), 
+                                    iEvent, iEvent);
     fRunLoader->TreeE()->Fill();
     if (fRawReader && fRawReader->UseAutoSaveESD())
       fRunLoader->TreeE()->AutoSave("SaveSelf");
@@ -1887,7 +1903,11 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
        if (fStopOnError) {CleanUp(); return kFALSE;}
       }
     }
+
+    // AdC+FN
+    if (fReconstructor[3])
+      GetReconstructor(3)->FillEventTimeWithTOF(fesd,&pid);
+
     // combined PID
     pid.MakePID(fesd);
 
@@ -2034,11 +2054,27 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     if (fRunV0Finder) {
        // V0 finding
        AliV0vertexer vtxer;
+       // get cuts for V0vertexer from AliGRPRecoParam
+       if (grpRecoParam) {
+        Int_t nCutsV0vertexer = grpRecoParam->GetVertexerV0NCuts();
+        Double_t *cutsV0vertexer = new Double_t[nCutsV0vertexer];
+        grpRecoParam->GetVertexerV0Cuts(cutsV0vertexer);
+        vtxer.SetCuts(cutsV0vertexer);
+        delete [] cutsV0vertexer; cutsV0vertexer = NULL; 
+       }
        vtxer.Tracks2V0vertices(fesd);
 
        if (fRunCascadeFinder) {
           // Cascade finding
           AliCascadeVertexer cvtxer;
+         // get cuts for CascadeVertexer from AliGRPRecoParam
+         if (grpRecoParam) {
+           Int_t nCutsCascadeVertexer = grpRecoParam->GetVertexerCascadeNCuts();
+           Double_t *cutsCascadeVertexer = new Double_t[nCutsCascadeVertexer];
+           grpRecoParam->GetVertexerCascadeCuts(cutsCascadeVertexer);
+           cvtxer.SetCuts(cutsCascadeVertexer);
+           delete [] cutsCascadeVertexer; cutsCascadeVertexer = NULL; 
+         }
           cvtxer.V0sTracks2CascadeVertices(fesd);
        }
     }
@@ -2062,6 +2098,7 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
   }
   if (fRunGlobalQA) {
     AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
+    if (qadm)
       qadm->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
     if (qadm && IsInTasks(AliQAv1::kESDS))
       qadm->Exec(AliQAv1::kESDS, fesd);
@@ -2088,8 +2125,6 @@ Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
     if (fRawReader && fRawReader->UseAutoSaveESD()) {
       ftree->AutoSave("SaveSelf");
       if (fWriteESDfriend) ftreeF->AutoSave("SaveSelf");
-      TFile *friendfile = (TFile *)(gROOT->GetListOfFiles()->FindObject("AliESDfriends.root"));
-      if (friendfile) friendfile->Save();
     }
 
     // write HLT ESD
@@ -2158,8 +2193,9 @@ void AliReconstruction::SlaveTerminate()
    TPair* pair = 0;     
    while((pair = dynamic_cast<TPair*> (iter.Next()))){  
          TObjString* keyStr = dynamic_cast<TObjString*> (pair->Key());  
-         TObjString* valStr = dynamic_cast<TObjString*> (pair->Value());        
-         cdbMapCopy->Add(new TObjString(keyStr->GetName()), new TObjString(valStr->GetName()));         
+         TObjString* valStr = dynamic_cast<TObjString*> (pair->Value());
+        if (keyStr && valStr)
+          cdbMapCopy->Add(new TObjString(keyStr->GetName()), new TObjString(valStr->GetName()));        
    }    
         
    TList *cdbListCopy = new TList();    
@@ -2337,7 +2373,7 @@ Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
     loader->UnloadRecPoints();
     AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr);
   }
-  IsSelected("CTP", detStr);
+  if (!IsSelected("CTP", detStr)) AliDebug(10,"No CTP");
   if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
     AliError(Form("the following detectors were not found: %s",
                   detStr.Data()));
@@ -2833,7 +2869,7 @@ Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors)
     }
   }
   
-  IsSelected("CTP", detStr);
+  if (!IsSelected("CTP", detStr)) AliDebug(10,"No CTP");
   if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
     AliError(Form("the following detectors were not found: %s", 
                   detStr.Data()));
@@ -3061,6 +3097,14 @@ AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
   if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
     reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0);
   }
+
+   // check if the upgrade reconstructor should be used instead of the standard one
+  if(fUpgradeMask[iDet]) {
+    if(reconstructor) delete reconstructor;
+    TClass *cl = new TClass(Form("Ali%sUpgradeReconstructor",fgkDetectorName[iDet]));
+    reconstructor = (AliReconstructor*)(cl->New());
+   }
+
   if (reconstructor) {
     TObject* obj = fOptions.FindObject(detName.Data());
     if (obj) reconstructor->SetOption(obj->GetTitle());
@@ -3110,8 +3154,10 @@ AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
       
   if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
     const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
-    reconstructor->SetRecoParam(par);
-    reconstructor->SetRunInfo(fRunInfo);
+    if (reconstructor) {
+      reconstructor->SetRecoParam(par);
+      reconstructor->SetRunInfo(fRunInfo);
+    }
   }
   return reconstructor;
 }
@@ -3447,15 +3493,13 @@ Bool_t AliReconstruction::InitAliEVE()
   // The return flag shows whenever the
   // AliEVE initialization was successful or not.
 
-  TString macroPath;
-  macroPath.Form(".:%s:%s/EVE/macros/",
-                gROOT->GetMacroPath(),
-                gSystem->ExpandPathName("$ALICE_ROOT"));
-  gROOT->SetMacroPath(macroPath.Data());
+  TString macroStr(gSystem->Getenv("ALIEVE_ONLINE_MACRO"));
+
+  if (macroStr.IsNull())
+    macroStr.Form("%s/EVE/macros/alieve_online.C",gSystem->ExpandPathName("$ALICE_ROOT"));
+
+  AliInfo(Form("Loading AliEVE macro: %s",macroStr.Data()));
 
-  TString macroStr("alieve_online.C");
-  AliInfo(Form("Loading AliEVE macro: %s (%s)",macroStr.Data(), 
-              gSystem->Which(gROOT->GetMacroPath(), macroStr.Data())));
   if (gROOT->LoadMacro(macroStr.Data()) != 0) return kFALSE;
 
   gROOT->ProcessLine("if (!AliEveEventManager::GetMaster()){new AliEveEventManager();AliEveEventManager::GetMaster()->AddNewEventCommand(\"alieve_online_on_new_event()\");gEve->AddEvent(AliEveEventManager::GetMaster());};");
@@ -3893,12 +3937,16 @@ Bool_t AliReconstruction::IsHighPt() const {
   // that was reconstructed by both ITS and TPC, the event is accepted
 
   // Track cuts
-
   const Double_t pTmin = 1.5;
   const Double_t pTmax = 100;
   ULong_t mask = 0;
   mask |= (AliESDtrack::kITSrefit);
   mask |= (AliESDtrack::kTPCrefit);
+  const Double_t pTminCosmic = 5.;
+  const Double_t pTmaxCosmic = 100;
+  ULong_t maskCosmic = 0;
+  Int_t cosmicCount=0;
+  maskCosmic |= (AliESDtrack::kTPCrefit);
 
   Bool_t isOK = kFALSE;
 
@@ -3916,7 +3964,17 @@ Bool_t AliReconstruction::IsHighPt() const {
        isOK = kTRUE;
        break;
       }
+      if (trk 
+         && trk->GetInnerParam()
+         && trk->GetInnerParam()->Pt() > pTminCosmic 
+         && trk->GetInnerParam()->Pt() < pTmaxCosmic
+         && (trk->GetStatus() & maskCosmic) == maskCosmic ) {
+       
+       cosmicCount++;
+       break;
+      }
     }
+    if (cosmicCount>1) isOK=kTRUE;
   }
   return isOK;
 }
@@ -3948,8 +4006,10 @@ void AliReconstruction::WriteESDfriend() {
   // 3. Sample randomly events if we still have remaining slot
 
   fNall++;
-
   Bool_t isSelected = kFALSE;
+  //
+  // Store all friends for B field OFF 
+  if (TMath::Abs(AliTrackerBase::GetBz())<0.5) isSelected=kTRUE;
 
   if (IsCosmicOrCalibSpecie()) { // Selection of calib or cosmic events
     fNspecie++;