2 // $Id: AliHLTGlobalCompareFlatComponent.cxx $
3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Steffen Weber *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
18 /** @file AliHLTGlobalCompareFlatComponent.cxx
20 @brief Compare flat events from different inputs
25 #include "TTimeStamp.h"
26 #include "TObjString.h"
28 #include "THnSparse.h"
29 #include "AliESDEvent.h"
30 #include "AliFlatESDEvent.h"
31 #include "AliFlatESDTrigger.h"
32 #include "AliFlatESDV0.h"
33 #include "AliFlatESDVertex.h"
34 #include "AliHLTErrorGuard.h"
35 #include "AliHLTDataTypes.h"
36 #include "AliHLTGlobalCompareFlatComponent.h"
37 #include "AliHLTITSClusterDataFormat.h"
38 #include "AliHLTTPCDefinitions.h"
40 #include "AliCDBEntry.h"
41 #include "AliCDBManager.h"
45 /** ROOT macro for the implementation of ROOT specific class methods */
46 ClassImp(AliHLTGlobalCompareFlatComponent)
48 void AliHLTGlobalCompareFlatComponent::printDiff( string name, double val1, double val2){
49 double relDiff = ( val1 != 0 || val2!=0 ) ? (val1-val2)/(fabs(val1) + fabs(val2)): 0;
51 if (relDiff > 1e-6) diff = 1;
52 else if(relDiff < -1e-6) diff = -1;
53 outFile<<name<<"\t" << val1 << "\t" << val2 <<"\t" << diff << "\n";
55 void AliHLTGlobalCompareFlatComponent::printDiff( string name, TString val1, TString val2){
56 outFile << name << "\t" << "\t\"" << val1 <<"\"\t\"" << val2 <<"\"\t" << (val1.EqualTo(val2) ?0:1)<<"\n";
60 * ---------------------------------------------------------------------------------
61 * Constructor / Destructor
62 * ---------------------------------------------------------------------------------
65 // #################################################################################
66 AliHLTGlobalCompareFlatComponent::AliHLTGlobalCompareFlatComponent() :
69 // an example component which implements the ALICE HLT processor
70 // interface and does some analysis on the input raw data
72 // see header file for class documentation
74 // refer to README to build package
76 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
78 // NOTE: all helper classes should be instantiated in DoInit()
81 // #################################################################################
82 AliHLTGlobalCompareFlatComponent::~AliHLTGlobalCompareFlatComponent() {
83 // see header file for class documentation
90 * ---------------------------------------------------------------------------------
91 * Public functions to implement AliHLTComponent's interface.
92 * These functions are required for the registration process
93 * ---------------------------------------------------------------------------------
96 // #################################################################################
97 const Char_t* AliHLTGlobalCompareFlatComponent::GetComponentID() {
98 // see header file for class documentation
99 return "GlobalCompareFlat";
102 // #################################################################################
103 void AliHLTGlobalCompareFlatComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
104 // see header file for class documentation
105 list.push_back(kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut );
108 // #################################################################################
109 AliHLTComponentDataType AliHLTGlobalCompareFlatComponent::GetOutputDataType() {
110 // see header file for class documentation
111 return kAliHLTDataTypeTObject|kAliHLTDataOriginOut;
114 // #################################################################################
115 void AliHLTGlobalCompareFlatComponent::GetOutputDataSize( ULong_t& constBase, Double_t& inputMultiplier ) {
116 // see header file for class documentation
118 inputMultiplier = 10.0;
122 // #################################################################################
123 AliHLTComponent* AliHLTGlobalCompareFlatComponent::Spawn() {
124 // see header file for class documentation
125 return new AliHLTGlobalCompareFlatComponent;
129 * ---------------------------------------------------------------------------------
130 * Protected functions to implement AliHLTComponent's interface.
131 * These functions provide initialization as well as the actual processing
132 * capabilities of the component.
133 * ---------------------------------------------------------------------------------
136 // #################################################################################
137 Int_t AliHLTGlobalCompareFlatComponent::DoInit( Int_t argc, const Char_t** argv ) {
138 // see header file for class documentation
139 printf("AliHLTGlobalCompareFlatComponent::DoInit\n");
140 // see header file for class documentation
145 Int_t bins[fDim] = {3};
146 Double_t mins[fDim] = {0};
147 Double_t maxs[fDim] = {2};
148 fhDiff = new THnSparseD("Differences","Differences",fDim,bins,mins,maxs);
153 fhDiff->GetAxis(tmp)->SetName("Overall");
154 fhDiff->GetAxis(tmp)->SetBinLabel(1,"no differences");
155 fhDiff->GetAxis(tmp)->SetBinLabel(2,"sizes differ");
156 fhDiff->GetAxis(tmp)->SetBinLabel(3,"other differences");
158 fhDiff->GetAxis(++tmp)->SetName("GetSize");
159 fhDiff->GetAxis(++tmp)->SetName("GetMagneticField");
160 fhDiff->GetAxis(++tmp)->SetName("GetPeriodNumber");
161 fhDiff->GetAxis(++tmp)->SetName("GetRunNumber");
162 fhDiff->GetAxis(++tmp)->SetName("GetOrbitNumber");
163 fhDiff->GetAxis(++tmp)->SetName("GetBunchCrossNumber");
164 fhDiff->GetAxis(++tmp)->SetName("GetTriggerMask");
165 fhDiff->GetAxis(++tmp)->SetName("GetTriggerMaskNext50");
166 fhDiff->GetAxis(++tmp)->SetName("GetFiredTriggerClasses");
167 fhDiff->GetAxis(++tmp)->SetName("GetNumberOfTracks");
168 fhDiff->GetAxis(++tmp)->SetName("GetNumberOfV0s");
169 fhDiff->GetAxis(++tmp)->SetName("GetTimeStamp");
170 fhDiff->GetAxis(++tmp)->SetName("GetEventSpecie");
182 // #################################################################################
183 Int_t AliHLTGlobalCompareFlatComponent::DoDeinit() {
184 // see header file for class documentation
185 printf("AliHLTGlobalCompareFlatComponent::DoDeInit\n");
189 TFile * f = TFile::Open("histograms.root","RECREATE");
199 // #################################################################################
200 Int_t AliHLTGlobalCompareFlatComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
201 const AliHLTComponentBlockData* /*blocks*/,
202 AliHLTComponentTriggerData& /*trigData*/,
203 AliHLTUInt8_t* /*outputPtr*/,
204 AliHLTUInt32_t& /*size*/,
205 AliHLTComponentBlockDataList& /*outputBlocks*/) {
206 // see header file for class documentation
208 printf("AliHLTGlobalCompareFlatComponent::DoEvent\n");
212 // -- Only use data event
216 AliFlatESDEvent *flatEsd[2] ;
218 printf("search for input onbjects\n");
221 for ( const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeFlatESD|kAliHLTDataOriginOut);
222 pBlock!=NULL && i<2; pBlock = GetNextInputBlock(),i++ ) {
223 flatEsd[i] = reinterpret_cast<AliFlatESDEvent*>( pBlock->fPtr );
226 cout<<"size event 1: "<<flatEsd[0]->GetSize()<<endl;
227 cout<<"size event 2: "<<flatEsd[1]->GetSize()<<endl;
230 cout<<"nTracks event 1: "<<flatEsd[0]->GetNumberOfTracks()<<endl;
231 cout<<"nTracks event 2: "<<flatEsd[1]->GetNumberOfTracks()<<endl;
233 outFile.open("comparison.txt",ios::app);
235 // Compare Event variables
237 outFile<<"\n\n------------------\nnew AliFlatESDEvent\n------------------\n";
238 printDiff( "AliFlatESDEvent::GetSize" ,flatEsd[0]->GetSize(), flatEsd[1]->GetSize() ) ;
239 printDiff( "AliFlatESDEvent::GetMagneticField",flatEsd[0]->GetMagneticField(),flatEsd[1]->GetMagneticField() );
240 printDiff( "AliFlatESDEvent::GetPeriodNumber",flatEsd[0]->GetPeriodNumber(),flatEsd[1]->GetPeriodNumber() );
241 printDiff( "AliFlatESDEvent::GetRunNumber",flatEsd[0]->GetRunNumber(), flatEsd[1]->GetRunNumber() );
242 printDiff( "AliFlatESDEvent::GetOrbitNumber",flatEsd[0]->GetOrbitNumber(),flatEsd[1]->GetOrbitNumber() );
243 printDiff( "AliFlatESDEvent::GetBunchCrossNumber",flatEsd[0]->GetBunchCrossNumber(),flatEsd[1]->GetBunchCrossNumber() );
244 printDiff( "AliFlatESDEvent::GetTriggerMask",flatEsd[0]->GetTriggerMask(),flatEsd[1]->GetTriggerMask() );
245 printDiff( "AliFlatESDEvent::GetTriggerMaskNext50",flatEsd[0]->GetTriggerMaskNext50(),flatEsd[1]->GetTriggerMaskNext50() );
246 printDiff( "AliFlatESDEvent::GetFiredTriggerClasses",flatEsd[0]->GetFiredTriggerClasses() ,flatEsd[1]->GetFiredTriggerClasses() );
247 printDiff( "AliFlatESDEvent::GetNumberOfTracks",flatEsd[0]->GetNumberOfTracks(), flatEsd[1]->GetNumberOfTracks() );
248 printDiff( "AliFlatESDEvent::GetNumberOfV0s",flatEsd[0]->GetNumberOfV0s(),flatEsd[1]->GetNumberOfV0s() );
249 printDiff( "AliFlatESDEvent::GetTimeStamp",flatEsd[0]->GetTimeStamp(),flatEsd[1]->GetTimeStamp() );
250 printDiff( "AliFlatESDEvent::GetEventSpecie",flatEsd[0]->GetEventSpecie(),flatEsd[1]->GetEventSpecie() );
251 printDiff( "AliFlatESDEvent::GetNumberOfTriggerClasses",flatEsd[0]->GetNumberOfTriggerClasses(),flatEsd[1]->GetNumberOfTriggerClasses() );
253 const AliFlatESDVertex * vertexTracks[2] = {flatEsd[0]->GetFlatPrimaryVertexTracks(), flatEsd[1]->GetFlatPrimaryVertexTracks()};
254 printDiff("AliFlatESDEvent::GetFlatPrimaryVertexTracks", (vertexTracks[0] ? 1:0), (vertexTracks[1] ? 1:0) );
256 const AliFlatESDVertex * vertexSPD[2] = {flatEsd[0]->GetFlatPrimaryVertexSPD(), flatEsd[1]->GetFlatPrimaryVertexSPD()};
257 printDiff("AliFlatESDEvent::GetFlatPrimaryVertexSPD", (vertexSPD[0] ? 1:0), (vertexSPD[1] ? 1:0) );
259 // Compare primary vertices
261 if(vertexTracks[0] && vertexTracks[1]){
262 outFile<<"\nnew AliFlatESDVertexTracks\n";
263 printDiff( "AliFlatESDVertexTracks::GetSize",vertexTracks[0]->GetSize(),vertexTracks[1]->GetSize() );
264 printDiff( "AliFlatESDVertexTracks::GetX",vertexTracks[0]->GetX(),vertexTracks[1]->GetX() );
265 printDiff( "AliFlatESDVertexTracks::GetY",vertexTracks[0]->GetY(),vertexTracks[1]->GetY() );
266 printDiff( "AliFlatESDVertexTracks::GetZ",vertexTracks[0]->GetZ(),vertexTracks[1]->GetZ() );
269 if(vertexSPD[0] && vertexSPD[1]){
270 outFile<<"\nnew AliFlatESDVertexSPD\n";
271 printDiff( "AliFlatESDVertexSPD::GetSize",vertexSPD[0]->GetSize(),vertexSPD[1]->GetSize() );
272 printDiff( "AliFlatESDVertexSPD::GetX",vertexSPD[0]->GetX(),vertexSPD[1]->GetX() );
273 printDiff( "AliFlatESDVertexSPD::GetY",vertexSPD[0]->GetY(),vertexSPD[1]->GetY() );
274 printDiff( "AliFlatESDVertexSPD::GetZ",vertexSPD[0]->GetZ(),vertexSPD[1]->GetZ() );
280 if(flatEsd[0]->GetNumberOfTriggerClasses() && flatEsd[1]->GetNumberOfTriggerClasses() ){
281 outFile<<"------------------\ntriggers\n------------------\n";
282 AliFlatESDTrigger * trigger[2] = { const_cast<AliFlatESDTrigger*>(flatEsd[0]->GetTriggerClasses() ) , const_cast<AliFlatESDTrigger*>(flatEsd[1]->GetTriggerClasses() ) };
283 for( Int_t i = 0; i < flatEsd[0]->GetNumberOfTriggerClasses() && i < flatEsd[1]->GetNumberOfTriggerClasses() ; i++ ){
284 outFile<<"\nnew AliFlatESDTrigger\n";
285 printDiff( "AliFlatESDTrigger::GetSize",trigger[0]->GetSize(),trigger[1]->GetSize() );
286 printDiff( "AliFlatESDTrigger::GetTriggerIndex",trigger[0]->GetTriggerIndex(),trigger[1]->GetTriggerIndex() );
287 printDiff( "AliFlatESDTrigger::GetTriggerClassName",trigger[0]->GetTriggerClassName(),trigger[1]->GetTriggerClassName() );
289 trigger[0] = trigger[0]->GetNextTriggerNonConst();
290 trigger[1] = trigger[1]->GetNextTriggerNonConst();
296 if(flatEsd[0]->GetNumberOfV0s() && flatEsd[1]->GetNumberOfV0s() ){
297 outFile<<"------------------\nv0s\n------------------\n";
299 AliFlatESDV0 * v0[2] = { const_cast<AliFlatESDV0*>(flatEsd[0]->GetV0s() ) , const_cast<AliFlatESDV0*>(flatEsd[1]->GetV0s() ) };
300 for( Int_t i = 0; i < flatEsd[0]->GetNumberOfV0s() && i < flatEsd[1]->GetNumberOfV0s() ; i++ ){
301 outFile<<"\nnew AliFlatESDV0\n";
302 printDiff( "AliFlatESDV0::GetSize",v0[0]->GetSize(),v0[1]->GetSize() );
303 printDiff( "AliFlatESDV0::GetNegTrackID",v0[0]->GetNegTrackID(),v0[1]->GetNegTrackID() );
304 printDiff( "AliFlatESDV0::GetPosTrackID",v0[0]->GetPosTrackID(),v0[1]->GetPosTrackID() );
306 v0[0] = v0[0]->GetNextV0NonConst();
307 v0[1] = v0[1]->GetNextV0NonConst();
313 if(flatEsd[0]->GetNumberOfTracks() && flatEsd[1]->GetNumberOfTracks() ){
314 outFile<<"------------------\ntracks\n------------------\n";
316 AliFlatESDTrack * track[2] = { const_cast<AliFlatESDTrack*>(flatEsd[0]->GetTracks() ) , const_cast<AliFlatESDTrack*>(flatEsd[1]->GetTracks() ) };
317 for( Int_t t = 0; t < flatEsd[0]->GetNumberOfTracks() && t < flatEsd[1]->GetNumberOfTracks() ; t++ ){
318 outFile<<"\nnew AliFlatESDTrack\n";
319 printDiff( "AliFlatESDTrack::GetSize",track[0]->GetSize(),track[1]->GetSize() );
320 printDiff( "AliFlatESDTrack::GetNumberOfTPCClusters",track[0]->GetNumberOfTPCClusters(),track[1]->GetNumberOfTPCClusters() );
321 printDiff( "AliFlatESDTrack::GetNumberOfITSClusters",track[0]->GetNumberOfITSClusters(),track[1]->GetNumberOfITSClusters() );
323 const char* pNames[7] = {"", "Refitted", "Ip", "TPCInner", "Op", "Cp", "ITSOUT"};
325 const AliFlatExternalTrackParam * p[7][2] = {
326 {track[0]->GetFlatTrackParam(), track[1]->GetFlatTrackParam()},
327 {track[0]->GetFlatTrackParamRefitted(), track[1]->GetFlatTrackParamRefitted()},
328 {track[0]->GetFlatTrackParamIp(), track[1]->GetFlatTrackParamIp()},
329 {track[0]->GetFlatTrackParamTPCInner(), track[1]->GetFlatTrackParamTPCInner()},
330 {track[0]->GetFlatTrackParamOp(), track[1]->GetFlatTrackParamOp()},
331 {track[0]->GetFlatTrackParamCp(), track[1]->GetFlatTrackParamCp()},
332 {track[0]->GetFlatTrackParamITSOut(), track[1]->GetFlatTrackParamITSOut()}
335 for(int i = 0 ; i<7; i++){
336 printDiff( Form("AliFlatESDTrack::GetFlatTrackParam%s",pNames[i]), (p[i][0] ? 1:0), (p[i][1] ? 1:0) );
339 for(int i = 0 ; i<7; i++){
340 if(p[i][0] && p[i][1] ){
341 outFile<<"\nnew AliFlatExternalTrackParam" << pNames[i] << "\n";
342 printDiff( Form("AliFlatExternalTrackParam%s::GetAlpha",pNames[i]),p[i][0]->GetAlpha(),p[i][1]->GetAlpha() );
343 printDiff( Form("AliFlatExternalTrackParam%s::GetX",pNames[i]),p[i][0]->GetX(),p[i][1]->GetX() );
344 printDiff( Form("AliFlatExternalTrackParam%s::GetY",pNames[i]),p[i][0]->GetY(),p[i][1]->GetY() );
345 printDiff( Form("AliFlatExternalTrackParam%s::GetZ",pNames[i]),p[i][0]->GetZ(),p[i][1]->GetZ() );
346 printDiff( Form("AliFlatExternalTrackParam%s::GetSnp",pNames[i]),p[i][0]->GetSnp(),p[i][1]->GetSnp() );
347 printDiff( Form("AliFlatExternalTrackParam%s::GetTgl",pNames[i]),p[i][0]->GetTgl(),p[i][1]->GetTgl() );
348 printDiff( Form("AliFlatExternalTrackParam%s::GetSigned1Pt",pNames[i]),p[i][0]->GetSigned1Pt(),p[i][1]->GetSigned1Pt() );
350 for(int j=0; j<15; j++){
351 printDiff( Form("AliFlatExternalTrackParam%s::GetCovEntry(%d)",pNames[i],j),p[i][0]->GetCovEntry(j),p[i][1]->GetCovEntry(j) );
360 track[0] = track[0]->GetNextTrackNonConst();
361 track[1] = track[1]->GetNextTrackNonConst();
382 // #################################################################################
383 Int_t AliHLTGlobalCompareFlatComponent::ReadPreprocessorValues(const Char_t* /*modules*/) {
384 // see header file for class documentation
385 ALIHLTERRORGUARD(5, "ReadPreProcessorValues not implemented for this component");
390 int AliHLTGlobalCompareFlatComponent::Configure(const char*/* arguments*/)
392 // see header file for class documentation
398 int AliHLTGlobalCompareFlatComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/)
400 // see header file for class documentation