]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/ITS/AliHLTITSClusterFinderComponent.cxx
updating macros (Theo)
[u/mrichter/AliRoot.git] / HLT / ITS / AliHLTITSClusterFinderComponent.cxx
index 06820a3a5cfab0be04ae33e879ffd7423c081994..ffc3b5a4a26eeb08c3f91f1af8eaaaeb49bf4c1f 100644 (file)
@@ -29,7 +29,7 @@ using namespace std;
 
 #include "AliCDBEntry.h"
 #include "AliCDBManager.h"
-#include "AliHLTDataTypes.h"
+#include "AliCDBStorage.h"
 #include "AliITSgeomTGeo.h"
 #include "AliITSRecPoint.h"
 #include "AliHLTITSSpacePointData.h"
@@ -68,7 +68,8 @@ AliHLTITSClusterFinderComponent::AliHLTITSClusterFinderComponent(int mode)
   fSSD(NULL),
   tD(NULL),
   tR(NULL),
-  fclusters()
+  fclusters(),
+  fBenchmark(GetComponentID())
 { 
   // see header file for class documentation
   // or
@@ -90,7 +91,7 @@ AliHLTITSClusterFinderComponent::AliHLTITSClusterFinderComponent(int mode)
     fOutputDataType = kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD;
     break;
   case kClusterFinderDigits:
-    fInputDataType  = kAliHLTDataTypeTTree|kAliHLTDataOriginITS;
+    fInputDataType  = kAliHLTDataTypeAliTreeD|kAliHLTDataOriginITS;
     fOutputDataType = kAliHLTDataTypeClusters|kAliHLTDataOriginITS;
     break;
   default:
@@ -157,6 +158,10 @@ AliHLTComponent* AliHLTITSClusterFinderComponent::Spawn() {
        
 Int_t AliHLTITSClusterFinderComponent::DoInit( int argc, const char** argv ) {
   // see header file for class documentation
+  fBenchmark.Reset();
+  fBenchmark.SetTimer(0,"total");
+  fBenchmark.SetTimer(1,"reco");
+
   /*
   fStatTime = 0;
   fStatTimeAll = 0;
@@ -164,6 +169,71 @@ Int_t AliHLTITSClusterFinderComponent::DoInit( int argc, const char** argv ) {
   fStatTimeAllC = 0;
   fStatNEv = 0;
   */
+  
+  Int_t runNo = GetRunNo();
+  AliCDBStorage* store = AliCDBManager::Instance()->GetDefaultStorage();
+  if (!store) {
+    return NULL;
+  }
+
+  bool cdbOK = true;
+  //OCDB for SPD
+  if(store->GetLatestVersion("ITS/Calib/SPDNoisy", runNo)<0){
+    HLTError("SPDNoisy is not found in SPD/Calib");
+    cdbOK = false;
+  }
+  if(store->GetLatestVersion("ITS/Calib/SPDDead", runNo)<0){
+    HLTError("SPDDead is not found in SPD/Calib");
+    cdbOK = false;
+  }
+  if(store->GetLatestVersion("TRIGGER/SPD/PITConditions", runNo)<0){
+    HLTError("PITConditions is not found in TRIGGER/SPD");
+    cdbOK = false;
+  }
+  
+  //OCDB for SDD
+  if(store->GetLatestVersion("ITS/Calib/CalibSDD", runNo)<0){
+    HLTError("CalibSDD is not found in ITS/Calib");
+    cdbOK = false;
+  }
+  if(store->GetLatestVersion("ITS/Calib/RespSDD", runNo)<0){
+    HLTError("RespSDD is not found in ITS/Calib");
+    cdbOK = false;
+  }
+  if(store->GetLatestVersion("ITS/Calib/DriftSpeedSDD", runNo)<0){
+    HLTError("DriftSpeedSDD is not found in ITS/Calib");
+    cdbOK = false;
+  }
+  if(store->GetLatestVersion("ITS/Calib/DDLMapSDD", runNo)<0){
+    HLTError("DDLMapSDD is not found in ITS/Calib");
+    cdbOK = false;
+  }
+  if(store->GetLatestVersion("ITS/Calib/MapsTimeSDD", runNo)<0){
+    HLTError("MapsTimeSDD is not found in ITS/Calib");
+    cdbOK = false;
+  }
+
+  //OCDB for SSD
+  if(store->GetLatestVersion("ITS/Calib/NoiseSSD", runNo)<0){
+    HLTError("NoiseSSD is not found in ITS/Calib");
+    cdbOK = false;
+  }
+  if(store->GetLatestVersion("ITS/Calib/GainSSD", runNo)<0){
+    HLTError("GainSSD is not found in ITS/Calib");
+    cdbOK = false;
+  }
+  if(store->GetLatestVersion("ITS/Calib/BadChannelsSSD", runNo)<0){
+    HLTError("BadChannelsSSD is not found in ITS/Calib");
+    cdbOK = false;
+  }
+  
+  //General reconstruction
+  if(store->GetLatestVersion("GRP/CTP/Scalers", runNo)<0){
+    HLTError("Scalers is not found in GRP/CTP/");
+    cdbOK = false;
+  }
+  if(!cdbOK){return NULL;}
+
   if(fModeSwitch==kClusterFinderSPD) {
     HLTDebug("using ClusterFinder for SPD");
     //fNModules=AliITSgeomTGeo::GetNDetectors(1)*AliITSgeomTGeo::GetNLadders(1) + AliITSgeomTGeo::GetNDetectors(2)*AliITSgeomTGeo::GetNLadders(2);
@@ -182,7 +252,7 @@ Int_t AliHLTITSClusterFinderComponent::DoInit( int argc, const char** argv ) {
     fId=AliHLTDAQ::DdlIDOffset("ITSSSD");
     fNddl=AliHLTDAQ::NumberOfDdls("ITSSSD");
   }
-  if(fModeSwitch==kClusterFinderDigits) {
+  else if(fModeSwitch==kClusterFinderDigits) {
     //tR = new TTree();
   }
   else{
@@ -275,12 +345,10 @@ Int_t AliHLTITSClusterFinderComponent::DoDeinit() {
   return 0;
 }
 
-// #include "TStopwatch.h"
-
 int AliHLTITSClusterFinderComponent::DoEvent
 (
  const AliHLTComponentEventData& evtData,
- const AliHLTComponentBlockData* blocks,
+ const AliHLTComponentBlockData* /*blocks*/,
  AliHLTComponentTriggerData& /*trigData*/,
  AliHLTUInt8_t* outputPtr,
  AliHLTUInt32_t& size,
@@ -298,11 +366,17 @@ int AliHLTITSClusterFinderComponent::DoEvent
       HLTDebug("no blocks in event" );
       return 0;
     }
-  
-  // TStopwatch timer;
+
+  fBenchmark.StartNewEvent();
+  fBenchmark.Start(0);
+  for( const AliHLTComponentBlockData *i= GetFirstInputBlock(fInputDataType); i!=NULL; i=GetNextInputBlock() ){
+    fBenchmark.AddInput(i->fSize);
+  }
+
   Int_t ret = 0;
-  //std::vector<AliITSRecPoint> vclusters;
+
   if(fModeSwitch==kClusterFinderDigits) {
+
     for ( const TObject *iter = GetFirstInputObject(fInputDataType); iter != NULL; iter = GetNextInputObject() ) {  
       tD = dynamic_cast<TTree*>(const_cast<TObject*>( iter ) );
       if(!tD){
@@ -314,8 +388,9 @@ int AliHLTITSClusterFinderComponent::DoEvent
       fDettype->MakeBranch(tR,"R");
       fDettype->SetTreeAddressR(tR);
       Option_t *opt="All";
+      fBenchmark.Start(1);
       fDettype->DigitsToRecPoints(tD,tR,0,opt,kTRUE);
-      
+      fBenchmark.Stop(1);
       TClonesArray * fRecPoints;
       tR->SetBranchAddress("ITSRecPoints",&fRecPoints);
       for(Int_t treeEntry=0;treeEntry<tR->GetEntries();treeEntry++){
@@ -338,9 +413,9 @@ int AliHLTITSClusterFinderComponent::DoEvent
        break;          
       }
       if( nClusters>0 ){
-
+       fBenchmark.Start(1);
        RecPointToSpacePoint(outputPtr,size);
-       
+       fBenchmark.Stop(1);
        AliHLTComponentBlockData bd;
        FillBlockData( bd );
        bd.fOffset = size;
@@ -349,7 +424,7 @@ int AliHLTITSClusterFinderComponent::DoEvent
        bd.fDataType = GetOutputDataType();
        outputBlocks.push_back( bd );
        size += bufferSize;
-       
+       fBenchmark.AddOutput(bd.fSize);
        fclusters.clear();      
       }
     }
@@ -383,11 +458,17 @@ int AliHLTITSClusterFinderComponent::DoEvent
       
       // -- Set equipment ID to the raw reader
       
+      if(!fRawReader){
+       HLTWarning("The fRawReader pointer is NULL");
+       continue;
+      }
+
       if(!fRawReader->AddBuffer((UChar_t*) iter->fPtr, iter->fSize, id)){
        HLTWarning("Could not add buffer");
       }
-      // TStopwatch timer1;
-      
+
+      fBenchmark.Start(1);
+
       if(fModeSwitch==kClusterFinderSPD && !fUseOfflineFinder){ fSPD->RawdataToClusters( fRawReader, fclusters ); }
       else if(fModeSwitch==kClusterFinderSSD && !fUseOfflineFinder){ fSSD->RawdataToClusters( fclusters ); }
       else{
@@ -406,10 +487,7 @@ int AliHLTITSClusterFinderComponent::DoEvent
          fClusters[i] = NULL;
        }     
       }
-      
-      // timer1.Stop();
-      // fStatTime+=timer1.RealTime();
-      // fStatTimeC+=timer1.CpuTime();
+      fBenchmark.Stop(1);
       
       fRawReader->ClearBuffers();    
          
@@ -433,23 +511,15 @@ int AliHLTITSClusterFinderComponent::DoEvent
        bd.fDataType = GetOutputDataType();
        outputBlocks.push_back( bd );
        size += bufferSize;
-       
+       fBenchmark.AddOutput(bd.fSize);
        fclusters.clear();      
       }
       
     } // input blocks
   }
-  /*
-  timer.Stop();
-  
-  fStatTimeAll+=timer.RealTime();
-  fStatTimeAllC+=timer.CpuTime();
-  fStatNEv++;
-  if( fStatNEv%1000==0 && fStatTimeAll>0.0 && fStatTime>0.0 && fStatTimeAllC>0.0 && fStatTimeC>0.0)
-    cout<<fStatTimeAll/fStatNEv*1.e3<<" "<<fStatTime/fStatNEv*1.e3<<" "
-       <<fStatTimeAllC/fStatNEv*1.e3<<" "<<fStatTimeC/fStatNEv*1.e3<<" ms"<<endl;
-  */
 
+  fBenchmark.Stop(0);
+  HLTInfo(fBenchmark.GetStatistics());
   return ret;
 }
 
@@ -525,7 +595,7 @@ void AliHLTITSClusterFinderComponent::RecPointToSpacePoint(AliHLTUInt8_t* output
   AliHLTITSClusterData *outputClusters = reinterpret_cast<AliHLTITSClusterData*>(outputPtr + size);
   outputClusters->fSpacePointCnt=fclusters.size();    
   int clustIdx=0;
-  for(int i=0;i<fclusters.size();i++){
+  for(UInt_t i=0;i<fclusters.size();i++){
     AliITSRecPoint *recpoint = (AliITSRecPoint*) &(fclusters[i]);
     outputClusters->fSpacePoints[clustIdx].fY=recpoint->GetY();
     outputClusters->fSpacePoints[clustIdx].fZ=recpoint->GetZ();