Update of Megans jeth code
authorjmazer <jmazer@cern.ch>
Wed, 8 Oct 2014 19:31:58 +0000 (15:31 -0400)
committermverweij <marta.verweij@cern.ch>
Thu, 9 Oct 2014 11:29:29 +0000 (13:29 +0200)
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetHMEC.cxx
PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetHMEC.h
PWGJE/EMCALJetTasks/macros/AddTaskEmcalJetHMEC.C

index 5c70625..f9e9fcd 100644 (file)
@@ -52,7 +52,10 @@ AliAnalysisTaskEmcalJetHMEC::AliAnalysisTaskEmcalJetHMEC() :
   fClusBias(5),
   fTrkEta(0.9),
   fDoEventMixing(0),
-  fMixingTracks(50000),
+  fMixingTracks(50000), fNMIXtracks(5000), fNMIXevents(5),
+  fTriggerEventType(AliVEvent::kEMCEJE), fMixingEventType(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral),
+  fDoLessSparseAxes(0), fDoWiderTrackBin(0),
+  fCentBinSize(1),
   fESD(0),
   fAOD(0), 
   fPoolMgr(0x0), 
@@ -99,7 +102,10 @@ AliAnalysisTaskEmcalJetHMEC::AliAnalysisTaskEmcalJetHMEC(const char *name) :
   fClusBias(5),
   fTrkEta(0.9),
   fDoEventMixing(0),
-  fMixingTracks(50000),
+  fMixingTracks(50000), fNMIXtracks(5000), fNMIXevents(5),
+  fTriggerEventType(AliVEvent::kEMCEJE), fMixingEventType(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral),
+  fDoLessSparseAxes(0), fDoWiderTrackBin(0),
+  fCentBinSize(1),
   fESD(0),
   fAOD(0), 
   fPoolMgr(0x0), 
@@ -191,13 +197,21 @@ void AliAnalysisTaskEmcalJetHMEC::UserCreateOutputObjects() {
   }
 
   UInt_t cifras = 0; // bit coded, see GetDimParams() below 
-  cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<7 | 1<<8; 
+  if(fDoLessSparseAxes) {
+    cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5;
+  } else {
+    cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7; 
+  }
   fhnJH = NewTHnSparseF("fhnJH", cifras);
   fhnJH->Sumw2();
   fOutput->Add(fhnJH);
 
   if(fDoEventMixing){    
-    cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<7 | 1<<8; 
+    if(fDoLessSparseAxes) { 
+      cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5;
+    } else {
+      cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7; 
+    }
     fhnMixedEvents = NewTHnSparseF("fhnMixedEvents", cifras);
     fhnMixedEvents->Sumw2();
     fOutput->Add(fhnMixedEvents);
@@ -219,10 +233,25 @@ void AliAnalysisTaskEmcalJetHMEC::UserCreateOutputObjects() {
   Double_t vertexBins[] = { -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, };
   Double_t* zvtxbin = vertexBins;
 
-  Int_t nCentralityBins  = 100;
+//  Int_t nCentralityBins  = 100;
+  Int_t nCentralityBins = 100;
+  Double_t mult = 1.0;
+  if(fCentBinSize==1) { 
+    nCentralityBins = 100;
+    mult = 1.0;  
+  } else if(fCentBinSize==2){
+    nCentralityBins = 50;
+    mult = 2.0;
+  } else if(fCentBinSize==5){
+    nCentralityBins = 20;
+    mult = 5.0;
+  } else if(fCentBinSize==10){
+    nCentralityBins = 10;
+    mult = 10.0;
+  }
   Double_t centralityBins[nCentralityBins];
   for(Int_t ic=0; ic<nCentralityBins; ic++){
-    centralityBins[ic]=1.0*ic;
+   centralityBins[ic]=mult*ic;
   }
 
   fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nCentralityBins, centralityBins, nZvtxBins, zvtxbin);
@@ -400,9 +429,17 @@ Bool_t AliAnalysisTaskEmcalJetHMEC::Run() {
       }
   }
 
