]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFSDigitizer.cxx
Removing inheritances from TAttLine, TAttMarker and AliRndm in AliModule. The copy...
[u/mrichter/AliRoot.git] / TOF / AliTOFSDigitizer.cxx
index 1ffbe7f4bbfec5e97758df4322ad5baf51b71286..d86265ce7bd51941f494dc0807c9cfb328929ef7 100644 (file)
 
 /* $Id$ */
 
-//_________________________________________________________________________
-// This is a TTask that constructs SDigits out of Hits
-// A Summable Digits is the "sum" of all hits in a pad
-// Detector response has been simulated via the method
-// SimulateDetectorResponse
-//
-//-- Authors: F. Pierella, A. De Caro
-// Use case: see AliTOFhits2sdigits.C macro in the CVS
-//////////////////////////////////////////////////////////////////////////////
-
-#include <Riostream.h>
-#include <stdlib.h>
+//__________________________________________________________//
+//                                                          //
+//   This is a TTask that constructs SDigits out of Hits    //
+//   A Summable Digits is the "sum" of all hits in a pad    //
+//   Detector response has been simulated via the method    //
+//   SimulateDetectorResponse                               //
+//                                                          //
+//  -- Authors: F. Pierella, A. De Caro                     //
+//   Use case: see AliTOFhits2sdigits.C macro in the CVS    //
+//__________________________________________________________//
 
 #include <TBenchmark.h>
 #include <TF1.h>
 #include <TFile.h>
-#include <TFolder.h>
-#include <TH1.h>
 #include <TParticle.h>
-#include <TROOT.h>
-#include <TSystem.h>
-#include <TTask.h>
 #include <TTree.h>
+#include <TRandom.h>
 
-#include "AliLog.h"
-#include "AliDetector.h"
 #include "AliLoader.h"
-#include "AliRun.h"
+#include "AliLog.h"
+#include "AliMC.h"
 #include "AliRunLoader.h"
-#include "AliTOF.h"
+#include "AliRun.h"
+
 #include "AliTOFGeometry.h"
 #include "AliTOFHitMap.h"
-#include "AliTOFSDigit.h"
-#include "AliTOFSDigitizer.h"
-#include "AliTOFhit.h"
 #include "AliTOFhitT0.h"
-#include "AliMC.h"
+#include "AliTOFhit.h"
+#include "AliTOFSDigitizer.h"
+#include "AliTOFSDigit.h"
+#include "AliTOF.h"
+
 
 ClassImp(AliTOFSDigitizer)
 
 //____________________________________________________________________________ 
-  AliTOFSDigitizer::AliTOFSDigitizer():TTask("TOFSDigitizer","") 
+AliTOFSDigitizer::AliTOFSDigitizer():
+  TTask("TOFSDigitizer",""),
+  fEvent1(-1),
+  fEvent2(-1),
+  ftail(0x0),
+  fHeadersFile(""),
+  fRunLoader(0x0),
+  fTOFLoader(0x0),
+  fTOFGeometry(new AliTOFGeometry()),
+  fSelectedSector(-1), 
+  fSelectedPlate(-1),
+  fTimeResolution(0),
+  fpadefficiency(0),
+  fEdgeEffect(-1),
+  fEdgeTails(-1),
+  fHparameter(0),
+  fH2parameter(0),
+  fKparameter(0),
+  fK2parameter(0),
+  fEffCenter(0),
+  fEffBoundary(0),
+  fEff2Boundary(0),
+  fEff3Boundary(0),
+  fAddTRes(0),
+  fResCenter(0),
+  fResBoundary(0),
+  fResSlope(0),
+  fTimeWalkCenter(0),
+  fTimeWalkBoundary(0),
+  fTimeWalkSlope(0),
+  fTimeDelayFlag(-1),
+  fPulseHeightSlope(0),
+  fTimeDelaySlope(0),
+  fMinimumCharge(0),
+  fChargeSmearing(0),
+  fLogChargeSmearing(0),
+  fTimeSmearing(0),
+  fAverageTimeFlag(-1),
+  fAdcBin(0),
+  fAdcMean(0),
+  fAdcRms(0)
 {
   // ctor
+}
 
