]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/MergeV1.C
More exact rounding function, but also much slower.
[u/mrichter/AliRoot.git] / ITS / MergeV1.C
CommitLineData
fd04285a 1////////////////////////////////////////////////////////////////////////
2//
3// name: MergeV1
4// date: 11.4.2002
5// last update: 11.4.2002
6// author: Jiri Chudoba
7// version: 1.0
8//
9// description:
10// creates digits from sdigits for several detectors
11// stores sdigits in separate file (or in the source file
12// with sdigits). Stores gAlice object and copies TE to the
13// file with digits
14// ITS region of Interest is set
15// test
16//
17// input:
18// TString fileNameSDigits ... input file with sdigits
19// TString fileNameDigits ... output file with digits
20// Int_t nEvents ... how many events to process
21// Int_t ITS, TPC, ... many flags for diff. detectors
22//
23// History:
24//
25// 04.04.02 - first version
26//
27////////////////////////////////////////////////////////////////////////
28
29#if !defined(__CINT__) || defined(__MAKECINT__)
30#include "iostream.h"
31#include "TDatetime.h"
32#include "STEER/AliRun.h"
33#include "STEER/AliRunDigitizer.h"
34#include "ITS/AliITSDigitizer.h"
35#include "ITS/AliITS.h"
36#include "ITS/AliITSDetType.h"
37#include "ITS/AliITSresponseSDD.h"
38#include "TPC/AliTPCDigitizer.h"
39#include "TRD/AliTRDdigitizer.h"
40#include "PHOS/AliPHOSDigitizer.h"
41#include "MUON/AliMUONDigitizer.h"
42#include "RICH/AliRICHDigitizer.h"
43#include "TStopwatch.h"
44#endif
45
46// #include "AliHits2SDigits.C"
47
48// void AliCopyN(TString inputFile, TString outputFile);
49
50Int_t MergeV1(TString fileNameDigits="digits.root",
51 TString fileNameSDigitsSig="sig.sdigits.root",
52 TString fileNameSDigitsBgr="bgr.sdigits.root",
53 Int_t nEvents = 1, Int_t iITS = 2, Int_t iTPC = 0,
54 Int_t iTRD = 0, Int_t iPHOS = 0, Int_t iMUON = 0,
55 Int_t iRICH = 0, Int_t iCopy = 1)
56{
57// delete the current gAlice object, the one from input file
58// will be used
59
60 if(gAlice){
61 delete gAlice;
62 gAlice = 0;
63 } // end if gAlice
64
65 // Connect the Root Galice file containing Geometry, Kine and Hits
66 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(fileNameSDigitsSig.Data());
67 if(!file) file = new TFile(fileNameSDigitsSig.Data());
68 TDatime *ct0 = new TDatime(2002,04,26,00,00,00), ct = file->GetCreationDate();
69
70
71 // Get AliRun object from file or create it if not on file
72 if(!gAlice) {
73 gAlice = (AliRun*)file->Get("gAlice");
74 if(gAlice) printf("AliRun object found on file\n");
75 if(!gAlice) gAlice = new AliRun("gAlice","Alice test program");
76 } // end if !gAlice
77
78 AliRunDigitizer * manager = new AliRunDigitizer(2,1);
79 manager->SetInputStream(0,fileNameSDigitsSig.Data());
80 manager->SetInputStream(1,fileNameSDigitsBgr.Data());
81 if (fileNameDigits != "") {
82// if (iCopy) {
83// AliCopyN(fileNameSDigitsSig,fileNameDigits);
84// }
85 manager->SetOutputFile(fileNameDigits);
86 }
87 manager->SetNrOfEventsToWrite(nEvents);
88
89 if (iITS) {
90 AliITSDigitizer *dITS = new AliITSDigitizer(manager);
91 if (iITS == 2) dITS->SetByRegionOfInterestFlag(1);
92 if(ct0->GetDate()>ct.GetDate()){
93 // For old files, must change SDD noise.
94 AliITS *ITS = (AliITS*) gAlice->GetDetector("ITS");
95 AliITSresponseSDD *resp1 = ITS->DetType(1)->GetResponseModel();
96 resp1->SetNoiseParam();
97 resp1->SetNoiseAfterElectronics();
98 Float_t n,b;
99 Int_t cPar[8];
100 resp1->GetNoiseParam(n,b);
101 n = resp1->GetNoiseAfterElectronics();
102 cPar[0]=0;
103 cPar[1]=0;
104 cPar[2]=(Int_t)(b + 2.*n + 0.5);
105 cPar[3]=(Int_t)(b + 2.*n + 0.5);
106 cPar[4]=0;
107 cPar[5]=0;
108 cPar[6]=0;
109 cPar[7]=0;
110 resp1->SetCompressParam(cPar);
111 } // end if
112 }
113 if (iTPC) AliTPCDigitizer *dTPC = new AliTPCDigitizer(manager);
114 if (iTRD) AliTRDdigitizer *dTRD = new AliTRDdigitizer(manager);
115 if (iPHOS) AliPHOSDigitizer *dPHOS = new AliPHOSDigitizer(manager);
116 if (iMUON) AliMUONDigitizer *dMUON = new AliMUONDigitizer(manager);
117 if (iRICH) AliRICHDigitizer *dRICH = new AliRICHDigitizer(manager);
118 TStopwatch timer;
119 timer.Start();
120 manager->Exec("deb all");
121 timer.Stop();
122 timer.Print();
123// delete gAlice;
124// gAlice = 0;
125 delete manager;
126}
127
128
129/*
130////////////////////////////////////////////////////////////////////////
131void AliCopyN(TString inputFileName, TString outputFileName) {
132// copy some objects
133
134 TFile *inputFile = OpenFile(inputFileName);
135 if (!inputFile) return;
136
137 TFile *outputFile = TFile::Open(outputFileName.Data(),"update");
138 if (!outputFile->IsOpen()) {
139 cerr<<"Can't open "<<outputFileName.Data()<<" !\n";
140 return;
141 }
142 if (!ImportgAlice(inputFile)) return;
143 AliCopy(inputFile, outputFile);
144 delete gAlice;
145 gAlice=0;
146 inputFile->Close();
147 delete inputFile;
148 outputFile->Close();
149 delete outputFile;
150}
151////////////////////////////////////////////////////////////////////////
152*/