//* This file is property of and copyright by the ALICE HLT Project *
//* ALICE Experiment at CERN, All rights reserved. *
//* *
-//* Primary Authors: Gaute Øvrebekk <st05886@alf.uib.no> *
+//* Primary Authors: Gaute Ovrebekk <st05886@alf.uib.no> *
//* for The ALICE HLT Project. *
//* *
//* Permission to use, copy, modify and distribute this software and its *
//* provided "as is" without express or implied warranty. *
//**************************************************************************
-/** @file AliHLTITSClusterFinderComponent.cxx
- @author Gaute Øvrebekk <st05886@alf.uib.no>
- @date
- @brief Component to run offline clusterfinders
-*/
+/// @file AliHLTITSClusterFinderComponent.cxx
+/// @author Gaute Ovrebekk <st05886@alf.uib.no>
+/// @date
+/// @brief Component to run offline clusterfinders
+///
#if __GNUC__>= 3
using namespace std;
#include "AliHLTITSClusterFinderSSD.h"
#include "TMap.h"
#include "AliITSRecPointContainer.h"
+#include "AliRunLoader.h"
+#include "AliLoader.h"
#include <cstdlib>
#include <cerrno>
fSPDNModules(0),
fSDDNModules(0),
fSSDNModules(0),
+ fFirstModule(0),
+ fLastModule(0),
+ fnClusters(0),
fclusters(),
- fBenchmark(GetComponentID())
+ fBenchmark(GetComponentID()),
+ fOutputSizeOffset(0),
+ fInputMultiplierDigits(20),
+ fpLoader(NULL)
{
// see header file for class documentation
// or
void AliHLTITSClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
// see header file for class documentation
- constBase = 0;
- inputMultiplier = 100;
+ constBase = fOutputSizeOffset;
+ switch(fModeSwitch){
+ case kClusterFinderDigits:
+ inputMultiplier = fInputMultiplierDigits;
+ break;
+ case kClusterFinderSPD:
+ case kClusterFinderSDD:
+ case kClusterFinderSSD:
+ default:
+ inputMultiplier = 20;
+ }
}
AliHLTComponent* AliHLTITSClusterFinderComponent::Spawn() {
Int_t runNo = GetRunNo();
AliCDBStorage* store = AliCDBManager::Instance()->GetDefaultStorage();
if (!store) {
- return NULL;
+ return -ENOENT;
}
bool cdbOK = true;
HLTError("Scalers is not found in GRP/CTP/");
cdbOK = false;
}
- if(!cdbOK){return NULL;}
+ if(!cdbOK){return -EIO;}
if(fModeSwitch==kClusterFinderSPD) {
HLTDebug("using ClusterFinder for SPD");
fNddl=AliHLTDAQ::NumberOfDdls("ITSSSD");
}
else if(fModeSwitch==kClusterFinderDigits) {
- //tR = new TTree();
+ tR = new TTree();
}
else{
HLTFatal("No mode set for clusterfindercomponent");
}
tD = NULL;
- tR = NULL;
+ //tR = NULL;
return Configure( arguments.Data() );
}
fUseOfflineFinder = 0;
+ if (fpLoader) {
+ fpLoader->UnloadDigits();
+ }
+ fpLoader=NULL;
+
return 0;
}
return 0;
}
+ AliHLTUInt32_t totalInputSize=0;
fBenchmark.StartNewEvent();
fBenchmark.Start(0);
for( const AliHLTComponentBlockData *i= GetFirstInputBlock(fInputDataType); i!=NULL; i=GetNextInputBlock() ){
+ totalInputSize+=i->fSize;
fBenchmark.AddInput(i->fSize);
}
//
// 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();
+ //
+ // 2011-01-28 hotfix reloaded: accessing the files like that fails if there are
+ // multiple digit files because of a large number of events. New ugly fix is to
+ // use the global runloader instance to get hold on the digits tree.
+ fnClusters = 0;
+ AliRunLoader* pRunLoader=AliRunLoader::Instance();
+ if (!pRunLoader) {
+ HLTError("failed to get global runloader instance");
+ return -ENOSYS;
+ }
+ // get the specific loader for the module
+ if (!fpLoader) {
+ const char* loaderType="ITSLoader";
+ fpLoader=pRunLoader->GetLoader(loaderType);
+ if (!fpLoader) {
+ HLTError("can not get loader \"%s\" from runloader", loaderType);
+ return -ENOSYS;
+ }
+ // prepare the loader
+ fpLoader->LoadDigits("read");
+ }
+ pRunLoader->GetEvent(GetEventCount());
+
+ tD=fpLoader->TreeD();
+ tR->Reset();
tR->SetDirectory(0);
fDettype->SetTreeAddressD(tD);
fDettype->MakeBranch(tR,"R");
tR->SetBranchAddress("ITSRecPoints",&fRecPoints);
for(Int_t treeEntry=0;treeEntry<tR->GetEntries();treeEntry++){
tR->GetEntry(treeEntry);
- for(Int_t tCloneEntry=0;tCloneEntry<fRecPoints->GetEntries();tCloneEntry++){
- AliITSRecPoint *recpoint=(AliITSRecPoint*)fRecPoints->At(tCloneEntry);
- fclusters.push_back(*recpoint);
- }
- }
-
- if(tR){
- tR->Delete();
+ fnClusters += fRecPoints->GetEntries();
}
- tD->SetDirectory(0);
- delete dummy;
- UInt_t nClusters=fclusters.size();
-
- UInt_t bufferSize = nClusters * sizeof(AliHLTITSSpacePointData) + sizeof(AliHLTITSClusterData);
+ UInt_t bufferSize = fnClusters * sizeof(AliHLTITSSpacePointData) + sizeof(AliHLTITSClusterData);
if( size + bufferSize > maxBufferSize ){
- HLTWarning( "Output buffer size exceed (buffer size %d, current size %d)", maxBufferSize, size+bufferSize);
+ //HLTWarning( "Output buffer size exceed (buffer size %d, required size %d)", maxBufferSize, size+bufferSize);
+ if (totalInputSize>0) {
+ fInputMultiplierDigits=(float)(size+bufferSize)/totalInputSize;
+ fInputMultiplierDigits+=1.;
+ } else {
+ fOutputSizeOffset=totalInputSize;
+ fInputMultiplierDigits=1.;
+ }
ret = -ENOSPC;
break;
}
- if( nClusters>0 ){
+ if( fnClusters>0 ){
fBenchmark.Start(1);
RecPointToSpacePoint(outputPtr,size);
fBenchmark.Stop(1);
outputBlocks.push_back( bd );
size += bufferSize;
fBenchmark.AddOutput(bd.fSize);
- fclusters.clear();
}
}
}
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() ) {
+
+ if(fUseOfflineFinder){
+ if(fModeSwitch==kClusterFinderSPD){rpc->ResetSPD();}
+ if(fModeSwitch==kClusterFinderSSD){rpc->ResetSSD();}
+ }
+ if(fModeSwitch==kClusterFinderSDD){rpc->ResetSDD();}
// -- Debug output of datatype --
HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
fBenchmark.Start(1);
+ fnClusters = 0;
+
if(fModeSwitch==kClusterFinderSPD && !fUseOfflineFinder){ fSPD->RawdataToClusters( fRawReader, fclusters ); }
else if(fModeSwitch==kClusterFinderSSD && !fUseOfflineFinder){ fSSD->RawdataToClusters( fclusters ); }
else{
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);
- }
+ fnClusters += clusters->GetEntriesFast();
}
}
}
-
- if(fUseOfflineFinder){
- if(fModeSwitch==kClusterFinderSPD){rpc->ResetSPD();}
- if(fModeSwitch==kClusterFinderSSD){rpc->ResetSSD();}
- }
- if(fModeSwitch==kClusterFinderSDD){rpc->ResetSDD();}
-
+
+ /* Do not work
+ if(fModeSwitch==kClusterfinderSPD){
+ fnClusters = rpc->GetNClustersInLayerFast(1) + rpc->GetNClustersInLayerFast(2);
+ }
+ if(fModeSwitch==kClusterfinderSDD){
+ fnClusters = rpc->GetNClustersInLayerFast(3) + rpc->GetNClustersInLayerFast(4);
+ }
+ if(fModeSwitch==kClusterfinderSSD){
+ fnClusters = rpc->GetNClustersInLayerFast(5) + rpc->GetNClustersInLayerFast(6);
+ }
+ */
+
fBenchmark.Stop(1);
fRawReader->ClearBuffers();
-
- UInt_t nClusters=fclusters.size();
- UInt_t bufferSize = nClusters * sizeof(AliHLTITSSpacePointData) + sizeof(AliHLTITSClusterData);
+ UInt_t nClusters=fclusters.size();
+ if(nClusters>0){fnClusters = nClusters;}
+
+ UInt_t bufferSize = fnClusters * sizeof(AliHLTITSSpacePointData) + sizeof(AliHLTITSClusterData);
if( size + bufferSize > maxBufferSize ){
HLTWarning( "Output buffer size exceed (buffer size %d, current size %d)", maxBufferSize, size+bufferSize);
ret = -ENOSPC;
break;
}
- if( nClusters>0 ){
+ if( fnClusters>0 ){
RecPointToSpacePoint(outputPtr,size);
outputBlocks.push_back( bd );
size += bufferSize;
fBenchmark.AddOutput(bd.fSize);
- fclusters.clear();
+ if(nClusters>0){fclusters.clear();}
}
} // input blocks
// see header file for class documentation
int iResult=0;
- const char* path="HLT/ConfigITS/ClusterFinderComponent";
+ const char* path="";
+
+ switch(fModeSwitch){
+ case kClusterFinderSPD:
+ path = "HLT/ConfigITS/ITSClusterFinderSPD";
+ break;
+ case kClusterFinderSDD:
+ path = "HLT/ConfigITS/ITSClusterFinderSDD";
+ break;
+ case kClusterFinderSSD:
+ path = "HLT/ConfigITS/ITSClusterFinderSSD";
+ break;
+ case kClusterFinderDigits:
+ path = "";
+ break;
+ default:
+ HLTFatal("unknown cluster finder");
+ }
+
const char* defaultNotify="";
if (cdbEntry) {
path=cdbEntry;
void AliHLTITSClusterFinderComponent::RecPointToSpacePoint(AliHLTUInt8_t* outputPtr,AliHLTUInt32_t& size){
AliHLTITSClusterData *outputClusters = reinterpret_cast<AliHLTITSClusterData*>(outputPtr + size);
- outputClusters->fSpacePointCnt=fclusters.size();
+ outputClusters->fSpacePointCnt=fnClusters;
int clustIdx=0;
- 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();
- outputClusters->fSpacePoints[clustIdx].fSigmaY2=recpoint->GetSigmaY2();
- outputClusters->fSpacePoints[clustIdx].fSigmaZ2=recpoint->GetSigmaZ2();
- outputClusters->fSpacePoints[clustIdx].fSigmaYZ=recpoint->GetSigmaYZ();
- outputClusters->fSpacePoints[clustIdx].fQ=recpoint->GetQ();
- outputClusters->fSpacePoints[clustIdx].fNy=recpoint->GetNy();
- outputClusters->fSpacePoints[clustIdx].fNz=recpoint->GetNz();
- outputClusters->fSpacePoints[clustIdx].fLayer=recpoint->GetLayer();
- outputClusters->fSpacePoints[clustIdx].fIndex=recpoint->GetDetectorIndex() | recpoint->GetPindex() | recpoint->GetNindex();
- outputClusters->fSpacePoints[clustIdx].fTracks[0]=recpoint->GetLabel(0);
- outputClusters->fSpacePoints[clustIdx].fTracks[1]=recpoint->GetLabel(1);
- outputClusters->fSpacePoints[clustIdx].fTracks[2]=recpoint->GetLabel(2);
- clustIdx++;
+ if(fModeSwitch==kClusterFinderDigits) {
+ TClonesArray * fRecPoints = NULL;
+ tR->SetBranchAddress("ITSRecPoints",&fRecPoints);
+ for(Int_t treeEntry=0;treeEntry<tR->GetEntries();treeEntry++){
+ tR->GetEntry(treeEntry);
+ fnClusters += fRecPoints->GetEntries();
+ for(Int_t tCloneEntry=0;tCloneEntry<fRecPoints->GetEntries();tCloneEntry++){
+ AliITSRecPoint *recpoint=(AliITSRecPoint*)fRecPoints->At(tCloneEntry);
+ RecpointToOutput(outputClusters,recpoint,clustIdx);
+ }
+ }
}
+ else if(fclusters.size()>0){
+ for(UInt_t i=0;i<fclusters.size();i++){
+ AliITSRecPoint *recpoint = (AliITSRecPoint*) &(fclusters[i]);
+ RecpointToOutput(outputClusters,recpoint,clustIdx);
+ }
+ }
+ else{
+ AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance();
+ TClonesArray* clusters = NULL;
+ for(Int_t i=fFirstModule;i<fLastModule;i++){
+ clusters = rpc->UncheckedGetClusters(i);
+ for(Int_t j=0;j<clusters->GetEntriesFast();j++){
+ AliITSRecPoint *recpoint = (AliITSRecPoint*) clusters->At(j);
+ RecpointToOutput(outputClusters,recpoint,clustIdx);
+ }
+ }
+ }
+}
+
+void AliHLTITSClusterFinderComponent::RecpointToOutput(AliHLTITSClusterData *outputClusters, AliITSRecPoint *recpoint, int &clustIdx){
+ outputClusters->fSpacePoints[clustIdx].fY=recpoint->GetY();
+ outputClusters->fSpacePoints[clustIdx].fZ=recpoint->GetZ();
+ outputClusters->fSpacePoints[clustIdx].fSigmaY2=recpoint->GetSigmaY2();
+ outputClusters->fSpacePoints[clustIdx].fSigmaZ2=recpoint->GetSigmaZ2();
+ outputClusters->fSpacePoints[clustIdx].fSigmaYZ=recpoint->GetSigmaYZ();
+ outputClusters->fSpacePoints[clustIdx].fQ=recpoint->GetQ();
+ outputClusters->fSpacePoints[clustIdx].fNy=recpoint->GetNy();
+ outputClusters->fSpacePoints[clustIdx].fNz=recpoint->GetNz();
+ outputClusters->fSpacePoints[clustIdx].fLayer=recpoint->GetLayer();
+ outputClusters->fSpacePoints[clustIdx].fIndex=recpoint->GetDetectorIndex() | recpoint->GetPindex() | recpoint->GetNindex();
+ outputClusters->fSpacePoints[clustIdx].fTracks[0]=recpoint->GetLabel(0);
+ outputClusters->fSpacePoints[clustIdx].fTracks[1]=recpoint->GetLabel(1);
+ outputClusters->fSpacePoints[clustIdx].fTracks[2]=recpoint->GetLabel(2);
+ clustIdx++;
}