-- LuciaAnnaHusova - 2017-08-03


Analysis with NanoAODs

NanoAODs are duplicates of AODs on the Grid, which contain only the information about tracks and events, which is really used in the analysis. Thus the NanoAODs file size is smaller than for AODs, but these are extra files to be saved. The analysis on the NanoAODs can be multiple times faster than on AODs, so the CPU time is saved. The speed up depends on the fraction of the stored information.

Use Case of Nano AODs

NanoAODs can be used in these cases:

  • For the analysis only a limited subset of the AOD information is needed
  • Same event and track cuts are used for each analysis rerun
  • Derived variables are used, which need a long time to be calculated
  • Analysis takes a lot of computing time
  • Analysis is often repeated

Differences between AODs and NanoAODs

Only a few changes are needed in the AnalysisTask to use the NanoAOD s. The NanoAOD event information is stored in AliAODEvent and AliNanoAODHeader while the track information is stored in AliNanoAODTrack, as is shown in the table below.

AOD Analysis

Nano AOD Analysis

AliAODTrack AliNanoAODTrack
AliNanoAODTrack inherits from AliVTrack like AliAODTrack does. If the NanoAOD generation was done properly the track information can be accesed the same way like in AODs, e.g.:
AliNanoAODTrack *particle = new AliNanoAODTrack();
particle = (AliNanoAODTrack *) aodEvent->GetTrack(0); 
Double_t pt = particle->Pt();

Note: some functions are not implemented, so always check the class AliNanoAODTrack. Functions which were recently changed in AODTracks, might not have been changed in NanoAODTracks.

Some information, which is usually read from AliAODEvent, is stored in AliNanoAODHeader, e.g. centrality:
AliNanoAODHeader* head = (AliNanoAODHeader *)aodEvent -> GetHeader();
Double_t centV0M = head->GetCentr("V0M");

The easiest way to distinguish the NanoAOD dataset from other datasets in the analysis, is to check, if the Header inherits from AliNanoAODStorage. You can use this example:

TObject *head = event->GetHeader();
if(!head->InheritsFrom("AliNanoAODStorage")){ // this is for AOD/ESD
...
}
if(head->InheritsFrom("AliNanoAODStorage")){ // this is for nanoAOD
AliNanoAODHeader *nanohead = (AliNanoAODHeader*) head;
...
}

NanoAOD Generation

Which information can be stored

  • AliAODEvent
    • the primary vertex is always stored. Only in case the event is empty, the primary vertex isn't stored.
    • AliVZERO and AliAODZDC could be stored as well, but it should be added to the wagon settings:
__R_ADDTASK__->ReplicatorSaveVzero(kTRUE);
__R_ADDTASK__->ReplicatorSaveAODZDC(kTRUE);

Functions Needed paramters
Eta() theta
Px(), Py(), Pz() pt, theta, phi
P() pt, theta, phi
PropagateToDCA() posX, posY, covmat, MagField (in AliNanoAODHeader)
ZAtDCA() IsMuonTrack, posY, posZ
DCA() posDCAx, posDCAz, posx
    • Only the parameters are stored which are defined in the the wagon settings in the NanoAOD generation:

__R_ADDTASK__->SetVarList("pt,phi,theta,covmat");

  • AliNanoAODHeader
    • list of parameters, which can be stored:
      • centrality: TRK, CL0, CL1, V0M (CentrTRK,CentrCL0,CentrCL1,Centr)
      • magnetic field ( MagField)
      • run number (RunNumber)
    • Only the parameters are stored which are defined in the the wagon settings in the NanoAOD generation:

 __R_ADDTASK__->SetVarListHead("Centr,RunNumber");

How to implement new custom variables in the AliNanoAODTrack

The custom variables are all the variables which don't have a function in AliNanoAODTrack and differ from user to user.

