Various improvements
authorcholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 26 Jan 2011 13:26:14 +0000 (13:26 +0000)
committercholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 26 Jan 2011 13:26:14 +0000 (13:26 +0000)
19 files changed:
PWG2/CMakelibPWG2forward2.pkg
PWG2/FORWARD/analysis/AliFMDAnalysisTaskGenerateCorrection.cxx
PWG2/FORWARD/analysis2/AddTaskFMDELoss.C
PWG2/FORWARD/analysis2/AliFMDCorrector.cxx
PWG2/FORWARD/analysis2/AliFMDEventInspector.cxx
PWG2/FORWARD/analysis2/AliForwardCorrectionManager.cxx
PWG2/FORWARD/analysis2/AliForwardCorrectionManager.h
PWG2/FORWARD/analysis2/AliForwardMCCorrectionsTask.cxx
PWG2/FORWARD/analysis2/AliForwardMultiplicityBase.cxx
PWG2/FORWARD/analysis2/AliForwardUtil.cxx
PWG2/FORWARD/analysis2/AliForwardUtil.h
PWG2/FORWARD/analysis2/AnalyseAOD.C
PWG2/FORWARD/analysis2/MakeAOD.C
PWG2/FORWARD/analysis2/scripts/CompareSecMaps.C [new file with mode: 0644]
PWG2/FORWARD/analysis2/scripts/RunCopyELossFit.C
PWG2/FORWARD/analysis2/scripts/RunCopyMergeEff.C
PWG2/FORWARD/analysis2/scripts/RunCopySecMap.C
PWG2/FORWARD/analysis2/scripts/RunCopyVtxBias.C
PWG2/PWG2forward2LinkDef.h

index ec9de2c5501b25f3d8f54dd63da18359a7b64194..2719cc3c98bb2b7cb52cbfe65db0b95d691f3ce2 100644 (file)
@@ -53,9 +53,12 @@ set ( SRCS
 )
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
+set ( HDRS ${HDRS} FORWARD/analysis2/AliFMDStripIndex.h )
 
 set ( EINCLUDE  ANALYSIS )
 
+set ( EXPORT FORWARD/analysis2/AliAODForwardMult.h )
+
 set ( DHDR  PWG2forward2LinkDef.h)
 
 # --------------------------------------------------------------------
index 9ea0f4c4ea2cf3acad9fa6ffbfc027047974a1ec..fe923aef840c326e5afe56b82bb584104812fb22 100644 (file)
@@ -793,19 +793,21 @@ void AliFMDAnalysisTaskGenerateCorrection::ReadFromFile(const Char_t* filename,
   
   fout.Close();
   AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
-  if(storeInOCDB) {
-    TFile fbg(pars->GetPath(pars->GetBackgroundID()),"RECREATE");
-    fBackground->Write(AliFMDAnaParameters::GetBackgroundID());
-    fbg.Close();
-    TFile feselect(pars->GetPath(pars->GetEventSelectionEffID()),"RECREATE");
-    fEventSelectionEff->Write(AliFMDAnaParameters::GetEventSelectionEffID());
-    feselect.Close();
-    
+  if (!storeInOCDB) {
+    pars->SetBackgroundPath(".");
+    pars->SetEnergyPath(".");
+    pars->SetEventSelectionPath(".");
+    pars->SetSharingEfficiencyPath(".");
   }
-  
-  
-  
-  
+  AliInfo(Form("Generating %s", pars->GetPath(pars->GetBackgroundID())));
+  TFile fbg(pars->GetPath(pars->GetBackgroundID()),"RECREATE");
+  fBackground->Write(AliFMDAnaParameters::GetBackgroundID());
+  fbg.Close();
+
+  AliInfo(Form("Generating %s", pars->GetPath(pars->GetEventSelectionEffID())));
+  TFile feselect(pars->GetPath(pars->GetEventSelectionEffID()),"RECREATE");
+  fEventSelectionEff->Write(AliFMDAnaParameters::GetEventSelectionEffID());
+  feselect.Close();
 }
 //_____________________________________________________________________
 //
index 018327b76ea089635357f7dc60e8dd519705810e..134e163b7d61c1163974eee0705242c4e4e009dd 100644 (file)
@@ -40,7 +40,7 @@ AddTaskFMDELoss(Bool_t mc)
   // Set maximum energy loss to consider 
   task->GetEnergyFitter().SetMaxE(15); 
   // Set number of energy loss bins 
-  task->GetEnergyFitter().SetNEbins(100);
+  task->GetEnergyFitter().SetNEbins(450);
   // Set whether to use increasing bin sizes 
   task->GetEnergyFitter().SetUseIncreasingBins(true);
   // Set whether to do fit the energy distributions 
@@ -57,6 +57,9 @@ AddTaskFMDELoss(Bool_t mc)
   // Set the minimum number of entries in the distribution before
   // trying to fit to the data
   task->GetEnergyFitter().SetMinEntries(1000);
+  task->GetEnergyFitter().SetMaxRelativeParameterError(0.12);
+  task->GetEnergyFitter().SetMaxChi2PerNDF(10);
+  task->GetEnergyFitter().SetMinWeight(1e-5);
   // --- Set limits on fits the energy -------------------------------
   // Maximum relative error on parameters 
   AliFMDCorrELossFit::ELossFit::fgMaxRelError = .12;
index f2ef96507a3766d2ee14206a6b8b9f2056f240ba..eeedace5a30d38d5d7d86af619c2c46cc3486e5b 100644 (file)
@@ -31,7 +31,7 @@ AliFMDCorrector::AliFMDCorrector()
 
 //____________________________________________________________________
 AliFMDCorrector::AliFMDCorrector(const char* title)
-  : TNamed("fmdCorrections", title), 
+  : TNamed("fmdCorrector", title), 
     fRingHistos(), 
     fUseMergingEfficiency(true),
     fDebug(0)
index 727ec3e236ded24079e3c7287abfe5aaf8f500cd..4b870516cde0bd767deb4430410ecb0b1fbfae10 100644 (file)
@@ -511,6 +511,9 @@ AliFMDEventInspector::ReadRunDetails(const AliESDEvent* esd)
   // Return:
   //    true on success, false 
   //
+  // AliInfo(Form("Parameters from 1st ESD event: cms=%s, sNN=%f, field=%f",
+  //          esd->GetBeamType(), 2*esd->GetBeamEnergy(), 
+  //          esd->GetMagneticField()));
   fCollisionSystem = 
     AliForwardUtil::ParseCollisionSystem(esd->GetBeamType());
   fEnergy          = 
index 02a0067b54af092fc8cfcf32af0d7489fd739020..5d63696f56689e101d3f54a0819f033851dca113 100644 (file)
@@ -123,6 +123,49 @@ AliForwardCorrectionManager::operator=(const AliForwardCorrectionManager& o)
   return *this;
 }
 
