]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSPreprocessorPHYS.cxx
DA for calibrating energy by pi0 and MIP and related classes (Hisayuki Torii).
[u/mrichter/AliRoot.git] / PHOS / AliPHOSPreprocessorPHYS.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 ///////////////////////////////////////////////////////////////////////////////
17 // PHOS Preprocessor class. It runs by Shuttle at the end of the run,
18 // calculates calibration coefficients and dead/bad channels
19 // to be posted in OCDB
20 //
21 // Author: Hisayuki Torii, 11 August 2009
22 ///////////////////////////////////////////////////////////////////////////////
23 #include "AliLog.h"
24 #include "TFile.h"
25 #include "TKey.h"
26 #include "TList.h"
27 #include "TString.h"
28 #include "TObjString.h"
29
30 #include "AliPHOSPreprocessorPHYS.h"
31
32 ClassImp(AliPHOSPreprocessorPHYS)
33
34 //_______________________________________________________________________________________
35 AliPHOSPreprocessorPHYS::AliPHOSPreprocessorPHYS() : AliPreprocessor("PHS",0) {
36   //default constructor
37 }
38 //_______________________________________________________________________________________
39 AliPHOSPreprocessorPHYS::AliPHOSPreprocessorPHYS(AliShuttleInterface* shuttle): AliPreprocessor("PHS",shuttle) {
40   // Constructor
41
42   AddRunType("PHYSICS");
43   AddRunType("COSMICS"); // Does this exist??
44 }
45 //_______________________________________________________________________________________
46 UInt_t AliPHOSPreprocessorPHYS::Process(TMap* /*valueSet*/){
47   // process data retrieved by the Shuttle
48   //
49   
50   TString runType = GetRunType();
51   Log(Form("Run type: %s",runType.Data()));
52
53   if( runType=="PHYSICS" || runType=="COSMICS") {
54     
55     Bool_t calibEmc_OK = CalibratePhys();
56     if(calibEmc_OK) return 0;
57     else return 1;
58   }
59   Log(Form("Unknown run type %s. Do nothing and return OK.",runType.Data()));
60   return 0;
61 }
62 //_______________________________________________________________________________________
63 Bool_t AliPHOSPreprocessorPHYS::CalibratePhys(){
64   //process PHYSICS event retrieved by the Shuttle
65   //
66   
67   TList* list = 0;
68   list = GetFileSources(kDAQ,"PHOSDApi0mip");
69   if(!list) {
70     Log(Form("DAQ sources list not found!"));
71     return kFALSE;
72   }
73   if(!list->GetEntries()) {
74     Log(Form("Got empty sources list. It seems PHYS DA did not produce any files!"));
75     return kFALSE;
76   }
77
78   TIter iter(list);
79   TObjString *source;
80   
81   while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
82     AliInfo(Form("found source %s", source->String().Data()));
83
84     TString fileName = GetFile(kDAQ, "PHOSDApi0mip", source->GetName());
85     AliInfo(Form("Got filename: %s",fileName.Data()));
86
87     TFile* file = TFile::Open(fileName);
88     if(!file) {
89       Log(Form("File %s is not opened, something goes wrong!",fileName.Data()));
90       return kFALSE;
91     }
92
93     file->ls();
94     //TList * keylist = file->GetListOfKeys();
95     Int_t nkeys   = file->GetNkeys();
96     if(nkeys==0){
97       Log(Form("Not enough  (%d) for calibration.",nkeys));
98       return 1; // it's not fatal! May be short run..
99     }
100     
101     file->Close();
102     delete file;
103
104
105   }
106   return kTRUE;
107 }
108 //_______________________________________________________________________________________
109      
110