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 "AliHLTPHOSRcuTreeMakerComponent.h"
19 #include "AliHLTPHOSRcuTreeMaker.h"
20 #include "AliHLTPHOSRcuProcessor.h"
21 #include "AliHLTPHOSDigitDataStruct.h"
23 #include "TClonesArray.h"
28 #include <sys/types.h>
30 const AliHLTComponentDataType AliHLTPHOSRcuTreeMakerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
32 AliHLTPHOSRcuTreeMakerComponent gAliHLTPHOSRcuTreeMakerComponent;
34 AliHLTPHOSRcuTreeMakerComponent::AliHLTPHOSRcuTreeMakerComponent() :
35 AliHLTPHOSRcuProcessor(),
43 AliHLTPHOSRcuTreeMakerComponent::~AliHLTPHOSRcuTreeMakerComponent()
49 AliHLTPHOSRcuTreeMakerComponent::Deinit()
52 // cout << "Printing file...";
56 sprintf(filename, "%s/run%d_digitTree_rcuX_%d_rcuZ_%d_%d.root", fDirectory, fRunNb,(fEventCount/fWriteInterval));
57 TFile *outfile = new TFile(filename,"recreate");
58 fDigitTreePtr->Write();
78 AliHLTPHOSRcuTreeMakerComponent::GetComponentID()
81 return "PhosRcuTreeMaker";
85 AliHLTPHOSRcuTreeMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
88 //Get datatypes for input
89 const AliHLTComponentDataType* pType=fgkInputDataTypes;
90 while (pType->fID!=0) {
91 list.push_back(*pType);
96 AliHLTComponentDataType
97 AliHLTPHOSRcuTreeMakerComponent::GetOutputDataType()
100 return AliHLTPHOSDefinitions::fgkAliHLTRootTreeDataType;
104 AliHLTPHOSRcuTreeMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
112 AliHLTPHOSRcuTreeMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
113 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.
114 std::vector<AliHLTComponentBlockData>& /*outputBlocks*/)
121 Int_t totalDigits = 0;
123 const AliHLTComponentBlockData* iter = 0;
126 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
130 if ( iter->fDataType == AliHLTPHOSDefinitions::fgkAliHLTDigitDataType )
134 nDigits = fTreeMakerPtr->MakeDigitArray ( reinterpret_cast<AliHLTPHOSRcuDigitContainerDataStruct*> ( iter->fPtr ), totalDigits );
135 totalDigits += nDigits;
136 //cout << totalDigits << endl;
139 if ( iter->fDataType == AliHLTPHOSDefinitions::fgkAliHLTClusterDataType )
145 fTreeMakerPtr->FillDigitTree();
147 if(fEventCount%fWriteInterval == 0)
158 AliHLTPHOSRcuTreeMakerComponent::DoInit ( int argc, const char** argv )
161 fTreeMakerPtr = new AliHLTPHOSRcuTreeMaker();
162 fDigitTreePtr = new TTree ( "digitTree", "Digits tree" );
163 fDirectory = new char[50];
165 for ( int i = 0; i < argc; i++ )
167 if ( !strcmp ( "-path", argv[i] ) )
169 strcpy ( fDirectory, argv[i+1] );
171 if ( !strcmp ( "-writeinterval", argv[i] ) )
173 fWriteInterval = atoi(argv[i+1]);
177 fTreeMakerPtr->SetDigitTree(fDigitTreePtr);
181 runNbFile.open("/opt/HLT-public/rundir/runNumber.txt");
184 /* newRunNb = fRunNb + 1;
185 runNbFile.open("/opt/HLT-public/rundir/runNumber.txt");
186 runNbFile << newRunNb;
189 cout << endl << "Run number is: " << fRunNb << " -- Check that this is correct!!!\n";
197 AliHLTPHOSRcuTreeMakerComponent::Spawn()
200 return new AliHLTPHOSRcuTreeMakerComponent();
204 AliHLTPHOSRcuTreeMakerComponent::Write()
207 cout << "Writing file...";
210 sprintf(filename, "%s/run%d_%d_digitTree_mod%d_rcuX%d_rcuZ%d_.root", fDirectory, fRunNb,(fEventCount/fWriteInterval - 1), fModuleID, fRcuX, fRcuZ);
211 TFile *outfile = new TFile(filename,"recreate");
212 fDigitTreePtr->Write();
220 AliHLTPHOSRcuTreeMakerComponent::ResetTrees()
223 delete fDigitTreePtr;
224 fDigitTreePtr = new TTree("digitTree", "Digits tree");
225 fTreeMakerPtr->SetDigitTree(fDigitTreePtr);