+//____________________________________________________________________
+void
+AliForwardCorrectionManager::SetPrefix(const char* prefix)
+{
+  fELossFitsPath    = Form("%s/%s", prefix, ELOSSFIT_DIR);
+  fMergingEffPath   = Form("%s/%s", prefix, MERGING_DIR); 
+  fSecondaryMapPath = Form("%s/%s", prefix, SECONDARY_DIR);
+  fDoubleHitPath    = Form("%s/%s", prefix, DOUBLE_DIR);
+  fVertexBiasPath   = Form("%s/%s", prefix, VERTEX_DIR);
+  fAcceptancePath   = Form("%s/%s", prefix, ACCEPTANCE_DIR);
+  
+}
+//____________________________________________________________________
+void
+AliForwardCorrectionManager::SetFileDir(ECorrection what, const char* dir)
+{
+  TString *path = 0;
+  // 
+  // Get the path to the specified object 
+  // 
+  // Parameters:
+  //    what  Which stuff to get the path for 
+  // 
+  // Return:
+  //    The full path or null 
+  //
+  if      (what & kSecondaryMap)        path = &fSecondaryMapPath;
+  else if (what & kDoubleHit)           path = &fDoubleHitPath;
+  else if (what & kELossFits)           path = &fELossFitsPath;
+  else if (what & kVertexBias)          path = &fVertexBiasPath;
+  else if (what & kMergingEfficiency)   path = &fMergingEffPath;
+  else if (what & kAcceptance)          path = &fAcceptancePath;
+  else { 
+    AliWarning(Form("No such path defined for 0x%02x", what));
+    return;
+  }
+  if (!path) {
+    AliWarning(Form("Couldn't find string for path 0x%02x", what));
+    return;
+  }
+  *path = dir;
+}
+
 //____________________________________________________________________
 Bool_t
 AliForwardCorrectionManager::Init(const char* cms, 
@@ -147,6 +190,8 @@ AliForwardCorrectionManager::Init(const char* cms,
   //    true on success
   //
   UShort_t col = AliForwardUtil::ParseCollisionSystem(cms);
+  // AliInfo(Form("Initialising with cms='%s', sNN=%fGeV field=%fkG", 
+  //          cms, sNN, field));
   return Init(col, 
              AliForwardUtil::ParseCenterOfMassEnergy(col, sNN),
              AliForwardUtil::ParseMagneticField(field), 
@@ -177,7 +222,38 @@ AliForwardCorrectionManager::Init(UShort_t cms,
   //    
   //
   if (force) fInit = kFALSE;
-  if (fInit) return kTRUE;
+  if (fInit) {
+    // Check that the initialisation and the passed parameters 
+    // match - if not give an error but continue - this allows 
+    // users to override particular settings. 
+    Bool_t same = true;
+    if (fSys != cms) { 
+      AliWarning(Form("Initialised collision system %s (%d) and "
+                     "passed same %s (%d) does not match", 
+                     AliForwardUtil::CollisionSystemString(fSys), fSys,
+                     AliForwardUtil::CollisionSystemString(cms), cms));
+      same = false;
+    }
+    if (TMath::Abs(fSNN - sNN) >= 10) {
+      AliWarning(Form("Initialised center of mass energy per nuclean "
+                     "%s (%d) and passed same %s (%d) does not match",
+                     AliForwardUtil::CenterOfMassEnergyString(fSNN), fSNN,
+                     AliForwardUtil::CenterOfMassEnergyString(sNN), sNN));
+      same = false;
+    }
+    if (fField != field) {
+      AliWarning(Form("Initialied L3 magnetic field %s (%d) and passed "
+                     "same %s (%d) does not match", 
+                     AliForwardUtil::MagneticFieldString(fField), fField,
+                     AliForwardUtil::MagneticFieldString(field), field));
+      same = false;
+    }
+    if (!same) 
+      AliWarning("Intialised parameters and these are not the same " 
+                "- PROCEED WITH CAUTION!");
+      
+    return kTRUE;
+  }
 
   Bool_t ret = kTRUE;
   if (fSys == cms && TMath::Abs(fSNN - sNN) < 10 && fField == field) { 
@@ -189,7 +265,9 @@ AliForwardCorrectionManager::Init(UShort_t cms,
   fSys   = cms;
   fSNN   = sNN;
   fField = field;
-              
+
+  // AliInfo(Form("Initialising with cms=%d, sNN=%dGeV field=%dkG", 
+  //          cms, sNN, field));
   // Read secondary map if requested 
   if (what & kSecondaryMap) {
     if (!ReadSecondaryMap(cms, sNN, field)) {
index ebc4a47e4183b1c66296039fcc932220cde11bf2..76dbdc337c90ea549d96b962c42da71a070d2ea3 100644 (file)
@@ -44,6 +44,18 @@ public:
    * @return Reference to the singleton object 
    */
   static AliForwardCorrectionManager& Instance();
+  /** 
+   *
+   * @param prefix Prefix to correction objects. 
+   */
+  void SetPrefix(const char* prefix);
+  void SetFileDir(ECorrection what, const char* dirname);
+  void SetSecondaryMapPath(const char* d) { SetFileDir(kSecondaryMap, d); }
+  void SetDoubleHitPath(const char* d)    { SetFileDir(kDoubleHit, d); }
+  void SetELossFitsPath(const char* d)    { SetFileDir(kELossFits, d); }
+  void SetVertexBiasPath(const char* d)   { SetFileDir(kVertexBias, d); }
+  void SetMergingEffPath(const char* d)   { SetFileDir(kMergingEfficiency, d); }
+  void SetAcceptancePath(const char* d)   { SetFileDir(kAcceptance, d); }
   /** 
    * Read in corrections based on the parameters given 
    * 
index 72557e84c16c27e76d8fb5fd97f4c32da0d36e80..d973b5b5667eb48b481bda8057c7e7c7bd1ba6fe 100644 (file)
@@ -457,7 +457,7 @@ AliForwardMCCorrectionsTask::UserExec(Option_t*)
 
   // Get the input data - MC event
   AliMCEvent*  mcEvent = MCEvent();
-  if (mcEvent) { 
+  if (!mcEvent) { 
     AliWarning("No MC event found");
     return;
   }
index c77391eda65e8fa52cd933b1d3bf3adbc4c695d6..2f0b8f15231c4ebcadbb0851ef410dfcf8d6a9ec 100644 (file)
@@ -79,6 +79,13 @@ AliForwardMultiplicityBase::CheckCorrections(UInt_t what) const
     AliFatal("No merging efficiencies");
     return false;
   }
+  // Check that we have the acceptance correction, needed by 
+  //   AliFMDCorrector 
+  if (what & AliForwardCorrectionManager::kAcceptance && 
+      !fcm.GetAcceptance()) { 
+    AliFatal("No acceptance corrections");
+    return false;
+  }
   return true;
 }
 
index c7723886ba2afea3ba120ba00f3df1483c79f9c7..b5dd3e5cf01a63caf291a9da98867554fb55f37c 100644 (file)
@@ -66,7 +66,7 @@ AliForwardUtil::CollisionSystemString(UShort_t sys)
 }
 //____________________________________________________________________
 UShort_t
-AliForwardUtil::ParseCenterOfMassEnergy(UShort_t sys, Float_t v)
+AliForwardUtil::ParseCenterOfMassEnergy(UShort_t /* sys */, Float_t v)
 {
   // 
   // Parse the center of mass energy given as a float and return known 
@@ -80,7 +80,8 @@ AliForwardUtil::ParseCenterOfMassEnergy(UShort_t sys, Float_t v)
   //    Center of mass energy per nucleon
   //
   Float_t energy = v; 
-  if (sys != AliForwardUtil::kPP) energy = energy / 208 * 82;
+  // Below no longer needed apparently
+  // if (sys == AliForwardUtil::kPbPb) energy = energy / 208 * 82;
   if (TMath::Abs(energy - 900.)   < 10)  return 900;
   if (TMath::Abs(energy - 2400.)  < 10)  return 2400;
   if (TMath::Abs(energy - 2750.)  < 10)  return 2750;
index b225a88cf8614f6d251388200305d852f04f8957..d49d0c979f1a435a5f15f63a2eb7d53ea86046de 100644 (file)
@@ -22,6 +22,19 @@ class AliESDEvent;
 class AliForwardUtil : public TObject
 {
 public:
+    /** 
+     * Get the standard color for a ring  
+     *
+     * @param d Detector
+     * @param r Ring 
+     * 
+     * @return 
+     */
+  static Color_t RingColor(UShort_t d, Char_t r)
+  { 
+    return ((d == 1 ? kRed : (d == 2 ? kGreen : kBlue))
+           + ((r == 'I' || r == 'i') ? 2 : -2));
+  }
   //==================================================================
   /** 
    * @{ 
@@ -540,8 +553,7 @@ public:
      */
     Color_t Color() const 
     { 
-      return ((fDet == 1 ? kRed : (fDet == 2 ? kGreen : kBlue))
-             + ((fRing == 'I' || fRing == 'i') ? 2 : -2));
+      return AliForwardUtil::RingColor(fDet, fRing);
     }
     UShort_t fDet;   // Detector
     Char_t   fRing;  // Ring
index 8acd19a7f622afa6a451e7f045a9d17c601f63e7..4a066f365c0e1fe98d8ebca48554faf87e1de12c 100644 (file)
@@ -178,9 +178,9 @@ public:
    */
   void ScanDirectory(TSystemDirectory* dir, TChain* chain, bool recursive)
   {
-    gROOT->IndentLevel();
-    printf("Scanning %s ...\n", dir->GetName());
-    gROOT->IncreaseDirLevel();
+    // gROOT->IndentLevel();
+    // printf("Scanning %s ...\n", dir->GetName());
+    // gROOT->IncreaseDirLevel();
 
     // Get list of files, and go back to old working directory
     TString oldDir(gSystem->WorkingDirectory());
@@ -214,12 +214,12 @@ public:
       TString aod(Form("%s/%s", file->GetTitle(), name.Data()));
 
       // Print and add 
-      gROOT->IndentLevel();
-      printf("adding %s\n", aod.Data());
+      // gROOT->IndentLevel();
+      // printf("adding %s\n", aod.Data());
       chain->Add(aod);
 
     }
-    gROOT->DecreaseDirLevel();
+    // gROOT->DecreaseDirLevel();
   }
   
   //__________________________________________________________________
@@ -276,10 +276,12 @@ public:
     fTree->SetBranchAddress("Forward", &fAOD);
 
     // Set the branch pointer 
-    fTree->SetBranchAddress("ForwardMC", &fMCAOD);
+    if (fTree->GetBranch("ForwardMC"))
+      fTree->SetBranchAddress("ForwardMC", &fMCAOD);
 
     // Set the branch pointer 
-    fTree->SetBranchAddress("primary", &fPrimary);
+    if (fTree->GetBranch("primary"))
+      fTree->SetBranchAddress("primary", &fPrimary);
 
     fOut = TFile::Open(outname, "RECREATE");
     if (!fOut) { 
@@ -1023,27 +1025,26 @@ public:
        Int_t bin = (i-1)*rebin + j;
        if(h->GetBinContent(bin) <= 0) continue;
        Double_t c =  h->GetBinContent(bin);
-       
-       //Double_t w = 1 / TMath::Power(c,2);
-       Double_t w = 1 / TMath::Power(h->GetBinError(bin),2);
+       Double_t e =  h->GetBinError(bin);
+       Double_t w =  1 / (e*e); // 1/c/c
        content    += c;
        sumw       += w;
        wsum       += w * c;
        nbins++;
       }
       
-      if(content > 0 ) {
+      if(content > 0 && nbins > 0) {
        tmp->SetBinContent(i, wsum / sumw);
-       tmp->SetBinError(i,1/TMath::Sqrt(sumw));
+       tmp->SetBinError(i,1./TMath::Sqrt(sumw));
       }
     }
 
     // Finally, rebin the histogram, and set new content
     h->Rebin(rebin);
     h->Reset();
-    for(Int_t i =1;i<=nBinsNew; i++) {
+    for(Int_t i = 1; i<= nBinsNew; i++) {
       h->SetBinContent(i,tmp->GetBinContent(i));
-      h->SetBinError(i,tmp->GetBinError(i));
+      h->SetBinError(i,  tmp->GetBinError(i));
     }
     
     delete tmp;
index 0799a876cf65561e22b469f0c071aaa6cf37ea05..4dadd409a539920d97d91d724f83c41ea6997ae6 100644 (file)
@@ -46,16 +46,32 @@ void MakeAOD(const char* esddir,
 
   // --- ESD input handler -------------------------------------------
   AliESDInputHandler *esdHandler = new AliESDInputHandler();
-  esdHandler->SetInactiveBranches("AliESDACORDE "
-                                 "AliRawDataErrorLogs "
-                                 "CaloClusters "
-                                 "Cascades "
-                                 "EMCALCells "
+  esdHandler->SetInactiveBranches(// "AliESDRun " 
+                                 // "AliESDHeader "
+                                 // "AliESDZDC "
+                                 // "AliESDFMD "
+                                 // "AliESDVZERO " 
+                                 "AliESDTZERO " 
+                                 "TPCVertex " 
+                                 // "SPDVertex "
+                                 // "PrimaryVertex "
+                                 // "AliMultiplicity "
+                                 "PHOSTrigger "
                                  "EMCALTrigger "
-                                 "Kinks "
-                                 "Cascades "
-                                 "MuonTracks "
+                                 "SPDPileupVertices " 
+                                 "TrkPileupVertices " 
+                                 "Tracks "
+                                 "MuonTracks " 
+                                 "PmdTracks "
                                  "TrdTracks "
+                                 "V0s " 
+                                 "Cascades " 
+                                 "Kinks " 
+                                 "CaloClusters "
+                                 "EMCALLCells "
+                                 "PHOSCells "
+                                 "AliRawDataErrorLogs "
+                                 "ALIESDCACORDE " 
                                  "HLTGlobalTrigger");
   mgr->SetInputEventHandler(esdHandler);      
        
@@ -76,11 +92,13 @@ void MakeAOD(const char* esddir,
   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
   AddTaskPhysicsSelection(mc, kTRUE, kTRUE);
 
-#if 0
+#if 1
   // Centrality 
   gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/Compile.C");
   // gDebug = 10;
   Compile("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskCopyHeader.C","+");
+  // gDebug = 10;
+  Compile("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/AliESDCentrality.C","+g");
   // gDebug = 0;
   AddTaskCopyHeader();
 #endif
diff --git a/PWG2/FORWARD/analysis2/scripts/CompareSecMaps.C b/PWG2/FORWARD/analysis2/scripts/CompareSecMaps.C
new file mode 100644 (file)
index 0000000..82fbe2a
--- /dev/null
@@ -0,0 +1,208 @@
+/** 
+ * Make ratio of two specific maps 
+ * 
+ * @param d        Detector
+ * @param r        Ring
+ * @param v        Vertex bin (1 based)
+ * @param first    First correction
+ * @param second   Second correction
+ * 
+ * @return Ratio of the two, or null
+ */
+TH2*
+Compare2Maps(UShort_t d, Char_t r, UShort_t v, 
+            const AliFMDCorrSecondaryMap& first, 
+            const AliFMDCorrSecondaryMap& second)
+{
+  TH2* h1 = first.GetCorrection(d, r, v);
+  TH2* h2 = second.GetCorrection(d, r, v);
+  
+  if (!h1) { 
+    Error("Compare2Maps", "Map for FMD%d%c, vtxbin %3d not found in first", 
+         d, r, v);
+    return 0;
+  }
+  if (!h1) { 
+    Error("Compare2Maps", "Map for FMD%d%c, vtxbin %3d not found in second", 
+         d, r, v);
+    return 0;
+  }
+  
+  Double_t vl    = first.GetVertexAxis().GetBinLowEdge(v);
+  Double_t vh    = first.GetVertexAxis().GetBinUpEdge(v);
+  TH2*     ratio = static_cast<TH2*>(h1->Clone(Form("tmpFMD%d%c_%3d",d,r,v)));
+  ratio->SetName(Form("FMD%d%c_vtx%03d_ratio", d, r, v));
+  ratio->SetTitle(Form("%+5.1f<v_{z}<%-+5.1f", vl, vh));
+  ratio->Divide(h2);
+  ratio->SetStats(0);
+  ratio->SetDirectory(0);
+  ratio->SetZTitle("ratio");
+  // ratio->SetMinimum(0.9);
+  // ratio->SetMaximum(1.5);
+
+  return ratio;
+}
+
+//____________________________________________________________________
+TPad* 
+ClearCanvas(TCanvas* c, UShort_t nVtx, UShort_t d, Char_t r, 
+           const char* n1, const char* n2)
+{
+  c->Clear();
+  TPad* p1 = new TPad("top", "Top", 0, .95, 1, 1, 0, 0);
+  p1->Draw();
+  p1->cd();
+
+  TLatex* l = new TLatex(.5, .5, Form("Ratio of secondary maps for "
+                                      "FMD%d%c (%s / %s)", d, r, n1, n2));
+  l->SetNDC();
+  l->SetTextAlign(22);
+  l->SetTextSize(0.3);
+  l->Draw();
+  
+  c->cd();
+  TPad* body = new TPad("body", "Body", 0, 0, 1, .95, 0, 0);
+  body->SetTopMargin(0.05);
+  body->SetRightMargin(0.05);
+  body->Divide(2, (nVtx+1)/2, 0.001, 0.001);
+  body->Draw();
+
+  return body;
+}
+
+//____________________________________________________________________
+void
+CompareSecMaps(const char* fn1,   const char* fn2, 
+              const char* n1=0,  const char* n2=0)
+{
+
+  // --- Load libraries ----------------------------------------------
+  // gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
+  
+  // --- Open files --------------------------------------------------
+  const char* nam1 = n1;
+  const char* nam2 = n2;
+  if (!n1) nam1 = fn1;                         
+  if (!n2) nam2 = fn2;
+
+  TFile* file1 = TFile::Open(fn1, "READ");
+  TFile* file2 = TFile::Open(fn2, "READ");
+
+  if (!file1) { 
+    Error("CompareSecMaps", "File %s cannot be opened for %s", fn1, n1);
+    return;
+  }
+
+  if (!file2) { 
+    Error("CompareSecMaps", "File %s cannot be opened for %s", fn2, n2);
+    return;
+  }
+  
+  // --- Find Objects ------------------------------------------------
+  const char* objName = AliForwardCorrectionManager::Instance()
+    .GetObjectName(AliForwardCorrectionManager::kSecondaryMap);
+  
+  AliFMDCorrSecondaryMap* obj1 = 
+    static_cast<AliFMDCorrSecondaryMap*>(file1->Get(objName));
+  AliFMDCorrSecondaryMap* obj2 = 
+    static_cast<AliFMDCorrSecondaryMap*>(file2->Get(objName));
+  
+  if (!obj1) {
+    Error("CompareSecMaps", "File %s does not contain an object named %s", 
+         fn1, objName);
+    return;
+  }
+  if (!obj2) {
+    Error("CompareSecMaps", "File %s does not contain an object named %s", 
+         fn2, objName);
+    return;
+  }
+  UShort_t nVtx = obj1->GetVertexAxis().GetNbins();
+
+  // --- Make canvas -------------------------------------------------
+  const char* pdfName = "secMapComparison.pdf";
+  gStyle->SetPalette(1);
+  gStyle->SetTitleX(.10);
+  gStyle->SetTitleY(.99);
+  gStyle->SetTitleW(.85);
+  gStyle->SetTitleH(.085);
+  gStyle->SetTitleFillColor(0);
+  gStyle->SetTitleBorderSize(0);
+
+  TCanvas* c = new TCanvas("c", "c", 800, TMath::Sqrt(2)*800);
+  c->SetFillColor(0);
+  
+  c->Print(Form("%s[", pdfName), "pdf");
+
+  for (UShort_t d = 1; d <= 3; d++) { 
+    UShort_t nR = (d == 1 ? 1 : 2);
+    for (UShort_t q = 0; q < nR; q++) { 
+      Char_t   r  = (q == 0 ? 'I' : 'O');
+      UShort_t nS = (q == 0 ?  20 :  40);
+
+      TPad* body = ClearCanvas(c, nVtx, d, r, nam1, nam2);
+      TList hists;
+      for (UShort_t v=1; v <= nVtx; v++) { 
+       TVirtualPad* p = body->cd(v);
+       // p->SetTopMargin(0.1);
+       // p->SetBottomMargin(0.05);
+       // p->SetRightMargin(0.05);
+       
+       TH2* ratio = Compare2Maps(d, r, v, *obj1, *obj2);
+       if (ratio->GetMaximum()-ratio->GetMinimum() > 10) 
+         p->SetLogz();
+
+       ratio->Draw("colz");
+       hists.AddAt(ratio, v-1);
+      }
+      c->Print(pdfName, Form("Title:FMD%d%c", d, r));
+      
+      body = ClearCanvas(c, nVtx, d, r, nam1, nam2);
+
+      for (UShort_t v=1; v <= nVtx; v++) { 
+       TVirtualPad* p    = body->cd(v);
+       TH2*         hist = static_cast<TH2*>(hists.At(v-1));
+       TH1*         prof = hist->ProjectionX();
+       prof->Scale(1. / nS);
+       prof->SetStats(0);
+       prof->SetMinimum(0.8);
+       prof->SetMaximum(1.2);
+
+       // prof->Draw("hist");
+       // prof->DrawCopy("e same");
+       prof->Draw();
+       prof->Fit("pol0","Q");
+
+       TF1* f = prof->GetFunction("pol0");
+
+       TLatex* l = new TLatex(0.5, 0.4, Form("A = %f #pm %f", 
+                                             f->GetParameter(0), 
+                                             f->GetParError(0)));
+       l->SetTextAlign(22);
+       l->SetNDC();
+       l->Draw();
+       l->DrawLatex(0.5, 0.3, Form("#chi^2/NDF = %f / %d = %f", 
+                                   f->GetChisquare(), 
+                                   f->GetNDF(), 
+                                   f->GetChisquare() / f->GetNDF()));
+       Double_t dist = TMath::Abs(1 - f->GetParameter(0));
+       l->DrawLatex(0.5, 0.35, Form("|1 - A| = %f %s #deltaA", 
+                                    dist, dist <= f->GetParError(0) ? 
+                                    "#leq" : ">")); 
+
+       TLine* l1 = new TLine(-4, 1, 6, 1);
+       l1->SetLineColor(kRed);
+       l1->SetLineStyle(2);
+       l1->Draw();
+      }
+
+      c->Print(pdfName, Form("Title:FMD%d%c profiles", d, r));
+    }
+  }
+
+  c->Print(Form("%s]", pdfName), "pdf");
+  file1->Close();
+  file2->Close();
+}
+
+  
index 09aded15d3162a4251d3000eac8712466214b084..1eb5204461748efe676eb786b6c499210f12162f 100644 (file)
@@ -4,6 +4,17 @@ Color_t Color(UShort_t d, Char_t r ) const
          + ((r == 'I' || r == 'i') ? 2 : -2));
 }
 
+void
+RunCopyELossFit(UShort_t sys, UShort_t cms, Short_t field, Bool_t mc=false,
+               const Char_t* path=0)
+{
+  RunCopyELossFit(sys == 1 ? "pp" : "PbPb", 
+                 cms, 
+                 field, 
+                 mc,
+                 path);
+}
+
 /** 
  * 
  * @param sys       Collision system 
@@ -13,7 +24,8 @@ Color_t Color(UShort_t d, Char_t r ) const
  * @ingroup pwg2_forward_analysis_scripts
  */
 void
-RunCopyELossFit(UShort_t sys, UShort_t cms, Short_t field, bool mc=false)
+RunCopyELossFit(const char* sys, UShort_t cms, Short_t field, bool mc=false,
+               const char* path=0)
 {
   gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
   gSystem->Load("libPWG2forward.so");
@@ -22,7 +34,13 @@ RunCopyELossFit(UShort_t sys, UShort_t cms, Short_t field, bool mc=false)
   p->SetRealData(!mc);
   p->SetEnergy(Float_t(cms));
   p->SetMagField(Float_t(field));
-  p->SetCollisionSystem(sys == 1 ? "pp" : "PbPb");
+  p->SetCollisionSystem(sys);
+  if (path) {
+    p->SetBackgroundPath(path);
+    p->SetEnergyPath(path);
+    p->SetEventSelectionPath(path);
+    p->SetSharingEfficiencyPath(path);
+  }
   p->Init(true, AliFMDAnaParameters::kBackgroundCorrection|
          AliFMDAnaParameters::kEnergyDistributions);
   
@@ -109,9 +127,10 @@ RunCopyELossFit(UShort_t sys, UShort_t cms, Short_t field, bool mc=false)
       }
     }
   }
+  UShort_t isys = AliForwardUtil::ParseCollisionSystem(sys);
   AliForwardCorrectionManager& mgr = AliForwardCorrectionManager::Instance();
   TString fname(mgr.GetFileName(AliForwardCorrectionManager::kELossFits,
-                               sys, cms, field, mc));
+                               isys, cms, field, mc));
   TFile* output = TFile::Open(fname.Data(), "RECREATE");
   if (!output) { 
     Warning("RunCopyELossFit", "Failed to open output file %s", fname.Data());
index 641f6a2afab0037e22175ce09540f67e0f79516e..0c1b833d46d1ae557268d746afe8510286fc1871 100644 (file)
@@ -4,6 +4,15 @@ Color_t Color(UShort_t d, Char_t r ) const
          + ((r == 'I' || r == 'i') ? 2 : -2));
 }
 
+void
+RunCopyMergeEff(UShort_t sys, UShort_t cms, Short_t field, const Char_t* path=0)
+{
+  RunCopyMergeEff(sys == 1 ? "pp" : "PbPb", 
+                 cms, 
+                 field, 
+                 path);
+}
+
 /** 
  * 
  * @param sys       Collision system 
@@ -13,7 +22,8 @@ Color_t Color(UShort_t d, Char_t r ) const
  * @ingroup pwg2_forward_analysis_scripts
  */
 void
-RunCopyMergeEff(UShort_t sys, UShort_t cms, Short_t field)
+RunCopyMergeEff(const char* sys, UShort_t cms, 
+               Short_t field, const char* path=0)
 {
   gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
   gSystem->Load("libPWG2forward.so");
@@ -21,7 +31,13 @@ RunCopyMergeEff(UShort_t sys, UShort_t cms, Short_t field)
   AliFMDAnaParameters* p = AliFMDAnaParameters::Instance();
   p->SetEnergy(Float_t(cms));
   p->SetMagField(Float_t(field));
-  p->SetCollisionSystem(sys == 1 ? "pp" : "PbPb");
+  p->SetCollisionSystem(sys);
+  if (path) {
+    p->SetBackgroundPath(path);
+    p->SetEnergyPath(path);
+    p->SetEventSelectionPath(path);
+    p->SetSharingEfficiencyPath(path);
+  }
   p->Init(true, AliFMDAnaParameters::kBackgroundCorrection|
          AliFMDAnaParameters::kSharingEfficiency);
   
@@ -70,9 +86,10 @@ RunCopyMergeEff(UShort_t sys, UShort_t cms, Short_t field)
       }
     }
   }
+  UShort_t isys = AliForwardUtil::ParseCollisionSystem(sys);
   AliForwardCorrectionManager& mgr = AliForwardCorrectionManager::Instance();
   TString fname(mgr.GetFileName(AliForwardCorrectionManager::kMergingEfficiency,
-                               sys, cms, field, false));
+                               isys, cms, field, false));
   TFile* output = TFile::Open(fname.Data(), "RECREATE");
   if (!output) { 
     Warning("Run", "Failed to open output file %s", fname.Data());
index 6bc8ec4da488eaa23a575700f792e825a5a91eaf..91544a5f260aec33414b7ed49992e88ef6aec874 100644 (file)
@@ -4,6 +4,14 @@ Color_t Color(UShort_t d, Char_t r ) const
          + ((r == 'I' || r == 'i') ? 2 : -2));
 }
 
