<commit_before>// $Id$

 /**************************************************************************
 * This file is property of and copyright by the ALICE HLT Project        *
 * All rights reserved.                                                   *
 *                                                                        *
 * Primary Authors: <NAME>                                     *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/

#include "AliHLTPHOSHistogramProducerComponent.h"
#include "AliHLTPHOSProcessor.h"
#include "TH1D.h"
#include "TNtuple.h"
#include "TFile.h"
#include "AliHLTPHOSHistogramProducer.h"
#include "AliHLTPHOSPhysicsHistogramProducer.h"
#include "AliHLTPHOSCaloClusterContainerStruct.h"
#include "TClonesArray.h"
/** 
 * @file   AliHLTPHOSHistogramProducerComponent.cxx
 * @author <NAME>
 * @date   
 * @brief  A histogram producer component for PHOS HLT
*/

// see below for class documentation
// or
// refer to README to build package
// or
// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt


AliHLTPHOSHistogramProducerComponent gAliHLTPHOSHistogramProducerComponent;

AliHLTPHOSHistogramProducerComponent::AliHLTPHOSHistogramProducerComponent() :
  AliHLTPHOSProcessor(),
  fPhysicsHistogramProducerPtr(0),
  fPushModulo(1)
{
  //see header file for documentation
}

AliHLTPHOSHistogramProducerComponent::~AliHLTPHOSHistogramProducerComponent()
{
  //see header file for documentation
}

int 
AliHLTPHOSHistogramProducerComponent::Deinit()
{ 
  //see header file for documentation
  if(fPhysicsHistogramProducerPtr != 0)
    {
      delete fPhysicsHistogramProducerPtr;
      fPhysicsHistogramProducerPtr = 0;
    }

  return 0;
}

const char*
AliHLTPHOSHistogramProducerComponent::GetComponentID()
{
  //see header file for documentation
  return "PhosHistoProducer";
}


void
AliHLTPHOSHistogramProducerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
{ 
  //see header file for documentation
  list.clear();
  list.push_back(AliHLTPHOSDefinitions::fgkESDCaloClusterDataType);
  list.push_back(AliHLTPHOSDefinitions::fgkESDCaloCellsDataType);

}

AliHLTComponentDataType 
AliHLTPHOSHistogramProducerComponent::GetOutputDataType()
{
  //see header file for documentation
  return AliHLTPHOSDefinitions::fgkPhosHistDataType;
}


void 
AliHLTPHOSHistogramProducerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
{
  //see header file for documentation
  constBase = 30;
  inputMultiplier = 5;
}

// int 
// AliHLTPHOSHistogramProducerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
// 					AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
// 					std::vector<AliHLTComponentBlockData>& outputBlocks)

int 
AliHLTPHOSHistogramProducerComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
					      AliHLTComponentTriggerData& /*trigData*/)


{
  //see header file for documentation

  const AliHLTComponentBlockData* block = GetFirstInputBlock(AliHLTPHOSDefinitions::fgkESDCaloClusterDataType);
  
  if(block != 0)
    {
      HLTError("Number of clusters: %d", reinterpret_cast<TClonesArray*>(const_cast<AliHLTComponentBlockData*>(block))->GetEntries());
      fPhysicsHistogramProducerPtr->AnalyseClusters(reinterpret_cast<TClonesArray*>(const_cast<AliHLTComponentBlockData*>(block)));
    }
  
  //  block = GetFirstInputBlock(AliHLTPHOSDefinitions::fgkESDCaloCellsDataType);
			     

  if(block != 0)
    {
      
    }
  //  if(fEventCount%fPushModulo == 0)
  //  {

  HLTError("WRITING HISTOGRAMS!");
  TFile* file = TFile::Open("/tmp/hist.root", "RECREATE");
  (fPhysicsHistogramProducerPtr->GetHistograms())->Write();
  file->Close();
  PushBack(fPhysicsHistogramProducerPtr->GetHistograms(), AliHLTPHOSDefinitions::fgkPhysicsHistogramsDataType);
      // }
    
  return 0;
}


int
AliHLTPHOSHistogramProducerComponent::DoInit(int argc, const char** argv )
{
  //see header file for documentation

  fPhysicsHistogramProducerPtr = new AliHLTPHOSPhysicsHistogramProducer();
  
  for(int i = 0; i < argc; i++)
    {
      if(!strcmp("-pushmodulo", argv[i]))
	{
	
	  fPushModulo = atoi(argv[i+1]);
	}
    }

  return 0;
}

AliHLTComponent*
AliHLTPHOSHistogramProducerComponent::Spawn()
{
  //see header file for documentation
  return new AliHLTPHOSHistogramProducerComponent();
}

<commit_msg>- adding the new histogram producer classes to the component<commit_after>// $Id$

 /**************************************************************************
 * This file is property of and copyright by the ALICE HLT Project        *
 * All rights reserved.                                                   *
 *                                                                        *
 * Primary Authors: <NAME>                                     *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/

#include "AliHLTPHOSHistogramProducerComponent.h"
#include "AliHLTPHOSProcessor.h"
#include "TH1D.h"
#include "TNtuple.h"
#include "TFile.h"
#include "AliHLTPHOSHistogramProducer.h"
#include "AliHLTPHOSPhysicsHistogramProducer.h"
#include "AliHLTPHOSCaloClusterContainerStruct.h"
#include "TClonesArray.h"
/** 
 * @file   AliHLTPHOSHistogramProducerComponent.cxx
 * @author <NAME>
 * @date   
 * @brief  A histogram producer component for PHOS HLT
*/

