using namespace std;
// variables for TTree filling; not sure if they should be static or not
-static int fChannelNum; // for regular towers
-static int fRefNum; // for LED
-static double fAmp;
-static double fAvgAmp;
-static double fRMS;
+static int fChannelNum = 0; // for regular towers
+static int fRefNum = 0; // for LED
+static double fAmp = 0;
+static double fAvgAmp = 0;
+static double fRMS = 0;
// ctor; initialize everything in order to avoid compiler warnings
// put some reasonable defaults
fAmpCut(40), // min. 40 ADC counts as default
fReqFractionAboveAmpCutVal(0.6), // 60% in a strip, per default
fReqFractionAboveAmp(kTRUE),
+ fAmpCutLEDRef(100), // min. 100 ADC counts as default
+ fReqLEDRefAboveAmpCutVal(kTRUE),
fHour(0),
fLatestHour(0),
fUseAverage(kTRUE),
// copy ctor
//_____________________________________________________________________
-AliCaloCalibSignal::AliCaloCalibSignal(const AliCaloCalibSignal &sig) :
- TObject(sig),
- fDetType(sig.GetDetectorType()),
- fColumns(sig.GetColumns()),
- fRows(sig.GetRows()),
- fLEDRefs(sig.GetLEDRefs()),
- fModules(sig.GetModules()),
- fCaloString(sig.GetCaloString()),
- fMapping(NULL), //! note that we are not copying the map info
- fRunNumber(sig.GetRunNumber()),
- fStartTime(sig.GetStartTime()),
- fAmpCut(sig.GetAmpCut()),
- fReqFractionAboveAmpCutVal(sig.GetReqFractionAboveAmpCutVal()),
- fReqFractionAboveAmp(sig.GetReqFractionAboveAmp()),
- fHour(sig.GetHour()),
- fLatestHour(sig.GetLatestHour()),
- fUseAverage(sig.GetUseAverage()),
- fSecInAverage(sig.GetSecInAverage()),
- fNEvents(sig.GetNEvents()),
- fNAcceptedEvents(sig.GetNAcceptedEvents()),
- fTreeAmpVsTime(NULL),
- fTreeAvgAmpVsTime(NULL),
- fTreeLEDAmpVsTime(NULL),
- fTreeLEDAvgAmpVsTime(NULL)
-{
- // also the TTree contents
- AddInfo(&sig);
-}
-
+//AliCaloCalibSignal::AliCaloCalibSignal(const AliCaloCalibSignal &sig) :
+// TObject(sig),
+// fDetType(sig.GetDetectorType()),
+// fColumns(sig.GetColumns()),
+// fRows(sig.GetRows()),
+// fLEDRefs(sig.GetLEDRefs()),
+// fModules(sig.GetModules()),
+// fCaloString(sig.GetCaloString()),
+// fMapping(), //! note that we are not copying the map info
+// fRunNumber(sig.GetRunNumber()),
+// fStartTime(sig.GetStartTime()),
+// fAmpCut(sig.GetAmpCut()),
+// fReqFractionAboveAmpCutVal(sig.GetReqFractionAboveAmpCutVal()),
+// fReqFractionAboveAmp(sig.GetReqFractionAboveAmp()),
+// fAmpCutLEDRef(sig.GetAmpCutLEDRef()),
+// fReqLEDRefAboveAmpCutVal(sig.GetReqLEDRefAboveAmpCutVal()),
+// fHour(sig.GetHour()),
+// fLatestHour(sig.GetLatestHour()),
+// fUseAverage(sig.GetUseAverage()),
+// fSecInAverage(sig.GetSecInAverage()),
+// fNEvents(sig.GetNEvents()),
+// fNAcceptedEvents(sig.GetNAcceptedEvents()),
+// fTreeAmpVsTime(),
+// fTreeAvgAmpVsTime(),
+// fTreeLEDAmpVsTime(),
+// fTreeLEDAvgAmpVsTime()
+//{
+// // also the TTree contents
+// AddInfo(&sig);
+// for (Int_t i = 0; i<fgkMaxTowers; i++) {
+// fNHighGain[i] = sig.fNHighGain[i];
+// fNLowGain[i] = sig.fNLowGain[i];
+// }
+// for (Int_t i = 0; i<(2*fgkMaxRefs); i++) {
+// fNRef[i] = sig.fNRef[i];
+// }
+//
+//
+//}
+//
// assignment operator; use copy ctor to make life easy..
//_____________________________________________________________________
-AliCaloCalibSignal& AliCaloCalibSignal::operator = (const AliCaloCalibSignal &source)
-{
- // assignment operator; use copy ctor
- if (&source == this) return *this;
-
- new (this) AliCaloCalibSignal(source);
- return *this;
-}
+//AliCaloCalibSignal& AliCaloCalibSignal::operator = (const AliCaloCalibSignal &source)
+//{
+// // assignment operator; use copy ctor
+// if (&source == this) return *this;
+//
+// new (this) AliCaloCalibSignal(source);
+// return *this;
+//}
//_____________________________________________________________________
void AliCaloCalibSignal::CreateTrees()
return returnCode;
}
+
+//_____________________________________________________________________
+Bool_t AliCaloCalibSignal::CheckLEDRefAboveAmp(const int *iAmpVal,
+ int resultArray[])
+{ // check which LEDRef/Mon strips are above amplitude cut
+ Bool_t returnCode = false;
+
+ int iRefNum = 0;
+ int gain = 1; // look at high gain; this should be rather saturated usually..
+ for (int i = 0; i<fModules; i++) {
+ for (int j = 0; j<fLEDRefs; j++) {
+ iRefNum = GetRefNum(i, j, gain);
+ if (iAmpVal[iRefNum] > fAmpCutLEDRef) {
+ resultArray[i*fLEDRefs +j] = 1; // enough signal
+ returnCode = true;
+ }
+ else {
+ resultArray[i*fLEDRefs +j] = 0; // not enough signal
+ }
+
+ /*
+ printf("DS mod %d LEDRef %d ampVal %d\n",
+ i, j, iAmpVal[iRefNum]);
+ */
+ } // LEDRefs
+ } // modules loop
+
+ return returnCode;
+}
+
// Parameter/cut handling
//_____________________________________________________________________
void AliCaloCalibSignal::SetParametersFromFile(const char *parameterFile)
s >> keyValue;
// check stream status
- if( s.rdstate() & ios::failbit ) break;
+ if( ( s.rdstate() & ios::failbit ) == ios::failbit ) break;
// skip rest of line if comments found
if( keyValue.substr( 0, 2 ) == "//" ) break;
// printf("AliCaloCalibSignal::SetParametersFromFile - key %s value %s\n", key.c_str(), value.c_str());
// if the key matches with something we expect, we assign the new value
- if ( (key == "fAmpCut") || (key == "fReqFractionAboveAmpCutVal") || (key == "fSecInAverage") ) {
+ if ( (key == "fAmpCut") || (key == "fReqFractionAboveAmpCutVal") ||
+ (key == "fAmpCutLEDRef") || (key == "fSecInAverage") ) {
istringstream iss(value);
printf("AliCaloCalibSignal::SetParametersFromFile - key %s value %s\n", key.c_str(), value.c_str());
else if (key == "fReqFractionAboveAmpCutVal") {
iss >> fReqFractionAboveAmpCutVal;
}
+ else if (key == "fAmpCutLEDRef") {
+ iss >> fAmpCutLEDRef;
+ }
else if (key == "fSecInAverage") {
iss >> fSecInAverage;
}
}
in.close();
- return;
-
+ return;
}
//_____________________________________________________________________
out << "// " << parameterFile << endl;
out << "fAmpCut" << "::" << fAmpCut << endl;
out << "fReqFractionAboveAmpCutVal" << "::" << fReqFractionAboveAmpCutVal << endl;
+ out << "fAmpCutLEDRef" << "::" << fAmpCutLEDRef << endl;
out << "fSecInAverage" << "::" << fSecInAverage << endl;
out.close();
Bool_t AliCaloCalibSignal::ProcessEvent(AliRawReader *rawReader)
{
// if fMapping is NULL the rawstream will crate its own mapping
- AliCaloRawStreamV3 rawStream(rawReader, fCaloString, (AliAltroMapping**)fMapping);
-
+ AliCaloRawStreamV3 rawStream(rawReader, fCaloString, (AliAltroMapping**)fMapping);
+ if (fDetType == kEmCal) {
+ rawReader->Select("EMCAL", 0, AliEMCALGeoParams::fgkLastAltroDDL) ; //select EMCAL DDL range
+ }
return ProcessEvent( &rawStream, rawReader->GetTimestamp() );
}
int iLEDAmpVal[fgkMaxRefs * 2]; // factor 2 is for the two gain values
memset(iLEDAmpVal, 0, sizeof(iLEDAmpVal));
- int sample; // temporary value
+ int sample = 0; // temporary value
int gain = 0; // high or low gain
- // Number of Low and High gain channels for this event:
+ // Number of Low and High gain, and LED Ref, channels for this event:
int nLowChan = 0;
int nHighChan = 0;
+ int nLEDRefChan = 0;
int iTowerNum = 0; // array index for regular towers
int iRefNum = 0; // array index for LED references
// strip # is coded is 'column' in the channel maps
iRefNum = GetRefNum(arrayPos, in->GetColumn(), gain);
iLEDAmpVal[iRefNum] = max - min;
+ nLEDRefChan++;
} // end of LED ref
} // nsamples>0 check, some data found for this channel; not only trailer/header
in->Reset(); // just in case the next customer forgets to check if the stream was reset..
- // now check if it was a led event, only use high gain (that should be sufficient)
+ // now check if it was an LED event, using the LED Reference info per strip
// by default all columns are accepted (init check to > 0)
int checkResultArray[AliEMCALGeoParams::fgkEMCALModules * AliEMCALGeoParams::fgkEMCALCols];
for (int ia=0; ia<(AliEMCALGeoParams::fgkEMCALModules * AliEMCALGeoParams::fgkEMCALCols); ia++) {
checkResultArray[ia] = 1;
}
-
if (fReqFractionAboveAmp) {
bool ok = false;
if (nHighChan > 0) {
if (!ok) return false; // skip event
}
+ // by default all columns are accepted (init check to > 0)
+ int checkResultArrayLEDRef[AliEMCALGeoParams::fgkEMCALModules * AliEMCALGeoParams::fgkEMCALLEDRefs];
+ for (int ia=0; ia<(AliEMCALGeoParams::fgkEMCALModules * AliEMCALGeoParams::fgkEMCALLEDRefs); ia++) {
+ checkResultArrayLEDRef[ia] = 1;
+ }
+ if (fReqLEDRefAboveAmpCutVal) {
+ bool ok = false;
+ if (nLEDRefChan > 0) {
+ ok = CheckLEDRefAboveAmp(iLEDAmpVal, checkResultArrayLEDRef);
+ }
+ if (!ok) return false; // skip event
+ }
+
fNAcceptedEvents++; // one more event accepted
if (fStartTime == 0) { // if start-timestamp wasn't set,we'll pick it up from the first event we encounter
}
// it is a led event, now fill TTree
+ // We also do the activity check for LEDRefs/Strips, but need to translate between column
+ // and strip indices for that; based on these relations:
+ // iStrip = AliEMCALGeoParams::GetStripModule(iSM, iCol);
+ // iStrip = (iSM%2==0) ? iCol/2 : AliEMCALGeoParams::fgkEMCALLEDRefs - 1 - iCol/2;
+ // which leads to
+ // iColFirst = (iSM%2==0) ? iStrip*2 : (AliEMCALGeoParams::fgkEMCALLEDRefs - 1 - iStrip)*2;
+
for(int i=0; i<fModules; i++){
- for(int j=0; j<fColumns; j++){
- if (checkResultArray[i*fColumns + j] > 0) { // column passed check
+ for(int j=0; j<fColumns; j++) {
+ int iStrip = (i%2==0) ? j/2 : AliEMCALGeoParams::fgkEMCALLEDRefs - 1 - j/2;
+ if (checkResultArray[i*fColumns + j]>0 && checkResultArrayLEDRef[i*fLEDRefs + iStrip]>0) { // column passed check
for(int k=0; k<fRows; k++){
iTowerNum = GetTowerNum(i, j, k);
fNLowGain[iTowerNum]++;
}
} // rows
- } // column passed check
+ } // column passed check, and LED Ref for strip passed check (if any)
} // columns
- // We also do the activity check for LEDRefs/Strips, but need to translate between column
- // and strip indices for that; based on these relations:
- // iStrip = AliEMCALGeoParams::GetStripModule(iSM, iCol);
- // iStrip = (iSM%2==0) ? iCol/2 : AliEMCALGeoParams::fgkEMCALLEDRefs - 1 - iCol/2;
- // which leads to
- // iColFirst = (iSM%2==0) ? iStrip*2 : (AliEMCALGeoParams::fgkEMCALLEDRefs - 1 - iStrip)*2;
-
// also LED refs
for(int j=0; j<fLEDRefs; j++){
int iColFirst = (i%2==0) ? j*2 : (AliEMCALGeoParams::fgkEMCALLEDRefs - 1 - j)*2; //CHECKME!!!
- if ( (checkResultArray[i*fColumns + iColFirst]>0) || (checkResultArray[i*fColumns + iColFirst + 1]>0) ) { // at least one column in strip passed check
- for (gain=0; gain<2; gain++) {
- fRefNum = GetRefNum(i, j, gain);
- if (iLEDAmpVal[fRefNum]) {
- fAmp = iLEDAmpVal[fRefNum];
- fTreeLEDAmpVsTime->Fill();//fRefNum,fHour,fAmp);
- fNRef[fRefNum]++;
- }
- } // gain
- } // at least one column in strip passed check
+ if ( ((checkResultArray[i*fColumns + iColFirst]>0) || (checkResultArray[i*fColumns + iColFirst + 1]>0)) && // at least one column in strip passed check
+ (checkResultArrayLEDRef[i*fLEDRefs + j]>0) ) { // and LED Ref passed checks
+ for (gain=0; gain<2; gain++) {
+ fRefNum = GetRefNum(i, j, gain);
+ if (iLEDAmpVal[fRefNum]) {
+ fAmp = iLEDAmpVal[fRefNum];
+ fTreeLEDAmpVsTime->Fill();//fRefNum,fHour,fAmp);
+ fNRef[fRefNum]++;
+ }
+ } // gain
+ } // at least one column in strip passed check, and LED Ref passed check (if any)
}
} // modules
//1: set up TProfiles for the towers that had data
TProfile * profile[fgkMaxTowers*2]; // *2 is since we include both high and low gains
memset(profile, 0, sizeof(profile));
-
- char name[200]; // for profile id and title
+ const Int_t buffersize = 200;
+ char name[buffersize]; // for profile id and title
int iTowerNum = 0;
for (int i = 0; i<fModules; i++) {
// high gain
if (fNHighGain[iTowerNum] > 0) {
fChannelNum = GetChannelNum(i, ic, ir, 1);
- sprintf(name, "profileChan%d", fChannelNum);
+ snprintf(name,buffersize,"profileChan%d", fChannelNum);
profile[fChannelNum] = new TProfile(name, name, numProfBins, timeMin, timeMax, "s");
}
// same for low gain
if (fNLowGain[iTowerNum] > 0) {
fChannelNum = GetChannelNum(i, ic, ir, 0);
- sprintf(name, "profileChan%d", fChannelNum);
+ snprintf(name,buffersize,"profileChan%d", fChannelNum);
profile[fChannelNum] = new TProfile(name, name, numProfBins, timeMin, timeMax, "s");
}
for (int gain=0; gain<2; gain++) {
fRefNum = GetRefNum(i, j, gain);
if (fNRef[fRefNum] > 0) {
- sprintf(name, "profileLEDRef%d", fRefNum);
+ snprintf(name, buffersize, "profileLEDRef%d", fRefNum);
profileLED[fRefNum] = new TProfile(name, name, numProfBins, timeMin, timeMax, "s");
}
}// gain