#include "AliAODHeader.h"
#include "AliAODTracklets.h"
#include "AliAODCaloCells.h"
+#include "AliAODCaloTrigger.h"
#include "AliAODMCParticle.h"
#include "AliVEvent.h"
#include "AliAODHandler.h"
AliAODTracklets* AliAnalysisTaskSE::fgAODTracklets = NULL;
AliAODCaloCells* AliAnalysisTaskSE::fgAODEmcalCells = NULL;
AliAODCaloCells* AliAnalysisTaskSE::fgAODPhosCells = NULL;
+AliAODCaloTrigger* AliAnalysisTaskSE::fgAODEMCALTrigger = NULL;
+AliAODCaloTrigger* AliAnalysisTaskSE::fgAODPHOSTrigger = NULL;
TClonesArray* AliAnalysisTaskSE::fgAODDimuons = NULL;
+TClonesArray* AliAnalysisTaskSE::fgAODHmpidRings = NULL;
AliAnalysisTaskSE::AliAnalysisTaskSE():
AliAnalysisTask(),
AliAnalysisTaskSE& AliAnalysisTaskSE::operator=(const AliAnalysisTaskSE& other)
{
// Assignment
+ if(&other == this) return *this;
+ AliAnalysisTask::operator=(other);
+
AliAnalysisTask::operator=(other);
fDebug = other.fDebug;
fEntry = other.fEntry;
}
//______________________________________________________________________________
-Bool_t AliAnalysisTaskSE::CheckPostData() const
-{
-// Checks if data was posted to all outputs defined by the task. If task does
-// not have output slots this returns always kTRUE.
- AliAnalysisDataContainer *coutput;
- AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
- for (Int_t islot=1; islot<fNoutputs; islot++) {
- coutput = GetOutputSlot(islot)->GetContainer();
- if (!mgr->GetOutputs()->FindObject(coutput)) continue;
- if (!coutput->GetData()) return kFALSE;
- }
- CheckOwnership();
- return kTRUE;
-}
-
void AliAnalysisTaskSE::ConnectInputData(Option_t* /*option*/)
{
// Connect the input data
fOutputAOD = handler->GetAOD();
fTreeA = handler->GetTree();
if (fOutputAOD && !(handler->IsStandard())) {
- if ((handler->NeedsHeaderReplication()) && !(fgAODHeader))
+ if ((handler->NeedsHeaderReplication() || merging) && !(fgAODHeader))
{
if (fDebug > 1) AliInfo("Replicating header");
fgAODHeader = new AliAODHeader;
fgAODPhosCells = new AliAODCaloCells("phosCells","phosCells",AliVCaloCells::kPHOSCell);
handler->AddBranch("AliAODCaloCells", &fgAODPhosCells);
-
+ }
+ if ((handler->NeedsCaloTriggerBranchReplication() || merging) && !(fgAODEMCALTrigger))
+ {
+ if (fDebug > 1) AliInfo("Replicating EMCAL Calo Trigger branches\n");
+ fgAODEMCALTrigger = new AliAODCaloTrigger("emcalTrigger","emcalTrigger");
+ handler->AddBranch("AliAODCaloTrigger", &fgAODEMCALTrigger);
+ }
+ if ((handler->NeedsCaloTriggerBranchReplication() || merging) && !(fgAODPHOSTrigger))
+ {
+ if (fDebug > 1) AliInfo("Replicating PHOS Calo Trigger branches\n");
+ fgAODPHOSTrigger = new AliAODCaloTrigger("phosTrigger","phosTrigger");
+ handler->AddBranch("AliAODCaloTrigger", &fgAODPHOSTrigger);
}
if ((handler->NeedsMCParticlesBranchReplication() || merging) && !(fgAODMCParticles))
{
fgAODMCParticles->SetName("mcparticles");
handler->AddBranch("TClonesArray", &fgAODMCParticles);
}
- if ((handler->NeedsDimuonsBranchReplication() || merging) && !(fgAODDimuons))
+ if ((handler->NeedsDimuonsBranchReplication() || merging) && !(fgAODDimuons))
{
if (fDebug > 1) AliInfo("Replicating dimuon branch\n");
fgAODDimuons = new TClonesArray("AliAODDimuon",0);
fgAODDimuons->SetName("dimuons");
handler->AddBranch("TClonesArray", &fgAODDimuons);
}
+ if ((handler->NeedsHMPIDBranchReplication() || merging) && !(fgAODHmpidRings))
+ {
+ if (fDebug > 1) AliInfo("Replicating HMPID branch\n");
+ fgAODHmpidRings = new TClonesArray("AliAODHMPIDrings",0);
+ fgAODHmpidRings->SetName("hmpidRings");
+ handler->AddBranch("TClonesArray", &fgAODHmpidRings);
+ }
+
// cache the pointerd in the AODEvent
fOutputAOD->GetStdContent();
//
// Was event selected ? If no event selection mechanism, the event SHOULD be selected (AG)
UInt_t isSelected = AliVEvent::kAny;
- if( fInputHandler && fInputHandler->GetEventSelection()) {
+ if( fInputHandler && (fInputHandler->GetEventSelection() || aodH)) {
// Get the actual offline trigger mask for the event and AND it with the
// requested mask. If no mask requested select by default the event.
if (fOfflineTriggerMask)
if (handler && aodH) {
fMCEvent = aodH->MCEvent();
Bool_t merging = aodH->GetMergeEvents();
+
+ // Do not analyze merged events if last embedded file has less events than normal event,
+ // skip analysis after last embeded event
+ if(merging){
+ if(aodH->GetReadEntry() + aodH->GetMergeOffset() >= aodH->GetTreeToMerge()->GetEntriesFast()){
+ //printf("Skip Entry %lld, Offset %d, Tree Entries %d\n",aodH->GetReadEntry(),aodH->GetMergeOffset(), aodH->GetTreeToMerge()->GetEntries());
+
+ // Do I need to add the lines before the return?
+ // Added protection in case the derived task is not an AOD producer.
+ AliAnalysisDataSlot *out0 = GetOutputSlot(0);
+ if (out0 && out0->IsConnected()) PostData(0, fTreeA);
+
+ DisconnectMultiHandler();
+
+ return;
+ }
+ //else printf("MERGE Entry %lld, Offset %d, Tree Entries %d\n",aodH->GetReadEntry(),aodH->GetMergeOffset(), aodH->GetTreeToMerge()->GetEntries());
+ }
+
AliAODEvent* aod = dynamic_cast<AliAODEvent*>(InputEvent());
if (aod && !(handler->IsStandard()) && !(handler->AODIsReplicated())) {
- if ((handler->NeedsHeaderReplication()) && (fgAODHeader))
+ if ((handler->NeedsHeaderReplication() || merging) && (fgAODHeader))
{
// copy the contents by assigment
*fgAODHeader = *(aod->GetHeader());
}
- if ((handler->NeedsTracksBranchReplication() || merging) && (fgAODTracks))
+ if ((handler->NeedsTracksBranchReplication() || (merging && aodH->GetMergeTracks())) && (fgAODTracks))
{
TClonesArray* tracks = aod->GetTracks();
new (fgAODTracks) TClonesArray(*tracks);
TClonesArray* pmdClusters = aod->GetPmdClusters();
new (fgAODPMDClusters) TClonesArray(*pmdClusters);
}
- if ((handler->NeedsJetsBranchReplication() || merging) && (fgAODJets))
+ if ((handler->NeedsJetsBranchReplication() || (merging &&aodH->GetMergeTracks())) && (fgAODJets))
{
TClonesArray* jets = aod->GetJets();
new (fgAODJets) TClonesArray(*jets);
TClonesArray* fmdClusters = aod->GetFmdClusters();
new (fgAODFMDClusters) TClonesArray(*fmdClusters);
}
- if ((handler->NeedsCaloClustersBranchReplication() || merging) && (fgAODCaloClusters))
+ if ((handler->NeedsCaloClustersBranchReplication() ||
+ (merging && (aodH->GetMergeEMCALClusters() || aodH->GetMergePHOSClusters())))
+ && (fgAODCaloClusters))
{
TClonesArray* caloClusters = aod->GetCaloClusters();
new (fgAODCaloClusters) TClonesArray(*caloClusters);
new (fgAODMCParticles) TClonesArray(*mcParticles);
}
- if ((handler->NeedsDimuonsBranchReplication() || merging) && (fgAODDimuons))
+ if ((handler->NeedsDimuonsBranchReplication() || (merging && aodH->GetMergeTracks())) && (fgAODDimuons))
{
fgAODDimuons->Clear();
TClonesArray& dimuons = *fgAODDimuons;
}
}
}
+ if ((handler->NeedsHMPIDBranchReplication()) && (fgAODHmpidRings))
+ {
+ TClonesArray* hmpidRings = aod->GetHMPIDrings();
+ new (fgAODHmpidRings) TClonesArray(*hmpidRings);
+ }
+
+
+
// Additional merging if needed
if (merging) {
Int_t nc;
// tracks
TClonesArray* tracks = aodH->GetEventToMerge()->GetTracks();
- if(tracks){
+ if(tracks && aodH->GetMergeTracks()){
Int_t ntr = tracks->GetEntries();
nc = fgAODTracks->GetEntries();
for (Int_t i = 0; i < ntr; i++) {
// clusters
TClonesArray* clusters = aodH->GetEventToMerge()->GetCaloClusters();
- if( clusters ){
+ if( clusters && (aodH->GetMergeEMCALClusters() || aodH->GetMergePHOSClusters())) {
Int_t ncl = clusters->GetEntries();
nc = fgAODCaloClusters->GetEntries();
for (Int_t i = 0; i < ncl; i++) {
AliAODCaloCluster* cluster = (AliAODCaloCluster*) clusters->At(i);
+ if(cluster->IsEMCAL() && !aodH->GetMergeEMCALClusters() ) continue;
+ if(cluster->IsPHOS() && !aodH->GetMergePHOSClusters() ) continue;
new((*fgAODCaloClusters)[nc++]) AliAODCaloCluster(*cluster);
}
}
// EMCAL cells
//*fgAODEmcalCells = *(aod->GetEMCALCells()); // This will be valid after 10.Mar.2011.
- {
- AliAODCaloCells* copycells = aod->GetEMCALCells();
- fgAODEmcalCells->CreateContainer(copycells->GetNumberOfCells());
- nc = copycells->GetNumberOfCells();
- while( nc-- ){ fgAODEmcalCells->SetCell(nc,copycells->GetCellNumber(nc),copycells->GetAmplitude(nc)); }
- }
- AliAODCaloCells* cellsA = aodH->GetEventToMerge()->GetEMCALCells();
- if( cellsA ){
- Int_t ncells = cellsA->GetNumberOfCells();
- nc = fgAODEmcalCells->GetNumberOfCells();
- for (Int_t i = 0; i < ncells; i++) {
- Int_t cn = cellsA->GetCellNumber(i);
- Int_t pos = fgAODEmcalCells->GetCellPosition(cn);
- if (pos >= 0) {
- Double_t amp = cellsA->GetAmplitude(i) + fgAODEmcalCells->GetAmplitude(pos);
- fgAODEmcalCells->SetCell(pos, cn, amp);
- } else {
- AliAODCaloCells* copycells = new AliAODCaloCells(*fgAODEmcalCells);
- fgAODEmcalCells->CreateContainer(nc+1);
- Int_t nn = copycells->GetNumberOfCells();
- while( nn-- ){ fgAODEmcalCells->SetCell(nn,copycells->GetCellNumber(nn),copycells->GetAmplitude(nn)); }
- fgAODEmcalCells->SetCell(nc++,cn,cellsA->GetAmplitude(i));
- delete copycells;
- }
- }
- fgAODEmcalCells->Sort();
- }
+ if(aodH->GetMergeEMCALCells())
+ {
+ AliAODCaloCells* copycells = aod->GetEMCALCells();
+ fgAODEmcalCells->CreateContainer(copycells->GetNumberOfCells());
+ nc = copycells->GetNumberOfCells();
+
+ while( nc-- ){ fgAODEmcalCells->SetCell(nc,copycells->GetCellNumber(nc),copycells->GetAmplitude(nc),
+ copycells->GetTime(nc),copycells->GetMCLabel(nc),copycells->GetEFraction(nc)); }
+
+ AliAODCaloCells* cellsA = aodH->GetEventToMerge()->GetEMCALCells();
+ if( cellsA )
+ {
+ Int_t ncells = cellsA->GetNumberOfCells();
+ nc = fgAODEmcalCells->GetNumberOfCells();
+
+ for (Int_t i = 0; i < ncells; i++)
+ {
+ Int_t cn = cellsA->GetCellNumber(i);
+ Int_t pos = fgAODEmcalCells->GetCellPosition(cn);
+
+ if (pos >= 0)
+ {
+ Double_t amp = cellsA->GetAmplitude(i) + fgAODEmcalCells->GetAmplitude(pos);
+
+ //Check if it is MC, depending on that assing the mc lable, time and e fraction
+ Double_t time = 0;
+ Int_t mclabel =-1;
+ Double_t efrac = 0;
+ if(cellsA->GetMCLabel(i) >= 0 && fgAODEmcalCells->GetMCLabel(i) < 0)
+ {
+ mclabel = cellsA->GetMCLabel(i) ;
+ time = fgAODEmcalCells->GetTime(i) ; // Time from data
+ if(amp > 0) efrac = cellsA->GetAmplitude(i) / amp;
+ }
+ else if(fgAODEmcalCells->GetMCLabel(i) >= 0 && cellsA->GetMCLabel(i) < 0)
+ {
+ mclabel = fgAODEmcalCells->GetMCLabel(i) ;
+ time = cellsA->GetTime(i) ; // Time from data
+ if(amp > 0) efrac = fgAODEmcalCells->GetAmplitude(i) / amp;
+ }
+ else
+ { // take all from input
+ mclabel = cellsA->GetMCLabel(i) ;
+ time = cellsA->GetTime(i) ;
+ if(amp > 0) efrac = cellsA->GetAmplitude(i) / amp;
+ }
+
+ fgAODEmcalCells->SetCell(pos, cn, amp,cellsA->GetTime(i),mclabel,efrac);
+
+ } else
+ {
+ AliAODCaloCells* copycells1 = new AliAODCaloCells(*fgAODEmcalCells);
+ fgAODEmcalCells->CreateContainer(nc+1);
+ Int_t nn = copycells1->GetNumberOfCells();
+
+ while( nn-- ){ fgAODEmcalCells->SetCell(nn,copycells1->GetCellNumber(nn),copycells1->GetAmplitude(nn),
+ copycells1->GetTime(nn),copycells1->GetMCLabel(nn),0.); }
+
+ fgAODEmcalCells->SetCell(nc++,cn,cellsA->GetAmplitude(i),cellsA->GetTime(i), cellsA->GetMCLabel(i),0.);
+
+ delete copycells1;
+ }
+ }
+ fgAODEmcalCells->Sort();
+ }
+ } // merge emcal cells
+
// PHOS cells
//*fgAODPhosCells = *(aod->GetPHOSCells()); // This will be valid after 10.Mar.2011.
+ if(aodH->GetMergePHOSCells())
+ {
+ AliAODCaloCells* copycells = aod->GetPHOSCells();
+ fgAODPhosCells->CreateContainer(copycells->GetNumberOfCells());
+ nc = copycells->GetNumberOfCells();
+
+ while( nc-- ){ fgAODPhosCells->SetCell(nc,copycells->GetCellNumber(nc),copycells->GetAmplitude(nc),
+ copycells->GetTime(nc),copycells->GetMCLabel(nc),copycells->GetEFraction(nc)); }
+
+ AliAODCaloCells* cellsP = aodH->GetEventToMerge()->GetPHOSCells();
+ if( cellsP )
+ {
+ Int_t ncellsP = cellsP->GetNumberOfCells();
+ nc = fgAODPhosCells->GetNumberOfCells();
+
+ for (Int_t i = 0; i < ncellsP; i++)
+ {
+ Int_t cn = cellsP->GetCellNumber(i);
+ Int_t pos = fgAODPhosCells->GetCellPosition(cn);
+
+ if (pos >= 0)
+ {
+ Double_t amp = cellsP->GetAmplitude(i) + fgAODPhosCells->GetAmplitude(pos);
+
+ //Check if it is MC, depending on that assing the mc lable, time and e fraction
+ Double_t time = 0;
+ Int_t mclabel =-1;
+ Double_t efrac = 0;
+ if(cellsP->GetMCLabel(i) >= 0 && fgAODPhosCells->GetMCLabel(i) < 0)
+ {
+ mclabel = cellsP->GetMCLabel(i) ;
+ time = fgAODPhosCells->GetTime(i) ; // Time from data
+ if(amp > 0) efrac = cellsP->GetAmplitude(i) / amp;
+ }
+ else if(fgAODPhosCells->GetMCLabel(i) >= 0 && cellsP->GetMCLabel(i) < 0)
+ {
+ mclabel = fgAODPhosCells->GetMCLabel(i) ;
+ time = cellsP->GetTime(i) ; // Time from data
+ if(amp > 0) efrac = fgAODPhosCells->GetAmplitude(i) / amp;
+ }
+ else
+ { // take all from input
+ mclabel = cellsP->GetMCLabel(i) ;
+ time = cellsP->GetTime(i) ;
+ if(amp > 0) efrac = cellsP->GetAmplitude(i) / amp;
+ }
+
+ fgAODPhosCells->SetCell(pos, cn, amp,cellsP->GetTime(i),mclabel,efrac);
+
+ } else
+ {
+ AliAODCaloCells* copycells1 = new AliAODCaloCells(*fgAODPhosCells);
+ fgAODPhosCells->CreateContainer(nc+1);
+ Int_t nn = copycells1->GetNumberOfCells();
+
+ while( nn-- ){ fgAODPhosCells->SetCell(nn,copycells1->GetCellNumber(nn),copycells1->GetAmplitude(nn),
+ copycells1->GetTime(nn),copycells1->GetMCLabel(nn),0.); }
+
+ fgAODPhosCells->SetCell(nc++,cn,cellsP->GetAmplitude(i),cellsP->GetTime(i), cellsP->GetMCLabel(i),0.);
+
+ delete copycells1;
+ }
+ }
+ fgAODPhosCells->Sort();
+ }
+ } // Merge PHOS Cells
+
+ if (aodH->GetMergeEMCALTrigger() && aod->GetCaloTrigger("EMCAL"))
{
- AliAODCaloCells* copycells = aod->GetPHOSCells();
- fgAODPhosCells->CreateContainer(copycells->GetNumberOfCells());
- nc = copycells->GetNumberOfCells();
- while( nc-- ){ fgAODPhosCells->SetCell(nc,copycells->GetCellNumber(nc),copycells->GetAmplitude(nc)); }
- }
- AliAODCaloCells* cellsP = aodH->GetEventToMerge()->GetPHOSCells();
- if( cellsP ){
- Int_t ncellsP = cellsP->GetNumberOfCells();
- nc = fgAODPhosCells->GetNumberOfCells();
-
- for (Int_t i = 0; i < ncellsP; i++) {
- Int_t cn = cellsP->GetCellNumber(i);
- Int_t pos = fgAODPhosCells->GetCellPosition(cn);
- if (pos >= 0) {
- Double_t amp = cellsP->GetAmplitude(i) + fgAODPhosCells->GetAmplitude(pos);
- fgAODPhosCells->SetCell(pos, cn, amp);
- } else {
- AliAODCaloCells* copycells = new AliAODCaloCells(*fgAODPhosCells);
- fgAODPhosCells->CreateContainer(nc+1);
- Int_t nn = copycells->GetNumberOfCells();
- while( nn-- ){ fgAODPhosCells->SetCell(nn,copycells->GetCellNumber(nn),copycells->GetAmplitude(nn)); }
- fgAODPhosCells->SetCell(nc++,cn,cellsP->GetAmplitude(i));
- delete copycells;
- }
- }
- fgAODPhosCells->Sort();
- }
+ Int_t tsEMCAL[48][64], px, py, ts;
+ Float_t foEMCAL[48][64], am;
+ for (Int_t i = 0; i < 48; i++) for (Int_t j = 0; j < 64; j++)
+ {
+ tsEMCAL[i][j] = 0;
+ foEMCAL[i][j] = 0.;
+ }
+
+ AliAODCaloTrigger& trg0 = *(aod->GetCaloTrigger("EMCAL"));
+ trg0.Reset();
+ while (trg0.Next())
+ {
+ trg0.GetPosition(px, py);
+
+ if (px > -1 && py > -1)
+ {
+ trg0.GetL1TimeSum(ts);
+ if (ts > -1) tsEMCAL[px][py] += ts;
+
+ trg0.GetAmplitude(am);
+ if (am > -1) foEMCAL[px][py] += am;
+ }
+ }
+
+ AliAODCaloTrigger& trg1 = *((aodH->GetEventToMerge())->GetCaloTrigger("EMCAL"));
+
+ trg1.Reset();
+ while (trg1.Next())
+ {
+ trg1.GetPosition(px, py);
+
+ if (px > -1 && py > -1)
+ {
+ trg1.GetL1TimeSum(ts);
+ if (ts > -1) tsEMCAL[px][py] += ts;
+
+ trg1.GetAmplitude(am);
+ if (am > -1) foEMCAL[px][py] += am;
+ }
+ }
+
+ int nEntries = 0;
+ for (Int_t i = 0; i < 48; i++)
+ for (Int_t j = 0; j < 64; j++)
+ if (tsEMCAL[i][j] || foEMCAL[i][j]) nEntries++;
+
+ fgAODEMCALTrigger->Allocate(nEntries);
+ Int_t timesL0[10]; for (int i = 0; i < 10; i++) timesL0[i] = -1;
+
+ for (Int_t i = 0; i < 48; i++)
+ for (Int_t j = 0; j < 64; j++)
+ if (tsEMCAL[i][j] || foEMCAL[i][j])
+ fgAODEMCALTrigger->Add(i, j, foEMCAL[i][j], -1., timesL0, 0, tsEMCAL[i][j], 0);
+ }
+
+ if (aodH->GetMergePHOSTrigger())
+ {
+ // To be implemented by PHOS
+ }
} // merging
handler->SetAODIsReplicated();