1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
5 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
6 * for The ALICE HLT Project. *
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 **************************************************************************/
17 /** @file AliHLTTRDEsdWriterComponent.cxx
18 @author Mateusz Ploskon
20 @brief Writer component to store tracks of the HLT TRD
23 #include "AliHLTTRDEsdWriterComponent.h"
24 #include "AliHLTTRDDefinitions.h"
25 #include "AliHLTTRDUtils.h"
26 #include "AliHLTCTPData.h"
27 #include "AliESDEvent.h"
28 #include "AliESDfriend.h"
29 #include "AliESDtrack.h"
30 #include "AliTRDtrackV1.h"
34 /** ROOT macro for the implementation of ROOT specific class methods */
35 ClassImp(AliHLTTRDEsdWriterComponent)
37 AliHLTTRDEsdWriterComponent::AliHLTTRDEsdWriterComponent()
38 :AliHLTRootFileWriterComponent()
47 // see header file for class documentation
49 // refer to README to build package
51 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
54 AliHLTTRDEsdWriterComponent::AliHLTTRDEsdWriterComponent(const AliHLTTRDEsdWriterComponent&)
55 :AliHLTRootFileWriterComponent()
66 void AliHLTTRDEsdWriterComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
68 // Get the list of input data
69 list.clear(); // We do not have any requirements for our input data type(s).
70 list.push_back( AliHLTTRDDefinitions::fgkTracksDataType );
71 list.push_back( AliHLTTRDDefinitions::fgkHiLvlTracksDataType );
74 AliHLTTRDEsdWriterComponent::~AliHLTTRDEsdWriterComponent()
76 // see header file for class documentation
79 int AliHLTTRDEsdWriterComponent::InitWriter()
81 // see header file for class documentation
83 fFile = new TFile("AliHLTTRDESDs.root", "recreate");
84 fESD = new AliESDEvent;
85 fESD->CreateStdContent();
86 fTree = new TTree("esdTree", "Tree with HLT::TRD ESD objects");
87 fESD->WriteToTree(fTree);
88 fFrFile = new TFile("AliHLTTRDESDfriends.root", "recreate");
89 fESDfriend = new AliESDfriend();
90 fFrTree = new TTree("esdFriendTree", "Tree with HLT::TRD ESD Friend objects");
91 fFrTree->Branch("ESDfriend.","AliESDfriend", &fESDfriend);
92 fESD->AddObject(fESDfriend);
94 fTree->GetUserInfo()->Add(fESD);
95 fTracksArray = new TClonesArray("AliTRDtrackV1");
102 int AliHLTTRDEsdWriterComponent::CloseWriter()
104 // see header file for class documentation
108 fTree->Write(fTree->GetName(),TObject::kOverwrite);
112 fFrTree->Write(fFrTree->GetName(),TObject::kOverwrite);
115 delete fFile; fFile=0;
116 delete fFrFile; fFrFile=0;
118 delete fTracksArray; fTracksArray=0;
120 return AliHLTRootFileWriterComponent::CloseWriter();
123 int AliHLTTRDEsdWriterComponent::DumpEvent( const AliHLTComponentEventData& /*evtData*/,
124 const AliHLTComponentBlockData* /*blocks*/,
125 AliHLTComponentTriggerData& trigData )
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;
131 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(AliHLTTRDDefinitions::fgkTracksDataType); pBlock; pBlock=GetNextInputBlock())
133 TCAarray[0] = fTracksArray;
134 AliHLTTRDUtils::ReadTracks(TCAarray[0], pBlock->fPtr, pBlock->fSize);
139 for(const TObject *iter = GetFirstInputObject(AliHLTTRDDefinitions::fgkHiLvlTracksDataType); iter; iter = GetNextInputObject())
142 HLTError("You may not mix high level and low level!");
146 TCAarray[usedEntries] = dynamic_cast<TClonesArray*>(const_cast<TObject*>(iter));
147 if(!TCAarray[usedEntries])continue;
156 fESD->SetMagneticField(GetBz());
157 fESD->SetRunNumber(GetRunNo());
158 fESD->SetPeriodNumber(GetPeriodNumber());
159 fESD->SetOrbitNumber(GetOrbitNumber());
160 fESD->SetBunchCrossNumber(GetBunchCrossNumber());
161 fESD->SetTimeStamp(GetTimeStamp());
162 fESD->SetEventType(7);
164 const AliHLTCTPData* pCTPData=CTPData();
166 AliHLTTriggerMask_t mask=pCTPData->ActiveTriggers(trigData);
167 for (int index=0; index<gkNCTPTriggerClasses; index++) {
168 if ((mask&(AliHLTTriggerMask_t(0x1)<<index)) == 0) continue;
169 fESD->SetTriggerClass(pCTPData->Name(index), index);
172 AliHLTTriggerMask_t mask50;
173 mask50.set(); // set all bits
174 mask50 >>= 50; // shift 50 right
175 fESD->SetTriggerMask((mask&mask50).to_ulong());
176 /* next 50, to be implemented
177 pESD->SetTriggerMaskNext50((mask>>50).to_ulong());
181 for(int i=0; i<usedEntries; i++){
182 const TClonesArray* inArr = TCAarray[i];
183 for(int ii=0; ii<inArr->GetEntriesFast(); ii++){
184 AliTRDtrackV1* inV1 = (AliTRDtrackV1*)inArr->UncheckedAt(ii);
185 AliESDtrack *esdTrack = new AliESDtrack();
186 esdTrack->UpdateTrackParams(inV1, AliESDtrack::kTRDout);
187 esdTrack->SetLabel(inV1->GetLabel());
188 inV1->UpdateESDtrack(esdTrack);
189 AliTRDtrackV1 *calibTrack = new AliTRDtrackV1(*inV1);
190 calibTrack->SetOwner();
191 esdTrack->AddCalibObject(calibTrack);
192 fESD->AddTrack(esdTrack);
197 fESD->GetESDfriend(fESDfriend);
198 Int_t nb = fTree->Fill();
199 HLTInfo("Tree filled with %i bytes\n", nb);
200 nb = fFrTree->Fill();
201 HLTInfo("FrTree filled with %i bytes\n", nb);
203 fESDfriend->~AliESDfriend();
204 new (fESDfriend) AliESDfriend();
207 TCAarray[0]->Delete();