3 /**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * Authors: Oystein Djuvsland <oysteind@ift.uib.no> *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
19 #include "AliHLTPHOSMonitorTriggerComponent.h"
20 #include "AliHLTCaloClusterDataStruct.h"
21 #include "AliHLTDataTypes.h"
23 /** @file AliHLTPHOSMonitorTriggerComponent.h
24 @author Oystein Djuvsland
29 // see header file for class documentation
31 // refer to README to build package
33 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
39 const AliHLTComponentDataType AliHLTPHOSMonitorTriggerComponent::fgkInputDataTypes[]=
41 kAliHLTVoidDataType,{0,"",""}
44 AliHLTPHOSMonitorTriggerComponent gAliHLTPHOSMonitorTriggerComponent;
47 AliHLTPHOSMonitorTriggerComponent::AliHLTPHOSMonitorTriggerComponent():
48 AliHLTPHOSProcessor(),
49 fCheckClusterEnergy(false),
50 fCheckClusterMultiplicities(false),
51 fClusterEnergyThreshold(1),
52 fMultiplicityThreshold(5),
53 fMultEnergyThreshold(0.5),
54 fDigitMultiplicityThreshold(16),
55 fMultDigitMultiplicityThreshold(9),
56 fLowerCentrality(0.5),
59 //See headerfile for documentation
62 AliHLTPHOSMonitorTriggerComponent::~AliHLTPHOSMonitorTriggerComponent()
64 //See headerfile for documentation
71 AliHLTPHOSMonitorTriggerComponent::Deinit()
73 //See headerfile for documentation
80 AliHLTPHOSMonitorTriggerComponent::GetComponentID()
82 //See headerfile for documentation
84 return "PhosMonitorTrigger";
88 AliHLTPHOSMonitorTriggerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
91 list.push_back(AliHLTPHOSDefinitions::fgkClusterDataType);
94 AliHLTComponentDataType
95 AliHLTPHOSMonitorTriggerComponent::GetOutputDataType()
97 //See headerfile for documentation
98 return AliHLTPHOSDefinitions::fgkSandboxDataType;
102 AliHLTPHOSMonitorTriggerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
105 //See headerfile for documentation
106 constBase = sizeof(int);
111 AliHLTPHOSMonitorTriggerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
112 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* /*outputPtr*/, AliHLTUInt32_t& /*size*/,
113 std::vector<AliHLTComponentBlockData>& /*outputBlocks*/)
115 //See headerfile for documentation
117 Int_t specification = 0;
118 Bool_t monitorflag = 0;
121 const AliHLTComponentBlockData* iter = NULL;
123 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
126 if ( iter->fDataType != AliHLTPHOSDefinitions::fgkDDLPackedRawDataType )
128 HLTDebug("Data block is not of type fgkDDLPackedRawDataType");
131 specification |= iter->fSpecification;
133 monitorflag += CheckClusters(reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(iter->fPtr));
137 if(monitorflag == true)
139 Int_t blockCount = 1;
140 int ret = ReserveEventDoneData( 1+2+blockCount*4 );
143 AliHLTUInt32_t eddWord;
145 eddWord = 5; // kAliHLTEventDoneFlagMonitorEventCmd
146 PushEventDoneData( eddWord );
147 eddWord = 4; // kAliHLTEventDoneMonitorListCmd
148 PushEventDoneData( eddWord );
149 eddWord = blockCount;
150 PushEventDoneData( eddWord );
152 //Int_t blockIndex = 0;
156 for ( unsigned ii=0; ii<4; ii++ )
158 eddWord |= ((AliHLTUInt32_t)(AliHLTPHOSDefinitions::fgkDDLPackedRawDataType.fID[8-1-ii])) << (ii*8);
160 PushEventDoneData( eddWord );
164 for ( unsigned ii=0; ii<4; ii++ )
166 eddWord |= ((AliHLTUInt32_t)(AliHLTPHOSDefinitions::fgkDDLPackedRawDataType.fID[8-5-ii])) << (ii*8);
168 PushEventDoneData( eddWord );
172 for ( unsigned ii=0; ii<4; ii++ )
174 eddWord |= ((AliHLTUInt32_t)(AliHLTPHOSDefinitions::fgkDDLPackedRawDataType.fOrigin[4-1-ii])) << (ii*8);
176 PushEventDoneData( eddWord );
178 eddWord = specification;
179 PushEventDoneData( eddWord );
183 HLTWarning("Could not get Event Done Data blocks");
191 AliHLTPHOSMonitorTriggerComponent::CheckClusters(AliHLTCaloClusterHeaderStruct* clusterHeaderPtr)
193 //See headerfile for documentation
195 UInt_t nClusters = clusterHeaderPtr->fNClusters;
196 // Float_t* ampFracPtr = 0;
198 AliHLTCaloClusterDataStruct* clusterPtr = 0;
200 clusterPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>(clusterHeaderPtr + sizeof(AliHLTCaloClusterHeaderStruct));
202 for(UInt_t n = 0; n < nClusters; n++)
204 if(fCheckClusterEnergy == true && clusterPtr->fEnergy > fClusterEnergyThreshold && clusterPtr->fNCells > fDigitMultiplicityThreshold)
206 /* ampFracPtr = &(clusterPtr->fCellsAmpFraction);
207 for(UInt_t i = 0; i < clusterPtr->fNCells; i++)
209 if(*ampFracPtr > fLowerCentrality && *ampFracPtr < fUpperCentrality) return true;
210 ampFracPtr += 6; // 6 = sizeof(Short_t) + sizeof(Float_t)
213 if(fCheckClusterMultiplicities == true && clusterPtr->fEnergy > fMultEnergyThreshold && clusterPtr->fNCells > fMultDigitMultiplicityThreshold)
216 if(nClusters > fMultiplicityThreshold)
221 clusterPtr += sizeof(AliHLTCaloClusterDataStruct) + 5*clusterPtr->fNCells; //5 = sizeof(Short_t) + sizeof(Float_t) - 1(pair already included)
230 AliHLTPHOSMonitorTriggerComponent::DoInit(int argc, const char** argv )
232 //See headerfile for documentation
234 for (int i = 0; i < argc; i++)
236 if(!strcmp("-checkenergy", argv[i]))
238 fCheckClusterEnergy = true;
240 if(!strcmp("-checkmultiplicity", argv[i]))
242 fCheckClusterMultiplicities = true;
244 if(!strcmp("-energythreshold", argv[i]))
246 fClusterEnergyThreshold = atof(argv[i+1]);
247 fCheckClusterEnergy = true;
249 if(!strcmp("-multiplicityinclusterE", argv[i]))
251 fDigitMultiplicityThreshold = atoi(argv[i+1]);
253 if(!strcmp("-multiplicitythreshold", argv[i]))
255 fMultiplicityThreshold = atoi(argv[i+1]);
256 fCheckClusterMultiplicities = true;
258 if(!strcmp("-multiplicityinclusterMult", argv[i]))
260 fMultDigitMultiplicityThreshold = atoi(argv[i+1]);
262 if(!strcmp("-centralitylimits", argv[i]))
264 fLowerCentrality = atof(argv[i+1]);
265 fUpperCentrality = atof(argv[i+2]);
272 AliHLTPHOSMonitorTriggerComponent::Spawn()
274 //See headerfile for documentation
276 return new AliHLTPHOSMonitorTriggerComponent();