#include "AliCDBEntry.h"
#include "AliLog.h"
#include "AliVEventHandler.h"
+#include "AliAODInputHandler.h"
// --- EMCAL
#include "AliEMCALRecParam.h"
, fDigitsArr(0), fClusterArr(0), fCaloClusterArr(0)
, fRecParam(0), fClusterizer(0), fUnfolder(0), fJustUnfold(kFALSE)
, fOutputAODBranch(0), fOutputAODBranchName("newEMCALClusters"), fFillAODFile(kTRUE)
- , fRun(-1), fRecoUtils(0), fConfigName("")
+ , fRun(-1), fRecoUtils(0), fConfigName(""), fCellLabels()
{
//ctor
- for(Int_t i = 0; i < 10; i++) fGeomMatrix[i] = 0 ;
+ for(Int_t i = 0; i < 10; i++) fGeomMatrix[i] = 0;
+ for(Int_t j = 0; j < 12672; j++) fCellLabels[j] = -1;
fDigitsArr = new TClonesArray("AliEMCALDigit",200);
fClusterArr = new TObjArray(100);
fCaloClusterArr = new TObjArray(100);
, fDigitsArr(0), fClusterArr(0), fCaloClusterArr(0)
, fRecParam(0), fClusterizer(0), fUnfolder(0), fJustUnfold(kFALSE)
, fOutputAODBranch(0), fOutputAODBranchName("newEMCALClusters"), fFillAODFile(kFALSE)
- , fRun(-1), fRecoUtils(0), fConfigName("")
+ , fRun(-1), fRecoUtils(0), fConfigName(""), fCellLabels()
{
// Constructor
- for(Int_t i = 0; i < 10; i++) fGeomMatrix[i] = 0 ;
+ for(Int_t i = 0; i < 10; i++) fGeomMatrix[i] = 0;
+ for(Int_t j = 0; j < 24*48*11; j++) fCellLabels[j] = -1;
fDigitsArr = new TClonesArray("AliEMCALDigit",200);
fClusterArr = new TObjArray(100);
fCaloClusterArr = new TObjArray(100);
//Remove the contents of output list set in the previous event
fOutputAODBranch->Clear("C");
- AliVEvent * event = InputEvent();
- AliESDEvent * esdevent = dynamic_cast<AliESDEvent*>(InputEvent());
-
+ //Get the event
+ AliVEvent * event = 0;
+ AliESDEvent * esdevent = 0;
+
+ //Check if input event are embedded events
+ //If so, take output event
+ AliAODInputHandler* aodIH = dynamic_cast<AliAODInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
+ if (aodIH && aodIH->GetMergeEvents()) {
+ //printf("AliAnalysisTaskEMCALClusterize::UserExec() - Use embedded events\n");
+ event = AODEvent();
+// printf("InputEvent N Clusters %d, N Cells %d\n",InputEvent()->GetNumberOfCaloClusters(),
+// InputEvent()->GetEMCALCells()->GetNumberOfCells());
+// printf("OutputEvent N Clusters %d, N Cells %d\n", AODEvent()->GetNumberOfCaloClusters(),
+// AODEvent()->GetEMCALCells()->GetNumberOfCells());
+ }
+ else {
+ event = InputEvent();
+ esdevent = dynamic_cast<AliESDEvent*>(InputEvent());
+ }
+
if (!event) {
Error("UserExec","Event not available");
return;
//-------------------------------------------------------------------------------------
//Transform CaloCells into Digits
//-------------------------------------------------------------------------------------
+
+ //In case of MC, first loop on the clusters and fill MC label to array
+ //.....................................................................
+
+// for(Int_t j = 0; j < 24*48*11; j++) {
+// if(fCellLabels[j]!=-1) printf("Not well initialized cell %d, label %d\n",j,fCellLabels[j]) ;
+// }
+
+ for (Int_t i = 0; i < event->GetNumberOfCaloClusters(); i++)
+ {
+ AliVCluster *clus = event->GetCaloCluster(i);
+ if(clus->IsEMCAL()){
+
+ Int_t label = clus->GetLabel();
+ UShort_t * index = clus->GetCellsAbsId() ;
+ for(Int_t icell=0; icell < clus->GetNCells(); icell++ ){
+ fCellLabels[index[icell]]=label;
+ //printf("1) absID %d, label %d\n",index[icell], fCellLabels[index[icell]]);
+ }
+ nClustersOrg++;
+ }
+ }
+
+ // Create digits
+ //.................
Int_t idigit = 0;
Int_t id = -1;
Float_t amp = -1;
TTree *digitsTree = new TTree("digitstree","digitstree");
digitsTree->Branch("EMCAL","TClonesArray", &fDigitsArr, 32000);
+
for (Int_t icell = 0; icell < cells->GetNumberOfCells(); icell++)
{
if (cells->GetCell(icell, cellNumber, cellAmplitude, cellTime) != kTRUE)
//Do not include bad channels found in analysis?
if( fRecoUtils->IsBadChannelsRemovalSwitchedOn() &&
fRecoUtils->GetEMCALChannelStatus(imod, ieta, iphi)){
+ fCellLabels[id]=-1; //reset the entry in the array for next event
//printf("Remove channel %d\n",id);
continue;
}
amp *=fRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi);
}
- AliEMCALDigit *digit = (AliEMCALDigit*) fDigitsArr->New(idigit);
- digit->SetId(id);
- digit->SetAmplitude(amp);
- digit->SetTime(time);
- digit->SetTimeR(time);
- digit->SetIndexInList(idigit);
- digit->SetType(AliEMCALDigit::kHG);
+ //Create the digit, put a fake primary deposited energy to trick the clusterizer when checking the most likely primary
+ new((*fDigitsArr)[idigit]) AliEMCALDigit( fCellLabels[id], fCellLabels[id],id, amp, time,AliEMCALDigit::kHG,idigit, 0, 0, 1);
+ //if(fCellLabels[id]>=0)printf("2) Digit cell %d, label %d\n",id,fCellLabels[id]) ;
+ //else printf("2) Digit cell %d, no label, amp %f \n",id,amp) ;
+ fCellLabels[id]=-1; //reset the entry in the array for next event
+
+ //AliEMCALDigit *digit = (AliEMCALDigit*) fDigitsArr->New(idigit);
+ //digit->SetId(id);
+ //digit->SetAmplitude(amp);
+ //digit->SetTime(time);
+ //digit->SetTimeR(time);
+ //digit->SetIndexInList(idigit);
+ //digit->SetType(AliEMCALDigit::kHG);
//printf("Digit: Id %d, amp %f, time %e, index %d\n",id, amp,time,idigit);
idigit++;
fClusterizer->SetInput(digitsTree);
fClusterizer->SetOutput(clustersTree);
fClusterizer->Digits2Clusters("");
-
+
//-------------------------------------------------------------------------------------
//Transform the recpoints into AliVClusters
//-------------------------------------------------------------------------------------
TBranch *branch = clustersTree->GetBranch("EMCALECARP");
branch->SetAddress(&fClusterArr);
branch->GetEntry(0);
-
+
RecPoints2Clusters(fDigitsArr, fClusterArr, fCaloClusterArr);
//---CLEAN UP-----
//-------------------------------------------------------------------------------------
Int_t kNumberOfCaloClusters = fCaloClusterArr->GetEntries();
- //Info("UserExec","New clusters %d",kNumberOfCaloClusters);
- //if(nClustersOrg!=kNumberOfCaloClusters) Info("UserExec","Different number: Org %d, New %d\n",nClustersOrg,kNumberOfCaloClusters);
+ //printf("New clusters %d, Org clusters %d\n",kNumberOfCaloClusters, nClustersOrg);
for(Int_t i = 0; i < kNumberOfCaloClusters; i++){
AliAODCaloCluster *newCluster = (AliAODCaloCluster *) fCaloClusterArr->At(i);
//if(Entry()==0) Info("UserExec","newCluster E %f\n", newCluster->E());
//printf("; after %f \n",newCluster->GetDistanceToBadChannel());
}
+// if(newCluster->GetNLabels()>0){
+// printf("3) MC: N labels %d, label %d ; ", newCluster->GetNLabels(), newCluster->GetLabel() );
+// UShort_t * newindex = newCluster->GetCellsAbsId() ;
+// for(Int_t icell=0; icell < newCluster->GetNCells(); icell++ ){
+// printf("\t absID %d\n",newindex[icell]);
+// }
+// }
+//
+// printf("Cluster %d, energy %f\n",newCluster->GetID(),newCluster->E());
+
newCluster->SetID(i);
- //printf("Cluster %d, energy %f\n",newCluster->GetID(),newCluster->E());
new((*fOutputAODBranch)[i]) AliAODCaloCluster(*newCluster);
}
clus->SetM02(elipAxis[0]*elipAxis[0]) ;
clus->SetM20(elipAxis[1]*elipAxis[1]) ;
clus->SetDistanceToBadChannel(recPoint->GetDistanceToBadTower());
+
+ //MC
+ Int_t parentMult = 0;
+ Int_t *parentList = recPoint->GetParents(parentMult);
+ clus->SetLabel(parentList, parentMult);
+
clusArray->Add(clus);
} // recPoints loop
}
//Settings to read locally several files, only for "mLocal" mode
//The different values are default, they can be set with environmental
//variables: INDIR, PATTERN, NFILES, respectivelly
-char * kInDir = "/Users/data/path/data/";
+char * kInDir = "/Users/Gustavo/Work/data/134908/pass1";
+//char * kInDir = "/Users/Gustavo/Work/data/137366/";
char * kPattern = ""; // Data are in files kInDir/kPattern+i
Int_t kFile = 1; // Number of files
//---------------------------------------------------------------------------
char * kXML = "collection.xml";
//---------------------------------------------------------------------------
-const TString kInputData = "ESD"; //ESD, AOD, MC
+TString kInputData = "AOD"; //ESD, AOD, MC
TString kTreeName = "esdTree";
Bool_t kUsePhysSel = kFALSE;
+Bool_t kEmbed = kTRUE;
void emcalReclusterize(Int_t mode=mLocal)
{
// Main
- char cmd[200] ;
- sprintf(cmd, ".! rm -rf aod.root") ;
- gROOT->ProcessLine(cmd) ;
+ //char cmd[200] ;
+ //sprintf(cmd, ".! rm -rf outputAOD.root") ;
+ //gROOT->ProcessLine(cmd) ;
//--------------------------------------------------------------------
// Load analysis libraries
// Look at the method below,
// AOD output handler
AliAODHandler* aodoutHandler = new AliAODHandler();
- aodoutHandler->SetOutputFileName("aod.root");
- ////aodoutHandler->SetCreateNonStandardAOD();
+ aodoutHandler->SetOutputFileName("outputAOD.root");
+ if(kEmbed){
+ aodoutHandler->SetCreateNonStandardAOD();
+ kInputData = "AOD";
+ }
mgr->SetOutputEventHandler(aodoutHandler);
+
//input
if(kInputData == "ESD")
{
// AOD handler
AliAODInputHandler *aodHandler = new AliAODInputHandler();
mgr->SetInputEventHandler(aodHandler);
+ if(kEmbed){
+ aodHandler->SetMergeEvents(kTRUE);
+ aodHandler->AddFriend("AliAOD.root");
+ }
+
cout<<"AOD handler "<<mgr->GetInputEventHandler()<<endl;
}
- mgr->SetDebugLevel(1);
+ //mgr->SetDebugLevel(1);
//-------------------------------------------------------------------------
//Define task, put here any other task that you want to use.
// mgr->ConnectInput (clusterize, 0, cinput1 );
// mgr->ConnectOutput (clusterize, 0, coutput1 );
-
//-----------------------
// Run the analysis
//-----------------------
fEMCALCells(0x0), fPHOSCells(0x0),
fInputEvent(0x0), fOutputEvent(0x0),fMC(0x0),
fFillCTS(0),fFillEMCAL(0),fFillPHOS(0),
- fFillEMCALCells(0),fFillPHOSCells(0),
+ fFillEMCALCells(0),fFillPHOSCells(0), fSelectEmbeddedClusters(kFALSE),
fRemoveSuspiciousClusters(kFALSE), fSmearClusterEnergy(kFALSE), fRandom(),
// fSecondInputAODTree(0x0), fSecondInputAODEvent(0x0),
// fSecondInputFileName(""),fSecondInputFirstEvent(0),
void AliCaloTrackReader::ResetLists() {
// Reset lists, called by the analysis maker
- if(fCTSTracks) fCTSTracks -> Clear();
+ if(fCTSTracks) fCTSTracks -> Clear();
if(fEMCALClusters) fEMCALClusters -> Clear("C");
if(fPHOSClusters) fPHOSClusters -> Clear("C");
// if(fEMCALCells) fEMCALCells -> Clear("");
// else {
// if(energy > 2)printf("AliCaloTrackReader::FillInputEMCALAlgorithm() - Keep cluster: e %2.2f, Ncells %d, min Ncells %2.1f\n",energy,ncells,minNCells);
// }
- }
+ }//Suspicious
+ if(fSelectEmbeddedClusters){
+ if(clus->GetNLabels()==0) return;
+ //else printf("Embedded cluster, %d, n label %d label %d \n",iclus,clus->GetNLabels(),clus->GetLabel());
+ }
TLorentzVector momentum ;
void SwitchOnPHOSCells() { fFillPHOSCells = kTRUE ; }
void SwitchOffPHOSCells() { fFillPHOSCells = kFALSE ; }
+ void SwitchOnEmbeddedClustersSelection() { fSelectEmbeddedClusters = kTRUE ; }
+ void SwitchOffEmbeddedClustersSelection(){ fSelectEmbeddedClusters = kFALSE ; }
+
// Filling/ filtering / detector information access methods
virtual Bool_t FillInputEvent(const Int_t iEntry, const char *currentFileName) ;
virtual void FillInputCTS() ;
//------------------------
// Centrality
//------------------------
- virtual AliCentrality* GetCentrality() const { return fInputEvent->GetCentrality() ; }
+ virtual AliCentrality* GetCentrality() const { return fInputEvent->GetCentrality() ; } //Look in AOD reader, different there
virtual void SetCentralityClass(TString name) { fCentralityClass = name ; }
virtual void SetCentralityOpt(Int_t opt) { fCentralityOpt = opt ; }
virtual TString GetCentralityClass() const { return fCentralityClass ; }
virtual AliAODMCHeader* GetAODMCHeader(Int_t input = 0) const ;
virtual AliVEvent* GetInputEvent() const { return fInputEvent ; }
+ virtual AliVEvent* GetOriginalInputEvent() const { return 0x0 ; }
virtual AliAODEvent* GetOutputEvent() const { return fOutputEvent ; }
virtual AliMCEvent* GetMC() const { return fMC ; }
virtual AliMixedEvent* GetMixedEvent() const { return fMixedEvent ; }
Bool_t fFillPHOS; // use data from PHOS
Bool_t fFillEMCALCells; // use data from EMCAL
Bool_t fFillPHOSCells; // use data from PHOS
+ Bool_t fSelectEmbeddedClusters; // Use only simulated clusters that come from embedding.
Bool_t fRemoveSuspiciousClusters; // Remove high energy clusters with low number of cells
Bool_t fSmearClusterEnergy; // Smear cluster energy, to be done only for simulated data to match real data
Float_t fSmearClusterParam[3]; // Smearing parameters
Int_t fCentralityOpt; // Option for the returned value of the centrality, possible options 5, 10, 100
Int_t fCentralityBin[2]; // Minimum and maximum value of the centrality for the analysis
- ClassDef(AliCaloTrackReader,27)
+ ClassDef(AliCaloTrackReader,28)
} ;