Bug fix. Removed delete statement
[u/mrichter/AliRoot.git] / ACORDE / ACORDERaw2Digits_sim.C
CommitLineData
0a59828d 1//_____________________________________________________//
2// //
3// This macro reads ACORDE DDL Raw Data and //
4// converts it into Digits //
5// //
6//____________________________________________________ //
7
8
9void ACORDERaw2Digits(Int_t nEvents = 1, char* fileName = "rawdata.root")
10{
11 // Reads DDL data from fileName
12
13 TStopwatch timer;
14 timer.Start();
15
16// Creates a TreeD to dump Digits
17
18 AliRunLoader* rl = AliRunLoader::Open("galice.root");
19
20 AliACORDELoader* loader = (AliACORDELoader*) rl->GetLoader("ACORDELoader");
21
22 if(!loader) {
23 AliError("no ACORDE loader found");
24 return kFALSE; }
25
26 TTree* treeD = loader->TreeD();
27 if(!treeD) {
28 loader->MakeTree("D");
29 treeD = loader->TreeD(); }
30
31 AliACORDEdigit digit;
32 AliACORDEdigit* pdigit = &digit;
33 const Int_t kBufferSize = 4000;
34
35 treeD->Branch("ACORDE", "AliACORDEdigit", &pdigit, kBufferSize);
36
37 AliRawReader* rawReader = 0x0;
38// rawReader = new AliRawReaderFile(fileName); // DDL files
39 rawReader = new AliRawReaderRoot(fileName); // DDL files
40
41 AliACORDERawStream* rawStream = new AliACORDERawStream(rawReader);
42
43 for (Int_t i=0; i<nEvents; i++) {
44 printf("=========== EVENT %d ===========\n",i);
45 if (!rawReader->NextEvent())
46 break;
47
48 rawStream->Reset();
49 if (!rawStream->Next())
50 break;
51 printf("Data size is %d\n",rawStream->DataSize());
52 /*
53 for(Int_t i=0; i<64; i++) {
54 new(pdigit) AliACORDEdigit(i, (Int_t)rawStream->GetADC(i), (Int_t)rawStream->GetTime(i));
55 treeD->Fill();
56 }
57 */
58// Checks if everything is OK by printing results
59
60// for(int i=0;i<64;i++) {
61// printf("Channel %d : %d %d \n",i,rawStream->GetADC(i),rawStream->GetTime(i)); }
62// treeD->Print(); printf(" \n");
63 }
64
65 loader->WriteDigits("OVERWRITE");
66 loader->UnloadDigits();
67
68 delete rawReader;
69 delete rawStream;
70
71 timer.Stop();
72 timer.Print();
73}