+void
+RunCopySecMap(UShort_t sys, UShort_t cms, Short_t field, const Char_t* path=0)
+{
+  RunCopySecMap(sys == 1 ? "pp" : "PbPb", 
+               cms, 
+               field, 
+               path);
+}
 /** 
  * 
  * @param sys       Collision system 
@@ -13,7 +21,8 @@ Color_t Color(UShort_t d, Char_t r ) const
  * @ingroup pwg2_forward_analysis_scripts
  */
 void
-RunCopySecMap(UShort_t sys, UShort_t cms, Short_t field)
+RunCopySecMap(const char* sys, UShort_t cms, Short_t field,
+             const Char_t* path=0)
 {
   gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
   gSystem->Load("libPWG2forward.so");
@@ -21,7 +30,13 @@ RunCopySecMap(UShort_t sys, UShort_t cms, Short_t field)
   AliFMDAnaParameters* p = AliFMDAnaParameters::Instance();
   p->SetEnergy(Float_t(cms));
   p->SetMagField(Float_t(field));
-  p->SetCollisionSystem(sys == 1 ? "pp" : "PbPb");
+  p->SetCollisionSystem(sys);
+  if (path) {
+    p->SetBackgroundPath(path);
+    p->SetEnergyPath(path);
+    p->SetEventSelectionPath(path);
+    p->SetSharingEfficiencyPath(path);
+  }
   p->Init(true, AliFMDAnaParameters::kBackgroundCorrection);
  
   Int_t    nVtx   = p->GetNvtxBins();
@@ -99,9 +114,10 @@ RunCopySecMap(UShort_t sys, UShort_t cms, Short_t field)
       }
     }
   }
