]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ACORDE/AliACORDEPreprocessor.cxx
Fix for coverity defects
[u/mrichter/AliRoot.git] / ACORDE / AliACORDEPreprocessor.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
18 #include "AliACORDEPreprocessor.h"
19 #include "TRandom.h"
20 #include "TFile.h"
21 #include "AliCDBMetaData.h"
22 #include "AliCDBEntry.h"
23 #include "AliLog.h"
24 #include "AliACORDECalibData.h"
25 #include "AliACORDEDataDCS.h"
26
27 #include <TTimeStamp.h>
28 #include <TObjString.h>
29 #include <TList.h>
30 #include <TH1F.h>
31
32 //ACORDE Preprocessor
33 // It takes data from DAQ and passes it to the class AliACORDECalibModule and 
34 // stores reference data.
35 //
36 // Authors
37 // Pedro Gonzalez pedro.gonzalez@fcfm.buap.mx
38 // Irais Bautista irais@fcfm.buap.mx
39 // Arturo Fernandez Tellez afernan@cern.ch
40
41 ClassImp(AliACORDEPreprocessor)
42
43 //______________________________________________________________________________________________
44 AliACORDEPreprocessor::AliACORDEPreprocessor(AliShuttleInterface* shuttle) :
45   AliPreprocessor("ACO", shuttle),
46   fCalData(0),
47   fDataDCS(0)
48 {
49   // constructor
50   AddRunType("STANDALONE_BC");
51   AddRunType("STANDALONE_PULSER");
52   AddRunType("PHYSICS");
53
54 }
55
56 //______________________________________________________________________________________________
57 AliACORDEPreprocessor::~AliACORDEPreprocessor()
58 {
59   // destructor
60 }
61
62 //______________________________________________________________________________________________
63 void AliACORDEPreprocessor::Initialize(Int_t run, UInt_t startTime,
64         UInt_t endTime)
65 {
66   // Creates AliACORDECalibModule object
67
68   AliPreprocessor::Initialize(run, startTime, endTime);
69
70         Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
71                 TTimeStamp(startTime).AsString(),
72                 TTimeStamp(endTime).AsString()));
73
74         fCalData = new AliACORDECalibData();
75         fDataDCS = new AliACORDEDataDCS();
76 }
77
78 //______________________________________________________________________________________________
79 UInt_t AliACORDEPreprocessor::Process(TMap* dcsAliasMap)
80 {
81   
82  
83 //   TH1D *fH1,*fH2,*fH3,*fH4; //Histogram of the rates per module
84    
85    TH1D *fH[4];
86    TFile *daqFile=0x0;
87
88
89
90    // retrieve the run type from the Shuttle,
91
92    if(!dcsAliasMap)
93    {
94    
95    Log(Form("Error there isn't dcsAliasMap"));
96    return  1;
97    
98    }
99
100
101    fDataDCS->ProcessData(*dcsAliasMap);
102
103
104
105    AliCDBMetaData metaData1;
106    metaData1.SetBeamPeriod(0);
107    metaData1.SetResponsible("Pedro and Irais");
108    metaData1.SetComment("This preprocessor fills an AliACORDECalibModule object.");
109
110    Bool_t result1 = StoreReferenceData("Calib", "DataDCS",fDataDCS, &metaData1);
111
112    if(!result1)
113    return 2;
114  
115    TString runType = GetRunType();
116
117
118    Log(Form("Run type for run %d: %s", fRun, runType.Data()));
119    TString SourcesId = "CALIB";
120
121
122   
123
124    //retrieve the list of sources that produced the file with id RATES
125  
126     TList* sourceList = GetFileSources(kDAQ,SourcesId.Data());
127
128    if (!sourceList)
129    {
130         Log(Form("Error: No sources found for id %s", SourcesId.Data()));
131         return 3;
132    }
133   
134    // TODO We have the list of sources that produced the files with Id RATES 
135    // Now we will loop on the list and we'll query the files one by one. 
136
137
138
139    Log(Form("The following sources produced files with the id %s",SourcesId.Data()));
140    sourceList->Print();
141      
142    TIter iter(sourceList);
143    TObjString *source = 0;
144  
145  
146
147    while((source=dynamic_cast<TObjString*> (iter.Next())))
148    {
149         
150         TString fileName = GetFile(kDAQ,SourcesId.Data(), source->GetName());
151
152         if (fileName.Length() > 0)
153                 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
154
155                 daqFile = new TFile(fileName.Data(),"READ");
156               
157               if(!daqFile)
158               {
159                             
160               Log(Form("There are not histos     1"));
161               return 4;
162
163               }
164
165            
166                 
167             fH[0] = (TH1D*)daqFile->Get("fHist1");
168             fH[1] = (TH1D*)daqFile->Get("fHist2");
169             fH[2] = (TH1D*)daqFile->Get("fHist3");
170             fH[3] = (TH1D*)daqFile->Get("fHist4");
171           
172
173              
174              if(fH[0]!=NULL&&fH[1]!=NULL&&fH[2]!=NULL&&fH[3]!=NULL)  
175              {  
176              fCalData->AddHHits(fH[0]);
177              fCalData->AddHTHits(fH[1]);
178              fCalData->AddHMultiHits(fH[2]);
179              fCalData->AddHTMultiHits(fH[3]);
180              }
181             
182             else
183             {
184              Log(Form("There are not histos     2"));
185              return 4;
186             }
187     
188
189    }                   
190                                                                           
191  
192  
193   delete sourceList;
194   
195
196         //Now we have to store
197
198         AliCDBMetaData metaData;
199         metaData.SetBeamPeriod(0);
200         metaData.SetResponsible("Pedro and Irais");
201         metaData.SetComment("This preprocessor fills an AliACORDECalibModule object.");
202
203                 Bool_t result2 = StoreReferenceData("Calib", "Data",fCalData, &metaData);
204       
205         delete fCalData;
206         delete fDataDCS;
207         fDataDCS = 0;
208         fCalData = 0;
209   
210
211   if (!result2)
212   return 5;
213   
214   return 0;
215 }
216