]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/ITS/AliHLTITSClusterFinderComponent.cxx
reverting r42022, changes to be committed separately in order to disentangle backporting
[u/mrichter/AliRoot.git] / HLT / ITS / AliHLTITSClusterFinderComponent.cxx
index ffc3b5a4a26eeb08c3f91f1af8eaaaeb49bf4c1f..8a25cb4542f96d5f57292daf50ba1b444b066da9 100644 (file)
@@ -40,9 +40,12 @@ using namespace std;
 #include "AliITSReconstructor.h"
 #include "AliHLTITSClusterFinderSPD.h"
 #include "AliHLTITSClusterFinderSSD.h"
+#include "TMap.h"
+#include "AliITSRecPointContainer.h"
 
 #include <cstdlib>
 #include <cerrno>
+#include "TFile.h"
 #include "TString.h"
 #include "TObjString.h"
 #include <sys/time.h>
@@ -59,7 +62,6 @@ AliHLTITSClusterFinderComponent::AliHLTITSClusterFinderComponent(int mode)
   fNModules(0),
   fId(0),
   fNddl(0),
-  fClusters(NULL),
   fRawReader(NULL),
   fDettype(NULL),
   fgeom(NULL),
@@ -68,6 +70,9 @@ AliHLTITSClusterFinderComponent::AliHLTITSClusterFinderComponent(int mode)
   fSSD(NULL),
   tD(NULL),
   tR(NULL),
