-//insert copyright
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project *
+ * All rights reserved. *
+ * *
+ * Primary Authors: Oystein Djuvsland *
+ * *
+ * 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. *
+ **************************************************************************/
#include "AliHLTPHOSBaselineAnalyzerComponent.h"
#include "AliHLTPHOSBaselineAnalyzer.h"
#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
#include <sys/stat.h>
#include <sys/types.h>
+/**
+ * Class does baseline analysis
+ *
+ * @file AliHLTPHOSBaselineAnalyzerComponent.cxx
+ * @author Oystein Djuvsland
+ * @date
+ * @brief A baseline analyzer for PHOS HLT
+*/
+
+// see below for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
const AliHLTComponentDataType AliHLTPHOSBaselineAnalyzerComponent::fgkInputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
AliHLTPHOSBaselineAnalyzerComponent gAliHLTPHOSBaselineAnalyzerComponent;
-AliHLTPHOSBaselineAnalyzerComponent::AliHLTPHOSBaselineAnalyzerComponent() :
- AliHLTPHOSProcessor(),
- fBaselineAnalyzerPtr(0),
- fTreePtr(0),
- fEventCount(0),
- fWriteInterval(100),
- fFillInterval(100),
- fFilename(0),
- fDirectory(0),
- fHistPath(0),
- fRunNb(0)
+AliHLTPHOSBaselineAnalyzerComponent::AliHLTPHOSBaselineAnalyzerComponent() :AliHLTPHOSProcessor(),
+ fBaselineAnalyzerPtr(0),
+ fTreePtr(0),
+ fBaselineArrayPtr(0),
+ fEvCnt(0),
+ fWriteInterval(100),
+ fFillInterval(100),
+ fFilename(0),
+ fDirectory(0),
+ fHistPath(0),
+ fRunNb(0),
+ fCalculateAll(false)
{
-
+ //See header file for documentation
}
AliHLTPHOSBaselineAnalyzerComponent::~AliHLTPHOSBaselineAnalyzerComponent()
{
+ //See header file for documentation
}
+
+
int
AliHLTPHOSBaselineAnalyzerComponent::Deinit()
{
-
+ //See header file for documentation
fBaselineAnalyzerPtr->CalculateChannelsBaselineRMS();
- char filename [50];
- cout << "Writing files...";
- sprintf(filename, "%s/run%d_baselineTree_%d.root", fDirectory, fRunNb,fEventCount/fWriteInterval);
- fBaselineAnalyzerPtr->WriteAccumulatedBaselines(filename);
+ char filename [256];
+ sprintf(filename, "%s/run%d_baselineTree_%d.root", fDirectory, fRunNb,fEvCnt/fWriteInterval);
+
+ if( CheckFileLog( __FILE__ , filename, "w") == true)
+ {
+ fBaselineAnalyzerPtr->WriteAccumulatedBaselines(filename);
+ DoneWritingLog( __FILE__ , filename);
+ }
+
sprintf(filename, "%s/run%d_channelHistograms.root", fHistPath, fRunNb);
- fBaselineAnalyzerPtr->WriteChannelHistograms(filename);
+
+ if( CheckFileLog( __FILE__ , filename, "w") == true)
+ {
+ fBaselineAnalyzerPtr->WriteChannelHistograms(filename);
+ DoneWritingLog( __FILE__ , filename);
+ }
+
sprintf(filename, "%s/run%d_RMSHistogram.root", fHistPath, fRunNb);
- fBaselineAnalyzerPtr->WriteRMSHistogram(filename);
- cout << "Done!\n";
+
+ if( CheckFileLog( __FILE__ , filename, "w") == true)
+ {
+ fBaselineAnalyzerPtr->WriteRMSHistogram(filename);
+ DoneWritingLog( __FILE__ , filename);
+ }
if(fCalculateAll)
{
}
if(fTreePtr)
{
- // delete fTreePtr;
fTreePtr = 0;
}
if(fFilename)
const char*
AliHLTPHOSBaselineAnalyzerComponent::GetComponentID()
{
+ //See header file for documentation
return "PhosBaselineAnalyzer";
}
void
-
AliHLTPHOSBaselineAnalyzerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
{
//Get datatypes for input
AliHLTComponentDataType
AliHLTPHOSBaselineAnalyzerComponent::GetOutputDataType()
{
- return AliHLTPHOSDefinitions::fgkAliHLTBaselineDataType;
+ //See header file for documentation
+ return AliHLTPHOSDefinitions::fgkBaselineDataType;
}
void
AliHLTPHOSBaselineAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
{
+ //See header file for documentation
constBase = 30;
inputMultiplier = 1;
}
int
AliHLTPHOSBaselineAnalyzerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
- AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
- std::vector<AliHLTComponentBlockData>& outputBlocks)
+ AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& /*size*/, //TODO: I think that not setting the size explicitly to zero when returning from this method may be a subtle bug in this component. Please check.
+ std::vector<AliHLTComponentBlockData>& /*outputBlocks*/)
{
- //Do event
-
- UInt_t tSize = 0;
- UInt_t offset = 0;
- UInt_t mysize = 0;
- Int_t index = 0;
-
- Int_t fileCount = 0;
- Int_t digitCount = 0;
- char filename [50];
-
-
AliHLTUInt8_t* outBPtr;
outBPtr = outputPtr;
const AliHLTComponentBlockData* iter = 0;
if(iter->fDataType != AliHLTPHOSDefinitions::fgkCellEnergyDataType)
{
- // cout << "Warning: data type is not fgkCellEnergyDataType " << endl;
+ Logging(kHLTLogWarning, __FILE__ , "wrong datatype" , "dat is not of type fgkCellEnergyDataType");
continue;
}
fBaselineAnalyzerPtr->CalculateRcuBaselines(reinterpret_cast<AliHLTPHOSRcuCellEnergyDataStruct*>(iter->fPtr));
}
- fEventCount++;
+ fEvCnt++;
//PushBack(fDigitArrayPtr, kAliHLTAnyDataType, (AliHLTUInt32_t)0);
- if(fEventCount % 10 == 0)
- {
- cout << "Event #: " << fEventCount << endl;
- }
- if(fEventCount % fFillInterval == 0)
+ if(fEvCnt % fFillInterval == 0)
{
fBaselineAnalyzerPtr->FillTree();
}
- if(fEventCount % fWriteInterval == 0)
+ if(fEvCnt % fWriteInterval == 0)
{
- char filename [50];
- cout << "Writing file...";
- sprintf(filename, "%s/run%d_baselineTree_%d.root", fDirectory, fRunNb,fEventCount/fWriteInterval - 1);
- fBaselineAnalyzerPtr->WriteAccumulatedBaselines(filename);
- cout << "Done!\n";
- delete fTreePtr;
- fTreePtr = new TTree("baselineTree", "Baselines");
- fBaselineAnalyzerPtr->SetRootObjects(fTreePtr, fBaselineArrayPtr);
+ char filename [256];
+ sprintf(filename, "%s/run%d_baselineTree_%d.root", fDirectory, fRunNb,fEvCnt/fWriteInterval - 1);
+ //:CheckFileLog(const char *origin, const char *filename, const char opt)
+ if( (CheckFileLog( __FILE__ , filename, "w") == true))
+ {
+ fBaselineAnalyzerPtr->WriteAccumulatedBaselines(filename);
+ delete fTreePtr;
+ fTreePtr = new TTree("baselineTree", "Baselines");
+ fBaselineAnalyzerPtr->SetRootObjects(fTreePtr, fBaselineArrayPtr);
+ DoneWritingLog( __FILE__ , filename);
+ }
+
+ return 0;
}
return 0;
}
-
int
AliHLTPHOSBaselineAnalyzerComponent::DoInit(int argc, const char** argv )
{
- //Do initialization sprintf(fFilename, "/tmp/phoshlt/analysis/data/run%d/run%d_digitTree_%d.root", fRunNb,fRunNb,(fEventCount/fWriteInterval - 1));
-
+ //See header file for documentation
Bool_t pathSet = false;
Bool_t histPathSet = false;
Bool_t nSamplesSet = false;
-
-
fFilename = new char[50];
fDirectory = new char[50];
fHistPath = new char[50];
-
+ /*
fstream runNbFile;
- //char dir [10];
-
- Int_t newRunNb;
runNbFile.open("/opt/HLT-public/rundir/runNumber.txt");
runNbFile >> fRunNb;
runNbFile.close();
- /* newRunNb = fRunNb + 1;
- runNbFile.open("/opt/HLT-public/rundir/runNumber.txt");
- runNbFile << newRunNb;
- runNbFile.close();*/
-
- // sprintf(dir, "//tmp//phoshlt//aldaqpc019//hlt//data//baselines//run%d", fRunNb);
- // if(mkdir(dir, 0777))
- //{
- // cerr << "WARNING! Could not create directory!\n";
- //}
-
+ */
+
fBaselineAnalyzerPtr = new AliHLTPHOSBaselineAnalyzer();
-
fTreePtr = new TTree("baselineTree", "Baselines");
fBaselineArrayPtr = new TClonesArray("AliHLTPHOSBaseline",N_XCOLUMNS_MOD*N_ZROWS_MOD*N_GAINS);
fBaselineAnalyzerPtr->SetRootObjects(fTreePtr, fBaselineArrayPtr);
fWriteInterval = 100;
fFillInterval = 100;
- if(fCalculateAll)
- cout << "Path to total baseline file: " << fFilename << endl;
- cout << endl << "Run number is: " << fRunNb << " -- Check that this is correct!!!\n";
- return 0;
-}
+ if(fCalculateAll)
+ {
+ CalculateAll();
+ }
+
-AliHLTComponent*
-AliHLTPHOSBaselineAnalyzerComponent::Spawn()
-{
- return new AliHLTPHOSBaselineAnalyzerComponent();
+ return 0;
}
+
-void
-AliHLTPHOSBaselineAnalyzerComponent::CalculateAll()
+ AliHLTComponent*
+ AliHLTPHOSBaselineAnalyzerComponent::Spawn()
+ {
+ //See header file for documentation
+ return new AliHLTPHOSBaselineAnalyzerComponent();
+ }
+
+ void
+ AliHLTPHOSBaselineAnalyzerComponent::CalculateAll()
{
-
- cout << "Calculating total baselines... \n";
+ //See header file for documentation
AliHLTPHOSBaseline *baselineObject = 0;
TChain* chain = new TChain("baselineTree");
TTree* totalTree = new TTree("baselineTree", "Baselines");
Float_t tmpBaselines[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS][2];
- for(Int_t x = 0; x < N_XCOLUMNS_MOD; x++)
+ for(int x = 0; x < N_XCOLUMNS_MOD; x++)
{
- for(Int_t z = 0; z < N_ZROWS_MOD; z++)
+ for(int z = 0; z < N_ZROWS_MOD; z++)
{
- for(Int_t gain = 0; gain < N_GAINS; gain++)
+ for(int gain = 0; gain < N_GAINS; gain++)
{
- for(Int_t d = 0; d < 2; d++)
+ for(int d = 0; d < 2; d++)
{
tmpBaselines[x][z][gain][d] = 0;
}
}
sprintf(filepath, "%s/run%d*", fDirectory, fRunNb);
- cout << "Adding files from: " << filepath << endl;
+ Logging(kHLTLogInfo, __FILE__ , "Adding files" , "Adding files from %s", filepath);
chain->Add(filepath);
-
- cout << "Gives a total number of " << chain->GetEntries() << " events.\n";
-
+ Logging(kHLTLogInfo, __FILE__ , "Adding files " , "Gives a total number of %d file",chain->GetEntries());
chain->SetBranchAddress("Baselines", &baselineArray);
totalTree->Branch("Baselines", &totalBaselineArray);
Int_t n = 0;
- for(x = 0; x < N_XCOLUMNS_MOD; x++)
+ for(x = 0; x < (Int_t)N_XCOLUMNS_MOD; x++)
{
- for(z = 0; z < N_ZROWS_MOD; z++)
+ for(z = 0; z < (Int_t)N_ZROWS_MOD; z++)
{
- for(gain = 0; gain < N_GAINS; gain++)
+ for(gain = 0; gain < (Int_t)N_GAINS; gain++)
{
baselineObject = (AliHLTPHOSBaseline*)totalBaselineArray->New(n);
baselineObject->SetBaseline(tmpBaselines[x][z][gain][0]);
baselineObject->SetGain(gain);
if( tmpBaselines[x][z][gain][1] == 0)
{
- cout << "Warning! Number of entries for x: " << x << " - z: " << z << " - gain: " << gain << " = 0\n"
- << "Setting baseline to 40\n\n";
+ Logging(kHLTLogWarning, __FILE__ , "zero entries", " for x:= %d, z=%d, gain = %d, Setting baseline to 40", x, z, gain);
baselineObject->SetBaseline(40);
continue;
}
- if( tmpBaselines[x][z][gain][1] == 0)
- {
- cout << "Warning! Number of entries for x: " << x << " - z: " << z << " - gain: " << gain << " = "
- << tmpBaselines[x][z][gain][1] << endl;
- }
- baselineObject->SetEntries(tmpBaselines[x][z][gain][1]);
+ baselineObject->SetEntries( Int_t(tmpBaselines[x][z][gain][1]) );
n++;
}
}
totalTree->Fill();
- cout << "Writing to: " << fFilename << endl;
- TFile *outfile = new TFile(fFilename,"recreate");
- totalTree->Write();
- outfile->Close();
- cout << "Done!\n";
+ if(CheckFileLog(__FILE__, fFilename, "w") == true)
+ {
+ TFile *outfile = new TFile(fFilename,"recreate");
+ totalTree->Write();
+ outfile->Close();
+ DoneWritingLog(__FILE__ , fFilename);
+ delete outfile;
+ }
}