45 fCalReplicate(0), fAnalyzer(0), fArray(0)
64 fClusterList(0), fLayerNames(0),
80 std::transform(kwPrefix.begin(), kwPrefix.end(), kwPrefix.begin(), ::tolower);
90 {
"_cal_layer_names", &layernamelist, kString},
101 vector<string> layer_names = Podd::vsplit(layernamelist);
104 cout <<
"THcNPSCalorimeter::Setup ERROR: Number of layers " <<
fNTotLayers
105 <<
" doesn't agree with number of layer names "
106 << layer_names.size() << endl;
112 fLayerNames[i] =
new char[layer_names[i].length()+1];
116 char *desc =
new char[strlen(description)+100];
120 strcpy(desc, description);
121 strcat(desc,
" Array ");
157 const char* EngineDID =
Form(
"%sCAL", kwPrefix.c_str());
159 static const char*
const here =
"Init()";
160 Error(
Here(here),
"Error filling detectormap for %s.", EngineDID );
269 cout <<
"---------------------------------------------------------------\n";
270 cout <<
"Debug output from THcNPSCalorimeter::ReadDatabase for "
273 cout <<
" Number of neg. columns = " <<
fNegCols << endl;
274 cout <<
" Slop parameter = " <<
fSlop << endl;
275 cout <<
" Fiducial volume test flag = " <<
fvTest << endl;
276 cout <<
" Fiducial volume excl. width = " <<
fvDelta << endl;
277 cout <<
" Initialize debug flag = " <<
fdbg_init_cal << endl;
278 cout <<
" Raw hit debug flag = " <<
fdbg_raw_cal << endl;
295 cout <<
"Clustering Algorithm: HCANA STANDARD " << endl;
300 *
fOutFile <<
"#! evNum[i,0]/, \t Nclusters[i,1]/, \t iCluster[i,2]/, \t BlockID[i,3]/, \t fT[f,4]/, \t fPI[f,5]/, \t fE[f,6]/" << endl;
308 cout <<
"Clustering Algorithm: CELLULAR AUTOMATA " << endl;
312 *
fOutFile <<
"#! evNum[i,0]/, \t Nclusters[i,1]/, \t iCluster[i,2]/, \t BlockID[i,3]/, \t fT[f,4]/, \t fPI[f,5]/, \t fE[f,6]/" << endl;
389 {
"nhits",
"(Total) Number of good hits",
"fNhits" },
390 {
"nclust",
"Number of layer clusters",
"fNclust" },
391 {
"etot",
"Total energy",
"fEtot" },
392 {
"clusX",
"Cluster x coordinate",
"fClusterX" },
393 {
"clusY",
"Cluster y coordinate",
"fClusterY" },
394 {
"clusZ",
"Cluster z coordinate",
"fClusterZ" },
395 {
"clusT",
"Cluster time",
"fClusterT" },
396 {
"clusE",
"Cluster energy",
"fClusterE" },
397 {
"clusSize",
"Cluster size",
"fClusters.fSize" },
398 {
"vtpErrorFlag",
"VTP error flag",
"fVTPErrorFlag" },
399 {
"vtpTrigTime",
"VTP trigger time",
"fVTPTriggerTime" },
400 {
"vtpTrigCrate",
"VTP trigger crate",
"fVTPTriggerCrate" },
401 {
"vtpTrigType0",
"VTP trigger cluster singles",
"fVTPTriggerType0" },
402 {
"vtpTrigType1",
"VTP trigger cosmic scin",
"fVTPTriggerType1" },
403 {
"vtpTrigType2",
"VTP trigger cosmic col",
"fVTPTriggerType2" },
404 {
"vtpTrigType3",
"VTP trigger cluster pair different crate",
"fVTPTriggerType3" },
405 {
"vtpTrigType4",
"VTP trigger cluster pair same crate",
"fVTPTriggerType4" },
406 {
"vtpTrigType5",
"VTP trigger VLD",
"fVTPTriggerType5" },
407 {
"vtpClusTime",
"VTP cluster time",
"fVTPClusterTime" },
408 {
"vtpClusE",
"VTP cluster energy",
"fVTPClusterEnergy" },
409 {
"vtpClusSize",
"VTP cluster n blocks",
"fVTPClusterSize" },
410 {
"vtpClusX",
"VTP cluster x coordinate",
"fVTPClusterX" },
411 {
"vtpClusY",
"VTP cluster y coordinate",
"fVTPClusterY" },
412 {
"vldErrorFlag",
"VLD error flag",
"fVLDErrorFlag" },
413 {
"vldLoChannelMask",
"VLD lo channel mask",
"fVLDLoChannelMask" },
414 {
"vldHiChannelMask",
"VLD hi channel mask",
"fVLDHiChannelMask" },
415 {
"vldColumn",
"VLD column",
"fVLDColumn" },
416 {
"vldRow",
"VLD row",
"fVLDRow" },
417 {
"vldPMT",
"VLD PMT",
"fVLDPMT" },
423 RVarDef array_vars[] = {
458 Podd::DeleteContainer(**i);
507 Podd::DeleteContainer(**i);
561 Int_t crate_num=
d->crate;
569 if( Nvtpfound == 1 ) {
599 for (
UInt_t nn=0 ; nn < temp1.size(); nn++) {
647 for(
size_t i=0; i<vldChannelMask.size(); i++ ) {
649 if( vldChannelMask.at(i) == 0 )
continue;
652 column = vldConnectorID.at(i) + 27 ;
653 else if( Nvldfound == 2 )
654 column = vldConnectorID.at(i) + 24 ;
655 else if( Nvldfound >= 3 && Nvldfound <= 10 )
656 column = vldConnectorID.at(i) + (3 * i/8);
658 cout <<
"THcNPSCalorimeter VLD decode error: Found " << Nvldfound <<
" VLD modules. There should be " <<
fnVLD << endl;
662 if( Nvldfound > 3 )
continue;
664 for(
int row=0; row<18; row++) {
666 if(
TESTBIT(vldChannelMask.at(i), row) ) {
668 if( vldLoHiBit.at(i) == 0 ) {
671 fVLDPMT.push_back( column + (30*row) );
675 if( vldLoHiBit.at(i) == 1 ) {
677 fVLDRow.push_back( (row + 18) );
678 fVLDPMT.push_back( column + (30*(row+18)) );
689 if( Nvtpfound >
fnVTP ) {
690 cout <<
"THcNPSCalorimeter VTP decode error: Found " << Nvtpfound <<
" VTP modules. There should be " <<
fnVTP << endl;
785 while (HitSet.size() != 0) {
790 (*cluster).insert(*(--it));
793 bool clustered =
true;
804 if ((**i).isNeighbour(*k)) {
805 (*cluster).insert(*i);
811 if (clustered)
break;
814 if (clustered)
break;
819 ClusterList->push_back(cluster);
824 fNclust = (*ClusterList).size();
828 ppcl != (*ClusterList).end(); ++ppcl) {
851 for (
size_t i=0; i<ClusterList->size(); i++){
856 *
fOutFile <<
"\t" <<
fEvent <<
",\t\t\t" << ClusterList->size() <<
",\t\t\t" << (i+1) <<
",\t\t\t" << (*j)->hitID() <<
",\t\t\t" << (*j)->hitT() <<
",\t\t\t" << (*j)->hitPI() <<
",\t\t\t" << (*j)->hitE() <<endl;
916 vector<Double_t> blk_pulseInt(
fNelem, -1);
917 vector<Double_t> blk_pulseTime(
fNelem, -1);
918 vector<Int_t> good_blk_id;
919 vector<Double_t> good_blk_pulseInt;
928 for(
int ielem=0; ielem<
fNelem; ielem++){
929 blk_hit_idx[ielem]=-1;
938 blk_pulseInt[ (*ihit)->hitID() ] = (*ihit)->hitE();
939 blk_pulseTime[ (*ihit)->hitID() ] = (*ihit)->hitT();
940 good_blk_id.push_back( (*ihit)->hitID() );
941 good_blk_pulseInt.push_back( (*ihit)->hitE() );
944 blk_hit_idx[ (*ihit)->hitID() ] = fNbBlocks;
952 Bool_t virus[fNbBlocks], virustmp[fNbBlocks], ill[fNbBlocks];
966 for(
Int_t j=0; j < fNbBlocks; j++){
979 for(
Int_t k=0;k<8;k++){
991 if( blk_pulseInt[
fArray->
GetNeighbor(good_blk_id[j], k) ] > good_blk_pulseInt[j] ){
1004 if (virus[j]==
true) { NbClusters++; }
1026 for(
Int_t j=0; j<fNbBlocks; j++){
1031 pIvirus[cp] = good_blk_pulseInt[j];
1042 pIpastmp[ielem] =-1.;
1047 for(
Int_t j=0; j<fNbBlocks; j++){
1050 pIpas[ good_blk_id[j] ] = good_blk_pulseInt[j];
1057 pIpastmp[ good_blk_id[j] ] = good_blk_pulseInt[j];
1078 Int_t safe=0, nbfine=1, virus_blk=-2;
1081 while(nbfine>0 && safe<15){
1088 for(
Int_t j=0; j<fNbBlocks; j++){
1106 for(
Int_t k=0; k<8; k++){
1141 pIpastmp[ good_blk_id[j] ]=
max;
1145 if(virus[virus_blk]){
1167 if(i<fNbBlocks) { virus[i] = virustmp[i]; }
1170 if(pIpastmp[i]!=-1){
1172 pIpas[i]=pIpastmp[i];
1180 for(
Int_t i=0; i<fNbBlocks; i++){
1201 while (HitSet.size() != 0) {
1208 (*cluster).insert(*(--it));
1211 bool clustered =
true;
1227 if(pIpas[ (*i)->hitID() ] == pIpas[ (*k)->hitID() ] && (blk_pulseTime[ (*i)->hitID() ] - blk_pulseTime[ (*k)->hitID() ]) > -
fClusterTimeWindow && (blk_pulseTime[ (*i)->hitID() ] - blk_pulseTime[ (*k)->hitID() ]) <
fClusterTimeWindow){
1229 (*cluster).insert(*i);
1238 if (clustered)
break;
1241 if (clustered)
break;
1246 ClusterList->push_back(cluster);
1250 fNclust = (*ClusterList).size();
1253 ppcl != (*ClusterList).end(); ++ppcl) {
1277 for (
size_t i=0; i<ClusterList->size(); i++){
1289 *
fOutFile <<
"\t" <<
fEvent <<
",\t\t\t" << ClusterList->size() <<
",\t\t\t" << (i+1) <<
",\t\t\t" << (*j)->hitID() <<
",\t\t\t" << (*j)->hitT() <<
",\t\t\t" << (*j)->hitPI() <<
",\t\t\t" << (*j)->hitE() << endl;
1308 return x +
h->hitE();
1312 return x +
h->hitE() *
h->hitX();
1316 return x +
h->hitE() *
h->hitY();
1320 return x +
h->hitE() *
h->hitZ();
1324 return x +
h->hitE() *
h->hitT();
1328 return h->hitColumn() == 0 ?
x +
h->hitE() :
x;
1345 Double_t Etot = accumulate((*cluster).begin(),(*cluster).end(),0.,
addE);
1347 hitW = (W0 +
TMath::Log((*pph)->hitE()/Etot) > 0. ? W0 +
TMath::Log((*pph)->hitE()/Etot) : 0.);
1349 x += hitW * (*pph)->hitY();
1351 return (Wtot != 0. ?
x/Wtot : -100.);
1362 Double_t Etot = accumulate((*cluster).begin(),(*cluster).end(),0.,
addE);
1364 hitW = (W0 +
TMath::Log((*pph)->hitE()/Etot) > 0. ? W0 +
TMath::Log((*pph)->hitE()/Etot) : 0.);
1366 x += hitW * (*pph)->hitX();
1368 return (Wtot != 0. ?
x/Wtot : -100.);
1376 Double_t Etot = accumulate((*cluster).begin(),(*cluster).end(),0.,
addE);
1377 return (Etot != 0. ?
1378 accumulate((*cluster).begin(),(*cluster).end(),0.,
addZ)/Etot : 0.);
1386 Double_t Etot = accumulate((*cluster).begin(),(*cluster).end(),0.,
addE);
1387 return (Etot != 0. ?
1388 accumulate((*cluster).begin(),(*cluster).end(),0.,
addT)/Etot : 0.);
1394 return accumulate((*cluster).begin(),(*cluster).end(),0.,
addE);
1400 return accumulate((*cluster).begin(),(*cluster).end(),0.,
addEpr);
1411 if (side!=0&&side!=1&&side!=2) {
1412 cout <<
"*** Wrong Side in clEplane:" << side <<
" ***" << endl;
1418 if ((*it)->hitColumn() == iplane) pcluster.insert(*it);
1432 Eplane = accumulate(pcluster.begin(),pcluster.end(),0.,
addE);
Option_t Option_t TPoint TPoint const char mode
R__EXTERN class THaVarList * gHaVars
R__EXTERN class THaCutList * gHaCuts
ClassImp(VDC::AnalyticTTDConv) using namespace std
R__EXTERN class THcParmList * gHcParms
R__EXTERN class THcDetectorMap * gHcDetectorMap
Double_t addX(Double_t x, THcNPSShowerHit *h)
Double_t clT(THcNPSShowerCluster *cluster)
Double_t clX(THcNPSShowerCluster *cluster)
Double_t addE(Double_t x, THcNPSShowerHit *h)
Double_t addT(Double_t x, THcNPSShowerHit *h)
Double_t clEplane(THcNPSShowerCluster *cluster, Int_t iplane, Int_t side)
Double_t clE(THcNPSShowerCluster *cluster)
Double_t addEpr(Double_t x, THcNPSShowerHit *h)
Double_t clY(THcNPSShowerCluster *cluster)
Double_t addZ(Double_t x, THcNPSShowerHit *h)
Double_t clZ(THcNPSShowerCluster *cluster)
Double_t clEpr(THcNPSShowerCluster *cluster)
Double_t addY(Double_t x, THcNPSShowerHit *h)
Double_t clT(THcNPSShowerCluster *cluster)
Double_t clX(THcNPSShowerCluster *cluster)
Double_t clE(THcNPSShowerCluster *cluster)
Double_t clY(THcNPSShowerCluster *cluster)
Double_t clZ(THcNPSShowerCluster *cluster)
THcNPSShowerCluster::iterator THcNPSShowerClusterIt
THcNPSShowerClusterList::iterator THcNPSShowerClusterListIt
vector< THcNPSShowerCluster * > THcNPSShowerClusterList
THcNPSShowerHitSet THcNPSShowerCluster
THcNPSShowerHitSet::iterator THcNPSShowerHitIt
set< THcNPSShowerHit * > THcNPSShowerHitSet
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
virtual std::vector< UInt_t > GetConnectorID()
virtual std::vector< UInt_t > GetChannelMask()
virtual std::vector< UInt_t > GetLoHiBit()
virtual std::vector< UInt_t > GetTriggerType1()
virtual std::vector< UInt_t > GetClusterEnergy()
virtual std::vector< UInt_t > GetTriggerType3()
virtual std::vector< UInt_t > GetTriggerTime()
virtual std::vector< UInt_t > GetTriggerType0()
virtual UInt_t GetTriggerNum()
virtual std::vector< UInt_t > GetTriggerType2()
virtual std::vector< UInt_t > GetTriggerType5()
virtual std::vector< UInt_t > GetClusterX()
virtual std::vector< UInt_t > GetClusterTime()
virtual std::vector< UInt_t > GetClusterY()
virtual std::vector< UInt_t > GetTriggerType4()
virtual std::vector< UInt_t > GetClusterSize()
static Int_t DefineVarsFromList(const void *list, EType type, EMode mode, const char *def_prefix, const TObject *obj, const char *prefix, const char *here, const char *comment_subst="")
virtual const char * Here(const char *) const
static THaAnalyzer * GetInstance()
virtual Int_t Result(const char *cutname="", EWarnMode mode=kWarn)
Module * GetModule(UInt_t i) const
UInt_t GetTotNumChan() const
virtual void DefineAxes(Double_t rotation_angle)
THaApparatus * GetApparatus() const
virtual Decoder::Module * GetModule(UInt_t roc, UInt_t slot) const
virtual THaVar * Find(const char *name) const
const void * GetValuePointer() const
virtual Int_t FillMap(THaDetMap *detmap, const char *detectorname)
virtual Int_t DecodeToHitList(const THaEvData &evdata, Bool_t suppress=kFALSE)
TClonesArray * fRawHitList
void MissReport(const char *name)
void CreateMissReportParms(const char *prefix)
void InitHitList(THaDetMap *detmap, const char *hitclass, Int_t maxhits, Int_t tdcref_cut=0, Int_t adcref_cut=0)
Bool_t GetClearThisEvent()
virtual EStatus Init(const TDatime &run_time)
virtual Int_t AccumulatePedestals(TClonesArray *rawhits, Int_t nexthit)
virtual Int_t CoarseProcessHits()
virtual void CalculatePedestals()
virtual void Clear(Option_t *opt="")
virtual Int_t ClearProcessedHits()
virtual Int_t AccumulateHits(TClonesArray *rawhits, Int_t nexthit, Int_t quadrant)
virtual Int_t CoarseProcess(TClonesArray &tracks)
Int_t GetNeighbor(UInt_t id, UInt_t k)
void GetMax(Float_t pInei[8], Int_t nei[8], Int_t &virus_blk, Float_t &max)
Generic segmented shower detector.
std::vector< Double_t > fClusterZ
THcNPSShowerClusterList * fClusterList
std::vector< UInt_t > fVLDColumn
static const Int_t kADCDynamicPedestal
virtual Int_t End(THaRunBase *r=0)
void ClusterHits(THcNPSShowerHitSet &HitSet, THcNPSShowerClusterList *ClusterList)
std::vector< THcNPSCluster > fClusters
virtual void Clear(Option_t *opt="")
std::vector< UInt_t > fVTPClusterY
Double_t fClusterTimeWindow
std::vector< UInt_t > fVTPTriggerType2
std::vector< UInt_t > fVLDRow
std::vector< UInt_t > fVTPClusterEnergy
void Setup(const char *name, const char *description)
std::vector< UInt_t > fVTPClusterTime
std::vector< UInt_t > fVTPTriggerType4
std::vector< UInt_t > fVTPClusterSize
std::vector< UInt_t > fVTPTriggerType3
std::vector< Int_t > fVTPTriggerCrate
std::vector< Double_t > fClusterE
std::vector< UInt_t > fVTPTriggerType1
std::vector< UInt_t > fVLDPMT
std::vector< UInt_t > fVTPClusterX
virtual Int_t DefineVariables(EMode mode=kDefine)
THcNPSAnalyzer * fAnalyzer
virtual Int_t Decode(const THaEvData &)
std::vector< Double_t > fClusterY
std::vector< UInt_t > fVTPTriggerType0
std::vector< UInt_t > fVLDHiChannelMask
std::vector< Double_t > fClusterT
Int_t fdbg_sparsified_cal
virtual ~THcNPSCalorimeter()
std::vector< Double_t > fClusterX
std::vector< UInt_t > fVLDLoChannelMask
virtual Int_t CoarseProcess(TClonesArray &tracks)
virtual Int_t FineProcess(TClonesArray &tracks)
std::vector< UInt_t > fVTPTriggerType5
std::vector< UInt_t > fVTPTriggerTime
virtual Int_t ReadDatabase(const TDatime &date)
void ClusterNPS_Hits(THcNPSShowerHitSet &HitSet, THcNPSShowerClusterList *ClusterList)
void AddBlock(Int_t blockID)
Int_t LoadParmValues(const DBRequest *list, const char *prefix="")
const char * GetName() const override
const char * GetTitle() const override
virtual void Error(const char *method, const char *msgfmt,...) const
virtual UInt_t Integer(UInt_t imax)
double max(double x, double y)
Double_t Min(Double_t a, Double_t b)
Double_t Max(Double_t a, Double_t b)