<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.                  *
  **************************************************************************/

///////////////////////////////////////////////////////////////////////////////
//
//     Data container for relative ITS-TPC alignment analysis
//     Holds an array of AliRelAlignerKalman objects
//     and takes care of merging when processing data in parallel
//
//     Origin: <NAME>, Nikhef, <EMAIL>
//
//////////////////////////////////////////////////////////////////////////////

#include <TNamed.h>
#include <TMath.h>
#include <TObjArray.h>
#include <TCollection.h>
#include "AliESDEvent.h"
#include "AliRelAlignerKalman.h"
#include "AliRelAlignerKalmanArray.h"

ClassImp(AliRelAlignerKalmanArray)

//______________________________________________________________________________
AliRelAlignerKalmanArray::AliRelAlignerKalmanArray():
    TNamed(),
    fArray(new TObjArray()),
    fSaveInterval(600), //default every 10minutes
    fTimeMatchingTolerance(20),
    fCurrentTimeBin(0),
    fAligner(new AliRelAlignerKalman())
{
  //ctor
}

//______________________________________________________________________________
AliRelAlignerKalmanArray::AliRelAlignerKalmanArray(const char* name):
    TNamed(name, name),
    fArray(new TObjArray()),
    fSaveInterval(600), //default every 10 minutes
    fTimeMatchingTolerance(60),
    fCurrentTimeBin(0),
    fAligner(new AliRelAlignerKalman())
{
  //ctor
}

//______________________________________________________________________________
AliRelAlignerKalmanArray::~AliRelAlignerKalmanArray()
{
  //dtor
  fArray->SetOwner();
  delete fArray;
  delete fAligner;
}

//______________________________________________________________________________
Long64_t AliRelAlignerKalmanArray::Merge( TCollection* list )
{
  //Merge all the arrays
  //the merge is vertical, meaning matching entries in tree are merged

  AliRelAlignerKalmanArray *arrayFromList;
  if (!list) return 0;
  TIter next(list);
  while ( arrayFromList = dynamic_cast<AliRelAlignerKalmanArray*>(next()) )
  {
    if (arrayFromList==this) continue;

    fArray->AddAll(arrayFromList->fArray); //put all objects in one array

    //do the merge
    fArray->Sort();
    TObjArray* tmpArray = SortedMerge(fArray);
    tmpArray->SetOwner(kTRUE);

    TObjArray* newArray = dynamic_cast<TObjArray*>(tmpArray->Clone());
    delete fArray; //takes care of all loaded objects
    fArray = newArray;

    fArray->AddLast(arrayFromList->fAligner); //add the endofrun aligner
  }

  //TODO: this can be done better!
  //Add own endofrun aligner and clean up
  fArray->AddLast(fAligner);
  fArray->Sort();
  //TObjArray* tmpArray = SortedMerge(fArray);
  //tmpArray->SetOwner(kTRUE);
  //TObjArray* newArray = dynamic_cast<TObjArray*>(tmpArray->Clone());
  //delete fArray; //takes care of all loaded objects
  //fArray = newArray;

  return fArray->GetEntriesFast();
}

//______________________________________________________________________________
TObjArray* AliRelAlignerKalmanArray::SortedMerge( TObjArray* input )
{
  //Merges the adjacent aligners if close enough
  //input needs to be already sorted

  UInt_t timeStampIn;
  AliRelAlignerKalman* alignerIn;
  AliRelAlignerKalman* alignerOut = dynamic_cast<AliRelAlignerKalman*>(input->At(0));
  TObjArray* output = new TObjArray();  //empty array
  output->AddLast(alignerOut);        //first object in: copy of first input element

  timeStampIn = alignerOut->GetTimeStamp();
  SetCurrentTimeBin( timeStampIn );
  TIter next(input);
  while ( alignerIn = dynamic_cast<AliRelAlignerKalman*>(next()) )
  {
    timeStampIn = alignerIn->GetTimeStamp();
    if ( IsInCurrentTimeBin(timeStampIn) )
    {
      alignerOut->Merge(alignerIn);
    }
    else
    {
      alignerOut = alignerIn;
      output->AddLast(alignerOut);
    }//if
    SetCurrentTimeBin( timeStampIn );
  }
  return output;
}

//______________________________________________________________________________
void AliRelAlignerKalmanArray::SetCurrentTimeBin( UInt_t timestamp )
{
  //set the current timebin
  fCurrentTimeBin = TimeBin(timestamp);
}

