1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
5 * Primary Authors: Oystein Djuvsland *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 #include "AliHLTPHOSTreeMakerComponent.h"
19 #include "AliHLTPHOSTreeMaker.h"
20 #include "AliHLTPHOSProcessor.h"
21 #include "AliHLTPHOSDigitDataStruct.h"
23 #include "TClonesArray.h"
28 #include <sys/types.h>
31 * Tree maker component for PHOS HLT
33 * @file AliHLTPHOSTreeMakerComponent.cxx
34 * @author Oystein Djuvsland
36 * @brief A tree maker component for PHOS HLT
40 // see header file for class documentation
42 // refer to README to build package
44 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
46 const AliHLTComponentDataType AliHLTPHOSTreeMakerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
48 AliHLTPHOSTreeMakerComponent gAliHLTPHOSTreeMakerComponent;
50 AliHLTPHOSTreeMakerComponent::AliHLTPHOSTreeMakerComponent() :
51 AliHLTPHOSProcessor(),
57 //See header file for documentation
60 AliHLTPHOSTreeMakerComponent::~AliHLTPHOSTreeMakerComponent()
62 //See header file for documentation
66 AliHLTPHOSTreeMakerComponent::Deinit()
68 //See header file for documentation
69 cout << "Writing file...";
72 sprintf(filename, "%s/run%d_digitTree_%d.root", fDirectory, fRunNumber,(fPhosEventCount/fWriteInterval));
74 TFile *outfile = new TFile(filename,"recreate");
75 fDigitTreePtr->Write();
90 AliHLTPHOSTreeMakerComponent::GetComponentID()
92 //See header file for documentation
93 return "PhosTreeMaker";
97 AliHLTPHOSTreeMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
99 //See header file for documentation
100 //Get datatypes for input
101 const AliHLTComponentDataType* pType=fgkInputDataTypes;
102 while (pType->fID!=0) {
103 list.push_back(*pType);
108 AliHLTComponentDataType
109 AliHLTPHOSTreeMakerComponent::GetOutputDataType()
111 //See header file for documentation
112 return AliHLTPHOSDefinitions::fgkAliHLTRootTreeDataType;
116 AliHLTPHOSTreeMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
118 //See header file for documentation
124 AliHLTPHOSTreeMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
125 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* /*outputPtr*/, AliHLTUInt32_t& /*size*/, //TODO: I think size should be set to zero when returning from this method if not data was written to the output buffer.
126 std::vector<AliHLTComponentBlockData>& /*outputBlocks*/)
130 //See header file for documentation
133 Int_t totalDigits = 0;
135 const AliHLTComponentBlockData* iter = 0;
138 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
142 if ( iter->fDataType == AliHLTPHOSDefinitions::fgkAliHLTDigitDataType )
146 nDigits = fTreeMakerPtr->MakeDigitArray ( reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*> ( iter->fPtr ), totalDigits );
147 totalDigits += nDigits;
148 //cout << totalDigits << endl;
151 if ( iter->fDataType == AliHLTPHOSDefinitions::fgkAliHLTClusterDataType )
159 fTreeMakerPtr->FillDigitTree();
161 if( (fPhosEventCount%fWriteInterval == 0 ) && (fPhosEventCount != 0))
172 AliHLTPHOSTreeMakerComponent::DoInit ( int argc, const char** argv )
174 //See header file for documentation
175 fTreeMakerPtr = new AliHLTPHOSTreeMaker();
176 fDigitTreePtr = new TTree ( "digitTree", "Digits tree" );
177 fDirectory = new char[50];
179 for ( int i = 0; i < argc; i++ )
181 if ( !strcmp ( "-path", argv[i] ) )
183 strcpy ( fDirectory, argv[i+1] );
185 if ( !strcmp ( "-writeinterval", argv[i] ) )
187 fWriteInterval = atoi(argv[i+1]);
191 fTreeMakerPtr->SetDigitTree(fDigitTreePtr);
192 cout << endl << "Run number is: " << fRunNumber << " -- Check that this is correct!!!\n" << endl;
202 AliHLTPHOSTreeMakerComponent::Spawn()
204 //See header file for documentation
205 return new AliHLTPHOSTreeMakerComponent();
209 AliHLTPHOSTreeMakerComponent::Write()
211 //See header file for documentation
212 cout << "Writing file...";
215 sprintf(filename, "%s/run%d_digitTree_%d.root", fDirectory, fRunNumber,(fPhosEventCount/fWriteInterval - 1));
217 TFile *outfile = new TFile(filename,"recreate");
218 fDigitTreePtr->Write();
225 AliHLTPHOSTreeMakerComponent::ResetTrees()
227 //See header file for documentation
228 delete fDigitTreePtr;
229 fDigitTreePtr = new TTree("digitTree", "Digits tree");
230 fTreeMakerPtr->SetDigitTree(fDigitTreePtr);