2 /**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * Authors: Oystein Djuvsland <oysteind@ift.uib.no> *
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 **************************************************************************/
19 #include "AliHLTPHOSESDCaloClusterWriterComponent.h"
20 #include "AliESDCaloCluster.h"
22 #include "TClonesArray.h"
25 /** @file AliHLTPHOSESDCaloClusterWriterComponent.cxx
26 @author Oystein Djuvsland
28 @brief An ESD calo cluster writer component for PHOS HLT
31 // see header file for class documentation
33 // refer to README to build package
35 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
41 AliHLTPHOSESDCaloClusterWriterComponent gAliHLTPHOSESDCaloClusterWriterComponent;
43 AliHLTPHOSESDCaloClusterWriterComponent::AliHLTPHOSESDCaloClusterWriterComponent():
44 AliHLTPHOSProcessor(),
48 fESDCaloClusterTreePtr(0),
49 fESDCaloClustersPtr(0)
51 //See headerfile for documentation
54 AliHLTPHOSESDCaloClusterWriterComponent::~AliHLTPHOSESDCaloClusterWriterComponent()
56 //See headerfile for documentation
58 if(fESDCaloClustersPtr)
60 fESDCaloClustersPtr->Write();
61 delete fESDCaloClustersPtr;
62 fESDCaloClustersPtr = 0;
74 AliHLTPHOSESDCaloClusterWriterComponent::Deinit()
76 //See headerfile for documentation
78 if(fESDCaloClustersPtr)
80 fESDCaloClustersPtr->Write();
81 delete fESDCaloClustersPtr;
82 fESDCaloClustersPtr = 0;
94 AliHLTPHOSESDCaloClusterWriterComponent::GetComponentID()
96 //See headerfile for documentation
98 return "PhosEsdCaloClusterWriter";
102 AliHLTPHOSESDCaloClusterWriterComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
104 //See headerfile for documentation
106 list.push_back(AliHLTPHOSDefinitions::fgkESDCaloClusterDataType);
110 AliHLTComponentDataType
111 AliHLTPHOSESDCaloClusterWriterComponent::GetOutputDataType()
113 //See headerfile for documentation
114 return kAliHLTAnyDataType;
118 AliHLTPHOSESDCaloClusterWriterComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
121 //See headerfile for documentation
128 AliHLTPHOSESDCaloClusterWriterComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ )
130 // see header file for class documentation
132 const TObject* iter = 0;
133 // const AliHLTComponentBlockData* iter = 0;
135 //UInt_t specification = 0;
136 // iter = GetFirstInputObject(AliHLTPHOSDefinitions::fgkESDCaloClusterDataType);
137 //cout << iter << endl;
138 for(iter = GetFirstInputObject(AliHLTPHOSDefinitions::fgkESDCaloClusterDataType); iter != NULL; iter = GetNextInputObject())
142 //fESDCaloClustersPtr->AddAll(reinterpret_cast<const TClonesArray*>(iter));
143 fESDCaloClustersPtr = reinterpret_cast<TClonesArray*>(const_cast<TObject*>(iter)->Clone());
149 // iter = GetFirstInputBlock(AliHLTPHOSDefinitions::fgkESDCaloClusterDataType);
153 // specification = specification|iter->fSpecification;
154 // cout << (reinterpret_cast<TClonesArray*>(iter->fPtr))->GetEntries() << endl;
155 // // fESDCaloClustersPtr->AddAll(reinterpret_cast<TClonesArray*>(iter->fPtr));
156 // while((iter = GetNextInputBlock()))
158 // // fESDCaloClustersPtr->AddAll(reinterpret_cast<TClonesArray*>(iter->fPtr));
162 // HLTError("Number of clusters: %d", fESDCaloClustersPtr->GetEntries());
163 fESDCaloClusterTreePtr->Fill();
167 if(fPhosEventCount % fWriteModulo == 0)
172 //fESDCaloClustersPtr->Delete();
178 AliHLTPHOSESDCaloClusterWriterComponent::WriteTree()
181 // See headerfile for documentation
182 char tmpFilename[128];
183 sprintf(tmpFilename, "%s_%d.root", fOutfileName, fPhosEventCount/fWriteModulo);
185 fOutfile = TFile::Open(tmpFilename, "RECREATE");
188 HLTError("Could not open file %s for writing", tmpFilename);
191 fESDCaloClusterTreePtr->Write();
193 fESDCaloClusterTreePtr->Reset();
198 AliHLTPHOSESDCaloClusterWriterComponent::DoInit(int argc, const char** argv )
200 //See headerfile for documentation
201 fOutfileName = new char[128];
202 char tmpFilename[128];
203 ScanArgumentsModule(argc, argv);
204 for (int i = 0; i < argc; i++)
206 if(!strcmp("-filename", argv[i]))
208 sprintf(fOutfileName, "/tmp/%s", argv[i+1]);
209 sprintf(tmpFilename, "%s_0.root", fOutfileName);
211 if(!strcmp("-writemodulo", argv[i]))
213 fWriteModulo = atoi(argv[i+1]);
216 // fESDCaloClustersPtr = new TClonesArray(AliESDCaloCluster::Class(), 0);
217 fESDCaloClusterTreePtr = new TTree("caloClusterTree", "Tree containing AliESDCaloClusters reconstructed in HLT");
218 fESDCaloClusterTreePtr->Branch("CaloClusters", &fESDCaloClustersPtr);
220 //fESDCaloClusterTreePtr->SetBranchAddress("CaloClusters", &fESDCaloClustersPtr);
226 AliHLTPHOSESDCaloClusterWriterComponent::Spawn()
228 //See headerfile for documentation
230 return new AliHLTPHOSESDCaloClusterWriterComponent();