//______________________________________________________________________________
UInt_t AliRelAlignerKalmanArray::TimeBin( UInt_t timestamp ) const
{
  return (timestamp+(fSaveInterval/2))/fSaveInterval*fSaveInterval; //it's all integers!<commit_msg>Fixing compilation warnings<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.                  *
  **************************************************************************/

///////////////////////////////////////////////////////////////////////////////
//
//     Data container for relative ITS-TPC alignment analysis
//     Holds an array of AliRelAlignerKalman objects
//     and takes care of merging when processing data in parallel
//
//     Origin: <NAME>, Nikhef, <EMAIL>
//
//////////////////////////////////////////////////////////////////////////////

#include <TNamed.h>
#include <TMath.h>
#include <TObjArray.h>
#include <TCollection.h>
#include "AliESDEvent.h"
#include "AliRelAlignerKalman.h"
#include "AliRelAlignerKalmanArray.h"

ClassImp(AliRelAlignerKalmanArray)

//______________________________________________________________________________
AliRelAlignerKalmanArray::AliRelAlignerKalmanArray():
    TNamed(),
    fArray(new TObjArray()),
    fSaveInterval(600), //default every 10minutes
    fTimeMatchingTolerance(20),
    fCurrentTimeBin(0),
    fAligner(new AliRelAlignerKalman())
{
  //ctor
}

//______________________________________________________________________________
AliRelAlignerKalmanArray::AliRelAlignerKalmanArray(const char* name):
    TNamed(name, name),
    fArray(new TObjArray()),
    fSaveInterval(600), //default every 10 minutes
    fTimeMatchingTolerance(60),
    fCurrentTimeBin(0),
    fAligner(new AliRelAlignerKalman())
{
  //ctor
}

//______________________________________________________________________________
AliRelAlignerKalmanArray::~AliRelAlignerKalmanArray()
{
  //dtor
  fArray->SetOwner();
  delete fArray;
  delete fAligner;
}

//______________________________________________________________________________
Long64_t AliRelAlignerKalmanArray::Merge( TCollection* list )
{
  //Merge all the arrays
  //the merge is vertical, meaning matching entries in tree are merged

  AliRelAlignerKalmanArray *arrayFromList;
  if (!list) return 0;
  TIter next(list);
  while ( (arrayFromList = dynamic_cast<AliRelAlignerKalmanArray*>(next())) )
  {
    if (arrayFromList==this) continue;

    fArray->AddAll(arrayFromList->fArray); //put all objects in one array

    //do the merge
    fArray->Sort();
    TObjArray* tmpArray = SortedMerge(fArray);
    tmpArray->SetOwner(kTRUE);

    TObjArray* newArray = dynamic_cast<TObjArray*>(tmpArray->Clone());
    delete fArray; //takes care of all loaded objects
    fArray = newArray;

    fArray->AddLast(arrayFromList->fAligner); //add the endofrun aligner
  }

  //TODO: this can be done better!
  //Add own endofrun aligner and clean up
  fArray->AddLast(fAligner);
  fArray->Sort();
  //TObjArray* tmpArray = SortedMerge(fArray);
  //tmpArray->SetOwner(kTRUE);
  //TObjArray* newArray = dynamic_cast<TObjArray*>(tmpArray->Clone());
  //delete fArray; //takes care of all loaded objects
  //fArray = newArray;

  return fArray->GetEntriesFast();
}

//______________________________________________________________________________
TObjArray* AliRelAlignerKalmanArray::SortedMerge( TObjArray* input )
{
  //Merges the adjacent aligners if close enough
  //input needs to be already sorted

  UInt_t timeStampIn;
  AliRelAlignerKalman* alignerIn;
  AliRelAlignerKalman* alignerOut = dynamic_cast<AliRelAlignerKalman*>(input->At(0));
  TObjArray* output = new TObjArray();  //empty array
  output->AddLast(alignerOut);        //first object in: copy of first input element

  timeStampIn = alignerOut->GetTimeStamp();
  SetCurrentTimeBin( timeStampIn );
  TIter next(input);
  while ( (alignerIn = dynamic_cast<AliRelAlignerKalman*>(next())) )
  {
    timeStampIn = alignerIn->GetTimeStamp();
    if ( IsInCurrentTimeBin(timeStampIn) )
    {
      alignerOut->Merge(alignerIn);
    }
    else
    {
      alignerOut = alignerIn;
      output->AddLast(alignerOut);
    }//if
    SetCurrentTimeBin( timeStampIn );
  }
  return output;
}

//______________________________________________________________________________
void AliRelAlignerKalmanArray::SetCurrentTimeBin( UInt_t timestamp )
{
  //set the current timebin
  fCurrentTimeBin = TimeBin(timestamp);
}

//______________________________________________________________________________
UInt_t AliRelAlignerKalmanArray::TimeBin( UInt_t timestamp ) const
{
  return (timestamp+(fSaveInterval/2))/fSaveInterval*fSaveInterval; //it's all integers!
{'fraction_non_alphanumeric': 0.1460716294768423, 'fraction_numerical': 0.005437839864991562, 'mean_word_length': 3.3168757588021043, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 63, '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': '4311386', 'n_tokens_mistral': 2922, 'n_tokens_neox': 2783, 'n_words': 709}