Write the output tree in the AOD format (Filip Krizek)
authorkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 22 Jun 2010 07:35:47 +0000 (07:35 +0000)
committerkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 22 Jun 2010 07:35:47 +0000 (07:35 +0000)
PWG4/JCORRAN/AliJCORRANTask.cxx
PWG4/JCORRAN/AliJCORRANTask.h
PWG4/macros/AddTaskJCORRANTask.C

index 6f0852f..6af95b9 100755 (executable)
@@ -37,6 +37,7 @@
 #include <TNtuple.h>
 
 #include "AliAnalysisTaskSE.h"
+#include "AliAODHandler.h"
 
 #include "AliJCORRANTask.h" 
 #include "AliAnalysisManager.h"
 AliJCORRANTask::AliJCORRANTask() :   
   AliAnalysisTaskSE("PWG4JCORRAN"),
   fInputFormat(0),
-  fEsdTrackCuts(0), //FK//
-  fDownscaling(0),//FK//
-  fLowerCutOnLPMom(0),//FK//
-  fLowerCutOnLeadingCaloClusterE(0),//FK//
-  fTree(0x0),
+  fEsdTrackCuts(0), 
+  fDownscaling(1),
+  fLowerCutOnLPMom(0),
+  fLowerCutOnLeadingCaloClusterE(0), 
+  fLowerCutOnCaloClusterE(0.2),
+  fIsRealOrMC(0),
+  fAODName("jcorran.root"),
   fTrackList(0x0),
-  //fMCTrackList(0),
+  fMCTrackList(0x0),
   fPhotonList(0x0),
   fHeaderList(0x0),
   fAliRunHeader(0x0),
-  fQAList(0x0),
-  fTrackQACuts(0x0),
-  fTrackKineCuts(0x0),
   fPHOSGeom(0x0),
   fEMCALGeom(0x0)
 {
@@ -105,22 +105,21 @@ AliJCORRANTask::AliJCORRANTask() :
 }
 
 //______________________________________________________________________________
-AliJCORRANTask::AliJCORRANTask(const char *name, TString inputformat, AliESDtrackCuts* esdTrackCuts, Int_t downSc, Double_t lowLPmom, Double_t lowCaloE) : 
+AliJCORRANTask::AliJCORRANTask(const char *name, TString inputformat) : 
   AliAnalysisTaskSE(name), 
   fInputFormat(inputformat),  
-  fEsdTrackCuts(esdTrackCuts), //FK//
-  fDownscaling(downSc),//FK//
-  fLowerCutOnLPMom(lowLPmom),//FK//
-  fLowerCutOnLeadingCaloClusterE(lowCaloE),//FK//
-  fTree(0x0),
+  fEsdTrackCuts(0),    // to be set by setters in AddAliJCORRANTask macro
+  fDownscaling(1),
+  fLowerCutOnLPMom(0),
+  fLowerCutOnLeadingCaloClusterE(0),
+  fLowerCutOnCaloClusterE(0.2),
+  fIsRealOrMC(0),
+  fAODName("jcorran.root"),
   fTrackList(0x0),
-  //fMCTrackList(0),
+  fMCTrackList(0x0),
   fPhotonList(0x0),
   fHeaderList(0x0),
   fAliRunHeader(0x0),
