Added trigger code. For the moment only preliminary code for pileup removal
authorvestbo <vestbo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 6 Mar 2002 09:53:13 +0000 (09:53 +0000)
committervestbo <vestbo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 6 Mar 2002 09:53:13 +0000 (09:53 +0000)
HLT/trigger/AliL3Trigger.cxx [new file with mode: 0644]
HLT/trigger/AliL3Trigger.h [new file with mode: 0644]

diff --git a/HLT/trigger/AliL3Trigger.cxx b/HLT/trigger/AliL3Trigger.cxx
new file mode 100644 (file)
index 0000000..c3b85b7
--- /dev/null
@@ -0,0 +1,179 @@
+
+#include "AliL3Trigger.h"
+#include "AliL3TrackArray.h"
+#include "AliL3Transform.h"
+#include "AliL3Vertex.h"
+#include "AliL3Defs.h"
+#include "AliL3DigitData.h"
+#include "AliL3Logging.h"
+#include "AliL3Track.h"
+#include "AliL3MemHandler.h"
+
+ClassImp(AliL3Trigger)
+
+AliL3Trigger::AliL3Trigger()
+{
+  fDataSize=0;
+  fTracks=0;
+  fTransform=0;
+  fDigitRowData=0;
+  fOutput=0;
+  fVertex=0;
+}
+
+AliL3Trigger::~AliL3Trigger()
+{
+  if(fTracks)
+    delete fTracks;
+  if(fTransform)
+    delete fTransform;
+}
+
+void AliL3Trigger::InitTrigger()
+{
+  if(fTracks)
+    delete fTracks;
+  if(fTransform)
+    delete fTransform;
+  fTracks = new AliL3TrackArray();
+  fTransform = new AliL3Transform;
+}
+
+void AliL3Trigger::InitPatch(Int_t slice,Int_t patch)
+{
+  fSlice=slice;
+  fPatch=patch;
+  fTracks->Reset();
+}
+
+void AliL3Trigger::FillTracks(Int_t ntracks,AliL3TrackSegmentData *tr)
+{
+  fTracks->FillTracks(ntracks,tr);
+}
+
+void AliL3Trigger::FillData(AliL3DigitRowData *data)
+{
+  fDigitRowData = data;
+}
+
+void AliL3Trigger::SetParameters(Float_t zcut,Int_t timematch,Int_t padmatch)
+{
+  fZcut=zcut;
+  fTimeMatch=timematch;
+  fPadMatch=padmatch;
+}
+
+void AliL3Trigger::SetOutputData(AliL3DigitRowData *ptr)
+{
+  fOutput=ptr;
+}
+
+void AliL3Trigger::RemovePileupTracks()
+{
+  Double_t xc,yc,zc;
+  for(Int_t i=0; i<fTracks->GetNTracks(); i++)
+    {
+      AliL3Track *track = fTracks->GetCheckedTrack(i);
+      if(!track) continue;
+      track->Rotate(fSlice,kTRUE);
+      track->CalculateHelix();
+      track->GetClosestPoint(fVertex,xc,yc,zc);
+      if(fabs(zc) > fZcut)
+       {
+         fTracks->Remove(i);
+         continue;
+       }
+    }
+  fTracks->Compress();
+}
+
+void AliL3Trigger::RemovePileupData()
+{
+  Float_t hit[3];
+  Int_t sector,row;
+  struct rowhit {Int_t pad; Int_t time;};
+  rowhit row_cross[(fTracks->GetNTracks())];
+  Int_t digitcount[(NumRows[fPatch])];
+  Int_t totalcount=0;
+  AliL3DigitRowData *rowPt = fDigitRowData;
+  for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
+    {
+      digitcount[(i-NRows[fPatch][0])]=0;
+      for(Int_t j=0; j<fTracks->GetNTracks(); j++)
+       {
+         AliL3Track *track = fTracks->GetCheckedTrack(j);
+         if(!track) continue;
+         track->GetCrossingPoint(i,hit);
+         fTransform->Slice2Sector(fSlice,i,sector,row);
+         fTransform->Local2Raw(hit,sector,row);
+         row_cross[j].pad = (Int_t)rint(hit[1]);
+         row_cross[j].time = (Int_t)rint(hit[2]);
+       }
+      AliL3DigitData *digPt = (AliL3DigitData*)rowPt->fDigitData;
+      Bool_t mark;
+      for(Int_t k=0; k<rowPt->fNDigit; k++)
+       {
+         mark = kFALSE;
+         for(Int_t l=0; l<fTracks->GetNTracks(); l++)
+           {
+             if(abs((Int_t)digPt[k].fPad-row_cross[l].pad) < fPadMatch &&
+                abs((Int_t)digPt[k].fTime-row_cross[l].time) < fTimeMatch)
+               {
+                 digitcount[(i-NRows[fPatch][0])]++;
+                 totalcount++;
+                 mark=kTRUE;
+                 break;
+               }
+           }
+         if(mark==kTRUE)
+           digPt[k].fCharge=0;
+       }
+      AliL3MemHandler::UpdateRowPointer(rowPt);
+    }
+  
+  Int_t size = totalcount*sizeof(AliL3DigitData) + NumRows[fPatch]*sizeof(AliL3DigitRowData);
+  fDataSize = size;
+  LOG(AliL3Log::kDebug,"AliL3Trigger::RemovePileupData","Memory")
+    <<"Allocating "<<size<<" bytes of data for trigger event"<<ENDLOG;
+  Byte_t *data = new Byte_t[size];
+  memset(data,0,size);
+  AliL3DigitRowData *tempPt = (AliL3DigitRowData*)data;
+  rowPt = fDigitRowData;
+  
+  Int_t localcount;
+  for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
+    {
+      tempPt->fRow = i;
+      tempPt->fNDigit = digitcount[(i-NRows[fPatch][0])];
+      AliL3DigitData *digPt = (AliL3DigitData*)rowPt->fDigitData;
+      localcount=0;
+      for(Int_t j=0; j<rowPt->fNDigit; j++)
+       {
+         if(digPt[j].fCharge==0) continue;
+         if(localcount >= digitcount[(i-NRows[fPatch][0])])
+           {
+             LOG(AliL3Log::kFatal,"AliL§Trigger::RemovePileupData","Array")
+               <<"Mismatch in digitcount: "<<localcount<<" "<<digitcount[(i-NRows[fPatch][0])]<<ENDLOG;
+             return;
+           }
+         tempPt->fDigitData[localcount].fCharge=digPt[j].fCharge;
+         tempPt->fDigitData[localcount].fPad=digPt[j].fPad;
+         tempPt->fDigitData[localcount].fTime=digPt[j].fTime;
+         localcount++;
+       }
+      if(digitcount[(i-NRows[fPatch][0])]!=localcount)
+       {
+         LOG(AliL3Log::kFatal,"AliL§Trigger::RemovePileupData","Array")
+           <<"Mismatch in digitcount: "<<localcount<<" "<<digitcount[(i-NRows[fPatch][0])]<<ENDLOG;
+       }
+      AliL3MemHandler::UpdateRowPointer(rowPt);
+      Byte_t *tmp = (Byte_t*)tempPt;
+      Int_t size = sizeof(AliL3DigitRowData)+digitcount[(i-NRows[fPatch][0])]*sizeof(AliL3DigitData);
+      tmp += size;
+      tempPt = (AliL3DigitRowData*)tmp;
+    }
+  
+  fOutput=(AliL3DigitRowData*)data;
+}
+
+
diff --git a/HLT/trigger/AliL3Trigger.h b/HLT/trigger/AliL3Trigger.h
new file mode 100644 (file)
index 0000000..f9c5c3a
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef AliL3_Trigger
+#define AliL3_Trigger
+
+#include "AliL3RootTypes.h"
+
+class AliL3TrackSegmentData;
+class AliL3DigitRowData;
+class AliL3TrackArray;
+class AliL3Transform;
+class AliL3Vertex;
+
+class AliL3Trigger {
+ private:
+  AliL3TrackArray *fTracks; //!
+  AliL3DigitRowData *fDigitRowData; //!
+  AliL3DigitRowData *fOutput; //!
+  AliL3Vertex *fVertex; //!
+  AliL3Transform *fTransform;//!
+  Int_t fDataSize;
+
+  Float_t fZcut;
+  Int_t fTimeMatch;
+  Int_t fPadMatch;
+  Int_t fSlice;
+  Int_t fPatch;
+
+ public:
+  AliL3Trigger();
+  virtual ~AliL3Trigger();
+  
+  void InitTrigger();
+  void InitPatch(Int_t slice,Int_t patch);
+  void FillTracks(Int_t ntracks,AliL3TrackSegmentData *tr);
+  void FillData(AliL3DigitRowData *data);
+  void SetOutputData(AliL3DigitRowData *ptr);
+  void SetVertex(AliL3Vertex *vertex) {fVertex = vertex;}
+  void SetParameters(Float_t zcut,Int_t timematch,Int_t padmatch);
+  void RemovePileupTracks();
+  void RemovePileupData();
+  
+  Int_t GetDataSize() {return fDataSize;}
+  
+  ClassDef(AliL3Trigger,1) 
+
+};
+
+#endif