ROOT logo
#if !defined(__CINT__) || defined(__MAKECINT__)

#include "iostream.h"
#include "TDatime.h"
#include "TDatime.h"
#include "TFile.h"
#include "TString.h"
#include "../STEER/AliRun.h"
#include "../STEER/AliRunDigitizer.h"
//#include "ITS/AliITSDigitizer.h"
#include "ITS/AliITS.h"
#include "ITS/AliITSDetType.h"
#include "ITS/AliITSresponseSDD.h"
#include "TStopwatch.h"

Bool_t GaliceITSok();
TFile* AccessFile(TString inFile="galice.root", TString acctype="R");
void writeAR(TFile * fin, TFile *fou);
Int_t ChangeITSDefaults(TFile *hitfile,AliITS *ITS,TString opt="");
void loadlibs();

#endif

//#define DEBUG

Int_t AliITSh2d(TString hf="galice.root",TString df="",TString opt=""){
    // Produce ITS SDigits from Hits.

    // Dynamically link some shared libs
    if (gClassTable->GetID("AliRun") < 0) {
	gROOT->LoadMacro("loadlibs.C");
	loadlibs();
    } // end if
    gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSstandard.C");

    TFile *hfp = 0, *dfp = 0;
    if(!GaliceITSok()){
	// gAlice not define. Must open a file and read it in.
	if(hf.CompareTo(df) == 0 || df.CompareTo("") == 0) {
	    // Input file = output file
	    hfp = AccessFile(hf,"U");  // input file open for update.
	}else{ // Input file different from output file.
	    hfp = AccessFile(hf,"R"); // input file open as read only
	    // open output file and create TreeR on it
	    dfp = gAlice->InitTreeFile("D",df);
	} // end if
    } // end if !GALICEITSOK()
    AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");

    ChangeITSDefaults(hfp,ITS,opt);
    // write the AliRun object to the output file if different from input file.
    if(dfp) writeAR(hfp,dfp);

    TStopwatch timer;
    Int_t evNumber1 = 0;
    Int_t evNumber2 = gAlice->GetEventsPerRun();
    timer.Start();
    for(Int_t event = evNumber1; event < evNumber2; event++){
	gAlice->GetEvent(event);
	if(!gAlice->TreeD() && dfp == 0){ 
	    cout << "Having to create the Digits Tree." << endl;
	    gAlice->MakeTree("S");
	} // end if !gAlice->TreeS()
	if(dfp) gAlice->MakeTree("D",dfp);
	//    make branch
	ITS->MakeBranch("D");
	ITS->SetTreeAddress();
#ifdef DEBUG
	cout<<"Making ITS Digits for event "<<event<<endl;
#endif
	ITS->Hits2Digits();
    } // end for event
    timer.Stop();
    timer.Print();
    if(dfp!=0){
	cout <<"After Digitization "<<df<< " size =" << dfp->GetSize() << endl;
    }else if(hfp!=0){
	cout <<"After digitization "<<hf<< " size =" << hfp->GetSize() << endl;
    } // end if dfp!=0
    return 0;
}
 AliITSh2d.C:1
 AliITSh2d.C:2
 AliITSh2d.C:3
 AliITSh2d.C:4
 AliITSh2d.C:5
 AliITSh2d.C:6
 AliITSh2d.C:7
 AliITSh2d.C:8
 AliITSh2d.C:9
 AliITSh2d.C:10
 AliITSh2d.C:11
 AliITSh2d.C:12
 AliITSh2d.C:13
 AliITSh2d.C:14
 AliITSh2d.C:15
 AliITSh2d.C:16
 AliITSh2d.C:17
 AliITSh2d.C:18
 AliITSh2d.C:19
 AliITSh2d.C:20
 AliITSh2d.C:21
 AliITSh2d.C:22
 AliITSh2d.C:23
 AliITSh2d.C:24
 AliITSh2d.C:25
 AliITSh2d.C:26
 AliITSh2d.C:27
 AliITSh2d.C:28
 AliITSh2d.C:29
 AliITSh2d.C:30
 AliITSh2d.C:31
 AliITSh2d.C:32
 AliITSh2d.C:33
 AliITSh2d.C:34
 AliITSh2d.C:35
 AliITSh2d.C:36
 AliITSh2d.C:37
 AliITSh2d.C:38
 AliITSh2d.C:39
 AliITSh2d.C:40
 AliITSh2d.C:41
 AliITSh2d.C:42
 AliITSh2d.C:43
 AliITSh2d.C:44
 AliITSh2d.C:45
 AliITSh2d.C:46
 AliITSh2d.C:47
 AliITSh2d.C:48
 AliITSh2d.C:49
 AliITSh2d.C:50
 AliITSh2d.C:51
 AliITSh2d.C:52
 AliITSh2d.C:53
 AliITSh2d.C:54
 AliITSh2d.C:55
 AliITSh2d.C:56
 AliITSh2d.C:57
 AliITSh2d.C:58
 AliITSh2d.C:59
 AliITSh2d.C:60
 AliITSh2d.C:61
 AliITSh2d.C:62
 AliITSh2d.C:63
 AliITSh2d.C:64
 AliITSh2d.C:65
 AliITSh2d.C:66
 AliITSh2d.C:67
 AliITSh2d.C:68
 AliITSh2d.C:69
 AliITSh2d.C:70
 AliITSh2d.C:71
 AliITSh2d.C:72
 AliITSh2d.C:73
 AliITSh2d.C:74
 AliITSh2d.C:75
 AliITSh2d.C:76
 AliITSh2d.C:77
 AliITSh2d.C:78
 AliITSh2d.C:79
 AliITSh2d.C:80
 AliITSh2d.C:81
 AliITSh2d.C:82