-  fQAList(0x0),
-  fTrackQACuts(0x0),
-  fTrackKineCuts(0x0),
   fPHOSGeom(0x0),
   fEMCALGeom(0x0)
 {
@@ -133,7 +132,7 @@ AliJCORRANTask::AliJCORRANTask(const char *name, TString inputformat, AliESDtrac
   DefineInput (0, TChain::Class());
 
   fTrackList    = new AliPhJTrackList(kALICE);
-  //fMCTrackList  = new AliPhJMCTrackList(kALICE);
+  fMCTrackList  = new AliPhJMCTrackList(kALICE);
   fPhotonList   = new AliPhJPhotonList(kALICE);
   fHeaderList   = new AliPhJHeaderList(kALICE);
   
@@ -143,28 +142,24 @@ AliJCORRANTask::AliJCORRANTask(const char *name, TString inputformat, AliESDtrac
   fEMCALGeom = new AliEMCALGeoUtils("EMCAL_COMPLETE");
   
 
-  DefineOutput(1, TTree::Class()); 
-  DefineOutput(2, TList::Class());
-
 }
 
 //____________________________________________________________________________
 AliJCORRANTask::AliJCORRANTask(const AliJCORRANTask& ap) :
   AliAnalysisTaskSE(ap.GetName()), 
   fInputFormat(ap.fInputFormat),
-  fEsdTrackCuts(ap.fEsdTrackCuts), //FK// 
-  fDownscaling(ap.fDownscaling),  //FK// 
-  fLowerCutOnLPMom(ap.fLowerCutOnLPMom), //FK// 
-  fLowerCutOnLeadingCaloClusterE(ap.fLowerCutOnLeadingCaloClusterE),  //FK// 
-  fTree(ap.fTree),
+  fEsdTrackCuts(ap.fEsdTrackCuts), 
+  fDownscaling(ap.fDownscaling),   
+  fLowerCutOnLPMom(ap.fLowerCutOnLPMom),  
+  fLowerCutOnLeadingCaloClusterE(ap.fLowerCutOnLeadingCaloClusterE),  
+  fLowerCutOnCaloClusterE(ap.fLowerCutOnCaloClusterE),
+  fIsRealOrMC(ap.fIsRealOrMC),
+  fAODName(ap.fAODName),
   fTrackList(ap.fTrackList),
-  //fMCTrackList(ap.fMCTrackList),
+  fMCTrackList(ap.fMCTrackList),
   fPhotonList(ap.fPhotonList),
   fHeaderList(ap.fHeaderList),
   fAliRunHeader(ap.fAliRunHeader),
-  fQAList(ap.fQAList),
-  fTrackQACuts(ap.fTrackQACuts),
-  fTrackKineCuts(ap.fTrackKineCuts),
   fPHOSGeom(ap.fPHOSGeom),
   fEMCALGeom(ap.fEMCALGeom)
 { 
@@ -172,7 +167,7 @@ AliJCORRANTask::AliJCORRANTask(const AliJCORRANTask& ap) :
 }
 
 //_____________________________________________________________________________
-AliJCORRANTask& AliJCORRANTask::operator = (const AliJCORRANTask& ap)
+AliJCORRANTask& AliJCORRANTask::operator= (const AliJCORRANTask& ap)
 {
 // assignment operator
 
@@ -187,65 +182,35 @@ AliJCORRANTask::~AliJCORRANTask()
   // destructor 
   
   delete fTrackList;
-  //delete fMCTrackList;
+  if(fMCTrackList) delete fMCTrackList;
   delete fPhotonList;
   delete fHeaderList;
   delete fAliRunHeader;
-  delete fTree;
-  
-  delete fQAList;
-  delete fTrackQACuts;
-  delete fTrackKineCuts;
-  if(fPHOSGeom)  delete fPHOSGeom  ;
-  if(fEMCALGeom) delete fEMCALGeom ;
+  if(fPHOSGeom)  delete fPHOSGeom;
+  if(fEMCALGeom) delete fEMCALGeom;
 
 }
 
 //________________________________________________________________________
 void AliJCORRANTask::UserCreateOutputObjects()
 {  
-  // create the jcorran outputs objects
-  if(fDebug > 5) cout << "AliJCORRANTask UserCreateOutputObjects----------------------"<<endl;
-  OpenFile(1) ;   // Will open the file for the object to be written at output #1
+  // create the jcorran output deltaAOD
+  //if(fDebug > 5) cout << "AliJCORRANTask UserCreateOutputObjects----------------------"<<endl;
   
-  fTree = new TTree("T","ALICE JYU CORRAN");
-  fTree->Branch("JTKT/JTrackList","AliPhJTrackList",&fTrackList,500000);
-  //fTree->Branch("JTKT/JMCTrackList","AliPhJMCTrackList",&fMCTrackList,500000);
-  fTree->Branch("JTKT/JPhotonList","AliPhJPhotonList",&fPhotonList,500000);
-  fTree->Branch("JTKT/JHeaderList","AliPhJHeaderList",&fHeaderList,500000);
-
-  //QA histgrams
-  // Offline Trigger QA
-  OpenFile(2) ; // Will open the file for the object to be written at output #2
-  TString trackQAlist = "MinNClusterTPC:";
-          trackQAlist+= "MinNClustersITS:";
-          trackQAlist+= "MaxChi2PerClusterTPC:";
-          trackQAlist+= "MaxChi2PerClusterITS:";
-          trackQAlist+= "RequireTPCRefit:";
-          trackQAlist+= "RequireITSRefit:";
-          trackQAlist+= "AcceptKinkDaughters:";
-          trackQAlist+= "MaxCovMatrixDiag11:";
-          trackQAlist+= "MaxCovMatrixDiag22:";
-          trackQAlist+= "MaxCovMatrixDiag33:";
-          trackQAlist+= "MaxCovMatrixDiag44:";
-          trackQAlist+= "MaxCovMatrixDiag55:";
-          trackQAlist+= "MaxNsigmaToVertex:";
-          trackQAlist+= "RequireSigmaToVertex";
-          
-  TString trackKinelist = "PMin:PMax:";
-          trackKinelist+= "PtMin:PtMax:";
-          trackKinelist+= "PxMin:PxMax:";
-          trackKinelist+= "PyMin:PyMax:";
-          trackKinelist+= "PzMin:PzMax:";
-          trackKinelist+= "EtaMin:EtaMax:";
-          trackKinelist+= "RapMin:RapMax";
-                        
-  fTrackQACuts    = new TNtuple("TrackQACuts", "track quality cuts applied on ESD",trackQAlist.Data());
-  fTrackKineCuts  = new TNtuple("TrackKineCuts", "kinematic cuts applied on ESD", trackKinelist.Data());
-  fQAList = new TList(); 
-  fQAList->SetName("ESD QA List") ; 
-  fQAList->AddAt(fTrackQACuts,   0) ; 
-  fQAList->AddAt(fTrackKineCuts, 1) ; 
+  if(fDebug > 1) printf("AliJCORRANTask::UserCreateOutPutData() \n");
+  if(!AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()) {
+    Fatal("UserCreateOutputObjects", "This task needs an AOD handler");
+    return;
+  }   
+
+
+  AddAODBranch("AliPhJTrackList", &fTrackList,fAODName.Data());
+  AddAODBranch("AliPhJPhotonList", &fPhotonList,fAODName.Data());
+  AddAODBranch("AliPhJHeaderList", &fHeaderList,fAODName.Data()); 
+
+  if(fIsRealOrMC){ 
+    AddAODBranch("AliPhJMCTrackList", &fMCTrackList);
+  }
   
 }
 
@@ -256,17 +221,31 @@ void AliJCORRANTask::UserExec(Option_t */*option*/)
   //if(fDebug > 5) cout << "------- AliJCORRANTask Exec-------"<<endl;
   if(!((Entry()-1)%100)) 
       AliInfo(Form(" Processing event # %lld",  Entry())); 
+  Bool_t storeEvent = kFALSE;//based on offline trigger decide whetehr to store the event or not 
+  if(fIsRealOrMC){
+    storeEvent = kTRUE; //store all MC events
+  }else{ //when we are processing real events store only selected events
+    if(StoreDownscaledMinBiasEvent() || 
+      ContainsESDHighPtTrack()   || 
+      ContainsESDHighECaloClusters()){
+        storeEvent = kTRUE; 
+    }
+  }
 
-   
+  fTrackList->Reset();
+  fMCTrackList->Reset();
+  fPhotonList->Reset();
+  fHeaderList->Reset();
  
+
   static int runId=-1;
  
   if(fInputFormat=="ESD"){
    //  if(fDebug > 5) cout <<"--------- Reading ESD --------"<< endl; 
      AliESDEvent* esd = (AliESDEvent*)InputEvent();
 
-     //AliMCEvent* fmcEvent = MCEvent();
-     //ReadMCTracks(fmcEvent);
+     AliMCEvent* mcEvent = NULL; 
+     if(fIsRealOrMC)  mcEvent = MCEvent();
 
 
      //=========== FILL AND STORE RUN HEADER   (ONLY ONCE PER RUN) =============
@@ -293,53 +272,41 @@ void AliJCORRANTask::UserExec(Option_t */*option*/)
        fAliRunHeader->SetL3Field(l3MgFieldPolarity, esd->GetMagneticField());
        fAliRunHeader->SetActiveTriggersJCorran(fTriggerTableJCorran,kRangeTriggerTableJCorran);
 
-      //Store Run header
-      (fTree->GetUserInfo())->Add(fAliRunHeader);   
+       //Store Run header
+       (OutputTree()->GetUserInfo())->Add(fAliRunHeader);  //FK// 
     }
 
-
-    if( StoreDownscaledMinBiasEvent() || ContainsESDHighPtTrack(esd) || ContainsESDHighECaloClusters(esd) ){ //FK//
+    if(storeEvent){ 
       //-------------- reset all the arrays -------------
-      fTrackList->Reset();
-      //fMCTrackList->Reset();
-      fPhotonList->Reset();
-      fHeaderList->Reset();
-      //store event only when it is downscaled min bias
+         //store event only when it is downscaled min bias
       // or contais high pt hadron
       // or contains high energy cluster in EMCAL or PHOS
-        ReadESDTracks(esd);
-        ReadESDCaloClusters(esd);
-        ReadESDHeader(esd);
-
-        fTree->Fill(); // fill the TTree
-        PostData(1, fTree);
+      ReadESDTracks(esd);
+      ReadESDCaloClusters(esd);
+      ReadESDHeader(esd);
+      if(fIsRealOrMC) ReadMCTracks(mcEvent);
     }
-  }else{
+  }else if( fInputFormat == "AODout" || fInputFormat == "AODin") {
   
-       AliAODEvent* aod;
-       if(fInputFormat == "AODout") // reading from AOD output handler
-         aod = AODEvent();
-       else 
-         if(fInputFormat == "AODin") // reading from AOD input handler
-            aod = (AliAODEvent*)InputEvent();
-         else{
-            cout << "Error: Not correct InputDataFormat especified " << endl;
-            return;
-         }
+    AliAODEvent* aod = NULL;
+    if(fInputFormat == "AODout"){ // reading from AOD output handler
+      aod = AODEvent();
+    }else if(fInputFormat == "AODin"){ // reading from AOD input handler
+      aod = (AliAODEvent*)InputEvent();
+    }
+
+    if(storeEvent){ 
+      //-------------- reset all the arrays -------------
          
-     ReadAODTracks(aod);
-     ReadAODCaloClusters(aod);
-     ReadAODHeader(aod);
-     fTree->Fill(); // fill the TTree
-     PostData(1, fTree);
+      ReadAODTracks(aod);
+      ReadAODCaloClusters(aod);
+      ReadAODHeader(aod);
+    }
     
+  }else{
+    cout << "Error: Not correct InputDataFormat especified " << endl;
+    return;
   }
-
-  
 }
 
 //______________________________________________________________________________
@@ -354,12 +321,14 @@ void AliJCORRANTask::Init()
 void AliJCORRANTask::Terminate(Option_t *)
 {
   // Processing when the event loop is ended
-  fTree->Print();
+  OutputTree()->Print(); 
   if(fInputFormat == "AODout") ReadFilter(); // change it to save this info also from AODin !!!! 
 
-  ((AliJRunHeader *) (fTree->GetUserInfo())->First())->PrintOut();  
+  ((AliJRunHeader *) (OutputTree()->GetUserInfo())->First())->PrintOut();  
 
   cout<<"PWG4JCORRAN Analysis DONE !!"<<endl; 
+
+
 }
 
 //______________________________________________________________________________
@@ -378,7 +347,7 @@ void AliJCORRANTask::ReadESDTracks(const AliESDEvent * esd)
     for(Int_t it = 0; it < nt; it++) { 
 
         AliESDtrack *track = esd->GetTrack(it);
-        if(! fEsdTrackCuts->IsSelected(track)) continue; //FK// apply loose selection criteria
+        if(! fEsdTrackCuts->IsSelected(track)) continue; //apply quality selection criteria
 
         UInt_t status = track->GetStatus();
            
@@ -395,7 +364,6 @@ void AliJCORRANTask::ReadESDTracks(const AliESDEvent * esd)
        Int_t nFindableClust = track->GetTPCNclsF();
        Float_t tpcChi2PerCluster = 0.;
        if(nClust>0.) tpcChi2PerCluster = track->GetTPCchi2()/Float_t(nClust);
-
        Float_t tpcClustPerFindClust = 0.;
        if(nFindableClust>0.) tpcClustPerFindClust = Float_t(nClust)/nFindableClust;
         //--------------------------------
@@ -418,6 +386,9 @@ void AliJCORRANTask::ReadESDTracks(const AliESDEvent * esd)
         extDiaCov[3]=extCov[9];
         extDiaCov[4]=extCov[14];
 
+      //  Int_t itsLabel = track->GetITSLabel(); //FK//
+      //  Int_t tpcLabel = track->GetTPCLabel(); //FK//   
+
         //create a new AliJTrack and fill the track info
        fTrackList->AddAliJTrack(ntrk);
        AliJTrack *ctrack = fTrackList->GetAliJTrack(ntrk);
@@ -427,7 +398,7 @@ void AliJCORRANTask::ReadESDTracks(const AliESDEvent * esd)
         ctrack->SetTheta(p3.Theta());
         ctrack->SetPhi(p3.Phi());
         ctrack->SetPID(pid);
-        ctrack->SetFlavor(kHadron);
+        ctrack->SetFlavor(kNone);//kHadron);
        ctrack->SetCharge(track->Charge());
         ctrack->ConvertAliPID();
         ctrack->SetEta(eta);
@@ -448,6 +419,10 @@ void AliJCORRANTask::ReadESDTracks(const AliESDEvent * esd)
         ctrack->SetStatus(status);
         ctrack->SetExternalDiaCovariance(extDiaCov);
 
+      //  ctrack->SetITSLabel(itsLabel);//FK//
+      //  ctrack->SetTPCLabel(tpcLabel);//FK//
+
+
        fTrackList->SetNTracks(++ntrk);
 
      } // end tracks loop
@@ -470,16 +445,21 @@ void AliJCORRANTask::ReadAODTracks(const AliAODEvent * aod)
        fTrackList->AddAliJTrack(ntrk);
         AliJTrack *ctrack = fTrackList->GetAliJTrack(ntrk);
 
+        ctrack->SetPtot(track->P());
         ctrack->SetPt(track->Pt());
         ctrack->SetTheta(track->Theta());
         ctrack->SetPhi(track->Phi());
+        ctrack->SetEta(track->Eta());
         ctrack->SetPID((Double_t*)track->PID());
-        ctrack->SetFlavor(kHadron);
+        ctrack->SetFlavor(kNone); //kHadron);
         ctrack->SetCharge(track->Charge());
         ctrack->SetChi2perNDF(track->Chi2perNDF());
         ctrack->SetChi2Trig(track->GetChi2MatchTrigger());
         ctrack->SetRecFlags(track->GetFlags());
-        
+      
+       
+       // ctrack->SetITSLabel(track->GetLabel());//FK//?
+      //  ctrack->SetTPCLabel(track->GetLabel());//FK//?
        fTrackList->SetNTracks(++ntrk);
 
      } // end tracks loop
