00001
00002
00003
00004
00005
00006
00007
00009
00010 #include <cassert>
00011
00012 #include "CandChop/AlgChopListGeneric.h"
00013 #include "CandChop/CandChopListHandle.h"
00014 #include "CandChop/DigitVector.h"
00015
00016
00017 #include "Algorithm/AlgConfig.h"
00018 #include "Algorithm/AlgFactory.h"
00019 #include "Algorithm/AlgHandle.h"
00020 #include "CandData/CandHeader.h"
00021 #include "CandData/CandRecord.h"
00022 #include "CandDigit/CandDigitHandle.h"
00023 #include "CandDigit/CandDigitListHandle.h"
00024 #include "CandDigit/CandDigitList.h"
00025 #include "Candidate/CandContext.h"
00026 #include "MessageService/MsgService.h"
00027 #include "MinosObjectMap/MomNavigator.h"
00028 #include "RawData/RawHeader.h"
00029 #include "RawData/RawRecord.h"
00030 #include "RawData/RawDigitDataBlock.h"
00031 #include "UgliGeometry/UgliGeomHandle.h"
00032 #include "UgliGeometry/UgliStripHandle.h"
00033 #include "Validity/VldContext.h"
00034 #include "Calibrator/Calibrator.h"
00035
00036 ClassImp(AlgChopListGeneric)
00037 CVSID( " $Id: AlgChopListGeneric.cxx,v 1.3 2007/11/11 08:26:13 rhatcher Exp $ ");
00038
00039 struct compareDigitTimes : public binary_function<const CandDigitHandle&, const CandDigitHandle&, bool> {
00040 bool operator()(const CandDigitHandle& d1, const CandDigitHandle& d2) {
00041 return (d1.GetTime() < d2.GetTime());
00042 }
00043 };
00044
00045 const RawChannelId kQieRcid(Detector::kNear,ElecType::kQIE,0,0,false,false);
00046
00047
00048
00049 AlgChopListGeneric::AlgChopListGeneric()
00050 {
00051 }
00052
00053
00054 AlgChopListGeneric::~AlgChopListGeneric()
00055 {
00056 }
00057
00058
00059
00060
00061 void AlgChopListGeneric::RunAlg(AlgConfig& ,
00062 CandHandle &candHandle,
00063 CandContext &candContext)
00064 {
00068
00069 assert(candHandle.InheritsFrom("CandChopListHandle"));
00070
00071
00072
00073 assert(candContext.GetDataIn());
00074
00075 if (!(candContext.GetDataIn()->InheritsFrom("CandDigitListHandle"))) {
00076 MSG("Chop",Msg::kWarning ) << "Data into AlgChopListGeneric is not a digit list." << std::endl;
00077 }
00078
00079 const CandDigitListHandle *cdlh_ptr =
00080 dynamic_cast<const CandDigitListHandle*>(candContext.GetDataIn());
00081
00082 const MomNavigator *mom = candContext.GetMom();
00083 RawRecord *rr = dynamic_cast<RawRecord *>(mom->GetFragment("RawRecord"));
00084 if (!rr) {
00085 MSG("Chop", Msg::kWarning) << "No RawRecord in MOM." << endl;
00086 return;
00087 }
00088 const RawDigitDataBlock *rddb = dynamic_cast<const RawDigitDataBlock *>
00089 (rr->FindRawBlock("RawDigitDataBlock"));
00090 if (!rddb) {
00091 MSG("Chop", Msg::kWarning) << "No RawDigitDataBlock in RawRecord." << endl;
00092 return;
00093 }
00094
00095
00096 AlgFactory &af = AlgFactory::GetInstance();
00097 AlgHandle ah = af.GetAlgHandle("AlgChop","default");
00098 CandContext cxx(this,candContext.GetMom());
00099
00100 const VldContext &context = *(candContext.GetCandRecord()->GetVldContext());
00101 if(context.GetDetector() != Detector::kNear)
00102 MSG("Chop",Msg::kError) << "Running the Generic algorithm on FD data is a no-no!" << endl;
00103
00104 Calibrator& cal = Calibrator::Instance();
00105 UgliGeomHandle ugli(context);
00106
00107
00108
00109
00110 DigitVector digits(cdlh_ptr);
00111
00112 UInt_t ndigits = digits.size();
00113
00114
00115
00116
00117
00118
00119 std::vector<int> digit_tdc(ndigits);
00120 std::vector<UInt_t> digit_plane(ndigits);
00121
00122 for(UInt_t i=0;i<ndigits;i++) {
00123 digit_tdc[i] = (cal.GetTDCFromTime(digits[i].GetTime(CalTimeType::kNone), kQieRcid));
00124 digit_plane[i] = digits[i].GetPlexSEIdAltL().GetPlane();
00125
00126
00127
00128
00129 }
00130
00131
00132 Int_t tfirst = digit_tdc[0];
00133 Int_t tlast = digit_tdc[0];
00134 for(UInt_t i=0;i<ndigits;i++) {
00135 if(digit_tdc[i] < tfirst) tfirst = digit_tdc[i];
00136 if(digit_tdc[i] > tlast ) tlast = digit_tdc[i];
00137 }
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 }
00152
00153
00154 void AlgChopListGeneric::Trace(const char * ) const
00155 {
00156 }
00157