#include "AliHLTTPCMemHandler.h"
#include "AliHLTTPCPad.h"
#include "AliHLTTPCPadArray.h"
+#include <sys/time.h>
#if __GNUC__ >= 3
using namespace std;
fOccupancyLimit(1.0),
fPadArray(NULL),
fUnsorted(0),
- fActivePads()
+ fActivePads(),
+ fNumberOfPadsInRow(NULL),
+ fNumberOfRows(0),
+ fRowPadVector(),
+ fClusters(),
+ fVectorInitialized(kFALSE),
+ fRowOfFirstCandidate(0)
{
- //constructor
+ //constructor
}
AliHLTTPCClusterFinder::~AliHLTTPCClusterFinder()
{
//destructor
+ if(fVectorInitialized){
+ DeInitializePadArray();
+ }
+ if(fNumberOfPadsInRow){
+ delete [] fNumberOfPadsInRow;
+ fNumberOfPadsInRow=NULL;
+ }
}
void AliHLTTPCClusterFinder::InitSlice(Int_t slice,Int_t patch,Int_t firstrow, Int_t lastrow,Int_t nmaxpoints)
fLastRow = lastrow;
}
+void AliHLTTPCClusterFinder::InitializePadArray(){
+ // see header file for class documentation
+
+ if(fCurrentPatch>5||fCurrentPatch<0){
+ HLTFatal("Patch is not set");
+ return;
+ }
+
+ HLTDebug("Patch number=%d",fCurrentPatch);
+
+ fFirstRow = AliHLTTPCTransform::GetFirstRow(fCurrentPatch);
+ fLastRow = AliHLTTPCTransform::GetLastRow(fCurrentPatch);
+
+ fNumberOfRows=fLastRow-fFirstRow+1;
+ fNumberOfPadsInRow= new UInt_t[fNumberOfRows];
+
+ memset( fNumberOfPadsInRow, 0, sizeof(Int_t)*(fNumberOfRows));
+
+ for(Int_t i=0;i<fNumberOfRows;i++){
+ fNumberOfPadsInRow[i]=AliHLTTPCTransform::GetNPads(i+fFirstRow);
+ AliHLTTPCPadVector tmpRow;
+ for(Int_t j=0;j<fNumberOfPadsInRow[i];j++){
+ AliHLTTPCPad *tmpPad = new AliHLTTPCPad(2);
+ tmpPad->SetID(i,j);
+ tmpRow.push_back(tmpPad);
+ }
+ fRowPadVector.push_back(tmpRow);
+ }
+ fVectorInitialized=kTRUE;
+}
+
+Int_t AliHLTTPCClusterFinder::DeInitializePadArray()
+{
+ // see header file for class documentation
+ for(Int_t i=0;i<fNumberOfRows;i++){
+ for(Int_t j=0;j<fNumberOfPadsInRow[i];j++){
+ delete fRowPadVector[i][j];
+ fRowPadVector[i][j]=NULL;
+ }
+ fRowPadVector[i].clear();
+ }
+ fRowPadVector.clear();
+ return 1;
+}
+
+
void AliHLTTPCClusterFinder::InitSlice(Int_t slice,Int_t patch,Int_t nmaxpoints)
{
//init slice
}
}
- if (fActivePads.size()==0 ||
- fActivePads.back().fRow!=fCurrentRow-rowOffset ||
- fActivePads.back().fPad!=pad) {
- AliHLTTPCPadArray::AliHLTTPCActivePads entry;
- entry.fRow=fCurrentRow-rowOffset;
- entry.fPad=pad;
- fActivePads.push_back(entry);
- }
-
+ /* if (fActivePads.size()==0 ||
+ fActivePads.back().fRow!=fCurrentRow-rowOffset ||
+ fActivePads.back().fPad!=pad) {
+ AliHLTTPCPadArray::AliHLTTPCActivePads entry;
+ entry.fRow=fCurrentRow-rowOffset;
+ entry.fPad=pad;
+ fActivePads.push_back(entry);
+ }
+ */
if (pCurrentPad) {
Float_t occupancy=pCurrentPad->GetOccupancy();
//HLTDebug("pad %d occupancy level: %f", pCurrentPad->GetPadNumber(), occupancy);
}
}
if(fStdout==kTRUE)
- cout<<"WriteCluster: padrow "<<fCurrentRow<<" pad "<<fpad << " +- "<<fpad2<<" time "<<ftime<<" +- "<<ftime2<<" charge "<<list[j].fTotalCharge<<endl;
+ HLTInfo("WriteCluster: padrow %d pad %d +- %d time +- %d charge %d",fCurrentRow, fpad, fpad2, ftime, ftime2, list[j].fTotalCharge);
if(!fRawSP){
AliHLTTPCTransform::Slice2Sector(fCurrentSlice,fCurrentRow,thissector,thisrow);
fSpacePointData[counter].fTrackID[1] = trackID[1];
fSpacePointData[counter].fTrackID[2] = trackID[2];
- //cout<<"padrow "<<fCurrentRow<<" pad "<<(Int_t)rint(fpad)<<" time "<<(Int_t)rint(ftime)<<" Trackid "<<trackID[0]<<endl;
#endif
fNClusters++;
AliHLTTPCDigitRowData *rowPt = (AliHLTTPCDigitRowData*)fDigitRowData;
trackID[0]=trackID[1]=trackID[2]=-2;
- //cout<<"Looking for pad "<<pad<<" time "<<time<<endl;
for(Int_t i=fFirstRow; i<=fLastRow; i++){
if(rowPt->fRow < (UInt_t)fCurrentRow){
AliHLTTPCMemHandler::UpdateRowPointer(rowPt);
trackID[1] = digPt[j].fTrackID[1];
trackID[2] = digPt[j].fTrackID[2];
- //cout<<"Reading row "<<fCurrentRow<<" pad "<<cpad<<" time "<<ctime<<" trackID "<<digPt[j].fTrackID[0]<<endl;
break;
}
break;
fPadArray=padArray;
}
-void AliHLTTPCClusterFinder::ReadDataUnsorted(void* ptr,unsigned long size)
+void AliHLTTPCClusterFinder::ReadDataUnsorted(void* ptr,unsigned long size, Int_t mode)
{
//set input pointer
fPtr = (UChar_t*)ptr;
fSize = size;
- fDigitReader->InitBlock(fPtr,fSize,fFirstRow,fLastRow,fCurrentPatch,fCurrentSlice);
-
- fPadArray->SetDigitReader(fDigitReader);
+ if(!fVectorInitialized){
+ InitializePadArray();
+ }
- if(fSignalThreshold>0){
- fPadArray->SetSignalThreshold(fSignalThreshold);
+ fDigitReader->InitBlock(fPtr,fSize,fFirstRow,fLastRow,fCurrentPatch,fCurrentSlice);
+
+ while(fDigitReader->NextChannel()){
+ UInt_t row=fDigitReader->GetRow();
+ UInt_t pad=fDigitReader->GetPad();
+ fRowPadVector[row][pad]->ClearCandidates();
+ while(fDigitReader->NextBunch()){
+ if(fDigitReader->GetBunchSize()>1){//to remove single timebin values, this will have to change at some point
+ const UInt_t *bunchData= fDigitReader->GetSignals();
+ UInt_t time = fDigitReader->GetTime();
+ AliHLTTPCClusters candidate;
+ for(Int_t i=0;i<fDigitReader->GetBunchSize();i++){
+ candidate.fTotalCharge+=bunchData[i];
+ candidate.fTime += time*bunchData[i];
+ candidate.fTime2 += time*time*bunchData[i];
+ time++;
+ }
+ if(candidate.fTotalCharge>0){
+ candidate.fMean=candidate.fTime/candidate.fTotalCharge;
+ candidate.fPad=candidate.fTotalCharge*pad;
+ candidate.fPad2=candidate.fPad*pad;
+ candidate.fLastMergedPad=pad;
+ candidate.fRowNumber=row;
+ }
+ fRowPadVector[row][pad]->AddClusterCandidate(candidate);
+ }
+ }
}
- if(fNSigmaThreshold>0){
- fPadArray->SetNSigmaThreshold(fNSigmaThreshold);
+}
+
+Bool_t AliHLTTPCClusterFinder::ComparePads(AliHLTTPCPad *nextPad,AliHLTTPCClusters* cluster,Int_t nextPadToRead){
+ //Checking if we have a match on the next pad
+ for(Int_t candidateNumber=0;candidateNumber<nextPad->fClusterCandidates.size();candidateNumber++){
+ AliHLTTPCClusters *candidate =&nextPad->fClusterCandidates[candidateNumber];
+ if(cluster->fMean-candidate->fMean==1 || candidate->fMean-cluster->fMean==1 || cluster->fMean-candidate->fMean==0){
+ cluster->fMean=candidate->fMean;
+ cluster->fTotalCharge+=candidate->fTotalCharge;
+ cluster->fTime += candidate->fTime;
+ cluster->fTime2 += candidate->fTime2;
+ cluster->fPad+=candidate->fPad;
+ cluster->fPad2=candidate->fPad2;
+ cluster->fLastMergedPad=candidate->fPad;
+
+ //setting the matched pad to used
+ nextPad->fUsedClusterCandidates[candidateNumber]=1;
+ nextPadToRead++;
+ if(nextPadToRead<fNumberOfPadsInRow[fRowOfFirstCandidate]){
+ nextPad=fRowPadVector[fRowOfFirstCandidate][nextPadToRead];
+ ComparePads(nextPad,cluster,nextPadToRead);
+ }
+ else{
+ return kFALSE;
+ }
+ }
+ else{
+ return kFALSE;
+ }
}
- fPadArray->ReadData();
+ return kFALSE;
}
void AliHLTTPCClusterFinder::FindClusters()
{
// see header file for function documentation
- fPadArray->FindClusterCandidates();
- fPadArray->FindClusters(fMatch);
-
- AliClusterData * clusterlist = new AliClusterData[fPadArray->fClusters.size()]; //Clusterlist
- for(unsigned int i=0;i<fPadArray->fClusters.size();i++){
- clusterlist[i].fTotalCharge = fPadArray->fClusters[i].fTotalCharge;
- clusterlist[i].fPad = fPadArray->fClusters[i].fPad;
- clusterlist[i].fPad2 = fPadArray->fClusters[i].fPad2;
- clusterlist[i].fTime = fPadArray->fClusters[i].fTime;
- clusterlist[i].fTime2 = fPadArray->fClusters[i].fTime2;
- clusterlist[i].fMean = fPadArray->fClusters[i].fMean;
- clusterlist[i].fFlags = fPadArray->fClusters[i].fFlags;
- clusterlist[i].fChargeFalling = fPadArray->fClusters[i].fChargeFalling;
- clusterlist[i].fLastCharge = fPadArray->fClusters[i].fLastCharge;
- clusterlist[i].fLastMergedPad = fPadArray->fClusters[i].fLastMergedPad;
- clusterlist[i].fRow = fPadArray->fClusters[i].fRowNumber;
+
+ AliHLTTPCClusters* tmpCandidate=NULL;
+ for(Int_t row=0;row<fNumberOfRows;row++){
+ fRowOfFirstCandidate=row;
+ for(Int_t pad=0;pad<fNumberOfPadsInRow[row]-1;pad++){
+ AliHLTTPCPad *tmpPad=fRowPadVector[row][pad];
+ for(size_t candidate=0;candidate<tmpPad->fClusterCandidates.size();candidate++){
+ if(tmpPad->fUsedClusterCandidates[candidate]){
+ continue;
+ }
+ tmpCandidate=&tmpPad->fClusterCandidates[candidate];
+ UInt_t tmpTotalCharge=tmpCandidate->fTotalCharge;
+ ComparePads(fRowPadVector[row][pad+1],tmpCandidate,pad+1);
+ if(tmpCandidate->fTotalCharge>tmpTotalCharge){
+ //we have a cluster
+ fClusters.push_back(*tmpCandidate);
+ }
+ }
+ }
}
- WriteClusters(fPadArray->fClusters.size(),clusterlist);
+
+ HLTInfo("Found %d clusters.",fClusters.size());
+
+ //TODO: Change so it stores AliHLTTPCSpacePointData directly, instead of this copying
+
+ AliClusterData * clusterlist = new AliClusterData[fClusters.size()]; //Clusterlist
+ for(unsigned int i=0;i<fClusters.size();i++){
+ clusterlist[i].fTotalCharge = fClusters[i].fTotalCharge;
+ clusterlist[i].fPad = fClusters[i].fPad;
+ clusterlist[i].fPad2 = fClusters[i].fPad2;
+ clusterlist[i].fTime = fClusters[i].fTime;
+ clusterlist[i].fTime2 = fClusters[i].fTime2;
+ clusterlist[i].fMean = fClusters[i].fMean;
+ clusterlist[i].fFlags = fClusters[i].fFlags;
+ clusterlist[i].fChargeFalling = fClusters[i].fChargeFalling;
+ clusterlist[i].fLastCharge = fClusters[i].fLastCharge;
+ clusterlist[i].fLastMergedPad = fClusters[i].fLastMergedPad;
+ clusterlist[i].fRow = fClusters[i].fRowNumber;
+ }
+ // PrintClusters();
+ WriteClusters(fClusters.size(),clusterlist);
delete [] clusterlist;
- fPadArray->DataToDefault();
+ fClusters.clear();
}
+void AliHLTTPCClusterFinder::PrintClusters()
+{
+ // see header file for class documentation
+ for(size_t i=0;i<fClusters.size();i++){
+ HLTInfo("Cluster number: %d",i);
+ HLTInfo("Row: %d \t Pad: %d",fClusters[i].fRowNumber,fClusters[i].fFirstPad);
+ HLTInfo("Total Charge: %d",fClusters[i].fTotalCharge);
+ HLTInfo("fPad: %d",fClusters[i].fPad);
+ HLTInfo("PadError: %d",fClusters[i].fPad2);
+ HLTInfo("TimeMean: %d",fClusters[i].fTime);
+ HLTInfo("TimeError: %d",fClusters[i].fTime2);
+ HLTInfo("EndOfCluster:");
+ }
+}
+
+/*
+
Int_t AliHLTTPCClusterFinder::GetActivePads(AliHLTTPCPadArray::AliHLTTPCActivePads* activePads,Int_t maxActivePads)
{
// see header file for function documentation
return iResult;
}
-
+*/
void AliHLTTPCClusterFinder::WriteClusters(Int_t nclusters,AliHLTTPCClusters *list)//This is used when using the AliHLTTPCClusters class for cluster data
{
//write cluster to output pointer
}
}
if(fStdout==kTRUE)
- cout<<"WriteCluster: padrow "<<fCurrentRow<<" pad "<<fpad << " +- "<<fpad2<<" time "<<ftime<<" +- "<<ftime2<<" charge "<<list[j].fTotalCharge<<endl;
-
+ HLTInfo("WriteCluster: padrow %d pad %d +- %d time +- %d charge %d",fCurrentRow, fpad, fpad2, ftime, ftime2, list[j].fTotalCharge);
+
if(!fRawSP){
AliHLTTPCTransform::Slice2Sector(fCurrentSlice,fCurrentRow,thissector,thisrow);
AliHLTTPCTransform::Raw2Local(xyz,thissector,thisrow,fpad,ftime);
fSpacePointData[counter].fTrackID[1] = trackID[1];
fSpacePointData[counter].fTrackID[2] = trackID[2];
- //cout<<"padrow "<<fCurrentRow<<" pad "<<(Int_t)rint(fpad)<<" time "<<(Int_t)rint(ftime)<<" Trackid "<<trackID[0]<<endl;
#endif
fNClusters++;
void SetOutputArray(AliHLTTPCSpacePointData *pt);
void WriteClusters(Int_t n_clusters,AliClusterData *list);
-
+ void PrintClusters();
void SetXYError(Float_t f) {fXYErr=f;}
void SetZError(Float_t f) {fZErr=f;}
void SetDeconv(Bool_t f) {fDeconvPad=f; fDeconvTime=f;}
//----------------------------------Methods for the new unsorted way of reading data ----------
void SetPadArray(AliHLTTPCPadArray *padArray);
- void ReadDataUnsorted(void* ptr,unsigned long size);
+ void ReadDataUnsorted(void* ptr,unsigned long size, Int_t mode);
void FindClusters();
- Int_t GetActivePads(AliHLTTPCPadArray::AliHLTTPCActivePads* activePads,Int_t maxActivePads);
+ // Int_t GetActivePads(AliHLTTPCPadArray::AliHLTTPCActivePads* activePads,Int_t maxActivePads);
void WriteClusters(Int_t nclusters,AliHLTTPCClusters *list);
void SetUnsorted(Int_t unsorted){fUnsorted=unsorted;}
-
+ void SetPatch(Int_t patch){fCurrentPatch=patch;}
+ void InitializePadArray();
+ Int_t DeInitializePadArray();
+ Bool_t ComparePads(AliHLTTPCPad *nextPad,AliHLTTPCClusters* candidate,Int_t nextPadToRead);
private:
/** copy constructor prohibited */
AliHLTTPCClusterFinder(const AliHLTTPCClusterFinder&);
AliHLTTPCPadArray * fPadArray; //! transient
Int_t fUnsorted; // enable for processing of unsorted digit data
+ Bool_t fVectorInitialized;
+
+ typedef vector<AliHLTTPCPad*> AliHLTTPCPadVector;
+
+ vector<AliHLTTPCPadVector> fRowPadVector; //! transient
+
+ vector<AliHLTTPCClusters> fClusters; //! transient
+
+ UInt_t* fNumberOfPadsInRow; //! transient
+
+ UInt_t fNumberOfRows; //! transient
+
+ UInt_t fRowOfFirstCandidate;
/** list of active pads if PadArray is not used */
vector<AliHLTTPCPadArray::AliHLTTPCActivePads> fActivePads; //!transient
void GetTrackID(Int_t pad,Int_t time,Int_t *trackID);
#endif
- ClassDef(AliHLTTPCClusterFinder,3) //Fast cluster finder
+ ClassDef(AliHLTTPCClusterFinder,4) //Fast cluster finder
};
#endif
#include "AliHLTTPCDigitReaderPacked.h"
#include "AliHLTTPCDigitReaderUnpacked.h"
#include "AliHLTTPCDigitReaderRaw.h"
+#include "AliHLTTPCDigitReaderDecoder.h"
#include "AliHLTTPCClusterFinder.h"
#include "AliHLTTPCSpacePointData.h"
#include "AliHLTTPCClusterDataFormat.h"
// this is a global object used for automatic component registration, do not use this
// use fPackedSwitch = true for packed inputtype "gkDDLPackedRawDataType"
// use fPackedSwitch = false for unpacked inputtype "gkUnpackedRawDataType"
-AliHLTTPCClusterFinderComponent gAliHLTTPCClusterFinderComponentPacked(true);
-AliHLTTPCClusterFinderComponent gAliHLTTPCClusterFinderComponentUnpacked(false);
+AliHLTTPCClusterFinderComponent gAliHLTTPCClusterFinderComponentPacked(0);
+AliHLTTPCClusterFinderComponent gAliHLTTPCClusterFinderComponentUnpacked(1);
+AliHLTTPCClusterFinderComponent gAliHLTTPCClusterFinderComponentDecoder(2);
/** ROOT macro for the implementation of ROOT specific class methods */
ClassImp(AliHLTTPCClusterFinderComponent)
-AliHLTTPCClusterFinderComponent::AliHLTTPCClusterFinderComponent(bool packed)
+AliHLTTPCClusterFinderComponent::AliHLTTPCClusterFinderComponent(int mode)
:
fClusterFinder(NULL),
fReader(NULL),
fClusterDeconv(true),
fXYClusterError(-1),
fZClusterError(-1),
- fPackedSwitch(packed),
+ fModeSwitch(mode),
fUnsorted(0),
fPatch(0),
fPadArray(NULL),
const char* AliHLTTPCClusterFinderComponent::GetComponentID()
{
// see header file for class documentation
- if (fPackedSwitch) return "TPCClusterFinderPacked";
- else return "TPCClusterFinderUnpacked";
+ switch(fModeSwitch){
+ case 0:
+ return "TPCClusterFinderPacked";
+ break;
+ case 1:
+ return "TPCClusterFinderUnpacked";
+ break;
+ case 2:
+ return "TPCClusterFinderDecoder";
+ break;
+ }
}
void AliHLTTPCClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
{
// see header file for class documentation
list.clear();
- if (fPackedSwitch) list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
- else list.push_back( AliHLTTPCDefinitions::fgkUnpackedRawDataType );
-
+ switch(fModeSwitch){
+ case 0:
+ list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
+ break;
+ case 1:
+ list.push_back( AliHLTTPCDefinitions::fgkUnpackedRawDataType );
+ break;
+ case 2:
+ list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
+ break;
+ }
}
AliHLTComponentDataType AliHLTTPCClusterFinderComponent::GetOutputDataType()
// see header file for class documentation
// XXX TODO: Find more realistic values.
constBase = 0;
- if (fPackedSwitch) inputMultiplier = (6 * 0.4);
- else inputMultiplier = 0.4;
+ switch(fModeSwitch){
+ case 0:
+ inputMultiplier = (6 * 0.4);
+ break;
+ case 1:
+ inputMultiplier = 0.4;
+ break;
+ case 2:
+ inputMultiplier = (6 * 0.4);
+ break;
+ }
}
AliHLTComponent* AliHLTTPCClusterFinderComponent::Spawn()
{
// see header file for class documentation
- return new AliHLTTPCClusterFinderComponent(fPackedSwitch);
+ return new AliHLTTPCClusterFinderComponent(fModeSwitch);
}
int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
}
// Choose reader
-
- if (fPackedSwitch) {
+ if (fModeSwitch==0) {
if (rawreadermode == -2) {
HLTDebug("using AliHLTTPCDigitReaderPacked");
fReader = new AliHLTTPCDigitReaderPacked();
fReader->SetUnsorted(kTRUE);
}
fClusterFinder->SetReader(fReader);
- } else {
+ }
+ else {
#if defined(HAVE_TPC_MAPPING)
HLTDebug("using AliHLTTPCDigitReaderRaw mode %d", rawreadermode);
fReader = new AliHLTTPCDigitReaderRaw(rawreadermode);
#endif //defined(HAVE_TPC_MAPPING)
}
}
- else {
+ else if(fModeSwitch==1){
HLTDebug("using AliHLTTPCDigitReaderUnpacked");
fReader = new AliHLTTPCDigitReaderUnpacked();
fClusterFinder->SetReader(fReader);
}
-
+ else if(fModeSwitch==2){
+ fReader = new AliHLTTPCDigitReaderDecoder();
+ fClusterFinder->SetReader(fReader);
+ }
+ else{
+ HLTFatal("No mode set for clusterfindercomponent");
+ }
// if pp-run use occupancy limit else set to 1. ==> use all
if ( !fClusterDeconv )
fClusterFinder->SetOccupancyLimit(occulimit);
offset = tSize;
- if (fPackedSwitch) {
+ if (fModeSwitch==0 || fModeSwitch==2) {
HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
evtData.fEventID, evtData.fEventID,
DataType2Text( iter->fDataType).c_str(),
iter->fDataType != AliHLTTPCDefinitions::fgkDDLPackedRawDataType ) continue;
}
- else {
+ else if(fModeSwitch==1){
HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
evtData.fEventID, evtData.fEventID,
DataType2Text( iter->fDataType).c_str(),
patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
row[0] = AliHLTTPCTransform::GetFirstRow( patch );
row[1] = AliHLTTPCTransform::GetLastRow( patch );
-
+
+
if(fUnsorted){
- if(fPadArray==NULL){
- fClusterFinder->SetUnsorted(fUnsorted);
- fPadArray = new AliHLTTPCPadArray(patch);
- fPadArray->InitializeVector();
- }
- else if(fPadArray->GetPatch()!=patch||fPadArray->GetPatch()==-1){
- if (GetEventCount()<3) {
- HLTWarning("pad array not initialized for data of specification 0x%08x, block skipped", iter->fSpecification);
- } else if ((GetEventCount()%5000)==0) { // assuming 0.5 to 1kHz this gives a message rate of 0.1 to 0.5 Hz
- HLTWarning("reminder: pad array not initialized for data of specification 0x%08x", iter->fSpecification);
- }
- continue;
- }
+ fClusterFinder->SetUnsorted(fUnsorted);
+ fClusterFinder->SetPatch(patch);
}
+ /* if(fUnsorted){
+ if(fPadArray==NULL){
+ fClusterFinder->SetUnsorted(fUnsorted);
+ //fPadArray = new AliHLTTPCPadArray(patch);
+ //fPadArray->InitializeVector(fModeSwitch);
+ }
+ else if(fPadArray->GetPatch()!=patch||fPadArray->GetPatch()==-1){
+ if (GetEventCount()<3) {
+ HLTWarning("pad array not initialized for data of specification 0x%08x, block skipped", iter->fSpecification);
+ } else if ((GetEventCount()%5000)==0) { // assuming 0.5 to 1kHz this gives a message rate of 0.1 to 0.5 Hz
+ HLTWarning("reminder: pad array not initialized for data of specification 0x%08x", iter->fSpecification);
+ }
+ continue;
+ }
+ }
+ */
+
outPtr = (AliHLTTPCClusterData*)outBPtr;
fClusterFinder->SetOutputArray( (AliHLTTPCSpacePointData*)outPtr->fSpacePoints );
if(fUnsorted){
+ fClusterFinder->ReadDataUnsorted(iter->fPtr, iter->fSize, fModeSwitch);
-
- fClusterFinder->SetPadArray(fPadArray);
- /*
- double totalT=0;
- struct timeval startT, endT;
- gettimeofday( &startT, NULL );
- */
- fClusterFinder->ReadDataUnsorted(iter->fPtr, iter->fSize );
- /*
- gettimeofday( &endT, NULL );
- unsigned long long dt;
- dt = endT.tv_sec-startT.tv_sec;
- dt *= 1000000ULL;
- dt += endT.tv_usec-startT.tv_usec;
- double dtd = ((double)dt);
- totalT += dtd;
- // dtd = dtd / (double)eventIterations;
- // if ( iterations<=1 )
- cout<<endl;
- printf( "Time needed to read data: %f microsec. / %f millisec. / %f s\n",
- dtd, dtd/1000.0, dtd/1000000.0 );
-
- cout<<endl;
- */
fClusterFinder->FindClusters();
}
else{
outBPtr += mysize;
outPtr = (AliHLTTPCClusterData*)outBPtr;
- if(fGetActivePads){
- AliHLTTPCPadArray::AliHLTTPCActivePads* outPtrActive;
- UInt_t activePadsSize, activePadsN = 0;
- outPtrActive = (AliHLTTPCPadArray::AliHLTTPCActivePads*)outBPtr;
- offset=tSize;
- Int_t maxActivePads = (size-tSize)/sizeof(AliHLTTPCPadArray::AliHLTTPCActivePads);
- activePadsSize= fClusterFinder->GetActivePads((AliHLTTPCPadArray::AliHLTTPCActivePads*)outPtrActive,maxActivePads)*sizeof(AliHLTTPCPadArray::AliHLTTPCActivePads);
+ /* if(fGetActivePads){
+ AliHLTTPCPadArray::AliHLTTPCActivePads* outPtrActive;
+ UInt_t activePadsSize, activePadsN = 0;
+ outPtrActive = (AliHLTTPCPadArray::AliHLTTPCActivePads*)outBPtr;
+ offset=tSize;
+ Int_t maxActivePads = (size-tSize)/sizeof(AliHLTTPCPadArray::AliHLTTPCActivePads);
+ activePadsSize= fClusterFinder->GetActivePads((AliHLTTPCPadArray::AliHLTTPCActivePads*)outPtrActive,maxActivePads)*sizeof(AliHLTTPCPadArray::AliHLTTPCActivePads);
- AliHLTComponentBlockData bdActive;
- FillBlockData( bdActive );
- bdActive.fOffset = offset;
- bdActive.fSize = activePadsSize;
- bdActive.fSpecification = iter->fSpecification;
- bdActive.fDataType = AliHLTTPCDefinitions::fgkActivePadsDataType;
- outputBlocks.push_back( bdActive );
+ AliHLTComponentBlockData bdActive;
+ FillBlockData( bdActive );
+ bdActive.fOffset = offset;
+ bdActive.fSize = activePadsSize;
+ bdActive.fSpecification = iter->fSpecification;
+ bdActive.fDataType = AliHLTTPCDefinitions::fgkActivePadsDataType;
+ outputBlocks.push_back( bdActive );
- tSize+=activePadsSize;
- outBPtr += activePadsSize;
- outPtrActive = (AliHLTTPCPadArray::AliHLTTPCActivePads*)outBPtr;
- }
+ tSize+=activePadsSize;
+ outBPtr += activePadsSize;
+ outPtrActive = (AliHLTTPCPadArray::AliHLTTPCActivePads*)outBPtr;
+ }
+ */
if ( tSize > size )
* constructor
* @param packed whether to use the packed or unpacked reader
*/
- AliHLTTPCClusterFinderComponent(bool packed);
+ AliHLTTPCClusterFinderComponent(int mode);
/** destructor */
virtual ~AliHLTTPCClusterFinderComponent();
float fZClusterError; //!transient
/**
* switch to indicated the reader
- * use fPackedSwitch = true for packed inputtype "gkDDLPackedRawDataType"
- * use fPackedSwitch = false for unpacked inputtype "gkUnpackedRawDataType"
+ * use fModeSwitch = 0 for packed inputtype "gkDDLPackedRawDataType"
+ * use fModeSwitch = 1 for unpacked inputtype "gkUnpackedRawDataType"
+ * use fModeSwitch = 2 for packed inputtype "gkDDLPackedRawDataType" with new digit reader
*/
- Int_t fPackedSwitch; // see above
+ Int_t fModeSwitch; // see above
/*
* Reads the data the new unsorted way if true
// $Id$
-
/**************************************************************************
* This file is property of and copyright by the ALICE HLT Project *
* ALICE Experiment at CERN, All rights reserved. *
break;
}
while(inFile>>hwAdd && inFile>>row && inFile>>pad){
- if (hwAdd>=fMaxHWAdd) {
+ if (hwAdd>fMaxHWAdd) {
HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
break;
}
break;
}
while(inFile>>hwAdd && inFile>>row && inFile>>pad){
- if (hwAdd>=fMaxHWAdd) {
+ if (hwAdd>fMaxHWAdd) {
HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
break;
}
break;
}
while(inFile>>hwAdd && inFile>>row && inFile>>pad){
- if (hwAdd>=fMaxHWAdd) {
+ if (hwAdd>fMaxHWAdd) {
HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
break;
}
break;
}
while(inFile>>hwAdd && inFile>>row && inFile>>pad){
- if (hwAdd>=fMaxHWAdd) {
+ if (hwAdd>fMaxHWAdd) {
HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
break;
}
break;
}
while(inFile>>hwAdd && inFile>>row && inFile>>pad){
- if (hwAdd>=fMaxHWAdd) {
+ if (hwAdd>fMaxHWAdd) {
HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
break;
}
break;
}
while(inFile>>hwAdd && inFile>>row && inFile>>pad){
- if (hwAdd>=fMaxHWAdd) {
+ if (hwAdd>fMaxHWAdd) {
HLTFatal("hardware address exceeds max hwAddress %d, mapping file %s corrupted?", fMaxHWAdd);
break;
}
fSignalPositionArray(NULL),
fSizeOfSignalPositionArray(0),
fNSigmaThreshold(0),
- fSignalThreshold(0)
+ fSignalThreshold(0),
+ fModeSwitch(0)
{
// see header file for class documentation
// or
// HLTInfo("Entering default constructor");
fDataSignals= new AliHLTTPCSignal_t[AliHLTTPCTransform::GetNTimeBins()];
memset( fDataSignals, 0xFF, sizeof(Int_t)*(AliHLTTPCTransform::GetNTimeBins()));
-
+
fSignalPositionArray= new AliHLTTPCSignal_t[AliHLTTPCTransform::GetNTimeBins()];
memset( fSignalPositionArray, 0xFF, sizeof(Int_t)*(AliHLTTPCTransform::GetNTimeBins()));
fSizeOfSignalPositionArray=0;
}
+AliHLTTPCPad::AliHLTTPCPad(Int_t mode)
+ :
+ fClusterCandidates(0),
+ fUsedClusterCandidates(0),
+ fRowNo(-1),
+ fPadNo(-1),
+ fThreshold(0),
+ fAverage(-1),
+ fNofEvents(0),
+ fSum(0),
+ fCount(0),
+ fTotal(0),
+ fBLMax(-1),
+ fBLMaxBin(-1),
+ fBLMin(-1),
+ fBLMinBin(-1),
+ fFirstBLBin(0),
+ fNofBins(0),
+ fReadPos(0),
+ fpRawData(NULL),
+ fDataSignals(NULL),
+ fSignalPositionArray(NULL),
+ fSizeOfSignalPositionArray(0),
+ fNSigmaThreshold(0),
+ fSignalThreshold(0),
+ fModeSwitch(mode)
+{
+ // see header file for class documentation
+ // or
+ // refer to README to build package
+ // or
+ // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+}
+
AliHLTTPCPad::AliHLTTPCPad(Int_t offset, Int_t nofBins)
:
fClusterCandidates(),
cout<<"bins: "<<AliHLTTPCTransform::GetNTimeBins()<<endl;
}
+void AliHLTTPCPad::ClearCandidates(){
+ fClusterCandidates.clear();
+ fUsedClusterCandidates.clear();
+}
+
void AliHLTTPCPad::SetDataToDefault()
{
// see header file for class documentation
- if(fpRawData){
+ /*
+ if(fpRawData){
memset( fDataSignals, 0xFF, sizeof(Int_t)*(AliHLTTPCTransform::GetNTimeBins()));
memset( fSignalPositionArray, 0xFF, sizeof(Int_t)*(AliHLTTPCTransform::GetNTimeBins()));
fSizeOfSignalPositionArray=0;
}
+ */
+ fClusterCandidates.clear();
}
void AliHLTTPCPad::SetDataSignal(Int_t bin,Int_t signal)
}
}
}
+void AliHLTTPCPad::AddClusterCandidate(AliHLTTPCClusters candidate){
+ fClusterCandidates.push_back(candidate);
+ fUsedClusterCandidates.push_back(0);
+}
void AliHLTTPCPad::FindClusterCandidates()
{
/** standard constructor */
AliHLTTPCPad();
+ /**
+ * Constructor
+ * @param mode mode determines if one need the raw data(not quite true at the moment but will be)
+ */
+ AliHLTTPCPad(Int_t mode);
+
/**
* Constructor
* @param offset The number of bins to ignore at the beginning
*/
Int_t GetSize() const {return fNofBins;}
+ void ClearCandidates();
+
/**
* Set the data array to -1
*/
* they are stored in a cluster candidate vector.
*/
void FindClusterCandidates();
+
+ /**
+ * Adds cluster candidate to the fClusterCandidates.
+ */
+ void AddClusterCandidate(AliHLTTPCClusters candidate);
+
/**
* Prints the raw data og this pad.
*/
Double_t fNSigmaThreshold; //! transient
Double_t fSignalThreshold; //! transient
- ClassDef(AliHLTTPCPad, 3)
+ Int_t fModeSwitch; //! transient
+ ClassDef(AliHLTTPCPad, 4)
};
#endif // ALIHLTTPCPAD_H
// see header file for class documentation
}
-Int_t AliHLTTPCPadArray::InitializeVector()
+Int_t AliHLTTPCPadArray::InitializeVector(Int_t mode)
{
// see header file for class documentation
fDigitReader=digitReader;
}
-Int_t AliHLTTPCPadArray::ReadData()
+Int_t AliHLTTPCPadArray::ReadData(Int_t mode)
{
// see header file for class documentation
switch (fPatch){
case 0:
- while(fDigitReader->Next()){
- UInt_t row = fDigitReader->GetRow();
- UInt_t pad = fDigitReader->GetPad();
- UInt_t time = fDigitReader->GetTime();
- if(row<fNumberOfRows){
- if(pad<fNumberOfPadsInRow[row]&&time<AliHLTTPCTransform::GetNTimeBins()){
- fRowPadVector[row][pad]->SetDataSignal(time,fDigitReader->GetSignal());
+ if(mode!=2){
+ while(fDigitReader->Next()){
+ UInt_t row = fDigitReader->GetRow();
+ UInt_t pad = fDigitReader->GetPad();
+ UInt_t time = fDigitReader->GetTime();
+ if(row<fNumberOfRows){
+ if(pad<fNumberOfPadsInRow[row]&&time<AliHLTTPCTransform::GetNTimeBins()){
+ fRowPadVector[row][pad]->SetDataSignal(time,fDigitReader->GetSignal());
+ }
}
}
}
+ else{
+ while(fDigitReader->NextChannel()){
+ while(fDigitReader->NextBunch()){
+ const UInt_t *bunchData= fDigitReader->GetSignals();
+ UInt_t row=fDigitReader->GetRow();
+ UInt_t pad=fDigitReader->GetPad();
+ UInt_t time=fDigitReader->GetTime();
+ AliHLTTPCClusters candidate;
+ for(Int_t i=0;i<fDigitReader->GetBunchSize();i++){
+ candidate.fTotalCharge+=bunchData[i];
+ candidate.fTime += time*bunchData[i];
+ candidate.fTime2 += time*time*bunchData[i];
+ time++;
+ }
+ if(candidate.fTotalCharge>0){
+ candidate.fMean=candidate.fTime/candidate.fTotalCharge;
+ candidate.fPad=candidate.fTotalCharge*pad;
+ candidate.fPad2=candidate.fPad*pad;
+ candidate.fLastMergedPad=pad;
+ fRowPadVector[row][pad]->AddClusterCandidate(candidate);
+ }
+ }
+ }
+
+ }
break;
case 1:
- while(fDigitReader->Next()){
- UInt_t row = fDigitReader->GetRow()-fFirstRow;
- UInt_t pad = fDigitReader->GetPad();
- UInt_t time = fDigitReader->GetTime();
- if(row<fNumberOfRows){
- if(pad<fNumberOfPadsInRow[row]&&time<AliHLTTPCTransform::GetNTimeBins()){
- fRowPadVector[row][pad]->SetDataSignal(time,fDigitReader->GetSignal());
+ if(mode!=2){
+ while(fDigitReader->Next()){
+ UInt_t row = fDigitReader->GetRow()-fFirstRow;
+ UInt_t pad = fDigitReader->GetPad();
+ UInt_t time = fDigitReader->GetTime();
+ if(row<fNumberOfRows){
+ if(pad<fNumberOfPadsInRow[row]&&time<AliHLTTPCTransform::GetNTimeBins()){
+ fRowPadVector[row][pad]->SetDataSignal(time,fDigitReader->GetSignal());
+ }
+ }
+ }
+ }
+ else{
+ while(fDigitReader->NextChannel()){
+ while(fDigitReader->NextBunch()){
+ const UInt_t *bunchData= fDigitReader->GetSignals();
+ UInt_t row=fDigitReader->GetRow();
+ UInt_t pad=fDigitReader->GetPad();
+ UInt_t time=fDigitReader->GetTime();
+ AliHLTTPCClusters candidate;
+ for(Int_t i=0;i<fDigitReader->GetBunchSize();i++){
+ candidate.fTotalCharge+=bunchData[i];
+ candidate.fTime += time*bunchData[i];
+ candidate.fTime2 += time*time*bunchData[i];
+ time++;
+ }
+ if(candidate.fTotalCharge>0){
+ candidate.fMean=candidate.fTime/candidate.fTotalCharge;
+ candidate.fPad=candidate.fTotalCharge*pad;
+ candidate.fPad2=candidate.fPad*pad;
+ candidate.fLastMergedPad=pad;
+ fRowPadVector[row][pad]->AddClusterCandidate(candidate);
+ }
+ }
}
- }
+
}
+
break;
case 2:
- while(fDigitReader->Next()){
- UInt_t row=fDigitReader->GetRow();
- UInt_t pad=fDigitReader->GetPad();
- UInt_t time= fDigitReader->GetTime();
- if(row<fNumberOfRows){
- if(pad<fNumberOfPadsInRow[row]&&time<AliHLTTPCTransform::GetNTimeBins()){
- fRowPadVector[fDigitReader->GetRow()][fDigitReader->GetPad()]->SetDataSignal(fDigitReader->GetTime(),fDigitReader->GetSignal());
+ if(mode!=2){
+ while(fDigitReader->Next()){
+ UInt_t row=fDigitReader->GetRow();
+ UInt_t pad=fDigitReader->GetPad();
+ UInt_t time= fDigitReader->GetTime();
+ if(row<fNumberOfRows){
+ if(pad<fNumberOfPadsInRow[row]&&time<AliHLTTPCTransform::GetNTimeBins()){
+ fRowPadVector[fDigitReader->GetRow()][fDigitReader->GetPad()]->SetDataSignal(fDigitReader->GetTime(),fDigitReader->GetSignal());
+ }
}
}
}
+ else{
+ while(fDigitReader->NextChannel()){
+ while(fDigitReader->NextBunch()){
+ const UInt_t *bunchData= fDigitReader->GetSignals();
+ UInt_t row=fDigitReader->GetRow();
+ UInt_t pad=fDigitReader->GetPad();
+ UInt_t time=fDigitReader->GetTime();
+ AliHLTTPCClusters candidate;
+ for(Int_t i=0;i<fDigitReader->GetBunchSize();i++){
+ candidate.fTotalCharge+=bunchData[i];
+ candidate.fTime += time*bunchData[i];
+ candidate.fTime2 += time*time*bunchData[i];
+ time++;
+ }
+ if(candidate.fTotalCharge>0){
+ candidate.fMean=candidate.fTime/candidate.fTotalCharge;
+ candidate.fPad=candidate.fTotalCharge*pad;
+ candidate.fPad2=candidate.fPad*pad;
+ candidate.fLastMergedPad=pad;
+ fRowPadVector[row][pad]->AddClusterCandidate(candidate);
+ }
+ }
+ }
+ }
break;
case 3:
- while(fDigitReader->Next()){
- UInt_t row=fDigitReader->GetRow()-27;
- UInt_t pad=fDigitReader->GetPad();
- UInt_t time= fDigitReader->GetTime();
- if(row<fNumberOfRows){
- if(pad<fNumberOfPadsInRow[row]&&time<AliHLTTPCTransform::GetNTimeBins()){
- fRowPadVector[row][pad]->SetDataSignal(time,fDigitReader->GetSignal());
+ if(mode!=2){
+ while(fDigitReader->Next()){
+ UInt_t row=fDigitReader->GetRow()-27;
+ UInt_t pad=fDigitReader->GetPad();
+ UInt_t time= fDigitReader->GetTime();
+ if(row<fNumberOfRows){
+ if(pad<fNumberOfPadsInRow[row]&&time<AliHLTTPCTransform::GetNTimeBins()){
+ fRowPadVector[row][pad]->SetDataSignal(time,fDigitReader->GetSignal());
+ }
}
}
}
+ else{
+ while(fDigitReader->NextChannel()){
+ while(fDigitReader->NextBunch()){
+ const UInt_t *bunchData= fDigitReader->GetSignals();
+ UInt_t row=fDigitReader->GetRow();
+ UInt_t pad=fDigitReader->GetPad();
+ UInt_t time=fDigitReader->GetTime();
+ AliHLTTPCClusters candidate;
+ for(Int_t i=0;i<fDigitReader->GetBunchSize();i++){
+ candidate.fTotalCharge+=bunchData[i];
+ candidate.fTime += time*bunchData[i];
+ candidate.fTime2 += time*time*bunchData[i];
+ time++;
+ }
+ if(candidate.fTotalCharge>0){
+ candidate.fMean=candidate.fTime/candidate.fTotalCharge;
+ candidate.fPad=candidate.fTotalCharge*pad;
+ candidate.fPad2=candidate.fPad*pad;
+ candidate.fLastMergedPad=pad;
+ fRowPadVector[row][pad]->AddClusterCandidate(candidate);
+ }
+ }
+ }
+ }
break;
case 4:
+ if(mode!=2){
while(fDigitReader->Next()){
UInt_t row=fDigitReader->GetRow()-54;
UInt_t pad=fDigitReader->GetPad();
}
}
}
+ }
+ else{
+ while(fDigitReader->NextChannel()){
+ while(fDigitReader->NextBunch()){
+ const UInt_t *bunchData= fDigitReader->GetSignals();
+ UInt_t row=fDigitReader->GetRow();
+ UInt_t pad=fDigitReader->GetPad();
+ UInt_t time=fDigitReader->GetTime();
+ AliHLTTPCClusters candidate;
+ for(Int_t i=0;i<fDigitReader->GetBunchSize();i++){
+ candidate.fTotalCharge+=bunchData[i];
+ candidate.fTime += time*bunchData[i];
+ candidate.fTime2 += time*time*bunchData[i];
+ time++;
+ }
+ if(candidate.fTotalCharge>0){
+ candidate.fMean=candidate.fTime/candidate.fTotalCharge;
+ candidate.fPad=candidate.fTotalCharge*pad;
+ candidate.fPad2=candidate.fPad*pad;
+ candidate.fLastMergedPad=pad;
+ fRowPadVector[row][pad]->AddClusterCandidate(candidate);
+ }
+ }
+ }
+
+ }
+
break;
case 5:
- while(fDigitReader->Next()){
- UInt_t row=fDigitReader->GetRow()-76;
- UInt_t pad=fDigitReader->GetPad();
- UInt_t time= fDigitReader->GetTime();
- if(row<fNumberOfRows){
- if(pad<fNumberOfPadsInRow[row]&&time<AliHLTTPCTransform::GetNTimeBins()){
- fRowPadVector[row][pad]->SetDataSignal(time,fDigitReader->GetSignal());
+ if(mode!=2){
+ while(fDigitReader->Next()){
+ UInt_t row=fDigitReader->GetRow()-76;
+ UInt_t pad=fDigitReader->GetPad();
+ UInt_t time= fDigitReader->GetTime();
+ if(row<fNumberOfRows){
+ if(pad<fNumberOfPadsInRow[row]&&time<AliHLTTPCTransform::GetNTimeBins()){
+ fRowPadVector[row][pad]->SetDataSignal(time,fDigitReader->GetSignal());
+ }
}
}
}
+ else{
+ while(fDigitReader->NextChannel()){
+ while(fDigitReader->NextBunch()){
+ const UInt_t *bunchData= fDigitReader->GetSignals();
+ UInt_t row=fDigitReader->GetRow();
+ UInt_t pad=fDigitReader->GetPad();
+ UInt_t time=fDigitReader->GetTime();
+ AliHLTTPCClusters candidate;
+ for(Int_t i=0;i<fDigitReader->GetBunchSize();i++){
+ candidate.fTotalCharge+=bunchData[i];
+ candidate.fTime += time*bunchData[i];
+ candidate.fTime2 += time*time*bunchData[i];
+ time++;
+ }
+ if(candidate.fTotalCharge>0){
+ candidate.fMean=candidate.fTime/candidate.fTotalCharge;
+ candidate.fPad=candidate.fTotalCharge*pad;
+ candidate.fPad2=candidate.fPad*pad;
+ candidate.fLastMergedPad=pad;
+ fRowPadVector[row][pad]->AddClusterCandidate(candidate);
+ }
+ }
+ }
+
+ }
+
break;
}
return 0;
fRowPadVector[i][j]->SetDataToDefault();
}
}
+ fClusters.clear();
}
void AliHLTTPCPadArray::FindClusterCandidates()
/**
* Initialize the pad vector for the patch set.
+ *@param mode Switch to keep raw data or not
*/
- Int_t InitializeVector();
+ Int_t InitializeVector(Int_t mode);
/**
* Deinitialize the pad vector for the patch set.
/**
* Reads the data, and set it in the Pad objects.
*/
- Int_t ReadData();
+ Int_t ReadData(Int_t mode);
/**
* Retuns number of pads in this row.
#endif
// The following definition is generated by MakeInitFile function
-Double_t AliHLTTPCTransform::fgBField = 0.2;
-Double_t AliHLTTPCTransform::fgSolenoidBField = 2;
+Double_t AliHLTTPCTransform::fgBField = 0.5;
+Double_t AliHLTTPCTransform::fgSolenoidBField = 5;
Double_t AliHLTTPCTransform::fgBFieldFactor = 1;
Int_t AliHLTTPCTransform::fgVersion = kVdefault;
Int_t AliHLTTPCTransform::fgNTimeBins = 1024; // = 1024; //446