-  fRunLoader      = 0;
-  fTOFLoader      = 0;
+//------------------------------------------------------------------------
+AliTOFSDigitizer::AliTOFSDigitizer(const AliTOFSDigitizer &source):
+  TTask(source),
+  fEvent1(-1),
+  fEvent2(-1),
+  ftail(0x0),
+  fHeadersFile(""),
+  fRunLoader(0x0),
+  fTOFLoader(0x0),
+  fTOFGeometry(0x0),
+  fSelectedSector(-1), 
+  fSelectedPlate(-1),
+  fTimeResolution(0),
+  fpadefficiency(0),
+  fEdgeEffect(-1),
+  fEdgeTails(-1),
+  fHparameter(0),
+  fH2parameter(0),
+  fKparameter(0),
+  fK2parameter(0),
+  fEffCenter(0),
+  fEffBoundary(0),
+  fEff2Boundary(0),
+  fEff3Boundary(0),
+  fAddTRes(0),
+  fResCenter(0),
+  fResBoundary(0),
+  fResSlope(0),
+  fTimeWalkCenter(0),
+  fTimeWalkBoundary(0),
+  fTimeWalkSlope(0),
+  fTimeDelayFlag(-1),
+  fPulseHeightSlope(0),
+  fTimeDelaySlope(0),
+  fMinimumCharge(0),
+  fChargeSmearing(0),
+  fLogChargeSmearing(0),
+  fTimeSmearing(0),
+  fAverageTimeFlag(-1),
+  fAdcBin(0),
+  fAdcMean(0),
+  fAdcRms(0)
+{
+  // copy constructor
+  this->fTOFGeometry=source.fTOFGeometry;
 
-  fEvent1         = 0;
-  fEvent2         = 0;
-  ftail           = 0;
-  fSelectedSector = -1;
-  fSelectedPlate  = -1;
 }
 
 //____________________________________________________________________________ 
-AliTOFSDigitizer::AliTOFSDigitizer(const char* HeaderFile, Int_t evNumber1, Int_t nEvents):TTask("TOFSDigitizer","")
+AliTOFSDigitizer& AliTOFSDigitizer::operator=(const AliTOFSDigitizer &source)
 {
-  ftail    = 0;
-  fSelectedSector=-1; // by default we sdigitize all sectors
-  fSelectedPlate =-1; // by default we sdigitize all plates in all sectors
+  // ass. op.
+  this->fTOFGeometry=source.fTOFGeometry;
+  return *this;
+
+}
+
+//____________________________________________________________________________ 
+AliTOFSDigitizer::AliTOFSDigitizer(const char* HeaderFile, Int_t evNumber1, Int_t nEvents):
+  TTask("TOFSDigitizer",""),
+  fEvent1(-1),
+  fEvent2(-1),
+  ftail(0x0),
+  fHeadersFile(HeaderFile), // input filename (with hits)
+  fRunLoader(0x0),
+  fTOFLoader(0x0),
+  fTOFGeometry(0x0),
+  fSelectedSector(-1), // by default we sdigitize all sectors
+  fSelectedPlate(-1),  // by default we sdigitize all plates in all sectors
+  fTimeResolution(0),
+  fpadefficiency(0),
+  fEdgeEffect(-1),
+  fEdgeTails(-1),
+  fHparameter(0),
+  fH2parameter(0),
+  fKparameter(0),
+  fK2parameter(0),
+  fEffCenter(0),
+  fEffBoundary(0),
+  fEff2Boundary(0),
+  fEff3Boundary(0),
+  fAddTRes(0),
+  fResCenter(0),
+  fResBoundary(0),
+  fResSlope(0),
+  fTimeWalkCenter(0),
+  fTimeWalkBoundary(0),
+  fTimeWalkSlope(0),
+  fTimeDelayFlag(-1),
+  fPulseHeightSlope(0),
+  fTimeDelaySlope(0),
+  fMinimumCharge(0),
+  fChargeSmearing(0),
+  fLogChargeSmearing(0),
+  fTimeSmearing(0),
+  fAverageTimeFlag(-1),
+  fAdcBin(0),
+  fAdcMean(0),
+  fAdcRms(0)
+{
+  //ctor, reading from input file 
   
-  fHeadersFile = HeaderFile ; // input filename (with hits)
   TFile * file = (TFile*) gROOT->GetFile(fHeadersFile.Data());
   
   //File was not opened yet open file and get alirun object
@@ -97,6 +217,21 @@ AliTOFSDigitizer::AliTOFSDigitizer(const char* HeaderFile, Int_t evNumber1, Int_
       return;
     }
 
+  fRunLoader->CdGAFile();
+  TDirectory *savedir=gDirectory;
+  TFile *in=(TFile*)gFile;
+
+  if (!in->IsOpen()) {
+    AliWarning("Geometry file is not open default TOF geometry will be used");
+    fTOFGeometry = new AliTOFGeometry();
+  }
+  else {
+    in->cd();
+    fTOFGeometry = (AliTOFGeometry*)in->Get("TOFgeometry");
+  }
+
+  savedir->cd();
+
   if (fRunLoader->TreeE() == 0x0) fRunLoader->LoadHeader();
   
   if (evNumber1>=0) fEvent1 = evNumber1;
@@ -130,6 +265,9 @@ AliTOFSDigitizer::~AliTOFSDigitizer()
 {
   // dtor
   fTOFLoader->CleanSDigitizer();
+
+  delete fTOFGeometry;
+
 }
 
 //____________________________________________________________________________ 
@@ -191,10 +329,9 @@ Double_t TimeWithTail(Double_t* x, Double_t* par)
   return f;
 }
 
