<commit_before>/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * 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.                  *
 **************************************************************************/

/*
 
 
EMCal trigger electronics manager L0/L1
can handle both simulated digits and raw data
Author: <NAME> LPSC Grenoble CNRS/IN2P3
*/

#include "AliEMCALTriggerElectronics.h"
#include "AliEMCALTriggerTRU.h"
#include "AliEMCALTriggerSTU.h"
#include "AliEMCALGeometry.h"
#include "AliRunLoader.h"
#include "AliEMCAL.h" 
#include "AliRun.h" 
#include "AliEMCALTriggerDCSConfig.h"
#include "AliEMCALTriggerData.h"
#include "AliEMCALDigit.h"
#include "AliCaloRawStreamV3.h"
#include "AliEMCALTriggerSTURawStream.h"
#include "AliEMCALDigit.h"
#include "AliEMCALTriggerRawDigit.h"
#include "AliEMCALTriggerPatch.h"

#include <TVector2.h>
#include <TClonesArray.h>

namespace
{
	const Int_t kNTRU = 30;
}

ClassImp(AliEMCALTriggerElectronics)

//__________________
AliEMCALTriggerElectronics::AliEMCALTriggerElectronics(const AliEMCALTriggerDCSConfig *dcsConf) : TObject(),
fTRU(new TClonesArray("AliEMCALTriggerTRU",32)),
fSTU(0x0)
{
	TVector2 rSize;
	
	rSize.Set( 24.,  4. );

	// 32 TRUs
	for (Int_t i=0;i<kNTRU;i++) 
	{
		AliEMCALTriggerTRUDCSConfig* truConf = dcsConf->GetTRUDCSConfig(i);
		new ((*fTRU)[i]) AliEMCALTriggerTRU(truConf, rSize, i % 2);
	}
	
	rSize.Set( 48., 64. );
	
	// 1 STU
	AliEMCALTriggerSTUDCSConfig* stuConf = dcsConf->GetSTUDCSConfig();
	fSTU = new AliEMCALTriggerSTU(stuConf, rSize);
	
	TString str = "map";
	for (Int_t i=0;i<kNTRU;i++) fSTU->Build(str,
											i,
											(static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->Map(),
											(static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->RegionSize() 
										    );
}

//________________
AliEMCALTriggerElectronics::~AliEMCALTriggerElectronics()
{
	//
	fTRU->Delete();
 	delete fSTU;
}

//__________________
void AliEMCALTriggerElectronics::Digits2Trigger(TClonesArray* digits, const Int_t V0M[], AliEMCALTriggerData* data)
{
	//
	AliEMCALGeometry* geom = 0x0;
	
	AliRunLoader *rl = AliRunLoader::Instance();
	if (rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL")){
	  AliEMCAL* emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"));
	  if(emcal)geom = emcal->GetGeometry();
	}
	
	if(!geom) geom =  AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
	
	if(!geom) AliError("Cannot access geometry!");
	
	//	digits->Sort();
	
	Int_t region[48][64], posMap[48][64];
	for (Int_t i = 0; i < 48; i++) for (Int_t j = 0; j < 64; j++) 
	{
		region[i][j] =  0;
		posMap[i][j] = -1;
	}
	
	for (Int_t i = 0; i < digits->GetEntriesFast(); i++)
	{
		AliEMCALTriggerRawDigit* digit = (AliEMCALTriggerRawDigit*)digits->At(i);
		
		Int_t id = digit->GetId();
		
		Int_t iTRU, iADC;
		
		Bool_t isOK1 = geom->GetTRUFromAbsFastORIndex(id, iTRU, iADC);
		
		for (Int_t j = 0; j < digit->GetNSamples(); j++)
		{
			Int_t time, amp;
			Bool_t isOK2 = digit->GetTimeSample(j, time, amp);
			<commit_msg>Keep only digits from active TRU to compute trigger response (only relevant for MC)<commit_after>/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * 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.                  *
 **************************************************************************/

/*
 
 
EMCal trigger electronics manager L0/L1
can handle both simulated digits and raw data
Author: <NAME> LPSC Grenoble CNRS/IN2P3
*/

#include "AliEMCALTriggerElectronics.h"
#include "AliEMCALTriggerTRU.h"
#include "AliEMCALTriggerSTU.h"
#include "AliEMCALGeometry.h"
#include "AliRunLoader.h"
#include "AliEMCAL.h" 
#include "AliRun.h" 
#include "AliEMCALTriggerDCSConfig.h"
#include "AliEMCALTriggerData.h"
#include "AliEMCALDigit.h"
#include "AliCaloRawStreamV3.h"
#include "AliEMCALTriggerSTURawStream.h"
#include "AliEMCALDigit.h"
#include "AliEMCALTriggerRawDigit.h"
#include "AliEMCALTriggerPatch.h"

#include <TVector2.h>
#include <TClonesArray.h>

namespace
{
	const Int_t kNTRU = 30;
}

ClassImp(AliEMCALTriggerElectronics)

//__________________
AliEMCALTriggerElectronics::AliEMCALTriggerElectronics(const AliEMCALTriggerDCSConfig *dcsConf) : TObject(),
fTRU(new TClonesArray("AliEMCALTriggerTRU",32)),
fSTU(0x0)
{
	TVector2 rSize;
	
	rSize.Set( 24.,  4. );

	// 32 TRUs
	for (Int_t i=0;i<kNTRU;i++) 
	{
		AliEMCALTriggerTRUDCSConfig* truConf = dcsConf->GetTRUDCSConfig(i);
		new ((*fTRU)[i]) AliEMCALTriggerTRU(truConf, rSize, i % 2);
	}
	
	rSize.Set( 48., 64. );
	
	// 1 STU
	AliEMCALTriggerSTUDCSConfig* stuConf = dcsConf->GetSTUDCSConfig();
	fSTU = new AliEMCALTriggerSTU(stuConf, rSize);
	
	TString str = "map";
	for (Int_t i=0;i<kNTRU;i++) fSTU->Build(str,
											i,
											(static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->Map(),
											(static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->RegionSize() 
										    );
}

//________________
AliEMCALTriggerElectronics::~AliEMCALTriggerElectronics()
{
	//
	fTRU->Delete();
 	delete fSTU;
}

//__________________
void AliEMCALTriggerElectronics::Digits2Trigger(TClonesArray* digits, const Int_t V0M[], AliEMCALTriggerData* data)
{
	//
	AliEMCALGeometry* geom = 0x0;
	
	AliRunLoader *rl = AliRunLoader::Instance();
	if (rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL")){
	  AliEMCAL* emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"));
	  if(emcal)geom = emcal->GetGeometry();
	}
	
	if(!geom) geom =  AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
	
	if(!geom) AliError("Cannot access geometry!");
	
	//	digits->Sort();
	
	Int_t region[48][64], posMap[48][64];
	for (Int_t i = 0; i < 48; i++) for (Int_t j = 0; j < 64; j++) 
	{
		region[i][j] =  0;
		posMap[i][j] = -1;
	}
	
	for (Int_t i = 0; i < digits->GetEntriesFast(); i++)
	{
		AliEMCALTriggerRawDigit* digit = (AliEMCALTriggerRawDigit*)digits->At(i);
		
		Int_t id = digit->GetId();
		
		Int_t iTRU, iADC;
		
		Bool_t isOK1 = geom->GetTRUFromAbsFastORIndex(id, iTRU, iADC);
		
		if ((isOK1 && iTRU >= kNTRU) || !isOK1) continue;

		for (Int_t j = 0; j < digit->GetNSamples(); j++)
		{
			Int_t time, amp;
			Bool_t isOK2 = digit->GetTimeSample(j, time, amp);
			
{'fraction_non_alphanumeric': 0.16188187681800936, 'fraction_numerical': 0.014923485519160238, 'mean_word_length': 3.571098265895954, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 58, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4210918', 'n_tokens_mistral': 3025, 'n_tokens_neox': 2635, 'n_words': 599}