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"
20 #include "AliHLTPHOSRcuDigitContainerDataStruct.h"
22 #include "AliHLTPHOSRcuTreeMaker.h"
23 #include "AliHLTPHOSRcuProcessor.h"
24 #include "AliHLTPHOSDigitDataStruct.h"
26 #include "TClonesArray.h"
31 #include <sys/types.h>
33 const AliHLTComponentDataType AliHLTPHOSRcuTreeMakerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
35 AliHLTPHOSRcuTreeMakerComponent gAliHLTPHOSRcuTreeMakerComponent;
37 AliHLTPHOSRcuTreeMakerComponent::AliHLTPHOSRcuTreeMakerComponent() :
38 AliHLTPHOSRcuProcessor(),
47 AliHLTPHOSRcuTreeMakerComponent::~AliHLTPHOSRcuTreeMakerComponent()
53 AliHLTPHOSRcuTreeMakerComponent::Deinit()
56 // cout << "Printing file...";
60 sprintf(filename, "%s/run%d_digitTree_rcuX_%d_rcuZ_%d_%d.root", fDirectory, fRunNb,(fEventCount/fWriteInterval));
61 TFile *outfile = new TFile(filename,"recreate");
62 fDigitTreePtr->Write();
82 AliHLTPHOSRcuTreeMakerComponent::GetComponentID()
85 return "PhosRcuTreeMaker";
89 AliHLTPHOSRcuTreeMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
92 //Get datatypes for input
93 const AliHLTComponentDataType* pType=fgkInputDataTypes;
94 while (pType->fID!=0) {
95 list.push_back(*pType);
100 AliHLTComponentDataType
101 AliHLTPHOSRcuTreeMakerComponent::GetOutputDataType()
104 return AliHLTPHOSDefinitions::fgkAliHLTRootTreeDataType;
108 AliHLTPHOSRcuTreeMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
116 AliHLTPHOSRcuTreeMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
117 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.
118 std::vector<AliHLTComponentBlockData>& /*outputBlocks*/)
122 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP0 " << endl;
127 Int_t totalDigits = 0;
129 const AliHLTComponentBlockData* iter = 0;
131 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP0.1 " << endl;
132 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
135 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP0.2 " << endl;
136 if ( iter->fDataType == AliHLTPHOSDefinitions::fgkAliHLTDigitDataType )
139 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP0.2 " << endl;
141 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP0.3 " << endl;
143 // fTreeMakerPtr = new AliHLTPHOSRcuTreeMaker();
147 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP0.3.1 " << endl;
148 cout << "ERROR" << endl;
149 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP0.3.2 " << endl;
153 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP0.3.3 " << endl;
155 // fTreeMakerPtr = new AliHLTPHOSRcuTreeMaker();
157 if(fTreeMakerPtr == 0 )
159 // cout << "FUCK" << endl;
163 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP0.3.4, -1 " << endl;
164 // nDigits = fTreeMakerPtr->MakeDigitArray ( reinterpret_cast<AliHLTPHOSRcuDigitContainerDataStruct*> ( iter->fPtr ), totalDigits );
167 nDigits = fTreeMakerPtr->MakeDigitArray ( reinterpret_cast<AliHLTPHOSRcuDigitContainerDataStruct*> ( iter->fPtr ), totalDigits );
169 // AliHLTPHOSRcuDigitContainerDataStruct *tmp = new AliHLTPHOSRcuDigitContainerDataStruct();
171 // nDigits = fTreeMakerPtr->MakeDigitArray(tmp, totalDigits );
173 // nDigits = fTreeMakerPtr->MakeDigitArray ( (AliHLTPHOSRcuDigitContainerDataStruct*) ( iter->fPtr ), totalDigits );
175 fTreeMakerPtr->FUCK();
176 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP0.3.4 " << endl;
181 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP0.4 " << endl;
182 totalDigits += nDigits;
183 //cout << totalDigits << endl;
184 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP0.5 " << endl;
188 if ( iter->fDataType == AliHLTPHOSDefinitions::fgkAliHLTClusterDataType )
190 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP0.6 " << endl;
196 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP1 " << endl;
199 fTreeMakerPtr->FillDigitTree();
200 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP2 " << endl;
201 // if(fEventCount%fWriteInterval == 0)
202 if(fPhosEventCount%fWriteInterval == 0)
204 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP3 " << endl;
206 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP4 " << endl;
208 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP5 " << endl;
210 cout << "AliHLTPHOSRcuTreeMakerComponent::DoEvent TP6 " << endl;
216 AliHLTPHOSRcuTreeMakerComponent::DoInit ( int argc, const char** argv )
219 fTreeMakerPtr = new AliHLTPHOSRcuTreeMaker();
220 fDigitTreePtr = new TTree ( "digitTree", "Digits tree" );
221 fDirectory = new char[50];
223 for ( int i = 0; i < argc; i++ )
225 if ( !strcmp ( "-path", argv[i] ) )
227 strcpy ( fDirectory, argv[i+1] );
229 if ( !strcmp ( "-writeinterval", argv[i] ) )
231 fWriteInterval = atoi(argv[i+1]);
235 fTreeMakerPtr->SetDigitTree(fDigitTreePtr);
237 // fstream runNbFile;
239 // runNbFile.open("/opt/HLT-public/rundir/runNumber.txt");
240 // runNbFile >> fRunNb;
241 // runNbFile.close();
242 /* newRunNb = fRunNb + 1;
243 runNbFile.open("/opt/HLT-public/rundir/runNumber.txt");
244 runNbFile << newRunNb;
247 cout << endl << "Run number is: " << fRunNumber << " -- Check that this is correct!!!\n" << endl;
255 AliHLTPHOSRcuTreeMakerComponent::Spawn()
258 return new AliHLTPHOSRcuTreeMakerComponent();
262 AliHLTPHOSRcuTreeMakerComponent::Write()
265 cout << "Writing file...";
268 // sprintf(filename, "%s/run%d_%d_digitTree_mod%d_rcuX%d_rcuZ%d_.root", fDirectory, fRunNb,(fEventCount/fWriteInterval - 1), fModuleID, fRcuX, fRcuZ);
269 sprintf(filename, "%s/run%d_%d_digitTree_mod%d_rcuX%d_rcuZ%d_.root", fDirectory, fRunNumber,(fPhosEventCount/fWriteInterval - 1), fModuleID, fRcuX, fRcuZ);
270 TFile *outfile = new TFile(filename,"recreate");
271 fDigitTreePtr->Write();
279 AliHLTPHOSRcuTreeMakerComponent::ResetTrees()
282 delete fDigitTreePtr;
283 fDigitTreePtr = new TTree("digitTree", "Digits tree");
284 fTreeMakerPtr->SetDigitTree(fDigitTreePtr);