@@ -497,7 +477,7 @@ void AliJCORRANTask::ReadESDCaloClusters(const AliESDEvent* esd)
     AliESDCaloCluster *caloCluster = esd->GetCaloCluster(icluster) ;
     if(!caloCluster) continue;
     if(caloCluster->GetTrackMatched()==-1){
-      if(caloCluster->E()<0.2) continue;                  //FK//
+      if(caloCluster->E()<fLowerCutOnCaloClusterE) continue;                  //FK//
       // we will not implement any PID cut here      
       fPhotonList->AddAliJPhoton(nPhotons);
       AliJPhoton *pht = fPhotonList->GetAliJPhoton(nPhotons);
@@ -524,8 +504,6 @@ void AliJCORRANTask::ReadESDCaloClusters(const AliESDEvent* esd)
       pht->SetCellsAbsId(caloCluster->GetCellsAbsId());
       Int_t imoduleID = GetSuperModuleNumber(caloCluster->IsEMCAL(), caloCluster->GetCellAbsId(0));
       pht->SetSuperModuleID(imoduleID);
-  //    char buffer[20] = "photon";  
- //     pht->PrintOut(buffer);
       
       fPhotonList->SetNPhotons(++nPhotons);
     } // end if 
@@ -585,8 +563,6 @@ void AliJCORRANTask::ReadESDHeader(const AliESDEvent *esd)
     //create a header and fill it
     fHeaderList->AddAliJHeader(nHeaders);
     AliJHeader *hdr = fHeaderList->GetAliJHeader(nHeaders);
