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>
30 const AliHLTComponentDataType AliHLTPHOSTreeMakerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
32 AliHLTPHOSTreeMakerComponent gAliHLTPHOSTreeMakerComponent;
34 AliHLTPHOSTreeMakerComponent::AliHLTPHOSTreeMakerComponent() :
35 AliHLTPHOSProcessor(),
43 AliHLTPHOSTreeMakerComponent::~AliHLTPHOSTreeMakerComponent()
49 AliHLTPHOSTreeMakerComponent::Deinit()
52 cout << "Printing file...";
54 sprintf(filename, "%s/run%d_digitTree_%d.root", fDirectory, fRunNb,(fEventCount/fWriteInterval));
55 TFile *outfile = new TFile(filename,"recreate");
56 fDigitTreePtr->Write();
71 AliHLTPHOSTreeMakerComponent::GetComponentID()
74 return "PhosTreeMaker";
78 AliHLTPHOSTreeMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
81 //Get datatypes for input
82 const AliHLTComponentDataType* pType=fgkInputDataTypes;
83 while (pType->fID!=0) {
84 list.push_back(*pType);
89 AliHLTComponentDataType
90 AliHLTPHOSTreeMakerComponent::GetOutputDataType()
93 return AliHLTPHOSDefinitions::fgkAliHLTRootTreeDataType;
97 AliHLTPHOSTreeMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
105 AliHLTPHOSTreeMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
106 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
107 std::vector<AliHLTComponentBlockData>& outputBlocks)
114 Int_t totalDigits = 0;
116 const AliHLTComponentBlockData* iter = 0;
119 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
123 if ( iter->fDataType == AliHLTPHOSDefinitions::fgkAliHLTDigitDataType )
127 nDigits = fTreeMakerPtr->MakeDigitArray ( reinterpret_cast<AliHLTPHOSDigitContainerDataStruct*> ( iter->fPtr ), totalDigits );
128 totalDigits += nDigits;
129 //cout << totalDigits << endl;
132 if ( iter->fDataType == AliHLTPHOSDefinitions::fgkAliHLTClusterDataType )
138 fTreeMakerPtr->FillDigitTree();
140 if(fEventCount%fWriteInterval == 0)
151 AliHLTPHOSTreeMakerComponent::DoInit ( int argc, const char** argv )
154 fTreeMakerPtr = new AliHLTPHOSTreeMaker();
155 fDigitTreePtr = new TTree ( "digitTree", "Digits tree" );
156 fDirectory = new char[50];
158 for ( int i = 0; i < argc; i++ )
160 if ( !strcmp ( "-path", argv[i] ) )
162 strcpy ( fDirectory, argv[i+1] );
164 if ( !strcmp ( "-writeinterval", argv[i] ) )
166 fWriteInterval = atoi(argv[i+1]);
170 fTreeMakerPtr->SetDigitTree(fDigitTreePtr);
174 runNbFile.open("/opt/HLT-public/rundir/runNumber.txt");
177 /* newRunNb = fRunNb + 1;
178 runNbFile.open("/opt/HLT-public/rundir/runNumber.txt");
179 runNbFile << newRunNb;
182 cout << endl << "Run number is: " << fRunNb << " -- Check that this is correct!!!\n";
190 AliHLTPHOSTreeMakerComponent::Spawn()
193 return new AliHLTPHOSTreeMakerComponent();
197 AliHLTPHOSTreeMakerComponent::Write()
200 cout << "Writing file...";
202 sprintf(filename, "%s/run%d_digitTree_%d.root", fDirectory, fRunNb,(fEventCount/fWriteInterval - 1));
203 TFile *outfile = new TFile(filename,"recreate");
204 fDigitTreePtr->Write();
211 AliHLTPHOSTreeMakerComponent::ResetTrees()
214 delete fDigitTreePtr;
215 fDigitTreePtr = new TTree("digitTree", "Digits tree");
216 fTreeMakerPtr->SetDigitTree(fDigitTreePtr);