Digitizer
authoralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 27 Mar 2002 18:13:59 +0000 (18:13 +0000)
committeralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 27 Mar 2002 18:13:59 +0000 (18:13 +0000)
START/AliSTART.h
START/AliSTARTDigitizer.cxx [new file with mode: 0644]
START/AliSTARTDigitizer.h [new file with mode: 0644]
START/libSTART.pkg

index 398fa49..31aaad4 100755 (executable)
@@ -33,6 +33,7 @@ public:
    virtual void   DrawDetector(){}
    virtual Int_t  IsVersion()const {return 0;}
    virtual void   Init();
+   virtual void SetHitsAddressBranch(TBranch *b){b->SetAddress(&fHits);}
    void Hit2digit(Int_t iEventNum);
    void Hit2digit(){return;}
    virtual void   MakeBranch(Option_t *opt=" ", const char *file=0);
diff --git a/START/AliSTARTDigitizer.cxx b/START/AliSTARTDigitizer.cxx
new file mode 100644 (file)
index 0000000..d9b9a51
--- /dev/null
@@ -0,0 +1,194 @@
+
+/**************************************************************************
+ * Copyright(c) 1998-2000, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+
+#include <TTree.h> 
+#include <TVector.h>
+#include <TObjArray.h>
+#include <TFile.h>
+#include <TDirectory.h>
+#include <TRandom.h>
+
+
+#include "AliSTARTDigitizer.h"
+#include "AliSTART.h"
+#include "AliSTARThit.h"
+#include "AliSTARTdigit.h"
+#include "AliRunDigitizer.h"
+
+#include "AliRun.h"
+#include "AliPDG.h"
+
+#include <stdlib.h>
+#include <iostream.h>
+#include <fstream.h>
+
+ClassImp(AliSTARTDigitizer)
+
+//___________________________________________
+  AliSTARTDigitizer::AliSTARTDigitizer()  :AliDigitizer()
+{
+// Default ctor - don't use it
+  ;
+}
+
+//___________________________________________
+AliSTARTDigitizer::AliSTARTDigitizer(AliRunDigitizer* manager) 
+    :AliDigitizer(manager) 
+{
+       cout<<"AliSTARTDigitizer::AliSTARTDigitizer"<<endl;
+// ctor which should be used
+//  fDebug =0;
+ // if (GetDebug()>2)
+  //  cerr<<"AliSTARTDigitizer::AliSTARTDigitizer"
+   //     <<"(AliRunDigitizer* manager) was processed"<<endl;
+
+}
+
+//------------------------------------------------------------------------
+AliSTARTDigitizer::~AliSTARTDigitizer()
+{
+// Destructor
+
+
+}
+
+ //------------------------------------------------------------------------
+Bool_t AliSTARTDigitizer::Init()
+{
+// Initialization
+ cout<<"AliSTARTDigitizer::Init"<<endl;
+ return kTRUE;
+}
+
+//---------------------------------------------------------------------
+
+void AliSTARTDigitizer::Exec(Option_t* option)
+{
+
+
+
+#ifdef DEBUG
+  cout<<"AliSTARTDigitizer::>SDigits2Digits start...\n";
+#endif
+  //
+  // From hits to digits
+  //
+  Int_t hit;
+  Int_t nhits;
+  Int_t volume,pmt;
+  char nameDigits[20];
+  Float_t timediff,timeright,timeleft,timeav;
+  Float_t besttimeright,besttimeleft,meanTime;
+  Int_t channelWidth=10;
+  fHits = new TClonesArray ("AliSTARThit", 1000);
+  AliSTART *START  = (AliSTART*) gAlice->GetDetector("START");
+
+  AliSTARThit  *startHit;
+  TBranch *brHits=0;
+  fdigits= new AliSTARTdigit();
+
+  Int_t nFiles=fManager->GetNinputs();
+  for (Int_t inputFile=0; inputFile<nFiles;  inputFile++) {
+    sprintf(nameDigits,"START_D_%d",fManager->GetOutputEventNr());
+    besttimeright=9999.;
+    besttimeleft=9999.;
+    Int_t timeDiff=0;
+    Int_t timeAv=0;
+    TClonesArray *STARThits = START->Hits ();
+
+   TTree *th = fManager->GetInputTreeH(inputFile);
+    brHits = th->GetBranch("START");
+    if (brHits) {
+      START->SetHitsAddressBranch(brHits);
+    }else{
+      cerr<<"EXEC Branch START hit not found"<<exit;
+    } 
+    Int_t ntracks    = (Int_t) th->GetEntries();
+    if (ntracks<=0) return;
+    // Start loop on tracks in the hits containers
+    for (Int_t track=0; track<ntracks;track++) {
+      brHits->GetEntry(track);
+      nhits = STARThits->GetEntriesFast();
+      for (hit=0;hit<nhits;hit++) {
+       startHit   = (AliSTARThit*) STARThits->UncheckedAt(hit);
+       pmt=startHit->fPmt;
+       volume = startHit->fVolume;
+       if(volume==1){
+         timeright = startHit->fTime;
+         if(timeright<besttimeright) {
+           besttimeright=timeright;
+         } //timeright
+       }//time for right shoulder
+       if(volume==2){            
+         timeleft = startHit->fTime;
+         //                printf("timeleft %f\n",timeleft);
+         if(timeleft<besttimeleft) {
+           besttimeleft=timeleft;
+         } //timeleftbest
+       }//time for left shoulder
+      } //hit loop
+    } //track loop
+    //folding with experimental time distribution
+    Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
+    Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
+    timediff=besttimerightGaus-besttimeleftGaus;
+    meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
+    if ( TMath::Abs(timediff)<TMath::Abs(10.) && meanTime<TMath::Abs(7.1)) 
+     {
+       //we assume centre of bunch is 5ns after TTS signal
+       //TOF values are relative of the end of bunch
+       Float_t ppBunch=25;
+    
+       ppBunch=ppBunch-10/2;
+       Float_t t1=1000.*besttimeleftGaus;
+       Float_t t2=1000.*besttimerightGaus;
+       t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
+       t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
+     
+       timeav=(t1+t2)/2.;
+     
+       // Time to TDC signal
+       // 256 channels for timediff, range 1ns
+       
+       timediff=128+1000*timediff/channelWidth; // time in ps 
+
+       timeAv = (Int_t)(timeav);   // time (ps) channel numbres
+       timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
+       fdigits->Set(timeAv,timeDiff);
+      fdigits->Print();
+     }
+    else
+      {timeAv=999999; timeDiff=99999;}
+
+// trick to find out output dir:
+    TTree *outTree = fManager->GetTreeD();
+    if (!outTree) {
+      cerr<<"something wrong with output...."<<exit;
+      return;
+    }
+    TDirectory *wd = gDirectory;
+    outTree->GetDirectory()->cd();
+    fdigits->Write(nameDigits);
+    wd->cd();
+  }
+
+}
+
+
diff --git a/START/AliSTARTDigitizer.h b/START/AliSTARTDigitizer.h
new file mode 100644 (file)
index 0000000..0b16e1b
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef ALISTARTDIGITIZER_H
+#define ALISTARTDIGITIZER_H
+/* Copyright(c) 1998-2000, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+#include "AliDigitizer.h"
+
+class AliRunDigitizer;
+class AliSTART;
+class AliSTARThit;
+class AliSTARTdigit;
+
+class AliSTARTDigitizer : public AliDigitizer {
+ public:
+  
+  AliSTARTDigitizer();
+  AliSTARTDigitizer(AliRunDigitizer * manager);
+  virtual ~AliSTARTDigitizer();
+  virtual Bool_t Init();
+  TClonesArray *Hits() const {return fHits;}
+  
+  // Do the main work
+  void Exec(Option_t* option=0) ;
+  
+  enum {kBgTag = -1};
+
+private:
+
+  AliSTART *START;
+  TClonesArray *fHits      ; // List of summable digits
+  AliSTARTdigit *fdigits   ; // digits
+     
+    ClassDef(AliSTARTDigitizer,0)
+};    
+#endif
+
index 2e3d7a5..d93d5e0 100644 (file)
@@ -1,4 +1,4 @@
-SRCS= AliSTART.cxx AliSTARTv0.cxx AliSTARTv1.cxx AliSTARThit.cxx AliSTARTdigit.cxx AliSTARTvertex.cxx
+SRCS= AliSTART.cxx AliSTARTv0.cxx AliSTARTv1.cxx AliSTARThit.cxx AliSTARTdigit.cxx AliSTARTvertex.cxx AliSTARTDigitizer.cxx
 
 HDRS= $(SRCS:.cxx=.h)