26 #include "AliRawReader.h" 27 #include "AliCaloRawStreamV3.h" 71 fReqFractionAboveAmpCutVal(0.6),
72 fReqFractionAboveAmp(kTRUE),
74 fReqLEDRefAboveAmpCutVal(kTRUE),
83 fTreeAvgAmpVsTime(NULL),
84 fTreeLEDAmpVsTime(NULL),
85 fTreeLEDAvgAmpVsTime(NULL)
88 if (detectorType ==
kPhos)
200 fTreeAmpVsTime =
new TTree(
"fTreeAmpVsTime",
"Amplitude vs. Time Tree Variables");
207 fTreeAvgAmpVsTime =
new TTree(
"fTreeAvgAmpVsTime",
"Average Amplitude vs. Time Tree Variables");
215 fTreeLEDAmpVsTime =
new TTree(
"fTreeLEDAmpVsTime",
"LED Amplitude vs. Time Tree Variables");
220 fTreeLEDAvgAmpVsTime =
new TTree(
"fTreeLEDAvgAmpVsTime",
"Average LED Amplitude vs. Time Tree Variables");
265 int resultArray[])
const 267 Bool_t returnCode =
false;
276 if (i==10 || i==11 || i==18 || i==19)
279 for (
int k = 0; k<
fRows; k++)
282 if (iAmpVal[iTowerNum] >
fAmpCut)
288 resultArray[i*fColumns +j] = 0;
292 fraction = (1.0*nAbove) / nRows;
299 resultArray[i*fColumns + j] = nAbove;
314 int resultArray[])
const 316 Bool_t returnCode =
false;
327 resultArray[i*fLEDRefs +j] = 1;
332 resultArray[i*fLEDRefs +j] = 0;
352 static const string delimitor(
"::");
355 ifstream in( parameterFile );
358 printf(
"in AliCaloCalibSignal::SetParametersFromFile - Using default/run_time parameters.\n");
369 while ((in.rdstate() & ios::failbit) == 0 )
373 in.getline(readline, 1024);
374 istringstream s(readline);
376 while ( ( s.rdstate() & ios::failbit ) == 0 )
382 if( ( s.rdstate() & ios::failbit ) == ios::failbit )
break;
385 if( keyValue.substr( 0, 2 ) ==
"//" )
break;
388 size_t position = keyValue.find( delimitor );
389 if( position == string::npos )
391 printf(
"wrong format for key::value pair: %s\n", keyValue.c_str());
395 string key( keyValue.substr( 0, position ) );
396 string value( keyValue.substr( position+delimitor.size(),
397 keyValue.size()-delimitor.size() ) );
400 if( value.find( delimitor ) != string::npos )
402 printf(
"wrong format for key::value pair: %s\n", keyValue.c_str());
409 if ( (key ==
"fAmpCut") || (key ==
"fReqFractionAboveAmpCutVal") ||
410 (key ==
"fAmpCutLEDRef") || (key ==
"fSecInAverage") ||
411 (key ==
"fFittingAlgorithm") || (key ==
"fDownscale") )
413 istringstream iss(value);
414 printf(
"AliCaloCalibSignal::SetParametersFromFile - key %s value %s\n", key.c_str(), value.c_str());
416 if (key ==
"fAmpCut") {
419 else if (key ==
"fReqFractionAboveAmpCutVal") {
422 else if (key ==
"fAmpCutLEDRef") {
425 else if (key ==
"fSecInAverage") {
428 else if (key ==
"fFittingAlgorithm") {
432 else if (key ==
"fDownscale") {
449 static const string delimitor(
"::");
451 ofstream out( parameterFile );
452 out <<
"// " << parameterFile << endl;
453 out <<
"fAmpCut" <<
"::" <<
fAmpCut << endl;
458 out <<
"fDownscale" <<
"::" <<
fDownscale << endl;
499 sigAmp->SetBranchAddress(
"fChannelNum",&
fChannelNum);
500 sigAmp->SetBranchAddress(
"fHour",&
fHour);
501 sigAmp->SetBranchAddress(
"fAmp",&
fAmp);
505 for (
int i=0; i<sigAmp->GetEntries(); i++)
511 sigAvgAmp->SetBranchAddress(
"fChannelNum",&
fChannelNum);
512 sigAvgAmp->SetBranchAddress(
"fHour",&
fHour);
513 sigAvgAmp->SetBranchAddress(
"fAvgAmp",&
fAvgAmp);
514 sigAvgAmp->SetBranchAddress(
"fRMS",&
fRMS);
516 for (
int i=0; i<sigAvgAmp->GetEntries(); i++)
518 sigAvgAmp->GetEntry(i);
527 sigLEDAmp->SetBranchAddress(
"fRefNum",&
fRefNum);
528 sigLEDAmp->SetBranchAddress(
"fHour",&
fHour);
529 sigLEDAmp->SetBranchAddress(
"fAmp",&
fAmp);
533 for (
int i=0; i<sigLEDAmp->GetEntries(); i++)
535 sigLEDAmp->GetEntry(i);
539 sigLEDAvgAmp->SetBranchAddress(
"fRefNum",&
fRefNum);
540 sigLEDAvgAmp->SetBranchAddress(
"fHour",&
fHour);
541 sigLEDAvgAmp->SetBranchAddress(
"fAvgAmp",&
fAvgAmp);
542 sigLEDAvgAmp->SetBranchAddress(
"fRMS",&
fRMS);
544 for (
int i=0; i<sigLEDAvgAmp->GetEntries(); i++)
546 sigLEDAvgAmp->GetEntry(i);
584 return ProcessEvent( &rawStream, rawReader->GetTimestamp() );
595 if (!in)
return kFALSE;
604 memset(iAmpValHighGain, 0,
sizeof(iAmpValHighGain));
605 memset(iAmpValLowGain, 0,
sizeof(iAmpValLowGain));
609 memset(iLEDAmpVal, 0,
sizeof(iLEDAmpVal));
623 while (in->NextDDL())
625 while (in->NextChannel())
627 vector<AliCaloBunchInfo> bunchlist;
628 while (in->NextBunch())
630 bunchlist.push_back(
AliCaloBunchInfo(in->GetStartTimeBin(), in->GetBunchLength(), in->GetSignals() ) );
633 if (bunchlist.size() == 0)
continue;
637 if ( in->IsLowGain() )
641 else if ( in->IsHighGain() )
645 else if ( in->IsLEDMonData() )
652 int arrayPos = in->GetModule();
654 if (arrayPos < 0 || arrayPos >=
fModules)
656 printf(
"AliCaloCalibSignal::ProcessEvent = Oh no: arrayPos = %i.\n", arrayPos);
661 if ( in->IsHighGain() || in->IsLowGain() )
664 iTowerNum =
GetTowerNum(arrayPos, in->GetColumn(), in->GetRow());
669 iAmpValLowGain[iTowerNum] = (int) res.
GetAmp();
675 iAmpValHighGain[iTowerNum] = (int) res.
GetAmp();
679 else if ( in->IsLEDMonData() )
682 iRefNum =
GetRefNum(arrayPos, in->GetColumn(), gain);
683 iLEDAmpVal[iRefNum] = (int) res.
GetAmp();
699 checkResultArray[ia] = 1;
710 if (!ok)
return false;
717 checkResultArrayLEDRef[ia] = 1;
728 if (!ok)
return false;
757 if (checkResultArray[i*fColumns + j]>0 && checkResultArrayLEDRef[i*
fLEDRefs + iStrip]>0)
760 for(
int k=0; k<
fRows; k++)
764 if(iAmpValHighGain[iTowerNum])
766 fAmp = iAmpValHighGain[iTowerNum];
772 if(iAmpValLowGain[iTowerNum])
774 fAmp = iAmpValLowGain[iTowerNum];
787 if ( ((checkResultArray[i*fColumns + iColFirst]>0) || (checkResultArray[i*fColumns + iColFirst + 1]>0)) &&
788 (checkResultArrayLEDRef[i*fLEDRefs + j]>0) )
790 for (gain=0; gain<2; gain++)
815 TFile destFile(fileName,
"recreate");
817 if (destFile.IsZombie())
861 timeMax = timeMin + numProfBins*binSize;
865 memset(profile, 0,
sizeof(profile));
866 const Int_t buffersize = 200;
867 char name[buffersize];
874 for (
int ir=0; ir<
fRows; ir++)
881 snprintf(name,buffersize,
"profileChan%d",
fChannelNum);
882 profile[
fChannelNum] =
new TProfile(name, name, numProfBins, timeMin, timeMax,
"s");
889 snprintf(name,buffersize,
"profileChan%d",
fChannelNum);
890 profile[
fChannelNum] =
new TProfile(name, name, numProfBins, timeMin, timeMax,
"s");
923 if (profile[fChannelNum]->GetEntries() > 0)
926 for(
int it=0; it<numProfBins; it++)
928 if (profile[fChannelNum]->GetBinEntries(it+1) > 0)
945 memset(profileLED, 0,
sizeof(profileLED));
951 for (
int gain=0; gain<2; gain++)
956 snprintf(name, buffersize,
"profileLEDRef%d",
fRefNum);
957 profileLED[
fRefNum] =
new TProfile(name, name, numProfBins, timeMin, timeMax,
"s");
990 if (profileLED[fRefNum]->GetEntries() > 0)
992 for(
int it=0; it<numProfBins; it++) {
993 if (profileLED[fRefNum]->GetBinEntries(it+1) > 0)
1014 int *imod,
int *icol,
int *irow,
int *igain)
const 1019 *irow = chanId %
fRows;
1027 int *imod,
int *istripMod,
int *igain)
const kDetType fDetType
The detector type for this object.
int fNAcceptedEvents
Number of events accepted.
Bool_t ProcessEvent(AliRawReader *rawReader)
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
Bool_t CheckLEDRefAboveAmp(const int *AmpVal, int resultArray[]) const
static const int fgkMaxTowers
AliEMCALGeoParams::fgkEMCALModules * AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRow...
int fStartTime
Time of first event.
int fNHighGain[fgkMaxTowers]
Number of Amp. vs. Time readings per tower.
void ResetInfo()
Reset trees and counters.
bool GetUseAverage() const
void CreateTrees()
Create/initialize/setup the TTrees.
TTree * GetTreeLEDAmpVsTime() const
static Int_t GetFirstSTUDDL()
kDetType
The detector types (add common enum as in AliCalibPedestal?)
int GetChannelNum(const int imod, const int icol, const int irow, const int igain) const
static const int fgkEMCALRows
Number of rows per module for EMCAL.
static const int fgkPhosRows
Number of rows per module for PHOS.
int fDownscale
To select 1 out every N (fDownscale) events.
bool fReqFractionAboveAmp
Flag to select if we should do some event selection based on amplitudes.
int fNEvents
Number of events processed.
AliCaloRawAnalyzer * fRawAnalyzer
! e.g. for sample selection for fits
AliCaloAltroMapping ** fMapping
! Altro Mapping object
static const int fgkEMCALLEDRefs
Number of LEDs (reference/monitors) per module for EMCAL; one per StripModule.
double fLatestHour
Largest fraction of hour since beginning of run, for amp vs. time graphs.
static const int fgkPhosCols
Number of columns per module for PHOS.
class for signal monitoring and calibration tools
Bool_t DecodeChannelNum(const int chanId, int *imod, int *icol, int *irow, int *igain) const
Output with the module, column, row, and gain for a given channel number.
bool GetReqFractionAboveAmp() const
void SetFittingAlgorithm(Int_t val)
int fRows
The number of rows per module.
int fRunNumber
The run number. Needs to be set by the user.
void SetParametersFromFile(const char *parameterFile)
double fReqFractionAboveAmpCutVal
Required fraction that should be above cut.
void DeleteTrees()
Delete old objects and set pointers, what was created in the constructor (TTrees) ...
TString fileName(const char *dir, int runNumber, const char *da, int i, const char *type)
Container class to hold results from fitting.
int fLEDRefs
The number of LED references/monitors per module.
Container of ALTRO information.
TTree * fTreeAvgAmpVsTime
Store channel, gain, amp, and time info, for averages.
Bool_t DecodeRefNum(const int refId, int *imod, int *istripMod, int *igain) const
Output with the module, stripModule, and gain for a given reference number.
double GetReqFractionAboveAmpCutVal() const
TTree * fTreeAmpVsTime
Store channel, gain, amp, and time info.
TString fCaloString
ID for which detector type we have.
double fAmpCut
Amplitude cut value.
static AliCaloRawAnalyzer * CreateAnalyzer(const int algo)
double fHour
Fraction of hour since beginning of run, for amp vs. time graphs, for current event.
int GetRefNum(const int imod, const int istripMod, const int igain) const
int fNRef[fgkMaxRefs *2]
Number of Amp. vs. Time readings per tower, for LED refs; *2 for both gains.
void Zero()
Set all counters to 0; not cuts etc. though.
AliCaloCalibSignal(kDetType detectorType=kEmCal)
virtual AliCaloFitResults Evaluate(const std::vector< AliCaloBunchInfo > &, UInt_t, UInt_t)=0
TTree * fTreeLEDAmpVsTime
Store channel, gain, amp, and time info, for LED reference.
bool GetReqLEDRefAboveAmpCutVal() const
void WriteParametersToFile(const char *parameterFile)
Write parameters to file.
static int fRefNum
for LED
int GetSecInAverage() const
int GetTowerNum(const int imod, const int icol, const int irow) const
int fNLowGain[fgkMaxTowers]
Number of Amp. vs. Time readings per tower, for low gain.
TTree * GetTreeAvgAmpVsTime() const
AliCaloAltroMapping * fMapping[4]
Bool_t AddInfo(const AliCaloCalibSignal *sig)
static const int fgkEMCALCols
Number of columns per module for EMCAL.
int fColumns
The number of columns per module.
double fAmpCutLEDRef
Amplitude cut value for LED reference.
int fSecInAverage
Time interval for the graph averaging.
double GetLatestHour() const
static const int fgkPhosModules
Number of modules for PHOS.
static const int fgkEMCALModules
Number of modules, 12 for EMCal + 8 for DCAL.
static int fChannelNum
for regular towers
static const int fgkNumSecInHr
Number of seconds in an hour, for the fractional hour conversion on the time graph.
TTree * GetTreeAmpVsTime() const
virtual ~AliCaloCalibSignal()
Destructor.
Bool_t CheckFractionAboveAmp(const int *AmpVal, int resultArray[]) const
bool fReqLEDRefAboveAmpCutVal
Flag to select if we should require that signal is also seen in LED Reference/Monitoring channel...
static const int fgkPhosLEDRefs
No LED monitor channels for PHOS.
int GetNAcceptedEvents() const
TTree * GetTreeLEDAvgAmpVsTime() const
static double fAvgAmp
average amplitude
Bool_t Save(TString fileName)
int fModules
The number of modules.
Int_t fFittingAlgorithm
Select the fitting algorithm.
void SetIsZeroSuppressed(bool iszs=true)
TTree * fTreeLEDAvgAmpVsTime
Store channel, gain, amp, and time info, for LED reference - averages.
double GetAmpCutLEDRef() const
bool fUseAverage
Flag to average graph points into over a time interval.
static const int fgkMaxRefs
AliEMCALGeoParams::fgkEMCALModules * AliEMCALGeoParams::fgkEMCALLEDRefs;.
static double fAmp
amplitude