-
 //____________________________________________________________________________
 void AliTOFSDigitizer::Exec(Option_t *verboseOption) { 
-
+  //execute TOF sdigitization
   if (strstr(verboseOption,"tim") || strstr(verboseOption,"all"))
     gBenchmark->Start("TOFSDigitizer");
 
@@ -227,8 +364,8 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption) {
   fTOFLoader->LoadSDigits("recreate");
   
   for (Int_t iEvent=fEvent1; iEvent<fEvent2; iEvent++) {
-//     cout << "------------------- "<< GetName() << " ------------- \n";
-//     cout << "Sdigitizing event " << iEvent << endl;
+    //AliInfo(Form("------------------- %s -------------", GetName()));
+    //AliInfo(Form("Sdigitizing event %i", iEvent));
 
     fRunLoader->GetEvent(iEvent);
 
@@ -262,7 +399,7 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption) {
     TClonesArray *tofHitArray = tof->Hits();
 
     // create hit map
-    AliTOFHitMap *hitMap = new AliTOFHitMap(tof->SDigits());
+    AliTOFHitMap *hitMap = new AliTOFHitMap(tof->SDigits(), fTOFGeometry);
 
     TBranch * tofHitsBranch = hitTree->GetBranch("TOF");
 
@@ -271,7 +408,10 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption) {
     {
       gAlice->ResetHits();
       tofHitsBranch->GetEvent(track);
-      particle = gAlice->GetMCApp()->Particle(track);
+
+      AliMC *mcApplication = (AliMC*)gAlice->GetMCApp();
+
+      particle = mcApplication->Particle(track);
       Int_t nhits = tofHitArray->GetEntriesFast();
       // cleaning all hits of the same track in the same pad volume
       // it is a rare event, however it happens
@@ -293,7 +433,7 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption) {
 
        // fp: really sorry for this, it is a temporary trick to have
        // track length too
-       if(version!=6){
+       if(version!=6 && version!=7){
          AliTOFhit *tofHit = (AliTOFhit *) tofHitArray->UncheckedAt(hit);
          tracknum = tofHit->GetTrack();
          vol[0] = tofHit->GetSector();
@@ -463,12 +603,13 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption) {
 //__________________________________________________________________
 void AliTOFSDigitizer::Print(Option_t* /*opt*/)const
 {
-  cout << "------------------- "<< GetName() << " ------------- \n";
+  AliInfo(Form(" ------------------- %s ------------- ", GetName()));
 }
 
 //__________________________________________________________________
 void AliTOFSDigitizer::SelectSectorAndPlate(Int_t sector, Int_t plate)
 {
+  //Select sector and plate
   Bool_t isaWrongSelection=(sector < 0) || (sector >= AliTOFGeometry::NSectors()) || (plate < 0) || (plate >= AliTOFGeometry::NPlates());
   if(isaWrongSelection){
     AliError("You have selected an invalid value for sector or plate ");
@@ -771,36 +912,36 @@ void AliTOFSDigitizer::PrintParameters()const
   //
   // Print parameters used for sdigitization
   //
-  cout << " ------------------- "<< GetName() << " -------------" << endl ;
-  cout << " Parameters used for TOF SDigitization " << endl ;
+  AliInfo(Form(" ------------------- %s -------------", GetName()));
+  AliInfo(" Parameters used for TOF SDigitization ");
   //  Printing the parameters
   
-  cout << " Number of events:                        " << (fEvent2-fEvent1) << endl; 
-  cout << " from event " << fEvent1 << " to event " << (fEvent2-1) << endl; 
-  cout << " Time Resolution (ns) "<< fTimeResolution <<" Pad Efficiency: "<< fpadefficiency << endl;
-  cout << " Edge Effect option:  "<<  fEdgeEffect<< endl;
-
-  cout << " Boundary Effect Simulation Parameters " << endl;
-  cout << " Hparameter: "<< fHparameter<<"  H2parameter:"<< fH2parameter <<"  Kparameter:"<< fKparameter<<"  K2parameter: "<< fK2parameter << endl;
-  cout << " Efficiency in the central region of the pad: "<< fEffCenter << endl;
-  cout << " Efficiency at the boundary region of the pad: "<< fEffBoundary << endl;
-  cout << " Efficiency value at H2parameter "<< fEff2Boundary << endl;
-  cout << " Efficiency value at K2parameter "<< fEff3Boundary << endl;
-  cout << " Resolution (ps) in the central region of the pad: "<< fResCenter << endl;
-  cout << " Resolution (ps) at the boundary of the pad      : "<< fResBoundary << endl;
-  cout << " Slope (ps/K) for neighbouring pad               : "<< fResSlope <<endl;
-  cout << " Time walk (ps) in the central region of the pad : "<< fTimeWalkCenter << endl;
-  cout << " Time walk (ps) at the boundary of the pad       : "<< fTimeWalkBoundary<< endl;
-  cout << " Slope (ps/K) for neighbouring pad               : "<< fTimeWalkSlope<<endl;
-  cout << " Pulse Heigth Simulation Parameters " << endl;
-  cout << " Flag for delay due to the PulseHeightEffect: "<< fTimeDelayFlag <<endl;
-  cout << " Pulse Height Slope                           : "<< fPulseHeightSlope<<endl;
-  cout << " Time Delay Slope                             : "<< fTimeDelaySlope<<endl;
-  cout << " Minimum charge amount which could be induced : "<< fMinimumCharge<<endl;
-  cout << " Smearing in charge in (q1/q2) vs x plot      : "<< fChargeSmearing<<endl;
-  cout << " Smearing in log of charge ratio              : "<< fLogChargeSmearing<<endl;
-  cout << " Smearing in time in time vs log(q1/q2) plot  : "<< fTimeSmearing<<endl;
-  cout << " Flag for average time                        : "<< fAverageTimeFlag<<endl;
-  cout << " Edge tails option                            : "<< fEdgeTails << endl;
+  AliInfo(Form(" Number of events:                       %i ", (fEvent2-fEvent1)));
+  AliInfo(Form(" from event %i to event %i", fEvent1, (fEvent2-1)));
+  AliInfo(Form(" Time Resolution (ns) %d  Pad Efficiency: %d ", fTimeResolution, fpadefficiency));
+  AliInfo(Form(" Edge Effect option:  %d", fEdgeEffect));
+
+  AliInfo(" Boundary Effect Simulation Parameters ");
+  AliInfo(Form(" Hparameter: %d  H2parameter: %d  Kparameter: %d  K2parameter: %d", fHparameter, fH2parameter, fKparameter, fK2parameter));
+  AliInfo(Form(" Efficiency in the central region of the pad: %d", fEffCenter));
+  AliInfo(Form(" Efficiency at the boundary region of the pad: %d", fEffBoundary));
+  AliInfo(Form(" Efficiency value at H2parameter %d", fEff2Boundary));
+  AliInfo(Form(" Efficiency value at K2parameter %d", fEff3Boundary));
+  AliInfo(Form(" Resolution (ps) in the central region of the pad: %d", fResCenter));
+  AliInfo(Form(" Resolution (ps) at the boundary of the pad      : %d", fResBoundary));
+  AliInfo(Form(" Slope (ps/K) for neighbouring pad               : %d", fResSlope));
+  AliInfo(Form(" Time walk (ps) in the central region of the pad : %d", fTimeWalkCenter));
+  AliInfo(Form(" Time walk (ps) at the boundary of the pad       : %d", fTimeWalkBoundary));
+  AliInfo(Form(" Slope (ps/K) for neighbouring pad               : %d", fTimeWalkSlope));
+  AliInfo(" Pulse Heigth Simulation Parameters ");
+  AliInfo(Form(" Flag for delay due to the PulseHeightEffect  : %d", fTimeDelayFlag));
+  AliInfo(Form(" Pulse Height Slope                           : %d", fPulseHeightSlope));
+  AliInfo(Form(" Time Delay Slope                             : %d", fTimeDelaySlope));
+  AliInfo(Form(" Minimum charge amount which could be induced : %d", fMinimumCharge));
+  AliInfo(Form(" Smearing in charge in (q1/q2) vs x plot      : %d", fChargeSmearing));
+  AliInfo(Form(" Smearing in log of charge ratio              : %d", fLogChargeSmearing));
+  AliInfo(Form(" Smearing in time in time vs log(q1/q2) plot  : %d", fTimeSmearing));
+  AliInfo(Form(" Flag for average time                        : %d", fAverageTimeFlag));
+  AliInfo(Form(" Edge tails option                            : %d", fEdgeTails));
   
 }