-
-    //cout << esd->GetRunNumber() <<"\t"<< esd->GetEventNumberInFile() << endl;
        
     AliMultiplicity *fSPDMult =(AliMultiplicity *) esd->GetMultiplicity();
     hdr->SetSPDTrackletMult(fSPDMult->GetNumberOfTracklets());
@@ -607,70 +583,24 @@ void AliJCORRANTask::ReadESDHeader(const AliESDEvent *esd)
 void AliJCORRANTask::ReadAODHeader(const AliAODEvent *aod)
 {
   //read AOD event header
-    Short_t nHeaders = 0;
-       //create a header and fill it
-       fHeaderList->AddAliJHeader(nHeaders);
-       AliJHeader *hdr = fHeaderList->GetAliJHeader(nHeaders);
-       
-       //load aod event header
-       AliAODHeader * aodh = aod->GetHeader();
-
-       hdr->SetCentrality(int(aodh->GetCentrality())); 
-       
-       hdr->SetTriggerMaskAlice(aodh->GetTriggerMask()); //ULong64_t
-       hdr->SetEventType(aodh->GetEventType());
+  Short_t nHeaders = 0;
+  //create a header and fill it
+  fHeaderList->AddAliJHeader(nHeaders);
+  AliJHeader *hdr = fHeaderList->GetAliJHeader(nHeaders);
+        
+  //load aod event header
+  AliAODHeader * aodh = aod->GetHeader();
+
+  hdr->SetCentrality(int(aodh->GetCentrality())); 
+  
+  hdr->SetTriggerMaskAlice(aodh->GetTriggerMask()); //ULong64_t
+  hdr->SetTriggerMaskJCorran(ConvertTriggerMask(/*esd->GetTriggerMask()*/)); //UInt_t
+  hdr->SetEventType(aodh->GetEventType());
        
-       fHeaderList->SetNHeaders(++nHeaders);
+  fHeaderList->SetNHeaders(++nHeaders);
 }
 
 //______________________________________________________________________________
-void AliJCORRANTask::ReadFilter()
-{
-   //read filter 
-   TList* olist = OutputTree()->GetUserInfo();
-   AliAnalysisFilter* trackFilter = (AliAnalysisFilter*)olist->At(0);
-   
-   if(!trackFilter) return;
-   
-   TList* cutslist = trackFilter->GetCuts();
-   //cout << "number of cuts " << cutslist->GetSize();
-   for(int ic = 0; ic< cutslist->GetSize(); ic++){
-       AliESDtrackCuts* icuts = (AliESDtrackCuts*)cutslist->At(ic);
-     
-       // read ESD track quality cuts
-       Float_t trkcut[14];
-       trkcut[0] = (Float_t)icuts->GetMinNClusterTPC();
-       trkcut[1] = (Float_t)icuts->GetMinNClustersITS();
-       trkcut[2] = (Float_t)icuts->GetMaxChi2PerClusterTPC();
-       trkcut[3] = (Float_t)icuts->GetMaxChi2PerClusterITS();
-       trkcut[4] = (Float_t)icuts->GetRequireTPCRefit();
-       trkcut[5] = (Float_t)icuts->GetRequireITSRefit();
-       trkcut[6] = (Float_t)icuts->GetAcceptKinkDaughters();
-       icuts->GetMaxCovDiagonalElements(trkcut[7],trkcut[8],trkcut[9],trkcut[10],trkcut[11]);
-       trkcut[12] = (Float_t)icuts->GetMaxNsigmaToVertex();
-       trkcut[13] = (Float_t)icuts->GetRequireSigmaToVertex();
-     
-       fTrackQACuts->Fill(trkcut);
-       
-       // read track kinmatic cuts
-       Float_t kinecut[14];
-       icuts->GetPRange(kinecut[0], kinecut[1]);
-       icuts->GetPtRange(kinecut[2], kinecut[3]);
-       icuts->GetPxRange(kinecut[4], kinecut[5]);
-       icuts->GetPyRange(kinecut[6], kinecut[7]);
-       icuts->GetPzRange(kinecut[8], kinecut[9]);
-       icuts->GetEtaRange(kinecut[10], kinecut[11]);
-       icuts->GetRapRange(kinecut[12], kinecut[13]);
-       
-       fTrackKineCuts->Fill(kinecut);
-       
-  
-   } // end cuts loop
-   
-   PostData(2,fQAList);
-}
-//______________________________________________________________________________
 Int_t AliJCORRANTask::GetSuperModuleNumber(bool isemcal, Int_t absId)
 {
   //get super module number 
@@ -718,19 +648,45 @@ bool AliJCORRANTask::StoreDownscaledMinBiasEvent(){
   }
   return isThisEventToBeStored;
 }
