]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSMerge.C
Reworked to work for the ITS only. Based on Jiri's MergeV1.C
[u/mrichter/AliRoot.git] / ITS / AliITSMerge.C
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // name: AliITSMerge
4 // date: 11.4.2002
5 // last update: 11.4.2002
6 // Updated 5/6/02
7 // author: Jiri Chudoba
8 // update by Bjorn Nilsen
9 // version: 1.1
10 //
11 // description: 
12 //       creates digits from sdigits for several detectors
13 //       stores sdigits in separate file (or in the source file
14 //       with sdigits). Stores gAlice object and copies TE to the
15 //       file with digits
16 //       ITS region of Interest is set
17 //       test
18 //
19 // input:
20 //       TString fileNameSDigits ... input file with sdigits
21 //       TString fileNameDigits ... output file with digits
22 //       Int_t nEvents  ... how many events to process
23 //       Int_t ITS, many flags for diff. detectors
24 //
25 // History:
26 //
27 // 04.04.02 - first version
28 // 
29 ////////////////////////////////////////////////////////////////////////
30
31 #if !defined(__CINT__) || defined(__MAKECINT__)
32 #include "iostream.h"
33 #include "TDatetime.h"
34 #include "STEER/AliRun.h"
35 #include "STEER/AliRunDigitizer.h"
36 #include "ITS/AliITSDigitizer.h"
37 #include "ITS/AliITS.h"
38 #include "ITS/AliITSDetType.h"
39 #include "ITS/AliITSresponseSDD.h"
40 #include "TStopwatch.h"
41 #endif
42
43 // #include "AliHits2SDigits.C"
44
45 Int_t AliITSMerge(TString fileNameDigits="digits.root", 
46             TString fileNameSDigitsSig="sig.sdigits.root", 
47             TString fileNameSDigitsBgr="bgr.sdigits.root", 
48             Int_t nEvents = 1, Int_t iITS = 2){
49 // delete the current gAlice object, the one from input file
50 //  will be used
51
52   if(gAlice){
53     delete gAlice;
54     gAlice = 0;
55   } // end if gAlice
56
57   // Connect the Root Galice file containing Geometry, Kine and Hits
58   TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(fileNameSDigitsSig.Data());
59   if(!file) file = new TFile(fileNameSDigitsSig.Data());
60   TDatime *ct0 = new TDatime(2002,04,26,00,00,00), ct = file->GetCreationDate();
61   
62  
63   // Get AliRun object from file or create it if not on file
64   if(!gAlice) {
65       gAlice = (AliRun*)file->Get("gAlice");
66       if(gAlice) printf("AliRun object found on file\n");
67       if(!gAlice) gAlice = new AliRun("gAlice","Alice test program");
68   } // end if !gAlice
69
70   AliRunDigitizer * manager = new AliRunDigitizer(2,1);
71   manager->SetInputStream(0,fileNameSDigitsSig.Data());
72   manager->SetInputStream(1,fileNameSDigitsBgr.Data());
73   if (fileNameDigits != "") {
74     manager->SetOutputFile(fileNameDigits);
75   }
76   manager->SetNrOfEventsToWrite(nEvents);
77   
78   if (iITS) {
79     AliITSDigitizer *dITS  = new AliITSDigitizer(manager);
80     if (iITS == 2) dITS->SetByRegionOfInterestFlag(1);
81     // For old files, must change SDD noise.
82     // and for new file we will do it anyway for simplicity.
83     AliITS *ITS = (AliITS*) gAlice->GetDetector("ITS");
84     AliITSresponseSDD *resp1 = ITS->DetType(1)->GetResponseModel();
85     resp1->SetNoiseParam();
86     resp1->SetNoiseAfterElectronics();
87     Float_t n,b;
88     Int_t cPar[8];
89     resp1->GetNoiseParam(n,b);
90     n = resp1->GetNoiseAfterElectronics();
91     cPar[0]=0;
92     cPar[1]=0;
93     cPar[2]=(Int_t)(b + 2.*n + 0.5);
94     cPar[3]=(Int_t)(b + 2.*n + 0.5);
95     cPar[4]=0;
96     cPar[5]=0;
97     cPar[6]=0;
98     cPar[7]=0;
99     resp1->SetCompressParam(cPar);
100   }
101   TStopwatch timer;
102   timer.Start();
103   manager->Exec("deb all");
104   timer.Stop(); 
105   timer.Print();
106   // gAlice may need to be deleted but not if as part of larger production.
107   delete manager;
108 }
109