]>
Commit | Line | Data |
---|---|---|
2519cca4 | 1 | #if !defined(__CINT__) || defined(__MAKECINT__) |
2 | #include "TFile.h" | |
3 | ||
4 | #include "AliRawReaderRoot.h" | |
5 | #include "AliTRDrawStream.h" | |
6 | #include "AliTRDdigitsManager.h" | |
7 | #include "AliESDTrdTrack.h" | |
8 | #endif | |
9 | ||
10 | void AliTRDreadRaw(TString filename, Int_t firstEvent = 0, Int_t nEvents = 100, | |
11 | Bool_t readDigits = kTRUE, Bool_t readAtOnce = kTRUE, Int_t debugLevel = -1) | |
ac01a9e7 | 12 | { |
2519cca4 | 13 | // this macro demonstrates the usage of the TRD rawstream |
14 | // including access to error codes, event statistics, tracklets and tracks | |
15 | ||
16 | Bool_t dump = kFALSE; // dump data from specified MCMs | |
17 | Bool_t oldReadoutOrder = kTRUE; // set correct readout order | |
18 | ||
19 | // create raw reader to retrieve data | |
20 | AliRawReader *reader = new AliRawReaderRoot(filename.Data()); | |
21 | reader->Select("TRD"); | |
22 | reader->GotoEvent(firstEvent); | |
23 | ||
24 | // create raw stream | |
25 | AliTRDrawStream *rawStream = new AliTRDrawStream(reader); | |
26 | ||
27 | // enable debug output for the rawStream | |
28 | if (debugLevel > 0) { | |
29 | AliLog::SetPrintLocation(kFALSE); | |
30 | AliLog::SetClassDebugLevel("AliTRDrawStream", debugLevel); | |
31 | } | |
32 | ||
33 | // create the digits manager if wanted | |
34 | AliTRDdigitsManager *digMgr = 0x0; | |
35 | if (readDigits) { | |
36 | digMgr = new AliTRDdigitsManager(); | |
37 | digMgr->CreateArrays(); | |
38 | rawStream->SetDigitsManager(digMgr); | |
39 | } | |
40 | ||
41 | // setup MCM readout order and enable error message in case of wrong order | |
42 | if (!oldReadoutOrder) { | |
43 | for (Int_t iMcm = 0; iMcm < 16; iMcm++) | |
44 | AliTRDrawStream::SetMCMReadoutPos(iMcm, iMcm); | |
45 | } | |
46 | AliTRDrawStream::SetErrorDebugLevel(AliTRDrawStream::kPosUnexp, 0); | |
47 | ||
48 | // if you want you can dump data from individual MCMs | |
49 | // add further MCMs as needed | |
50 | if (dump) { | |
51 | rawStream->SetDumpMCM(330, 0, 10); | |
52 | } | |
53 | ||
54 | Int_t iEvent = firstEvent; | |
55 | ||
56 | // create the array to hold the tracklets | |
57 | TClonesArray *trklArray = new TClonesArray("AliTRDtrackletWord", 500); | |
58 | ||
59 | // create the array to hold the tracks | |
60 | TClonesArray *trkArray = new TClonesArray("AliESDTrdTrack", 50); | |
61 | ||
62 | // open a file to hold output data (for testing only) | |
63 | TFile *f = TFile::Open("raw-out.root", "RECREATE"); | |
64 | TTree *trackingTree = new TTree("trackingTree", "tree with tracklets and tracks"); | |
65 | trackingTree->Branch("event", &iEvent); | |
66 | trackingTree->Branch("trkl", &trklArray); | |
67 | trackingTree->Branch("trkl", &trkArray); | |
68 | ||
69 | TTree *eventStats = new TTree("stats", "event statistics"); | |
70 | AliTRDrawStream::AliTRDrawStats *stats = rawStream->GetStats(); | |
71 | eventStats->Branch("event", &iEvent); | |
72 | eventStats->Branch("stats", &stats); | |
73 | ||
74 | // loop over events | |
75 | while (reader->NextEvent()) { | |
76 | iEvent++; | |
77 | ||
78 | // clear from previous event | |
79 | if (digMgr) { | |
80 | for (Int_t iDet = 0; iDet < 540; iDet++) | |
81 | digMgr->ClearArrays(iDet); | |
ac01a9e7 | 82 | } |
2519cca4 | 83 | stats->ClearStats(); |
ac01a9e7 | 84 | |
2519cca4 | 85 | if (readAtOnce) { |
86 | rawStream->ReadEvent(); | |
87 | } | |
88 | else { | |
89 | Int_t det; | |
90 | ||
91 | while (rawStream->NextDDL()) { | |
92 | while ((det = rawStream->NextChamber(digMgr)) > -1) | |
93 | ; | |
94 | } | |
95 | } | |
96 | ||
97 | // store the output | |
98 | trackingTree->Fill(); | |
99 | eventStats->Fill(); | |
100 | ||
101 | if (iEvent >= (firstEvent + nEvents)) | |
102 | break; | |
103 | } | |
ac01a9e7 | 104 | |
2519cca4 | 105 | // retrieve error tree and write output to file |
106 | TTree *t = rawStream->GetErrorTree(); | |
107 | f->WriteTObject(t); | |
108 | f->WriteTObject(trackingTree); | |
109 | eventStats->Write(); | |
ac01a9e7 | 110 | |
2519cca4 | 111 | f->Close(); |
ac01a9e7 | 112 | } |