]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFSDigitizer.cxx
Introducing Riostream.h
[u/mrichter/AliRoot.git] / TOF / AliTOFSDigitizer.cxx
index 66d1198c2bee036d5109372073d47a61fe563788..8be200d25e31d7b8ae2b5b16267ce0b25f96b7ce 100644 (file)
 #include "TFolder.h"
 #include <TF1.h>
 #include <stdlib.h>
-#include <iostream.h>
-#include <fstream.h>
+#include <Riostream.h>
+#include <Riostream.h>
 
 #include "AliTOFHitMap.h"
 #include "AliTOFSDigit.h"
 #include "AliTOFConstants.h"
 #include "AliTOFhit.h"
+#include "AliTOFhitT0.h"
 #include "AliTOF.h"
 #include "AliTOFv1.h"
 #include "AliTOFv2.h"
@@ -178,6 +179,7 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption, Option_t *allEvents) {
     TOF->RecreateSDigitsArray();
   }
 
+  Int_t version=TOF->IsVersion();
 
   if (fEdgeTails) ftail = new TF1("tail",TimeWithTail,-2,2,3);
 
@@ -223,10 +225,9 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption, Option_t *allEvents) {
     
     //Now made SDigits from hits
 
-    Int_t    vol[5];       // location for a digit
-    Float_t  digit[2];     // TOF digit variables
+
     TParticle *particle;
-    AliTOFhit *tofHit;
+    //AliTOFhit *tofHit;
     TClonesArray *TOFhits = TOF->Hits();
 
     // create hit map
@@ -255,25 +256,51 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption, Option_t *allEvents) {
 
       for (Int_t hit = 0; hit < nhits; hit++)
       {
-       tofHit = (AliTOFhit *) TOFhits->UncheckedAt(hit);
-       Int_t tracknum = tofHit->GetTrack();
-       vol[0] = tofHit->GetSector();
-       vol[1] = tofHit->GetPlate();
-
-       // selection case for sdigitizing only hits in a given plate of a given sector
-       if(thereIsNotASelection || (vol[0]==fSelectedSector && vol[1]==fSelectedPlate)){
-         
+       Int_t    vol[5];       // location for a digit
+       Float_t  digit[2];     // TOF digit variables
+       Int_t tracknum;
+       Float_t Xpad;
+       Float_t Zpad;
+       Float_t geantTime;
+
+       // fp: really sorry for this, it is a temporary trick to have
+       // track length too
+       if(version!=6){
+         AliTOFhit *tofHit = (AliTOFhit *) TOFhits->UncheckedAt(hit);
+         tracknum = tofHit->GetTrack();
+         vol[0] = tofHit->GetSector();
+         vol[1] = tofHit->GetPlate();
+         vol[2] = tofHit->GetStrip();
+         vol[3] = tofHit->GetPadx();
+         vol[4] = tofHit->GetPadz();
+         Xpad = tofHit->GetDx();
+         Zpad = tofHit->GetDz();
+         geantTime = tofHit->GetTof(); // unit [s]
+       } else {
+         AliTOFhitT0 *tofHit = (AliTOFhitT0 *) TOFhits->UncheckedAt(hit);
+         tracknum = tofHit->GetTrack();
+         vol[0] = tofHit->GetSector();
+         vol[1] = tofHit->GetPlate();
          vol[2] = tofHit->GetStrip();
          vol[3] = tofHit->GetPadx();
          vol[4] = tofHit->GetPadz();
+         Xpad = tofHit->GetDx();
+         Zpad = tofHit->GetDz();
+         geantTime = tofHit->GetTof(); // unit [s]
+       }
+
+       geantTime *= 1.e+09;  // conversion from [s] to [ns]
+           
+       // selection case for sdigitizing only hits in a given plate of a given sector
+       if(thereIsNotASelection || (vol[0]==fSelectedSector && vol[1]==fSelectedPlate)){
          
          Bool_t dummy=((tracknum==previousTrack) && (vol[0]==previousSector) && (vol[1]==previousPlate) && (vol[2]==previousStrip));
          
          Bool_t isCloneOfThePrevious=dummy && ((vol[3]==previousPadX) && (vol[4]==previousPadZ));
          
-         // much stronger check to be inserted here
+         Bool_t isNeighOfThePrevious=dummy && ((((vol[3]==previousPadX-1) || (vol[3]==previousPadX+1)) && (vol[4]==previousPadZ)) || ((vol[3]==previousPadX) && ((vol[4]==previousPadZ+1) || (vol[4]==previousPadZ-1))));
          
-         if(!isCloneOfThePrevious){
+         if(!isCloneOfThePrevious && !isNeighOfThePrevious){
            // update "previous" values
            // in fact, we are yet in the future, so the present is past
            previousTrack=tracknum;
@@ -289,13 +316,9 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption, Option_t *allEvents) {
              nHitsFromPrim++;
            } // counts hits due to primary particles
            
-           Float_t Xpad = tofHit->GetDx();
-           Float_t Zpad = tofHit->GetDz();
            Float_t xStrip=AliTOFConstants::fgkXPad*(vol[3]-0.5-0.5*AliTOFConstants::fgkNpadX)+Xpad;
            Float_t zStrip=AliTOFConstants::fgkZPad*(vol[4]-0.5-0.5*AliTOFConstants::fgkNpadZ)+Zpad;
-           Float_t geantTime = tofHit->GetTof(); // unit [s]
-           geantTime *= 1.e+09;  // conversion from [s] to [ns]
-           
+
            //cout << "geantTime " << geantTime << " [ns]" << endl;
            Int_t nActivatedPads = 0, nFiredPads = 0;
            Bool_t isFired[4] = {kFALSE, kFALSE, kFALSE, kFALSE};
@@ -311,7 +334,7 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption, Option_t *allEvents) {
                  
                  if(timediff>=0.2) nlargeTofDiff++;
                  
-                 digit[0] = (Int_t) ((tofAfterSimul[indexOfPad]*1.e+03)/fTdcBin); // TDC bin number (each bin -> 25. ps)
+                 digit[0] = (Int_t) ((tofAfterSimul[indexOfPad]*1.e+03)/fTdcBin); // TDC bin number (each bin -> 50. ps)
                  
                  Float_t landauFactor = gRandom->Landau(fAdcMean, fAdcRms); 
                  digit[1] = (Int_t) (qInduced[indexOfPad] * landauFactor); // ADC bins (each bin -> 0.25 (or 0.03) pC)
@@ -328,7 +351,7 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption, Option_t *allEvents) {
                    AliTOFSDigit *sdig = static_cast<AliTOFSDigit*>(hitMap->GetHit(vol));
                    Int_t tdctime = (Int_t) digit[0];
                    Int_t adccharge = (Int_t) digit[1];
-                   sdig->Update(tdctime,adccharge,tracknum);
+                   sdig->Update(fTdcBin,tdctime,adccharge,tracknum);
                    ntotalupdatesinEv++;
                    ntotalupdates++;
                  } else {