+  UShort_t isys = AliForwardUtil::ParseCollisionSystem(sys);
   AliForwardCorrectionManager& mgr = AliForwardCorrectionManager::Instance();
   TString fname(mgr.GetFileName(AliForwardCorrectionManager::kSecondaryMap,
-                               sys, cms, field, false));
+                               isys, cms, field, false));
   TFile* output = TFile::Open(fname.Data(), "RECREATE");
   if (!output) { 
     Warning("Run", "Failed to open output file %s", fname.Data());
@@ -114,7 +130,7 @@ RunCopySecMap(UShort_t sys, UShort_t cms, Short_t field)
        fname.Data(),mgr.GetFileDir(AliForwardCorrectionManager::kSecondaryMap));
 
   fname = mgr.GetFileName(AliForwardCorrectionManager::kDoubleHit,
-                         sys, cms, field, false);
+                         isys, cms, field, false);
   output = TFile::Open(fname.Data(), "RECREATE");
   if (!output) { 
     Warning("Run", "Failed to open output file %s", fname.Data());
index 1da2b01b1b9f2591b2b2476a817eebde7ec6fcdf..2ede02dd38c5c5f57e74b51d243e7bcdb843491e 100644 (file)
@@ -4,6 +4,12 @@ Color_t Color(UShort_t d, Char_t r ) const
          + ((r == 'I' || r == 'i') ? 2 : -2));
 }
 