+
 //______________________________________________________________________________
-bool AliJCORRANTask::ContainsESDHighPtTrack(const AliESDEvent* esd){
-  bool isThisEventToBeStored = kFALSE;
+bool AliJCORRANTask::ContainsESDHighPtTrack(){
 
-  Int_t nt = esd->GetNumberOfTracks();
+  bool isThisEventToBeStored = kFALSE; //initialize return value
 
-  for(Int_t it = 0; it < nt; it++) {
-    AliESDtrack *track = esd->GetTrack(it);
-    //Does event contain high pt particle above 2 GeV 
-    //which fulfills loose track selection criteria 
-    if(track->Pt() > fLowerCutOnLPMom && fEsdTrackCuts->IsSelected(track)){
-      isThisEventToBeStored = kTRUE;
-      break; 
+  if(fInputFormat=="ESD"){
+
+    AliESDEvent* esd = NULL; 
+    esd = (AliESDEvent*)InputEvent();
+
+    Int_t nt = esd->GetNumberOfTracks();
+
+    for(Int_t it = 0; it < nt; it++) {
+      AliESDtrack *track = esd->GetTrack(it);
+      //Does event contain high pt particle above thereshold in GeV 
+      if(track->Pt() > fLowerCutOnLPMom && fEsdTrackCuts->IsSelected(track)){
+        isThisEventToBeStored = kTRUE;
+        break; 
+      }
+    }
+  }else{
+
+    AliAODEvent* aod=NULL;
+    if(fInputFormat == "AODout"){ // reading from AOD output handler
+      aod = AODEvent();
+    }else if(fInputFormat == "AODin"){ // reading from AOD input handler
+      aod = (AliAODEvent*)InputEvent();
+    }
+
+    Int_t nt = aod->GetNumberOfTracks();
+
+    for(Int_t it = 0; it < nt; it++) {
+      AliAODTrack *track = aod->GetTrack(it);
+      //Does event contain high pt particle above threshold in GeV 
+      if(track->Pt() > fLowerCutOnLPMom && IsSelectedAODTrack(track)){
+        isThisEventToBeStored = kTRUE;
+        break; 
+      }
     }
   }
 
@@ -738,88 +694,149 @@ bool AliJCORRANTask::ContainsESDHighPtTrack(const AliESDEvent* esd){
 }
 
 //______________________________________________________________________________
-bool AliJCORRANTask::ContainsESDHighECaloClusters(const AliESDEvent* esd){
-  bool isThisEventToBeStored = kFALSE;
+bool AliJCORRANTask::ContainsESDHighECaloClusters(){
+  bool isThisEventToBeStored = kFALSE; //initialize return value
 
-  Int_t numberOfCaloClusters = esd->GetNumberOfCaloClusters() ;
-  // loop over all the Calo Clusters
-  for(Int_t icluster = 0 ; icluster < numberOfCaloClusters ; icluster++) {
-    AliESDCaloCluster *caloCluster = esd->GetCaloCluster(icluster) ;
-    if(!caloCluster) continue;
-    if(caloCluster->GetTrackMatched()==-1){
-      //sotre calo clusters above 2 GeV
+  if(fInputFormat=="ESD"){
+
+    AliESDEvent* esd = NULL; 
+    esd = (AliESDEvent*)InputEvent();
+
+    Int_t numberOfCaloClusters = esd->GetNumberOfCaloClusters() ;
+    // loop over all the Calo Clusters
+    for(Int_t icluster = 0 ; icluster < numberOfCaloClusters ; icluster++) {
+      AliESDCaloCluster *caloCluster = esd->GetCaloCluster(icluster) ;
+      if(!caloCluster) continue;
+      if(caloCluster->GetTrackMatched()==-1){
+        //sotre calo clusters above 1 GeV
+        if( caloCluster->E() > fLowerCutOnLeadingCaloClusterE){
+          isThisEventToBeStored = kTRUE;
+          break; 
+        }
+      }
+    }
+  }else{
+
+    AliAODEvent* aod=NULL;
+    if(fInputFormat == "AODout"){ // reading from AOD output handler
+      aod = AODEvent();
+    }else if(fInputFormat == "AODin"){ // reading from AOD input handler
+      aod = (AliAODEvent*)InputEvent();
+    }
+
+    Int_t numberOfCaloClusters = aod->GetNCaloClusters() ;
+    // loop over all the Calo Clusters
+    for(Int_t icluster = 0 ; icluster < numberOfCaloClusters ; icluster++) {
+      AliAODCaloCluster *caloCluster = aod->GetCaloCluster(icluster) ;
+      if(!caloCluster) continue;
+      if(caloCluster->GetNTracksMatched() > 0) continue;
+      //sotre calo clusters above 1 GeV
       if( caloCluster->E() > fLowerCutOnLeadingCaloClusterE){
         isThisEventToBeStored = kTRUE;
         break; 
       }
     }
   }
+
   return isThisEventToBeStored;
 }
 
 
+//______________________________________________________________________________
 
+void AliJCORRANTask::ReadMCTracks(AliMCEvent *fMC)
+{
+  //AliGenEventHeader* genHeader = fMC->GenEventHeader();
+  //AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(genHeader);
+         
+  //Double_t ptHard = 0;
+  //Double_t nTrials = 1; // Trials for MC trigger weigth for real data
 
+  //nTrials = pythiaGenHeader->Trials();
+  //ptHard  = pythiaGenHeader->GetPtHard();
 
+  AliStack *stack = fMC->Stack();
+  Int_t np        = fMC->GetNumberOfTracks();
+  //Int_t nprim = stack->GetNtrack();
+  //  if(np!=nprim) cout << "GetNumberOfTracks = "<< np <<"\t, stack = "<< nprim << endl;
+  Short_t ntrack = 0;
 
-/*
-
+  for(Int_t itrack = 0; itrack < np; itrack++){
+    AliMCParticle *track = (AliMCParticle*) fMC->GetTrack(itrack);
+    if(!track){
+      Printf("ERROR: Could not receive track %d", itrack);
+      continue;
+    }
 
-void AliJCORRANTask::ReadMCTracks(AliMCEvent *fMC)
-{
-  AliGenEventHeader* genHeader = fMC->GenEventHeader();
-  AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(genHeader);
-         
-  Double_t ptHard = 0;
-  Double_t nTrials = 1; // Trials for MC trigger weigth for real data
-
-    nTrials = pythiaGenHeader->Trials();
-    ptHard  = pythiaGenHeader->GetPtHard();
-    //cout << nTrials <<"\t"<< ptHard << endl;
-
-    AliStack *stack = fMC->Stack();
-    Int_t np    = fMC->GetNumberOfTracks();
-    Int_t nprim = stack->GetNtrack();
-    if(np!=nprim) cout << "GetNumberOfTracks = "<< np <<"\t, stack = "<< nprim << endl;
-    Short_t ntrack = 0;
-    for(Int_t itrack = 0; itrack < nprim; itrack++){
-      //create a new JMCTrack and fill the track info
-      fMCTrackList->AddJMCTrack(ntrack);
-      JMCTrack *ctrack = fMCTrackList->GetTrack(ntrack);
-      TParticle *ipart = stack->Particle(itrack);
-      Int_t icode= ipart->GetPdgCode();
-      Float_t pt = ipart->Pt();
-      Float_t eta = ipart->Eta();
-      Float_t phi = ipart->Phi();
-      Int_t   status  = ipart->GetStatusCode();
-      Bool_t  isprim =  ipart->IsPrimary();
-      // fill base class
-      ctrack->SetE(ipart->Energy());
-      ctrack->SetTheta(ipart->Theta());
-      ctrack->SetPhi(phi);
-      ctrack->SetPt(pt);
-      // MC
-      ctrack->SetPtHard(ptHard);
-      ctrack->SetPdgCode(icode);
-      ctrack->SetStatusCode(status);
-      ctrack->SetIsPrimary(isprim);
-      ctrack->SetProductionVertex(ipart->Vx(),ipart->Vx(),ipart->Vz());
+    Bool_t isPrimary = stack->IsPhysicalPrimary(itrack);
+
+    //create a new JMCTrack and fill the track info
+    fMCTrackList->AddJMCTrack(ntrack);
+    AliJMCTrack *ctrack = fMCTrackList->GetTrack(ntrack);
+
+    TParticle *partStack = stack->Particle(itrack);
+    Int_t   pdg  = partStack->GetPdgCode();
+    Float_t engy = partStack->Energy();
+    Float_t pt   = partStack->Pt();
+    Float_t ptot = partStack->P();
+    Float_t eta  = partStack->Eta();
+    Float_t theta  = partStack->Theta();
+    Float_t phi    = atan2(sin( partStack->Phi()), cos(partStack->Phi()));
+    Short_t ch     = (Short_t) partStack->GetPDG()->Charge();
+    Int_t label    = track->GetLabel();
+    Int_t   status = partStack->GetStatusCode();
+
+    ctrack->SetLabel(label);
+    ctrack->SetPdgCode(pdg);
+    ctrack->SetPt(pt);
+    ctrack->SetTheta(theta);
+    ctrack->SetEta(eta);
+    ctrack->SetPhi(phi);
+    ctrack->SetE(engy);
+    ctrack->SetCharge(ch);
+    ctrack->SetPtot(ptot);
+    ctrack->SetStatusCode(status);
+    ctrack->SetIsPrimary(isPrimary);
+
+    ctrack->SetProductionVertex(partStack->Vx(),partStack->Vy(),partStack->Vz());
+
+    //ctrack->SetPtHard(ptHard);
       
-      //bool isInc = (status ==  1 && icode ==  22); //Inclusive
-      bool ispi0 = (status == 11 && icode == 111); //kPizero
-      bool isDgamma = (status == 6 || status == 7) && icode == 22; // Direct photon
-      bool inPHOS  = (ispi0||isDgamma)&&fabs(eta)<0.12; 
-      bool inEMCAL = (ispi0||isDgamma)&&fabs(eta)<0.7; 
-      bool inTPC   = fabs(eta)<0.9; 
-      ctrack->SetMother(0,ipart->GetFirstMother());
-      ctrack->SetMother(1,ipart->GetSecondMother());
-      ctrack->SetDaughter(0,ipart->GetFirstDaughter());
-      ctrack->SetDaughter(1,ipart->GetLastDaughter());
-      ctrack->SetIsInPHOS(inPHOS);
-      ctrack->SetIsInEMCAL(inEMCAL);
-      ctrack->SetIsInTPC(inTPC);
-
-      fMCTrackList->SetNTracks(++ntrack);
-    }// loop for al primary tracks
+    //bool isInc = (status ==  1 && icode ==  22); //Inclusive
+    bool ispi0 = (status == 11 && pdg == 111); //kPizero
+    bool isDgamma = (status == 6 || status == 7) && pdg == 22; // Direct photon
+    bool inPHOS  = (ispi0||isDgamma)&&fabs(eta)<0.12; 
+    bool inEMCAL = (ispi0||isDgamma)&&fabs(eta)<0.7; 
+    bool inTPC   = fabs(eta)<0.9; 
+    ctrack->SetMother(0,partStack->GetFirstMother());
+    ctrack->SetMother(1,partStack->GetSecondMother());
+    ctrack->SetDaughter(0,partStack->GetFirstDaughter());
+    ctrack->SetDaughter(1,partStack->GetLastDaughter());
+    ctrack->SetIsInPHOS(inPHOS);
+    ctrack->SetIsInEMCAL(inEMCAL);
+    ctrack->SetIsInTPC(inTPC);
+
+    fMCTrackList->SetNTracks(++ntrack);
+  }// loop for al primary tracks
+}
+
+//______________________________________________________________________________
+
+bool AliJCORRANTask::IsSelectedAODTrack(AliAODTrack   *track){
+
+  if(fIsRealOrMC &&  track->GetType() != AliAODTrack::kPrimary) return kFALSE; // only primaries 
+  if(fEsdTrackCuts->GetMinNClusterTPC() > track->GetTPCNcls()) return kFALSE;
+  if(fEsdTrackCuts->GetRequireTPCRefit()  && ((track->GetStatus() & AliJTrack::kTPCrefit) == 0)) return kFALSE;
+  if(fEsdTrackCuts->GetRequireITSRefit()  && ((track->GetStatus() & AliJTrack::kITSrefit) == 0)) return kFALSE;
+
+  return kTRUE;
 }
-*/
+
+//______________________________________________________________________________
+
+
+
+
+
+
index d417d09..c6672c9 100755 (executable)
@@ -5,7 +5,7 @@
  * See cxx source for full Copyright notice     */
 //______________________________________________________________________________
 // Analysis task for high pt particle correlations 
-// author: R.Diaz, J. Rak,  D.J. Kim
+// author: R.Diaz, J. Rak,  D.J. Kim, F.Krizek
 // ALICE Group University of Jyvaskyla 
 // Finland 
 //
@@ -24,6 +24,7 @@
 #include "AliAnalysisTaskSE.h"
 #include "AliAnalysisFilter.h"
 #include "AliMCEvent.h"
+#include "AliAODTrack.h"
 
 #include "AliPhJTrackList.h"
 #include "AliPhJMCTrackList.h"
@@ -38,8 +39,6 @@
 
 using namespace std;
 
-const int kMaxDimBuffer = 300;//max length of a line read to a buffe
-
 class TH1D;
 class TH2D;
 class TNtuple;
@@ -67,8 +66,8 @@ class AliPhJTrackList;
 class AliJCORRANTask : public AliAnalysisTaskSE {
 
 public:
-  AliJCORRANTask() ;
-  AliJCORRANTask(const char *name, TString inputformat, AliESDtrackCuts* esdTrackCuts, Int_t downSc, Double_t lowLPmom, Double_t lowCaloE); //FK//
+  AliJCORRANTask();
+  AliJCORRANTask(const char *name, TString inputformat);
   AliJCORRANTask(const AliJCORRANTask& ap);   
   AliJCORRANTask& operator = (const AliJCORRANTask& ap);
   virtual ~AliJCORRANTask();
@@ -89,50 +88,58 @@ public:
   void ReadAODCaloClusters(const AliAODEvent* aod);
   void ReadAODHeader(const AliAODEvent* aod);
   void ReadFilter();
-  //void ReadMCTracks(AliMCEvent* fMC);
+  void ReadMCTracks(AliMCEvent* fMC);
   Int_t GetSuperModuleNumber(bool isemcal, Int_t absId);
 
-private:
 
-  UInt_t ConvertTriggerMask(/*Long64_t alicetriggermask*/);//Converts alice trigger mask to JCorran trigger mask
+  //Setters to be used in AddAliJCORRANTask
+  void SetAliESDtrackCuts(AliESDtrackCuts* cuts){ fEsdTrackCuts=cuts;} 
+  void SetDownscaling(Int_t ds){ fDownscaling=ds;} 
+  void SetLowerCutOnLPMom(Double_t lcut){ fLowerCutOnLPMom=lcut;} 
+  void SetLowerCutOnLeadingCaloClusterE(Double_t lowE){ fLowerCutOnLeadingCaloClusterE=lowE;} //
+  void SetLowerCutOnCaloClusterE(Double_t lowE){ fLowerCutOnCaloClusterE=lowE;} //
+  void SetRealOrMC(Bool_t realormc){fIsRealOrMC=realormc;} //flags whether the input 
+                                                         //are ESDs from real  exp or MonteCarlo 
+  void SetOutputAODName(const char* aodname){ fAODName=aodname;}
 
-  bool StoreDownscaledMinBiasEvent();
-  bool ContainsESDHighPtTrack(const AliESDEvent* esd);
-  bool ContainsESDHighECaloClusters(const AliESDEvent* esd);
+private:
 
-  TString fInputFormat; // specify the input data format (ESD or AOD)
+  UInt_t ConvertTriggerMask(/*Long64_t alicetriggermask*/);//Converts alice trigger mask to JCorran trigger mask
 
-  AliESDtrackCuts* fEsdTrackCuts; //FK//
 
-  Int_t fDownscaling; //FK//
+  bool IsSelectedAODTrack(AliAODTrack   *track); //check if the track fulfils quality cuts on AOD tracks
 
-  Double_t fLowerCutOnLPMom; //FK//
+  bool StoreDownscaledMinBiasEvent(); //functions for offline event selection 
+  bool ContainsESDHighPtTrack();
+  bool ContainsESDHighECaloClusters();
 
-  Double_t fLowerCutOnLeadingCaloClusterE;//FK//
 
-  TString fActiveTriggers[kRangeTriggerTableAlice];//alice table mapping trigger bit to trigger name
+  TString fInputFormat; // specify the input data format (ESD or AOD)
 
-  TString fTriggerTableJCorran[kRangeTriggerTableJCorran];//JCorran trigger table TBit 0 =MinBias
+  //To be set in from AddAliJCORRANTask macro  
+  AliESDtrackCuts* fEsdTrackCuts;     //standard track quality cuts
+  Int_t    fDownscaling;              // downscaling
+  Double_t fLowerCutOnLPMom;          // lower cut on leading particle momentum
+  Double_t fLowerCutOnLeadingCaloClusterE; // lower cut on leading calo cluster energy
+  Double_t fLowerCutOnCaloClusterE;   //minimal E of cluster to be stored
+  Bool_t   fIsRealOrMC;               //flags if the input are real (0) ESDs or MonteCarlo ESDs (1)
+  TString fAODName; //output name
   
-  // jcorran output objects
-  TTree*         fTree;        // output tree
-  AliPhJTrackList*    fTrackList;  // list of charged track objects
-  //AliPhJMCTrackList*    fMCTrackList;  // list of charged track objects
-  AliPhJPhotonList*   fPhotonList; // list of photons objects
-  AliPhJHeaderList*   fHeaderList; // run, event details
-
-  AliJRunHeader* fAliRunHeader; // run, event details
-
+  TString fActiveTriggers[kRangeTriggerTableAlice];//alice table mapping trigg. bit to trigg. name
+  TString fTriggerTableJCorran[kRangeTriggerTableJCorran];//JCorran trigger table TBit 0 =MinBias
  
-  // QA output 
-  TList*    fQAList;        // list to hold all the qa objects
-  TNtuple*  fTrackQACuts ;  // tree of track quality cuts applied on ESD 
-  TNtuple*  fTrackKineCuts; // tree of track kinematic cuts applied on ESD
+  //output objects
+  AliPhJTrackList*   fTrackList;    //list of charged track objects
+  AliPhJMCTrackList* fMCTrackList;  //list of charged track objects
+  AliPhJPhotonList*  fPhotonList;   //list of photons objects
+  AliPhJHeaderList*  fHeaderList;   //event details
 
-  AliPHOSGeoUtils  * fPHOSGeom; //phos geometry matrix 
+  AliJRunHeader*     fAliRunHeader; // run details
+  AliPHOSGeoUtils  * fPHOSGeom;  //phos geometry matrix 
   AliEMCALGeoUtils * fEMCALGeom; //emcal geometry matrix
    
-  ClassDef(AliJCORRANTask, 1); // JCORRAN analysis task 
+  ClassDef(AliJCORRANTask, 2) // JCORRAN analysis task 
 };
 #endif // AliJCORRANTask_H
index ad21bb6..f8075ca 100644 (file)
@@ -5,14 +5,15 @@
 //
 // ALICE Jyvaskyla group 
 //
+// last change 20th Jun 2010 FK
 //-------------------------------------------------
 
 
 const TString kInputData = "ESD";
 const TString kJCORRANInputFormat = "ESD"; // ESD, AODout, AODin
+const Bool_t  kMC = kFALSE; //With real data kMC = kFALSE, MC data kMC =kTRUE
 
-
-AliJCORRANTask* AddTaskJCORRAN()
+AliJCORRANTask* AddTaskJCORRAN(const char* aodName="jcorran.root", const char* addPhysSelection="$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C")
 {
     //--------------------------------------
     // Make the analysis manager
@@ -23,22 +24,21 @@ AliJCORRANTask* AddTaskJCORRAN()
       return NULL;
     }
 
-    if (!mgr->GetInputEventHandler()) {
+    if(!mgr->GetInputEventHandler()){
        ::Error("AddTaskJets", "This task requires an input event handler");
        return NULL;
     }
 
+    //AliAODHandler *aodH = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
+    //aodH->SetCreateNonStandardAOD();
 
     //-------------------------------------------------------------------------
-    //Define task, put here any other task that you want to use.
-    //-------------------------------------------------------------------------
-    Int_t     downscaling     = 20;  //downscaling of normal events
-    Double_t  lowerCutOnLPmom =  2;  // 3 GeV
-    Double_t  lowerCutOnLeadingCaloClusterE = 1.; //GeV
-
     //           T R A C K     S E L E C T I O N
 
-    // Apply loose track cuts   //FK// 
+    AliESDtrackCuts* esdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts2009","Standard");
+  
+    /* // Apply loose track cuts   
     AliESDtrackCuts* esdTrackCutsLoose = new AliESDtrackCuts("AliESDtrackCuts", "Loose");
     esdTrackCutsLoose->SetMinNClustersTPC(60);
     esdTrackCutsLoose->SetMaxChi2PerClusterTPC(4.0);
@@ -48,54 +48,50 @@ AliJCORRANTask* AddTaskJCORRAN()
     esdTrackCutsLoose->SetAcceptKinkDaughters(kFALSE);
     esdTrackCutsLoose->SetMaxDCAToVertexXY(3.5);
     esdTrackCutsLoose->SetMaxDCAToVertexZ(3.5);
-    // hard
-    //AliESDtrackCuts* esdTrackCutsHard = new AliESDtrackCuts("AliESDtrackCuts", "Hard");
-    //esdTrackCutsHard->SetMinNClustersTPC(100);
-    //esdTrackCutsHard->SetMaxChi2PerClusterTPC(2.0);
-    //esdTrackCutsHard->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
-    //esdTrackCutsHard->SetRequireTPCRefit(kTRUE);
-    //esdTrackCutsHard->SetMaxNsigmaToVertex(2);
-    //esdTrackCutsHard->SetRequireSigmaToVertex(kTRUE);
-    //esdTrackCutsHard->SetAcceptKinkDaughters(kFALSE);
+    */
 
     //---------------------------------------------------------------------------
-   
     //       E V E N T     S E L E C T I O N
 
-    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
-    AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection();
-    AliPhysicsSelection* physSele = physSelTask->GetPhysicsSelection();
-
+    Int_t     downscaling     = 20;  //downscaling of normal events
+    Double_t  lowerCutOnLPmom =  3;  //select all events with a particle above momentum  
+    Double_t  lowerCutOnLeadingCaloClusterE = 1.; //GeV   select all events with a calo cluster above the energy   
+    Double_t  lowerCutOnCaloClusterE = 0.2; // GeV  store only calo clusters above this energy   
+
+    if(addPhysSelection){ 
+      gROOT->LoadMacro(addPhysSelection);
+      AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection();
+      AliPhysicsSelection* physSele = physSelTask->GetPhysicsSelection();
+    
     //tag as MB different trigger than CINT1B
     //physSele->AddCollisionTriggerClass("+CSMBB-ABCE-NOPF-ALL"); // Put here trigger to be selected, default is CINT1B 
+    }
+    //---------------------------------------------------------------------------
+    //            J C O R R A N    T A S K 
 
-    AliJCORRANTask *jctask = new AliJCORRANTask("PWG4JCORRANTask",kJCORRANInputFormat, esdTrackCutsLoose, downscaling, lowerCutOnLPmom, lowerCutOnLeadingCaloClusterE); //FK//
+    AliJCORRANTask *jctask = new AliJCORRANTask("PWG4JCORRANTask",kJCORRANInputFormat); 
     jctask->SetDebugLevel(1);
+    /*jctask->SetAliESDtrackCuts(esdTrackCutsLoose); */
+    jctask->SetAliESDtrackCuts(esdTrackCuts->GetStandardITSTPCTrackCuts2009());
+    jctask->SetDownscaling(downscaling);
+    jctask->SetLowerCutOnLPMom(lowerCutOnLPmom);
+    jctask->SetLowerCutOnLeadingCaloClusterE(lowerCutOnLeadingCaloClusterE);
+    jctask->SetLowerCutOnCaloClusterE(lowerCutOnCaloClusterE);
+    jctask->SetRealOrMC(kMC); //flags whether the input are ESDs from real  exp or MonteCarlo 
+    jctask->SetOutputAODName(aodName); 
     mgr->AddTask(jctask);
 
     jctask->SelectCollisionCandidates();  //Apply offline trigger selection by AliPhysicsSelectionTask
 
     
     // Create containers for input:
-    AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer(); 
+    AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer(); 
 
-    // JCORRAN output containers:
-    AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("jcorrantree", TTree::Class(),
-                                                             AliAnalysisManager::kOutputContainer, "jcorran.root");
-                                                             
-    AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("jcorranQAlist", TList::Class(),
-                                                             AliAnalysisManager::kOutputContainer, "jcorranQA.root");
+    //connect input to JCORRAN task
+    mgr->ConnectInput(jctask, 0, cinput0);
 
-
-                                                             
-    // JCORRAN task
-    mgr->ConnectInput  (jctask,     0, cinput0  );
-    mgr->ConnectOutput (jctask,     1, coutput1 );
-    mgr->ConnectOutput (jctask,     2, coutput2 );
-
-    
     
- return jctask;
+    return jctask;
 }