#include "ILowLevelInfoModule.hxx" #include "ITFBDigit.hxx" #include "ITFBChannelId.hxx" #include "IHit.hxx" #include "IGeomInfo.hxx" #include "IIntegerDatum.hxx" ClassImp(COMET::ILowLevelInfoModule); ClassImp(COMET::ILowLevelInfoModule::ILowLevelTFBDigit); ClassImp(COMET::ILowLevelInfoModule::ILowLevelHit); //---------------------------------------------------------------------- COMET::ILowLevelInfoModule::ILowLevelInfoModule(const char *name, const char *title) { SetNameTitle(name, title); // Enable this module by default: fIsEnabled = kTRUE; fDescription = "Module for extracting IDigit and IHit level info from the output of oaUnpack"; fLowLevelTFBDigits = new TClonesArray("COMET::ILowLevelInfoModule::ILowLevelTFBDigit",100); fLowLevelHits = new TClonesArray("COMET::ILowLevelInfoModule::ILowLevelHit",100); } //---------------------------------------------------------------------- void COMET::ILowLevelInfoModule::InitializeBranches() { //DIGIT AND HIT INFO fOutputTree->Branch("TFBDigitArray", &fLowLevelTFBDigits, fBufferSize, fSplitLevel); fOutputTree->Branch("HitArray", &fLowLevelHits, fBufferSize, fSplitLevel); } //---------------------------------------------------------------------- bool COMET::ILowLevelInfoModule::FillTree(COMET::ICOMETEvent& event) { fEventNumber = event.GetEventId(); // =========================================================================== // First get mcmTrig info // Long64_t fTdcTrig = 0; COMET::IHandle mcmTrigTime = event.Get("mcmTrigTime"); if (mcmTrigTime){ UInt_t trigger_mcmTDC = static_cast(mcmTrigTime->GetValue()); const Long64_t mcmTick(4LL); fTdcTrig = mcmTick * trigger_mcmTDC; } Long64_t fTdcRead = 0; Float_t fTimeRead = 0; COMET::IHandle mcmTimeSinceBusy = event.Get("mcmTimeSinceBusy"); if (mcmTimeSinceBusy){ UInt_t dt_bktTrig_mcmTDC = static_cast(mcmTimeSinceBusy->GetValue()); const Long64_t mcmTick(4LL); fTdcRead = mcmTick * dt_bktTrig_mcmTDC; fTimeRead = (fTdcRead%260) * 2.5; } // =========================================================================== // Get the TFBDigits // COMET::IHandle digitV = event.Get("digits"); if (digitV) { COMETDebug("\nFound a vector of digit containers!"); fNLowLevelTFBDigits = 0; for(COMET::IDataVector::iterator diter = digitV->begin(); diter != digitV->end(); diter++){ COMET::IDigitContainer* digList = dynamic_cast(*diter); if (digList){ std::string dt_name = digList->GetName(); dt_name += "digits"; std::string dt_name_full = (digList->GetFullName()).Data(); dt_name_full += "digits"; EDigitType digit_type = this->GetDigitType(digList->GetName()); /// For now just do for ecal defined digits but could expand this to work for /// other sub-systems such as ingrid, smrd etc... if(digit_type == kECalDigits){ COMETDebug("Found an ecal digit container with name = " << dt_name << " and "<< digList->size() << " elements"); COMET::IDigitContainer::iterator digItr; for (digItr=digList->begin(); digItr!=digList->end(); ++digItr){ ITFBDigit* digit = dynamic_cast (*digItr); if (!digit) { continue; } // Now make a new lowleveltfbdigit and add it to the clones array. COMET::ILowLevelInfoModule::ILowLevelTFBDigit * fTFBDigit = new( (*fLowLevelTFBDigits)[fNLowLevelTFBDigits++] ) COMET::ILowLevelInfoModule::ILowLevelTFBDigit(); // Fill in the lowleveldigit fields. ITFBChannelId id(digit->GetChannelId()); fTFBDigit->Chan = id.GetChannel() + 16*id.GetTripChip(); fTFBDigit->Tfb = id.GetTFB(); fTFBDigit->Rmm = id.GetRMM(); fTFBDigit->Subdet = id.GetSubDetector(); fTFBDigit->Side = 0; fTFBDigit->Err = 0; fTFBDigit->Err += (digit->CheckTimeDiscriminator() ? 0x1 : 0); fTFBDigit->Tdc = (digit->GetTimeCounter()*4) + digit->GetTimeQuad(); fTFBDigit->Adc_lo = digit->GetLowGainADC(); fTFBDigit->Adc_hi = digit->GetHighGainADC(); fTFBDigit->TdcTrig = fTdcTrig; fTFBDigit->TdcRead = fTdcRead; } // end of loop over digits in container } // for ecal digits } // if(digList) } // end of loop over digit containers } // end of if(event.Has... // =========================================================================== // Now get the Hits. // COMET::IHandle hitV = event.Get("hits"); if (hitV) { COMETDebug("Found a hits container!"); fNLowLevelHits = 0; for(COMET::IDataVector::iterator hiter = hitV->begin(); hiter != hitV->end(); ++hiter){ COMET::IHitSelection* hitList = dynamic_cast(*hiter); if (hitList){ EHitType hit_type = this->GetHitType(hitList->GetName()); /// ==================================================================== /// For now just do for ecal defined hits but could expand this to work /// for other sub-systems such as ingrid, smrd etc... if(hit_type == kECalHits){ COMET::IHitSelection::iterator hitItr; for (hitItr=hitList->begin(); hitItr!=hitList->end(); ++hitItr){ // Now make a new lowlevelecal hit and add it to the clones array. COMET::ILowLevelInfoModule::ILowLevelHit * fTFBHit = new( (*fLowLevelHits)[fNLowLevelHits++] ) COMET::ILowLevelInfoModule::ILowLevelHit(); // Fill in the lowlevelhit fields. COMET::IHandle hit = (*hitItr); fTFBHit->Time = hit->GetTime(); fTFBHit->Charge = hit->GetCharge(); fTFBHit->GeomId = hit->GetGeomId().AsInt(); fTFBHit->PosX = hit->GetPosition().X(); fTFBHit->PosY = hit->GetPosition().Y(); fTFBHit->PosZ = hit->GetPosition().Z(); std::string nodename = COMET::IGeomInfo::Get().NodeName(hit->GetGeomId()); fTFBHit->XLayer = this->LayerXFromName(nodename); fTFBHit->YLayer = this->LayerYFromName(nodename); fTFBHit->Bar = this->BarFromName(nodename); fTFBHit->End = -1; fTFBHit->TimeRead = fTimeRead; //fTFBHit->Adc.hi = srcdigit->GetHighGainADC(); } // end of loop over digits in container } // for ecal digits } // if(digList) } // end of loop over digit containers } // end of if(event.Has... return true; } //---------------------------------------------------------------------- Bool_t COMET::ILowLevelInfoModule::ProcessFirstEvent(COMET::ICOMETEvent&) { return true; } //---------------------------------------------------------------------- int COMET::ILowLevelInfoModule::BarFromName(std::string name) { std::string match("Bar_"); if ( name.find(match) == name.npos ) return -1; std::string ss =name.substr(name.find(match)+match.size()); return atoi(ss.c_str()); } //---------------------------------------------------------------------- int COMET::ILowLevelInfoModule::LayerXFromName(std::string name) { std::string match("ScintX1_"); if ( name.find(match) == name.npos ) return -1; std::string ss =name.substr(name.find(match)+match.size()); return atoi(ss.c_str()); } //---------------------------------------------------------------------- int COMET::ILowLevelInfoModule::LayerYFromName(std::string name) { std::string match("ScintY1_"); if ( name.find(match) == name.npos ) return -1; std::string ss =name.substr(name.find(match)+match.size()); return atoi(ss.c_str()); } //---------------------------------------------------------------------- COMET::ILowLevelInfoModule::EDigitType COMET::ILowLevelInfoModule::GetDigitType(const char * name){ std::string digit_str(name); EDigitType digit_type = kOtherDigits; if(digit_str.compare("ecal") == 0){ digit_type = kECalDigits; } else if(digit_str.compare("p0d") == 0){ digit_type = kP0DDigits; } else if(digit_str.compare("smrd") == 0){ digit_type = kSMRDDigits; } else if(digit_str.compare("ingrid") == 0){ digit_type = kINGRIDDigits; } return digit_type; } //---------------------------------------------------------------------- COMET::ILowLevelInfoModule::EHitType COMET::ILowLevelInfoModule::GetHitType(const char * name){ std::string hit_str(name); EHitType hit_type = kOtherHits; if(hit_str.find("ecal") != std::string::npos || hit_str.find("barrel") != std::string::npos){ hit_type = kECalHits; } else if(hit_str.compare("p0d") == 0){ hit_type = kP0DHits; } else if(hit_str.compare("smrd") == 0){ hit_type = kSMRDHits; } else if(hit_str.compare("ingrid") == 0){ hit_type = kINGRIDHits; } return hit_type; } //----------------------------------------------------------------------