+void
+RunCopyVtxBias(UShort_t sys, UShort_t cms, Short_t field, const char* path=0)
+{
+  RunCopyVtxBias(sys == 1 ? "pp" : "PbPb", cms, field, path);
+}
+
 /** 
  * 
  * @param sys       Collision system 
@@ -13,7 +19,7 @@ Color_t Color(UShort_t d, Char_t r ) const
  * @ingroup pwg2_forward_analysis_scripts
  */
 void
-RunCopyVtxBias(UShort_t sys, UShort_t cms, Short_t field)
+RunCopyVtxBias(const char* sys, UShort_t cms, Short_t field, const char* path=0)
 {
   gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
   gSystem->Load("libPWG2forward.so");
@@ -21,7 +27,13 @@ RunCopyVtxBias(UShort_t sys, UShort_t cms, Short_t field)
   AliFMDAnaParameters* p = AliFMDAnaParameters::Instance();
   p->SetEnergy(Float_t(cms));
   p->SetMagField(Float_t(field));
-  p->SetCollisionSystem(sys == 1 ? "pp" : "PbPb");
+  p->SetCollisionSystem(sys);
+  if (path) {
+    p->SetBackgroundPath(path);
+    p->SetEnergyPath(path);
+    p->SetEventSelectionPath(path);
+    p->SetSharingEfficiencyPath(path);
+  }
   p->Init(true, AliFMDAnaParameters::kBackgroundCorrection|
          AliFMDAnaParameters::kEventSelectionEfficiency);
  
@@ -72,9 +84,10 @@ RunCopyVtxBias(UShort_t sys, UShort_t cms, Short_t field)
       obj->SetCorrection(r, b, newcorr);
     }
   }
+  UShort_t isys = AliForwardUtil::ParseCollisionSystem(sys);
   AliForwardCorrectionManager& mgr = AliForwardCorrectionManager::Instance();
   TString fname(mgr.GetFileName(AliForwardCorrectionManager::kVertexBias,
-                               sys, cms, field, false));
+                               isys, cms, field, false));
   TFile* output = TFile::Open(fname.Data(), "RECREATE");
   if (!output) { 
     Warning("Run", "Failed to open output file %s", fname.Data());
index 98d97720465d44b506fa66177819995176dcc3ac..a04447515961600c19cbd219e69d7015ab3c238d 100644 (file)
@@ -29,6 +29,7 @@
 
 #pragma link C++ nestedclasses;
 
+#pragma link C++ class AliForwardUtil+;
 #pragma link C++ class AliForwardUtil::Histos+;
 #pragma link C++ class AliForwardUtil::RingHistos+;
 #pragma link C++ class AliFMDEventInspector+;