]>
Commit | Line | Data |
---|---|---|
808618f5 | 1 | /************************************************************************** |
2 | * This file is property of and copyright by the ALICE HLT Project * | |
3 | * ALICE Experiment at CERN, All rights reserved. * | |
4 | * * | |
5 | * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * | |
6 | * for The ALICE HLT Project. * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
17 | /** @file AliHLTTRDEsdWriterComponent.cxx | |
18 | @author Mateusz Ploskon | |
19 | @date | |
20 | @brief Writer component to store tracks of the HLT TRD | |
21 | ||
22 | */ | |
23 | #include "AliHLTTRDEsdWriterComponent.h" | |
d135ae21 | 24 | #include "AliHLTTRDDefinitions.h" |
25 | #include "AliHLTTRDUtils.h" | |
26 | #include "AliHLTCTPData.h" | |
808618f5 | 27 | #include "AliESDEvent.h" |
d135ae21 | 28 | #include "AliESDfriend.h" |
808618f5 | 29 | #include "AliESDtrack.h" |
d135ae21 | 30 | #include "AliTRDtrackV1.h" |
808618f5 | 31 | #include "TTree.h" |
d135ae21 | 32 | #include "TFile.h" |
808618f5 | 33 | |
34 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
35 | ClassImp(AliHLTTRDEsdWriterComponent) | |
36 | ||
37 | AliHLTTRDEsdWriterComponent::AliHLTTRDEsdWriterComponent() | |
d135ae21 | 38 | :AliHLTRootFileWriterComponent() |
39 | ,fTree(NULL) | |
f9778343 | 40 | ,fFrTree(NULL) |
d135ae21 | 41 | ,fESD(NULL) |
42 | ,fESDfriend(NULL) | |
43 | ,fFile(NULL) | |
f9778343 | 44 | ,fFrFile(NULL) |
d135ae21 | 45 | ,fTracksArray(NULL) |
808618f5 | 46 | { |
47 | // see header file for class documentation | |
48 | // or | |
49 | // refer to README to build package | |
50 | // or | |
51 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
52 | } | |
53 | ||
54 | AliHLTTRDEsdWriterComponent::AliHLTTRDEsdWriterComponent(const AliHLTTRDEsdWriterComponent&) | |
d135ae21 | 55 | :AliHLTRootFileWriterComponent() |
56 | ,fTree(NULL) | |
f9778343 | 57 | ,fFrTree(NULL) |
d135ae21 | 58 | ,fESD(NULL) |
59 | ,fESDfriend(NULL) | |
60 | ,fFile(NULL) | |
6840d0ab | 61 | ,fFrFile(NULL) |
d135ae21 | 62 | ,fTracksArray(NULL) |
808618f5 | 63 | { |
808618f5 | 64 | } |
65 | ||
66 | void AliHLTTRDEsdWriterComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list) | |
67 | { | |
68 | // Get the list of input data | |
69 | list.clear(); // We do not have any requirements for our input data type(s). | |
07f31c0e | 70 | list.push_back( AliHLTTRDDefinitions::fgkTracksDataType ); |
d135ae21 | 71 | list.push_back( AliHLTTRDDefinitions::fgkHiLvlTracksDataType ); |
808618f5 | 72 | } |
73 | ||
74 | AliHLTTRDEsdWriterComponent::~AliHLTTRDEsdWriterComponent() | |
75 | { | |
76 | // see header file for class documentation | |
77 | } | |
78 | ||
79 | int AliHLTTRDEsdWriterComponent::InitWriter() | |
80 | { | |
81 | // see header file for class documentation | |
d135ae21 | 82 | |
83 | fFile = new TFile("AliHLTTRDESDs.root", "recreate"); | |
808618f5 | 84 | fESD = new AliESDEvent; |
d135ae21 | 85 | fESD->CreateStdContent(); |
f9778343 | 86 | fTree = new TTree("esdTree", "Tree with HLT::TRD ESD objects"); |
d135ae21 | 87 | fESD->WriteToTree(fTree); |
f9778343 | 88 | fFrFile = new TFile("AliHLTTRDESDfriends.root", "recreate"); |
d135ae21 | 89 | fESDfriend = new AliESDfriend(); |
f9778343 | 90 | fFrTree = new TTree("esdFriendTree", "Tree with HLT::TRD ESD Friend objects"); |
91 | fFrTree->Branch("ESDfriend.","AliESDfriend", &fESDfriend); | |
d135ae21 | 92 | fESD->AddObject(fESDfriend); |
f9778343 | 93 | fFile->cd(); |
d135ae21 | 94 | fTree->GetUserInfo()->Add(fESD); |
95 | fTracksArray = new TClonesArray("AliTRDtrackV1"); | |
96 | ||
97 | SetupCTPData(); | |
98 | ||
99 | return 0; | |
808618f5 | 100 | } |
101 | ||
102 | int AliHLTTRDEsdWriterComponent::CloseWriter() | |
103 | { | |
104 | // see header file for class documentation | |
d135ae21 | 105 | |
106 | //fTree->Print(); | |
f9778343 | 107 | fFile->cd(); |
108 | fTree->Write(fTree->GetName(),TObject::kOverwrite); | |
d135ae21 | 109 | fFile->Write(); |
110 | fFile->Close(); | |
f9778343 | 111 | fFrFile->cd(); |
112 | fFrTree->Write(fFrTree->GetName(),TObject::kOverwrite); | |
113 | fFrFile->Write(); | |
114 | fFrFile->Close(); | |
d135ae21 | 115 | delete fFile; fFile=0; |
f9778343 | 116 | delete fFrFile; fFrFile=0; |
d135ae21 | 117 | //delete fTree; |
118 | delete fTracksArray; fTracksArray=0; | |
119 | ||
120 | return AliHLTRootFileWriterComponent::CloseWriter(); | |
808618f5 | 121 | } |
122 | ||
d135ae21 | 123 | int AliHLTTRDEsdWriterComponent::DumpEvent( const AliHLTComponentEventData& /*evtData*/, |
124 | const AliHLTComponentBlockData* /*blocks*/, | |
125 | AliHLTComponentTriggerData& trigData ) | |
808618f5 | 126 | { |
d135ae21 | 127 | TClonesArray* TCAarray[18] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; |
128 | Int_t usedEntries = 0; | |
129 | Int_t blockOrObject = 0; | |
808618f5 | 130 | |
d135ae21 | 131 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(AliHLTTRDDefinitions::fgkTracksDataType); pBlock; pBlock=GetNextInputBlock()) |
808618f5 | 132 | { |
d135ae21 | 133 | TCAarray[0] = fTracksArray; |
134 | AliHLTTRDUtils::ReadTracks(TCAarray[0], pBlock->fPtr, pBlock->fSize); | |
135 | usedEntries = 1; | |
136 | blockOrObject = -1; | |
808618f5 | 137 | } |
808618f5 | 138 | |
d135ae21 | 139 | for(const TObject *iter = GetFirstInputObject(AliHLTTRDDefinitions::fgkHiLvlTracksDataType); iter; iter = GetNextInputObject()) |
808618f5 | 140 | { |
d135ae21 | 141 | if(blockOrObject<0){ |
142 | HLTError("You may not mix high level and low level!"); | |
143 | return -1; | |
144 | } | |
145 | ||
146 | TCAarray[usedEntries] = dynamic_cast<TClonesArray*>(const_cast<TObject*>(iter)); | |
147 | if(!TCAarray[usedEntries])continue; | |
148 | usedEntries++; | |
149 | blockOrObject = 1; | |
808618f5 | 150 | } |
151 | ||
d135ae21 | 152 | if(!blockOrObject) |
153 | return 0; | |
154 | ||
155 | fESD->Reset(); | |
156 | fESD->SetMagneticField(GetBz()); | |
157 | fESD->SetRunNumber(GetRunNo()); | |
158 | fESD->SetPeriodNumber(GetPeriodNumber()); | |
159 | fESD->SetOrbitNumber(GetOrbitNumber()); | |
160 | fESD->SetBunchCrossNumber(GetBunchCrossNumber()); | |
161 | fESD->SetTimeStamp(GetTimeStamp()); | |
d9f9c395 | 162 | fESD->SetEventType(7); |
d135ae21 | 163 | |
164 | const AliHLTCTPData* pCTPData=CTPData(); | |
165 | if (pCTPData) { | |
166 | AliHLTUInt64_t mask=pCTPData->ActiveTriggers(trigData); | |
167 | for (int index=0; index<gkNCTPTriggerClasses; index++) { | |
168 | if ((mask&((AliHLTUInt64_t)0x1<<index)) == 0) continue; | |
169 | fESD->SetTriggerClass(pCTPData->Name(index), index); | |
808618f5 | 170 | } |
d135ae21 | 171 | fESD->SetTriggerMask(mask); |
172 | } | |
173 | ||
174 | for(int i=0; i<usedEntries; i++){ | |
175 | const TClonesArray* inArr = TCAarray[i]; | |
176 | for(int ii=0; ii<inArr->GetEntriesFast(); ii++){ | |
177 | AliTRDtrackV1* inV1 = (AliTRDtrackV1*)inArr->UncheckedAt(ii); | |
178 | AliESDtrack *esdTrack = new AliESDtrack(); | |
179 | esdTrack->UpdateTrackParams(inV1, AliESDtrack::kTRDout); | |
180 | esdTrack->SetLabel(inV1->GetLabel()); | |
181 | inV1->UpdateESDtrack(esdTrack); | |
182 | AliTRDtrackV1 *calibTrack = new AliTRDtrackV1(*inV1); | |
183 | calibTrack->SetOwner(); | |
184 | esdTrack->AddCalibObject(calibTrack); | |
185 | fESD->AddTrack(esdTrack); | |
186 | delete esdTrack; | |
dc2e6604 | 187 | } |
d135ae21 | 188 | } |
189 | ||
190 | fESD->GetESDfriend(fESDfriend); | |
f9778343 | 191 | Int_t nb = fTree->Fill(); |
192 | HLTInfo("Tree filled with %i bytes\n", nb); | |
193 | nb = fFrTree->Fill(); | |
194 | HLTInfo("FrTree filled with %i bytes\n", nb); | |
d135ae21 | 195 | fESD->Reset(); |
196 | fESDfriend->~AliESDfriend(); | |
197 | new (fESDfriend) AliESDfriend(); | |
198 | ||
199 | if(blockOrObject<0){ | |
200 | TCAarray[0]->Delete(); | |
201 | } | |
dc2e6604 | 202 | |
203 | return 0; | |
204 | } |