1 ////////////////////////////////////////////////////////////////////////
5 // last update: 11.4.2002
6 // author: Jiri Chudoba
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
14 // ITS region of Interest is set
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
25 // 04.04.02 - first version
27 ////////////////////////////////////////////////////////////////////////
29 #if !defined(__CINT__) || defined(__MAKECINT__)
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"
46 // #include "AliHits2SDigits.C"
48 // void AliCopyN(TString inputFile, TString outputFile);
50 Int_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)
57 // delete the current gAlice object, the one from input file
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();
71 // Get AliRun object from file or create it if not on file
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");
78 AliRunDigitizer * manager = new AliRunDigitizer(2,1);
79 manager->SetInputStream(0,fileNameSDigitsSig.Data());
80 manager->SetInputStream(1,fileNameSDigitsBgr.Data());
81 if (fileNameDigits != "") {
83 // AliCopyN(fileNameSDigitsSig,fileNameDigits);
85 manager->SetOutputFile(fileNameDigits);
87 manager->SetNrOfEventsToWrite(nEvents);
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();
100 resp1->GetNoiseParam(n,b);
101 n = resp1->GetNoiseAfterElectronics();
104 cPar[2]=(Int_t)(b + 2.*n + 0.5);
105 cPar[3]=(Int_t)(b + 2.*n + 0.5);
110 resp1->SetCompressParam(cPar);
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);
120 manager->Exec("deb all");
130 ////////////////////////////////////////////////////////////////////////
131 void AliCopyN(TString inputFileName, TString outputFileName) {
134 TFile *inputFile = OpenFile(inputFileName);
135 if (!inputFile) return;
137 TFile *outputFile = TFile::Open(outputFileName.Data(),"update");
138 if (!outputFile->IsOpen()) {
139 cerr<<"Can't open "<<outputFileName.Data()<<" !\n";
142 if (!ImportgAlice(inputFile)) return;
143 AliCopy(inputFile, outputFile);
151 ////////////////////////////////////////////////////////////////////////