// see below for class documentation
// or
// refer to README to build package
// or
// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt


AliHLTPHOSHistogramProducerComponent gAliHLTPHOSHistogramProducerComponent;

AliHLTPHOSHistogramProducerComponent::AliHLTPHOSHistogramProducerComponent() :
  AliHLTPHOSProcessor(),
  fPhysicsHistogramProducerPtr(0),
  fPushModulo(1)
{
  //see header file for documentation
}

AliHLTPHOSHistogramProducerComponent::~AliHLTPHOSHistogramProducerComponent()
{
  //see header file for documentation
}

int 
AliHLTPHOSHistogramProducerComponent::Deinit()
{ 
  //see header file for documentation
  if(fPhysicsHistogramProducerPtr != 0)
    {
      delete fPhysicsHistogramProducerPtr;
      fPhysicsHistogramProducerPtr = 0;
    }

  return 0;
}

const char*
AliHLTPHOSHistogramProducerComponent::GetComponentID()
{
  //see header file for documentation
  return "PhosHistoProducer";
}


void
AliHLTPHOSHistogramProducerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
{ 
  //see header file for documentation
  list.clear();
  list.push_back(AliHLTPHOSDefinitions::fgkESDCaloClusterDataType);
  list.push_back(AliHLTPHOSDefinitions::fgkESDCaloCellsDataType);

}

AliHLTComponentDataType 
AliHLTPHOSHistogramProducerComponent::GetOutputDataType()
{
  //see header file for documentation
  return AliHLTPHOSDefinitions::fgkPhosHistDataType;
}


void 
AliHLTPHOSHistogramProducerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
{
  //see header file for documentation
  constBase = 30;
  inputMultiplier = 5;
}

// int 
// AliHLTPHOSHistogramProducerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
// 					AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
// 					std::vector<AliHLTComponentBlockData>& outputBlocks)

int 
AliHLTPHOSHistogramProducerComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
					      AliHLTComponentTriggerData& /*trigData*/)


{
  //see header file for documentation
  for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeCaloCluster | kAliHLTDataOriginPHOS); pBlock!=NULL; pBlock=GetNextInputBlock()) 
    {
      AliHLTCaloClusterHeaderStruct *caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
      
      if(fCellEnergy)
	{
	  fCellEnergyHistProducer->DoEvent(caloClusterHeaderPtr);
	}
      if(fClusterEnergy)
	{
	  fClusterEnergyHistProducer->DoEvent(caloClusterHeaderPtr);
	}
      if(fInvariantMass)
	{
	  fInvariantMassHistProducer->DoEvent(caloClusterHeaderPtr);
	}
      if(fMatchedTracks)
	{
	  fMatchedTracksHistProducer->DoEvent(caloClusterHeaderPtr);
	}
    }
  if(fCellEnergy)
    {
      PushBack(fCellEnergyHistProducer->GetHistograms(), AliHLTPHOSDefinitions::fgkPhysicsHistogramsDataType);
    }
  if(fClusterEnergy)
    {
      PushBack(fClusterEnergyHistProducer->GetHistograms(), AliHLTPHOSDefinitions::fgkPhysicsHistogramsDataType);
    }
  if(fInvariantMass)
    {
      PushBack(fInvariantMassHistProducer->GetHistograms(), AliHLTPHOSDefinitions::fgkPhysicsHistogramsDataType);
    }
  if(fMatchedTracks)
    {
      PushBack(fMatchedTracksHistProducer->GetHistograms(), AliHLTPHOSDefinitions::fgkPhysicsHistogramsDataType);
    }
      
  return 0;
}


int
AliHLTPHOSHistogramProducerComponent::DoInit(int argc, const char** argv )
{
  //see header file for documentation

   
  for(int i = 0; i < argc; i++)
    {
      if(!strcmp("-cellenergy", argv[i+1])) fCellEnergy = true;
      if(!strcmp("-clusterenergy", argv[i+1])) fClusterEnergy = true;
      if(!strcmp("-invariantmass", argv[i+1])) fInvariantMass= true;
      if(!strcmp("-matchedtracks", argv[i+1])) fMatchedTracks = true;
    }
  
  if(fCellEnergy)
    {
      fCellEnergyHistProducer = new AliHLTPHOSHistoProdCellEnergy();
    }
  if(fClusterEnergy)
    {
      fClusterEnergyHistProducer = new AliHLTPHOSHistoProdClusterEnergy();
    }
  if(fInvariantMass)
    {
      fInvariantMassHistProducer = new AliHLTPHOSHistoProdInvMass();
    }
  if(fMatchedTracks)
    {
      fMatchedTracksHistProducer = new AliHLTPHOSHistoProdMatchedTracks();
    }

  return 0;
}

AliHLTComponent*
AliHLTPHOSHistogramProducerComponent::Spawn()
{
  //see header file for documentation
  return new AliHLTPHOSHistogramProducerComponent();
}


{'fraction_non_alphanumeric': 0.11609331033856767, 'fraction_numerical': 0.0034492148497776163, 'mean_word_length': 3.9209468512728898, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5519770', 'n_tokens_mistral': 3454, 'n_tokens_neox': 3331, 'n_words': 646}