Skip to content

Commit 8ae2298

Browse files
authored
Merge pull request #99 from emilelavaut/develop
space-point and waveform add
2 parents 26b69cd + db95c8c commit 8ae2298

File tree

7 files changed

+392
-303
lines changed

7 files changed

+392
-303
lines changed

duneana/CalibAna/CalibAnaTree.h

Lines changed: 1 addition & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -206,192 +206,6 @@ class dune::CalibAnaTree : public art::EDAnalyzer {
206206

207207
void DoTailFit();
208208

209-
//single hit fct
210-
/*
211-
bool AllSame(std::vector<int> v);
212-
213-
std::vector<std::string> GetGeneratorTag(art::Event const& e,
214-
art::InputTag fG4producer,
215-
art::ServiceHandle<cheat::BackTrackerService> bt_serv);
216-
217-
bool Inside( int k , std::list<int> liste);
218-
219-
float GetDist( float x0 , float y0 , float z0 ,
220-
float x1 , float y1 , float z1 );
221-
222-
int NearOrFar( bool IsPDVD , bool IsPDHD , const recob::Hit & hit);
223-
224-
void GetTimeIsolation(art::Event const & ev,
225-
art::InputTag HitLabel,
226-
float const PeakTimeWdInt,
227-
float const PeakTimeWdExt,
228-
std::list<int> & index_list_single,
229-
std::list<int> & index_listIsolated);
230-
231-
void GetListOfTimeCoincidenceHit( bool IsPDVD , bool IsPDHD ,
232-
art::Event const & ev,
233-
art::InputTag HitLabel,
234-
const float CoincidenceWd1_l,
235-
const float CoincidenceWd1_r,
236-
const float CoincidenceWd2_l,
237-
const float CoincidenceWd2_r,
238-
const recob::Hit & HitCol,
239-
std::list<geo::WireID> & WireInd1,
240-
std::list<geo::WireID> & WireInd2,
241-
std::list<int> & ChannelInd1,
242-
std::list<int> & ChannelInd2,
243-
std::list<float> & EInd1,
244-
std::list<float> & EInd2,
245-
std::list<float> & PTInd1,
246-
std::list<float> & PTInd2,
247-
std::list<float> & PAInd1,
248-
std::list<float> & PAInd2);
249-
250-
void GetListOfCrossingChannel(bool IsPDVD , bool IsPDHD,
251-
float Ymin , float Ymax , float Zmin , float Zmax,
252-
geo::WireID & WireCol,
253-
std::list<geo::WireID> & WireInd1,
254-
std::list<geo::WireID> & WireInd2,
255-
std::list<int> & ChInd1,
256-
std::list<float> & EInd1,
257-
std::list<float> & YInd1,
258-
std::list<float> & ZInd1,
259-
std::list<int> & ChIntersectInd1,
260-
std::list<float> & EIntersectInd1,
261-
std::list<int> & ChInd2,
262-
std::list<float> & EInd2,
263-
std::list<float> & YInd2,
264-
std::list<float> & ZInd2,
265-
std::list<int> & ChIntersectInd2,
266-
std::list<float> & EIntersectInd2);
267-
268-
void GetListOf3ViewsPoint( float pitch , float alpha ,
269-
std::list<int> & ChIntersectInd1,
270-
std::list<float> YInd1,
271-
std::list<float> ZInd1,
272-
std::list<float> EIntersectInd1,
273-
std::list<int> & ChIntersectInd2,
274-
std::list<float> YInd2,
275-
std::list<float> ZInd2,
276-
std::list<float> EIntersectInd2,
277-
std::list<float> & listYSP,
278-
std::list<float> & listZSP,
279-
std::list<float> & listEind1SP,
280-
std::list<float> & listEind2SP,
281-
std::list<int> & listCh1SP,
282-
std::list<int> & listCh2SP);
283-
284-
std::vector<int> GetXYZIsolatedPoint(
285-
std::vector<float> vYPoint,
286-
std::vector<float> vZPoint,
287-
std::vector<float> vPeakTimeCol,
288-
std::vector<int> vNOF,
289-
float fElectronVelocity,
290-
float fTickToMus,
291-
float radiusInt,
292-
float radiusExt);
293-
294-
bool IntersectOutsideOfTPC(
295-
float Ymin , float Ymax , float Zmin , float Zmax,
296-
double ChInd_start_y,
297-
double ChInd_start_z,
298-
double ChInd_end_y,
299-
double ChInd_end_z,
300-
double ChCol_start_y,
301-
double ChCol_start_z,
302-
double ChCol_end_y,
303-
double ChCol_end_z,
304-
double& y , double& z );
305-
306-
point gen_yz(int size,
307-
std::vector<int> vIndex,
308-
std::vector<float> vY,
309-
std::vector<float> vZ,
310-
std::vector<int> vNOF);
311-
312-
float dist2(point a, point b);
313-
314-
float randf(float m);
315-
316-
int nearest(point pt, point cent, int n_cluster, float *d2);
317-
318-
int reallocate(point pt, std::vector<std::vector<float>> ClusterPosition , float threshold);
319-
320-
float GetDist2D(float y0,float z0,float y1,float z1);
321-
322-
float mean(float y,float z);
323-
324-
void kpp(point pts, int len, point cent, int n_cent);
325-
326-
std::vector<std::vector<float> > lloyd(point pts, int len, int n_cluster);
327-
328-
std::vector<std::vector<float> > GetData(int len,point data);
329-
330-
std::vector<int> CheckCompletude(
331-
std::vector<std::vector<float> > &data,
332-
std::vector<std::vector<float> > &cluster,
333-
float RMS,
334-
float mult);
335-
336-
std::vector<int> CheckClusters(
337-
std::vector<std::vector<float> > &data,
338-
std::vector<std::vector<float> > &cluster,
339-
float RMS,
340-
float mult,
341-
float tmp);
342-
343-
std::vector<ClusterInfo*> GetCluster(
344-
bool fAsConverged,
345-
float CRP_T0,
346-
int n_point,
347-
int n_cluster,
348-
point p,
349-
std::vector<float> vEInd1PointByEvent,
350-
std::vector<float> vEInd2PointByEvent,
351-
std::vector<int> vChInd1PointByEvent,
352-
std::vector<int> vChInd2PointByEvent,
353-
std::vector<float> vEnergyColByEvent,
354-
std::vector<float> vPeakTimeColByEvent,
355-
std::vector<int> vChannelColByEvent,
356-
bool truth,
357-
std::vector<int> vMCPDGByEvent,
358-
std::vector<int> vMCMOMpdgByEvent,
359-
std::vector<float> vMCWeightByEvent,
360-
std::vector<std::string> vGeneratorTagByEvent,
361-
std::vector<float> vMCXByEvent,
362-
std::vector<float> vMCYByEvent,
363-
std::vector<float> vMCZByEvent,
364-
std::vector<int> vNoFByEvent,
365-
std::vector<float> vMCEByEvent,
366-
std::vector<int> vMCNeByEvent);
367-
368-
std::vector<ClusterInfo*> SingleHitAnalysis(
369-
art::Event const& e,
370-
art::InputTag fRDTLabel,
371-
art::InputTag fG4producer,
372-
art::InputTag fHITproducer,
373-
bool bIsPDVD,
374-
bool bIsPDHD,
375-
float fCoincidenceWd1_left,
376-
float fCoincidenceWd1_right,
377-
float fCoincidenceWd2_left,
378-
float fCoincidenceWd2_right,
379-
bool bIs3ViewsCoincidence,
380-
float fPitch,
381-
float fPitchMultiplier,
382-
bool fVerbose,
383-
float fMinSizeCluster,
384-
float fMaxSizeCluster,
385-
float fNumberInitClusters,
386-
float fRadiusInt,
387-
float fRadiusExt,
388-
float fgeoYmin,
389-
float fgeoYmax,
390-
float fgeoZmin,
391-
float fgeoZmax,
392-
float fElectronVelocity,
393-
float fTickTimeInMus);
394-
*/
395209
// declare truth utils, ported from CAFana in SBNCode
396210
std::map<int, std::vector<std::pair<geo::WireID, const sim::IDE*>>>
397211
PrepSimChannels(const std::vector<art::Ptr<sim::SimChannel>> &simchannels,
@@ -421,7 +235,7 @@ class dune::CalibAnaTree : public art::EDAnalyzer {
421235

422236
float fRadiusInt;
423237
float fRadiusExt;
424-
//float fElectronVelocity;
238+
//float fElectronVelocity; //You have a local variable of the same name, and it's only used in analyze(). So commenting this out to make Clang happy.
425239
float fCoincidenceWd1_left;
426240
float fCoincidenceWd1_right;
427241
float fCoincidenceWd2_left;

duneana/CalibAna/CalibAnaTreeObj.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ namespace dune {
7474
end(-1) {}
7575
};
7676

77+
struct ClusterHitInfo {
78+
HitInfo h; //!< Hit information by itself
79+
std::vector<Vector3D> vSpacePoint; //!< Associated LE-SpacePoint created with SingleHit method
80+
//!< Several LE-SpacePoint can be associated to one hit
81+
//!< x coordinate is not reliable x = PeakTime*V_drift
82+
ClusterHitInfo():
83+
vSpacePoint( {Vector3D()} ) {}
84+
85+
};
86+
7787
struct TrackHitInfo {
7888
HitInfo h; //!< Hit information by itself
7989
float pitch; //!< Pitch of track across wire the hit is on [cm]
@@ -330,6 +340,17 @@ namespace dune {
330340
int NumberOfInduction1; //!< number of induction1 wires/channels in cluster
331341
int NumberOfInduction2; //!< number of induction2 wires/channels in cluster
332342

343+
344+
std::vector<ClusterHitInfo> vHitsInfo; //!< vector of HitInfo for all collection hits in the LE-Cluster
345+
//!< verif vHisInfo.size() = NumberOfCollection
346+
347+
//Wire information/Wave-Forms
348+
//<! time window for wave-form = peaktime +/- Rext/V_drift
349+
//<! wire windows spreading of cluster +/- fHitRawDigitsWireCollectWidth (same as for track)
350+
std::vector<WireInfo> wires0; //!< induction 1
351+
std::vector<WireInfo> wires1; //!< induction 2
352+
std::vector<WireInfo> wires2; //!< collection
353+
333354
//truth info
334355
bool truth; //!< yes if truth info no if not
335356
std::vector<float> vMC_energy; //!< vector of energy for collection hits in the cluster

duneana/CalibAna/CalibAnaTree_module.cc

Lines changed: 50 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ dune::CalibAnaTree::CalibAnaTree(fhicl::ParameterSet const& p)
6969
fLowEnergyClusterAnalysis = p.get<bool>("LowEnergyClusterAnalysis", true);
7070
fRDTLabel = p.get<std::string>("RDTLabel","tpcrawdecoder:daq");
7171

72-
fRadiusInt = p.get<float>("RadiusInt");
73-
fRadiusExt = p.get<float>("RadiusExt");
72+
fRadiusInt = p.get<float>("RadiusInt",4);
73+
fRadiusExt = p.get<float>("RadiusExt",10);
7474

7575
fCoincidenceWd1_left = p.get<float>("CoincidenceWindow1_left" ,3); //in mus,
7676
fCoincidenceWd1_right = p.get<float>("CoincidenceWindow1_right",3); //in mus,
@@ -80,7 +80,7 @@ dune::CalibAnaTree::CalibAnaTree(fhicl::ParameterSet const& p)
8080
fPitch = p.get<float>("Pitch",0.5); //cm
8181
fPitchMultiplier = p.get<float>("PitchMultiplier",1.2); // 20% error
8282

83-
bIs3ViewsCoincidence = p.get<bool>("Is3ViewsCoincidence");
83+
bIs3ViewsCoincidence = p.get<bool>("Is3ViewsCoincidence",false);
8484
bIsPDVD = p.get<bool>("IsPDVD",false);
8585
bIsPDHD = p.get<bool>("IsPDHD",false);
8686
bIsFDVD = p.get<bool>("IsFDVD",false);
@@ -272,6 +272,50 @@ void dune::CalibAnaTree::analyze(art::Event const& e)
272272
std::cout<<"Received "<<simchannels.size()<<" SimChannels for this event."<<std::endl;
273273
}
274274

275+
// Collect raw digits for saving hits
276+
std::vector<art::Ptr<raw::RawDigit>> rawdigitlist;
277+
for (const art::InputTag &t: fRawDigitproducers) {
278+
try {
279+
art::ValidHandle<std::vector<raw::RawDigit>> thisdigits = e.getValidHandle<std::vector<raw::RawDigit>>(t);
280+
art::fill_ptr_vector(rawdigitlist, thisdigits);
281+
}
282+
catch(...) {
283+
if (!fSilenceMissingDataProducts) throw;
284+
else { if (fVerbose) {std::cout<<" no raw digits " <<std::endl;}} // Allow Raw Digits to not be present
285+
}
286+
}
287+
288+
// The raw digit list is not sorted, so make it into a map on the WireID
289+
std::map<geo::WireID, art::Ptr<raw::RawDigit>> rawdigits;
290+
for (const art::Ptr<raw::RawDigit> &d: rawdigitlist) {
291+
292+
std::vector<geo::WireID> wids;
293+
// Handle bad channel ID
294+
try {
295+
wids = wireReadout->ChannelToWire(d->Channel());
296+
}
297+
catch(...) {
298+
//Fail if something...fails...
299+
throw cet::exception("CalibAnaTree_module") << "Raw digit " <<
300+
d->Channel() << " has no wires";
301+
}
302+
303+
//We shouldn't ever have a raw digit NOT mapped to a wire
304+
if (wids.size() == 0) {
305+
throw cet::exception("CalibAnaTree_module") << "Raw digit " <<
306+
d->Channel() << " has no wires";
307+
}
308+
309+
//A raw digit can come from multiple wire segments because some wires
310+
//are wrapped
311+
for (const auto & w : wids) {
312+
// Ignore wires that are already mapped
313+
if (rawdigits.count(w)) continue;
314+
rawdigits[w] = d;
315+
}
316+
}
317+
318+
275319
if (fLowEnergyClusterAnalysis)
276320
{
277321
if (fVerbose)
@@ -297,6 +341,9 @@ void dune::CalibAnaTree::analyze(art::Event const& e)
297341
{
298342
fCluster = vCluster[i];
299343
fCluster->meta = fMeta;
344+
//if (fVerbose) std::cout<< " tick window " << fRadiusExt/fElectronVelocity << " wire window " << fHitRawDigitsWireCollectWidth <<std::endl;
345+
FillWireInfoForLECluster(fCluster , fWireReadout , rawdigits , fRadiusExt/fElectronVelocity , fHitRawDigitsWireCollectWidth);
346+
// fRadiusExt/fElectronVelocity is the size (in tt) of the full (cluster + veto)
300347
fTree_LE->Fill();
301348
}
302349
}
@@ -335,49 +382,6 @@ void dune::CalibAnaTree::analyze(art::Event const& e)
335382
art::FindManyP<recob::Hit, recob::TrackHitMeta> fmtrkHits(tracks, e, thm_label);
336383
art::FindManyP<anab::Calorimetry> fmCalo(tracks, e, fCALOproducer);
337384

338-
// Collect raw digits for saving hits
339-
std::vector<art::Ptr<raw::RawDigit>> rawdigitlist;
340-
for (const art::InputTag &t: fRawDigitproducers) {
341-
try {
342-
art::ValidHandle<std::vector<raw::RawDigit>> thisdigits = e.getValidHandle<std::vector<raw::RawDigit>>(t);
343-
art::fill_ptr_vector(rawdigitlist, thisdigits);
344-
}
345-
catch(...) {
346-
if (!fSilenceMissingDataProducts) throw;
347-
else {} // Allow Raw Digits to not be present
348-
}
349-
}
350-
351-
// The raw digit list is not sorted, so make it into a map on the WireID
352-
std::map<geo::WireID, art::Ptr<raw::RawDigit>> rawdigits;
353-
for (const art::Ptr<raw::RawDigit> &d: rawdigitlist) {
354-
355-
std::vector<geo::WireID> wids;
356-
// Handle bad channel ID
357-
try {
358-
wids = wireReadout->ChannelToWire(d->Channel());
359-
}
360-
catch(...) {
361-
//Fail if something...fails...
362-
throw cet::exception("CalibAnaTree_module") << "Raw digit " <<
363-
d->Channel() << " has no wires";
364-
}
365-
366-
//We shouldn't ever have a raw digit NOT mapped to a wire
367-
if (wids.size() == 0) {
368-
throw cet::exception("CalibAnaTree_module") << "Raw digit " <<
369-
d->Channel() << " has no wires";
370-
}
371-
372-
//A raw digit can come from multiple wire segments because some wires
373-
//are wrapped
374-
for (const auto & w : wids) {
375-
// Ignore wires that are already mapped
376-
if (rawdigits.count(w)) continue;
377-
rawdigits[w] = d;
378-
}
379-
}
380-
381385
// Collect all hits
382386
art::ValidHandle<std::vector<recob::Hit>> allhit_handle = e.getValidHandle<std::vector<recob::Hit>>(fHITproducer);
383387
std::vector<art::Ptr<recob::Hit>> allHits;

0 commit comments

Comments
 (0)