]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/ITSHitsToDigits.C
New version with the Bari/Salerno model as default for SPD simulation
[u/mrichter/AliRoot.git] / ITS / ITSHitsToDigits.C
CommitLineData
e8189707 1#include "iostream.h"
2
3void ITSHitsToDigits (Int_t evNumber1=0,Int_t evNumber2=0,Int_t nsignal =25, Int_t size=-1)
4{
5/////////////////////////////////////////////////////////////////////////
6// This macro is a small example of a ROOT macro
7// illustrating how to read the output of GALICE
8// and do some analysis.
9//
10/////////////////////////////////////////////////////////////////////////
11
12// Dynamically link some shared libs
13
14 if (gClassTable->GetID("AliRun") < 0) {
15 gROOT->LoadMacro("loadlibs.C");
16 loadlibs();
9c712bc6 17 } else {
18 delete gAlice;
19 gAlice=0;
20 }
e8189707 21
22
23// Connect the Root Galice file containing Geometry, Kine and Hits
24
25 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
26 printf("file %p\n",file);
27 if (file) file->Close();
28 if (!file) file = new TFile("galice.root","UPDATE");
29 file->ls();
30
31 printf ("I'm after Map \n");
32
33// Get AliRun object from file or create it if not on file
34
35 if (!gAlice) {
36 gAlice = (AliRun*)file->Get("gAlice");
37 if (gAlice) printf("AliRun object found on file\n");
38 if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
39 }
40 printf ("I'm after gAlice \n");
41
42 AliITS *ITS = (AliITS*) gAlice->GetModule("ITS");
43 if (!ITS) return;
44
45
46 // Set the simulation models
47
48 AliITSgeom *geom = ITS->GetITSgeom();
49
50 // SDD
51 // SDD compression param: 2 fDecrease, 2fTmin, 2fTmax or disable, 2 fTolerance
b9381d0c 52
af4af6f5 53 AliITSDetType *iDetType=ITS->DetType(1);
54 AliITSresponseSDD *res1 = (AliITSresponseSDD*)iDetType->GetResponseModel();
55 if (!res1) {
56 res1=new AliITSresponseSDD();
57 ITS->SetResponseModel(1,res1);
58 }
b9381d0c 59
21b825a4 60
1ef94a0c 61 //res1->SetChargeLoss(0.);
62 Float_t baseline;
63 Float_t noise;
64 res1->GetNoiseParam(noise,baseline);
65 Float_t noise_after_el = res1->GetNoiseAfterElectronics();
21b825a4 66 cout << "noise_after_el: " << noise_after_el << endl;
1ef94a0c 67 Float_t fCutAmp;
68 fCutAmp = baseline;
69 fCutAmp += (2.*noise_after_el); // noise
70 cout << "Cut amplitude: " << fCutAmp << endl;
71 Int_t cp[8]={0,0,fCutAmp,fCutAmp,0,0,0,0};
72 res1->SetCompressParam(cp);
73 // res1->SetElectronics(2); // 1 = Pascal, 2 = OLA
6bfd27fa 74
1ef94a0c 75 res1->Print();
b9381d0c 76
1ef94a0c 77 //cout << "SDD segmentation" << endl;
e8189707 78
79 AliITSsegmentationSDD *seg1=(AliITSsegmentationSDD*)iDetType->GetSegmentationModel();
80 if (!seg1) {
81 seg1 = new AliITSsegmentationSDD(geom,res1);
82 ITS->SetSegmentationModel(1,seg1);
83 }
1ef94a0c 84 seg1->Print();
e8189707 85
1ef94a0c 86 //cout << "SDD segmentation" << endl;
e8189707 87 AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
88 ITS->SetSimulationModel(1,sim1);
1ef94a0c 89 sim1->Print();
21b825a4 90
e8189707 91
92 // SPD
93
94 AliITSDetType *iDetType=ITS->DetType(0);
95 AliITSsegmentationSPD *seg0=(AliITSsegmentationSPD*)iDetType->GetSegmentationModel();
96 AliITSresponseSPD *res0 = (AliITSresponseSPD*)iDetType->GetResponseModel();
21b825a4 97 //AliITSresponseSPD *res0= new AliITSresponseSPD();
98 //ITS->SetResponseModel(0,res0);
99
100// to change the parameters
101 //res0->SetThresholds(2000,280);
102 //res0->SetNoiseParam(0., 0.);
103 //res0->SetNoiseParam(0.04, 0.08);
104
105// to monitor the parameters
106 Float_t thresh, sigma;
107 res0->Thresholds(thresh, sigma);
108 printf("SPD: threshold %e sigma %e\n",thresh, sigma);
109 Float_t col, row;
110 res0->GetNoiseParam(col, row);
111 printf("SPD: Coupling by column %e Coupling by row %e\n",col, row);
112
e8189707 113 AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
114 ITS->SetSimulationModel(0,sim0);
e8189707 115
116 // SSD
117
118 AliITSDetType *iDetType=ITS->DetType(2);
119 AliITSsegmentationSSD *seg2=(AliITSsegmentationSSD*)iDetType->GetSegmentationModel();
120 AliITSresponseSSD *res2 = (AliITSresponseSSD*)iDetType->GetResponseModel();
121 res2->SetSigmaSpread(3.,2.);
122 AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
123 ITS->SetSimulationModel(2,sim2);
124
125
126//
127// Event Loop
128//
129
e8189707 130
a939f834 131 // create the TreeD
132
133 Int_t nparticles=gAlice->GetEvent(0);
134 printf("Create TreeD \n");
629ed79f 135 if(!gAlice->TreeD()) gAlice->MakeTree("D");
a939f834 136 //make branch
137 ITS->MakeBranch("D");
138
139 Int_t nbgr_ev=0;
e53d0fac 140
141
142 cout<<"Digitizing ITS...\n";
143 TStopwatch timer;
144
e8189707 145 for (Int_t nev=evNumber1; nev<= evNumber2; nev++) {
146 cout << "nev " <<nev<<endl;
a939f834 147 if(nev>0) {
21b825a4 148 nparticles = gAlice->GetEvent(nev);
149 gAlice->SetEvent(nev);
150 if(!gAlice->TreeD()) gAlice-> MakeTree("D");
151 ITS->MakeBranch("D");
a939f834 152 }
e8189707 153 cout << "nparticles " <<nparticles<<endl;
154 if (nev < evNumber1) continue;
155 if (nparticles <= 0) return;
156
9c712bc6 157 Int_t nbgr_ev=0;
158 if(nsignal) nbgr_ev=Int_t(nev/nsignal);
1ef94a0c 159 timer.Start();
e8189707 160 ITS->HitsToDigits(nev,nbgr_ev,size," ","All"," ");
21b825a4 161 //ITS->HitsToDigits(nev,nbgr_ev,size," ","SPD"," ");
1ef94a0c 162 timer.Stop(); timer.Print();
e8189707 163 } // event loop
164
21b825a4 165// delete sim0;
9c712bc6 166 delete sim1;
167 delete sim2;
168
e8189707 169 file->Close();
170}