+  // see if event is selected
+  UInt_t trig = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
+
   for (Int_t ijet = 0; ijet < Njets; ijet++){    
     AliEmcalJet *jet = static_cast<AliEmcalJet*>(jets->At(ijet));
     if (!jet) continue; 
+
+    // see if event is selected and our jet came from trigger event
+    if (!(trig & fTriggerEventType)) continue;
+    if (jet->Pt()<0.1) continue;
+
     if(!AcceptthisJet(jet)) continue;
 
     Double_t jetphi = jet->Phi();
@@ -435,8 +472,7 @@ Bool_t AliAnalysisTaskEmcalJetHMEC::Run() {
       iptjet=GetpTjetBin(jetPt);
       if(iptjet<0) continue;
 
-      //if (highestjetpt>15) {
-      if (highestjetpt>8) {
+    if (jetPt > 15) {
 
       for (Int_t iTracks = 0; iTracks < Ntracks; iTracks++) {
            AliVTrack* track = static_cast<AliVTrack*>(tracks->At(iTracks));
@@ -479,8 +515,13 @@ Bool_t AliAnalysisTaskEmcalJetHMEC::Run() {
            if ((jet->MaxTrackPt()>fTrkBias) || (jet->MaxClusterPt()>fClusBias)){
              fHistJetHBias[centbin][iptjet][ieta]->Fill(dphijh,trackpt);
 
-             Double_t triggerEntries[8] = {fCent,jetPt,trackpt,dR,deta,dphijh,0.0,leadjet};                      
-             fhnJH->Fill(triggerEntries);
+          if(fDoLessSparseAxes) { // check if we want all dimensions
+            Double_t triggerEntries[6] = {fCent,jetPt,trackpt,deta,dphijh,leadjet};
+            fhnJH->Fill(triggerEntries);
+          } else { 
+               Double_t triggerEntries[8] = {fCent,jetPt,trackpt,deta,dphijh,leadjet,0.0,dR};                      
+            fhnJH->Fill(triggerEntries);
+          }
            }
 
            if(passedTTcut)
@@ -493,8 +534,7 @@ Bool_t AliAnalysisTaskEmcalJetHMEC::Run() {
   //Prepare to do event mixing
 
   // create a list of reduced objects. This speeds up processing and reduces memory consumption for the event pool
-  TObjArray* tracksClone = CloneAndReduceTrackList(tracks);
-  //delete tracks;
+  TObjArray* tracksClone = 0x0;
 
   if(fDoEventMixing>0){
     
@@ -516,6 +556,10 @@ Bool_t AliAnalysisTaskEmcalJetHMEC::Run() {
     //    FillCorrelations(). Also nMix should be passed in, so a weight
     //    of 1./nMix can be applied.
 
+    UInt_t trigger = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
+    // if event was not selected (triggered) for any reseason (should never happen) then return
+    if (trigger==0)  return kTRUE;
+
     AliEventPool* pool = fPoolMgr->GetEventPool(fCent, zVtx);
     
     if (!pool){
@@ -523,20 +567,26 @@ Bool_t AliAnalysisTaskEmcalJetHMEC::Run() {
       return kTRUE;
     }
 
+if(trigger & fTriggerEventType) {
     //check for a trigger jet
-    if (pool->IsReady() || pool->NTracksInPool() > fMixingTracks / 10 || pool->GetCurrentNEvents() >= 5) {
+    if (pool->IsReady() || pool->NTracksInPool() > fNMIXtracks || pool->GetCurrentNEvents() >= fNMIXevents) {
 
        for (Int_t ijet = 0; ijet < Njets; ijet++){
          Double_t leadjet=0;
          if (ijet==ijethi) leadjet=1;
          
          AliEmcalJet *jet = static_cast<AliEmcalJet*>(jets->At(ijet));
+      if (!jet) continue;
+
          if(!AcceptthisJet(jet)) continue;
 
          Double_t jetPt = jet->Pt();   
          Double_t jetphi = jet->Phi();
          Double_t jeteta=jet->Eta();
-         
+
+      // make sure event contains jet above our threshold (reduce stats of sparse)
+      if (jetPt < 15) continue;
+
          Int_t nMix = pool->GetCurrentNEvents();
          
          //Fill for biased jet triggers only
@@ -550,6 +600,8 @@ Bool_t AliAnalysisTaskEmcalJetHMEC::Run() {
           for(Int_t ibg=0; ibg<Nbgtrks; ibg++){
                    AliPicoTrack *part = static_cast<AliPicoTrack*>(bgTracks->At(ibg));         
                    if(!part) continue;
+            if(TMath::Abs(part->Eta())>0.9) continue;
+            if(part->Pt()<0.15) continue;
   
                    Double_t DEta = part->Eta()-jeteta;
                    Double_t DPhi = RelativePhi(jetphi,part->Phi());
@@ -557,17 +609,28 @@ Bool_t AliAnalysisTaskEmcalJetHMEC::Run() {
                    Double_t DR=TMath::Sqrt(DPhi*DPhi+DEta*DEta);
                    if(DPhi<-0.5*TMath::Pi()) DPhi+=2.*TMath::Pi();
                    if(DPhi>3./2.*TMath::Pi()) DPhi-=2.*TMath::Pi();
-                   Double_t triggerEntries[8] = {fCent,jetPt,part->Pt(),DR,DEta,DPhi,0.0,leadjet};                      
-                   fhnMixedEvents->Fill(triggerEntries,1./nMix);                 
+            if(fDoLessSparseAxes) {  // check if we want all the axis filled
+              Double_t triggerEntries[6] = {fCent,jetPt,part->Pt(),DEta,DPhi,leadjet};
+              fhnMixedEvents->Fill(triggerEntries,1./nMix);
+            } else {
+                     Double_t triggerEntries[8] = {fCent,jetPt,part->Pt(),DEta,DPhi,leadjet,0.0,DR};                      
+              fhnMixedEvents->Fill(triggerEntries,1./nMix);
+                   }
                    }
              }
            }
          }
     }
+}
+
+    if(trigger & fMixingEventType) {
+      tracksClone = CloneAndReduceTrackList(tracks);
+
+      //update pool if jet in event or not
+      pool->UpdatePool(tracksClone);
+    }
 
-    //update pool if jet in event or not
-    pool->UpdatePool(tracksClone);
-  }
+  } // end of event mixing
 
   return kTRUE;
 }      
@@ -662,55 +725,60 @@ void AliAnalysisTaskEmcalJetHMEC::GetDimParams(Int_t iEntry, TString &label, Int
       break;
       
    case 2:
-      label = "track pT";
-      nbins = 100;
-      xmin = 0.;
-      xmax = 10;
-      break;
-        
-    case 3:
-      label = "deltaR";
-      nbins = 10;
-      xmin = 0.;
-      xmax = 5.0;
+      if(fDoWiderTrackBin) {
+        label = "track pT";
+        nbins = 40;
+        xmin = 0.;
+        xmax = 10.;
+      } else {
+        label = "track pT";
+        nbins = 100;
+        xmin = 0.;
+        xmax = 10;
+      }
       break;
-
-   case 4:
+      
+   case 3:
       label = "deltaEta";
       nbins = 24;
       xmin = -1.2;
       xmax = 1.2;
       break;
 
-  case 5:
+   case 4:
       label = "deltaPhi";
       nbins = 72;
       xmin = -0.5*pi;
       xmax = 1.5*pi;
       break;         
-        
-    case 6:
-      label = "leading track";
-      nbins = 13;
-      xmin = 0;
-      xmax = 50;
+
+    case 5:
+      label = "leading jet";
+      nbins = 3;
+      xmin = -0.5;
+      xmax = 2.5;
       break;
            
-     case 7:
-    
+    case 6:
       label = "trigger track";
       nbins =10;
       xmin = 0;
       xmax = 50;
       break;
 
+    case 7:
+      label = "deltaR";
+      nbins = 10;
+      xmin = 0.;
+      xmax = 5.0;
+      break;
+
     case 8:
-      label = "leading jet";
-      nbins = 3;
-      xmin = -0.5;
-      xmax = 2.5;
+      label = "leading track";
+      nbins = 13;
+      xmin = 0;
+      xmax = 50;
       break;
-  
    }
 }
 
index 3027bb0..66108e1 100644 (file)
@@ -43,6 +43,17 @@ class AliAnalysisTaskEmcalJetHMEC : public AliAnalysisTaskEmcalJet {
   virtual void            SetEventMixing(Int_t yesno)              { fDoEventMixing=yesno;}
   virtual void            SetMixingTracks(Int_t tracks)            { fMixingTracks = tracks; }
 
+  // event trigger/mixed selection - setters
+  virtual void            SetTrigType(UInt_t te)       { fTriggerEventType = te; }
+  virtual void            SetMixType(UInt_t me)        { fMixingEventType = me; }
+  virtual void            SetNMixedTracks(Int_t nmt)   { fNMIXtracks = nmt; }
+  virtual void            SetNMixedEvents(Int_t nme)   { fNMIXevents = nme; }
+
+  // switch to cut out some unneeded sparse axis
+  void                    SetDoLessSparseAxes(Bool_t dlsa) { fDoLessSparseAxes = dlsa; }
+  void                    SetDoWiderTrackBin(Bool_t wtrbin) { fDoWiderTrackBin = wtrbin; }
+
+  virtual void            SetCentBinSize(Bool_t centbins) { fCentBinSize = centbins; }
 
  protected:
   void                                  ExecOnce();
@@ -63,8 +74,19 @@ class AliAnalysisTaskEmcalJetHMEC : public AliAnalysisTaskEmcalJet {
   Double_t               fTrkEta;                  // eta min/max of tracks
   Int_t                  fDoEventMixing;           // flag to do evt mixing
   Int_t                         fMixingTracks;                // size of track buffer for event mixing
+  Int_t                  fNMIXtracks;              // threshold to use event pool # tracks
+  Int_t                  fNMIXevents;              // threshold to use event pool # events
   TObjArray*             CloneAndReduceTrackList(TObjArray* tracks);
 
+  // event selection types
+  UInt_t         fTriggerEventType;
+  UInt_t         fMixingEventType;
+
+  Bool_t         fDoLessSparseAxes;
+  Bool_t         fDoWiderTrackBin;
+
+  UInt_t         fCentBinSize;
+
   AliESDEvent           *fESD;    //! ESD object
   AliAODEvent                  *fAOD;    //! AOD object
   AliEventPoolManager   *fPoolMgr; //!
index 093e3a0..b28bd3c 100644 (file)
@@ -13,6 +13,13 @@ AliAnalysisTaskEmcalJetHMEC* AddTaskEmcalJetHMEC(
    const Double_t TrkBias     = 5,
    const Double_t ClusBias    = 5,
    const Double_t TrkEta      = 0.9,
+   const Int_t nmixingTR      = 5000,
+   const Int_t nmixingEV      = 5,
+   UInt_t trigevent           = AliVEvent::kAny,
+   UInt_t mixevent            = AliVEvent::kAny,
+   Bool_t lessSparseAxes      = 0,
+   Bool_t widertrackbin       = 0,
+   UInt_t centbinsize         = 1,
    const char *branch         = "biased"
                                                  
 )
@@ -48,14 +55,20 @@ AliAnalysisTaskEmcalJetHMEC* AddTaskEmcalJetHMEC(
   if(EvtMix>0){
     correlationtask->SetMixingTracks(EvtMix);
     correlationtask->SetEventMixing(1);
+    correlationtask->SetNMixedTracks(nmixingTR);
+    correlationtask->SetNMixedEvents(nmixingEV);
   }else{
     correlationtask->SetEventMixing(EvtMix);
   }
   correlationtask->SetTrkBias(TrkBias);
   correlationtask->SetClusBias(ClusBias);
   correlationtask->SetTrkEta(TrkEta);
+  correlationtask->SetTrigType(trigevent);
+  correlationtask->SetMixType(mixevent);
+  correlationtask->SetDoLessSparseAxes(lessSparseAxes);
+  correlationtask->SetDoWiderTrackBin(widertrackbin);
+  correlationtask->SetCentBinSize(centbinsize);
 
   //-------------------------------------------------------
   // Final settings, pass to manager and set the containers
   //-------------------------------------------------------