The custom variables for AliNanoAODTrack should be implemented in the function AliNanoAODSimpleSetter ::SetNanoAODTrack (the class AliNanoAODSimpleSetter doesn't have its own file, it can be found in AliAnalysisNanoAODCuts ). Your own variables shouldn't be in this SimpleSetter , thus make a copy of AliAnalysisNanoAODCuts with a name AliAnalysisNanoAODCutsMyTask and implement the method SetNanoAODTrack in the way, you need for your analysis. All new variables can be stored only in the format of a Double_t. Here is an example of pt^2 and rapidity.

Pt^2 example

1. Get and compute your variable:

void AliNanoAODSimpleSetterMyTask::SetNanoAODTrack (const AliAODTrack * aodTrack, AliNanoAODTrack * spTrack) {
Double_t pt = aodTrack->Pt();
Double_t pt2 = TMath::Power(pt,2);

2. Get an index for this variable with which you can acces the variable. Remember, that the name has to begin with the prefix "cst":

static  Int_t Pt2Index  = AliNanoAODTrackMapping::GetInstance()->GetVarIndex("cstPt2");

3. Store the variable in the new AliNanoAODTrack

spTrack->SetVar(Pt2Index,pt2);

4. Define your setter and this variable in the wagon settings. The name of the variable has to be the same as in 2.:

AliNanoAODSimpleSetterMyTask* setter = new AliNanoAODSimpleSetterMyTask();
__R_ADDTASK__->SetSetter(setter);
__R_ADDTASK__->SetVarList("... cstPt2 ... ");

5. Finally use your custom variable in your AnalysisTask. Get the variable index at the begining of the task, so it does not need to be searched for every track separately

const Int_t pt2Index =AliNanoAODTrackMapping::GetInstance()->GetVarIndex("cstPt2");
...
AliNanoAODTrack *nanoTrack = AliAODEvent -> GetTrack(i);
Double_t pt2 = nanoTrack->GetVar(pt2Index);
...

Rapidity example

1. Get and compute your variable in the method SetNanoAODTrack:

AODTrkPID_t trPID = aodTrack->GetMostProbablePID();
Double_t rapidity = aodTrack->Y(trPID);

2. Get an index for this variable

static  Int_t rapidityIndex  = AliNanoAODTrackMapping::GetInstance()->GetVarIndex("cstY");

3. Store the variable in the new AliNanoAODTrack

spTrack->SetVar(rapidityIndex,rapidity);

4. Define your setter and this variable in the wagon settings.The name of the variable has to be the same as in 2.:

AliNanoAODSimpleSetterMyTask* setter = new AliNanoAODSimpleSetterMyTask();
__R_ADDTASK__->SetSetter(setter);
__R_ADDTASK__->SetVarList("... cstY ... ");

5. Finally use your custom variable in your AnalysisTask

...
AliNanoAODTrack *nanoTrack = AliAODEvent -> GetTrack(i);
Double_t rapidity = nanoTrack->GetVar(AliNanoAODTrackMapping::GetInstance()->GetVarIndex("cstY"));
...

How to implement a new custom variable in the AliNanoAODHeader

The AliNanoAODHeader is set by the method AliNanoAODSimpleSetter::SetNanoAODHeader. The new custom variables have to be defined and added to the array of header variables in AliNanoAODSimpleSetter. The procedure is very similar to the one of implementing a new variable in the AliNanoAODTrack. If you have not already made a copy of AliNanoAODCuts, do so and implement the custom variable in the method SetNanoAODHeader. Here is an example for the variable Pile-Up:

1. Copy your own Pile-Up function to the class AliNanoAODSimpleSetterMyTask:

Bool_t AliNanoAODSimpleSetterMyTask::MyPileUpInfo(AliAODEvent* event){
    Bool_t pass = kTRURE;
    ...
    return pass;
}

2. Get an index for this variable:

 static Int_t pileUpIndex = head->GetVarIndex("cstPileUp");

3. Store the variable in the AliNanoAODHeader (Here variables can only be stored in a format of a Double_t, for Bool_t store 0 or 1 ):

Bool_t isPileUp = MyPileUpInfo(event);
if (isPileUp) head->SetVar(pileUpIndex,1.);
else head->SetVar(pileUpIndex,0.);

4. Add this variable in the wagon settings:

__R_ADDTASK__->SetVarListHead(" ... cstPileUp, ... "); 

5. Use the new variable in your AnalysisTask:

AliNanoAODHeader *nanoHeader = (AliNanoAODHeader*) event -> GetHeader();
Double_t pileUp = nanoHeader->GetVar(nanoHeader->GetVarIndex("cstPileUp"));

Events and track cuts

All cuts can be done as usually in the analysis. For this many variables have to be stored in NanoAODs. So NanoAODs become more complex and the size of the file become bigger, but it can be used by more users.

Some or all cuts could be done during the generation of NanoAODs as well. In this case, all the useless events and tracks aren't stored, so the size of NanoAOD files is smaller and the analysis can be executed faster.

Some cuts are already implemented:

  • Track cuts
  • Event cuts
    • Vertex range
    • Multiplicity range

These cuts could be set in the train configuration:

AliAnalysisNanoAODTrackCuts* trk = new AliAnalysisNanoAODTrackCuts;
trk->SetBitMask((1 << 8) | (1 << 9)); // hybrid 2011
trk->SetMaxEta(0.9);
trk->SetMinPt(1.0);

AliAnalysisNanoAODEventCuts* evt = new AliAnalysisNanoAODEventCuts;
evt->SetVertexRange(8);
__R_ADDTASK__->SetTrkCuts(trk);
__R_ADDTASK__->SetEvtCuts(evt);

NanoAODs with customised cuts

The best way to implement customised cuts in the NanoAOD generation, is to create a copy of AliAnalysisNanoAODCuts in the folder $ALICE_PHYSICS/PWG/DevNanoAOD where all the cuts could be implemented. If you have done the copy to implement some custom variables, use the same file to implemt the cuts.

The new cuts can be defined in the wagon settings. At the end the cuts have to be added to the AliAnalysisTaskNanoAODFilter :

AliAnalysisNanoAODEventCutsMyTask* evt = new AliAnalysisNanoAODEventCutsMyTask;
evt->SetVertexRange(8);
evt->SetSpecialCut(kTRUE);
__R_ADDTASK__->SetEvtCuts(evt);

Local generation of NanoAODs

NanoAODs can be generated locally with the Local train test. All files could be downloaded directly from the train configuration, if such a train already exists, or you can find example files on the bottom of this page:

  • MLTrainDefinition.cfg is a configuration for the train. You'll have to add the AddTaskNanoAODFilter.C macro and define the event and track cuts, which should be used during the NanoAODs generation. Afterwards you'll have to define a setter for the AliNanoAODHeader and all the variables, which you want to be stored in AliNanoAODTrack and AliNanoAODHeader. Here is an example, how such a NanoAODGeneretion task could look like:

    Screen_Shot_2017-08-21_at_16.46.09.png

  • handlers.C: You'll have to add an OutputHandler here, as in the example below:

    Screen_Shot_2017-08-07_at_09.16.03.png

  • env.sh: Here you'll need to configure the train environment. The dataset is selected here and the whole train configuration is done, e.g. the AliPhysics version and the run number are selected. You can just download the file from train test running on the datasets, which you want to generate the NanoAODs from. This train does not need to generate NanoAODs.
  • generate.C: The number of input files can be changed here. Otherwise no changes are needed here. Download this file and the runTest.sh from Local train test .
  • generator_customization.C and runTest.sh: no further changes are needed here
  • globalveriables.C: take from the train you want to run in. A basic example is on the bottom of this page.

To run the local NanoAODs generation, you'll have to initialise the correct version of Root, AliRoot and AliPhysics and to run the runTest.sh. You will need the AliEn connection to download the input files. They will be saved in the same folder as runTest.sh. A new text file will be created pointing to the input files.

Generation of NanoAODs on the Grid

The procedure is the same as for normal analysis train runs, only a few changes are needed. The OutputHandler has to be defined additionally to the AOD handler and the PWG/DevNanoAOD/AddTaskNanoAODFilter.C should be used as the wagon AddTask macro.

Screen_Shot_2017-08-07_at_10.10.02.png

In the NanoAOD wagon setting, the variables and the cuts should be defined. The important variable configuration is highlighted in red.

Screen_Shot_2017-08-07_at_10.10.12.png

By starting a new train run the dataset should be selected, which you want to create your derived dataset from. Remember to mark the checkboxes derived data production and slow train.

Screen_Shot_2017-08-10_at_16.48.11.png

The output files are not merged and they are kept for 2 months on the Grid. If you want the files to be kept for longer, the operator can define it. Mark the check box "keep longer than 2 months". If you don't want to use the derived dataset anymore, please delete it by unmark this checkbox in the correspondent train run.

Screen_Shot_2017-08-21_at_17.09.50.png

When you want to start a new analysis with the derived dataset, it has to be define as a new dataset.

Screen_Shot_2017-08-10_at_16.48.54.png

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatcfg MLTrainDefinition.cfg r1 manage 1.3 K 2017-08-10 - 16:34 LuciaAnnaHusova  
Unix shell scriptsh env.sh r1 manage 1.6 K 2017-08-10 - 16:30 LuciaAnnaHusova  
C source code filec generator_customization.C r1 manage 0.1 K 2017-08-10 - 16:30 LuciaAnnaHusova  
C source code filec globalvariables.C r1 manage 0.1 K 2017-08-10 - 16:30 LuciaAnnaHusova  
C source code filec handlers.C r1 manage 0.4 K 2017-08-10 - 16:30 LuciaAnnaHusova  
Edit | Attach | Watch | Print version | History: r20 < r19 < r18 < r17 < r16 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r20 - 2017-08-23 - LuciaAnnaHusova
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Sandbox All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback