]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ACORDE/AliACORDEPreprocessor.cxx
Add required AliVParticle functionality (Markus)
[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 "AliACORDECalibModule.h"
25 #include "AliACORDEDataModule.h"
26
27 #include <TTimeStamp.h>
28 #include <TObjString.h>
29 #include <TList.h>
30
31 //
32 // This is the first version of 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 {
48   // constructor
49 }
50
51 //______________________________________________________________________________________________
52 AliACORDEPreprocessor::~AliACORDEPreprocessor()
53 {
54   // destructor
55 }
56
57 //______________________________________________________________________________________________
58 void AliACORDEPreprocessor::Initialize(Int_t run, UInt_t startTime,
59         UInt_t endTime)
60 {
61   // Creates AliACORDECalibModule object
62
63   AliPreprocessor::Initialize(run, startTime, endTime);
64
65         Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
66                 TTimeStamp(startTime).AsString(),
67                 TTimeStamp(endTime).AsString()));
68
69         fCalData = new AliACORDECalibModule();
70 }
71
72 //______________________________________________________________________________________________
73 UInt_t AliACORDEPreprocessor::Process(TMap* /*dcsAliasMap*/)
74 {
75   
76
77  
78  
79    TH1D *histoRate; //Histogram of the rates per module
80    TFile *daqFile=0x0;
81
82
83    // retrieve the run type from the Shuttle,
84
85  
86    TString runType = GetRunType();
87     
88    if(runType !="SPD_STANDALONE_CALIBRATION")
89    {
90
91    Log("RunType is not SPD_STANDALONE_CALIBRATION, nothing to do");
92    return 1;
93
94    }
95
96
97    Log(Form("Run type for run %d: %s", fRun, runType.Data()));
98
99   
100
101    //retrieve the list of sources that produced the file with id RATES
102  
103    TList* sourceList = GetFileSources(kDAQ, "RATES");
104
105    if (!sourceList)
106    {
107         Log("Error: No sources found for id RATES!");
108         return 2;
109    }
110   
111    // TODO We have the list of sources that produced the files with Id RATES 
112    // Now we will loop on the list and we'll query the files one by one. 
113
114
115
116    Log("The following sources produced files with the id RATES");
117    sourceList->Print();
118      
119    TIter iter(sourceList);
120    TObjString *source = 0;
121  
122  
123
124    while((source=dynamic_cast<TObjString*> (iter.Next())))
125    {
126         
127         TString fileName = GetFile(kDAQ, "RATES", source->GetName());
128
129         if (fileName.Length() > 0)
130                 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
131
132               daqFile = new TFile(fileName.Data(),"READ");
133               histoRate =(TH1D *) daqFile->Get("Rates"); //Get Histogram with Rates per module
134              
135
136               if(!histoRate)
137               {
138                             
139               Log(Form("There are not histos"));
140               return 3;
141
142               }
143                 
144               
145     
146               //Set Status Module   
147               //Fills data in  to AliACORDECalibModule object        
148            
149               for(int module=0;module<kNModules;module++)
150               {
151                 
152                          Float_t value = histoRate->At(module);
153                          TString name = "aco_hv_module";
154                          
155                          name+=module;
156                          
157                          //if(value>=0&&value<=2.5)
158                          fCalData->SetModule(module,value,1,name); //1 module
159                         // else
160                         // fCalData->SetModule(module,value,0,name); //0 module 
161
162
163               }
164                     
165             fCalData->Create_Histo(); 
166             //fCalData->Print_Module();
167 }                                                                           
168  
169  
170   delete sourceList;
171   
172
173         //Now we have to store
174
175         AliCDBMetaData metaData;
176         metaData.SetBeamPeriod(0);
177         metaData.SetResponsible("Pedro and Irais");
178         metaData.SetComment("This preprocessor fills an AliACORDECalibModule object.");
179
180                 Bool_t result = StoreReferenceData("Calib", "Data",fCalData, &metaData);
181       
182         delete fCalData;
183         fCalData = 0;
184   
185
186   if (!result)
187   return 4;
188   
189   return 0;
190 }
191