]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/TenderSupplies/AliT0TenderSupply.cxx
end-of-line normalization
[u/mrichter/AliRoot.git] / ANALYSIS / TenderSupplies / AliT0TenderSupply.cxx
index 1cce68edfb4ed3112ad8fe40751c65a351e5b4c2..5b8a13a8c964204f59b286f2cbc59d0209b0a06d 100644 (file)
-/**************************************************************************\r
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
- *                                                                        *\r
- * Author: The ALICE Off-line Project.                                    *\r
- * Contributors are mentioned in the code where appropriate.              *\r
- *                                                                        *\r
- * Permission to use, copy, modify and distribute this software and its   *\r
- * documentation strictly for non-commercial purposes is hereby granted   *\r
- * without fee, provided that the above copyright notice appears in all   *\r
- * copies and that both the copyright notice and this permission notice   *\r
- * appear in the supporting documentation. The authors make no claims     *\r
- * about the suitability of this software for any purpose. It is          *\r
- * provided "as is" without express or implied warranty.                  *\r
- **************************************************************************/\r
-\r
-///////////////////////////////////////////////////////////////////////////\r
-//                                                                       //\r
-//  T0 Tender supply    //\r
-//  //\r
-//                                                                       //\r
-///////////////////////////////////////////////////////////////////////////\r
-\r
-#include <AliESDEvent.h>\r
-#include <AliESDtrack.h>\r
-#include <AliTender.h>\r
-#include <AliT0TenderSupply.h>\r
-#include <AliCDBManager.h>\r
-#include <AliCDBEntry.h>\r
-#include <AliT0CalibSeasonTimeShift.h>\r
-#include <AliESDInputHandler.h>\r
-\r
-ClassImp(AliT0TenderSupply)\r
-\r
-//________________________________________________________________________\r
-AliT0TenderSupply::AliT0TenderSupply():\r
-  AliTenderSupply(),\r
-  fCorrectMeanTime(kFALSE),\r
-  fCorrectStartTimeOnAmplSatur(kFALSE),\r
-  fAmplitudeThreshold(100), \r
-  fPass4LHC11aCorrection(kFALSE)\r
-{\r
-  //\r
-  // default constructor\r
-  //\r
-  for(int i=0; i<4; i++) fTimeOffset[i]=0;\r
-}\r
-\r
-//________________________________________________________________________\r
-AliT0TenderSupply::AliT0TenderSupply(const char *name, const AliTender *tender):\r
-  AliTenderSupply(name,tender),\r
-  fCorrectMeanTime(kFALSE),\r
-  fCorrectStartTimeOnAmplSatur(kFALSE),\r
-  fAmplitudeThreshold(100),\r
-  fPass4LHC11aCorrection(kFALSE)\r
-{\r
-  //\r
-  // constructor\r
-  //\r
-  for(int i=0; i<4; i++) fTimeOffset[i]=0;\r
-\r
-}\r
-\r
-//________________________________________________________________________\r
-AliT0TenderSupply::~AliT0TenderSupply(){\r
-  //\r
-  // destructor\r
-  //\r
-  \r
-}\r
-\r
-//________________________________________________________________________\r
-void AliT0TenderSupply::Init(){\r
-  // Init\r
-  //\r
-  Int_t run = fTender->GetRun();\r
-  if (run == 0) return;    // to skip first init, when we don't have yet a run number\r
-  Printf("----------- TZERO Tender ----------------");\r
-\r
-  fCorrectMeanTime = kFALSE; //reset\r
-  for(int i=0; i<4; i++) fTimeOffset[i]=0;\r
-\r
-  // align T0s for LHC10def periods \r
-  if (fTender->GetRun()>=122195 &&  fTender->GetRun()<=130850){\r
-    Printf("Loading TZERO OCBD entries");\r
-    fCorrectMeanTime=kTRUE;\r
-    Printf("fCorrectMeanTime %i \n", fCorrectMeanTime);\r
\r
-    AliCDBManager* ocdbMan = AliCDBManager::Instance();\r
-    ocdbMan->SetRun(fTender->GetRun());    \r
-    AliCDBEntry *entry = ocdbMan->Get("T0/Calib/TimeAdjust/");\r
-    if(entry) {\r
-      AliT0CalibSeasonTimeShift *clb = (AliT0CalibSeasonTimeShift*) entry->GetObject();\r
-      Float_t *t0means = clb->GetT0Means();\r
-      for (Int_t i=0;i<4;i++) fTimeOffset[i] = t0means[i];\r
-    } else {\r
-      for (Int_t i=0;i<4;i++) fTimeOffset[i] = 0;\r
-      AliWarning("T0Tender no T0 entry found T0shift set to 0");\r
-    }\r
-  }  \r
-       \r
-  // LHC11h\r
-  fCorrectStartTimeOnAmplSatur = kFALSE;\r
-  fAmplitudeThreshold = 100; //in mips\r
-  if(167693<= run && run<=170593){  \r
-    fCorrectStartTimeOnAmplSatur = kTRUE;\r
-    fAmplitudeThreshold = 50; //in mips\r
-  }\r
-\r
-\r
-\r
-}\r
-\r
-//________________________________________________________________________\r
-void AliT0TenderSupply::ProcessEvent(){\r
-\r
-    //\r
-    // loop over all online T0 candidates and flag\r
-    // selected daughter tracks using the status bis of the TObject\r
-    //\r
-\r
-    AliESDEvent *event=fTender->GetEvent();\r
-    if (!event) return;\r
-     //...........................................\r
-   //Do something when the run number changed, like loading OCDB entries etc.\r
-     if(fTender->RunChanged()) Init();\r
-    \r
-   if(fTender->RunChanged()){\r
-      Init();\r
-      if (fTender->GetRun()>=139699&&  fTender->GetRun()<=146860){\r
-        AliESDInputHandler *esdIH = dynamic_cast<AliESDInputHandler*>  (fTender->GetESDhandler());\r
-        if (esdIH) {\r
-          TTree *tree= (TTree*)esdIH->GetTree();\r
-          TFile *file= (TFile*)tree->GetCurrentFile();\r
-         if (file){\r
-            TString fileName(file->GetName());\r
-           if (fileName.Contains("pass4") ) fPass4LHC11aCorrection=kTRUE;\r
-         }\r
-       }\r
-      }\r
-    }\r
-    \r
-    if(fPass4LHC11aCorrection) {\r
-      const Double32_t* mean = event->GetT0TOF();\r
-      event->SetT0TOF(0, (mean[1]+mean[2])/2.);\r
\r
-    }\r
-    //...........................................\r
-    if(fCorrectStartTimeOnAmplSatur){\r
-        //correct A side ORA on amplitude saturation\r
-        const Double32_t* time = event->GetT0time();\r
-        const Double32_t* amplitude = event->GetT0amplitude();\r
-\r
-        Int_t idxOfFirstPmtA = -1;\r
-        Double32_t timeOrA   = 99999;\r
-        for(int ipmt=12; ipmt<24; ipmt++){ //loop over A side\r
-            if( amplitude[ipmt] < fAmplitudeThreshold){\r
-                if( time[ipmt] > -200 && time[ipmt]!=0 && time[ipmt] < timeOrA ){ \r
-                    timeOrA        = time[ipmt];\r
-                    idxOfFirstPmtA = ipmt;\r
-                }\r
-            }\r
-        }\r
-\r
-        if(idxOfFirstPmtA>-1){ //a hit in aside with less than 40 mips\r
-            const Double32_t* mean = event->GetT0TOF();\r
-            Double32_t timeOrC = mean[2];\r
-            Double32_t timeOrAplusOrC = (timeOrA+timeOrC)/2;\r
-\r
-            event->SetT0TOF(0, timeOrAplusOrC);\r
-            event->SetT0TOF(1, timeOrA);\r
-        }\r
-    }\r
-\r
-    //...........................................\r
-    if(fCorrectMeanTime) {\r
-      // correct mean time offsets  \r
-      const Double32_t* mean = event->GetT0TOF();\r
-      for(int it0=0; it0<3; it0++){\r
-       if( mean[it0] < 10000 || (mean[it0]>6499000 && mean[it0]<6555000 ) )\r
-         event->SetT0TOF(it0, mean[it0] - fTimeOffset[it0]); \r
-      }\r
-    }\r
-    //...........................................\r
-\r
-\r
-}\r
-\r
-\r
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+//  T0 Tender supply    //
+//  //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+#include <AliESDEvent.h>
+#include <AliESDtrack.h>
+#include <AliTender.h>
+#include <AliT0TenderSupply.h>
+#include <AliCDBManager.h>
+#include <AliCDBEntry.h>
+#include <AliT0CalibSeasonTimeShift.h>
+#include <AliESDInputHandler.h>
+
+ClassImp(AliT0TenderSupply)
+
+//________________________________________________________________________
+AliT0TenderSupply::AliT0TenderSupply():
+  AliTenderSupply(),
+  fCorrectMeanTime(kFALSE),
+  fCorrectStartTimeOnAmplSatur(kFALSE),
+  fAmplitudeThreshold(100), 
+  fPass4LHC11aCorrection(kFALSE)
+{
+  //
+  // default constructor
+  //
+  for(int i=0; i<4; i++) fTimeOffset[i]=0;
+}
+
+//________________________________________________________________________
+AliT0TenderSupply::AliT0TenderSupply(const char *name, const AliTender *tender):
+  AliTenderSupply(name,tender),
+  fCorrectMeanTime(kFALSE),
+  fCorrectStartTimeOnAmplSatur(kFALSE),
+  fAmplitudeThreshold(100),
+  fPass4LHC11aCorrection(kFALSE)
+{
+  //
+  // constructor
+  //
+  for(int i=0; i<4; i++) fTimeOffset[i]=0;
+
+}
+
+//________________________________________________________________________
+AliT0TenderSupply::~AliT0TenderSupply(){
+  //
+  // destructor
+  //
+  
+}
+
+//________________________________________________________________________
+void AliT0TenderSupply::Init(){
+  // Init
+  //
+  Int_t run = fTender->GetRun();
+  if (run == 0) return;    // to skip first init, when we don't have yet a run number
+  Printf("----------- TZERO Tender ----------------");
+
+  fCorrectMeanTime = kFALSE; //reset
+  for(int i=0; i<4; i++) fTimeOffset[i]=0;
+
+  // align T0s for LHC10def periods 
+  if (fTender->GetRun()>=122195 &&  fTender->GetRun()<=130850){
+    Printf("Loading TZERO OCBD entries");
+    fCorrectMeanTime=kTRUE;
+    Printf("fCorrectMeanTime %i \n", fCorrectMeanTime);
+    AliCDBManager* ocdbMan = AliCDBManager::Instance();
+    ocdbMan->SetRun(fTender->GetRun());    
+    AliCDBEntry *entry = ocdbMan->Get("T0/Calib/TimeAdjust/");
+    if(entry) {
+      AliT0CalibSeasonTimeShift *clb = (AliT0CalibSeasonTimeShift*) entry->GetObject();
+      Float_t *t0means = clb->GetT0Means();
+      for (Int_t i=0;i<4;i++) fTimeOffset[i] = t0means[i];
+    } else {
+      for (Int_t i=0;i<4;i++) fTimeOffset[i] = 0;
+      AliWarning("T0Tender no T0 entry found T0shift set to 0");
+    }
+  }  
+       
+  // LHC11h
+  fCorrectStartTimeOnAmplSatur = kFALSE;
+  fAmplitudeThreshold = 100; //in mips
+  if(167693<= run && run<=170593){  
+    fCorrectStartTimeOnAmplSatur = kTRUE;
+    fAmplitudeThreshold = 50; //in mips
+  }
+
+
+
+}
+
+//________________________________________________________________________
+void AliT0TenderSupply::ProcessEvent(){
+
+    //
+    // loop over all online T0 candidates and flag
+    // selected daughter tracks using the status bis of the TObject
+    //
+
+    AliESDEvent *event=fTender->GetEvent();
+    if (!event) return;
+     //...........................................
+   //Do something when the run number changed, like loading OCDB entries etc.
+     if(fTender->RunChanged()) Init();
+    
+   if(fTender->RunChanged()){
+      Init();
+      if (fTender->GetRun()>=139699&&  fTender->GetRun()<=146860){
+        AliESDInputHandler *esdIH = dynamic_cast<AliESDInputHandler*>  (fTender->GetESDhandler());
+        if (esdIH) {
+          TTree *tree= (TTree*)esdIH->GetTree();
+          TFile *file= (TFile*)tree->GetCurrentFile();
+         if (file){
+            TString fileName(file->GetName());
+           if (fileName.Contains("pass4") ) fPass4LHC11aCorrection=kTRUE;
+         }
+       }
+      }
+    }
+    
+    if(fPass4LHC11aCorrection) {
+      const Double32_t* mean = event->GetT0TOF();
+      event->SetT0TOF(0, (mean[1]+mean[2])/2.);
+    }
+    //...........................................
+    if(fCorrectStartTimeOnAmplSatur){
+        //correct A side ORA on amplitude saturation
+        const Double32_t* time = event->GetT0time();
+        const Double32_t* amplitude = event->GetT0amplitude();
+
+        Int_t idxOfFirstPmtA = -1;
+        Double32_t timeOrA   = 99999;
+        for(int ipmt=12; ipmt<24; ipmt++){ //loop over A side
+            if( amplitude[ipmt] < fAmplitudeThreshold){
+                if( time[ipmt] > -200 && time[ipmt]!=0 && time[ipmt] < timeOrA ){ 
+                    timeOrA        = time[ipmt];
+                    idxOfFirstPmtA = ipmt;
+                }
+            }
+        }
+
+        if(idxOfFirstPmtA>-1){ //a hit in aside with less than 40 mips
+            const Double32_t* mean = event->GetT0TOF();
+            Double32_t timeOrC = mean[2];
+            Double32_t timeOrAplusOrC = (timeOrA+timeOrC)/2;
+
+            event->SetT0TOF(0, timeOrAplusOrC);
+            event->SetT0TOF(1, timeOrA);
+        }
+    }
+
+    //...........................................
+    if(fCorrectMeanTime) {
+      // correct mean time offsets  
+      const Double32_t* mean = event->GetT0TOF();
+      for(int it0=0; it0<3; it0++){
+       if( mean[it0] < 10000 || (mean[it0]>6499000 && mean[it0]<6555000 ) )
+         event->SetT0TOF(it0, mean[it0] - fTimeOffset[it0]); 
+      }
+    }
+    //...........................................
+
+
+}
+
+