]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSHits2DigitsDubna.C
Macros now work with one or more events in a file. Shell scripts are
[u/mrichter/AliRoot.git] / ITS / AliITSHits2DigitsDubna.C
1 Int_t AliITSHits2DigitsDubna(const char *inFile = "galice.root"){
2     ////////////////////////////////////////////////////////////////////
3     //      This macro will take hits from a galice.root file and 
4     // produce digits for the ITS using the settings for the detector 
5     // simulations defined in this file. Specificaly it replaces the
6     // default SPD simulation with that of Dubna It will measure the 
7     // time required to do so and the increase in the galice.root file. 
8     // There is only one input, that of the name of the root file 
9     // containing the hits and to which the digits will be written to. 
10     // This macro will process all of the events on the root file.
11     ////////////////////////////////////////////////////////////////////
12
13     // Dynamically link some shared libs
14     if (gClassTable->GetID("AliRun") < 0) {
15         gROOT->LoadMacro("loadlibs.C");
16         loadlibs();
17     } // end if
18
19     // Connect the Root Galice file containing Geometry, Kine and Hits
20
21     TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(inFile);
22     if (file) {file->Close(); delete file;}
23     cout << "AliITSHits2DigitsDubna" << endl;
24     file = new TFile(inFile,"UPDATE");
25     if (!file->IsOpen()) {
26         cerr<<"Can't open "<<inFile<<" !" << endl;
27         return 1;
28     } // end if
29     file->ls();
30
31     // Get AliRun object from file or return if not on file
32     if (gAlice) delete gAlice;
33     gAlice = (AliRun*)file->Get("gAlice");
34     if (!gAlice) {
35         cerr<<"AliITSHits2DigitsDubna.C : AliRun object not found on file"
36             << endl;
37         return 2;
38     } // end if !gAlice
39
40     AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");      
41     if (!ITS) {
42         cerr<<"ITSHits2Digits.C : AliITS object not found on file" << endl;
43         return 3;
44     }  // end if !ITS
45     if(!(ITS->GetITSgeom())){
46         cerr << " AliITSgeom not found. Can't digitize with out it." << endl;
47         return 4;
48     } // end if
49
50     // SPD
51     cout << "Changing from Default SPD simulation, and responce." << endl;
52     AliITSDetType *iDetType=ITS->DetType(0);
53     AliITSsegmentationSPD *seg0=(AliITSsegmentationSPD*)iDetType->
54         GetSegmentationModel();
55     AliITSresponseSPDdubna *res0 = new AliITSresponseSPDdubna();
56     ITS->SetResponseModel(0,res0);
57     AliITSsimulationSPDdubna *sim0=new AliITSsimulationSPDdubna(seg0,res0);
58     ITS->SetSimulationModel(0,sim0);
59     // test
60     cout << "SPD dimensions " << seg0->Dx() << " " << seg0->Dz() << endl;
61     cout << "SPD npixels " << seg0->Npz() << " " << seg0->Npx() << endl;
62     cout << "SPD pitches " << seg0->Dpz(0) << " " << seg0->Dpx(0) << endl;
63     // end test
64
65     // SDD
66     cout << "Changing from Default SDD simulation, and responce." << endl;
67     //Set response functions
68     Float_t baseline = 10.;
69     Float_t noise = 1.75;
70     // SDD compression param: 2 fDecrease, 2fTmin, 2fTmax or disable,
71     // 2 fTolerance
72     AliITSDetType *iDetType=ITS->DetType(1);
73     AliITSresponseSDD *res1 = (AliITSresponseSDD*)iDetType->GetResponseModel();
74     if (!res1) {
75         res1=new AliITSresponseSDD();
76         ITS->SetResponseModel(1,res1);
77     } // end if !res1
78     Float_t fCutAmp = baseline + 2.*noise;
79     Int_t cp[8]={0,0,fCutAmp,fCutAmp,0,0,0,0}; //1D
80
81     //res1->SetZeroSupp("2D");
82     res1->SetZeroSupp("1D");
83     res1->SetNoiseParam(noise,baseline);
84     res1->SetDo10to8(kTRUE);
85     res1->SetCompressParam(cp);
86     res1->SetMinVal(4);
87     res1->SetDiffCoeff(3.6,40.);
88     AliITSsegmentationSDD *seg1=(AliITSsegmentationSDD*)iDetType->
89         GetSegmentationModel();
90     if (!seg1) {
91         seg1 = new AliITSsegmentationSDD(ITS->GetITSgeom(),res1);
92         ITS->SetSegmentationModel(1,seg1);
93     } // end if !seg1
94     AliITSsimulationSDD *sim1 = new AliITSsimulationSDD(seg1,res1);
95     sim1->SetDoFFT(1);
96     sim1->SetCheckNoise(kFALSE);
97     ITS->SetSimulationModel(1,sim1);
98
99     // SSD
100     cout << "Changing from Default SSD simulation, and responce." << endl;
101     AliITSDetType *iDetType = ITS->DetType(2);
102     AliITSsegmentationSSD *seg2 = (AliITSsegmentationSSD*)iDetType->
103         GetSegmentationModel();
104     AliITSresponseSSD *res2 = (AliITSresponseSSD*)iDetType->GetResponseModel();
105     res2->SetSigmaSpread(3.,2.);
106     AliITSsimulationSSD *sim2 = new AliITSsimulationSSD(seg2,res2);
107     ITS->SetSimulationModel(2,sim2);
108
109     cout << "Digitizing ITS..." << endl;
110
111     TStopwatch timer;
112     Long_t size0 = file->GetSize();
113     timer.Start();
114     gAlice->Hits2Digits();
115     timer.Stop(); timer.Print();
116
117     file->Close();
118     Long_t size1 = file->GetSize();
119     cout << "File size before = " << size0 << " file size after = " << size1;
120     cout << "Increase in file size is " << size1-size0 << " Bytes" << endl;
121     delete file;
122     return 0;
123 };
124