+  fSPDNModules(0),
+  fSDDNModules(0),
+  fSSDNModules(0),
   fclusters(),
   fBenchmark(GetComponentID())
 { 
@@ -274,18 +279,31 @@ Int_t AliHLTITSClusterFinderComponent::DoInit( int argc, const char** argv ) {
     AliGeomManager::LoadGeometry();
   }
 
//fgeomInit = new AliITSInitGeometry(kvSPD02,2);
-  fgeomInit = new AliITSInitGeometry(kvPPRasymmFMD,2);
 fgeomInit = new AliITSInitGeometry();
+  //fgeomInit = new AliITSInitGeometry(kvPPRasymmFMD,2);
   //fgeomInit->InitAliITSgeom(fgeom);
   fgeom = fgeomInit->CreateAliITSgeom();
  
   fNModules = fgeom->GetIndexMax();
-
-  fClusters = new TClonesArray*[fNModules]; 
-  for (Int_t iModule = 0; iModule < fNModules; iModule++) {
-    fClusters[iModule] = NULL;
-  } 
-
+  Int_t modperlay[6];
+  for(Int_t i=0;i<6;i++)modperlay[i]=AliITSgeomTGeo::GetNDetectors(1+i)*AliITSgeomTGeo::GetNLadders(1+i);
+  fSPDNModules=modperlay[0]+modperlay[1];
+  fSDDNModules=modperlay[2]+modperlay[3];
+  fSSDNModules=modperlay[4]+modperlay[5];
+  
+  if(fModeSwitch==kClusterFinderSPD) {
+    fFirstModule=0;
+    fLastModule=fSPDNModules;
+  }
+  else if(fModeSwitch==kClusterFinderSDD) {
+     fFirstModule=fSPDNModules;
+     fLastModule=fFirstModule + fSDDNModules;
+  }
+  else if(fModeSwitch==kClusterFinderSSD) {
+    fFirstModule=fSPDNModules + fSDDNModules;
+    fLastModule=fFirstModule + fSSDNModules;
+  }
   //set dettype
   fDettype = new AliITSDetTypeRec();
   fDettype->SetITSgeom(fgeom); 
@@ -332,14 +350,6 @@ Int_t AliHLTITSClusterFinderComponent::DoDeinit() {
   delete fSSD;
   fSSD = 0;
 
-  for (Int_t iModule = 0; iModule < fNModules; iModule++) {
-    if(fClusters[iModule] != NULL){
-      fClusters[iModule]->Delete();
-      delete fClusters[iModule];
-    }
-    fClusters[iModule] = NULL;
-  } 
-  
   fUseOfflineFinder = 0;
 
   return 0;
@@ -383,15 +393,38 @@ int AliHLTITSClusterFinderComponent::DoEvent
        HLTFatal("No Digit Tree found");
        return -1;
       }
+      // 2010-04-17 very crude workaround: TTree objects are difficult to send
+      // The actual case: Running ITS and TPC reconstruction fails at the second event
+      // to read the ITS digits from the TreeD
+      //
+      // Reason: reading fails in TBranch::GetBasket, there a new basket is opened from
+      // a TFile object. The function TBranch::GetFile returns the file object from
+      // an internal fDirectory (TDirectory) object. This file is at the second event
+      // set to the TPC.Digits.root. The internal mismatch creates a seg fault
+      //
+      // Investigation: TBranch::Streamer uses a crude assignment after creating the
+      // TBranch object
+      //    fDirectory = gDirectory;
+      // gDirectory is obviously not set correctly. Setting the directory to a TFile
+      // object for the ITS digits helps to fix the internal mess. Tried also to set
+      // the Directory for the TreeD to NULL (This has only effect if ones sets it 
+      // to something not NULL first, and then to NULL). But then no content, i.e.
+      // ITS clusters could be retrieved.
+      //
+      // Conclusion: TTree objects are hardly to be sent via TMessage, there are direct
+      // links to the file required anyhow.
+      TFile* dummy=new TFile("ITS.Digits.root");
+      tD->SetDirectory(dummy);
       tR = new TTree();
+      tR->SetDirectory(0);
       fDettype->SetTreeAddressD(tD);
       fDettype->MakeBranch(tR,"R");
       fDettype->SetTreeAddressR(tR);
       Option_t *opt="All";
       fBenchmark.Start(1);
-      fDettype->DigitsToRecPoints(tD,tR,0,opt,kTRUE);
+      fDettype->DigitsToRecPoints(tD,tR,0,opt,0);
       fBenchmark.Stop(1);
-      TClonesArray * fRecPoints;
+      TClonesArray * fRecPoints = NULL;
       tR->SetBranchAddress("ITSRecPoints",&fRecPoints);
       for(Int_t treeEntry=0;treeEntry<tR->GetEntries();treeEntry++){
        tR->GetEntry(treeEntry);
@@ -404,6 +437,9 @@ int AliHLTITSClusterFinderComponent::DoEvent
       if(tR){
        tR->Delete();
       }
+
+      tD->SetDirectory(0);
+      delete dummy;
       UInt_t nClusters=fclusters.size();
       
       UInt_t bufferSize = nClusters * sizeof(AliHLTITSSpacePointData) + sizeof(AliHLTITSClusterData);
@@ -430,7 +466,15 @@ int AliHLTITSClusterFinderComponent::DoEvent
     }
   }
   else{
-      
+
+    AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance();
+
+    if(fUseOfflineFinder){
+      if(fModeSwitch==kClusterFinderSPD){rpc->ResetSPD();}
+      if(fModeSwitch==kClusterFinderSSD){rpc->ResetSSD();}
+    }
+    if(fModeSwitch==kClusterFinderSDD){rpc->ResetSDD();}
+
     // -- Loop over blocks
     for( const AliHLTComponentBlockData* iter = GetFirstInputBlock(fInputDataType); iter != NULL; iter = GetNextInputBlock() ) {
       
@@ -472,21 +516,28 @@ int AliHLTITSClusterFinderComponent::DoEvent
       if(fModeSwitch==kClusterFinderSPD && !fUseOfflineFinder){ fSPD->RawdataToClusters( fRawReader, fclusters ); }
       else if(fModeSwitch==kClusterFinderSSD && !fUseOfflineFinder){ fSSD->RawdataToClusters( fclusters ); }
       else{
-       if(fModeSwitch==kClusterFinderSPD && fUseOfflineFinder) {fDettype->DigitsToRecPoints(fRawReader,fClusters,"SPD");}
-       if(fModeSwitch==kClusterFinderSSD && fUseOfflineFinder) {fDettype->DigitsToRecPoints(fRawReader,fClusters,"SSD");}
-       if(fModeSwitch==kClusterFinderSDD) {fDettype->DigitsToRecPoints(fRawReader,fClusters,"SDD");}
-       for(int i=0;i<fNModules;i++){
-         if(fClusters[i] != NULL){
-           for(int j=0;j<fClusters[i]->GetEntriesFast();j++){
-             AliITSRecPoint *recpoint = (AliITSRecPoint*) (fClusters[i]->At(j));
+       if(fModeSwitch==kClusterFinderSPD && fUseOfflineFinder) {fDettype->DigitsToRecPoints(fRawReader,"SPD");}
+       if(fModeSwitch==kClusterFinderSSD && fUseOfflineFinder) {fDettype->DigitsToRecPoints(fRawReader,"SSD");}
+       if(fModeSwitch==kClusterFinderSDD) {fDettype->DigitsToRecPoints(fRawReader,"SDD");}
+       //AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance();
+       TClonesArray* clusters = NULL;
+       for(int i=fFirstModule;i<fLastModule;i++){
+         clusters = rpc->UncheckedGetClusters(i);
+         if(clusters != NULL){
+           for(int j=0;j<clusters->GetEntriesFast();j++){
+             AliITSRecPoint *recpoint = (AliITSRecPoint*) (clusters->At(j));
              fclusters.push_back(*recpoint);
            }
-           fClusters[i]->Delete();
-           delete fClusters[i];
          }
-         fClusters[i] = NULL;
        }     
       }
+  
+      if(fUseOfflineFinder){
+       if(fModeSwitch==kClusterFinderSPD){rpc->ResetSPD();}
+       if(fModeSwitch==kClusterFinderSSD){rpc->ResetSSD();}
+      }
+      if(fModeSwitch==kClusterFinderSDD){rpc->ResetSDD();}
+  
       fBenchmark.Stop(1);
       
       fRawReader->ClearBuffers();    
@@ -591,6 +642,29 @@ int AliHLTITSClusterFinderComponent::Reconfigure(const char* cdbEntry, const cha
   
   return iResult;
 }
+void AliHLTITSClusterFinderComponent::GetOCDBObjectDescription( TMap* const targetMap)
+{
+  // Get a list of OCDB object description.
+  if (!targetMap) return;
+  //SPD
+  targetMap->Add(new TObjString("ITS/Calib/SPDNoisy"),new TObjString("Calibration object for SPD" ));
+  targetMap->Add(new TObjString("ITS/Calib/SPDDead"),new TObjString("Calibration object for SPD" ));
+  targetMap->Add(new TObjString("TRIGGER/SPD/PITConditions"),new TObjString("Calibration object for SPD" ));
+  //SDD
+  targetMap->Add(new TObjString("ITS/Calib/CalibSDD"),new TObjString("Calibration object for SDD" ));
+  targetMap->Add(new TObjString("ITS/Calib/RespSDD"),new TObjString("Calibration object for SDD" ));
+  targetMap->Add(new TObjString("ITS/Calib/DriftSpeedSDD"),new TObjString("Calibration object for SDD" ));
+  targetMap->Add(new TObjString("ITS/Calib/DDLMapSDD"),new TObjString("Calibration object for SDD" ));
+  targetMap->Add(new TObjString("ITS/Calib/MapsTimeSDD"),new TObjString("Calibration object for SDD" ));
+  //SSD
+  targetMap->Add(new TObjString("ITS/Calib/NoiseSSD"),new TObjString("Calibration object for SSD" ));
+  targetMap->Add(new TObjString("ITS/Calib/GainSSD"),new TObjString("Calibration object for SSD" ));
+  targetMap->Add(new TObjString("ITS/Calib/BadChannelsSSD"),new TObjString("Calibration object for SSD" ));
+  //General reconstruction
+  targetMap->Add(new TObjString("GRP/CTP/Scalers"),new TObjString("General reconstruction object" ));
+}
+
+
 void AliHLTITSClusterFinderComponent::RecPointToSpacePoint(AliHLTUInt8_t* outputPtr,AliHLTUInt32_t& size){
   AliHLTITSClusterData *outputClusters = reinterpret_cast<AliHLTITSClusterData*>(outputPtr + size);
   outputClusters->fSpacePointCnt=fclusters.size();