Skip to content

Commit b1f0e65

Browse files
committed
Initial commit of the groundwork for the Hough Transform implementation
1 parent d6e7a57 commit b1f0e65

5 files changed

Lines changed: 151 additions & 6 deletions

File tree

devices/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
add_subdirectory (aliceHLTwrapper)
12
add_subdirectory (flp2epn)
23
add_subdirectory (flp2epn-dynamic)
34
add_subdirectory (flp2epn-distributed)
4-
add_subdirectory (aliceHLTwrapper)
5+
if(ALIROOT)
6+
add_subdirectory (hough)
7+
endif(ALIROOT)
58
add_subdirectory (roundtrip)

devices/aliceHLTwrapper/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set(INCLUDE_DIRECTORIES
2-
${BASE_INCLUDE_DIRECTORIES}
2+
${BASE_INCLUDE_DIRECTORIES}
33
${ZMQ_INCLUDE_DIR}
44
${Boost_INCLUDE_DIR}
55
${CMAKE_SOURCE_DIR}/devices/aliceHLTwrapper
@@ -50,7 +50,7 @@ Set(Exe_Names
5050
runComponent
5151
)
5252

53-
set(Exe_Source
53+
set(Exe_Source
5454
aliceHLTWrapper.cxx
5555
runComponent.cxx
5656
)
@@ -66,3 +66,4 @@ ForEach(_file RANGE 0 ${_length})
6666
set(DEPENDENCIES ALICEHLT dl)
6767
GENERATE_EXECUTABLE()
6868
EndForEach(_file RANGE 0 ${_length})
69+

devices/hough/CMakeLists.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
set(INCLUDE_DIRECTORIES
2+
${BASE_INCLUDE_DIRECTORIES}
3+
${Boost_INCLUDE_DIR}
4+
${ALIROOT}/include
5+
${SIMPATH}/include/root
6+
)
7+
8+
include_directories(${INCLUDE_DIRECTORIES})
9+
10+
set(LINK_DIRECTORIES
11+
${Boost_LIBRARY_DIRS}
12+
${ALIROOT}/lib
13+
${SIMPATH}/lib/root
14+
)
15+
16+
link_directories(${LINK_DIRECTORIES})
17+
18+
set(SRCS
19+
runHough.cxx
20+
)
21+
22+
Set(Exe_Names
23+
runHough
24+
)
25+
26+
set(Exe_Source
27+
runHough.cxx
28+
)
29+
30+
list(LENGTH Exe_Names _length)
31+
math(EXPR _length ${_length}-1)
32+
33+
ForEach(_file RANGE 0 ${_length})
34+
list(GET Exe_Names ${_file} _name)
35+
list(GET Exe_Source ${_file} _src)
36+
set(EXE_NAME ${_name})
37+
set(SRCS ${_src})
38+
set(DEPENDENCIES dl Core AliHLTTPC HLTbase boost_system boost_filesystem)
39+
GENERATE_EXECUTABLE()
40+
EndForEach(_file RANGE 0 ${_length})
41+

devices/hough/runHough.cxx

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/// \file runHough.cxx
2+
/// \brief Implementation of a cluster loader
3+
/// \author Charis Kouzinopoulos
4+
5+
#include "AliHLTTPCTrackGeometry.h"
6+
#include "AliHLTTPCClusterDataFormat.h"
7+
#include "AliHLTTPCSpacePointContainer.h"
8+
#include "AliHLTComponent.h"
9+
10+
#include "boost/filesystem.hpp"
11+
12+
#include <sstream>
13+
14+
int processData(std::string dataFileName, std::string dataType, std::string dataOrigin)
15+
{
16+
std::ifstream inputData(dataFileName.c_str(), std::ifstream::binary);
17+
if (!inputData) {
18+
std::cerr << "Error, cluster data file " << dataFileName << " could not be accessed" << endl;
19+
std::exit(1);
20+
}
21+
22+
// Get length of file
23+
inputData.seekg(0, inputData.end);
24+
int dataLength = inputData.tellg();
25+
inputData.seekg(0, inputData.beg);
26+
27+
// Allocate memory and read file to memory
28+
char* inputBuffer = new char[dataLength];
29+
inputData.read(inputBuffer, dataLength);
30+
inputData.close();
31+
32+
// Cast data to an AliHLTUInt8_t*, AliHLTComponentBlockData* and AliHLTTPCClusterData* data type
33+
AliHLTUInt8_t* pData = reinterpret_cast<AliHLTUInt8_t*>(&inputBuffer[0]);
34+
AliHLTComponentBlockData* bdTarget = reinterpret_cast<AliHLTComponentBlockData*>(&inputBuffer[0]);
35+
AliHLTTPCClusterData* pClusterData = reinterpret_cast<AliHLTTPCClusterData*>(inputBuffer);
36+
37+
// Create a collection of all points
38+
std::auto_ptr<AliHLTTPCSpacePointContainer> spacepoints(new AliHLTTPCSpacePointContainer);
39+
if (!spacepoints.get()) {
40+
std::cerr << "Error, could not create a space point collection" << endl;
41+
std::exit(1);
42+
}
43+
44+
// Determine the number of clusters from the header of the data file
45+
pClusterData->fSpacePointCnt = ((int)inputBuffer[1] << 8) + (int)inputBuffer[0];
46+
47+
AliHLTComponent::SetDataType(bdTarget->fDataType, dataType.c_str(), dataOrigin.c_str());
48+
49+
// AliHLTTPCDefinitions::EncodeDataSpecification(currentSlice, currentSlice, currentPartition, currentPartition);
50+
bdTarget->fSpecification = kAliHLTVoidDataSpec;
51+
bdTarget->fPtr = inputBuffer;
52+
bdTarget->fSize = sizeof(AliHLTTPCClusterData) + pClusterData->fSpacePointCnt * sizeof(AliHLTTPCSpacePointData);
53+
54+
int numberOfClusters = spacepoints->AddInputBlock(bdTarget);
55+
56+
// cout << *spacepoints << endl;
57+
58+
if (inputBuffer) {
59+
delete[] inputBuffer;
60+
}
61+
inputBuffer = NULL;
62+
63+
return numberOfClusters;
64+
}
65+
66+
int main(int argc, char** argv)
67+
{
68+
if (argc != 2) {
69+
std::cerr << "Usage: " << argv[0] << " <event number>" << endl;
70+
std::exit(1);
71+
}
72+
73+
// Create data path
74+
std::string dataPath = "emulated-tpc-clusters/event";
75+
dataPath += argv[1];
76+
77+
boost::filesystem::path someDir(dataPath);
78+
boost::filesystem::directory_iterator end_iter;
79+
80+
typedef std::multimap<std::time_t, boost::filesystem::path> result_set_t;
81+
result_set_t result_set;
82+
83+
std::string dataType = "CLUSTERS", dataOrigin = "TPC ";
84+
85+
int totalNumberOfClusters = 0, totalNumberOfDataFiles = 0;
86+
87+
if (boost::filesystem::exists(someDir) && boost::filesystem::is_directory(someDir)) {
88+
for (boost::filesystem::directory_iterator dir_iter(someDir); dir_iter != end_iter; ++dir_iter) {
89+
if (boost::filesystem::is_regular_file(dir_iter->status())) {
90+
totalNumberOfClusters += processData(dir_iter->path().string(), dataType, dataOrigin);
91+
totalNumberOfDataFiles++;
92+
}
93+
}
94+
} else {
95+
std::cerr << "Path " << someDir.string() << "/ could not be found or does not contain any valid data files" << endl;
96+
exit(1);
97+
}
98+
99+
cout << "Added " << totalNumberOfClusters << " clusters from " << totalNumberOfDataFiles << " data files" << endl;
100+
return 0;
101+
}

tpc/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# The extension is already found. Any number of sources could be listed here.
44

55
set(INCLUDE_DIRECTORIES
6-
${ROOT_INCLUDE_DIR}
6+
${ROOT_INCLUDE_DIR}
77
${BASE_INCLUDE_DIRECTORIES}
88
${Boost_INCLUDE_DIRS}
99
${FAIRROOT_INCLUDE_DIR}
@@ -18,8 +18,7 @@ include_directories( ${INCLUDE_DIRECTORIES})
1818
set(LINK_DIRECTORIES
1919
${ROOT_LIBRARY_DIR}
2020
${FAIRROOT_LIBRARY_DIR}
21-
22-
)
21+
)
2322

2423
link_directories( ${LINK_DIRECTORIES})
2524

0 commit comments

Comments
 (0)